فهرست منبع

优惠券问题

shish 5 سال پیش
والد
کامیت
85811e4044

+ 10 - 5
biz-ghs/order/services/OrderService.php

@@ -402,6 +402,7 @@ class OrderService extends BaseService
 
         /**门店资产变化**/
         $amount = $order->actPrice ?? 0.00;
+        $realPrice = $order->realPrice ?? 0.00;
         $currentShopId = $order->shopId ?? 0;
         $shop = ShopClass::getLockById($currentShopId);
         if (empty($shop)) {
@@ -415,7 +416,7 @@ class OrderService extends BaseService
         $shop->totalIncome = $currentTotalIncome;
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
             //客户欠款支付会增加【应收客户款】
-            $currentGathering = bcadd($shop->mayGathering, $amount, 2);
+            $currentGathering = bcadd($shop->mayGathering, $realPrice, 2);
             $shop->mayGathering = $currentGathering;
             //客户第一次欠款的增加一个欠款客户
             if ($custom->debtNum == 0) {
@@ -450,11 +451,15 @@ class OrderService extends BaseService
         ];
         ShopCapitalClass::addCapital($capital);
 
-        //客户采购引起的开单,会增加余额,会增加收入
+        //客户采购,会增加余额,会增加收入
         if ($isPurchase == true) {
             //余额支付和微信支付会增加余额
             if ($payWay == dict::getDict('payWay', 'wxPay') || $payWay == dict::getDict('payWay', 'balancePay')) {
-                ShopClass::customKdAddBalance($shop, $amount, $order, $capitalType);
+                ShopClass::customKdAddBalance($shop, $realPrice, $order, $capitalType);
+            }
+            if (isset($order->discountType) && $order->discountType == dict::getDict('discountType', 'usePtCoupon')) {
+                //客户使用优惠券增加的余额
+                ShopClass::customKdUseCouponAddBalance($shop, $order, $capitalType);
             }
         }
 
@@ -477,9 +482,9 @@ class OrderService extends BaseService
 
         /**客户资产变化**/
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
-            //欠款支付
+            //欠款金额
             $custom->isDebt = CustomClass::IS_DEBT_YES;
-            $custom->debtAmount = bcadd($custom->debtAmount, $amount, 2);
+            $custom->debtAmount = bcadd($custom->debtAmount, $realPrice, 2);
             $custom->debtNum += 1;
         }
         $custom->buyNum += 1;

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

@@ -239,15 +239,14 @@ class PurchaseService extends BaseService
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        $actPrice = $info->actPrice;
         $realPrice = $info->realPrice;
         /**余额支付引起余额减少**/
         if ($payWay == dict::getDict('payWay', 'balancePay')) {
             ShopClass::purchaseReduceBalance($shop, $realPrice, $info);
         }
-        $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
+        $shop->totalPurchase = bcadd($shop->totalPurchase, $realPrice, 2);
         $shop->totalPurchaseOrder += 1;
-        $currentExpend = bcadd($shop->totalExpend, $actPrice, 2);
+        $currentExpend = bcadd($shop->totalExpend, $realPrice, 2);
         $shop->totalExpend = $currentExpend;
         $shop->cgUnPay -= 1;
         $shop->cgUnSend += 1;
@@ -300,7 +299,7 @@ class PurchaseService extends BaseService
             $ghs->debtAmount = bcadd($ghs->debtAmount, $realPrice, 2);
             $ghs->debtNum += 1;
         }
-        $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
+        $ghs->expendAmount = bcadd($ghs->expendAmount, $realPrice, 2);
         $ghs->expendNum += 1;
         $ghs->save();
 

+ 37 - 0
biz/shop/classes/ShopClass.php

@@ -179,6 +179,43 @@ class ShopClass extends BaseClass
         return $gatheringCode;
     }
 
+    //客户使用优惠券增加余额 shish 20210601
+    public static function customKdUseCouponAddBalance($shop, $order, $capitalType)
+    {
+        //门店余额增加
+        $amount = $order->discountAmount;
+        $currentBalance = bcadd($shop->balance, $amount, 2);
+        $shop->balance = $currentBalance;
+        $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
+        //可提现余额同步增加
+        $currentTx = bcadd($shop->txBalance, $amount, 2);
+        $shop->txBalance = $currentTx;
+        $shop->save();
+
+        //增加余额变动记录
+        $id = $order->id;
+        $event = "客户下单 使用平台优惠券{$amount}元";
+        $tx = dict::getDict('yeTx', 'can');
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentBalance,
+            'txBalance' => $currentTx,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'sjId' => $order->sjId,
+            'shopId' => $order->shopId,
+            'tx' => $tx,
+            'ptStyle' => $shop->ptStyle,
+        ];
+        ShopYeChangeClass::addChange($change, true);
+
+        //平台余额增加
+        PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
+    }
+
     //客户下单引起的余额增加 shish 20210520
     public static function customKdAddBalance($shop, $amount, $order, $capitalType)
     {

+ 3 - 3
biz/shop/classes/ShopCouponClass.php

@@ -21,21 +21,21 @@ class ShopCouponClass extends BaseClass
         [
             'name' => '优惠券',
             'amount' => '5',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+6 days",
             'endTime' => "+7 days",
         ],
         [
             'name' => '优惠券',
             'amount' => '10',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+3 days",
             'endTime' => "+7 days",
         ],
         [
             'name' => '优惠券',
             'amount' => '15',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+0 days",
             'endTime' => "+7 days",
         ]