This commit is contained in:
mkm 2023-11-04 19:39:53 +08:00
parent e34bd3df99
commit 4621219000

View File

@ -51,7 +51,7 @@ class MerchantIntention extends BaseController
if (($this->userInfo->phone ?? false) && ($this->userInfo->phone != ($data['phone'] ?? ''))) { if (($this->userInfo->phone ?? false) && ($this->userInfo->phone != ($data['phone'] ?? ''))) {
throw new ValidateException('联系电话和注册手机不一致'); throw new ValidateException('联系电话和注册手机不一致');
} }
$intentionInfo = Db::name('merchant_intention')->where('social_credit_code', $data['social_credit_code'])->where('status', '<>', 2)->find(); $intentionInfo = Db::name('merchant_intention')->where('social_credit_code', $data['social_credit_code'])->where('status', '<>', 2)->find();
if ($intentionInfo) { if ($intentionInfo) {
throw new ValidateException('此统一社会信用代码已申请商户'); throw new ValidateException('此统一社会信用代码已申请商户');
@ -87,7 +87,7 @@ class MerchantIntention extends BaseController
'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' => $areaInfo['city_code'] ?? '', 'city' => $areaInfo['city_code'] ?? '',
'area' => $data['area_id'] ?? '', 'area' => $data['area_id'] ?? '',
'street' => $data['street_id'] ?? '', 'street' => $data['street_id'] ?? '',
@ -108,7 +108,7 @@ class MerchantIntention extends BaseController
$status = $this->request->post('status', 0); $status = $this->request->post('status', 0);
if ($this->userInfo) $data['uid'] = $this->userInfo->uid; if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
if ($status == 1) { if ($status == 1) {
Db::name('merchant')->where('uid', $this->userInfo->uid)->update(['mer_settlement_agree_status'=>1]); Db::name('merchant')->where('uid', $this->userInfo->uid)->update(['mer_settlement_agree_status' => 1]);
} }
return app('json')->success('操作成功'); return app('json')->success('操作成功');
} }
@ -116,14 +116,14 @@ class MerchantIntention extends BaseController
public function businessApply() public function businessApply()
{ {
$data = $this->request->params([ $data = $this->request->params([
'phone', 'phone',
'mer_name', 'mer_name',
'company_name', 'company_name',
'address', 'address',
'name', 'name',
'code', 'code',
'images', 'images',
'merchant_category_id', 'merchant_category_id',
'mer_type_id', 'mer_type_id',
'social_credit_code', 'social_credit_code',
'area_id', 'area_id',
@ -141,7 +141,7 @@ class MerchantIntention extends BaseController
if (empty($data['bank_username']) || empty($data['bank_opening']) || empty($data['bank_front']) || empty($data['bank_back']) || empty($data['cardno_front']) || empty($data['cardno_back'])) { if (empty($data['bank_username']) || empty($data['bank_opening']) || empty($data['bank_front']) || empty($data['bank_back']) || empty($data['cardno_front']) || empty($data['cardno_back'])) {
return app('json')->fail('请完善银行卡及身份信息'); return app('json')->fail('请完善银行卡及身份信息');
} }
if (!systemConfig('mer_intention_open')) { if (!systemConfig('mer_intention_open')) {
return app('json')->fail('未开启商户入驻'); return app('json')->fail('未开启商户入驻');
} }
@ -150,10 +150,10 @@ class MerchantIntention extends BaseController
if (empty($merInfo)) { if (empty($merInfo)) {
return app('json')->fail('请申请商户入驻申请!'); return app('json')->fail('请申请商户入驻申请!');
} }
if (!empty($merInfo['business_status']) && ($merInfo['business_status']==1)) { if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 1)) {
return app('json')->fail('商户交易已申请,正在审核中!'); return app('json')->fail('商户交易已申请,正在审核中!');
} }
if (!empty($merInfo['business_status']) && ($merInfo['business_status']==2)) { if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 2)) {
return app('json')->fail('商户交易申请已通过'); return app('json')->fail('商户交易申请已通过');
} }
$intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->where('type', 1)->find(); $intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->where('type', 1)->find();
@ -191,7 +191,7 @@ class MerchantIntention extends BaseController
'organization_code' => $intenInfo['social_credit_code'] ?? '', 'organization_code' => $intenInfo['social_credit_code'] ?? '',
'master_name' => $intenInfo['name'], 'master_name' => $intenInfo['name'],
'master_phone' => $intenInfo['phone'], 'master_phone' => $intenInfo['phone'],
'images' => !empty($intenInfo['images'])?json_encode(explode(',', $intenInfo['images'])):'', 'images' => !empty($intenInfo['images']) ? json_encode(explode(',', $intenInfo['images'])) : '',
'city' => $areaInfo['city_code'] ?? '', 'city' => $areaInfo['city_code'] ?? '',
'area' => $merInfo['area_id'] ?? '', 'area' => $merInfo['area_id'] ?? '',
'street' => $merInfo['street_id'] ?? '', 'street' => $merInfo['street_id'] ?? '',
@ -210,7 +210,7 @@ class MerchantIntention extends BaseController
Db::name('merchant_intention')->where('mer_intention_id', $intentionId)->delete(); Db::name('merchant_intention')->where('mer_intention_id', $intentionId)->delete();
throw new ValidateException('供销平台商户交易申请失败,' . $res['msg']); throw new ValidateException('供销平台商户交易申请失败,' . $res['msg']);
} }
Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]); Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status' => 1]);
return app('json')->success('申请成功'); return app('json')->success('申请成功');
} }
@ -234,7 +234,7 @@ class MerchantIntention extends BaseController
if (!empty($resData) && is_string($resData)) { if (!empty($resData) && is_string($resData)) {
Log::info("商户申请反馈信息" . $resData); Log::info("商户申请反馈信息" . $resData);
$resInfo = json_decode($resData, true); $resInfo = json_decode($resData, true);
if(!empty($resInfo['code']) && $resInfo['code'] == 1){ if (!empty($resInfo['code']) && $resInfo['code'] == 1) {
$rtnData['ok'] = true; $rtnData['ok'] = true;
} else { } else {
$rtnData['msg'] = $resInfo['msg']; $rtnData['msg'] = $resInfo['msg'];
@ -291,7 +291,7 @@ class MerchantIntention extends BaseController
'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' => $areaInfo['city_code'] ?? '', 'city' => $areaInfo['city_code'] ?? '',
'area' => $data['area_id'] ?? '', 'area' => $data['area_id'] ?? '',
'street' => $data['street_id'] ?? '', 'street' => $data['street_id'] ?? '',
@ -310,7 +310,7 @@ class MerchantIntention extends BaseController
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$type = $this->request->get('type', 1); $type = $this->request->get('type', 1);
$data = $this->repository->getList(['uid' => $this->userInfo->uid, 'type'=>$type], $page, $limit); $data = $this->repository->getList(['uid' => $this->userInfo->uid, 'type' => $type], $page, $limit);
return app('json')->success($data); return app('json')->success($data);
} }
@ -329,14 +329,14 @@ class MerchantIntention extends BaseController
protected function checkParams() protected function checkParams()
{ {
$data = $this->request->params([ $data = $this->request->params([
'phone', 'phone',
'mer_name', 'mer_name',
'company_name', 'company_name',
'address', 'address',
'name', 'name',
'code', 'code',
'images', 'images',
'merchant_category_id', 'merchant_category_name',
'mer_type_id', 'mer_type_id',
'social_credit_code', 'social_credit_code',
'area_id', 'area_id',
@ -352,8 +352,17 @@ class MerchantIntention extends BaseController
if (!$check) throw new ValidateException('验证码不正确'); if (!$check) throw new ValidateException('验证码不正确');
} }
if (!app()->make(MerchantCategoryRepository::class)->get($data['merchant_category_id'])) throw new ValidateException('商户分类不存在'); if (!app()->make(MerchantCategoryRepository::class)->get($data['merchant_category_id'])) throw new ValidateException('商户分类不存在');
if ($data['mer_type_id'] && !app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id'])) if ($data['mer_type_id'] && !app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id'])) {
throw new ValidateException('店铺类型不存在'); throw new ValidateException('店铺类型不存在');
}
if ($data['merchant_category_name'] == '') {
throw new ValidateException('商户分类,不能为空');
}
$merchant_category_id=Db::name('merchant_category')->where('category_name',$data['merchant_category_name'])->value('merchant_category_id');
if(!$merchant_category_id){
throw new ValidateException('没有对应的商户分类,请联系工作人员添加');
}
$data['merchant_category_id']=$merchant_category_id;
unset($data['code']); unset($data['code']);
return $data; return $data;
} }
@ -392,4 +401,3 @@ class MerchantIntention extends BaseController
return app('json')->success($lst); return app('json')->success($lst);
} }
} }