diff --git a/app/common/repositories/marketing/AgentRepository.php b/app/common/repositories/marketing/AgentRepository.php index 7164d86..036c614 100644 --- a/app/common/repositories/marketing/AgentRepository.php +++ b/app/common/repositories/marketing/AgentRepository.php @@ -50,6 +50,16 @@ class AgentRepository extends BaseRepository{ $query = $this->dao->searchList($params); return $query->select()->toArray(); } + /** + * Common: 获取单条代理人员信息 + * Author: wu-hui + * Time: 2024/01/30 9:27 + * @param $id + * @return array + */ + public function getSingleInfo($id){ + return $this->dao->searchList(['id'=>$id])->findOrEmpty()->toArray(); + } /** * Common: 生成对应的二维码 * Author: wu-hui diff --git a/app/controller/api/Agent.php b/app/controller/api/Agent.php index 93f0ba3..4234f2c 100644 --- a/app/controller/api/Agent.php +++ b/app/controller/api/Agent.php @@ -50,6 +50,21 @@ class Agent extends BaseController{ return app('json')->fail('小程序码生成失败!'); } + /** + * Common: 获取单条代理人员信息 + * Author: wu-hui + * Time: 2024/01/30 9:27 + * @param $id + * @return mixed + */ + public function singleAgentInfo($id){ + $res = $this->repository->getSingleInfo($id); + + return app('json')->success($res); + } + + + diff --git a/app/controller/api/Supplier.php b/app/controller/api/Supplier.php new file mode 100644 index 0000000..78df55e --- /dev/null +++ b/app/controller/api/Supplier.php @@ -0,0 +1,97 @@ +services = $services; + } + + /** + * Common: 申请入驻 + * Author: wu-hui + * Time: 2024/01/30 14:28 + * @return mixed + */ + public function applyJoin(){ + // 参数获取 + $data = $this->checkParam(); + if((int)$data['supplierApplyId'] > 0){ + // 编辑账号信息 + app()->make(SystemSupplierApplyServices::class)->editInfo((array)$data); + }else{ + // 添加账号 + app()->make(SystemSupplierApplyServices::class)->createApplyInfo((array)$data); + } + + return app('json')->success('操作成功'); + } + /** + * Common: 申请信息接收 + * Author: wu-hui + * Time: 2024/01/30 14:18 + * @return array + */ + private function checkParam():array{ + // 接收表单参数 + $supplierApplyId = (int)$this->request->param('id'); + $applyInfo = $this->request->params([ + 'invite_agent_id', + 'winery_name', + 'scale', + 'cellar_size', + 'corporation_name', + 'corporation_phone', + ['corporation_id_card',[]], + 'chairman_name', + 'chairman_phone', + ['chairman_id_card',[]], + 'contacts_name', + 'contacts_phone', + 'business_license', + 'production_icense', + 'circulative_license', + ]); + // 数据校验 + if (empty($applyInfo['invite_agent_id'])) throw new ValidateException('非法请求,无有效邀请人!'); + if (empty($applyInfo['winery_name'])) throw new ValidateException('请输入酒厂名称!'); + if (empty($applyInfo['scale'])) throw new ValidateException('请输入年产量多少吨!'); + if (empty($applyInfo['cellar_size'])) throw new ValidateException('请输入窖池大小!'); + if (empty($applyInfo['corporation_name'])) throw new ValidateException('请输入法人姓名!'); + if (empty($applyInfo['corporation_phone'])) throw new ValidateException('请输入法人电话!'); + if (isPhone($applyInfo['corporation_phone'])) throw new ValidateException('请输入正确的法人电话!'); + if (empty($applyInfo['corporation_id_card'])) throw new ValidateException('请上传法人身份证正反面图片!'); + if (empty($applyInfo['chairman_name'])) throw new ValidateException('请输入董事长姓名!'); + if (empty($applyInfo['chairman_phone'])) throw new ValidateException('请输入董事长电话!'); + if (isPhone($applyInfo['chairman_phone'])) throw new ValidateException('请输入正确的董事长电话!'); + if (empty($applyInfo['chairman_id_card'])) throw new ValidateException('请上传董事长身份证正反面图片!'); + if (empty($applyInfo['contacts_name'])) throw new ValidateException('请输入联系人姓名!'); + if (empty($applyInfo['contacts_phone'])) throw new ValidateException('请输入联系人电话!'); + if (isPhone($applyInfo['contacts_phone'])) throw new ValidateException('请输入正确的联系人电话!'); + if (empty($applyInfo['business_license'])) throw new ValidateException('请上传营业执照!'); + if (empty($applyInfo['production_icense'])) throw new ValidateException('请上传生产许可证!'); + if (empty($applyInfo['circulative_license'])) throw new ValidateException('请上传流通许可证!'); + // 联系人及联系人手机号 + $isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['contacts_phone'=>$applyInfo['contacts_phone']])->count(); + if($isHas >= 1) throw new ValidateException('联系人已经存在,请勿重复申请!'); + + return compact('supplierApplyId','applyInfo'); + } + + + + + + +} diff --git a/app/dao/supplier/SystemSupplierApplyDao.php b/app/dao/supplier/SystemSupplierApplyDao.php new file mode 100644 index 0000000..5861130 --- /dev/null +++ b/app/dao/supplier/SystemSupplierApplyDao.php @@ -0,0 +1,28 @@ +getModel() + ->when(isset($search['id']) && $search['id'] !== '', function ($query) use ($search) { + $query->where('id',$search['id']); + }) + ->when(isset($search['contacts_phone']) && $search['contacts_phone'] !== '', function ($query) use ($search) { + $query->where('contacts_phone', $search['contacts_phone']); + }); + } + + + + +} diff --git a/app/model/supplier/SystemSupplierApply.php b/app/model/supplier/SystemSupplierApply.php new file mode 100644 index 0000000..6a83741 --- /dev/null +++ b/app/model/supplier/SystemSupplierApply.php @@ -0,0 +1,23 @@ +dao = $dao; + } + /** + * Common: 查询模型 + * Author: wu-hui + * Time: 2024/01/30 14:46 + * @param $where + * @return \crmeb\basic\BaseModel + */ + public function searchModel($where){ + return $this->dao->searchModel($where); + } + /** + * Common: 添加申请信息 + * Author: wu-hui + * Time: 2024/01/30 14:28 + * @param array $data + * @return mixed + */ + public function createApplyInfo(array $data){ + return $this->transaction(function() use ($data){ + // 添加供应商信息 + $relation_id = $this->dao->save($data['applyInfo'])->id; + if(!$relation_id) throw new AdminException('申请失败'); + + return $relation_id; + }); + } + + + + + +} diff --git a/route/api.php b/route/api.php index 0a839bf..6a593a4 100644 --- a/route/api.php +++ b/route/api.php @@ -382,11 +382,11 @@ Route::group('api/', function () { Route::get('promote_qr_code', 'Merchant/promoteQrCode');// 推广二维码 Route::get('online_payment_qr_code', 'Merchant/onlinePaymentQrCode');// 买单二维码 })->prefix('api.store.merchant.'); - // 代理中心 + // 代理中心相关 Route::group('agent', function () { Route::get('agent_list', 'agentList');// 我的代理身份列表 - Route::get('qr_code_invite_supplier', 'qrCodeInviteSupplier');// 推广二维码 - + Route::get('qr_code_invite_supplier', 'qrCodeInviteSupplier');// 供应商邀请二维码 + Route::get('single_agent_info/:id', 'singleAgentInfo');// 获取单个代理人员信息 @@ -394,12 +394,21 @@ Route::group('api/', function () { })->prefix('api.Agent/'); + // 供应商相关 + Route::group('supplier', function () { + Route::post('apply', 'applyJoin');// 申请成为供应商 + })->prefix('api.Supplier/'); + + + + + })->middleware(UserTokenMiddleware::class, true); //非强制登录