From fb8460e1a90c1f179c20bb9411d90d95b4ec24ab Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 22 Jun 2024 18:59:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=91=E6=8D=A2=E6=95=B0=E9=87=8F=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/store_order/StoreOrderLogic.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 07c64b3e3..088e87c8b 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -50,8 +50,9 @@ class StoreOrderLogic extends BaseLogic self::$activity_price = 0; //活动减少 self::$store_price = 0; //门店零售价 /** 计算价格 */ + $pay_type = isset($params['pay_type'])?$params['pay_type']:0; foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,swap')->withTrashed()->find(); if (!$find) { continue; } @@ -75,6 +76,11 @@ class StoreOrderLogic extends BaseLogic $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); $cart_select[$k]['deduction_price'] =$deduction_price_count; self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + } + if($pay_type ==19){ + if ($find['swap'] < $cart_select[$k]['cart_num']) { + throw new \Exception('兑换数量不足'); + } } //利润 // $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润 @@ -111,7 +117,6 @@ class StoreOrderLogic extends BaseLogic self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } - $pay_type = isset($params['pay_type'])?$params['pay_type']:0; if ($user && $user['user_ship'] == 1 && $pay_type !=17) { $pay_price = self::$pay_price; $activity_string = '';