shish 1 месяц назад
Родитель
Сommit
4dc46f2877
1 измененных файлов с 35 добавлено и 0 удалено
  1. 35 0
      console/controllers/ClearController.php

+ 35 - 0
console/controllers/ClearController.php

@@ -5,6 +5,7 @@ namespace console\controllers;
 use biz\ghs\classes\GhsBackClass;
 use bizGhs\clear\classes\OrderCgClearClass;
 use bizGhs\clear\models\Clear;
+use bizGhs\clear\models\OrderCgClear;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\classes\CustomBalanceChangeClass;
 use bizGhs\ghs\classes\GhsBalanceChangeClass;
@@ -20,6 +21,40 @@ use Yii;
 class ClearController extends Controller
 {
 
+    public function actionUpdate()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $query = new \yii\db\Query();
+        $query->from(Clear::tableName());
+        $query->where(['ownPtStyle' => 2]);
+        $query->orderBy('id desc');
+        foreach ($query->batch(500) as $clearList) {
+            foreach ($clearList as $clear) {
+                $status = $clear['status'] ?? 1;
+                $clearId = $clear['id'] ?? 0;
+                $clearPrice = $clear['actPrice'] ?? 0;
+                $clearPrice = floatval($clearPrice);
+                if ($status == 2) {
+                    $relateList = OrderCgClearClass::getAllByCondition(['clearId' => $clearId], null, '*');
+                    $count = count($relateList);
+                    if ($count == 1) {
+                        foreach ($relateList as $relate) {
+                            $cgId = $relate['cgId'] ?? 0;
+                            $cgInfo = GhsClass::getById($cgId, true);
+                            $remainDebtPrice = $cgInfo->remainDebtPrice ?? 0;
+                            $remainDebtPrice = floatval($remainDebtPrice);
+                            if ($clearPrice == $remainDebtPrice) {
+                                echo "clearId {$clearId} cgId {$cgId} remainDebtPrice {$remainDebtPrice} 需要清除 \n";
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     public function actionGhsGhs()
     {
         ini_set('memory_limit', '2045M');