|
|
@@ -63,58 +63,54 @@ class ApplyService extends BaseService
|
|
|
return MerchantClass::generateMerchant($apply);
|
|
|
}
|
|
|
|
|
|
- //新增推荐 shish 2020.2.27
|
|
|
+ //申请开店 shish 2021.01.28
|
|
|
public static function addApply($data)
|
|
|
{
|
|
|
- $mobile = isset($data['mobile']) ? $data['mobile'] : 0;
|
|
|
- if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ $mobile = $data['mobile'] ?? 0;
|
|
|
+ if (empty($mobile)) {
|
|
|
util::fail('请填写手机号');
|
|
|
}
|
|
|
- $apply = self::getByCondition(['mobile' => $mobile]);
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('请填写正确手机号');
|
|
|
+ }
|
|
|
+ $adminId = $data['adminId'] ?? 0;
|
|
|
+ $apply = ApplyClass::getByCondition(['mobile' => $mobile]);
|
|
|
if (!empty($apply)) {
|
|
|
util::fail('手机号已被使用');
|
|
|
}
|
|
|
- $apply = self::getByCondition(['adminId' => $data['adminId']]);
|
|
|
- if (!empty($apply)) {
|
|
|
- util::fail('您已申请过了');
|
|
|
+ $style = $data['style'] ?? 0;
|
|
|
+ if (in_array($style, [MerchantClass::STYLE_RETAIL, MerchantClass::STYLE_SUPPLIER]) == false) {
|
|
|
+ util::fail('请确认开店资料');
|
|
|
}
|
|
|
- $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $data['adminId']]);
|
|
|
- if (!empty($shopAdmin)) {
|
|
|
- util::fail('您已经有门店了');
|
|
|
+ $from = $data['from'] ?? 0;
|
|
|
+ if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
|
|
|
+ util::fail('请确认开店资料是否完整!');
|
|
|
+ }
|
|
|
+ $apply = ApplyClass::getByCondition(['adminId' => $adminId, 'from' => $from, 'style' => $style]);
|
|
|
+ if (!empty($apply)) {
|
|
|
+ util::fail('您已经申请过了');
|
|
|
}
|
|
|
$prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
|
|
|
- $dist = isset($data['dist']) ? $data['dist'] : '';
|
|
|
- $floor = isset($data['floor']) ? $data['floor'] : '';
|
|
|
- $data['fullAddress'] = $prefix . $dist . $data['address'] . $floor;
|
|
|
+ $dist = $data['dist'] ?? '';
|
|
|
+ $floor = $data['floor'] ?? '';
|
|
|
+ $address = $data['address'] ?? '';
|
|
|
+ $data['fullAddress'] = $prefix . $dist . $address . $floor;
|
|
|
+ ApplyClass::addApply($data);
|
|
|
$mobile = $data['mobile'];
|
|
|
- noticeUtil::push('客户 ' . $mobile . ' 已提交开店资料,请及时跟进', '15280215347');
|
|
|
- return ApplyClass::addApply($data);
|
|
|
- }
|
|
|
-
|
|
|
- //供货商新增客户 shish 2021.1.10
|
|
|
- public static function addCustom($data, $merchantId)
|
|
|
- {
|
|
|
- $mobile = isset($data['mobile']) ? $data['mobile'] : 0;
|
|
|
- if (stringUtil::isMobile($mobile) == false) {
|
|
|
- util::fail('请填写手机号');
|
|
|
- }
|
|
|
- $apply = self::getByCondition(['mobile' => $mobile]);
|
|
|
- if (!empty($apply)) {
|
|
|
- util::fail('手机号已被使用');
|
|
|
+ if ($style == MerchantClass::STYLE_RETAIL) {
|
|
|
+ $text = "零售申请开店,";
|
|
|
+ } else {
|
|
|
+ $text = "供货商申请开店,";
|
|
|
}
|
|
|
- $currentAddress = $data['address'] ?? '';
|
|
|
- if (isset($data['province']) && isset($data['city'])) {
|
|
|
- $prefix = $data['province'] == $data['city'] ? $data['province'] : $data['province'] . $data['city'];
|
|
|
+ $text .= '客户(' . $mobile . ')已提交资料,';
|
|
|
+ $introSjId = $data['introSjId'] ?? 0;
|
|
|
+ if (!empty($introSjId)) {
|
|
|
+ $merchant = MerchantClass::getMerchantById($introSjId);
|
|
|
+ $name = $merchant['merchantName'] ?? '';
|
|
|
+ $text .= "介绍人:{$name},";
|
|
|
}
|
|
|
- $dist = isset($data['dist']) ? $data['dist'] : '';
|
|
|
- $floor = isset($data['floor']) ? $data['floor'] : '';
|
|
|
- $data['fullAddress'] = $prefix . $dist . $currentAddress . $floor;
|
|
|
- $data['introSjId'] = $merchantId;
|
|
|
- $data['introStyle'] = MerchantClass::STYLE_SUPPLIER;
|
|
|
- $mobile = $data['mobile'];
|
|
|
- noticeUtil::push('客户 ' . $mobile . ' 已由供货商提交开店资料,请及时跟进', '15280215347');
|
|
|
-
|
|
|
- return ApplyClass::addApply($data);
|
|
|
+ $text .= "请及时跟进";
|
|
|
+ noticeUtil::push($text, '15280215347');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|