From 4bf661fba06974e788a9f81ec88d88e90fce54a9 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 17 Jun 2024 17:37:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/controller/store_order/StoreOrderController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index b9f70c37b..e09ce0c47 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -136,13 +136,15 @@ class StoreOrderController extends BaseAdminController public function checkSms() { $params = (new StoreOrderValidate())->post()->goCheck('check'); - $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 $user= User::where('id',$params['uid'])->find(); if(empty($user)){ return $this->fail('无该用户请检查'); } $order = StoreOrderLogic::cartIdByOrderInfo($params['cart_id'], null, $user, $params); + if(!$order){ + return $this->fail(StoreOrderLogic::getError()); + } if($order['order']['pay_price'] > $user['purchase_funds']){ return $this->fail('当前用户采购款不足支付'); } From c0c61dd042049d69c63b9536d780dfd1c8ab908c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 17 Jun 2024 17:38:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E6=97=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E7=94=A8=E6=88=B7=E4=B8=BA=E5=BD=93=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=BA=E6=91=8A=E8=B4=A9/=E9=85=92=E5=BA=97/=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E6=97=B6,=E8=BF=94=E5=9B=9E=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index ccb309821..20fe8d784 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -47,6 +47,7 @@ class OrderLogic extends BaseLogic public static $pay_price; public static $cost; public static $profit; + public static $store_price;//门店零售价 public static $activity_price; /** @@ -69,6 +70,7 @@ class OrderLogic extends BaseLogic self::$cost = 0; //成本由采购价替代原成本为门店零售价 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 + self::$store_price = 0; //门店零售价 /** 计算价格 */ foreach ($cart_select as $k => $v) { @@ -77,11 +79,9 @@ class OrderLogic extends BaseLogic continue; } unset($cart_select[$k]['id']); - if($user && in_array($user['user_ship'],UserShipEnum::DISCOUNT_ARRAY)){ - $find['price'] = $find['cost']; - } $cart_select[$k]['price'] = $find['price']; + $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 @@ -94,6 +94,7 @@ class OrderLogic extends BaseLogic // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 + $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2)??0; //门店零售价 $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; @@ -114,9 +115,17 @@ class OrderLogic extends BaseLogic self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); + self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } + $preferential_amount = 0;//差价(用户为UserShipEnum::DISCOUNT_ARRAY 的时候的优惠差价) + $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 + if($user && in_array($user['user_ship'],UserShipEnum::DISCOUNT_ARRAY)){ + $pay_price =bcsub(self::$store_price, self::$activity_price, 2); //减去活动优惠金额 + $preferential_amount = bcsub(self::$pay_price,self::$store_price,2); + } + $vipPrice = 0; //成本价 收益 $order = [ @@ -138,6 +147,7 @@ class OrderLogic extends BaseLogic 'activities' => self::$activity_price>0?1:0, 'deduction_price' => self::$activity_price, 'is_vip' => 0, + 'preferential_amount' => $preferential_amount, ]; $order['default_delivery'] = 0;