|
@@ -9,8 +9,8 @@ use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\custom\services\CustomService;
|
|
use bizGhs\custom\services\CustomService;
|
|
|
use bizHd\saas\classes\ApplyClass;
|
|
use bizHd\saas\classes\ApplyClass;
|
|
|
use bizHd\saas\services\ApplyService;
|
|
use bizHd\saas\services\ApplyService;
|
|
|
|
|
+use bizHd\shop\classes\ShopClass;
|
|
|
use bizHd\stat\classes\StatVisitClass;
|
|
use bizHd\stat\classes\StatVisitClass;
|
|
|
-use bizGhs\shop\classes\ShopClass;
|
|
|
|
|
use common\components\imgUtil;
|
|
use common\components\imgUtil;
|
|
|
use common\components\stringUtil;
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
use common\components\util;
|
|
@@ -116,43 +116,54 @@ class CustomController extends BaseController
|
|
|
public function actionCreateCustomers()
|
|
public function actionCreateCustomers()
|
|
|
{
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
$post = Yii::$app->request->post();
|
|
|
- $post['style'] = SjClass::STYLE_RETAIL;
|
|
|
|
|
- $sjId = $this->sjId;
|
|
|
|
|
- $shopId = $this->shopId;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $arr = [];
|
|
|
for ($i = 1; $i <= 5; $i++) {
|
|
for ($i = 1; $i <= 5; $i++) {
|
|
|
- $name = $post['name' . $i];
|
|
|
|
|
- $mobile = $post['mobile' . $i];
|
|
|
|
|
- $confirmMobile = $post['confirmMobile' . $i];
|
|
|
|
|
-
|
|
|
|
|
- if (empty($name)) {
|
|
|
|
|
- Yii::info("花店名称不能为空");
|
|
|
|
|
|
|
+ $name = $post['name' . $i] ?? '';
|
|
|
|
|
+ $mobile = $post['mobile' . $i] ?? '';
|
|
|
|
|
+ $confirmMobile = $post['confirmMobile' . $i] ?? '';
|
|
|
|
|
+ if (empty($name) && empty($mobile) && empty($confirmMobile)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (empty($name)) {
|
|
|
|
|
+ util::fail('花店名称不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ $has = SjClass::getByCondition(['name' => $name]);
|
|
|
|
|
+ if (!empty($has)) {
|
|
|
|
|
+ util::fail($name . ' 这个名称已经被别人使用了');
|
|
|
|
|
+ }
|
|
|
if (stringUtil::getWordNum($name) > 8) {
|
|
if (stringUtil::getWordNum($name) > 8) {
|
|
|
- Yii::info('名称不能超过8个汉字');
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ util::fail('名称不能超过8个汉字');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if (empty($mobile)) {
|
|
if (empty($mobile)) {
|
|
|
- Yii::info("手机号不能为空");
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ util::fail($name . " 手机号不能为空");
|
|
|
}
|
|
}
|
|
|
if (stringUtil::isMobile($mobile) == false) {
|
|
if (stringUtil::isMobile($mobile) == false) {
|
|
|
- Yii::info('手机号格式不正确');
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ util::fail($name . " 手机号格式不正确");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if ($mobile != $confirmMobile) {
|
|
if ($mobile != $confirmMobile) {
|
|
|
- Yii::info("添加客户失败:mobile " . $mobile . ' != confirmMobile ' . $confirmMobile);
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ util::fail($name . " 二次手机号不一致");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ $hasShop = ShopClass::getByCondition(['mobile' => $mobile], true);
|
|
|
|
|
+ if (!empty($hasShop)) {
|
|
|
|
|
+ util::fail($name . "这个客户已经添加过了");
|
|
|
|
|
+ }
|
|
|
|
|
+ $has = ApplyClass::getByCondition(['mobile' => $mobile]);
|
|
|
|
|
+ if (!empty($has)) {
|
|
|
|
|
+ util::fail($name . "这个客户已经添加过了哦");
|
|
|
|
|
+ }
|
|
|
|
|
+ $arr[] = ['name' => $name, 'mobile' => $mobile];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($arr)) {
|
|
|
|
|
+ util::fail('请填写客户');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($arr as $item) {
|
|
|
|
|
+ $name = $item['name'] ?? '';
|
|
|
|
|
+ $mobile = $item['mobile'] ?? '';
|
|
|
//队列方式去处理
|
|
//队列方式去处理
|
|
|
$customerCachedKey = 'batch_create_customer_list';
|
|
$customerCachedKey = 'batch_create_customer_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::$app->redis->executeCommand('LPUSH', [$customerCachedKey, $value]);
|
|
|
- Yii::info("添加客户:name - " . $name . ' == mobile - ' . $mobile);
|
|
|
|
|
|
|
+ Yii::info("供应商添加客户:name - " . $name . ' == mobile - ' . $mobile);
|
|
|
Yii::info("shopAdminId: " . $this->shopAdminId);
|
|
Yii::info("shopAdminId: " . $this->shopAdminId);
|
|
|
}
|
|
}
|
|
|
util::complete();
|
|
util::complete();
|