...
|
...
|
@@ -10,6 +10,7 @@ |
|
|
// +----------------------------------------------------------------------
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\admin\model\Car;
|
|
|
use app\admin\model\Ogoods;
|
|
|
use app\admin\model\Order;
|
|
|
use app\admin\model\Rcoupon;
|
...
|
...
|
@@ -506,6 +507,15 @@ class Common |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删购物车
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function deleteCar($where){
|
|
|
$carModel = new Car();
|
|
|
$carModel->where($where)->delete();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新优惠券
|
|
|
* @ApiInternal
|
|
|
*/
|
...
|
...
|
@@ -515,7 +525,7 @@ class Common |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购买成功,更新订单号为待发货,销量增加1,减库存,
|
|
|
* 购买成功,更新订单号为待发货,销量增加1,减库存,删除购物车
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function paySuccess($out_trade_no){
|
...
|
...
|
@@ -524,12 +534,16 @@ class Common |
|
|
$orderModel = new Order();
|
|
|
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
|
|
|
//销量增加1
|
|
|
$res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id');
|
|
|
$res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id,uid');
|
|
|
if($res){
|
|
|
$res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id');
|
|
|
$g_ids = array_column($res1,'g_id');
|
|
|
//减库存
|
|
|
self::decStock(['id'=>['in',$g_ids]]);
|
|
|
//增加销售
|
|
|
self::incSales(['id'=>['in',$g_ids]]);
|
|
|
//删除购物车
|
|
|
self::deleteCar(['uid'=>$res['uid'],'g_id'=>['in',$g_ids]]);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|