更新商户入驻

This commit is contained in:
yaooo 2023-09-14 17:33:56 +08:00
parent db02424721
commit fa1a2a9634
2 changed files with 53 additions and 9 deletions

View File

@ -207,6 +207,7 @@ class Auth extends BaseController
// 判断是否是商户,并且有没有完善信息
// 这里有点小问题以后要修改
$store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
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();
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
@ -1358,7 +1359,7 @@ class Auth extends BaseController
Log::info("接收到同步商户状态数据:" . json_encode(request()->param()));
$repository = app()->make(MerchantIntentionRepository::class);
if (!$repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
return app('json')->fail('数据不存在');
return app('json')->fail('数据不存在');
$param = $this->request->params(['status']);
$data['status'] = $param['status'];
$data['create_mer'] = -1;

View File

@ -46,6 +46,14 @@ class MerchantIntention extends BaseController
return app('json')->fail('未开启商户入驻');
}
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();
if ($merInfo) {
throw new ValidateException('该用户已存在商户,不可申请');
@ -68,17 +76,16 @@ class MerchantIntention extends BaseController
]
]);
$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 = [
'company_name' => $data['mer_name'],
'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' => $cityId,
'area' => $areaInfo['area_id'] ?? 0,
'street' => $streetId,
'city' => $areaInfo['city_code'] ?? '',
'area' => $data['area_id'] ?? '',
'street' => $data['street_id'] ?? '',
'address' => $data['address'] ?? '',
'mer_intention_id' => $intention->mer_intention_id
];
$res = $this->sendMerIntentionApply($sendData);
@ -120,15 +127,32 @@ class MerchantIntention extends BaseController
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('数据不存在');
if ($merIntentionInfo['status']) {
return app('json')->fail('已审核数据不能修改');
}
$data = $this->checkParams();
if (!systemConfig('mer_intention_open')) {
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'])) {
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());
$this->repository->updateIntention((int)$id, $data);
SwooleTaskService::admin('notice', [
@ -139,6 +163,23 @@ class MerchantIntention extends BaseController
'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('修改成功');
}
@ -165,7 +206,9 @@ class MerchantIntention extends BaseController
{
$data = $this->request->params([
'phone',
'mer_name',
'mer_name',
'company_name',
'address',
'name',
'code',
'images',