shish преди 3 години
родител
ревизия
18ad4b9a51
променени са 1 файла, в които са добавени 31 реда и са изтрити 2 реда
  1. 31 2
      console/controllers/ImportCustomController.php

+ 31 - 2
console/controllers/ImportCustomController.php

@@ -18,12 +18,41 @@ class ImportCustomController extends Controller
 {
 
     //批量导客户进去 ssh 20230408
-    private function actionInit()
+    public function actionInit()
     {
+        $str = <<<CUSTOM
+袭人花店,18229700445
+花来旺,13662131860
+鲜花店,13701110216
+CUSTOM;
+
+        $str = trim($str);
+        $arr = explode('
+', $str);
+        if (empty($arr) || is_array($arr) == false) {
+            util::stop('客户资料有问题');
+        }
         $customList = [];
+        foreach ($arr as $item) {
+            $item = trim($item);
+            $it = explode(',', $item);
+            $mobile = $it[1] ?? '';
+            $name = $it[0] ?? '';
+            if (empty($name)) {
+                util::stop('有客户名称是空的');
+            }
+            if (stringUtil::isMobile($mobile) == false) {
+                util::stop('有客户手机号有问题');
+            }
+            $customList[] = ['name' => $name, 'mobile' => $mobile];
+        }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
-        $masterShopId = 0;
+        if (getenv('YII_ENV') == 'production') {
+            $masterShopId = 4892;
+        } else {
+            $masterShopId = 36523;
+        }
         $master = ShopClass::getById($masterShopId, true);
         if (empty($master)) {
             util::stop('没有找到主人的门店');