|
|
@@ -110,27 +110,46 @@ class ApplyService extends BaseService
|
|
|
}
|
|
|
$mobile = $data['mobile'] ?? '';
|
|
|
$data['licenseNo'] = $mobile;
|
|
|
- $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => ApplyClass::FROM_RETAIL]);
|
|
|
- if (!empty($has)) {
|
|
|
- if (isset($data['replace']) && $data['replace'] == 1) {
|
|
|
- util::fail('手机号已经添加过了');
|
|
|
- }
|
|
|
- util::fail('手机号已经使用');
|
|
|
- }
|
|
|
$adminId = $data['adminId'] ?? 0;
|
|
|
if (!empty($adminId)) {
|
|
|
$has = ApplyClass::getByCondition(['adminId' => $adminId, 'style' => ApplyClass::FROM_RETAIL]);
|
|
|
if (!empty($has)) {
|
|
|
util::fail('您已经申请过');
|
|
|
}
|
|
|
- //已提交开店申请,待审核
|
|
|
- \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 2]);
|
|
|
+ }
|
|
|
+ $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => ApplyClass::FROM_RETAIL]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ if (isset($data['replace']) && $data['replace'] == 1) {
|
|
|
+ if (empty($adminId)) {
|
|
|
+ util::fail('手机号已经添加过了');
|
|
|
+ } else {
|
|
|
+ if (isset($has['adminId']) && !empty($has['adminId'])) {
|
|
|
+ //已经被开店的客户主动申请开店
|
|
|
+ $hasId = $has['id'] ?? 0;
|
|
|
+ ApplyClass::updateById($hasId, ['adminId' => $adminId]);
|
|
|
+ $currentSjId = $has['sjId'] ?? 0;
|
|
|
+ $currentShopId = $has['shopId'] ?? 0;
|
|
|
+ $has['adminId'] = $adminId;
|
|
|
+ MerchantClass::initMore($has, $currentSjId, $currentShopId);
|
|
|
+ //开店成功
|
|
|
+ \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 3, 'currentShopId' => $currentShopId]);
|
|
|
+ return $has;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::fail('手机号已经使用');
|
|
|
}
|
|
|
$from = $data['from'] ?? ApplyClass::FROM_GHS;
|
|
|
if (in_array($from, [ApplyClass::FROM_GHS, ApplyClass::FROM_RETAIL]) == false) {
|
|
|
util::fail('请填写来源');
|
|
|
}
|
|
|
$respond = ApplyClass::addRetail($data);
|
|
|
+
|
|
|
+ if (!empty($adminId)) {
|
|
|
+ //已提交开店申请,待审核
|
|
|
+ \biz\admin\classes\AdminClass::updateById($adminId, ['openShop' => 2]);
|
|
|
+ }
|
|
|
+
|
|
|
return $respond;
|
|
|
}
|
|
|
|