From 339c18afde235dd8129c7609148c1d37ea9e3891 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Tue, 30 Jan 2024 18:45:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=94=B3=E8=AF=B7=20-=20=E9=A9=B3=E5=9B=9E=E5=90=8E?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=8D=E6=AC=A1=E6=8F=90=E4=BA=A4=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=20=E4=BC=98=E5=8C=96=EF=BC=9A=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=20-=20=E9=82=80=E8=AF=B7=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/AgentRepository.php | 21 +++++---- app/controller/api/Agent.php | 10 ++-- app/controller/api/Supplier.php | 46 +++++++++++++++++-- app/dao/supplier/SystemSupplierApplyDao.php | 3 ++ app/model/supplier/SystemSupplierApply.php | 8 +++- .../supplier/SystemSupplierApplyServices.php | 30 +++++++++++- route/api.php | 7 ++- 7 files changed, 98 insertions(+), 27 deletions(-) diff --git a/app/common/repositories/marketing/AgentRepository.php b/app/common/repositories/marketing/AgentRepository.php index 036c614..df972c5 100644 --- a/app/common/repositories/marketing/AgentRepository.php +++ b/app/common/repositories/marketing/AgentRepository.php @@ -63,17 +63,22 @@ class AgentRepository extends BaseRepository{ /** * Common: 生成对应的二维码 * Author: wu-hui - * Time: 2024/01/29 17:40 - * @param array $data - * @param string $type + * Time: 2024/01/30 18:39 + * @param array $params * @return mixed */ - public function createQrCode(array $data,string $type = 'inviteSupplier'){ + public function createQrCode(array $params){ // 参数获取 - switch($type){ - case 'inviteSupplier': - $valueData = 'agent_id=' . $data['agent_id']; - $path = 'pages/supplier/apply_join'; + switch($params['type']){ + case 'supplier': + $valueData = 'agent_id=' . $params['agent_id']; + $path = 'pages/supplier/apply/apply_join'; + return app()->make(QrcodeService::class)->createQrCode($valueData,$path); + break; + case 'subordinate': + // 参数长度超过 简写:lv=level;agent_id=aid + $valueData = 'lv=' . $params['level'] . '&aid=' . $params['agent_id']; + $path = 'pages/agent/invite/index'; return app()->make(QrcodeService::class)->createQrCode($valueData,$path); break; } diff --git a/app/controller/api/Agent.php b/app/controller/api/Agent.php index 4234f2c..ae4e0ad 100644 --- a/app/controller/api/Agent.php +++ b/app/controller/api/Agent.php @@ -41,14 +41,10 @@ class Agent extends BaseController{ */ public function qrCodeInviteSupplier(){ // 参数获取 - $agentId = (int)$this->request->param('agent_id'); - if((int)$agentId > 0){ - $qrcode = $this->repository->createQrCode(['agent_id'=>$agentId]); + $params = $this->request->params(['agent_id','type','level']); + $qrcode = $this->repository->createQrCode($params); - return app('json')->success(['qr_code' => $qrcode]); - } - - return app('json')->fail('小程序码生成失败!'); + return app('json')->success(['qr_code' => $qrcode]); } /** * Common: 获取单条代理人员信息 diff --git a/app/controller/api/Supplier.php b/app/controller/api/Supplier.php index 4187618..8c35455 100644 --- a/app/controller/api/Supplier.php +++ b/app/controller/api/Supplier.php @@ -29,7 +29,7 @@ class Supplier extends BaseController{ $data = $this->checkParam(); if((int)$data['supplierApplyId'] > 0){ // 编辑账号信息 - app()->make(SystemSupplierApplyServices::class)->editInfo((array)$data); + app()->make(SystemSupplierApplyServices::class)->editApplyInfo((array)$data); }else{ // 添加账号 app()->make(SystemSupplierApplyServices::class)->createApplyInfo((array)$data); @@ -63,6 +63,7 @@ class Supplier extends BaseController{ 'production_icense', 'circulative_license', ]); + $applyInfo['uid'] = $this->request->uid(); // 数据校验 if (empty($applyInfo['invite_agent_id'])) throw new ValidateException('非法请求,无有效邀请人!'); if (empty($applyInfo['winery_name'])) throw new ValidateException('请输入酒厂名称!'); @@ -83,12 +84,20 @@ class Supplier extends BaseController{ 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(); + $isHas = app()->make(SystemSupplierApplyServices::class) + ->searchModel(['contacts_phone'=>$applyInfo['contacts_phone']]) + ->when($supplierApplyId > 0,function($query) use ($supplierApplyId){ + $query->where('id','<>', $supplierApplyId); + }) + ->count(); if($isHas >= 1) throw new ValidateException('联系人已经存在,请勿重复申请!'); // 酒厂是否已经存在 - $isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['winery_name'=>$applyInfo['winery_name']])->count(); - if($isHas >= 1) throw new ValidateException('酒厂已经存在,请勿重复申请!'); - $isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['winery_name'=>$applyInfo['winery_name']])->count(); + $isHas = app()->make(SystemSupplierApplyServices::class) + ->searchModel(['winery_name'=>$applyInfo['winery_name']]) + ->when($supplierApplyId > 0,function($query) use ($supplierApplyId){ + $query->where('id','<>', $supplierApplyId); + }) + ->count(); if($isHas >= 1) throw new ValidateException('酒厂已经存在,请勿重复申请!'); $nameIsHave = $this->services->isHave('supplier_name',$applyInfo['winery_name']); if($nameIsHave) throw new ValidateException('该酒厂已经入驻,请勿重复申请!'); @@ -96,6 +105,33 @@ class Supplier extends BaseController{ return compact('supplierApplyId','applyInfo'); } + /** + * Common: 申请记录 + * Author: wu-hui + * Time: 2024/01/30 17:11 + * @return mixed + */ + public function applyRecord(){ + $search = $this->request->params(['winery_name','contacts_name','contacts_phone','invite_agent_id','status']); + $search['uid'] = $this->request->uid(); + [$page, $limit] = $this->getPage(); + $data = app()->make(SystemSupplierApplyServices::class)->getList($search, $page, $limit); + + return app('json')->success($data); + } + /** + * Common: 获取单条申请信息 + * Author: wu-hui + * Time: 2024/01/30 17:35 + * @return mixed + */ + public function applyInfo(){ + $applyId = $this->request->param('apply_id'); + $data = app()->make(SystemSupplierApplyServices::class)->getSingleInfo(['id'=>$applyId]); + + return app('json')->success($data); + } + } diff --git a/app/dao/supplier/SystemSupplierApplyDao.php b/app/dao/supplier/SystemSupplierApplyDao.php index 2ca4e72..54f0647 100644 --- a/app/dao/supplier/SystemSupplierApplyDao.php +++ b/app/dao/supplier/SystemSupplierApplyDao.php @@ -17,6 +17,9 @@ class SystemSupplierApplyDao extends BaseDao{ ->when(isset($search['id']) && $search['id'] !== '',function($query) use ($search){ $query->where('id',$search['id']); }) + ->when(isset($search['uid']) && $search['uid'] !== '',function($query) use ($search){ + $query->where('uid',$search['uid']); + }) ->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 index 340a290..acb146f 100644 --- a/app/model/supplier/SystemSupplierApply.php +++ b/app/model/supplier/SystemSupplierApply.php @@ -22,10 +22,14 @@ class SystemSupplierApply extends BaseModel{ return implode(',',$value); } public function getCorporationIdCardAttr($value){ - return explode(',',$value); + if(!empty($value)) return explode(',',$value); + + return []; } public function getChairmanIdCardAttr($value){ - return explode(',',$value); + if(!empty($value)) return explode(',',$value); + + return []; } diff --git a/app/services/supplier/SystemSupplierApplyServices.php b/app/services/supplier/SystemSupplierApplyServices.php index 5d34a6b..4e96e39 100644 --- a/app/services/supplier/SystemSupplierApplyServices.php +++ b/app/services/supplier/SystemSupplierApplyServices.php @@ -46,6 +46,16 @@ class SystemSupplierApplyServices extends BaseServices{ return compact('count', 'list'); } + /** + * Common: 获取单条信息 + * Author: wu-hui + * Time: 2024/01/30 17:34 + * @param $search + * @return array + */ + public function getSingleInfo($search){ + return $this->dao->searchModel($search)->findOrEmpty()->toArray(); + } /** * Common: 添加申请信息 * Author: wu-hui @@ -55,13 +65,31 @@ class SystemSupplierApplyServices extends BaseServices{ */ 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; }); } + /** + * Common: 修改编辑信息 + * Author: wu-hui + * Time: 2024/01/30 18:07 + * @param array $data + * @return mixed + */ + public function editApplyInfo(array $data){ + return $this->transaction(function() use ($data){ + // 修改供应商申请信息 + $data['applyInfo']['status'] = 0; + $data['applyInfo']['reason'] = ''; + $res = $this->dao->update($data['supplierApplyId'],$data['applyInfo']); + if(!$res) throw new AdminException('申请信息修改失败'); + + return true; + }); + } /** * Common: 审核通过的操作 * Author: wu-hui diff --git a/route/api.php b/route/api.php index 6a593a4..f6854ef 100644 --- a/route/api.php +++ b/route/api.php @@ -385,7 +385,7 @@ Route::group('api/', function () { // 代理中心相关 Route::group('agent', function () { Route::get('agent_list', 'agentList');// 我的代理身份列表 - Route::get('qr_code_invite_supplier', 'qrCodeInviteSupplier');// 供应商邀请二维码 + Route::get('qr_code_invite', 'qrCodeInviteSupplier');// 供应商邀请二维码 Route::get('single_agent_info/:id', 'singleAgentInfo');// 获取单个代理人员信息 @@ -397,9 +397,8 @@ Route::group('api/', function () { // 供应商相关 Route::group('supplier', function () { Route::post('apply', 'applyJoin');// 申请成为供应商 - - - + Route::post('apply_record', 'applyRecord');// 申请记录 + Route::get('apply_info', 'applyInfo');// 申请信息详情