shish пре 10 месеци
родитељ
комит
13149a73c1
2 измењених фајлова са 47 додато и 3 уклоњено
  1. 9 3
      biz-hd/order/classes/ScanPayClass.php
  2. 38 0
      biz/shop/classes/ShopClass.php

+ 9 - 3
biz-hd/order/classes/ScanPayClass.php

@@ -76,12 +76,18 @@ class ScanPayClass extends BaseClass
         $order->payTime = $date;
         $order->returnCode = $transactionId;
         $order->save();
-        self::payAfter($order, $payWay);
+        self::payAfter($order);
     }
 
-    public static function payAfter($order, $payWay)
+    public static function payAfter($order)
     {
-
+        $capitalType = dict::getDict('capitalType', 'scanPay', 'id');
+        $mainId = $order->mainId;
+        $shopId = $order->shopId;
+        $amount = $order->actPrice ?? 0;
+        $main = MainClass::getById($mainId, true);
+        $shop = ShopClass::getLockById($shopId);
+        ShopClass::customScanPayAddBalance($main, $shop, $amount, $order, $capitalType);
     }
 
 }

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

@@ -447,6 +447,44 @@ class ShopClass extends BaseClass
         PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
     }
 
+    public static function customScanPayAddBalance($main, $shop, $amount, $order, $capitalType)
+    {
+        //门店余额增加
+        $mainId = $shop->mainId ?? 0;
+        $currentBalance = bcadd($main->balance, $amount, 2);
+        $main->balance = $currentBalance;
+        //可提现余额同步增加
+        $currentTx = bcadd($main->txBalance, $amount, 2);
+        $main->txBalance = $currentTx;
+        $main->save();
+
+        $customName = '客户';
+        $customId = $order->customId ?? 0;
+        $custom = \bizHd\custom\classes\CustomClass::getById($customId, true);
+        if (!empty($custom->name)) {
+            $customName = $custom->name;
+        }
+
+        //增加余额变动记录
+        $id = $order->id;
+        $event = $customName . "扫码付款" . floatval($amount) . "元";
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentBalance,
+            'txBalance' => $currentTx,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'mainId' => $mainId,
+            'tx' => 2,
+            'ptStyle' => $shop->ptStyle,
+            'fromType' => 1,
+        ];
+        ShopYeChangeClass::addChange($change, true);
+    }
+
     //门店充值增加余额 ssh 2021.2.21
     //$fix = true 余额只能在指定门店使用
     public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)