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 = '';