shish 8 месяцев назад
Родитель
Сommit
6d41f2f044
2 измененных файлов с 3 добавлено и 141 удалено
  1. 1 30
      app-ghs/controllers/UploadController.php
  2. 2 111
      console/controllers/CustomController.php

+ 1 - 30
app-ghs/controllers/UploadController.php

@@ -177,36 +177,7 @@ class UploadController extends BaseController
     //批量导入客户 ssh 2024426
     public function actionCustom()
     {
-        $file = $_FILES['file'];
-        if (!is_uploaded_file($file['tmp_name'])) {
-            util::fail('please upload img');
-        }
-        $mainId = $this->sjId;
-        $shopId = $this->shopId;
-        $month = date("Ym");
-        $date = date("d");
-        $path = dirUtil::getImgUploadDir() . "/{$mainId}/{$shopId}/{$month}/{$date}/";
-        if (!file_exists($path)) {
-            //检查是否有该文件夹,如果没有就创建,并给予最高权限
-            mkdir($path, 0700, true);
-        }
-        $preFileName = stringUtil::uniqueFileName();
-        //$newFile = $preFileName . ".txt";
-        $newFile = $preFileName . ".txt";
-        $fullPathFile = $path . $newFile;
-        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
-
-//            //队列方式去处理
-//            $customerCachedKey = 'file_batch_create_customer_list';
-            $value = $shopId . ',' . $fullPathFile;
-//            Yii::$app->redis->executeCommand('LPUSH', [$customerCachedKey, $value]);
-
-            noticeUtil::push("待批量导入客户的文件:" . $value, '15280215347');
-
-            util::complete();
-        } else {
-            util::fail('fail');
-        }
+        //重新写这个方法,用rabbitMQ来实现
     }
 
     //删除oss上的图片

+ 2 - 111
console/controllers/CustomController.php

@@ -261,116 +261,7 @@ class CustomController extends Controller
     //从文件批量创建客户 ssh 20240426
     public function actionFileCreateCustom()
     {
-//        $customerCachedKey = 'file_batch_create_customer_list';
-//        $fileCustomList = [];
-//        while ($count = Yii::$app->redis->executeCommand('LLEN', [$customerCachedKey])) {
-//            $customer = Yii::$app->redis->executeCommand('RPOP', [$customerCachedKey]);
-//            $fileCustomList[] = $customer;
-//        }
-//
-//        if (empty($fileCustomList)) {
-//            noticeUtil::push("没有找到手机号", '15280215347');
-//            return false;
-//        }
-
-        $fileCustomList = ['23580,/usr/local/nginx/html/huahuibao/vendor/../../resource/images/uploads/35869/23580/202404/27/f4ed6c0aa209b4d0d56dd6543b7c4e25.txt'];
-
-        foreach ($fileCustomList as $fileCustom) {
-
-            $customerInfo = explode(',', $fileCustom);
-            $masterShopId = $customerInfo[0];
-            $masterShop = ShopClass::getById($masterShopId, true);
-            $masterSjId = $masterShop->sjId ?? 0;
-            $masterSjName = $masterShop->merchantName ?? '';
-
-            $filePath = $customerInfo[1];
-
-            $content = file_get_contents($filePath);
-            $content = trim($content);
-
-            $arr = explode('
-', $content);
-
-            foreach ($arr as $key => $one) {
-                $single = explode(',', $one);
-
-                $shopName = trim($single[0]);
-                $mobile = trim($single[1]);
-
-                echo bcadd($key, 1) . ' ' . $shopName . ' ' . $mobile . "\n";
-
-                $connection = Yii::$app->db;
-                $transaction = $connection->beginTransaction();
-
-                try {
-
-                    // 组织表单数据
-                    $post = [];
-                    $post['introSjId'] = $masterSjId;
-                    $post['introShopId'] = $masterShopId;
-                    $post['introSjName'] = $masterSjName;
-                    $post['introStyle'] = SjClass::STYLE_SUPPLIER;
-
-                    $post['name'] = $shopName;
-                    if (empty($shopName)) {
-                        noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称没有填写", '15280215347');
-                        $transaction->rollBack();
-                        continue;
-                    }
-                    $post['mobile'] = $mobile;
-                    if (stringUtil::isMobile($mobile) == false) {
-                        noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号填写错误", '15280215347');
-                        $transaction->rollBack();
-                        continue;
-                    }
-                    if (stringUtil::getWordNum($shopName) > 15) {
-                        noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称超过了15个汉字", '15280215347');
-                        $transaction->rollBack();
-                        continue;
-                    }
-                    $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
-                    if (!empty($hasShop)) {
-                        //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号已经存在了", '15280215347');
-                        $transaction->rollBack();
-                        continue;
-                    }
-                    $has = ApplyClass::getByCondition(['mobile' => $mobile]);
-                    if (!empty($has)) {
-                        noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,在申请列表,手机号已经存在了哦", '15280215347');
-                        $transaction->rollBack();
-                        continue;
-                    }
-                    $adminName = $post['adminName'] ?? '';
-                    $miniOpenId = $post['miniOpenId'] ?? '';
-                    $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId];
-                    $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
-
-                    $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
-                    $adminId = $admin['id'] ?? 0;
-                    $post['adminId'] = $adminId;
-                    $post['adminName'] = $admin['name'] ?? '';
-                    $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
-                    $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
-                    $post['from'] = ApplyClass::FROM_RETAIL;
-                    $post['style'] = SjClass::STYLE_RETAIL;
-                    //增加或更新申请
-                    $respond = ApplyService::replaceRetail($post);
-                    $id = $respond['id'] ?? 0;
-                    //后继代码,要用到此参数
-                    Yii::$app->params['ptStyle'] = 2;
-                    ApplyService::pass($id, '批发商手动添加');
-                    $transaction->commit();
-                    //只要手动添加的都标记为花店,任何情况都不会标记为散客
-                    CustomClass::updateByCondition(['mobile' => $mobile], ['isHd' => 1]);
-                    //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 由批发商添加成功");
-                } catch (\Exception $exception) {
-                    $transaction->rollBack();
-                    noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,原因:" . $exception->getMessage(), '15280215347');
-                }
-
-
-            }
-
-        }
+        //重新写这个方法,用rabbitMQ来实现
     }
+
 }