diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 17b1f9c44..ea1816a0a 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;