diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index eef5b90c..fac2a7d1 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -109,6 +109,47 @@ class MerchantIntention extends BaseController return app('json')->success('提交成功'); } + /** + * 个人提交入驻申请 + */ + public function PersonalStore() + { + $data = $this->checkParams(); + if (!systemConfig('mer_intention_open')) { + 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('联系电话和注册手机不一致'); + } + $merInfo = Db::name('merchant_intention')->where('uid', $this->userInfo->uid)->where('status', 'in',[0,1])->where('is_del',0)->find(); + if ($merInfo) { + throw new ValidateException('该用户已申请商户,不可重复申请'); + } + $make = app()->make(MerchantRepository::class); + if ($make->fieldExists('mer_name', $data['mer_name'])) + throw new ValidateException('商户名称已存在,不可申请'); + if ($make->fieldExists('mer_phone', $data['phone'])) + throw new ValidateException('手机号已存在,不可申请'); + $adminRepository = app()->make(MerchantAdminRepository::class); + if ($adminRepository->fieldExists('account', $data['phone'])) + throw new ValidateException('手机号已是管理员,不可申请'); + $mer_type_id=Db::name('merchant_type')->where('type_code','PersonalStore')->value('mer_type_id'); + $data['status']=1; + $data['mer_type_id']=$mer_type_id; + $intention = $this->repository->create($data); + if($intention){ + $datas['fail_msg']=''; + $datas['create_mer']=1; + $datas['status']=1; + $this->repository->updateStatus($intention->mer_intention_id, $datas); + + return app('json')->success('开户成功'); + }else{ + return app('json')->fail('开户失败'); + } + } + public function settlementApply() { $status = $this->request->post('status', 0); diff --git a/route/api.php b/route/api.php index 4514055e..3d0af1cc 100644 --- a/route/api.php +++ b/route/api.php @@ -283,6 +283,8 @@ Route::group('api/', function () { //申请商户 Route::get('intention/lst', 'api.store.merchant.MerchantIntention/lst'); + //申请个人交易 + Route::post('intention/personal_store', 'api.store.merchant.MerchantIntention/PersonalStore'); //交易申请商户 Route::post('intention/business', 'api.store.merchant.MerchantIntention/businessApply'); //申请商户协议