shish 4 jaren geleden
bovenliggende
commit
4389012776
2 gewijzigde bestanden met toevoegingen van 19 en 9 verwijderingen
  1. 7 1
      app-pt/controllers/CashController.php
  2. 12 8
      biz/sj/classes/CashClass.php

+ 7 - 1
app-pt/controllers/CashController.php

@@ -5,6 +5,7 @@ namespace pt\controllers;
 use biz\notice\classes\NoticeClass;
 use biz\pt\classes\PtAssetClass;
 use biz\pt\classes\PtYeChangeClass;
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopYeChangeClass;
 use biz\sj\classes\CashClass;
@@ -49,10 +50,15 @@ class CashController extends BaseController
             }
             $shopId = $cash->shopId;
             $shop = ShopClass::getLockById($shopId);
-            $cashAmount = isset($cash->amount) ? floatval($cash->amount) : 0;
             if (empty($shop)) {
                 util::fail('没有找到门店');
             }
+            $mainId = $shop->mainId ?? 0;
+            $main = MainClass::getLockById($mainId);
+            if (empty($main)) {
+                util::fail('没有main信息');
+            }
+            $cashAmount = isset($cash->amount) ? floatval($cash->amount) : 0;
             if ($cashAmount <= 0) {
                 CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
                 util::fail('提现金额有问题');

+ 12 - 8
biz/sj/classes/CashClass.php

@@ -198,20 +198,24 @@ class CashClass extends BaseClass
 
     public static function rollback($cash, $shop, $transaction, $cashAmount, $remark)
     {
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有main信息');
+        }
         $cash->remark = $remark;
         $cash->status = self::STATUS_CHECK_NO;
         $cash->save();
         //冻结金额回滚
-        $shop->freezeBalance = bcsub($shop->freezeBalance, $cashAmount, 2);
-        $currentBalance = bcadd($shop->balance, $cashAmount, 2);
-        $shop->balance = $currentBalance;
-        $currentTxBalance = bcadd($shop->txBalance, $cashAmount, 2);
-        $shop->txBalance = $currentTxBalance;
-        $shop->save();
+        $main->freezeBalance = bcsub($main->freezeBalance, $cashAmount, 2);
+        $currentBalance = bcadd($main->balance, $cashAmount, 2);
+        $main->balance = $currentBalance;
+        $currentTxBalance = bcadd($main->txBalance, $cashAmount, 2);
+        $main->txBalance = $currentTxBalance;
+        $main->save();
 
         $sjId = $shop->sjId;
         $shopId = $shop->id;
-        $mainId = $shop->mainId ?? 0;
         $tx = dict::getDict('yeTx', 'can');
         $ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
         $capitalType = dict::getDict('capitalType', 'xhDrawCash', 'id');
@@ -228,7 +232,7 @@ class CashClass extends BaseClass
             'event' => "提现回滚",
             'sjId' => $sjId,
             'shopId' => $shopId,
-            'mainId'=>$mainId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $ptStyle,
         ];