...
|
...
|
@@ -544,9 +544,9 @@ class Common |
|
|
* 增销量
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function incSales($where){
|
|
|
public static function incSales($where,$sale_number){
|
|
|
$goodsModel = new \app\admin\model\Goods();
|
|
|
$goodsModel->where($where)->setInc('sales',1);
|
|
|
$goodsModel->where($where)->setInc('sales',$sale_number);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -579,7 +579,7 @@ class Common |
|
|
//销量增加1
|
|
|
$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,style');
|
|
|
$res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id,style,goods_number');
|
|
|
$g_ids = array_column($res1,'g_id');
|
|
|
//减库存
|
|
|
$goodsModel = new \app\admin\model\Goods();
|
...
|
...
|
@@ -587,19 +587,21 @@ class Common |
|
|
$res_stock = self::selectSoftWhereData('goods',['id'=>['in',$g_ids]],'id,style g_style,stock');
|
|
|
foreach($res_stock as $g_value){
|
|
|
$arr_stock = explode('|',$g_value['stock']);
|
|
|
$sale_number = 1;
|
|
|
foreach($res1 as $value){
|
|
|
if($g_value['id'] == $value['g_id']){
|
|
|
$s_index = array_search($value['style'],self::salePrice($g_value['g_style']));
|
|
|
$stock = self::salePrice($g_value['stock'])[$s_index] - 1;
|
|
|
$stock = self::salePrice($g_value['stock'])[$s_index] - $value['goods_number'];
|
|
|
$arr_stock[$s_index] = $stock;
|
|
|
$sale_number = $value['goods_number'];
|
|
|
}
|
|
|
}
|
|
|
//更新库存
|
|
|
$stock1 = implode('|',$arr_stock);
|
|
|
$goodsModel->where(['id'=>$g_value['id']])->update(['stock'=>$stock1]);
|
|
|
//增加销售
|
|
|
self::incSales(['id'=>['in',$g_ids]],$sale_number);
|
|
|
}
|
|
|
//增加销售
|
|
|
self::incSales(['id'=>['in',$g_ids]]);
|
|
|
//删除购物车
|
|
|
self::deleteCar(['uid'=>$res['uid'],'g_id'=>['in',$g_ids]]);
|
|
|
}
|
...
|
...
|
|