Sfoglia il codice sorgente

充值增加金额

shish 2 anni fa
parent
commit
abb85de5ad

+ 10 - 0
biz-ghs/custom/classes/CustomRechargeClass.php

@@ -2,7 +2,9 @@
 
 namespace bizGhs\custom\classes;
 
+use biz\shop\classes\ShopClass;
 use bizGhs\ghs\classes\GhsRechargeClass;
+use bizGhs\shop\classes\MainClass;
 use bizHd\ghs\classes\GhsClass;
 use common\components\dict;
 use common\components\noticeUtil;
@@ -140,6 +142,14 @@ class CustomRechargeClass extends BaseClass
         $ghsRecharge->save();
         $customRecharge->balance = $custom->balance;
         $customRecharge->save();
+
+        if ($customRecharge->onlinePay == dict::getDict('onlinePay', 'yes')) {
+            //供货商门店余额增加
+            $ghsShop = ShopClass::getById($ghsShopId, true);
+            $ghsMain = MainClass::getLockById($ghsMainId);
+            ShopClass::customRechargeAddBalance($ghsMain, $ghsShop, $customRecharge);
+        }
+
     }
 
 }

+ 58 - 0
biz/pt/classes/PtAssetClass.php

@@ -61,6 +61,64 @@ class PtAssetClass extends BaseClass
         PtYeChangeClass::addChange($change, true);
     }
 
+    //客户充值增加余额 ssh 20240508
+    public static function customRechargeAddBalance($shop, $order, $capitalType, $tx)
+    {
+        $amount = $order->amount ?? 0;
+        $ptStyle = $shop->ptStyle;
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $asset = self::getHdBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $asset = self::getGhsBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentAmount = bcadd($asset->amount, $amount, 2);
+        $asset->amount = $currentAmount;
+        $asset->save();
+
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $txAsset = self::getHdTxBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $txAsset = self::getGhsTxBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentTxBalance = $txAsset->amount;
+        if ($tx == dict::getDict('yeTx', 'can')) {
+            $currentTxBalance = bcadd($currentTxBalance, $amount, 2);
+            $txAsset->amount = $currentTxBalance;
+            $txAsset->save();
+        }
+        $sjName = $shop->merchantName ?? '';
+        if (isset($shop->default) == false || $shop->default != 1 || $shop->shopName != '首店') {
+            $sjName .= ' ' . $shop->shopName;
+        }
+
+        $id = $order->id;
+        $event = "客户向商家-{$sjName}充值(单号:{$order->orderSn})";
+        $mainId = $shop->mainId ?? 0;
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentAmount,
+            'txBalance' => $currentTxBalance,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'sjId' => $order->sjId,
+            'shopId' => $order->shopId,
+            'mainId' => $order->mainId ?? 0,
+            'tx' => $tx,
+            'ptStyle' => $ptStyle,
+            'shopName' => $shop->shopName,
+            'sjName' => $shop->merchantName,
+            'mainId' => $mainId,
+        ];
+        PtYeChangeClass::addChange($change, true);
+    }
+
     //客户结帐增加加余额 ssh 20210729
     public static function customClearAddBalance($shop, $order, $capitalType, $tx)
     {

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

@@ -215,6 +215,43 @@ class ShopClass extends BaseClass
         return $imgUrl;
     }
 
+    //客户充值增加余额 ssh 20240508
+    public static function customRechargeAddBalance($main, $shop, $order)
+    {
+        $mainId = $shop->mainId ?? 0;
+        $balance = bcadd($main->balance, $order->actPrice, 2);
+        $txBalance = bcadd($main->txBalance, $order->actPrice, 2);
+        $main->balance = $balance;
+        $main->txBalance = $txBalance;
+        $main->save();
+        $rechargeId = $order->id ?? 0;
+        $tx = dict::getDict('yeTx', 'can');
+        $capitalType = dict::getDict('capitalType', 'customRechargeToGhs', 'id');
+        $custom = '客户';
+        if (isset($order->customName) && !empty($order->customName)) {
+            $custom = $order->customName;
+        }
+        $change = [
+            'relateId' => $rechargeId,
+            'capitalType' => $capitalType,
+            'amount' => $order->amount,
+            'balance' => $balance,
+            'txBalance' => $txBalance,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $custom . "充值(单号:{$order->orderSn})",
+            'sjId' => $shop->sjId,
+            'shopId' => $shop->id,
+            'mainId' => $shop->mainId,
+            'tx' => $tx,
+            'ptStyle' => $shop->ptStyle,
+            'mainId' => $mainId,
+        ];
+        ShopYeChangeClass::addChange($change, true);
+        //平台余额增加
+        PtAssetClass::customRechargeAddBalance($shop, $order, $capitalType, $tx);
+    }
+
     //客户结帐增加余额 ssh 20210729
     public static function customClearAddBalance($main, $shop, $order)
     {