|
@@ -10,6 +10,7 @@ |
|
@@ -10,6 +10,7 @@ |
10
|
// +----------------------------------------------------------------------
|
10
|
// +----------------------------------------------------------------------
|
11
|
namespace app\api\controller;
|
11
|
namespace app\api\controller;
|
12
|
|
12
|
|
|
|
13
|
+use app\admin\model\Car;
|
13
|
use app\admin\model\Ogoods;
|
14
|
use app\admin\model\Ogoods;
|
14
|
use app\admin\model\Order;
|
15
|
use app\admin\model\Order;
|
15
|
use app\admin\model\Rcoupon;
|
16
|
use app\admin\model\Rcoupon;
|
|
@@ -506,6 +507,15 @@ class Common |
|
@@ -506,6 +507,15 @@ class Common |
506
|
}
|
507
|
}
|
507
|
|
508
|
|
508
|
/**
|
509
|
/**
|
|
|
510
|
+ * 删购物车
|
|
|
511
|
+ * @ApiInternal
|
|
|
512
|
+ */
|
|
|
513
|
+ public static function deleteCar($where){
|
|
|
514
|
+ $carModel = new Car();
|
|
|
515
|
+ $carModel->where($where)->delete();
|
|
|
516
|
+ }
|
|
|
517
|
+
|
|
|
518
|
+ /**
|
509
|
* 更新优惠券
|
519
|
* 更新优惠券
|
510
|
* @ApiInternal
|
520
|
* @ApiInternal
|
511
|
*/
|
521
|
*/
|
|
@@ -515,7 +525,7 @@ class Common |
|
@@ -515,7 +525,7 @@ class Common |
515
|
}
|
525
|
}
|
516
|
|
526
|
|
517
|
/**
|
527
|
/**
|
518
|
- * 购买成功,更新订单号为待发货,销量增加1,减库存,
|
528
|
+ * 购买成功,更新订单号为待发货,销量增加1,减库存,删除购物车
|
519
|
* @ApiInternal
|
529
|
* @ApiInternal
|
520
|
*/
|
530
|
*/
|
521
|
public static function paySuccess($out_trade_no){
|
531
|
public static function paySuccess($out_trade_no){
|
|
@@ -524,12 +534,16 @@ class Common |
|
@@ -524,12 +534,16 @@ class Common |
524
|
$orderModel = new Order();
|
534
|
$orderModel = new Order();
|
525
|
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
|
535
|
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
|
526
|
//销量增加1
|
536
|
//销量增加1
|
527
|
- $res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id');
|
537
|
+ $res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id,uid');
|
528
|
if($res){
|
538
|
if($res){
|
529
|
$res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id');
|
539
|
$res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id');
|
530
|
$g_ids = array_column($res1,'g_id');
|
540
|
$g_ids = array_column($res1,'g_id');
|
|
|
541
|
+ //减库存
|
531
|
self::decStock(['id'=>['in',$g_ids]]);
|
542
|
self::decStock(['id'=>['in',$g_ids]]);
|
|
|
543
|
+ //增加销售
|
532
|
self::incSales(['id'=>['in',$g_ids]]);
|
544
|
self::incSales(['id'=>['in',$g_ids]]);
|
|
|
545
|
+ //删除购物车
|
|
|
546
|
+ self::deleteCar(['uid'=>$res['uid'],'g_id'=>['in',$g_ids]]);
|
533
|
}
|
547
|
}
|
534
|
}
|
548
|
}
|
535
|
} |
549
|
} |