shish 5 лет назад
Родитель
Сommit
c9e97b8587

+ 6 - 0
biz-ghs/order/classes/OrderClass.php

@@ -119,6 +119,12 @@ class OrderClass extends BaseClass
         $currentPrice = bcadd($price, $sendCost, 2);
         $data['actPrice'] = $currentPrice;
         $data['prePrice'] = $currentPrice;
+        $data['realPrice'] = $currentPrice;
+        //如果有平台补贴
+        if (isset($data['discountType']) && $data['discountType'] == dict::getDict('discountType', 'usePtCoupon')) {
+            $discountAmount = $data['discountAmount'] ?? 0;
+            $data['realPrice'] = bcsub($currentPrice, $discountAmount, 2);
+        }
 
         //将花店每月的总   订单数作为编号
         $data['sendNum'] = StatOrderCountClass::addOrder($month, $sjId);

+ 3 - 4
biz-hd/purchase/classes/PurchaseClass.php

@@ -122,6 +122,7 @@ class PurchaseClass extends BaseClass
         $sendCost = $data['sendCost'] ?? 0.00;
         $prePrice = bcadd($prePrice, $sendCost, 2);
         $actPrice = $prePrice;
+        $realPrice = $actPrice;
 
         //验证优惠券
         $couponId = isset($data['couponId']) ? $data['couponId'] : 0;
@@ -136,14 +137,14 @@ class PurchaseClass extends BaseClass
             }
             $coupon->take = ShopCouponClass::TAKE_HAS;
             $coupon->save();
-            $actPrice = bcsub($prePrice, $coupon->amount, 2);
+            $realPrice = bcsub($actPrice, $coupon->amount, 2);
             $data['discountType'] = dict::getDict('discountType', 'usePtCoupon');
             $data['discountAmount'] = $coupon->amount;
         }
         $data['couponId'] = $couponId;
-
         $data['prePrice'] = $prePrice;
         $data['actPrice'] = $actPrice;
+        $data['realPrice'] = $realPrice;
         $data['bigNum'] = $bigNum;
         $data['smallNum'] = $smallNum;
         //采购单有效期
@@ -155,7 +156,6 @@ class PurchaseClass extends BaseClass
             util::fail('请选择花材');
         }
         PurchaseItemClass::batchAdd($productList);
-
         $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
@@ -174,7 +174,6 @@ class PurchaseClass extends BaseClass
 
         $ghsIds = array_unique(array_filter(array_column($list, 'ghsId')));
         $ghsInfo = GhsClass::getGhsByIds($ghsIds);
-
         $adminIds = array_unique(array_filter(array_column($list, 'adminId')));
         $adminInfo = AdminClass::getAdminByIds($adminIds, null, 'id');
 

+ 4 - 5
biz-hd/purchase/services/PurchaseService.php

@@ -56,7 +56,6 @@ class PurchaseService extends BaseService
         $couponId = $data['couponId'] ?? 0;
         $discountType = $respond->discountType ?? dict::getDict('discountType', 'noDiscount');
         $discountAmount = $respond->discountAmount ?? 0;
-        $customPrice = $respond->actPrice;
         $arr = [
             'product' => $product,
             'sjId' => $currentSjId,
@@ -82,7 +81,6 @@ class PurchaseService extends BaseService
             'couponId' => $couponId,
             'discountType' => $discountType,
             'discountAmount' => $discountAmount,
-            'customPrice' => $customPrice,
         ];
         $result = OrderClass::addOrder($arr);
         $saleId = $result['id'] ?? 0;
@@ -237,9 +235,10 @@ class PurchaseService extends BaseService
             util::fail('没有找到门店');
         }
         $actPrice = $info->actPrice;
+        $realPrice = $info->realPrice;
         /**余额支付引起余额减少**/
         if ($payWay == dict::getDict('payWay', 'balancePay')) {
-            ShopClass::purchaseReduceBalance($shop, $actPrice, $info);
+            ShopClass::purchaseReduceBalance($shop, $realPrice, $info);
         }
         $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
         $shop->totalPurchaseOrder += 1;
@@ -249,7 +248,7 @@ class PurchaseService extends BaseService
         $shop->cgUnSend += 1;
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
             //欠款支付会增加【应付供货商款】
-            $currentMayPay = bcadd($shop->mayPay, $actPrice, 2);
+            $currentMayPay = bcadd($shop->mayPay, $realPrice, 2);
             $shop->mayPay = $currentMayPay;
         }
         $shop->save();
@@ -274,7 +273,7 @@ class PurchaseService extends BaseService
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
             //欠款支付
             $ghs->debt = 2;
-            $ghs->debtAmount = bcadd($ghs->debtAmount, $actPrice, 2);
+            $ghs->debtAmount = bcadd($ghs->debtAmount, $realPrice, 2);
             $ghs->debtNum += 1;
         }
         $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);