|
|
|
@ -370,7 +370,7 @@ class Order extends Api |
|
|
|
|
if ($status != "") { |
|
|
|
|
$where['status'] = ['in', explode(",", $status)]; |
|
|
|
|
} else { |
|
|
|
|
$where['status'] = ['in', [-1,0,1,2,3,4,5,6]]; |
|
|
|
|
$where['status'] = ['in', [-1,0,1,2,3,4,5]]; |
|
|
|
|
} |
|
|
|
|
$list = OrderModel::where('buyer_id', $user_id)->where($where)->order('id', 'desc')->paginate($this->request->param('list_rows', $limit))->each(function ($item, $key){ |
|
|
|
|
$order_goods = Detail::where('order_id', $item['id'])->select(); |
|
|
|
@ -594,12 +594,46 @@ class Order extends Api |
|
|
|
|
//修改用户可用佣金 |
|
|
|
|
User::where('id', $user_id)->update(['available_commission_amount' => $user['available_commission_amount'] - $pay_amount,"profit_amount" => $user['profit_amount'] + $profit, "updatetime" => time()]); |
|
|
|
|
//更新订单信息 |
|
|
|
|
OrderModel::where("id", $order_id)->update(['status' => 7]); |
|
|
|
|
OrderModel::where("id", $order_id)->update(['status' => 6]); |
|
|
|
|
Detail::where("order_id", $order_id)->update(['commission_price' => $goods_price, "fee" => $fee, "dikou_price" => $pay_amount]); |
|
|
|
|
//使用优惠卷 |
|
|
|
|
if ($coupon_id) { |
|
|
|
|
UserCouponModel::where('id', $coupon_id)->update(['use_order_id'=>$order_id, "use_time"=>time()]); |
|
|
|
|
} |
|
|
|
|
//新增卖单 |
|
|
|
|
$order_sn = "ZH".date("YmdHis").rand(1000,9999); |
|
|
|
|
//创建订单 |
|
|
|
|
$orderData = [ |
|
|
|
|
"order_type" => 1, |
|
|
|
|
"user_id" => $user_id, |
|
|
|
|
"sell_order_id" => 0, |
|
|
|
|
"buyer_id" => 0, |
|
|
|
|
"seller_id" => $user_id, |
|
|
|
|
"order_sn" => $order_sn, |
|
|
|
|
"warehouse_id" => $order['warehouse_id'], |
|
|
|
|
"order_amount" => intval($goods_price), |
|
|
|
|
"pay_amount" => intval($goods_price), |
|
|
|
|
"coupon_price" => 0, |
|
|
|
|
"coupon_id" => 0, |
|
|
|
|
"status" => 3, |
|
|
|
|
]; |
|
|
|
|
$order1 = OrderModel::create($orderData); |
|
|
|
|
|
|
|
|
|
$goods1 = Goods::where('id', $goods['goods_id'])->find(); |
|
|
|
|
$orderDetail = [ |
|
|
|
|
"order_id" => $order1->id, |
|
|
|
|
"buyer_id" => 0, |
|
|
|
|
"seller_id" => $user_id, |
|
|
|
|
"goods_id" => $goods1['id'], |
|
|
|
|
"goods_name" => $goods1['name'], |
|
|
|
|
"goods_image" => $goods1['image'], |
|
|
|
|
"goods_price" => intval($goods_price), |
|
|
|
|
"num" => 1, |
|
|
|
|
]; |
|
|
|
|
$ret = Detail::create($orderDetail); |
|
|
|
|
if ($ret === false) { |
|
|
|
|
$this->error("下单失败"); |
|
|
|
|
} |
|
|
|
|
$this->success('succ', ['pay_data' => 1]); |
|
|
|
|
} else { |
|
|
|
|
if ($user['available_commission_amount'] > 0) { |
|
|
|
|