Browse Source

欠款融合

shish 3 years ago
parent
commit
524aa7af27
1 changed files with 27 additions and 0 deletions
  1. 27 0
      console/controllers/TotalDebtChangeController.php

+ 27 - 0
console/controllers/TotalDebtChangeController.php

@@ -12,6 +12,33 @@ use Yii;
 class TotalDebtChangeController extends Controller
 {
 
+    // ./yii total-debt-change/ls
+    public function actionLs()
+    {
+        $list = ShopClass::getAllByCondition(['ptStyle' => 1], null, '*', null, true);
+        if (!empty($list)) {
+            foreach ($list as $shop) {
+                $shopId = $shop->id ?? 0;
+                $customList = \bizHd\custom\classes\CustomClass::getAllByCondition(['shopId' => $shopId], null, '*', null, true);
+                if (!empty($customList)) {
+                    foreach ($customList as $custom) {
+                        $customId = $custom->id ?? 0;
+                        $lsOrderDebt = 0;
+                        $lsOrderList = \bizHd\order\classes\OrderClass::getAllByCondition(['customId' => $customId], null, '*', null, true);
+                        if (!empty($lsOrderList)) {
+                            foreach ($lsOrderList as $lsOrder) {
+                                $remainDebtPrice = $lsOrder->remainDebtPrice ?? 0;
+                                $lsOrderDebt = bcadd($lsOrderDebt, $remainDebtPrice, 2);
+                            }
+                        }
+                        $custom->debtAmount = $lsOrderDebt;
+                        $custom->save();
+                    }
+                }
+            }
+        }
+    }
+
     // ./yii total-debt-change/init
     public function actionInit()
     {