shish 2 éve
szülő
commit
631813bbe8
1 módosított fájl, 33 hozzáadás és 0 törlés
  1. 33 0
      console/controllers/CpController.php

+ 33 - 0
console/controllers/CpController.php

@@ -2,6 +2,11 @@
 
 namespace console\controllers;
 
+use biz\cp\services\PtCpService;
+use biz\main\classes\MainClass;
+use biz\shop\classes\ShopClass;
+use bizGhs\cp\classes\CpClass;
+use common\components\noticeUtil;
 use common\components\util;
 use yii\console\Controller;
 use Yii;
@@ -14,6 +19,34 @@ class CpController extends Controller
     {
         ini_set('memory_limit', '2045M');
         set_time_limit(0);
+        //$shopList = ShopClass::getAllByCondition(['ptStyle' => 2], null, '*', null, true);
+        $shopList = ShopClass::getAllByCondition(['id' => 36523], null, '*', null, true);
+        if (empty($shopList)) {
+            util::stop('没有找到门店');
+        }
+        foreach ($shopList as $shop) {
+            $mainId = $shop->mainId;
+            $hasClass = CpClass::getByCondition(['mainId' => $mainId], true);
+            if (!empty($hasClass)) {
+                continue;
+            }
+            $main = MainClass::getById($mainId, true);
+            if (empty($main)) {
+                noticeUtil::push("mainId:{$mainId} 初始化产品没有找到main信息", '15280215347');
+                continue;
+            }
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+                PtCpService::initMainCp($main);
+                $transaction->commit();
+                echo "mainId:{$mainId} 初始化产品 success \n";
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                $msg = $e->getMessage();
+                noticeUtil::push("mainId:{$mainId} 初始化产品报错:{$msg}", '15280215347');
+            }
+        }
     }
 
 }