From 9e0e1524f2442bf903d7d05be7f5f1425ebac42f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 11:16:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(order):=20=E6=B7=BB=E5=8A=A0=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E9=80=89=E6=8B=A9=E5=88=A4=E6=96=AD=E5=92=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 17b1f9c4..ea1816a0 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -66,6 +66,11 @@ class OrderLogic extends BaseLogic */ static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0) { + if(empty($params['store_id']) || $params['store_id'] <= 0){ + self::setError('请选择门店'); + return false; + } + $where = ['is_pay' => 0]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); if (empty($cart_select)) { @@ -84,9 +89,9 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; + $field = 'product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field($field)->find(); if (!$find) { self::setError('商品不存在'); return false; @@ -114,7 +119,8 @@ class OrderLogic extends BaseLogic $price = $find['cost']; } else { $price = $find['price']; - if (isset($params['store_id']) && $params['store_id'] == getenv('ACTIVITY_STORE_ID')) { + //单门店活动判断 + if ($params['store_id'] == getenv('ACTIVITY_STORE_ID')) { $storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price'); if ($storeBranchPrice) { $price = $storeBranchPrice;