From 7aba307a8dae76831b0211a4920c2fe89e8d8de5 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 29 Jan 2024 18:03:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E9=82=80=E8=AF=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/AgentRepository.php | 42 ++++++++++++-- app/controller/api/Agent.php | 56 +++++++++++++++++++ route/api.php | 20 ++++++- 3 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 app/controller/api/Agent.php diff --git a/app/common/repositories/marketing/AgentRepository.php b/app/common/repositories/marketing/AgentRepository.php index 6927bb3..7164d86 100644 --- a/app/common/repositories/marketing/AgentRepository.php +++ b/app/common/repositories/marketing/AgentRepository.php @@ -6,6 +6,8 @@ use app\common\dao\marketing\AgentDao; use app\common\model\marketing\Agent; use app\common\model\system\merchant\Merchant; use app\common\repositories\BaseRepository; +use crmeb\services\QrcodeService; +use think\exception\ValidateException; use think\facade\Db; class AgentRepository extends BaseRepository{ @@ -34,6 +36,40 @@ class AgentRepository extends BaseRepository{ return compact('count','list'); } + /** + * Common: 获取全部信息列表 + * Author: wu-hui + * Time: 2024/01/29 16:00 + * @param array $params + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getAllList(array $params):array{ + $query = $this->dao->searchList($params); + return $query->select()->toArray(); + } + /** + * Common: 生成对应的二维码 + * Author: wu-hui + * Time: 2024/01/29 17:40 + * @param array $data + * @param string $type + * @return mixed + */ + public function createQrCode(array $data,string $type = 'inviteSupplier'){ + // 参数获取 + switch($type){ + case 'inviteSupplier': + $valueData = 'agent_id=' . $data['agent_id']; + $path = 'pages/supplier/apply_join'; + return app()->make(QrcodeService::class)->createQrCode($valueData,$path); + break; + } + + throw new ValidateException('小程序码生成失败!'); + } /** @@ -197,10 +233,4 @@ class AgentRepository extends BaseRepository{ - - - - - - } diff --git a/app/controller/api/Agent.php b/app/controller/api/Agent.php new file mode 100644 index 0000000..93f0ba3 --- /dev/null +++ b/app/controller/api/Agent.php @@ -0,0 +1,56 @@ +repository = $repository; + } + /** + * Common: 获取代理列表 + * Author: wu-hui + * Time: 2024/01/29 16:00 + * @return mixed + */ + public function agentList(){ + // 参数处理 + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['is_get_self','not_page']); + if((int)$params['is_get_self'] > 0) $params['uid'] = $this->request->uid(); + // 信息列表获取 + if((int)$params['not_page'] > 0) $data = app()->make(AgentRepository::class)->getAllList((array)$params); + else $data = app()->make(AgentRepository::class)->getList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + /** + * Common: 二维码 - 供应商入驻二维码 + * Author: wu-hui + * Time: 2024/01/29 17:40 + * @return mixed + */ + public function qrCodeInviteSupplier(){ + // 参数获取 + $agentId = (int)$this->request->param('agent_id'); + if((int)$agentId > 0){ + $qrcode = $this->repository->createQrCode(['agent_id'=>$agentId]); + + return app('json')->success(['qr_code' => $qrcode]); + } + + return app('json')->fail('小程序码生成失败!'); + } + + + +} diff --git a/route/api.php b/route/api.php index 72edefe..0a839bf 100644 --- a/route/api.php +++ b/route/api.php @@ -381,10 +381,24 @@ Route::group('api/', function () { Route::group('merchant', 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');// 推广二维码 + + + + + + + + })->prefix('api.Agent/'); + + + + + })->middleware(UserTokenMiddleware::class, true);