From 7c35d4e504b631c6e0c261e95d3a68fc52a1ccf9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 16:38:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A4=84=E7=90=86=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E5=92=8C=E9=94=80=E5=94=AE=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 3fcabb03b..e016bff55 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -203,12 +203,15 @@ class OrderLogic extends BaseLogic $goods_list[$k]['uid'] = request()->userId; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $stock = StoreBranchProduct::where('id',$v['branch_product_id'])->value('stock'); + $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->find(); $updateData[] = [ 'id' => $v['branch_product_id'], - 'stock' => $stock-$v['cart_num'], + 'stock' => $StoreBranchProduct['stock']-$v['cart_num'], 'sales' => ['inc', $v['cart_num']] ]; + if($StoreBranchProduct['stock']-$v['cart_num']<=0){ + Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]); + } } (new StoreOrderCartInfo())->saveAll($goods_list); (new StoreBranchProduct())->saveAll($updateData);