添加:生成供应商邀请入驻二维码
This commit is contained in:
parent
857e36c838
commit
7aba307a8d
|
|
@ -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{
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace app\controller\api;
|
||||
|
||||
|
||||
use app\common\repositories\marketing\AgentRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
|
||||
|
||||
class Agent extends BaseController{
|
||||
|
||||
protected $repository;
|
||||
|
||||
public function __construct(App $app, AgentRepository $repository){
|
||||
parent::__construct($app);
|
||||
$this->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('小程序码生成失败!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue