new-admin-api/app/controller/api/marketing/agent/Delivery.php

134 lines
3.7 KiB
PHP

<?php
namespace app\controller\api\marketing\agent;
use app\common\repositories\marketing\agent\AgentDeliveryRepository;
use app\common\repositories\marketing\AgentRepository;
use crmeb\basic\BaseController;
use think\App;
use think\exception\ValidateException;
/**
* Common: 运营中心 - 配送商相关
* Author: wu-hui
* Time: 2024/06/17 14:26
* Class Delivery
* @package app\controller\api\marketing\agent
*/
class Delivery extends BaseController{
protected $repository;
protected $agentRepository;
public function __construct(App $app, AgentDeliveryRepository $repository, AgentRepository $agentRepository){
parent::__construct($app);
$this->repository = $repository;
$this->agentRepository = $agentRepository;
}
/**
* Common: 获取缴费列表
* Author: wu-hui
* Time: 2024/06/17 14:25
* @return mixed
*/
public function paymentList(){
$config = $this->agentRepository->getConfig();
$paymentList = $config['payment_list'] ?? [];
return app('json')->success($paymentList);
}
/**
* Common: 生成缴费记录及订单
* Author: wu-hui
* Time: 2024/06/17 18:12
* @return mixed
*/
public function createOrder(){
// 参数获取
$params = $this->request->params([
['agent_id', 0],
['money', 0],
['title_quota', 0],
['other_quota', 0],
// 支付相关
'pay_type',
'return_url'
]);
// 参数判断
if($params['agent_id'] <= 0) throw new ValidateException('身份信息不明确,请重新登录!');
$params['uid'] = $this->request->uid();
$params['user_info'] = $this->request->userInfo();
$params['is_app'] = $this->request->isApp();
$res = $this->repository->createOrder($params);
if($res) return $res;
else return app('json')->success("操作成功");
}
/**
* Common: 配送商缴费记录
* Author: wu-hui
* Time: 2024/06/18 14:25
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function paymentRecord(){
// 参数处理
[$page,$limit] = $this->getPage();
$params = $this->request->params([
['agent_id', 0],
'is_bind',
'status'
]);
// 信息列表获取
$data = $this->repository->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 获取相关商户
* Author: wu-hui
* Time: 2024/06/18 9:47
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function merList(){
// 参数处理
[$page,$limit] = $this->getPage();
$params = $this->request->params([
['agent_id',0],
['search_text',''],
]);
// 信息列表获取
$data = $this->repository->getMerList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 分配缴费记录给商户
* Author: wu-hui
* Time: 2024/06/18 16:53
* @return mixed
*/
public function allocationOrder(){
// 参数获取
$params = $this->request->params([
['mer_id', 0],
['agent_delivery_id', 0],
]);
// 分配到订单
$this->repository->allocationOrder((int)$params['mer_id'], (int)$params['agent_delivery_id']);
return app('json')->success();
}
}