shish 1 rok pred
rodič
commit
6a340c2138

+ 13 - 0
biz-hd/custom/classes/CustomClass.php

@@ -158,6 +158,19 @@ class CustomClass extends BaseClass
             $custom->isDebt = 1;
         }
         $custom->save();
+
+        $hdId = $custom->hdId ?? 0;
+        $hd = HdClass::getById($hdId);
+        if (empty($hd)) {
+            util::fail('花店信息缺失');
+        }
+        $remain = bcsub($hd->balance, $amount, 2);
+        $hd->balance = $remain;
+        if ($hd->balance < 0) {
+            $hd->debt = 2;
+        }
+        $hd->save();
+
         $staffId = $order->shopAdminId ?? 0;
         $staffName = $order->shopAdminName ?? '';
         $relateId = $order->id ?? 0;

+ 18 - 19
console/controllers/LsCustomController.php

@@ -57,32 +57,32 @@ class LsCustomController extends Controller
 
                                 echo "shopId:".$shopId." | ".$customName . " customId:" . $customId . " hdId:" . $hdId . " 有欠款 ==== \n\n";
 
-                                $c = CustomClass::getById($customId, true);
-                                $h = HdClass::getById($hdId, true);
-                                if (empty($c) || empty($h)) {
+                                $custom = CustomClass::getById($customId, true);
+                                $hd = HdClass::getById($hdId, true);
+                                if (empty($custom) || empty($hd)) {
                                     echo $customName . " customId:" . $customId . " hdId:" . $hdId . " 的对象是空的哦!! \n";
                                     util::stop();
                                 }
-                                $balance = $c->balance ?? 0;
-                                $hdBalance = $h->balance ?? 0;
+                                $balance = $custom->balance ?? 0;
+                                $hdBalance = $hd->balance ?? 0;
                                 if (floatval($balance) != $hdBalance) {
                                     echo $customName . " customId:" . $customId . " hdId:" . $hdId . " 二边余额不一致 \n";
                                     util::stop();
                                 }
                                 $newBalance = bcsub($balance, $debtAmount, 2);
-                                $c->balance = $newBalance;
-                                $c->debtAmount = 0;
-                                $c->isDebt =0;
-                                $c->debtNum = 0;
-                                $c->save();
-
-                                $h->balance = $newBalance;
-                                $h->debtAmount = 0;
-                                $h->debt =1;
-                                $h->debtNum = 0;
-                                $h->save();
-
-                                $hdName = $h->name ?? '';
+                                $custom->balance = $newBalance;
+                                $custom->debtAmount = 0;
+                                $custom->isDebt =0;
+                                $custom->debtNum = 0;
+                                $custom->save();
+
+                                $hd->balance = $newBalance;
+                                $hd->debtAmount = 0;
+                                $hd->debt =1;
+                                $hd->debtNum = 0;
+                                $hd->save();
+
+                                $hdName = $hd->name ?? '';
                                 $mainId = $shop['mainId'] ?? 0;
                                 $event = '系统操作:合并欠款';
                                 $capitalType = dict::getDict('capitalType', 'system', 'id');
@@ -108,7 +108,6 @@ class LsCustomController extends Controller
                                 ];
                                 BalanceChangeClass::add($change, true);
 
-
                             }else{
                                 //echo "shopId:".$shopId." | ".$customName . " customId:" . $customId . " hdId:" . $hdId . " 没有欠款 ok ok \n";
                             }