shish пре 4 година
родитељ
комит
4c378572ca
1 измењених фајлова са 9 додато и 7 уклоњено
  1. 9 7
      app-ghs/controllers/CustomController.php

+ 9 - 7
app-ghs/controllers/CustomController.php

@@ -120,7 +120,7 @@ class CustomController extends BaseController
         $sjId = $this->sjId;
         $shopId = $this->shopId;
 
-        for($i = 1; $i <= 5; $i++) {
+        for ($i = 1; $i <= 5; $i++) {
             $name = $post['name' . $i];
             $mobile = $post['mobile' . $i];
             $confirmMobile = $post['confirmMobile' . $i];
@@ -150,7 +150,7 @@ class CustomController extends BaseController
 
             //队列方式去处理
             $customerCachedKey = 'customers_list';
-            $value = $name . '_' . $mobile . '_' . $this->sjId . '_' . $this->shop['id'] . '_' .$this->sj['name'] . '_' . $this->shopAdminId;
+            $value = $name . '_' . $mobile . '_' . $this->sjId . '_' . $this->shop['id'] . '_' . $this->sj['name'] . '_' . $this->shopAdminId;
             Yii::$app->redis->executeCommand('LPUSH', [$customerCachedKey, $value]);
             Yii::info("添加客户:name - " . $name . ' == mobile - ' . $mobile);
             Yii::info("shopAdminId: " . $this->shopAdminId);
@@ -158,20 +158,22 @@ class CustomController extends BaseController
         util::complete();
     }
 
-    //向队列写入执行复制客户的任务 shizhongqi 2022.6.9
+    //从首店同步客户 shizhongqi 2022.6.9
     public function actionCopyCustomers()
     {
         $shopId = $this->shopId;
         // 检测首店存在
         $defaultShopId = ShopClass::getDefaultShopId($shopId);
         if (empty($defaultShopId)) {
-            Yii::info("通过分店 id = $shopId 取首店 id 失败");
-            return;
+            util::fail('没有找到首店');
+        }
+        $shop = ShopClass::getById($defaultShopId, true);
+        if (empty($shop)) {
+            util::fail('首店不存在');
         }
-
         $cachedKey = 'copy_firstShop_customers';
         Yii::$app->redis->executeCommand('LPUSH', [$cachedKey, $shopId . '_' . $defaultShopId]);
-        Yii::info("复制首店的客户:分店id =  " . $shopId . ' 首店id = ' . $defaultShopId);
+        Yii::info("从首店同步客户:分店id =  " . $shopId . ' 首店id = ' . $defaultShopId);
         util::complete();
     }