...
|
...
|
@@ -479,6 +479,24 @@ class Common |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 减库存
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function decStock($where){
|
|
|
$goodsModel = new \app\admin\model\Goods();
|
|
|
$goodsModel->where($where)->setDec('stock',1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 增销量
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function incSales($where){
|
|
|
$goodsModel = new \app\admin\model\Goods();
|
|
|
$goodsModel->where($where)->setInc('sales',1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新优惠券
|
|
|
* @ApiInternal
|
|
|
*/
|
...
|
...
|
@@ -488,17 +506,21 @@ class Common |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购买成功,更新订单号,销量增加1
|
|
|
* 购买成功,更新订单号为待发货,销量增加1,减库存,
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function incSales($out_trade_no){
|
|
|
public static function paySuccess($out_trade_no){
|
|
|
$status = config('verify.status');
|
|
|
//更新订单号成功
|
|
|
$orderModel = new Order();
|
|
|
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
|
|
|
$goodsModel = new \app\admin\model\Goods();
|
|
|
//销量增加1
|
|
|
$res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id');
|
|
|
$goodsModel->where(['id'=>$res['id']])->setInc('sales',1);
|
|
|
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]]);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|