From 1afadcfd972c488fe7dd1b93f89a6f5eb527e469 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Sat, 23 Mar 2024 16:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=83=9F=E9=85=92?= =?UTF-8?q?=E9=A6=86=E4=BB=A3=E9=94=80=E5=95=86=E9=82=80=E8=AF=B7=E7=83=9F?= =?UTF-8?q?=E9=85=92=E9=A6=86=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantIntentionDao.php | 47 ++++++++++++------- .../marketing/AgentRepository.php | 11 ++++- app/controller/api/Agent.php | 3 ++ .../api/store/merchant/MerchantIntention.php | 26 ++++++---- .../api/MerchantIntentionValidate.php | 4 +- 5 files changed, 60 insertions(+), 31 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantIntentionDao.php b/app/common/dao/system/merchant/MerchantIntentionDao.php index 880b4fa..0fe9c45 100644 --- a/app/common/dao/system/merchant/MerchantIntentionDao.php +++ b/app/common/dao/system/merchant/MerchantIntentionDao.php @@ -17,24 +17,35 @@ class MerchantIntentionDao extends BaseDao public function search(array $where) { - $query = $this->getModel()::getDB()->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) { - $query->where('mer_id', $where['mer_id']); - })->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { - $query->where('uid', $where['uid']); - })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) { - $query->where('status', (int)$where['status']); - })->when(isset($where['mer_intention_id']) && $where['mer_intention_id'] !== '', function ($query) use ($where) { - $query->where('mer_intention_id', $where['mer_intention_id']); - })->when(isset($where['category_id']) && $where['category_id'] !== '', function ($query) use ($where) { - $query->where('merchant_category_id', $where['category_id']); - })->when(isset($where['type_id']) && $where['type_id'] !== '', function ($query) use ($where) { - $query->where('mer_type_id', $where['type_id']); - })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) { - $query->where('mer_name|phone|mark', 'like', '%' . $where['keyword'] . '%'); - })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { - getModelTime($query, $where['date']); - })->where('is_del', 0); - + $query = $this->getModel()::getDB() + ->when(isset($where['mer_id']) && $where['mer_id'] !== '',function($query) use ($where){ + $query->where('mer_id',$where['mer_id']); + }) + ->when(isset($where['merchant_type']) && $where['merchant_type'] !== '',function($query) use ($where){ + $query->where('merchant_type',$where['merchant_type']); + }) + ->when(isset($where['uid']) && $where['uid'] !== '',function($query) use ($where){ + $query->where('uid',$where['uid']); + }) + ->when(isset($where['status']) && $where['status'] !== '',function($query) use ($where){ + $query->where('status',(int)$where['status']); + }) + ->when(isset($where['mer_intention_id']) && $where['mer_intention_id'] !== '',function($query) use ($where){ + $query->where('mer_intention_id',$where['mer_intention_id']); + }) + ->when(isset($where['category_id']) && $where['category_id'] !== '',function($query) use ($where){ + $query->where('merchant_category_id',$where['category_id']); + }) + ->when(isset($where['type_id']) && $where['type_id'] !== '',function($query) use ($where){ + $query->where('mer_type_id',$where['type_id']); + }) + ->when(isset($where['keyword']) && $where['keyword'] !== '',function($query) use ($where){ + $query->where('mer_name|phone|mark','like','%'.$where['keyword'].'%'); + }) + ->when(isset($where['date']) && $where['date'] !== '',function($query) use ($where){ + getModelTime($query,$where['date']); + }) + ->where('is_del',0); return $query; } diff --git a/app/common/repositories/marketing/AgentRepository.php b/app/common/repositories/marketing/AgentRepository.php index ec6fde1..6dfe19d 100644 --- a/app/common/repositories/marketing/AgentRepository.php +++ b/app/common/repositories/marketing/AgentRepository.php @@ -92,6 +92,12 @@ class AgentRepository extends BaseRepository{ $path = 'pages/agent/invite/index'; return app()->make(QrcodeService::class)->createQrCode($valueData,$path); break; + case 'wine': + // 参数长度超过 简写:aid=agent_id;mt=merchant_type + $valueData = 'aid=' . $params['agent_id'].'&mt=3'; + $path = 'pages/store/settled/index'; + return app()->make(QrcodeService::class)->createQrCode($valueData,$path); + break; } throw new ValidateException('小程序码生成失败!'); @@ -108,7 +114,7 @@ class AgentRepository extends BaseRepository{ * @throws \think\db\exception\ModelNotFoundException */ public function getIdentityList(int $uid,string $type = 'headquarters'):array{ - // 根据身份类型,获取代理中心角色类型数组:headquarters=总部,province=省公司,county=区县 + // 根据身份类型,获取代理中心角色类型数组:headquarters=总部,province=省公司,county=区县,wine=烟酒馆 // 类型:1=总部发起人,2=省公司发起人,3=省合伙人(外勤),4=省合伙人(内勤),5=区县运营商,6=区县合伙人,7=餐厅,8=配送商,9=总部外勤,10=总部内勤 switch($type){ case 'headquarters': @@ -120,6 +126,9 @@ class AgentRepository extends BaseRepository{ case 'county': $agentType = [5,6,7,8]; break; + case 'wine': + $agentType = [11]; + break; default: throw new ValidateException('身份查询失败!'); } diff --git a/app/controller/api/Agent.php b/app/controller/api/Agent.php index 01bba72..ba3b781 100644 --- a/app/controller/api/Agent.php +++ b/app/controller/api/Agent.php @@ -295,6 +295,7 @@ class Agent extends BaseController{ $headquartersList = (array)$this->repository->getIdentityList($uid); $provinceList = (array)$this->repository->getIdentityList($uid,'province'); $countyList = (array)$this->repository->getIdentityList($uid,'county'); + $wineList = (array)$this->repository->getIdentityList($uid,'wine'); // 省公司信息:仅显示省公司信息,如果存在多个则只显示一个,如果是内勤或者外勤则查询省公司信息 $newProvince = []; foreach($provinceList as $k => $v){ @@ -334,11 +335,13 @@ class Agent extends BaseController{ array_multisort(array_column($headquartersList,'id'), SORT_DESC, $headquartersList); array_multisort(array_column($provinceList,'id'), SORT_DESC, $provinceList); array_multisort(array_column($countyList,'id'), SORT_DESC, $countyList); + array_multisort(array_column($wineList,'id'), SORT_DESC, $wineList); return app('json')->success([ 'headquarters_list' => $headquartersList, 'province_list' => $provinceList, 'county_list' => $countyList, + 'wine_list' => $wineList, ]); } /** diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index ea7ef43..4676141 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -73,10 +73,14 @@ class MerchantIntention extends BaseController return app('json')->success('修改成功'); } - public function lst() - { + public function lst(){ + $merchantType = $this->request->param('merchant_type', 0); + [$page, $limit] = $this->getPage(); - $data = $this->repository->getList(['uid' => $this->userInfo->uid], $page, $limit); + $data = $this->repository->getList([ + 'uid' => $this->userInfo->uid, + 'merchant_type' => $merchantType + ],$page,$limit); return app('json')->success($data); } @@ -95,17 +99,19 @@ class MerchantIntention extends BaseController // 接收参数处理 protected function checkParams($id = 0){ // 参数获取 - $data = $this->request->params(['phone','mer_name','name','code','images','merchant_category_id','mer_type_id','manage_uid']); + $data = $this->request->params(['phone','mer_name','name','code','images','merchant_category_id','mer_type_id','manage_uid',['agent_id', 0],['merchant_type',0]]); app()->make(MerchantIntentionValidate::class)->check($data); // $check = app()->make(SmsService::class)->checkSmsCode($data['phone'],$data['code'],'intention'); $data['mer_type_id'] = (int)$data['mer_type_id']; // if(!$check) throw new ValidateException('验证码不正确'); - // 判断:商户分类是否存在 - $cateIsHas = app()->make(MerchantCategoryRepository::class)->get($data['merchant_category_id']); - if(!$cateIsHas) throw new ValidateException('商户分类不存在'); - // 判断:商户类型是否存在 - $typeIsHas = app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id']); - if($data['mer_type_id'] && !$typeIsHas) throw new ValidateException('店铺类型不存在'); + if((int)$data['merchant_type'] != 3){ + // 判断:商户分类是否存在 + $cateIsHas = app()->make(MerchantCategoryRepository::class)->get($data['merchant_category_id']); + if(!$cateIsHas) throw new ValidateException('商户分类不存在'); + // 判断:商户类型是否存在 + $typeIsHas = app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id']); + if($data['mer_type_id'] && !$typeIsHas) throw new ValidateException('店铺类型不存在'); + } // 判断:当前管理员身份是否有效 $isService = app()->make(StoreServiceRepository::class)->isService($data['manage_uid'], $id, 1);// 是否存在店员信息 if($isService) throw new ValidateException('管理员身份无效,已成为其他商户管理员或店员!'); diff --git a/app/validate/api/MerchantIntentionValidate.php b/app/validate/api/MerchantIntentionValidate.php index a99d434..d56287c 100644 --- a/app/validate/api/MerchantIntentionValidate.php +++ b/app/validate/api/MerchantIntentionValidate.php @@ -15,8 +15,8 @@ class MerchantIntentionValidate extends Validate 'phone|手机号' => 'require|mobile', 'name|姓名' => 'require', 'mer_name|姓名' => 'require|max:32', - 'merchant_category_id|商户分类' => 'require', - 'mer_type_id|店铺类型' => 'integer', + // 'merchant_category_id|商户分类' => 'require', + // 'mer_type_id|店铺类型' => 'integer', // 'code|验证码' => 'require', 'images|资质' => 'array', 'manage_uid|管理员' => 'require',