shish 2 ヶ月 前
コミット
db7af82084

+ 1 - 1
biz-ghs/custom/classes/CustomRechargeClass.php

@@ -308,7 +308,7 @@ class CustomRechargeClass extends BaseClass
             'remark' => '',
         ], true);
 
-        // 线上充值曾增加门店 xhMain 余额,退款时对称扣减
+        // 线上充值曾增加门店 xhMain 余额,退款时对称扣减(不操作平台资产 PtAsset)
         if ($isOnline) {
             $ghsShopId = intval($customRecharge->shopId ?? 0);
             $ghsShop = ShopClass::getById($ghsShopId, true);

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

@@ -119,72 +119,6 @@ class PtAssetClass extends BaseClass
         PtYeChangeClass::addChange($change, true);
     }
 
-    /**
-     * 客户线上充值退款:扣减平台资产(与 customRechargeAddBalance 对称)。
-     */
-    public static function customRechargeRefundReduceBalance($shop, $order, $capitalType, $tx, $staffName = '')
-    {
-        $amount = bcadd((string)($order->amount ?? '0'), '0', 2);
-        if (bccomp($amount, '0', 2) <= 0) {
-            return;
-        }
-        $ptStyle = $shop->ptStyle ?? 0;
-        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
-            $asset = self::getHdBalance();
-        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
-            $asset = self::getGhsBalance();
-        } else {
-            util::fail('没有找到平台');
-        }
-        $currentAmount = bcsub((string)($asset->amount ?? '0'), $amount, 2);
-        if (bccomp($currentAmount, '0', 2) < 0) {
-            util::fail('平台余额不足,无法退款');
-        }
-        $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 ?? 0;
-        if ($tx == dict::getDict('yeTx', 'can')) {
-            $currentTxBalance = bcsub((string)$currentTxBalance, $amount, 2);
-            if (bccomp($currentTxBalance, '0', 2) < 0) {
-                $currentTxBalance = '0.00';
-            }
-            $txAsset->amount = $currentTxBalance;
-            $txAsset->save();
-        }
-        $sjName = $shop->merchantName ?? '';
-        if (!isset($shop->default) || $shop->default != 1 || ($shop->shopName ?? '') != '首店') {
-            $sjName .= ' ' . ($shop->shopName ?? '');
-        }
-        $operator = $staffName !== '' ? "(操作人:{$staffName})" : '';
-        $event = "客户向商家-{$sjName}充值退款{$operator},单号:" . ($order->orderSn ?? '');
-        $change = [
-            'relateId' => $order->id ?? 0,
-            'capitalType' => $capitalType,
-            'amount' => $amount,
-            'balance' => $currentAmount,
-            'txBalance' => $currentTxBalance,
-            'io' => 0,
-            'payWay' => $order->payWay ?? 0,
-            'event' => $event,
-            'sjId' => $order->sjId ?? ($shop->sjId ?? 0),
-            'shopId' => $shop->shopId ?? ($shop->id ?? 0),
-            'mainId' => $shop->mainId ?? 0,
-            'tx' => $tx,
-            'ptStyle' => $ptStyle,
-            'shopName' => $shop->shopName ?? '',
-            'sjName' => $shop->merchantName ?? '',
-        ];
-        PtYeChangeClass::addChange($change, true);
-    }
-
     //客户结帐增加加余额 ssh 20210729
     public static function customClearAddBalance($shop, $order, $capitalType, $tx)
     {

+ 1 - 2
biz/shop/classes/ShopClass.php

@@ -362,7 +362,7 @@ class ShopClass extends BaseClass
     }
 
     /**
-     * 客户线上充值退款:扣减门店 xhMain 余额并记门店余额变动(与 customRechargeAddBalance 对称)。
+     * 客户线上充值退款:扣减门店 xhMain 余额并记门店余额变动(不涉及平台资产 PtAsset)。
      */
     public static function customRechargeRefundReduceBalance($main, $shop, $order, $capitalType, $staffName = '')
     {
@@ -407,7 +407,6 @@ class ShopClass extends BaseClass
             'ptStyle' => $shop->ptStyle ?? 0,
         ];
         ShopYeChangeClass::addChange($change, true);
-        PtAssetClass::customRechargeRefundReduceBalance($shop, $order, $capitalType, $tx, $staffName);
     }
 
     public static function skRechargeAddBalance($main, $shop, $order)