更新商户入驻
This commit is contained in:
parent
db02424721
commit
fa1a2a9634
@ -207,6 +207,7 @@ class Auth extends BaseController
|
|||||||
// 判断是否是商户,并且有没有完善信息
|
// 判断是否是商户,并且有没有完善信息
|
||||||
// 这里有点小问题以后要修改
|
// 这里有点小问题以后要修改
|
||||||
$store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
|
$store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
|
||||||
|
|
||||||
if ($store_service) {
|
if ($store_service) {
|
||||||
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time')->find();
|
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time')->find();
|
||||||
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
|
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
|
||||||
|
@ -46,6 +46,14 @@ class MerchantIntention extends BaseController
|
|||||||
return app('json')->fail('未开启商户入驻');
|
return app('json')->fail('未开启商户入驻');
|
||||||
}
|
}
|
||||||
if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
|
if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
|
||||||
|
if (($this->userInfo->phone ?? false) && ($this->userInfo->phone != ($data['phone'] ?? ''))) {
|
||||||
|
throw new ValidateException('联系电话和注册手机不一致');
|
||||||
|
}
|
||||||
|
|
||||||
|
$intentionInfo = Db::name('merchant_intention')->where('social_credit_code', $data['social_credit_code'])->where('status', '<>', 2)->find();
|
||||||
|
if ($intentionInfo) {
|
||||||
|
throw new ValidateException('此统一社会信用代码已申请商户');
|
||||||
|
}
|
||||||
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find();
|
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find();
|
||||||
if ($merInfo) {
|
if ($merInfo) {
|
||||||
throw new ValidateException('该用户已存在商户,不可申请');
|
throw new ValidateException('该用户已存在商户,不可申请');
|
||||||
@ -68,17 +76,16 @@ class MerchantIntention extends BaseController
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find();
|
$areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find();
|
||||||
$cityId = Db::name('geo_city')->where('city_code', $areaInfo['city_code'] ?? '')->value('city_id', 0);
|
|
||||||
$streetId = Db::name('geo_street')->where('street_code', $data['street_id'] ?? '')->value('street_id', 0);
|
|
||||||
$sendData = [
|
$sendData = [
|
||||||
'company_name' => $data['mer_name'],
|
'company_name' => $data['company_name'] ?? '',
|
||||||
'organization_code' => $data['social_credit_code'] ?? '',
|
'organization_code' => $data['social_credit_code'] ?? '',
|
||||||
'master_name' => $data['name'],
|
'master_name' => $data['name'],
|
||||||
'master_phone' => $data['phone'],
|
'master_phone' => $data['phone'],
|
||||||
'images' => !empty($data['images'])?json_encode($data['images']):'',
|
'images' => !empty($data['images'])?json_encode($data['images']):'',
|
||||||
'city' => $cityId,
|
'city' => $areaInfo['city_code'] ?? '',
|
||||||
'area' => $areaInfo['area_id'] ?? 0,
|
'area' => $data['area_id'] ?? '',
|
||||||
'street' => $streetId,
|
'street' => $data['street_id'] ?? '',
|
||||||
|
'address' => $data['address'] ?? '',
|
||||||
'mer_intention_id' => $intention->mer_intention_id
|
'mer_intention_id' => $intention->mer_intention_id
|
||||||
];
|
];
|
||||||
$res = $this->sendMerIntentionApply($sendData);
|
$res = $this->sendMerIntentionApply($sendData);
|
||||||
@ -120,15 +127,32 @@ class MerchantIntention extends BaseController
|
|||||||
|
|
||||||
public function update($id)
|
public function update($id)
|
||||||
{
|
{
|
||||||
if (!$this->repository->getWhere(['mer_intention_id' => (int)$id, 'uid' => $this->userInfo->uid, 'is_del' => 0]))
|
$merIntentionInfo = $this->repository->getWhere(['mer_intention_id' => (int)$id, 'uid' => $this->userInfo->uid, 'is_del' => 0]);
|
||||||
|
if (!$merIntentionInfo)
|
||||||
return app('json')->fail('数据不存在');
|
return app('json')->fail('数据不存在');
|
||||||
|
if ($merIntentionInfo['status']) {
|
||||||
|
return app('json')->fail('已审核数据不能修改');
|
||||||
|
}
|
||||||
$data = $this->checkParams();
|
$data = $this->checkParams();
|
||||||
if (!systemConfig('mer_intention_open')) {
|
if (!systemConfig('mer_intention_open')) {
|
||||||
return app('json')->fail('未开启商户入驻');
|
return app('json')->fail('未开启商户入驻');
|
||||||
}
|
}
|
||||||
|
if (($this->userInfo->phone ?? false) && ($this->userInfo->phone != ($data['phone'] ?? ''))) {
|
||||||
|
throw new ValidateException('联系电话和注册手机不一致');
|
||||||
|
}
|
||||||
|
$intentionInfo = Db::name('merchant_intention')->where('social_credit_code', $data['social_credit_code'])->where('status', '<>', 2)->find();
|
||||||
|
if ($intentionInfo) {
|
||||||
|
throw new ValidateException('此统一社会信用代码已申请商户');
|
||||||
|
}
|
||||||
if (!empty($data['mer_phone'])) {
|
if (!empty($data['mer_phone'])) {
|
||||||
unset($data['mer_phone']);
|
unset($data['mer_phone']);
|
||||||
}
|
}
|
||||||
|
$make = app()->make(MerchantRepository::class);
|
||||||
|
if ($make->fieldExists('mer_name', $data['mer_name']))
|
||||||
|
throw new ValidateException('商户名称已存在,不可申请');
|
||||||
|
$adminRepository = app()->make(MerchantAdminRepository::class);
|
||||||
|
if ($adminRepository->fieldExists('account', $data['phone']))
|
||||||
|
throw new ValidateException('手机号已是管理员,不可申请');
|
||||||
$data['create_time'] = date('Y-m-d H:i:s', time());
|
$data['create_time'] = date('Y-m-d H:i:s', time());
|
||||||
$this->repository->updateIntention((int)$id, $data);
|
$this->repository->updateIntention((int)$id, $data);
|
||||||
SwooleTaskService::admin('notice', [
|
SwooleTaskService::admin('notice', [
|
||||||
@ -139,6 +163,23 @@ class MerchantIntention extends BaseController
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
$areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find();
|
||||||
|
$sendData = [
|
||||||
|
'company_name' => $data['company_name'] ?? '',
|
||||||
|
'organization_code' => $data['social_credit_code'] ?? '',
|
||||||
|
'master_name' => $data['name'],
|
||||||
|
'master_phone' => $data['phone'],
|
||||||
|
'images' => !empty($data['images'])?json_encode($data['images']):'',
|
||||||
|
'city' => $areaInfo['city_code'] ?? '',
|
||||||
|
'area' => $data['area_id'] ?? '',
|
||||||
|
'street' => $data['street_id'] ?? '',
|
||||||
|
'address' => $data['address'] ?? '',
|
||||||
|
'mer_intention_id' => $id
|
||||||
|
];
|
||||||
|
$res = $this->sendMerIntentionApply($sendData);
|
||||||
|
if (!$res) {
|
||||||
|
throw new ValidateException('申请商户入驻任务失败,请联系平台');
|
||||||
|
}
|
||||||
return app('json')->success('修改成功');
|
return app('json')->success('修改成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +207,8 @@ class MerchantIntention extends BaseController
|
|||||||
$data = $this->request->params([
|
$data = $this->request->params([
|
||||||
'phone',
|
'phone',
|
||||||
'mer_name',
|
'mer_name',
|
||||||
|
'company_name',
|
||||||
|
'address',
|
||||||
'name',
|
'name',
|
||||||
'code',
|
'code',
|
||||||
'images',
|
'images',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user