shish 4 年之前
父節點
當前提交
b7825b4a77
共有 1 個文件被更改,包括 11 次插入7 次删除
  1. 11 7
      console/controllers/InitController.php

+ 11 - 7
console/controllers/InitController.php

@@ -104,7 +104,7 @@ class InitController extends Controller
     {
 
         //基地批发商
-        $jdShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'kmGhs')], null, '*', null, true);
+        $jdShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'kmGhs')], 'default DESC', '*', null, true);
         if (!empty($jdShopList)) {
             foreach ($jdShopList as $jdShop) {
                 $main = MainClass::add(['id' => null], true);
@@ -119,7 +119,7 @@ class InitController extends Controller
         }
 
         //批发商
-        $pfShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'ghs')], null, '*', null, true);
+        $pfShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'ghs')], 'default DESC', '*', null, true);
         if (!empty($pfShopList)) {
             foreach ($pfShopList as $pfShop) {
                 $pfShopId = $pfShop->id ?? 0;
@@ -142,8 +142,10 @@ class InitController extends Controller
                         $pfAdminId = $staff['adminId'] ?? 0;
                         $pfAdmin = AdminClass::getById($pfAdminId, true);
                         if (!empty($pfAdmin)) {
-                            $pfAdmin->currentGhsShopId = $pfShopId;
-                            $pfAdmin->save();
+                            if(empty($pfAdmin->currentGhsShopId)){
+                                $pfAdmin->currentGhsShopId = $pfShopId;
+                                $pfAdmin->save();
+                            }
                         } else {
                             echo "没有找到shopId:{$pfShopId}批发店的员工\n";
                         }
@@ -180,7 +182,7 @@ class InitController extends Controller
         }
 
         //零售
-        $lsShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'hd')], null, '*', null, true);
+        $lsShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'hd')], 'default DESC', '*', null, true);
         if (!empty($lsShopList)) {
             foreach ($lsShopList as $lsShop) {
                 $main = MainClass::add(['id' => null], true);
@@ -203,8 +205,10 @@ class InitController extends Controller
                         $adminId = $staff['adminId'] ?? 0;
                         $admin = AdminClass::getById($adminId, true);
                         if (!empty($admin)) {
-                            $admin->currentHdShopId = $lsShopId;
-                            $admin->save();
+                            if(empty($admin->currentHdShopId)){
+                                $admin->currentHdShopId = $lsShopId;
+                                $admin->save();
+                            }
                         }
                     }
                 }