|
|
@@ -363,12 +363,12 @@ class CustomController extends Controller
|
|
|
|
|
|
public function actionImport()
|
|
|
{
|
|
|
- $masterShopId = 55238;
|
|
|
- $masterShop = ShopClass::getById($masterShopId, true);
|
|
|
- $masterSjId = $masterShop->sjId ?? 0;
|
|
|
- $masterSjName = $masterShop->merchantName ?? '';
|
|
|
+ $masterShopId = 55238;
|
|
|
+ $masterShop = ShopClass::getById($masterShopId, true);
|
|
|
+ $masterSjId = $masterShop->sjId ?? 0;
|
|
|
+ $masterSjName = $masterShop->merchantName ?? '';
|
|
|
|
|
|
- $content = '1314花艺坊 15396301318
|
|
|
+ $content = '1314花艺坊 15396301318
|
|
|
1314花艺坊 16521681314
|
|
|
贻苗鲜花店 15959886775
|
|
|
七里香花坊 18965691877
|
|
|
@@ -592,94 +592,100 @@ U兰花坊15860453349
|
|
|
花心思花艺15880800812
|
|
|
囍礼花艺13559599226
|
|
|
超级花花(官桥店)13338589831';
|
|
|
- $content = trim($content);
|
|
|
+ $content = trim($content);
|
|
|
|
|
|
- $arr = explode('
|
|
|
+ $arr = explode('
|
|
|
', $content);
|
|
|
|
|
|
- foreach ($arr as $key => $one) {
|
|
|
-
|
|
|
- echo $one;die;
|
|
|
+ foreach ($arr as $key => $one) {
|
|
|
|
|
|
- $single = explode(',', $one);
|
|
|
- $shopName = trim($single[0]);
|
|
|
- $mobile = trim($single[1]);
|
|
|
+ $one = trim($one);
|
|
|
+ $mobile = substr($one, -11);
|
|
|
+ if (!stringUtil::isMobile($mobile)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $name = str_replace($mobile, "", $one);
|
|
|
+ echo $name.' '.$mobile."\n";continue;
|
|
|
|
|
|
- echo bcadd($key, 1) . ' ' . $shopName . ' ' . $mobile . "\n";
|
|
|
+ $single = explode(',', $one);
|
|
|
+ $shopName = trim($single[0]);
|
|
|
+ $mobile = trim($single[1]);
|
|
|
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
+ echo bcadd($key, 1) . ' ' . $shopName . ' ' . $mobile . "\n";
|
|
|
|
|
|
- try {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
|
|
|
- // 组织表单数据
|
|
|
- $post = [];
|
|
|
- $post['introSjId'] = $masterSjId;
|
|
|
- $post['introShopId'] = $masterShopId;
|
|
|
- $post['introSjName'] = $masterSjName;
|
|
|
- $post['introStyle'] = SjClass::STYLE_SUPPLIER;
|
|
|
+ try {
|
|
|
|
|
|
- $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');
|
|
|
+ // 组织表单数据
|
|
|
+ $post = [];
|
|
|
+ $post['introSjId'] = $masterSjId;
|
|
|
+ $post['introShopId'] = $masterShopId;
|
|
|
+ $post['introSjName'] = $masterSjName;
|
|
|
+ $post['introStyle'] = SjClass::STYLE_SUPPLIER;
|
|
|
|
|
|
- $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) {
|
|
|
+ $post['name'] = $shopName;
|
|
|
+ if (empty($shopName)) {
|
|
|
+ noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称没有填写", '15280215347');
|
|
|
$transaction->rollBack();
|
|
|
- noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,原因:" . $exception->getMessage(), '15280215347');
|
|
|
+ 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');
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|