105 lines
3.0 KiB
PHP
105 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\order;
|
|
|
|
use app\common\controller\Backend;
|
|
use support\Response;
|
|
use Webman\Http\Request as WebmanRequest;
|
|
|
|
/**
|
|
* 压注订单(业务下单写入,后台以查询为主)
|
|
*/
|
|
class BetOrder extends Backend
|
|
{
|
|
protected ?object $model = null;
|
|
|
|
protected bool $modelValidate = false;
|
|
|
|
protected string|array $quickSearchField = ['id', 'period_no', 'idempotency_key'];
|
|
|
|
protected string|array $defaultSortField = ['id' => 'desc'];
|
|
|
|
protected string|array $orderGuarantee = ['id' => 'desc'];
|
|
|
|
protected array $withJoinTable = ['user', 'channel', 'gameRecord'];
|
|
|
|
protected function initController(WebmanRequest $request): ?Response
|
|
{
|
|
$this->model = new \app\common\model\BetOrder();
|
|
return null;
|
|
}
|
|
|
|
public function add(WebmanRequest $request): Response
|
|
{
|
|
$response = $this->initializeBackend($request);
|
|
if ($response !== null) {
|
|
return $response;
|
|
}
|
|
return $this->error('注单由游戏接口生成,禁止后台手工新增');
|
|
}
|
|
|
|
public function edit(WebmanRequest $request): Response
|
|
{
|
|
$response = $this->initializeBackend($request);
|
|
if ($response !== null) {
|
|
return $response;
|
|
}
|
|
return $this->error('注单不可编辑');
|
|
}
|
|
|
|
public function del(WebmanRequest $request): Response
|
|
{
|
|
$response = $this->initializeBackend($request);
|
|
if ($response !== null) {
|
|
return $response;
|
|
}
|
|
return $this->error('注单不可删除');
|
|
}
|
|
|
|
public function sortable(WebmanRequest $request): Response
|
|
{
|
|
$response = $this->initializeBackend($request);
|
|
if ($response !== null) {
|
|
return $response;
|
|
}
|
|
return $this->error('不支持排序');
|
|
}
|
|
|
|
/**
|
|
* 渠道管理员仅看本渠道注单
|
|
*/
|
|
protected function _index(): Response
|
|
{
|
|
if ($this->request && $this->request->get('select')) {
|
|
return $this->select($this->request);
|
|
}
|
|
|
|
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
|
$table = strtolower($this->model->getTable());
|
|
$mainShort = $alias[$table] ?? '';
|
|
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
|
|
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
|
|
}
|
|
|
|
$res = $this->model
|
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
|
->with($this->withJoinTable)
|
|
->visible([
|
|
'user' => ['username', 'phone'],
|
|
'channel' => ['name'],
|
|
'gameRecord' => ['period_no', 'status'],
|
|
])
|
|
->alias($alias)
|
|
->where($where)
|
|
->order($order)
|
|
->paginate($limit);
|
|
|
|
return $this->success('', [
|
|
'list' => $res->items(),
|
|
'total' => $res->total(),
|
|
'remark' => get_route_remark(),
|
|
]);
|
|
}
|
|
|
|
}
|