shish 7 місяців тому
батько
коміт
4ebb0e7858
1 змінених файлів з 14 додано та 16 видалено
  1. 14 16
      console/controllers/TestController.php

+ 14 - 16
console/controllers/TestController.php

@@ -83,23 +83,21 @@ class TestController extends Controller
 
     public function actionOrder()
     {
-        $list = \bizGhs\order\classes\OrderClass::getAllByCondition(['mainId' => 10975, 'customId' => 19746, 'onlinePay' => 1, 'payTime>' => '2024-9-30 23:59:59', 'payTime<' => '2024-11-01 00:00:00', 'payStatus' => 1], null, '*', null, true);
-        $ids = [];
-        if (!empty($list)) {
-            $total = 0;
-            foreach ($list as $order) {
-                $actPrice = $order->actPrice ?? 0;
-                $total = bcadd($actPrice, $total, 2);
-                $ids[] = $order->id;
-            }
-            echo $total;
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $query = new \yii\db\Query();
+        $query->select(['id', 'sendStatus']);
+        $query->from(\bizHd\order\models\Order::tableName());
+        $query->where(['status' => 2, 'sendType' => 1]);
+        $totalCount = 0;
+        foreach ($query->batch(1000) as $batch) {
+            $ids = array_column($batch, 'id');
+            OrderClass::updateByIds($ids, ['sendStatus' => 4]);
+            $totalCount += count($ids);
+            echo "已处理 " . $totalCount . " 条记录\n";
         }
-        $clear = ClearClass::getByCondition(['orderSn' => 'CL28884368'], true);
-        $string = $clear->saleIds;
-        $saleIds = explode(',', trim($string));
-        $arr = array_diff($ids, $saleIds);
-        print_r($arr);
-        echo implode(',', $arr);
+        echo "全部完成!共处理 " . $totalCount . " 条记录\n";
+        util::stop('');
     }
 
     //更新核销码 ssh 20240804