Jelajahi Sumber

修改ptStyle

shish 3 tahun lalu
induk
melakukan
270940a082
1 mengubah file dengan 52 tambahan dan 8 penghapusan
  1. 52 8
      console/controllers/GhsInitController.php

+ 52 - 8
console/controllers/GhsInitController.php

@@ -7,16 +7,60 @@
 namespace console\controllers;
 
 use biz\item\classes\PtItemClass;
+use biz\shop\classes\ShopClass;
+use bizGhs\custom\classes\CustomClass;
+use bizGhs\ghs\classes\GhsClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
 use bizGhs\product\classes\ProductClass;
 use common\services\xhItemService;
 use yii\console\Controller;
+
 class GhsInitController extends Controller
 {
 
-    public function actionInit()
+    public function actionChangePtType()
     {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $shopList = ShopClass::getAllByCondition(['id>' => 0], null, '*', 'id');
+        $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($ghsList)) {
+            foreach ($ghsList as $ghs) {
+                $ownShopId = $ghs->ownShopId ?? 0;
+                if (isset($shopList[$ownShopId]) == false) {
+                    echo "没有找到供货商门店\n";
+                    continue;
+                }
+                $shop = $shopList[$ownShopId];
+                $ptStyle = $shop['ptStyle'] ?? 0;
+                if (empty($ptStyle)) {
+                    echo "没有找到ptStyle \n";
+                    continue;
+                }
+                $ghs->ownPtStyle = $ptStyle;
+                $ghs->save();
+            }
+        }
+        $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (!empty($customList)) {
+            foreach ($customList as $custom) {
+                $ownShopId = $custom->ownShopId ?? 0;
+                if (isset($shopList[$ownShopId]) == false) {
+                    echo "没有找到客户门店\n";
+                    continue;
+                }
+                $shop = $shopList[$ownShopId];
+                $ptStyle = $shop['ptStyle'] ?? 0;
+                if (empty($ptStyle)) {
+                    echo "没有找到ptStyle \n";
+                    continue;
+                }
+                $custom->ownPtStyle = $ptStyle;
+                $custom->save();
+            }
+        }
     }
 
     //清空某个商户的product
@@ -26,20 +70,20 @@ class GhsInitController extends Controller
 
     public function actionPtUnit()
     {
-        $res = ProductClass::getAllList("*","");
-        foreach ($res as $v){
+        $res = ProductClass::getAllList("*", "");
+        foreach ($res as $v) {
             $id = $v['id'];
             $obigU = $v['bigUnit'];
             $oSmallU = $v['smallUnit'];
             $bigUname = xhItemService::getUnitName($obigU);
             $smallUName = xhItemService::getUnitName($oSmallU);
             $data = [
-                'bigUnitId'=>$obigU,
-                'smallUnitId'=>$oSmallU,
-                'bigUnit'=>$bigUname,
-                'smallUnit'=>$smallUName,
+                'bigUnitId' => $obigU,
+                'smallUnitId' => $oSmallU,
+                'bigUnit' => $bigUname,
+                'smallUnit' => $smallUName,
             ];
-            ProductClass::updateById($id,$data);
+            ProductClass::updateById($id, $data);
         }
         echo "done";
     }