shish 4 år sedan
förälder
incheckning
56337e920c
1 ändrade filer med 31 tillägg och 3 borttagningar
  1. 31 3
      console/controllers/ShopController.php

+ 31 - 3
console/controllers/ShopController.php

@@ -11,7 +11,7 @@ use Yii;
 class ShopController extends Controller
 {
 
-    public function actionMain()
+    public function actionCustom()
     {
         $custom = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
         if (empty($custom)) {
@@ -23,16 +23,44 @@ class ShopController extends Controller
             $shop = ShopClass::getById($shopId, true);
             if ($shop->mainId != $item->mainId) {
                 echo "客户id:{$item->id} {$shop->mainId} {$item->mainId}\n";
-                $item->mainId = $shop->mainId;
-                $item->save();
+                if (!empty($shop->mainId)) {
+                    $item->mainId = $shop->mainId;
+                    $item->save();
+                }
             }
 
             $ownShopId = $item->ownShopId ?? 0;
             $ownShop = ShopClass::getById($ownShopId, true);
             if ($ownShop->mainId != $item->ownMainId) {
                 echo "客户own {$item->id} {$item->ownMainId} {$ownShop->mainId}\n";
+                if (!empty($ownShop->mainId)) {
+                    $item->ownMainId = $ownShop->mainId;
+                    $item->save();
+                }
             }
+        }
+    }
 
+    public function actionGhs()
+    {
+        $ghs = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
+        if (empty($ghs)) {
+            echo '空';
+            return false;
+        }
+        foreach ($ghs as $item) {
+            $shopId = $item->shopId ?? 0;
+            $mainId = $item->mainId ?? 0;
+            $shop = ShopClass::getById($shopId, true);
+            if ($shop->mainId != $mainId) {
+                echo "ghs {$item->id} {$mainId} {$shop->mainId} \n";
+            }
+            $ownShopId = $item->ownMainId ?? 0;
+            $ownMainId = $item->ownMainId ?? 0;
+            $ownShop = ShopClass::getById($ownShopId, true);
+            if ($ownShop->mainId != $ownMainId) {
+                echo "ghs own {$item->id} {$ownMainId} {$ownShop->mainId} \n";
+            }
         }
     }