shish 3 年之前
父节点
当前提交
77d8248ac4
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      console/controllers/WorkController.php

+ 10 - 4
console/controllers/WorkController.php

@@ -10,21 +10,27 @@ use Yii;
 class WorkController extends Controller
 class WorkController extends Controller
 {
 {
 
 
-
     public function actionInit()
     public function actionInit()
     {
     {
-        GoodsClass::updateByCondition(['id>' => 0], ['stock' => 0]);
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $goodsList = GoodsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($goodsList)) {
+            foreach ($goodsList as $goods) {
+                $goods->stock = 0;
+                $goods->save();
+            }
+        }
         $workList = WorkClass::getAllByCondition(['status' => 0], null, '*', null, true);
         $workList = WorkClass::getAllByCondition(['status' => 0], null, '*', null, true);
         if (!empty($workList)) {
         if (!empty($workList)) {
             foreach ($workList as $work) {
             foreach ($workList as $work) {
                 $num = $work->num ?? 0;
                 $num = $work->num ?? 0;
                 $goodsId = $work->goodsId ?? 0;
                 $goodsId = $work->goodsId ?? 0;
-                if(!empty($goodsId)){
+                if (!empty($goodsId)) {
                     GoodsClass::updateById($goodsId, ['stock' => $num]);
                     GoodsClass::updateById($goodsId, ['stock' => $num]);
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
-
 }
 }