添加:供应商申请 - 驳回后修改再次提交申请

优化:代理中心 - 邀请二维码流程优化
This commit is contained in:
wuhui_zzw 2024-01-30 18:45:18 +08:00
parent 8d34485be2
commit 339c18afde
7 changed files with 98 additions and 27 deletions

View File

@ -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=levelagent_id=aid
$valueData = 'lv=' . $params['level'] . '&aid=' . $params['agent_id'];
$path = 'pages/agent/invite/index';
return app()->make(QrcodeService::class)->createQrCode($valueData,$path);
break;
}

View File

@ -41,15 +41,11 @@ 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('小程序码生成失败!');
}
/**
* Common: 获取单条代理人员信息
* Author: wu-hui

View File

@ -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);
}
}

View File

@ -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']);
})

View File

@ -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 [];
}

View File

@ -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

View File

@ -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');// 申请信息详情