feat: 修改订单逻辑和任务处理,优化商品处理流程
This commit is contained in:
parent
3e6abe5957
commit
e90e666738
@ -83,27 +83,12 @@ class OrderLogic extends BaseLogic
|
||||
self::$fresh_price = 0; //生鲜金额
|
||||
/** 计算价格 */
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose';
|
||||
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose';
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
|
||||
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
|
||||
if (!$find) {
|
||||
// unset($cart_select[$k]);
|
||||
// continue;
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id,store_info,rose';
|
||||
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
|
||||
if ($find) {
|
||||
$cate_id = StoreCategory::where('id', $find['cate_id'])->value('pid');
|
||||
if ($cate_id > 0) {
|
||||
$cate_id = StoreCategory::where('id', $cate_id)->value('pid');
|
||||
if ($cate_id > 0) {
|
||||
$cate_id = StoreCategory::where('id', $cate_id)->value('pid');
|
||||
$find['top_cate_id'] = $cate_id;
|
||||
} else {
|
||||
$find['top_cate_id'] = $cate_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cart_select[$k]['status'] = 1; //缺货标识
|
||||
self::setError('商品不存在');
|
||||
return false;
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
@ -152,7 +137,6 @@ class OrderLogic extends BaseLogic
|
||||
$cartInfo['name'] = $find['store_name'];
|
||||
$cartInfo['image'] = $find['image'];
|
||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||
$cart_select[$k]['branch_product_id'] = $find['branch_product_id'];
|
||||
//理论上每笔都是拆分了
|
||||
$cart_select[$k]['name'] = $find['store_name'];
|
||||
$cart_select[$k]['imgs'] = $find['image'];
|
||||
@ -339,11 +323,14 @@ class OrderLogic extends BaseLogic
|
||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||
|
||||
$updateData[] = [
|
||||
'id' => $v['branch_product_id'],
|
||||
'sales' => ['inc', $v['cart_num']],
|
||||
'stock' => ['dec', $v['cart_num']],
|
||||
];
|
||||
$id=StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$params['store_id'])->value('id');
|
||||
if($id){
|
||||
$updateData[] = [
|
||||
'id' => $id,
|
||||
'sales' => ['inc', $v['cart_num']],
|
||||
'stock' => ['dec', $v['cart_num']],
|
||||
];
|
||||
}
|
||||
$updateDataTwo[] = [
|
||||
'id' => $v['product_id'],
|
||||
'sales' => ['inc', $v['cart_num']]
|
||||
|
@ -30,11 +30,14 @@ class Task
|
||||
$updateData = [];
|
||||
$updateDataTwo = [];
|
||||
foreach ($arr as $v) {
|
||||
$updateData[] = [
|
||||
'id' => $v['branch_product_id'],
|
||||
'sales' => ['dec', $v['cart_num']],
|
||||
'stock' => ['inc', $v['cart_num']],
|
||||
];
|
||||
$id=StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$v['store_id'])->value('id');
|
||||
if($id){
|
||||
$updateData[] = [
|
||||
'id' => $id,
|
||||
'sales' => ['dec', $v['cart_num']],
|
||||
'stock' => ['inc', $v['cart_num']],
|
||||
];
|
||||
}
|
||||
$updateDataTwo[] = [
|
||||
'id' => $v['product_id'],
|
||||
'sales' => ['dec', $v['cart_num']]
|
||||
|
Loading…
x
Reference in New Issue
Block a user