|
@@ -45,6 +45,7 @@ class Orders extends Api{
|
|
|
$productList = request('product_list','[]');
|
|
|
$customCouponId = request('custom_coupon_id',0);
|
|
|
$addrId = request('addr_id',0);
|
|
|
+ $isPay = request('is_pay',0);
|
|
|
// 如果不存在数据
|
|
|
if( !$addrId ) return json_send(['code'=>'error','msg'=>'请选择收货地址','data'=>['error'=>'请选择收货地址']]);
|
|
|
// 解码购买信息
|
|
@@ -338,6 +339,8 @@ class Orders extends Api{
|
|
|
// 删除非必要数据
|
|
|
unset($order['product_list']);
|
|
|
$order['snowflake_id'] = $SnowflakeId;
|
|
|
+ $order['is_pay'] = $isPay;
|
|
|
+ $order['status'] = $isPay ? 0 : 1;
|
|
|
// 创建总订单
|
|
|
$orderId = $Model->add($order);
|
|
|
// 如果订单写入失败
|
|
@@ -351,6 +354,7 @@ class Orders extends Api{
|
|
|
foreach ($productItem as $key=>$value) {
|
|
|
// 增加订单ID
|
|
|
$value['order_id'] = $orderId;
|
|
|
+ $value['status'] = $isPay ? 0 : 1;
|
|
|
// 增加订单ID
|
|
|
$value['insert_time']= $time;
|
|
|
$value['update_time']= $time;
|
|
@@ -377,12 +381,14 @@ class Orders extends Api{
|
|
|
// 提示信息
|
|
|
return json_send(['code'=>'error','msg'=>'地址写入失败','data'=>['error'=>'地址写入失败']]);
|
|
|
}
|
|
|
- // 赠送积分
|
|
|
- if( $order['order_score'] > 0 ) $CustomScore->trade($order['custom_uid'],$orderId,$order['order_score'],5,1);
|
|
|
+ if ($isPay == 0) {
|
|
|
+ // 赠送积分
|
|
|
+ if( $order['order_score'] > 0 ) $CustomScore->trade($order['custom_uid'],$orderId,$order['order_score'],5,1);
|
|
|
+ }
|
|
|
// 如果使用了优惠券
|
|
|
if( $usedCoupon ) $CustomCoupon->edit($usedCoupon,['status'=>1,'order_id'=>$orderId]);
|
|
|
// 购物车
|
|
|
- if( $isCart ) $ShopCart->query()->where([['custom_uid','=',$uid]])->whereIn('skuid',array_column($buyList,'product_skuid'))->delete();
|
|
|
+ if( $isCart ) $ShopCart->query()->whereIn('id',array_column($buyList,'shop_cart_id'))->delete();
|
|
|
}
|
|
|
// 自动发放优惠券
|
|
|
$this->autoCoupon($uid);
|
|
@@ -430,7 +436,7 @@ class Orders extends Api{
|
|
|
// 查询状态
|
|
|
if( $status ) $map[] = ['status','=',$status];
|
|
|
// 查询
|
|
|
- $Paginator = $Model->query()->where($map)->orderByDesc('id')->paginate($limit,['id','pay_total','status','price_total','coupon_total','business_id','pay_total','weizan_orderid','insert_time']);
|
|
|
+ $Paginator = $Model->query()->where($map)->orderByDesc('id')->paginate($limit,['id','regiment_id','is_pay','pay_total','status','price_total','coupon_total','business_id','pay_total','weizan_orderid','insert_time']);
|
|
|
// 订单产品
|
|
|
$productList = $OrdersProduct->query()->whereIn('order_id', array_column($Paginator->items(),'id'))->select(['id as item_id','order_id','product_id','buy_num','is_rebate','sku_attr_names as product_spec','product_name','product_thumb'])->get()->toArray();
|
|
|
// 循环处理
|
|
@@ -656,6 +662,7 @@ class Orders extends Api{
|
|
|
$regimentId = request('regiment_id',0);
|
|
|
$regimentActiveId = request('regiment_active_id',0);
|
|
|
$btnType = request('btn_type',0);
|
|
|
+ $isPay = request('is_pay',0);
|
|
|
$Snowflake = new Snowflake();
|
|
|
$SnowflakeId = $Snowflake->next();
|
|
|
// 如果不存在数据
|
|
@@ -837,8 +844,8 @@ class Orders extends Api{
|
|
|
'custom_uid' => $uid,
|
|
|
'active_id' => $regimentActiveInfo['id'],
|
|
|
'product_id' => $buyInfo['product_id'],
|
|
|
- 'people_number' => 1,
|
|
|
- 'status' => 1,
|
|
|
+ 'people_number' => $isPay ? 0 : 1,
|
|
|
+ 'status' => $isPay ? 4 : 0,
|
|
|
'start_time' => $time,
|
|
|
'end_time' => $time + $regimentActiveInfo['expiration']*3600,
|
|
|
'update_time' => $time,
|
|
@@ -890,10 +897,11 @@ class Orders extends Api{
|
|
|
'active_id' => $regimentActiveInfo['id'],
|
|
|
'product_id' => $buyInfo['product_id'],
|
|
|
'order_id' => $orderId,
|
|
|
+ 'status' => $isPay ? 4 : 0,
|
|
|
'update_time' => $time,
|
|
|
'insert_time' => $time,
|
|
|
];
|
|
|
- if($btnType == 4){
|
|
|
+ if($btnType == 4 && $isPay == 0){
|
|
|
// 拼团人数加1
|
|
|
$inc = Regiment::query()->where('id','=',$regimentId)->increment('people_number',1);
|
|
|
if( !$inc ) {
|