Compare commits
6 Commits
cfe5ec6fb0
...
e3f26ba1f7
| Author | SHA1 | Date | |
|---|---|---|---|
| e3f26ba1f7 | |||
| a4878a9bbd | |||
| 9954ea741b | |||
| 2e0bcd3f23 | |||
| bf3d50a309 | |||
| 3cf386756b |
@@ -16,7 +16,7 @@ class Channel extends Backend
|
|||||||
/**
|
/**
|
||||||
* 预览接口与手动结算共用「手动结算」按钮权限(避免额外菜单节点)
|
* 预览接口与手动结算共用「手动结算」按钮权限(避免额外菜单节点)
|
||||||
*/
|
*/
|
||||||
protected array $noNeedPermission = ['manualSettlePreview'];
|
protected array $noNeedPermission = ['manualSettlePreview', 'channelAdminShareList', 'saveChannelAdminShare'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel模型对象
|
* Channel模型对象
|
||||||
@@ -25,9 +25,9 @@ class Channel extends Backend
|
|||||||
*/
|
*/
|
||||||
protected ?object $model = null;
|
protected ?object $model = null;
|
||||||
|
|
||||||
protected array|string $preExcludeFields = ['id', 'user_count', 'profit_amount', 'create_time', 'update_time'];
|
protected array|string $preExcludeFields = ['id', 'user_count', 'profit_amount', 'create_time', 'update_time', 'admin_id'];
|
||||||
|
|
||||||
protected array $withJoinTable = ['adminGroup', 'admin'];
|
protected array $withJoinTable = [];
|
||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class Channel extends Backend
|
|||||||
if ($response !== null) return $response;
|
if ($response !== null) return $response;
|
||||||
|
|
||||||
$query = Db::name('channel')
|
$query = Db::name('channel')
|
||||||
->field(['id', 'name', 'admin_group_id'])
|
->field(['id', 'name'])
|
||||||
->order('id', 'asc');
|
->order('id', 'asc');
|
||||||
if (!$this->auth->isSuperAdmin()) {
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
$query = $query->where('id', 'in', $this->currentChannelIds ?: [0]);
|
$query = $query->where('id', 'in', $this->currentChannelIds ?: [0]);
|
||||||
@@ -79,11 +79,16 @@ class Channel extends Backend
|
|||||||
|
|
||||||
$tree = [];
|
$tree = [];
|
||||||
foreach ($channels as $ch) {
|
foreach ($channels as $ch) {
|
||||||
$groupId = $ch['admin_group_id'] ?? null;
|
$channelId = (int) ($ch['id'] ?? 0);
|
||||||
|
$rootGroupIds = Db::name('admin_group')
|
||||||
|
->where('channel_id', $channelId)
|
||||||
|
->where('pid', 0)
|
||||||
|
->where('status', 1)
|
||||||
|
->column('id');
|
||||||
$groupIds = [];
|
$groupIds = [];
|
||||||
if ($groupId !== null && $groupId !== '') {
|
foreach ($rootGroupIds as $rootId) {
|
||||||
$groupIds[] = $groupId;
|
$groupIds[] = $rootId;
|
||||||
foreach ($getGroupChildren($groupId) as $gid) {
|
foreach ($getGroupChildren($rootId) as $gid) {
|
||||||
$groupIds[] = $gid;
|
$groupIds[] = $gid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +135,7 @@ class Channel extends Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加(重写:管理员只选顶级组;admin_group_id 后端自动写入)
|
* 添加(重写:渠道与角色组在「角色组」侧绑定 channel_id,此处不再写入 admin_group_id)
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
protected function _add(): Response
|
protected function _add(): Response
|
||||||
@@ -150,30 +155,10 @@ class Channel extends Backend
|
|||||||
}
|
}
|
||||||
unset($data['invite_code']);
|
unset($data['invite_code']);
|
||||||
|
|
||||||
$adminId = $data['admin_id'] ?? null;
|
|
||||||
if ($adminId === null || $adminId === '') {
|
|
||||||
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('admin_group_id', $data)) {
|
if (array_key_exists('admin_group_id', $data)) {
|
||||||
unset($data['admin_group_id']);
|
unset($data['admin_group_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$topGroupId = Db::name('admin_group_access')
|
|
||||||
->alias('aga')
|
|
||||||
->join('admin_group ag', 'aga.group_id = ag.id')
|
|
||||||
->where('aga.uid', $adminId)
|
|
||||||
->where('ag.pid', 0)
|
|
||||||
->value('ag.id');
|
|
||||||
|
|
||||||
if ($topGroupId === null || $topGroupId === '') {
|
|
||||||
return $this->error(__('Record not found'));
|
|
||||||
}
|
|
||||||
$data['admin_group_id'] = $topGroupId;
|
|
||||||
if (!$this->auth->isSuperAdmin()) {
|
|
||||||
$data['admin_id'] = $this->auth->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||||
$data[$this->dataLimitField] = $this->auth->id;
|
$data[$this->dataLimitField] = $this->auth->id;
|
||||||
}
|
}
|
||||||
@@ -207,7 +192,7 @@ class Channel extends Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑(重写:管理员只选顶级组;admin_group_id 后端自动写入)
|
* 编辑(重写:不再维护 channel.admin_group_id)
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
protected function _edit(): Response
|
protected function _edit(): Response
|
||||||
@@ -246,24 +231,6 @@ class Channel extends Backend
|
|||||||
unset($data['admin_group_id']);
|
unset($data['admin_group_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextAdminId = array_key_exists('admin_id', $data) ? $data['admin_id'] : ($row['admin_id'] ?? null);
|
|
||||||
if ($nextAdminId !== null && $nextAdminId !== '') {
|
|
||||||
$topGroupId = Db::name('admin_group_access')
|
|
||||||
->alias('aga')
|
|
||||||
->join('admin_group ag', 'aga.group_id = ag.id')
|
|
||||||
->where('aga.uid', $nextAdminId)
|
|
||||||
->where('ag.pid', 0)
|
|
||||||
->value('ag.id');
|
|
||||||
|
|
||||||
if ($topGroupId === null || $topGroupId === '') {
|
|
||||||
return $this->error(__('Record not found'));
|
|
||||||
}
|
|
||||||
$data['admin_group_id'] = $topGroupId;
|
|
||||||
}
|
|
||||||
if (!$this->auth->isSuperAdmin()) {
|
|
||||||
$data['admin_id'] = $this->auth->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
$this->model->startTrans();
|
$this->model->startTrans();
|
||||||
try {
|
try {
|
||||||
@@ -310,9 +277,6 @@ class Channel extends Backend
|
|||||||
$where[] = [$alias['channel'] . '.id', 'in', $this->currentChannelIds ?: [0]];
|
$where[] = [$alias['channel'] . '.id', 'in', $this->currentChannelIds ?: [0]];
|
||||||
}
|
}
|
||||||
$res = $this->model
|
$res = $this->model
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
|
||||||
->with($this->withJoinTable)
|
|
||||||
->visible(['adminGroup' => ['name'], 'admin' => ['username']])
|
|
||||||
->alias($alias)
|
->alias($alias)
|
||||||
->where($where)
|
->where($where)
|
||||||
->order($order)
|
->order($order)
|
||||||
@@ -358,6 +322,273 @@ class Channel extends Backend
|
|||||||
return $this->success('', $payload);
|
return $this->success('', $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道管理员分配比例列表(用于结算二次分配配置)
|
||||||
|
*/
|
||||||
|
public function channelAdminShareList(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if (!$this->auth->check('channel/edit')) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
$id = (int) ($request->get('id', 0));
|
||||||
|
if ($id <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$row = $this->model->find($id);
|
||||||
|
if (!$row) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->auth->isSuperAdmin() && !in_array((int) $row['id'], $this->currentChannelIds, true)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$adminRows = Db::name('admin')
|
||||||
|
->field(['id', 'username', 'status'])
|
||||||
|
->where('channel_id', (int) $row['id'])
|
||||||
|
->order('id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
$shareRows = Db::name('channel_admin_share')
|
||||||
|
->where('channel_id', (int) $row['id'])
|
||||||
|
->column(['share_rate', 'status'], 'admin_id');
|
||||||
|
|
||||||
|
$adminIds = [];
|
||||||
|
foreach ($adminRows as $adminRow) {
|
||||||
|
$aid = (int) ($adminRow['id'] ?? 0);
|
||||||
|
if ($aid > 0) {
|
||||||
|
$adminIds[] = $aid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$adminIds = array_values(array_unique($adminIds));
|
||||||
|
$roleMetaMap = $this->resolveAdminRoleMetaForChannel((int) $row['id'], $adminIds);
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
foreach ($adminRows as $adminRow) {
|
||||||
|
$aid = (int) ($adminRow['id'] ?? 0);
|
||||||
|
if ($aid <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$saved = $shareRows[$aid] ?? null;
|
||||||
|
$roleMeta = $roleMetaMap[$aid] ?? null;
|
||||||
|
$list[] = [
|
||||||
|
'admin_id' => $aid,
|
||||||
|
'username' => (string) ($adminRow['username'] ?? ''),
|
||||||
|
'role_group_name' => is_array($roleMeta) ? (string) ($roleMeta['role_group_name'] ?? '') : '',
|
||||||
|
'role_level' => is_array($roleMeta) ? (int) ($roleMeta['role_level'] ?? 9999) : 9999,
|
||||||
|
'admin_status' => (string) ($adminRow['status'] ?? ''),
|
||||||
|
'share_rate' => $saved['share_rate'] ?? null,
|
||||||
|
'status' => isset($saved['status']) ? (int) $saved['status'] : 1,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
usort($list, static function (array $a, array $b): int {
|
||||||
|
$levelA = (int) ($a['role_level'] ?? 9999);
|
||||||
|
$levelB = (int) ($b['role_level'] ?? 9999);
|
||||||
|
if ($levelA !== $levelB) {
|
||||||
|
return $levelA <=> $levelB;
|
||||||
|
}
|
||||||
|
$idA = (int) ($a['admin_id'] ?? 0);
|
||||||
|
$idB = (int) ($b['admin_id'] ?? 0);
|
||||||
|
return $idA <=> $idB;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->success('', [
|
||||||
|
'channel_id' => (int) $row['id'],
|
||||||
|
'channel_name' => (string) ($row['name'] ?? ''),
|
||||||
|
'list' => $list,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, int> $adminIds
|
||||||
|
* @return array<int, array{role_group_name:string,role_level:int}>
|
||||||
|
*/
|
||||||
|
private function resolveAdminRoleMetaForChannel(int $channelId, array $adminIds): array
|
||||||
|
{
|
||||||
|
if ($channelId <= 0 || $adminIds === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$groupRows = Db::name('admin_group')
|
||||||
|
->field(['id', 'pid', 'name'])
|
||||||
|
->where('channel_id', $channelId)
|
||||||
|
->order('id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
if ($groupRows === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$groupMap = [];
|
||||||
|
foreach ($groupRows as $groupRow) {
|
||||||
|
$gid = (int) ($groupRow['id'] ?? 0);
|
||||||
|
if ($gid <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$groupMap[$gid] = [
|
||||||
|
'pid' => (int) ($groupRow['pid'] ?? 0),
|
||||||
|
'name' => trim((string) ($groupRow['name'] ?? '')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($groupMap === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$groupDepthById = [];
|
||||||
|
$calcDepth = function (int $groupId) use (&$calcDepth, &$groupDepthById, $groupMap): int {
|
||||||
|
if (isset($groupDepthById[$groupId])) {
|
||||||
|
return $groupDepthById[$groupId];
|
||||||
|
}
|
||||||
|
$current = $groupMap[$groupId] ?? null;
|
||||||
|
if (!$current) {
|
||||||
|
$groupDepthById[$groupId] = 9999;
|
||||||
|
return 9999;
|
||||||
|
}
|
||||||
|
$pid = (int) ($current['pid'] ?? 0);
|
||||||
|
if ($pid <= 0 || !isset($groupMap[$pid])) {
|
||||||
|
$groupDepthById[$groupId] = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
$depth = $calcDepth($pid) + 1;
|
||||||
|
$groupDepthById[$groupId] = $depth;
|
||||||
|
return $depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
$accessRows = Db::name('admin_group_access')
|
||||||
|
->field(['uid', 'group_id'])
|
||||||
|
->where('uid', 'in', $adminIds)
|
||||||
|
->order('uid', 'asc')
|
||||||
|
->order('group_id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
$metaMap = [];
|
||||||
|
foreach ($accessRows as $accessRow) {
|
||||||
|
$uid = (int) ($accessRow['uid'] ?? 0);
|
||||||
|
$groupId = (int) ($accessRow['group_id'] ?? 0);
|
||||||
|
if ($uid <= 0 || $groupId <= 0 || !isset($groupMap[$groupId])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$roleName = trim((string) ($groupMap[$groupId]['name'] ?? ''));
|
||||||
|
if ($roleName === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$depth = $calcDepth($groupId);
|
||||||
|
if (!isset($metaMap[$uid])) {
|
||||||
|
$metaMap[$uid] = [
|
||||||
|
'role_group_name' => $roleName,
|
||||||
|
'role_level' => $depth,
|
||||||
|
'group_id' => $groupId,
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$currentDepth = (int) ($metaMap[$uid]['role_level'] ?? 9999);
|
||||||
|
$currentGroupId = (int) ($metaMap[$uid]['group_id'] ?? 0);
|
||||||
|
if ($depth < $currentDepth || ($depth === $currentDepth && $groupId < $currentGroupId)) {
|
||||||
|
$metaMap[$uid]['role_group_name'] = $roleName;
|
||||||
|
$metaMap[$uid]['role_level'] = $depth;
|
||||||
|
$metaMap[$uid]['group_id'] = $groupId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out = [];
|
||||||
|
foreach ($metaMap as $uid => $meta) {
|
||||||
|
$out[$uid] = [
|
||||||
|
'role_group_name' => (string) ($meta['role_group_name'] ?? ''),
|
||||||
|
'role_level' => (int) ($meta['role_level'] ?? 9999),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存渠道管理员分配比例(启用项总和必须=100)
|
||||||
|
*/
|
||||||
|
public function saveChannelAdminShare(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if (!$this->auth->check('channel/edit')) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'POST') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$id = (int) ($request->post('id', 0));
|
||||||
|
if ($id <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$row = $this->model->find($id);
|
||||||
|
if (!$row) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->auth->isSuperAdmin() && !in_array((int) $row['id'], $this->currentChannelIds, true)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
$rowsRaw = $request->post('list', []);
|
||||||
|
if (!is_array($rowsRaw) || $rowsRaw === []) {
|
||||||
|
return $this->error('请至少配置一条分配记录');
|
||||||
|
}
|
||||||
|
|
||||||
|
$adminIds = Db::name('admin')
|
||||||
|
->where('channel_id', (int) $row['id'])
|
||||||
|
->column('id');
|
||||||
|
$adminIdSet = [];
|
||||||
|
foreach ($adminIds as $adminId) {
|
||||||
|
$adminIdSet[(int) $adminId] = true;
|
||||||
|
}
|
||||||
|
if ($adminIdSet === []) {
|
||||||
|
return $this->error('该渠道下暂无管理员,无法配置分配比例');
|
||||||
|
}
|
||||||
|
|
||||||
|
$enabledSum = '0.0000';
|
||||||
|
$insertRows = [];
|
||||||
|
foreach ($rowsRaw as $line) {
|
||||||
|
if (!is_array($line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$adminId = (int) ($line['admin_id'] ?? 0);
|
||||||
|
if ($adminId <= 0 || !isset($adminIdSet[$adminId])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$status = ((int) ($line['status'] ?? 1)) === 1 ? 1 : 0;
|
||||||
|
$shareRaw = $line['share_rate'] ?? null;
|
||||||
|
$shareRate = self::normalizeAmountScale($shareRaw === null ? '0' : (string) $shareRaw, 4);
|
||||||
|
if (bccomp($shareRate, '0', 4) < 0 || bccomp($shareRate, '100', 4) > 0) {
|
||||||
|
return $this->error('分配比例必须在0到100之间');
|
||||||
|
}
|
||||||
|
if ($status === 1) {
|
||||||
|
$enabledSum = bcadd($enabledSum, $shareRate, 4);
|
||||||
|
}
|
||||||
|
$insertRows[] = [
|
||||||
|
'channel_id' => (int) $row['id'],
|
||||||
|
'admin_id' => $adminId,
|
||||||
|
'share_rate' => $shareRate,
|
||||||
|
'status' => $status,
|
||||||
|
'create_time' => time(),
|
||||||
|
'update_time' => time(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($insertRows === []) {
|
||||||
|
return $this->error('请至少配置一条有效分配记录');
|
||||||
|
}
|
||||||
|
if (bccomp($enabledSum, '100.0000', 4) !== 0) {
|
||||||
|
return $this->error('启用的分配比例总和必须等于100');
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Db::name('channel_admin_share')->where('channel_id', (int) $row['id'])->delete();
|
||||||
|
Db::name('channel_admin_share')->insertAll($insertRows);
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('分配比例保存成功');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动结算(渠道维度):仅接收备注;周期与金额全部由服务端按注单汇总计算,并写入结算周期与佣金记录
|
* 手动结算(渠道维度):仅接收备注;周期与金额全部由服务端按注单汇总计算,并写入结算周期与佣金记录
|
||||||
*/
|
*/
|
||||||
@@ -392,9 +623,9 @@ class Channel extends Backend
|
|||||||
return $this->error('结算单号已存在,请稍后重试');
|
return $this->error('结算单号已存在,请稍后重试');
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminId = $row['admin_id'] ?? null;
|
$shareRows = $this->resolveCommissionSharesForChannel((int) $row['id']);
|
||||||
if ($adminId === null || $adminId === '' || (int) $adminId <= 0) {
|
if ($shareRows === []) {
|
||||||
return $this->error('渠道未绑定代理管理员,无法生成佣金记录');
|
return $this->error('渠道下无可用管理员分配比例,无法生成佣金记录');
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
@@ -413,19 +644,19 @@ class Channel extends Backend
|
|||||||
'update_time' => $now,
|
'update_time' => $now,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::name('agent_commission_record')->insert([
|
$commissionRows = $this->buildCommissionRowsForSplit(
|
||||||
'settlement_period_id' => $periodId,
|
$shareRows,
|
||||||
'channel_id' => (int) $row['id'],
|
(int) $row['id'],
|
||||||
'admin_id' => (int) $adminId,
|
$periodId,
|
||||||
'commission_rate' => $payload['commission_rate'],
|
(string) $payload['calc_base_amount'],
|
||||||
'calc_base_amount' => $payload['calc_base_amount'],
|
(string) $payload['commission_amount'],
|
||||||
'commission_amount' => $payload['commission_amount'],
|
trim($remark) !== '' ? $remark : ('手动结算佣金-CH' . $row['id']),
|
||||||
'status' => 0,
|
$now
|
||||||
'settled_at' => null,
|
);
|
||||||
'remark' => trim($remark) !== '' ? $remark : ('手动结算佣金-CH' . $row['id']),
|
if ($commissionRows === []) {
|
||||||
'create_time' => $now,
|
throw new \RuntimeException('分配比例拆分失败,未生成佣金记录');
|
||||||
'update_time' => $now,
|
}
|
||||||
]);
|
Db::name('agent_commission_record')->insertAll($commissionRows);
|
||||||
|
|
||||||
Db::name('channel')->where('id', $row['id'])->update([
|
Db::name('channel')->where('id', $row['id'])->update([
|
||||||
'update_time' => $now,
|
'update_time' => $now,
|
||||||
@@ -475,6 +706,9 @@ class Channel extends Backend
|
|||||||
|
|
||||||
$settlementNo = $this->generateAgentSettlementNo('M', $channelId, $endTs);
|
$settlementNo = $this->generateAgentSettlementNo('M', $channelId, $endTs);
|
||||||
|
|
||||||
|
$splitRows = $this->resolveCommissionSharesForChannel($channelId);
|
||||||
|
$splitPreview = $this->buildCommissionSplitPreview($splitRows, $commission['commission_amount']);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'settlement_no' => $settlementNo,
|
'settlement_no' => $settlementNo,
|
||||||
'period_start_ts' => $periodStartTs,
|
'period_start_ts' => $periodStartTs,
|
||||||
@@ -488,6 +722,7 @@ class Channel extends Backend
|
|||||||
'calc_base_amount' => $commission['calc_base_amount'],
|
'calc_base_amount' => $commission['calc_base_amount'],
|
||||||
'commission_amount' => $commission['commission_amount'],
|
'commission_amount' => $commission['commission_amount'],
|
||||||
'agent_mode' => $mode,
|
'agent_mode' => $mode,
|
||||||
|
'commission_split' => $splitPreview,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,8 +920,159 @@ class Channel extends Backend
|
|||||||
if ($admin && !empty($admin['channel_id'])) {
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
$ids[] = $admin['channel_id'];
|
$ids[] = $admin['channel_id'];
|
||||||
}
|
}
|
||||||
$byAdmin = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
return array_values(array_unique($ids));
|
||||||
return array_values(array_unique(array_merge($ids, $byAdmin)));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 佣金归属管理员:取该渠道下 admin.channel_id 匹配的首个管理员(按 id 升序)。
|
||||||
|
*/
|
||||||
|
private function resolveCommissionAdminIdForChannel(int $channelId): ?int
|
||||||
|
{
|
||||||
|
if ($channelId <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$aid = Db::name('admin')
|
||||||
|
->where('channel_id', $channelId)
|
||||||
|
->order('id', 'asc')
|
||||||
|
->value('id');
|
||||||
|
if ($aid === null || $aid === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (int) $aid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array{admin_id:int, share_rate:string}>
|
||||||
|
*/
|
||||||
|
private function resolveCommissionSharesForChannel(int $channelId): array
|
||||||
|
{
|
||||||
|
if ($channelId <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$rows = Db::name('channel_admin_share')->alias('cas')
|
||||||
|
->join('admin a', 'cas.admin_id = a.id')
|
||||||
|
->field(['cas.admin_id', 'cas.share_rate'])
|
||||||
|
->where('cas.channel_id', $channelId)
|
||||||
|
->where('cas.status', 1)
|
||||||
|
->where('a.status', 'enable')
|
||||||
|
->order('cas.admin_id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
if ($rows !== []) {
|
||||||
|
$sum = '0.0000';
|
||||||
|
$out = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$adminId = (int) ($row['admin_id'] ?? 0);
|
||||||
|
if ($adminId <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$shareRate = self::normalizeAmountScale((string) ($row['share_rate'] ?? '0'), 4);
|
||||||
|
if (bccomp($shareRate, '0', 4) <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$sum = bcadd($sum, $shareRate, 4);
|
||||||
|
$out[] = [
|
||||||
|
'admin_id' => $adminId,
|
||||||
|
'share_rate' => $shareRate,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($out !== [] && bccomp($sum, '100.0000', 4) === 0) {
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fallbackAdminId = $this->resolveCommissionAdminIdForChannel($channelId);
|
||||||
|
if ($fallbackAdminId === null || $fallbackAdminId <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return [[
|
||||||
|
'admin_id' => (int) $fallbackAdminId,
|
||||||
|
'share_rate' => '100.0000',
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, array{admin_id:int, share_rate:string}> $shareRows
|
||||||
|
* @return array<int, array{settlement_period_id:int, channel_id:int, admin_id:int, commission_rate:string, calc_base_amount:string, commission_amount:string, status:int, settled_at:null, remark:string, create_time:int, update_time:int}>
|
||||||
|
*/
|
||||||
|
private function buildCommissionRowsForSplit(
|
||||||
|
array $shareRows,
|
||||||
|
int $channelId,
|
||||||
|
int $periodId,
|
||||||
|
string $calcBaseAmount,
|
||||||
|
string $commissionTotal,
|
||||||
|
string $remark,
|
||||||
|
int $now
|
||||||
|
): array {
|
||||||
|
if ($shareRows === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$sum = '0.0000';
|
||||||
|
$rows = [];
|
||||||
|
$lastIndex = count($shareRows) - 1;
|
||||||
|
foreach ($shareRows as $index => $shareRow) {
|
||||||
|
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 4);
|
||||||
|
$shareDec = bcdiv($shareRate, '100', 8);
|
||||||
|
$amount = $index === $lastIndex
|
||||||
|
? bcsub($commissionTotal, $sum, 4)
|
||||||
|
: bcmul($commissionTotal, $shareDec, 4);
|
||||||
|
if ($index !== $lastIndex) {
|
||||||
|
$sum = bcadd($sum, $amount, 4);
|
||||||
|
}
|
||||||
|
$effectiveRate = bccomp($calcBaseAmount, '0', 4) <= 0 ? '0.000000' : bcdiv($amount, $calcBaseAmount, 6);
|
||||||
|
$rows[] = [
|
||||||
|
'settlement_period_id' => $periodId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'admin_id' => (int) ($shareRow['admin_id'] ?? 0),
|
||||||
|
'commission_rate' => $effectiveRate,
|
||||||
|
'calc_base_amount' => $calcBaseAmount,
|
||||||
|
'commission_amount' => $amount,
|
||||||
|
'status' => 0,
|
||||||
|
'settled_at' => null,
|
||||||
|
'remark' => $remark . ' | 分配比例=' . $shareRate . '%',
|
||||||
|
'create_time' => $now,
|
||||||
|
'update_time' => $now,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, array{admin_id:int, share_rate:string}> $shareRows
|
||||||
|
* @return array<int, array{admin_id:int, admin_username:string, share_rate:string, commission_amount:string}>
|
||||||
|
*/
|
||||||
|
private function buildCommissionSplitPreview(array $shareRows, string $commissionTotal): array
|
||||||
|
{
|
||||||
|
if ($shareRows === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$adminIds = [];
|
||||||
|
foreach ($shareRows as $shareRow) {
|
||||||
|
$adminIds[] = (int) ($shareRow['admin_id'] ?? 0);
|
||||||
|
}
|
||||||
|
$adminNames = Db::name('admin')->where('id', 'in', $adminIds)->column('username', 'id');
|
||||||
|
|
||||||
|
$sum = '0.0000';
|
||||||
|
$out = [];
|
||||||
|
$lastIndex = count($shareRows) - 1;
|
||||||
|
foreach ($shareRows as $index => $shareRow) {
|
||||||
|
$shareRate = self::normalizeAmountScale((string) ($shareRow['share_rate'] ?? '0'), 4);
|
||||||
|
$shareDec = bcdiv($shareRate, '100', 8);
|
||||||
|
$amount = $index === $lastIndex
|
||||||
|
? bcsub($commissionTotal, $sum, 4)
|
||||||
|
: bcmul($commissionTotal, $shareDec, 4);
|
||||||
|
if ($index !== $lastIndex) {
|
||||||
|
$sum = bcadd($sum, $amount, 4);
|
||||||
|
}
|
||||||
|
$adminId = (int) ($shareRow['admin_id'] ?? 0);
|
||||||
|
$out[] = [
|
||||||
|
'admin_id' => $adminId,
|
||||||
|
'admin_username' => (string) ($adminNames[$adminId] ?? ('#' . $adminId)),
|
||||||
|
'share_rate' => $shareRate,
|
||||||
|
'commission_amount' => $amount,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeAgentModeFields(array $data): array
|
private function normalizeAgentModeFields(array $data): array
|
||||||
@@ -782,6 +1168,35 @@ class Channel extends Backend
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function normalizeAmountScale(string $amount, int $scale): string
|
||||||
|
{
|
||||||
|
$raw = trim(str_replace(',', '.', $amount));
|
||||||
|
if ($raw === '') {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
|
$negative = false;
|
||||||
|
if (str_starts_with($raw, '-')) {
|
||||||
|
$negative = true;
|
||||||
|
$raw = ltrim(substr($raw, 1));
|
||||||
|
}
|
||||||
|
if (!str_contains($raw, '.')) {
|
||||||
|
$v = ltrim($raw, '0');
|
||||||
|
$v = $v === '' ? '0' : $v;
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
[$intPart, $fracPart] = explode('.', $raw, 2);
|
||||||
|
$intPart = ltrim($intPart, '0');
|
||||||
|
$intPart = $intPart === '' ? '0' : $intPart;
|
||||||
|
$fracPart = preg_replace('/\D+/', '', $fracPart) ?? '';
|
||||||
|
if (strlen($fracPart) > $scale) {
|
||||||
|
$fracPart = substr($fracPart, 0, $scale);
|
||||||
|
} else {
|
||||||
|
$fracPart = str_pad($fracPart, $scale, '0');
|
||||||
|
}
|
||||||
|
$v = $intPart . '.' . $fracPart;
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
|
||||||
private function validateLadderRulesField(array &$data): ?string
|
private function validateLadderRulesField(array &$data): ?string
|
||||||
{
|
{
|
||||||
$rulesRaw = $data['affiliate_ladder_rules'] ?? null;
|
$rulesRaw = $data['affiliate_ladder_rules'] ?? null;
|
||||||
|
|||||||
@@ -63,15 +63,6 @@ class Admin extends Backend
|
|||||||
->order($order)
|
->order($order)
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
$items = $res->items();
|
$items = $res->items();
|
||||||
$topGroupUids = $this->getTopGroupUserMap(array_column($items, 'id'));
|
|
||||||
foreach ($items as &$item) {
|
|
||||||
$id = $item['id'] ?? null;
|
|
||||||
if ($id === 1 || isset($topGroupUids[$id])) {
|
|
||||||
$item['commission_rate'] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($item);
|
|
||||||
|
|
||||||
return $this->success('', [
|
return $this->success('', [
|
||||||
'list' => $items,
|
'list' => $items,
|
||||||
'total' => $res->total(),
|
'total' => $res->total(),
|
||||||
@@ -187,24 +178,23 @@ class Admin extends Backend
|
|||||||
$passwd = $data['password'] ?? '';
|
$passwd = $data['password'] ?? '';
|
||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
$creatorChannelId = $this->getCreatorChannelId();
|
$creatorChannelId = $this->getCreatorChannelId();
|
||||||
|
$groupChannelId = $this->resolveChannelIdFromPrimaryGroup($data['group_arr'] ?? []);
|
||||||
if (!$this->auth->isSuperAdmin()) {
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
if ($creatorChannelId === null || $creatorChannelId === '') {
|
if ($creatorChannelId === null || $creatorChannelId === '') {
|
||||||
return $this->error(__('You have no permission'));
|
return $this->error(__('You have no permission'));
|
||||||
}
|
}
|
||||||
|
if ($groupChannelId === null || $groupChannelId === '') {
|
||||||
|
return $this->error('所选角色组未绑定渠道');
|
||||||
|
}
|
||||||
|
if ((string) $groupChannelId !== (string) $creatorChannelId) {
|
||||||
|
return $this->error('所选角色组渠道与当前账号不一致');
|
||||||
|
}
|
||||||
$data['channel_id'] = $creatorChannelId;
|
$data['channel_id'] = $creatorChannelId;
|
||||||
$data['parent_admin_id'] = $this->auth->id;
|
$data['parent_admin_id'] = $this->auth->id;
|
||||||
|
} else {
|
||||||
|
$data['channel_id'] = ($groupChannelId === null || $groupChannelId === '') ? null : $groupChannelId;
|
||||||
}
|
}
|
||||||
$data['invite_code'] = $this->generateUniqueInviteCode();
|
$data['invite_code'] = $this->generateUniqueInviteCode();
|
||||||
$requireCommissionRate = $this->requireCommissionRate($data['group_arr'] ?? []);
|
|
||||||
if ($requireCommissionRate) {
|
|
||||||
if (!$this->isValidCommissionRate($data['commission_rate'] ?? null)) {
|
|
||||||
return $this->error(__('Please enter a valid commission rate for non-top role group'));
|
|
||||||
}
|
|
||||||
$commissionRes = $this->validateAdminCommissionByGroups($data['group_arr'] ?? [], floatval((string)$data['commission_rate']));
|
|
||||||
if ($commissionRes !== null) return $commissionRes;
|
|
||||||
} else {
|
|
||||||
$data['commission_rate'] = null;
|
|
||||||
}
|
|
||||||
$result = false;
|
$result = false;
|
||||||
if (!empty($data['group_arr'])) {
|
if (!empty($data['group_arr'])) {
|
||||||
$authRes = $this->checkGroupAuth($data['group_arr']);
|
$authRes = $this->checkGroupAuth($data['group_arr']);
|
||||||
@@ -268,18 +258,12 @@ class Admin extends Backend
|
|||||||
return $this->error('请选择且仅选择一个角色组');
|
return $this->error('请选择且仅选择一个角色组');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 未提交分红比例时,若角色组未变更则沿用数据库原值(避免表单单项 number 校验把空串判错)
|
|
||||||
$postedGroups = array_map('intval', $data['group_arr'] ?? []);
|
$postedGroups = array_map('intval', $data['group_arr'] ?? []);
|
||||||
$rowGroups = array_map('intval', $row->group_arr ?? []);
|
$rowGroups = array_map('intval', $row->group_arr ?? []);
|
||||||
sort($postedGroups);
|
sort($postedGroups);
|
||||||
sort($rowGroups);
|
sort($rowGroups);
|
||||||
$sameGroups = $postedGroups === $rowGroups;
|
|
||||||
$postedCommission = $data['commission_rate'] ?? null;
|
|
||||||
if (($postedCommission === null || $postedCommission === '') && $sameGroups && $this->isValidCommissionRate($row['commission_rate'] ?? null)) {
|
|
||||||
$data['commission_rate'] = $row['commission_rate'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当前管理员编辑自身时,不允许修改角色组和分红比
|
// 当前管理员编辑自身时,不允许修改角色组
|
||||||
if ((int)$this->auth->id === (int)$id) {
|
if ((int)$this->auth->id === (int)$id) {
|
||||||
$postedGroups = $data['group_arr'] ?? [];
|
$postedGroups = $data['group_arr'] ?? [];
|
||||||
if (!is_array($postedGroups)) {
|
if (!is_array($postedGroups)) {
|
||||||
@@ -288,9 +272,7 @@ class Admin extends Backend
|
|||||||
$originGroups = $row->group_arr ?? [];
|
$originGroups = $row->group_arr ?? [];
|
||||||
sort($postedGroups);
|
sort($postedGroups);
|
||||||
sort($originGroups);
|
sort($originGroups);
|
||||||
$postedRate = $data['commission_rate'] ?? null;
|
if ($postedGroups !== $originGroups) {
|
||||||
$originRate = $row['commission_rate'] ?? null;
|
|
||||||
if ($postedGroups !== $originGroups || (string)$postedRate !== (string)$originRate) {
|
|
||||||
return $this->error(__('You cannot modify your own management group!'));
|
return $this->error(__('You cannot modify your own management group!'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,18 +325,20 @@ class Admin extends Backend
|
|||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
unset($data['invite_code']);
|
unset($data['invite_code']);
|
||||||
$creatorChannelId = $this->getCreatorChannelId();
|
$creatorChannelId = $this->getCreatorChannelId();
|
||||||
if (!$this->auth->isSuperAdmin() && $creatorChannelId !== null && $creatorChannelId !== '') {
|
$groupChannelId = $this->resolveChannelIdFromPrimaryGroup($data['group_arr'] ?? []);
|
||||||
$data['channel_id'] = $creatorChannelId;
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
}
|
if ($creatorChannelId === null || $creatorChannelId === '') {
|
||||||
$requireCommissionRate = $this->requireCommissionRate($data['group_arr'] ?? []);
|
return $this->error(__('You have no permission'));
|
||||||
if ($requireCommissionRate) {
|
|
||||||
if (!$this->isValidCommissionRate($data['commission_rate'] ?? null)) {
|
|
||||||
return $this->error(__('Please enter a valid commission rate for non-top role group'));
|
|
||||||
}
|
}
|
||||||
$commissionRes = $this->validateAdminCommissionByGroups($data['group_arr'] ?? [], floatval((string)$data['commission_rate']), intval((string)$id));
|
if ($groupChannelId === null || $groupChannelId === '') {
|
||||||
if ($commissionRes !== null) return $commissionRes;
|
return $this->error('所选角色组未绑定渠道');
|
||||||
|
}
|
||||||
|
if ((string) $groupChannelId !== (string) $creatorChannelId) {
|
||||||
|
return $this->error('所选角色组渠道与当前账号不一致');
|
||||||
|
}
|
||||||
|
$data['channel_id'] = $creatorChannelId;
|
||||||
} else {
|
} else {
|
||||||
$data['commission_rate'] = null;
|
$data['channel_id'] = ($groupChannelId === null || $groupChannelId === '') ? null : $groupChannelId;
|
||||||
}
|
}
|
||||||
$result = false;
|
$result = false;
|
||||||
$this->model->startTrans();
|
$this->model->startTrans();
|
||||||
@@ -463,10 +447,24 @@ class Admin extends Backend
|
|||||||
if ($currentAdmin && !empty($currentAdmin['channel_id'])) {
|
if ($currentAdmin && !empty($currentAdmin['channel_id'])) {
|
||||||
return $currentAdmin['channel_id'];
|
return $currentAdmin['channel_id'];
|
||||||
}
|
}
|
||||||
$channelId = Db::name('channel')
|
|
||||||
->where('admin_id', $this->auth->id)
|
return null;
|
||||||
->value('id');
|
}
|
||||||
return $channelId ?: null;
|
|
||||||
|
/**
|
||||||
|
* @param array<int|string> $groupIds
|
||||||
|
*/
|
||||||
|
private function resolveChannelIdFromPrimaryGroup(array $groupIds): mixed
|
||||||
|
{
|
||||||
|
if ($groupIds === []) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$gid = $groupIds[0];
|
||||||
|
if ($gid === null || $gid === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Db::name('admin_group')->where('id', $gid)->value('channel_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateUniqueInviteCode(): string
|
private function generateUniqueInviteCode(): string
|
||||||
@@ -480,73 +478,6 @@ class Admin extends Backend
|
|||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function requireCommissionRate(array $groupIds): bool
|
|
||||||
{
|
|
||||||
if (!$groupIds) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$count = Db::name('admin_group')
|
|
||||||
->where('id', 'in', $groupIds)
|
|
||||||
->where('pid', '<>', 0)
|
|
||||||
->count();
|
|
||||||
return $count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isValidCommissionRate(mixed $value): bool
|
|
||||||
{
|
|
||||||
if ($value === null || $value === '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$rate = trim((string)$value);
|
|
||||||
if (!preg_match('/^(100(\.00?)?|[0-9]{1,2}(\.[0-9]{1,2})?)$/', $rate)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function validateAdminCommissionByGroups(array $groupIds, float $currentRate, ?int $excludeAdminId = null): ?Response
|
|
||||||
{
|
|
||||||
if (!$groupIds) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$groups = Db::name('admin_group')
|
|
||||||
->where('id', 'in', $groupIds)
|
|
||||||
->where('pid', '<>', 0)
|
|
||||||
->column('name', 'id');
|
|
||||||
foreach ($groups as $groupId => $groupName) {
|
|
||||||
$query = Db::name('admin_group_access')->alias('aga')
|
|
||||||
->join('admin a', 'aga.uid = a.id')
|
|
||||||
->where('aga.group_id', intval((string)$groupId));
|
|
||||||
if ($excludeAdminId !== null) {
|
|
||||||
$query = $query->where('a.id', '<>', $excludeAdminId);
|
|
||||||
}
|
|
||||||
$sum = (float)$query->sum('a.commission_rate');
|
|
||||||
$remaining = 100 - $sum;
|
|
||||||
if ($currentRate > $remaining + 0.000001) {
|
|
||||||
$exceed = $currentRate - $remaining;
|
|
||||||
return $this->error(sprintf('角色组[%s]分红比例总和不能超过100%%,当前剩余 %.2f%%,本次超出 %.2f%%', $groupName, max(0, $remaining), $exceed));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getTopGroupUserMap(array $userIds): array
|
|
||||||
{
|
|
||||||
if (!$userIds) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
$uids = Db::name('admin_group_access')->alias('aga')
|
|
||||||
->join('admin_group ag', 'aga.group_id = ag.id')
|
|
||||||
->where('aga.uid', 'in', $userIds)
|
|
||||||
->where('ag.pid', 0)
|
|
||||||
->column('aga.uid');
|
|
||||||
$map = [];
|
|
||||||
foreach ($uids as $uid) {
|
|
||||||
$map[$uid] = true;
|
|
||||||
}
|
|
||||||
return $map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function normalizeSingleGroup(array $data): array
|
private function normalizeSingleGroup(array $data): array
|
||||||
{
|
{
|
||||||
if (!array_key_exists('group_arr', $data)) {
|
if (!array_key_exists('group_arr', $data)) {
|
||||||
|
|||||||
@@ -86,17 +86,9 @@ class Group extends Backend
|
|||||||
if (!$this->auth->isSuperAdmin() && $pidInt !== 0 && !in_array($pidInt, $this->manageableGroupIds, true)) {
|
if (!$this->auth->isSuperAdmin() && $pidInt !== 0 && !in_array($pidInt, $this->manageableGroupIds, true)) {
|
||||||
return $this->error(__('You have no permission'));
|
return $this->error(__('You have no permission'));
|
||||||
}
|
}
|
||||||
$shouldHandleCommissionRate = true;
|
$inheritRes = $this->applyChannelInheritance($data, $pidInt);
|
||||||
if ($shouldHandleCommissionRate) {
|
if ($inheritRes !== null) {
|
||||||
if (!$this->isValidCommissionRate($data['commission_rate'] ?? null)) {
|
return $inheritRes;
|
||||||
return $this->error(__('Please enter the correct field', ['commission_rate']));
|
|
||||||
}
|
|
||||||
if ($pidInt !== 0) {
|
|
||||||
$commissionRes = $this->validateSiblingCommissionRate($pidInt, floatval((string)$data['commission_rate']));
|
|
||||||
if ($commissionRes !== null) return $commissionRes;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$data['commission_rate'] = 0;
|
|
||||||
}
|
}
|
||||||
$rulesRes = $this->handleRules($data);
|
$rulesRes = $this->handleRules($data);
|
||||||
if ($rulesRes instanceof Response) return $rulesRes;
|
if ($rulesRes instanceof Response) return $rulesRes;
|
||||||
@@ -165,17 +157,9 @@ class Group extends Backend
|
|||||||
if (!$this->auth->isSuperAdmin() && $pidInt !== 0 && !in_array($pidInt, $this->manageableGroupIds, true)) {
|
if (!$this->auth->isSuperAdmin() && $pidInt !== 0 && !in_array($pidInt, $this->manageableGroupIds, true)) {
|
||||||
return $this->error(__('You have no permission'));
|
return $this->error(__('You have no permission'));
|
||||||
}
|
}
|
||||||
$shouldHandleCommissionRate = true;
|
$inheritRes = $this->applyChannelInheritance($data, $pidInt);
|
||||||
if ($shouldHandleCommissionRate) {
|
if ($inheritRes !== null) {
|
||||||
if (!$this->isValidCommissionRate($data['commission_rate'] ?? null)) {
|
return $inheritRes;
|
||||||
return $this->error(__('Please enter the correct field', ['commission_rate']));
|
|
||||||
}
|
|
||||||
if ($pidInt !== 0) {
|
|
||||||
$commissionRes = $this->validateSiblingCommissionRate($pidInt, floatval((string)$data['commission_rate']), intval((string)$row['id']));
|
|
||||||
if ($commissionRes !== null) return $commissionRes;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$data['commission_rate'] = 0;
|
|
||||||
}
|
}
|
||||||
$rulesRes = $this->handleRules($data);
|
$rulesRes = $this->handleRules($data);
|
||||||
if ($rulesRes instanceof Response) return $rulesRes;
|
if ($rulesRes instanceof Response) return $rulesRes;
|
||||||
@@ -204,6 +188,7 @@ class Group extends Backend
|
|||||||
return $this->error($e->getMessage());
|
return $this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
|
$this->syncDescendantChannelIds(intval((string)$row['id']));
|
||||||
return $this->success(__('Update successful'));
|
return $this->success(__('Update successful'));
|
||||||
}
|
}
|
||||||
return $this->error(__('No rows updated'));
|
return $this->error(__('No rows updated'));
|
||||||
@@ -223,11 +208,39 @@ class Group extends Backend
|
|||||||
}
|
}
|
||||||
$rowData = $row->toArray();
|
$rowData = $row->toArray();
|
||||||
$rowData['rules'] = array_values($rules);
|
$rowData['rules'] = array_values($rules);
|
||||||
|
$rowData = $this->enrichChannelDisplay($rowData);
|
||||||
return $this->success('', [
|
return $this->success('', [
|
||||||
'row' => $rowData
|
'row' => $rowData
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单只读展示:根据 channel_id 解析渠道名称与渠道负责人(admin.channel_id → admin.username,取首个)
|
||||||
|
*/
|
||||||
|
public function channelBindPreview(Request $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
$cid = $request->get('channel_id') ?? $request->post('channel_id');
|
||||||
|
if ($cid === null || $cid === '') {
|
||||||
|
return $this->success('', [
|
||||||
|
'channel_name' => '',
|
||||||
|
'channel_admin_username' => '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (!Db::name('channel')->where('id', $cid)->value('id')) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
$row = $this->enrichChannelDisplay(['channel_id' => $cid]);
|
||||||
|
|
||||||
|
return $this->success('', [
|
||||||
|
'channel_name' => $row['channel_name'] ?? '',
|
||||||
|
'channel_admin_username' => $row['channel_admin_username'] ?? '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function del(Request $request): Response
|
public function del(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeBackend($request);
|
$response = $this->initializeBackend($request);
|
||||||
@@ -353,7 +366,21 @@ class Group extends Backend
|
|||||||
}
|
}
|
||||||
$data = $this->model->where($where)->select()->toArray();
|
$data = $this->model->where($where)->select()->toArray();
|
||||||
|
|
||||||
|
$channelIds = [];
|
||||||
|
foreach ($data as $datum) {
|
||||||
|
$c = $datum['channel_id'] ?? null;
|
||||||
|
if ($c !== null && $c !== '') {
|
||||||
|
$channelIds[] = $c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$channelNames = [];
|
||||||
|
if ($channelIds !== []) {
|
||||||
|
$channelNames = Db::name('channel')->where('id', 'in', array_unique($channelIds))->column('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data as &$datum) {
|
foreach ($data as &$datum) {
|
||||||
|
$c = $datum['channel_id'] ?? null;
|
||||||
|
$datum['channel_name'] = ($c !== null && $c !== '') ? ($channelNames[$c] ?? '') : '';
|
||||||
if ($datum['rules']) {
|
if ($datum['rules']) {
|
||||||
if ($datum['rules'] == '*') {
|
if ($datum['rules'] == '*') {
|
||||||
$datum['rules'] = __('Super administrator');
|
$datum['rules'] = __('Super administrator');
|
||||||
@@ -368,6 +395,7 @@ class Group extends Backend
|
|||||||
$datum['rules'] = __('No permission');
|
$datum['rules'] = __('No permission');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($datum);
|
||||||
|
|
||||||
return $this->assembleTree ? $this->tree->assembleChild($data) : $data;
|
return $this->assembleTree ? $this->tree->assembleChild($data) : $data;
|
||||||
}
|
}
|
||||||
@@ -391,30 +419,84 @@ class Group extends Backend
|
|||||||
return array_values(array_unique(array_merge($own, $children)));
|
return array_values(array_unique(array_merge($own, $children)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isValidCommissionRate(mixed $value): bool
|
/**
|
||||||
|
* 顶级角色组可选渠道;子级继承父级 channel_id(不信任客户端提交的子级 channel_id)。
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
private function applyChannelInheritance(array &$data, int $pidInt): ?Response
|
||||||
{
|
{
|
||||||
if ($value === null || $value === '') {
|
if ($pidInt === 0) {
|
||||||
return false;
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
unset($data['channel_id']);
|
||||||
|
$cc = $this->getCreatorChannelId();
|
||||||
|
if ($cc !== null && $cc !== '') {
|
||||||
|
$data['channel_id'] = $cc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cid = $data['channel_id'] ?? null;
|
||||||
|
if ($cid !== null && $cid !== '') {
|
||||||
|
$exists = Db::name('channel')->where('id', $cid)->value('id');
|
||||||
|
if (!$exists) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
$rate = trim((string)$value);
|
|
||||||
if (!preg_match('/^(100(\.00?)?|[0-9]{1,2}(\.[0-9]{1,2})?)$/', $rate)) {
|
unset($data['channel_id']);
|
||||||
return false;
|
$parent = Db::name('admin_group')->where('id', $pidInt)->find();
|
||||||
|
if (!$parent) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
}
|
}
|
||||||
return true;
|
$data['channel_id'] = $parent['channel_id'];
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateSiblingCommissionRate(int $pid, float $currentRate, ?int $excludeId = null): ?Response
|
/**
|
||||||
|
* @param array<string, mixed> $row
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function enrichChannelDisplay(array $row): array
|
||||||
{
|
{
|
||||||
$query = Db::name('admin_group')->where('pid', $pid);
|
$row['channel_name'] = '';
|
||||||
if ($excludeId !== null) {
|
$row['channel_admin_username'] = '';
|
||||||
$query = $query->where('id', '<>', $excludeId);
|
$cid = $row['channel_id'] ?? null;
|
||||||
|
if ($cid === null || $cid === '') {
|
||||||
|
return $row;
|
||||||
}
|
}
|
||||||
$sum = (float)$query->sum('commission_rate');
|
$ch = Db::name('channel')->where('id', $cid)->field(['id', 'name'])->find();
|
||||||
$remaining = 100 - $sum;
|
if (!$ch) {
|
||||||
if ($currentRate > $remaining + 0.000001) {
|
return $row;
|
||||||
$exceed = $currentRate - $remaining;
|
|
||||||
return $this->error(sprintf('同一父级角色组分红比例总和不能超过100%%,当前父级剩余 %.2f%%,本次超出 %.2f%%', max(0, $remaining), $exceed));
|
|
||||||
}
|
}
|
||||||
|
$row['channel_name'] = $ch['name'] ?? '';
|
||||||
|
$row['channel_admin_username'] = (string) (Db::name('admin')->where('channel_id', $cid)->order('id', 'asc')->value('username') ?? '');
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function syncDescendantChannelIds(int $groupId): void
|
||||||
|
{
|
||||||
|
$channelId = Db::name('admin_group')->where('id', $groupId)->value('channel_id');
|
||||||
|
$children = Db::name('admin_group')->where('pid', $groupId)->column('id');
|
||||||
|
foreach ($children as $childId) {
|
||||||
|
Db::name('admin_group')->where('id', $childId)->update(['channel_id' => $channelId]);
|
||||||
|
$this->syncDescendantChannelIds($childId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCreatorChannelId(): mixed
|
||||||
|
{
|
||||||
|
$currentAdmin = Db::name('admin')
|
||||||
|
->field(['id', 'channel_id'])
|
||||||
|
->where('id', $this->auth->id)
|
||||||
|
->find();
|
||||||
|
if ($currentAdmin && !empty($currentAdmin['channel_id'])) {
|
||||||
|
return $currentAdmin['channel_id'];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
130
app/admin/controller/config/DepositTier.php
Normal file
130
app/admin/controller/config/DepositTier.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\config;
|
||||||
|
|
||||||
|
use app\common\controller\Backend;
|
||||||
|
use app\common\library\game\DepositTier as DepositTierLib;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use support\think\Db;
|
||||||
|
use support\Response;
|
||||||
|
use Throwable;
|
||||||
|
use Webman\Http\Request as WebmanRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值档位独立编辑(仅 game_config.deposit_tier)
|
||||||
|
*/
|
||||||
|
class DepositTier extends Backend
|
||||||
|
{
|
||||||
|
protected bool $modelValidate = false;
|
||||||
|
|
||||||
|
protected array $noNeedPermission = ['index', 'save'];
|
||||||
|
|
||||||
|
private function hasNodePermission(WebmanRequest $request, string $action): bool
|
||||||
|
{
|
||||||
|
if (!$this->auth) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$controllerPath = get_controller_path($request);
|
||||||
|
if (!$controllerPath) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$paths = [];
|
||||||
|
$paths[] = $controllerPath . '/' . $action;
|
||||||
|
$parts = explode('/', $controllerPath);
|
||||||
|
foreach ($parts as &$part) {
|
||||||
|
if (str_contains($part, '_')) {
|
||||||
|
$part = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $part))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$paths[] = implode('/', $parts) . '/' . $action;
|
||||||
|
foreach (array_values(array_unique($paths)) as $path) {
|
||||||
|
if ($this->auth->check($path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function initController(WebmanRequest $request): ?Response
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取 game_config.deposit_tier 的档位列表
|
||||||
|
*/
|
||||||
|
public function index(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if (!$this->hasNodePermission($request, 'index')) {
|
||||||
|
return $this->error(__('You have no permission'), [], 401);
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'GET') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$row = Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->find();
|
||||||
|
$items = DepositTierLib::parseFromConfigValue($row['config_value'] ?? null);
|
||||||
|
return $this->success('', [
|
||||||
|
'items' => $items,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存 JSON 数组(value_type=json)
|
||||||
|
*/
|
||||||
|
public function save(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if (!$this->hasNodePermission($request, 'save')) {
|
||||||
|
return $this->error(__('You have no permission'), [], 401);
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'POST') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$payload = $request->post();
|
||||||
|
if (!is_array($payload)) {
|
||||||
|
return $this->error(__('Parameter %s can not be empty', ['']));
|
||||||
|
}
|
||||||
|
$items = $payload['items'] ?? null;
|
||||||
|
if (!is_array($items)) {
|
||||||
|
return $this->error('items 必须为数组');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$clean = DepositTierLib::prepareItemsForSave(array_values($items));
|
||||||
|
$json = DepositTierLib::encodeForDb($clean);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
try {
|
||||||
|
$exists = Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->find();
|
||||||
|
if ($exists) {
|
||||||
|
Db::name('game_config')->where('config_key', DepositTierLib::CONFIG_KEY)->update([
|
||||||
|
'config_value' => $json,
|
||||||
|
'value_type' => 'json',
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Db::name('game_config')->insert([
|
||||||
|
'config_key' => DepositTierLib::CONFIG_KEY,
|
||||||
|
'config_value' => $json,
|
||||||
|
'value_type' => 'json',
|
||||||
|
'remark' => '充值档位 JSON 数组(独立表单维护)',
|
||||||
|
'create_time' => $now,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success(__('Saved successfully'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ class Record extends Backend
|
|||||||
{
|
{
|
||||||
protected ?object $model = null;
|
protected ?object $model = null;
|
||||||
|
|
||||||
protected string|array $preExcludeFields = ['id', 'create_time', 'update_time'];
|
protected string|array $preExcludeFields = ['id', 'create_time', 'update_time', 'platform_profit_amount', 'winner_user_count'];
|
||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'period_no'];
|
protected string|array $quickSearchField = ['id', 'period_no'];
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ class BetOrder extends Backend
|
|||||||
if ($admin && !empty($admin['channel_id'])) {
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
$ids[] = $admin['channel_id'];
|
$ids[] = $admin['channel_id'];
|
||||||
}
|
}
|
||||||
$byAdmin = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
return array_values(array_unique($ids));
|
||||||
return array_values(array_unique(array_merge($ids, $byAdmin)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ use Webman\Http\Request as WebmanRequest;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 充值订单
|
* 充值订单
|
||||||
|
*
|
||||||
|
* 订单的"由 0 转 1(成功入账)"统一走 app\common\library\finance\DepositSettlement。
|
||||||
|
* 当前充值接口为 mock 支付网关,点击即成功;后台不再保留人工审核按钮,
|
||||||
|
* 如需人工补单,请通过后续专门的"补单/冲正"工具完成,而不是在这个 CRUD 里直接改 status。
|
||||||
|
*
|
||||||
|
* 编辑入口现在只用于"查看详情":GET 返回订单 + 关联的 user/channel 信息,
|
||||||
|
* 阻止 POST 任何改字段的动作(保证金额、状态只能由结算服务变更)。
|
||||||
*/
|
*/
|
||||||
class DepositOrder extends Backend
|
class DepositOrder extends Backend
|
||||||
{
|
{
|
||||||
@@ -18,7 +25,7 @@ class DepositOrder extends Backend
|
|||||||
|
|
||||||
protected bool $modelSceneValidate = true;
|
protected bool $modelSceneValidate = true;
|
||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'order_no', 'pay_channel', 'remark'];
|
protected string|array $quickSearchField = ['id', 'order_no', 'pay_channel', 'remark', 'deposit_tier_id', 'idempotency_key'];
|
||||||
|
|
||||||
protected string|array $defaultSortField = ['id' => 'desc'];
|
protected string|array $defaultSortField = ['id' => 'desc'];
|
||||||
|
|
||||||
@@ -65,6 +72,69 @@ class DepositOrder extends Backend
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET 时返回关联信息,便于前端详情弹窗直接渲染 user.username / channel.name;
|
||||||
|
* POST 一律拒绝,保证充值订单的金额/状态只能由结算服务变更。
|
||||||
|
*/
|
||||||
|
protected function _edit(): Response
|
||||||
|
{
|
||||||
|
$pk = $this->model->getPk();
|
||||||
|
$id = $this->request ? ($this->request->post($pk) ?? $this->request->get($pk)) : null;
|
||||||
|
if ($id === null || $id === '') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request && $this->request->method() === 'POST') {
|
||||||
|
return $this->error('充值订单为自动入账,禁止直接修改,如需补单请走专用工具');
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = $this->loadWithRelations(intval(strval($id)));
|
||||||
|
if (!$row) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->checkChannelScoped($row)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('', ['row' => $row]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadWithRelations(int $id): ?array
|
||||||
|
{
|
||||||
|
$row = $this->model
|
||||||
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
|
->with($this->withJoinTable)
|
||||||
|
->visible([
|
||||||
|
'user' => ['username', 'phone'],
|
||||||
|
'channel' => ['name'],
|
||||||
|
])
|
||||||
|
->where($this->model->getTable() . '.id', $id)
|
||||||
|
->find();
|
||||||
|
if (!$row) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $row->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkChannelScoped(array $row): bool
|
||||||
|
{
|
||||||
|
if (!$this->auth || $this->auth->isSuperAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$channelIds = $this->getScopedChannelIdsForFilter();
|
||||||
|
if ($channelIds === []) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$raw = $row['channel_id'] ?? null;
|
||||||
|
if ($raw === null || $raw === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!is_numeric(strval($raw))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return in_array(intval(strval($raw)), $channelIds, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +151,6 @@ class DepositOrder extends Backend
|
|||||||
if ($admin && !empty($admin['channel_id'])) {
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
$ids[] = $admin['channel_id'];
|
$ids[] = $admin['channel_id'];
|
||||||
}
|
}
|
||||||
$byAdmin = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
return array_values(array_unique($ids));
|
||||||
return array_values(array_unique(array_merge($ids, $byAdmin)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,16 @@ namespace app\admin\controller\order;
|
|||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
use support\think\Db;
|
use support\think\Db;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
|
use Throwable;
|
||||||
use Webman\Http\Request as WebmanRequest;
|
use Webman\Http\Request as WebmanRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提现订单
|
* 提现订单
|
||||||
|
*
|
||||||
|
* 当前审核流转:
|
||||||
|
* - 用户端提交提现时,立即冻结余额(user.coin - apply_amount)并生成 withdraw_order(status=0)与 withdraw 流水(direction=2)。
|
||||||
|
* - 管理员在后台审核:通过(approve)→ status=1;拒绝(reject)→ status=2 并回冲用户余额与流水。
|
||||||
|
* - 通过流程不再额外扣钱包,因为申请时已冻结;仅在管理员调整 amount/fee 时写一条差额流水。
|
||||||
*/
|
*/
|
||||||
class WithdrawOrder extends Backend
|
class WithdrawOrder extends Backend
|
||||||
{
|
{
|
||||||
@@ -66,6 +72,387 @@ class WithdrawOrder extends Backend
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET 时返回关联信息,便于编辑弹窗直接渲染 user.username/channel.name
|
||||||
|
*/
|
||||||
|
protected function _edit(): Response
|
||||||
|
{
|
||||||
|
$pk = $this->model->getPk();
|
||||||
|
$id = $this->request ? ($this->request->post($pk) ?? $this->request->get($pk)) : null;
|
||||||
|
if ($id === null || $id === '') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request && $this->request->method() === 'POST') {
|
||||||
|
// 历史 CRUD 的 POST 编辑已被 approve/reject 替代,这里阻止直接改金额绕过审核流程
|
||||||
|
return $this->error('请使用通过/拒绝按钮完成审核');
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = $this->loadWithRelations(intval(strval($id)));
|
||||||
|
if (!$row) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->checkChannelScoped($row)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
return $this->success('', ['row' => $row]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核通过:允许调整 amount/fee;actual_amount 自动为 amount - fee。
|
||||||
|
* 对金额差额自动在用户钱包与流水中做增减,保持账务平衡。
|
||||||
|
*/
|
||||||
|
public function approve(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'POST') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->intParam($request->post('id'));
|
||||||
|
if ($id <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$newAmount = $this->decimalParam($request->post('amount'), '0');
|
||||||
|
$newFee = $this->decimalParam($request->post('fee'), '0');
|
||||||
|
if (bccomp($newAmount, '0', 4) <= 0) {
|
||||||
|
return $this->error('申请金额必须大于 0');
|
||||||
|
}
|
||||||
|
if (bccomp($newFee, '0', 4) < 0) {
|
||||||
|
return $this->error('手续费不能为负');
|
||||||
|
}
|
||||||
|
if (bccomp($newFee, $newAmount, 4) > 0) {
|
||||||
|
return $this->error('手续费不能大于申请金额');
|
||||||
|
}
|
||||||
|
$newActual = bcsub($newAmount, $newFee, 4);
|
||||||
|
|
||||||
|
$remarkRaw = $request->post('remark');
|
||||||
|
$remark = is_string($remarkRaw) ? trim($remarkRaw) : '';
|
||||||
|
|
||||||
|
$order = Db::name('withdraw_order')->where('id', $id)->find();
|
||||||
|
if (!$order) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->checkChannelScoped($order)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
$currentStatus = $this->intParam($order['status'] ?? 0);
|
||||||
|
if ($currentStatus !== 0) {
|
||||||
|
return $this->error('该订单已审核,无需重复操作');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userId = $this->intParam($order['user_id'] ?? 0);
|
||||||
|
if ($userId <= 0) {
|
||||||
|
return $this->error('订单缺少用户信息');
|
||||||
|
}
|
||||||
|
$oldAmount = bcadd(strval($order['amount'] ?? '0'), '0', 4);
|
||||||
|
$diff = bcsub($newAmount, $oldAmount, 4);
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$adminId = $this->intParam($this->auth->id ?? 0);
|
||||||
|
$adminName = $this->adminDisplayName();
|
||||||
|
$channelIdRaw = $order['channel_id'] ?? null;
|
||||||
|
$channelId = ($channelIdRaw === null || $channelIdRaw === '')
|
||||||
|
? null
|
||||||
|
: $this->intParam($channelIdRaw);
|
||||||
|
if ($remark === '') {
|
||||||
|
$remark = '管理员(' . $adminName . ')审核通过:金额 '
|
||||||
|
. $this->shortAmount($newAmount) . ',手续费 ' . $this->shortAmount($newFee)
|
||||||
|
. ',实际到账 ' . $this->shortAmount($newActual);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// 金额调整差额处理
|
||||||
|
$cmp = bccomp($diff, '0', 4);
|
||||||
|
if ($cmp > 0) {
|
||||||
|
// 新金额更大:再冻结用户 diff
|
||||||
|
$userRow = Db::name('user')->where('id', $userId)->find();
|
||||||
|
if (!$userRow) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error('关联用户不存在');
|
||||||
|
}
|
||||||
|
$beforeCoin = bcadd(strval($userRow['coin'] ?? '0'), '0', 4);
|
||||||
|
if (bccomp($beforeCoin, $diff, 4) < 0) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error('用户余额不足以补扣调整差额');
|
||||||
|
}
|
||||||
|
$afterCoin = bcsub($beforeCoin, $diff, 4);
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $afterCoin,
|
||||||
|
'total_withdraw_coin' => Db::raw('total_withdraw_coin + ' . $diff),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => 'withdraw',
|
||||||
|
'direction' => 2,
|
||||||
|
'amount' => $diff,
|
||||||
|
'balance_before' => $beforeCoin,
|
||||||
|
'balance_after' => $afterCoin,
|
||||||
|
'ref_type' => 'withdraw_order',
|
||||||
|
'ref_id' => $id,
|
||||||
|
'idempotency_key' => 'wd_adjust_add_' . strval($order['order_no'] ?? $id) . '_' . $now,
|
||||||
|
'operator_admin_id' => $adminId > 0 ? $adminId : null,
|
||||||
|
'remark' => '管理员(' . $adminName . ')审核调增申请金额差额 '
|
||||||
|
. $this->shortAmount($diff),
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
} elseif ($cmp < 0) {
|
||||||
|
// 新金额更小:退回差额
|
||||||
|
$abs = bcsub('0', $diff, 4);
|
||||||
|
$userRow = Db::name('user')->where('id', $userId)->find();
|
||||||
|
if (!$userRow) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error('关联用户不存在');
|
||||||
|
}
|
||||||
|
$beforeCoin = bcadd(strval($userRow['coin'] ?? '0'), '0', 4);
|
||||||
|
$afterCoin = bcadd($beforeCoin, $abs, 4);
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $afterCoin,
|
||||||
|
'total_withdraw_coin' => Db::raw('total_withdraw_coin - ' . $abs),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => 'withdraw_refund',
|
||||||
|
'direction' => 1,
|
||||||
|
'amount' => $abs,
|
||||||
|
'balance_before' => $beforeCoin,
|
||||||
|
'balance_after' => $afterCoin,
|
||||||
|
'ref_type' => 'withdraw_order',
|
||||||
|
'ref_id' => $id,
|
||||||
|
'idempotency_key' => 'wd_adjust_sub_' . strval($order['order_no'] ?? $id) . '_' . $now,
|
||||||
|
'operator_admin_id' => $adminId > 0 ? $adminId : null,
|
||||||
|
'remark' => '管理员(' . $adminName . ')审核调减申请金额差额 '
|
||||||
|
. $this->shortAmount($abs),
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::name('withdraw_order')->where('id', $id)->update([
|
||||||
|
'amount' => $newAmount,
|
||||||
|
'fee' => $newFee,
|
||||||
|
'actual_amount' => $newActual,
|
||||||
|
'status' => 1,
|
||||||
|
'review_admin_id' => $adminId > 0 ? $adminId : null,
|
||||||
|
'review_time' => $now,
|
||||||
|
'remark' => substr($remark, 0, 255),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('审核通过', [
|
||||||
|
'id' => $id,
|
||||||
|
'amount' => $newAmount,
|
||||||
|
'fee' => $newFee,
|
||||||
|
'actual_amount' => $newActual,
|
||||||
|
'status' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核拒绝:必须填写驳回原因(remark)。
|
||||||
|
* 回冲申请时的冻结:user.coin += amount;total_withdraw_coin -= amount;写一条 withdraw_refund 流水。
|
||||||
|
*/
|
||||||
|
public function reject(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'POST') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->intParam($request->post('id'));
|
||||||
|
if ($id <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$remarkRaw = $request->post('remark');
|
||||||
|
$remark = is_string($remarkRaw) ? trim($remarkRaw) : '';
|
||||||
|
if ($remark === '') {
|
||||||
|
return $this->error('请填写拒绝原因');
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = Db::name('withdraw_order')->where('id', $id)->find();
|
||||||
|
if (!$order) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
if (!$this->checkChannelScoped($order)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
$currentStatus = $this->intParam($order['status'] ?? 0);
|
||||||
|
if ($currentStatus !== 0) {
|
||||||
|
return $this->error('该订单已审核,无需重复操作');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userId = $this->intParam($order['user_id'] ?? 0);
|
||||||
|
if ($userId <= 0) {
|
||||||
|
return $this->error('订单缺少用户信息');
|
||||||
|
}
|
||||||
|
$amount = bcadd(strval($order['amount'] ?? '0'), '0', 4);
|
||||||
|
$channelIdRaw = $order['channel_id'] ?? null;
|
||||||
|
$channelId = ($channelIdRaw === null || $channelIdRaw === '')
|
||||||
|
? null
|
||||||
|
: $this->intParam($channelIdRaw);
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$adminId = $this->intParam($this->auth->id ?? 0);
|
||||||
|
$adminName = $this->adminDisplayName();
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$userRow = Db::name('user')->where('id', $userId)->find();
|
||||||
|
if (!$userRow) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error('关联用户不存在');
|
||||||
|
}
|
||||||
|
$beforeCoin = bcadd(strval($userRow['coin'] ?? '0'), '0', 4);
|
||||||
|
$afterCoin = bcadd($beforeCoin, $amount, 4);
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $afterCoin,
|
||||||
|
'total_withdraw_coin' => Db::raw('total_withdraw_coin - ' . $amount),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => 'withdraw_refund',
|
||||||
|
'direction' => 1,
|
||||||
|
'amount' => $amount,
|
||||||
|
'balance_before' => $beforeCoin,
|
||||||
|
'balance_after' => $afterCoin,
|
||||||
|
'ref_type' => 'withdraw_order',
|
||||||
|
'ref_id' => $id,
|
||||||
|
'idempotency_key' => 'wd_reject_' . strval($order['order_no'] ?? $id) . '_' . $now,
|
||||||
|
'operator_admin_id' => $adminId > 0 ? $adminId : null,
|
||||||
|
'remark' => '管理员(' . $adminName . ')驳回提现,退回冻结金额 '
|
||||||
|
. $this->shortAmount($amount) . ':' . $remark,
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::name('withdraw_order')->where('id', $id)->update([
|
||||||
|
'status' => 2,
|
||||||
|
'review_admin_id' => $adminId > 0 ? $adminId : null,
|
||||||
|
'review_time' => $now,
|
||||||
|
'remark' => substr($remark, 0, 255),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('审核已拒绝', [
|
||||||
|
'id' => $id,
|
||||||
|
'status' => 2,
|
||||||
|
'remark' => $remark,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadWithRelations(int $id): ?array
|
||||||
|
{
|
||||||
|
$row = $this->model
|
||||||
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
|
->with($this->withJoinTable)
|
||||||
|
->visible([
|
||||||
|
'user' => ['username', 'phone'],
|
||||||
|
'channel' => ['name'],
|
||||||
|
'reviewAdmin' => ['username'],
|
||||||
|
])
|
||||||
|
->where($this->model->getTable() . '.id', $id)
|
||||||
|
->find();
|
||||||
|
if (!$row) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $row->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkChannelScoped(array|object $row): bool
|
||||||
|
{
|
||||||
|
if (!$this->auth || $this->auth->isSuperAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$channelIds = $this->getScopedChannelIdsForFilter();
|
||||||
|
if ($channelIds === []) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$raw = is_array($row) ? ($row['channel_id'] ?? null) : ($row->channel_id ?? null);
|
||||||
|
if ($raw === null || $raw === '') {
|
||||||
|
// 无归属渠道的数据只有超管可见
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$cid = $this->intParam($raw);
|
||||||
|
return in_array($cid, $channelIds, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function intParam($raw): int
|
||||||
|
{
|
||||||
|
if ($raw === null || $raw === '') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!is_numeric(strval($raw))) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return intval(strval($raw));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function decimalParam($raw, string $default): string
|
||||||
|
{
|
||||||
|
if ($raw === null || $raw === '' || !is_numeric(strval($raw))) {
|
||||||
|
return bcadd($default, '0', 4);
|
||||||
|
}
|
||||||
|
return bcadd(strval($raw), '0', 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function adminDisplayName(): string
|
||||||
|
{
|
||||||
|
if (!$this->auth) {
|
||||||
|
return 'admin';
|
||||||
|
}
|
||||||
|
$name = $this->auth->username ?? null;
|
||||||
|
if (is_string($name) && $name !== '') {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
$id = $this->intParam($this->auth->id ?? 0);
|
||||||
|
return '#' . strval($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把 4 位小数金额压缩成最多 2 位小数用于展示(不影响落库精度)
|
||||||
|
*/
|
||||||
|
private function shortAmount(string $amount): string
|
||||||
|
{
|
||||||
|
if (!is_numeric($amount)) {
|
||||||
|
return $amount;
|
||||||
|
}
|
||||||
|
$normalized = bcadd($amount, '0', 4);
|
||||||
|
$negative = false;
|
||||||
|
if (str_starts_with($normalized, '-')) {
|
||||||
|
$negative = true;
|
||||||
|
$normalized = substr($normalized, 1);
|
||||||
|
}
|
||||||
|
$parts = explode('.', $normalized, 2);
|
||||||
|
$intPart = $parts[0] ?? '0';
|
||||||
|
$fracPart = $parts[1] ?? '0000';
|
||||||
|
$displayFrac = substr($fracPart, 0, 2);
|
||||||
|
$v = $intPart . '.' . str_pad($displayFrac, 2, '0');
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +469,6 @@ class WithdrawOrder extends Backend
|
|||||||
if ($admin && !empty($admin['channel_id'])) {
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
$ids[] = $admin['channel_id'];
|
$ids[] = $admin['channel_id'];
|
||||||
}
|
}
|
||||||
$byAdmin = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
return array_values(array_unique($ids));
|
||||||
return array_values(array_unique(array_merge($ids, $byAdmin)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class User extends Backend
|
|||||||
*/
|
*/
|
||||||
protected ?object $model = null;
|
protected ?object $model = null;
|
||||||
|
|
||||||
protected array|string $preExcludeFields = ['id', 'uuid', 'create_time', 'update_time'];
|
protected array|string $preExcludeFields = ['id', 'uuid', 'create_time', 'update_time', 'invite_code', 'coin', 'total_deposit_coin', 'total_withdraw_coin', 'bet_flow_coin'];
|
||||||
|
|
||||||
protected array $withJoinTable = ['channel', 'admin'];
|
protected array $withJoinTable = ['channel', 'admin'];
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class User extends Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加(重写:password 使用 Admin 同款加密;uuid 由 username+channel_id 生成)
|
* 添加(重写:password 使用 Admin 同款加密;uuid 为 10 位唯一对外标识)
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
protected function _add(): Response
|
protected function _add(): Response
|
||||||
@@ -47,6 +47,10 @@ class User extends Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->applyInputFilter($data);
|
$data = $this->applyInputFilter($data);
|
||||||
|
$inviteResolved = $this->applyInviteCodeToUserChannel($data);
|
||||||
|
if ($inviteResolved !== null) {
|
||||||
|
return $inviteResolved;
|
||||||
|
}
|
||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
|
|
||||||
$password = $data['password'] ?? null;
|
$password = $data['password'] ?? null;
|
||||||
@@ -60,7 +64,7 @@ class User extends Backend
|
|||||||
if (!is_string($username) || trim($username) === '' || $channelId === null || $channelId === '') {
|
if (!is_string($username) || trim($username) === '' || $channelId === null || $channelId === '') {
|
||||||
return $this->error(__('Parameter %s can not be empty', ['username/channel_id']));
|
return $this->error(__('Parameter %s can not be empty', ['username/channel_id']));
|
||||||
}
|
}
|
||||||
$data['uuid'] = md5(trim($username) . '|' . $channelId);
|
$data['uuid'] = \app\common\model\User::generateUniquePublicCode10();
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||||
$data[$this->dataLimitField] = $this->auth->id;
|
$data[$this->dataLimitField] = $this->auth->id;
|
||||||
@@ -95,7 +99,7 @@ class User extends Backend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑(重写:password 使用 Admin 同款加密;uuid 由 username+channel_id 生成)
|
* 编辑(重写:password 使用 Admin 同款加密;uuid 创建后不因改名改渠道自动变更)
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
protected function _edit(): Response
|
protected function _edit(): Response
|
||||||
@@ -130,18 +134,6 @@ class User extends Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextUsername = array_key_exists('username', $data) ? $data['username'] : $row['username'];
|
|
||||||
$nextChannelId = null;
|
|
||||||
if (array_key_exists('channel_id', $data)) {
|
|
||||||
$nextChannelId = $data['channel_id'];
|
|
||||||
} else {
|
|
||||||
$nextChannelId = $row['channel_id'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($nextUsername) && trim($nextUsername) !== '' && $nextChannelId !== null && $nextChannelId !== '') {
|
|
||||||
$data['uuid'] = md5(trim($nextUsername) . '|' . $nextChannelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
$this->model->startTrans();
|
$this->model->startTrans();
|
||||||
try {
|
try {
|
||||||
@@ -208,6 +200,159 @@ class User extends Backend
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台钱包加减点(不允许在用户编辑表单直接改余额)
|
||||||
|
*/
|
||||||
|
public function walletAdjust(WebmanRequest $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeBackend($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
if ($request->method() !== 'POST') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$userIdRaw = $request->post('user_id');
|
||||||
|
$userId = is_numeric(strval($userIdRaw)) ? intval(strval($userIdRaw)) : 0;
|
||||||
|
if ($userId <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$opRaw = $request->post('op');
|
||||||
|
$op = is_string($opRaw) ? trim($opRaw) : '';
|
||||||
|
if (!in_array($op, ['credit', 'deduct'], true)) {
|
||||||
|
return $this->error('操作类型不正确');
|
||||||
|
}
|
||||||
|
|
||||||
|
$amountRaw = $request->post('amount');
|
||||||
|
$amountText = is_string($amountRaw) || is_numeric($amountRaw) ? trim(strval($amountRaw)) : '';
|
||||||
|
if ($amountText === '' || !is_numeric($amountText)) {
|
||||||
|
return $this->error('金额格式不正确');
|
||||||
|
}
|
||||||
|
if (bccomp($amountText, '0', 4) <= 0) {
|
||||||
|
return $this->error('金额必须大于0');
|
||||||
|
}
|
||||||
|
|
||||||
|
$remarkRaw = $request->post('remark');
|
||||||
|
$remark = is_string($remarkRaw) ? trim($remarkRaw) : '';
|
||||||
|
$adminName = is_string($this->auth->username ?? null) ? $this->auth->username : ('#' . strval($this->auth->id));
|
||||||
|
$amountForRemark = self::formatAmountForDisplay($amountText);
|
||||||
|
if ($remark === '') {
|
||||||
|
$actionText = $op === 'credit' ? '加点' : '扣点';
|
||||||
|
$remark = '后台管理员(' . $adminName . ')' . $actionText . $amountForRemark . '(值)';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->model->where('id', $userId)->find();
|
||||||
|
if (!$user) {
|
||||||
|
return $this->error(__('Record not found'));
|
||||||
|
}
|
||||||
|
$dataLimitAdminIds = $this->getDataLimitAdminIds();
|
||||||
|
if ($dataLimitAdminIds && !in_array($user[$this->dataLimitField], $dataLimitAdminIds)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$channelIdRaw = $user['channel_id'] ?? null;
|
||||||
|
$channelId = is_numeric(strval($channelIdRaw)) ? intval(strval($channelIdRaw)) : null;
|
||||||
|
$before = strval($user['coin'] ?? '0');
|
||||||
|
$delta = self::normalizeAmountScale($amountText, 4);
|
||||||
|
if ($op === 'credit') {
|
||||||
|
$after = bcadd($before, $delta, 4);
|
||||||
|
$bizType = 'admin_credit';
|
||||||
|
$direction = 1;
|
||||||
|
} else {
|
||||||
|
if (bccomp($before, $delta, 4) < 0) {
|
||||||
|
return $this->error('余额不足,扣点失败');
|
||||||
|
}
|
||||||
|
$after = bcsub($before, $delta, 4);
|
||||||
|
$bizType = 'admin_deduct';
|
||||||
|
$direction = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$idem = 'admin_adjust_' . $userId . '_' . $this->auth->id . '_' . $now . '_' . random_int(1000, 9999);
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $after,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => $bizType,
|
||||||
|
'direction' => $direction,
|
||||||
|
'amount' => $delta,
|
||||||
|
'balance_before' => $before,
|
||||||
|
'balance_after' => $after,
|
||||||
|
'ref_type' => 'admin_user_wallet_adjust',
|
||||||
|
'ref_id' => null,
|
||||||
|
'idempotency_key' => $idem,
|
||||||
|
'operator_admin_id' => intval(strval($this->auth->id)),
|
||||||
|
'remark' => substr($remark, 0, 500),
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('钱包调整成功', [
|
||||||
|
'user_id' => $userId,
|
||||||
|
'coin_before' => self::formatAmountForDisplay($before),
|
||||||
|
'coin_after' => self::formatAmountForDisplay($after),
|
||||||
|
'amount' => self::formatAmountForDisplay($delta),
|
||||||
|
'op' => $op,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function normalizeAmountScale(string $amount, int $scale): string
|
||||||
|
{
|
||||||
|
$raw = trim(str_replace(',', '.', $amount));
|
||||||
|
if ($raw === '') {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
|
$negative = false;
|
||||||
|
if (str_starts_with($raw, '-')) {
|
||||||
|
$negative = true;
|
||||||
|
$raw = ltrim(substr($raw, 1));
|
||||||
|
}
|
||||||
|
if (!str_contains($raw, '.')) {
|
||||||
|
$v = ltrim($raw, '0');
|
||||||
|
$v = $v === '' ? '0' : $v;
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
[$intPart, $fracPart] = explode('.', $raw, 2);
|
||||||
|
$intPart = ltrim($intPart, '0');
|
||||||
|
$intPart = $intPart === '' ? '0' : $intPart;
|
||||||
|
$fracPart = preg_replace('/\D+/', '', $fracPart) ?? '';
|
||||||
|
if (strlen($fracPart) > $scale) {
|
||||||
|
$fracPart = substr($fracPart, 0, $scale);
|
||||||
|
} else {
|
||||||
|
$fracPart = str_pad($fracPart, $scale, '0');
|
||||||
|
}
|
||||||
|
$v = $intPart . '.' . $fracPart;
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function formatAmountForDisplay(string $amount): string
|
||||||
|
{
|
||||||
|
$normalized = self::normalizeAmountScale($amount, 4);
|
||||||
|
$negative = false;
|
||||||
|
if (str_starts_with($normalized, '-')) {
|
||||||
|
$negative = true;
|
||||||
|
$normalized = substr($normalized, 1);
|
||||||
|
}
|
||||||
|
$parts = explode('.', $normalized, 2);
|
||||||
|
$intPart = $parts[0] ?? '0';
|
||||||
|
$fracPart = $parts[1] ?? '0000';
|
||||||
|
$displayFrac = substr($fracPart, 0, 2);
|
||||||
|
$v = $intPart . '.' . str_pad($displayFrac, 2, '0');
|
||||||
|
return $negative ? ('-' . $v) : $v;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色组 → 管理员树(仅当前账号可管理的角色组及其下管理员;用于游戏用户归属)
|
* 角色组 → 管理员树(仅当前账号可管理的角色组及其下管理员;用于游戏用户归属)
|
||||||
* 同一管理员若属于多个组,只挂在 id 最小的所属组下,避免树中重复 value
|
* 同一管理员若属于多个组,只挂在 id 最小的所属组下,避免树中重复 value
|
||||||
@@ -337,6 +482,63 @@ class User extends Backend
|
|||||||
return array_values(array_unique(array_merge($own, $children)));
|
return array_values(array_unique(array_merge($own, $children)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求中的 `invite_code`(子代理 admin.invite_code)解析为 `channel_id`,并写入 `register_invite_code`、`admin_id`。
|
||||||
|
* 若同时提交 `channel_id` / `admin_id`,须与邀请码对应记录一致。
|
||||||
|
*/
|
||||||
|
private function applyInviteCodeToUserChannel(array &$data): ?Response
|
||||||
|
{
|
||||||
|
if (!array_key_exists('invite_code', $data)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$raw = $data['invite_code'];
|
||||||
|
unset($data['invite_code']);
|
||||||
|
$inviteCode = is_string($raw) ? trim($raw) : '';
|
||||||
|
if ($inviteCode === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = Db::name('admin')->field(['id', 'channel_id'])->where('invite_code', $inviteCode)->find();
|
||||||
|
if (!$row) {
|
||||||
|
return $this->error(__('Invite code does not exist'));
|
||||||
|
}
|
||||||
|
$cid = $row['channel_id'] ?? null;
|
||||||
|
if ($cid === null || $cid === '') {
|
||||||
|
return $this->error(__('Invite code not bound to channel'));
|
||||||
|
}
|
||||||
|
$cidInt = intval(trim((string) $cid));
|
||||||
|
if ($cidInt <= 0) {
|
||||||
|
return $this->error(__('Invite code not bound to channel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['channel_id']) && $data['channel_id'] !== null && $data['channel_id'] !== '') {
|
||||||
|
$existing = intval(trim((string) $data['channel_id']));
|
||||||
|
if ($existing > 0 && $existing !== $cidInt) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['channel_id'] = $cidInt;
|
||||||
|
$data['register_invite_code'] = $inviteCode;
|
||||||
|
|
||||||
|
$aidRaw = $row['id'] ?? null;
|
||||||
|
if ($aidRaw === null || $aidRaw === '') {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
$aidInt = intval(trim((string) $aidRaw));
|
||||||
|
if ($aidInt <= 0) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
if (isset($data['admin_id']) && $data['admin_id'] !== null && $data['admin_id'] !== '') {
|
||||||
|
$reqAid = intval(trim((string) $data['admin_id']));
|
||||||
|
if ($reqAid > 0 && $reqAid !== $aidInt) {
|
||||||
|
return $this->error(__('Parameter error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['admin_id'] = $aidInt;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\admin\controller\record;
|
namespace app\admin\controller\user;
|
||||||
|
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
use support\think\Db;
|
use support\think\Db;
|
||||||
@@ -124,7 +124,6 @@ class UserWalletRecord extends Backend
|
|||||||
if ($admin && !empty($admin['channel_id'])) {
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
$ids[] = $admin['channel_id'];
|
$ids[] = $admin['channel_id'];
|
||||||
}
|
}
|
||||||
$byAdmin = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
return array_values(array_unique($ids));
|
||||||
return array_values(array_unique(array_merge($ids, $byAdmin)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,14 @@ namespace app\api\controller;
|
|||||||
use ba\Date;
|
use ba\Date;
|
||||||
use ba\Captcha;
|
use ba\Captcha;
|
||||||
use ba\Random;
|
use ba\Random;
|
||||||
|
use app\common\library\finance\WithdrawFlow;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
use app\common\facade\Token;
|
use app\common\facade\Token;
|
||||||
use app\common\model\UserScoreLog;
|
use app\common\model\UserScoreLog;
|
||||||
use app\common\model\UserMoneyLog;
|
use app\common\model\UserMoneyLog;
|
||||||
use app\common\controller\Frontend;
|
use app\common\controller\Frontend;
|
||||||
use app\common\facade\Token as TokenFacade;
|
use app\common\facade\Token as TokenFacade;
|
||||||
|
use support\think\Db;
|
||||||
use support\validation\Validator;
|
use support\validation\Validator;
|
||||||
use support\validation\ValidationException;
|
use support\validation\ValidationException;
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
@@ -41,16 +43,60 @@ class Account extends Frontend
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->auth->getUser();
|
$user = $this->auth->getUser();
|
||||||
|
$userId = intval(strval($user->id));
|
||||||
|
$coinBalance = WithdrawFlow::amountString($user->coin ?? '0');
|
||||||
|
|
||||||
|
// 打码量 / 提现配额快照
|
||||||
|
$flow = WithdrawFlow::status($userId, [
|
||||||
|
'total_deposit_coin' => $user->total_deposit_coin ?? '0',
|
||||||
|
'total_withdraw_coin' => $user->total_withdraw_coin ?? '0',
|
||||||
|
'bet_flow_coin' => $user->bet_flow_coin ?? '0',
|
||||||
|
]);
|
||||||
|
$maxWithdrawable = WithdrawFlow::maxWithdrawable($coinBalance, $flow);
|
||||||
|
|
||||||
|
// 待审核提现订单数(配合 /api/finance/withdrawCreate 的 3 笔上限)
|
||||||
|
$pendingWithdrawCount = Db::name('withdraw_order')
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->where('status', 0)
|
||||||
|
->count();
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'message' => __('ok'),
|
'message' => __('ok'),
|
||||||
'data' => [
|
'data' => [
|
||||||
'username' => $user->username,
|
'uuid' => $user->uuid ?? '',
|
||||||
'head_image' => $user->avatar ?? '',
|
'username' => $user->username,
|
||||||
'coin' => $user->coin,
|
'head_image' => $user->avatar ?? '',
|
||||||
'current_streak' => $user->current_streak ?? 0,
|
'phone' => $user->phone ?? '',
|
||||||
'channel_id' => $user->channel_id,
|
'email' => $user->email ?? '',
|
||||||
'risk_flags' => $user->risk_flags ?? 0,
|
'register_invite_code' => $user->register_invite_code ?? '',
|
||||||
|
'channel_id' => $user->channel_id,
|
||||||
|
'risk_flags' => $user->risk_flags ?? 0,
|
||||||
|
'current_streak' => $user->current_streak ?? 0,
|
||||||
|
'last_bet_period_no' => $user->last_bet_period_no ?? '',
|
||||||
|
'create_time' => $user->create_time ?? 0,
|
||||||
|
|
||||||
|
// 资金字段(4 位小数字符串,与 /api/wallet/balanceSummary 对齐)
|
||||||
|
'coin' => $coinBalance,
|
||||||
|
'coin_balance' => $coinBalance,
|
||||||
|
'frozen_balance' => '0.0000',
|
||||||
|
'total_deposit_coin' => WithdrawFlow::amountString($user->total_deposit_coin ?? '0'),
|
||||||
|
'total_withdraw_coin' => WithdrawFlow::amountString($user->total_withdraw_coin ?? '0'),
|
||||||
|
'bet_flow_coin' => $flow['bet_flow_coin'],
|
||||||
|
'max_withdrawable' => $maxWithdrawable,
|
||||||
|
'withdraw_flow' => [
|
||||||
|
'ratio' => $flow['ratio'],
|
||||||
|
'net_deposit' => $flow['net_deposit'],
|
||||||
|
'required_bet_flow' => $flow['required_bet_flow'],
|
||||||
|
'remaining_bet_flow' => $flow['remaining_bet_flow'],
|
||||||
|
'eligible' => $flow['eligible'],
|
||||||
|
'max_withdraw_by_flow' => $flow['flow_unlimited'] ? null : $flow['max_withdraw_by_flow'],
|
||||||
|
'flow_unlimited' => $flow['flow_unlimited'],
|
||||||
|
'pending_withdraw' => [
|
||||||
|
'count' => $pendingWithdrawCount,
|
||||||
|
'max' => WithdrawFlow::MAX_PENDING_WITHDRAW,
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
return \response(json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 200, ['Content-Type' => 'application/json']);
|
return \response(json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 200, ['Content-Type' => 'application/json']);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use support\Response;
|
|||||||
class Auth extends MobileBase
|
class Auth extends MobileBase
|
||||||
{
|
{
|
||||||
protected array $noNeedLogin = ['register', 'login', 'refreshToken', 'userRegister', 'userLogin', 'tokenRefresh'];
|
protected array $noNeedLogin = ['register', 'login', 'refreshToken', 'userRegister', 'userLogin', 'tokenRefresh'];
|
||||||
protected array $noNeedAuthToken = ['register', 'login', 'refreshToken', 'userRegister', 'userLogin', 'tokenRefresh'];
|
protected array $noNeedAuthToken = ['register', 'refreshToken', 'userRegister', 'tokenRefresh'];
|
||||||
|
|
||||||
public function userRegister(Request $request): Response
|
public function userRegister(Request $request): Response
|
||||||
{
|
{
|
||||||
@@ -34,6 +34,9 @@ class Auth extends MobileBase
|
|||||||
if ($username === '' || $password === '') {
|
if ($username === '' || $password === '') {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
|
if ($inviteCode === '') {
|
||||||
|
return $this->mobileError(1001, 'Invite code required');
|
||||||
|
}
|
||||||
if (!preg_match('/^1[3-9]\d{9}$/', $username)) {
|
if (!preg_match('/^1[3-9]\d{9}$/', $username)) {
|
||||||
return $this->mobileError(1003, 'Please enter the correct mobile number');
|
return $this->mobileError(1003, 'Please enter the correct mobile number');
|
||||||
}
|
}
|
||||||
@@ -41,19 +44,33 @@ class Auth extends MobileBase
|
|||||||
$phone = $username;
|
$phone = $username;
|
||||||
$email = '';
|
$email = '';
|
||||||
|
|
||||||
$extend = [];
|
if (User::where('username', $username)->find() || User::where('phone', $username)->find()) {
|
||||||
if ($inviteCode !== '') {
|
return $this->mobileError(2003, 'Account already registered', [
|
||||||
$inviterAdmin = Db::name('admin')->field(['id', 'channel_id'])->where('invite_code', $inviteCode)->find();
|
'already_registered' => true,
|
||||||
if (!$inviterAdmin) {
|
]);
|
||||||
return $this->mobileError(2002, 'Invite code does not exist');
|
|
||||||
}
|
|
||||||
$extend['register_invite_code'] = $inviteCode;
|
|
||||||
$extend['admin_id'] = $inviterAdmin['id'];
|
|
||||||
$extend['channel_id'] = $inviterAdmin['channel_id'] ?? null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$extend = [];
|
||||||
|
$inviterAdmin = Db::name('admin')->field(['id', 'channel_id'])->where('invite_code', $inviteCode)->find();
|
||||||
|
if (!$inviterAdmin) {
|
||||||
|
return $this->mobileError(2002, 'Invite code does not exist');
|
||||||
|
}
|
||||||
|
$extend['register_invite_code'] = $inviteCode;
|
||||||
|
$extend['admin_id'] = $inviterAdmin['id'];
|
||||||
|
$channelId = $inviterAdmin['channel_id'] ?? null;
|
||||||
|
if ($channelId === null || $channelId === '' || (int) $channelId <= 0) {
|
||||||
|
return $this->mobileError(2002, 'Invite code not bound to channel');
|
||||||
|
}
|
||||||
|
$extend['channel_id'] = (int) $channelId;
|
||||||
|
|
||||||
$registered = $this->auth->register($username, $password, $phone, $email, 1, $extend);
|
$registered = $this->auth->register($username, $password, $phone, $email, 1, $extend);
|
||||||
if (!$registered) {
|
if (!$registered) {
|
||||||
|
$dup = $this->auth->getRegisterDuplicateKind();
|
||||||
|
if ($dup === 'username' || $dup === 'email' || $dup === 'phone') {
|
||||||
|
return $this->mobileError(2003, 'Account already registered', [
|
||||||
|
'already_registered' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
return $this->mobileError(2000, (string) $this->auth->getError());
|
return $this->mobileError(2000, (string) $this->auth->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +139,7 @@ class Auth extends MobileBase
|
|||||||
'expires_in' => config('buildadmin.user_token_keep_time', 259200),
|
'expires_in' => config('buildadmin.user_token_keep_time', 259200),
|
||||||
'user' => [
|
'user' => [
|
||||||
'username' => $userInfo['username'] ?? '',
|
'username' => $userInfo['username'] ?? '',
|
||||||
|
'uuid' => $userInfo['uuid'] ?? '',
|
||||||
'coin' => $userInfo['coin'] ?? '0.0000',
|
'coin' => $userInfo['coin'] ?? '0.0000',
|
||||||
'channel_id' => $userInfo['channel_id'] ?? null,
|
'channel_id' => $userInfo['channel_id'] ?? null,
|
||||||
'risk_flags' => $userInfo['risk_flags'] ?? 0,
|
'risk_flags' => $userInfo['risk_flags'] ?? 0,
|
||||||
|
|||||||
@@ -4,57 +4,230 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\library\finance\DepositSettlement;
|
||||||
|
use app\common\library\finance\WithdrawFlow;
|
||||||
|
use app\common\library\game\DepositTier as DepositTierLib;
|
||||||
use app\common\model\DepositOrder;
|
use app\common\model\DepositOrder;
|
||||||
|
use app\common\model\GameConfig;
|
||||||
use app\common\model\WithdrawOrder;
|
use app\common\model\WithdrawOrder;
|
||||||
use Webman\Http\Request;
|
|
||||||
use support\Response;
|
use support\Response;
|
||||||
|
use support\think\Db;
|
||||||
|
use Throwable;
|
||||||
|
use Webman\Http\Request;
|
||||||
|
|
||||||
class Finance extends MobileBase
|
class Finance extends MobileBase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 充值档位列表(仅启用档位,按 sort 升序)
|
||||||
|
*/
|
||||||
|
public function depositTierList(Request $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeMobile($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lang = $this->currentLang();
|
||||||
|
$tiers = $this->loadEnabledTiers();
|
||||||
|
$list = [];
|
||||||
|
foreach ($tiers as $tier) {
|
||||||
|
$amount = $this->amountString($tier['amount'] ?? '0');
|
||||||
|
$bonus = $this->amountString($tier['bonus_amount'] ?? '0');
|
||||||
|
$total = bcadd($amount, $bonus, 4);
|
||||||
|
$localized = DepositTierLib::localize($tier, $lang);
|
||||||
|
$list[] = [
|
||||||
|
'id' => $tier['id'],
|
||||||
|
'title' => $localized['title'],
|
||||||
|
'amount' => $amount,
|
||||||
|
'bonus_amount' => $bonus,
|
||||||
|
'total_amount' => $total,
|
||||||
|
'desc' => $localized['desc'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $this->mobileSuccess([
|
||||||
|
'list' => $list,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前请求语言标识(由中间件 LoadLangPack 设置到 locale),规范为小写、以 "-" 连字
|
||||||
|
*/
|
||||||
|
private function currentLang(): string
|
||||||
|
{
|
||||||
|
$lang = function_exists('locale') ? locale() : '';
|
||||||
|
if (!is_string($lang) || $lang === '') {
|
||||||
|
return 'zh-cn';
|
||||||
|
}
|
||||||
|
return strtolower(str_replace('_', '-', $lang));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建充值订单
|
||||||
|
*
|
||||||
|
* 当前为 mock 支付网关,点击即成功:服务端直接在同一请求内完成订单入账。
|
||||||
|
* 未来接入真实第三方支付时,仅需把 "立即结算" 替换为 "返回 pay_url 进入网关",
|
||||||
|
* 并把入账动作放到网关回调里完成(回调中调用 DepositSettlement::settle)。
|
||||||
|
*
|
||||||
|
* 请求:application/json 或 x-www-form-urlencoded
|
||||||
|
* - tier_id: 必填,档位 ID(需在 game_config.deposit_tier 启用档位内)
|
||||||
|
* - idempotency_key: 必填,客户端幂等键,短时间内重复提交只生成一次订单
|
||||||
|
*
|
||||||
|
* 响应(统一结构,未来接入第三方也保持此形状):
|
||||||
|
* - order_no / amount / pay_channel / paid / pay_url / status / create_time / pay_time
|
||||||
|
*/
|
||||||
public function depositCreate(Request $request): Response
|
public function depositCreate(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeMobile($request);
|
$response = $this->initializeMobile($request);
|
||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$payAmountFiat = (string) $request->post('pay_amount_fiat', '');
|
|
||||||
$fiatCurrency = trim((string) $request->post('fiat_currency', ''));
|
$tierId = $this->stringParam($request->input('tier_id'));
|
||||||
$channel = trim((string) $request->post('channel', ''));
|
$idempotencyKey = $this->stringParam($request->input('idempotency_key'));
|
||||||
$idempotencyKey = trim((string) $request->post('idempotency_key', ''));
|
if ($tierId === '' || $idempotencyKey === '') {
|
||||||
if ($payAmountFiat === '' || $fiatCurrency === '' || $channel === '' || $idempotencyKey === '') {
|
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
|
if (mb_strlen($idempotencyKey) > 64) {
|
||||||
|
return $this->mobileError(1002, 'Idempotency key is too long');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tiers = $this->loadEnabledTiers();
|
||||||
|
$tier = DepositTierLib::findById($tiers, $tierId);
|
||||||
|
if (!$tier) {
|
||||||
|
return $this->mobileError(2003, 'Deposit tier not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 幂等命中:直接返回已有订单
|
||||||
|
try {
|
||||||
|
$existing = DepositOrder::where('idempotency_key', $idempotencyKey)->find();
|
||||||
|
if ($existing) {
|
||||||
|
if (intval($existing->user_id) !== intval($this->auth->id)) {
|
||||||
|
return $this->mobileError(1002, 'Idempotency key conflict');
|
||||||
|
}
|
||||||
|
return $this->mobileSuccess($this->buildDepositResponse($existing));
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
// 忽略幂等查询失败,继续创建
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->auth->getUser();
|
||||||
$orderNo = 'DP' . date('YmdHis') . substr(str_replace('.', '', uniqid('', true)), -6);
|
$orderNo = 'DP' . date('YmdHis') . substr(str_replace('.', '', uniqid('', true)), -6);
|
||||||
$coinAmount = $payAmountFiat;
|
$tierSnapshot = [
|
||||||
DepositOrder::create([
|
'id' => $tier['id'],
|
||||||
'order_no' => $orderNo,
|
'title' => is_string($tier['title'] ?? null) ? $tier['title'] : '',
|
||||||
'user_id' => $this->auth->id,
|
'title_en' => is_string($tier['title_en'] ?? null) ? $tier['title_en'] : '',
|
||||||
'fiat_currency' => $fiatCurrency,
|
'amount' => $this->amountString($tier['amount'] ?? '0'),
|
||||||
'fiat_amount' => $payAmountFiat,
|
'bonus_amount' => $this->amountString($tier['bonus_amount'] ?? '0'),
|
||||||
'fx_rate' => '1.00000000',
|
'desc' => is_string($tier['desc'] ?? null) ? $tier['desc'] : '',
|
||||||
'coin_amount' => $coinAmount,
|
'desc_en' => is_string($tier['desc_en'] ?? null) ? $tier['desc_en'] : '',
|
||||||
'gateway' => $channel,
|
];
|
||||||
'status' => 0,
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->mobileSuccess([
|
$now = time();
|
||||||
'order_no' => $orderNo,
|
$channelId = null;
|
||||||
'coin_amount' => $coinAmount,
|
if (isset($user->channel_id) && is_numeric(strval($user->channel_id))) {
|
||||||
'pay_url' => '',
|
$channelId = intval(strval($user->channel_id));
|
||||||
'status' => 'pending',
|
}
|
||||||
]);
|
|
||||||
|
$orderId = 0;
|
||||||
|
try {
|
||||||
|
$order = DepositOrder::create([
|
||||||
|
'order_no' => $orderNo,
|
||||||
|
'idempotency_key' => $idempotencyKey,
|
||||||
|
'user_id' => intval($user->id),
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'amount' => $tierSnapshot['amount'],
|
||||||
|
'bonus_amount' => $tierSnapshot['bonus_amount'],
|
||||||
|
'status' => 0,
|
||||||
|
'pay_channel' => 'mock_gateway',
|
||||||
|
'deposit_tier_id' => $tier['id'],
|
||||||
|
'proof_image' => '',
|
||||||
|
'pay_account_snapshot' => json_encode($tierSnapshot, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
|
||||||
|
'remark' => '',
|
||||||
|
'create_time' => $now,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
$orderId = intval($order->id);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$msg = $e->getMessage();
|
||||||
|
if (stripos($msg, 'Duplicate') !== false && stripos($msg, 'uk_deposit_order_idem') !== false) {
|
||||||
|
$existing = DepositOrder::where('idempotency_key', $idempotencyKey)->find();
|
||||||
|
if ($existing) {
|
||||||
|
return $this->mobileSuccess($this->buildDepositResponse($existing));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->mobileError(2000, $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock 网关:立即结算,入账到钱包
|
||||||
|
try {
|
||||||
|
DepositSettlement::settle(
|
||||||
|
$orderId,
|
||||||
|
DepositSettlement::SOURCE_MOCK_GATEWAY,
|
||||||
|
'mock gateway auto settled'
|
||||||
|
);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
return $this->mobileError(2000, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$settled = DepositOrder::where('id', $orderId)->find();
|
||||||
|
if (!$settled) {
|
||||||
|
return $this->mobileError(2000, 'Order not found after settle');
|
||||||
|
}
|
||||||
|
return $this->mobileSuccess($this->buildDepositResponse($settled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将订单模型转换为统一的创建/详情响应数据
|
||||||
|
*/
|
||||||
|
private function buildDepositResponse($order): array
|
||||||
|
{
|
||||||
|
$status = $this->mapDepositStatus($order->status);
|
||||||
|
$paid = $status === 'paid';
|
||||||
|
$amount = $this->amountString($order->amount);
|
||||||
|
$bonus = $this->amountString($order->bonus_amount);
|
||||||
|
$total = bcadd($amount, $bonus, 4);
|
||||||
|
return [
|
||||||
|
'order_no' => is_string($order->order_no) ? $order->order_no : strval($order->order_no),
|
||||||
|
'amount' => $amount,
|
||||||
|
'bonus_amount' => $bonus,
|
||||||
|
'total_amount' => $total,
|
||||||
|
'status' => $status,
|
||||||
|
'paid' => $paid,
|
||||||
|
'pay_channel' => is_string($order->pay_channel) ? $order->pay_channel : strval($order->pay_channel),
|
||||||
|
'pay_url' => '',
|
||||||
|
'create_time' => is_numeric(strval($order->create_time)) ? intval(strval($order->create_time)) : 0,
|
||||||
|
'pay_time' => is_numeric(strval($order->pay_time)) ? intval(strval($order->pay_time)) : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将任意金额输入归一化为 4 位小数字符串(不做类型强制转换)
|
||||||
|
*/
|
||||||
|
private function amountString($raw): string
|
||||||
|
{
|
||||||
|
if (is_string($raw)) {
|
||||||
|
$s = trim($raw);
|
||||||
|
} elseif (is_int($raw) || is_float($raw)) {
|
||||||
|
$s = strval($raw);
|
||||||
|
} else {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
if ($s === '' || !is_numeric($s)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
return bcadd($s, '0', 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看充值订单详情(原 depositDetail)。根据 order_no 返回完整订单快照。
|
||||||
|
*/
|
||||||
public function depositDetail(Request $request): Response
|
public function depositDetail(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeMobile($request);
|
$response = $this->initializeMobile($request);
|
||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$orderNo = trim((string) $request->get('order_no', ''));
|
$orderNo = $this->stringParam($request->input('order_no'));
|
||||||
if ($orderNo === '') {
|
if ($orderNo === '') {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
@@ -62,12 +235,47 @@ class Finance extends MobileBase
|
|||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->mobileError(2003, 'Order does not exist');
|
return $this->mobileError(2003, 'Order does not exist');
|
||||||
}
|
}
|
||||||
|
return $this->mobileSuccess($this->buildDepositResponse($order));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户的充值订单列表(分页)。列表项返回 order_no / amount / bonus_amount / status,
|
||||||
|
* 其他字段请调用 /api/finance/depositDetail。
|
||||||
|
*/
|
||||||
|
public function depositList(Request $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeMobile($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
$page = $this->intValue($request->input('page', 1));
|
||||||
|
if ($page <= 0) {
|
||||||
|
$page = 1;
|
||||||
|
}
|
||||||
|
$pageSize = $this->intValue($request->input('page_size', 20));
|
||||||
|
if ($pageSize <= 0 || $pageSize > 100) {
|
||||||
|
$pageSize = 20;
|
||||||
|
}
|
||||||
|
$paginate = DepositOrder::where('user_id', $this->auth->id)
|
||||||
|
->order('id', 'desc')
|
||||||
|
->paginate(['page' => $page, 'list_rows' => $pageSize]);
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
foreach ($paginate->items() as $row) {
|
||||||
|
$list[] = [
|
||||||
|
'order_no' => $row->order_no,
|
||||||
|
'amount' => $this->amountString($row->amount ?? '0'),
|
||||||
|
'bonus_amount' => $this->amountString($row->bonus_amount ?? '0'),
|
||||||
|
'status' => $this->mapDepositStatus($row->status ?? null),
|
||||||
|
];
|
||||||
|
}
|
||||||
return $this->mobileSuccess([
|
return $this->mobileSuccess([
|
||||||
'order_no' => $order->order_no,
|
'list' => $list,
|
||||||
'status' => $this->mapDepositStatus($order->status),
|
'pagination' => [
|
||||||
'coin_amount' => $order->coin_amount,
|
'page' => $paginate->currentPage(),
|
||||||
'create_time' => $order->create_time,
|
'page_size' => $paginate->listRows(),
|
||||||
'finish_time' => $order->paid_at,
|
'total' => $paginate->total(),
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,51 +285,142 @@ class Finance extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$withdrawCoin = (string) $request->post('withdraw_coin', '');
|
$withdrawCoinRaw = $request->post('withdraw_coin', '');
|
||||||
$receiveAccount = trim((string) $request->post('receive_account', ''));
|
$withdrawCoin = is_string($withdrawCoinRaw) ? trim($withdrawCoinRaw) : (is_numeric($withdrawCoinRaw) ? strval($withdrawCoinRaw) : '');
|
||||||
$receiveType = trim((string) $request->post('receive_type', ''));
|
$receiveAccount = trim(is_string($request->post('receive_account', '')) ? $request->post('receive_account', '') : '');
|
||||||
$idempotencyKey = trim((string) $request->post('idempotency_key', ''));
|
$receiveType = trim(is_string($request->post('receive_type', '')) ? $request->post('receive_type', '') : '');
|
||||||
|
$idempotencyKey = trim(is_string($request->post('idempotency_key', '')) ? $request->post('idempotency_key', '') : '');
|
||||||
if ($withdrawCoin === '' || $receiveAccount === '' || $receiveType === '' || $idempotencyKey === '') {
|
if ($withdrawCoin === '' || $receiveAccount === '' || $receiveType === '' || $idempotencyKey === '') {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
|
if (!is_numeric($withdrawCoin) || bccomp($withdrawCoin, '0', 4) <= 0) {
|
||||||
|
return $this->mobileError(1001, 'Invalid withdraw amount');
|
||||||
|
}
|
||||||
|
$withdrawCoin = bcadd($withdrawCoin, '0', 4);
|
||||||
|
|
||||||
$user = $this->auth->getUser();
|
$user = $this->auth->getUser();
|
||||||
if (bccomp((string) $user->coin, $withdrawCoin, 4) < 0) {
|
$userId = intval(strval($user->id));
|
||||||
|
|
||||||
|
// 待审核订单数限制:同一用户最多 MAX_PENDING_WITHDRAW 笔 status=0(待审核)
|
||||||
|
$pendingCount = Db::name('withdraw_order')
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->where('status', 0)
|
||||||
|
->count();
|
||||||
|
if ($pendingCount >= WithdrawFlow::MAX_PENDING_WITHDRAW) {
|
||||||
|
return $this->mobileError(2004, 'Too many pending withdraw orders', [
|
||||||
|
'max_pending' => WithdrawFlow::MAX_PENDING_WITHDRAW,
|
||||||
|
'pending_count' => $pendingCount,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$balanceBefore = bcadd(strval($user->coin ?? '0'), '0', 4);
|
||||||
|
if (bccomp($balanceBefore, $withdrawCoin, 4) < 0) {
|
||||||
return $this->mobileError(2001, 'Insufficient balance');
|
return $this->mobileError(2001, 'Insufficient balance');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 单笔上限校验:提现金额 <= min(coin, max_withdraw_by_flow)
|
||||||
|
// - max_withdraw_by_flow = max(0, bet_flow_coin / ratio - total_withdraw_coin)
|
||||||
|
// - ratio = 0 视为"不限打码",上限仅取余额
|
||||||
|
// 超过上限直接回传 max_withdrawable,前端可据此提示"最大可提现金额为 XXX"。
|
||||||
|
$flowStatus = WithdrawFlow::status($userId, [
|
||||||
|
'total_deposit_coin' => $user->total_deposit_coin ?? '0',
|
||||||
|
'total_withdraw_coin' => $user->total_withdraw_coin ?? '0',
|
||||||
|
'bet_flow_coin' => $user->bet_flow_coin ?? '0',
|
||||||
|
]);
|
||||||
|
$maxWithdrawable = WithdrawFlow::maxWithdrawable($balanceBefore, $flowStatus);
|
||||||
|
if (bccomp($withdrawCoin, $maxWithdrawable, 4) > 0) {
|
||||||
|
return $this->mobileError(2002, 'Withdraw exceeds available bet flow', [
|
||||||
|
'max_withdrawable' => $maxWithdrawable,
|
||||||
|
'coin_balance' => $balanceBefore,
|
||||||
|
'bet_flow_coin' => $flowStatus['bet_flow_coin'],
|
||||||
|
'total_withdraw_coin' => WithdrawFlow::amountString($user->total_withdraw_coin ?? '0'),
|
||||||
|
'ratio' => $flowStatus['ratio'],
|
||||||
|
'max_withdraw_by_flow' => $flowStatus['flow_unlimited'] ? null : $flowStatus['max_withdraw_by_flow'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$channelIdRaw = $user->channel_id ?? null;
|
||||||
|
$channelId = ($channelIdRaw !== null && $channelIdRaw !== '' && is_numeric(strval($channelIdRaw)))
|
||||||
|
? intval(strval($channelIdRaw))
|
||||||
|
: null;
|
||||||
|
|
||||||
$orderNo = 'WD' . date('YmdHis') . substr(str_replace('.', '', uniqid('', true)), -6);
|
$orderNo = 'WD' . date('YmdHis') . substr(str_replace('.', '', uniqid('', true)), -6);
|
||||||
$feeCoin = bcmul($withdrawCoin, '0.005', 4);
|
$feeCoin = bcmul($withdrawCoin, '0.005', 4);
|
||||||
$actualArrivalCoin = bcsub($withdrawCoin, $feeCoin, 4);
|
$actualArrivalCoin = bcsub($withdrawCoin, $feeCoin, 4);
|
||||||
WithdrawOrder::create([
|
$balanceAfter = bcsub($balanceBefore, $withdrawCoin, 4);
|
||||||
'order_no' => $orderNo,
|
$now = time();
|
||||||
'user_id' => $user->id,
|
|
||||||
'apply_amount' => $withdrawCoin,
|
Db::startTrans();
|
||||||
'fee_amount' => $feeCoin,
|
try {
|
||||||
'actual_amount' => $actualArrivalCoin,
|
// 钱包即时扣减(冻结语义):审核通过即定稿;审核驳回在管理端回冲。
|
||||||
'fiat_currency' => '',
|
$affected = Db::name('user')
|
||||||
'need_audit' => 1,
|
->where('id', $userId)
|
||||||
'audit_status' => 0,
|
->where('coin', '>=', $withdrawCoin)
|
||||||
'reject_reason' => '',
|
->update([
|
||||||
'create_time' => time(),
|
'coin' => Db::raw('coin - ' . $withdrawCoin),
|
||||||
'update_time' => time(),
|
'total_withdraw_coin' => Db::raw('total_withdraw_coin + ' . $withdrawCoin),
|
||||||
]);
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
if ($affected <= 0) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->mobileError(2001, 'Insufficient balance');
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderId = Db::name('withdraw_order')->insertGetId([
|
||||||
|
'order_no' => $orderNo,
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'amount' => $withdrawCoin,
|
||||||
|
'fee' => $feeCoin,
|
||||||
|
'actual_amount' => $actualArrivalCoin,
|
||||||
|
'status' => 0,
|
||||||
|
'review_admin_id' => null,
|
||||||
|
'review_time' => null,
|
||||||
|
'remark' => '',
|
||||||
|
'create_time' => $now,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => 'withdraw',
|
||||||
|
'direction' => 2,
|
||||||
|
'amount' => $withdrawCoin,
|
||||||
|
'balance_before' => $balanceBefore,
|
||||||
|
'balance_after' => $balanceAfter,
|
||||||
|
'ref_type' => 'withdraw_order',
|
||||||
|
'ref_id' => $orderId,
|
||||||
|
'idempotency_key' => 'wd_apply_' . $orderNo,
|
||||||
|
'operator_admin_id' => null,
|
||||||
|
'remark' => '用户申请提现(待审核冻结):' . $orderNo,
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->mobileError(2000, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return $this->mobileSuccess([
|
return $this->mobileSuccess([
|
||||||
'order_no' => $orderNo,
|
'order_no' => $orderNo,
|
||||||
'status' => 'pending_review',
|
'status' => 'pending_review',
|
||||||
'fee_coin' => $feeCoin,
|
'fee_coin' => $feeCoin,
|
||||||
'actual_arrival_coin' => $actualArrivalCoin,
|
'actual_arrival_coin' => $actualArrivalCoin,
|
||||||
'risk_review_required' => true,
|
'risk_review_required' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看提现订单详情(原 withdrawDetail)。根据 order_no 返回完整订单快照。
|
||||||
|
*/
|
||||||
public function withdrawDetail(Request $request): Response
|
public function withdrawDetail(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeMobile($request);
|
$response = $this->initializeMobile($request);
|
||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$orderNo = trim((string) $request->get('order_no', ''));
|
$orderNo = $this->stringParam($request->input('order_no'));
|
||||||
if ($orderNo === '') {
|
if ($orderNo === '') {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
@@ -129,16 +428,79 @@ class Finance extends MobileBase
|
|||||||
if (!$order) {
|
if (!$order) {
|
||||||
return $this->mobileError(2003, 'Order does not exist');
|
return $this->mobileError(2003, 'Order does not exist');
|
||||||
}
|
}
|
||||||
|
$remarkRaw = $order->remark ?? '';
|
||||||
|
$remark = is_string($remarkRaw) ? $remarkRaw : strval($remarkRaw);
|
||||||
|
$statusCode = $this->intValue($order->status);
|
||||||
return $this->mobileSuccess([
|
return $this->mobileSuccess([
|
||||||
'order_no' => $order->order_no,
|
'order_no' => $order->order_no,
|
||||||
'status' => $this->mapWithdrawStatus($order->audit_status),
|
'status' => $this->mapWithdrawStatus($statusCode),
|
||||||
'withdraw_coin' => $order->apply_amount,
|
'withdraw_coin' => $order->amount,
|
||||||
'fee_coin' => $order->fee_amount,
|
'fee_coin' => $order->fee,
|
||||||
'reject_reason' => $order->reject_reason === '' ? null : $order->reject_reason,
|
'actual_arrival_coin' => $order->actual_amount,
|
||||||
'create_time' => $order->create_time,
|
'reject_reason' => $statusCode === 2 && $remark !== '' ? $remark : null,
|
||||||
|
'create_time' => $order->create_time,
|
||||||
|
'review_time' => $order->review_time,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户的提现订单列表(分页)。列表项返回 order_no / amount / status,
|
||||||
|
* 手续费、实到账、拒绝原因等请调用 /api/finance/withdrawDetail。
|
||||||
|
*/
|
||||||
|
public function withdrawList(Request $request): Response
|
||||||
|
{
|
||||||
|
$response = $this->initializeMobile($request);
|
||||||
|
if ($response !== null) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
$page = $this->intValue($request->input('page', 1));
|
||||||
|
if ($page <= 0) {
|
||||||
|
$page = 1;
|
||||||
|
}
|
||||||
|
$pageSize = $this->intValue($request->input('page_size', 20));
|
||||||
|
if ($pageSize <= 0 || $pageSize > 100) {
|
||||||
|
$pageSize = 20;
|
||||||
|
}
|
||||||
|
$paginate = WithdrawOrder::where('user_id', $this->auth->id)
|
||||||
|
->order('id', 'desc')
|
||||||
|
->paginate(['page' => $page, 'list_rows' => $pageSize]);
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
foreach ($paginate->items() as $row) {
|
||||||
|
$list[] = [
|
||||||
|
'order_no' => $row->order_no,
|
||||||
|
'amount' => $this->amountString($row->amount ?? '0'),
|
||||||
|
'status' => $this->mapWithdrawStatus($row->status ?? null),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $this->mobileSuccess([
|
||||||
|
'list' => $list,
|
||||||
|
'pagination' => [
|
||||||
|
'page' => $paginate->currentPage(),
|
||||||
|
'page_size' => $paginate->listRows(),
|
||||||
|
'total' => $paginate->total(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function stringParam($raw): string
|
||||||
|
{
|
||||||
|
if ($raw === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (!is_string($raw)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return trim($raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadEnabledTiers(): array
|
||||||
|
{
|
||||||
|
$row = GameConfig::where('config_key', DepositTierLib::CONFIG_KEY)->find();
|
||||||
|
$all = DepositTierLib::parseFromConfigValue($row?->config_value ?? null);
|
||||||
|
return DepositTierLib::publicList($all);
|
||||||
|
}
|
||||||
|
|
||||||
private function mapDepositStatus($status): string
|
private function mapDepositStatus($status): string
|
||||||
{
|
{
|
||||||
if ($this->intValue($status) === 1) {
|
if ($this->intValue($status) === 1) {
|
||||||
@@ -150,12 +512,16 @@ class Finance extends MobileBase
|
|||||||
return 'pending';
|
return 'pending';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mapWithdrawStatus($auditStatus): string
|
/**
|
||||||
|
* 映射 withdraw_order.status(0 待审 / 1 通过 / 2 拒绝 / 3 已打款)到移动端状态字符串
|
||||||
|
*/
|
||||||
|
private function mapWithdrawStatus($statusCode): string
|
||||||
{
|
{
|
||||||
if ($this->intValue($auditStatus) === 1) {
|
$code = $this->intValue($statusCode);
|
||||||
|
if ($code === 1 || $code === 3) {
|
||||||
return 'approved';
|
return 'approved';
|
||||||
}
|
}
|
||||||
if ($this->intValue($auditStatus) === 2) {
|
if ($code === 2) {
|
||||||
return 'rejected';
|
return 'rejected';
|
||||||
}
|
}
|
||||||
return 'pending_review';
|
return 'pending_review';
|
||||||
@@ -170,4 +536,3 @@ class Finance extends MobileBase
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class Game extends MobileBase
|
|||||||
'open_at' => $openAt,
|
'open_at' => $openAt,
|
||||||
],
|
],
|
||||||
'bet_config' => [
|
'bet_config' => [
|
||||||
'max_select_count' => $this->intValue($this->getConfigValue('max_select_count', '5')),
|
'pick_max_number_count' => $this->getPickMaxNumberCount(),
|
||||||
'chips' => ['1.0000', '5.0000', '10.0000', '25.0000', '50.0000', '100.0000'],
|
'chips' => ['1.0000', '5.0000', '10.0000', '25.0000', '50.0000', '100.0000'],
|
||||||
'single_number_max_bet' => $this->getConfigValue('single_number_max_bet', '500.0000'),
|
'single_number_max_bet' => $this->getConfigValue('single_number_max_bet', '500.0000'),
|
||||||
],
|
],
|
||||||
@@ -95,7 +95,7 @@ class Game extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$limit = $this->intValue($request->get('limit', 30));
|
$limit = $this->intValue($request->input('limit', 30));
|
||||||
if ($limit < 1) {
|
if ($limit < 1) {
|
||||||
$limit = 30;
|
$limit = 30;
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,12 @@ class Game extends MobileBase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交下注:入参极简——period_no + numbers + bet_amount(整笔总金额) + idempotency_key。
|
||||||
|
*
|
||||||
|
* 下注判定:开奖号码 ∈ pick_numbers 即算中奖,赔付按整笔 total_amount × odds 计算
|
||||||
|
* (odds 定义见 GameBetSettleService::BASE_ODDS 与 streak_at_bet)。
|
||||||
|
*/
|
||||||
public function betPlace(Request $request): Response
|
public function betPlace(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeMobile($request);
|
$response = $this->initializeMobile($request);
|
||||||
@@ -140,13 +146,23 @@ class Game extends MobileBase
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$periodNo = trim((string) $request->post('period_no', ''));
|
$periodNo = trim((string) $request->post('period_no', ''));
|
||||||
$numbers = $request->post('numbers', []);
|
$numbersRaw = $request->post('numbers', '');
|
||||||
$betAmount = (string) $request->post('bet_amount', '');
|
$betAmount = trim((string) $request->post('bet_amount', ''));
|
||||||
$idempotencyKey = trim((string) $request->post('idempotency_key', ''));
|
$idempotencyKey = trim((string) $request->post('idempotency_key', ''));
|
||||||
if ($periodNo === '' || !is_array($numbers) || $betAmount === '' || $idempotencyKey === '') {
|
if ($periodNo === '' || $betAmount === '' || $idempotencyKey === '') {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
if (count($numbers) < 1) {
|
if (!is_numeric($betAmount) || bccomp($betAmount, '0', 4) <= 0) {
|
||||||
|
return $this->mobileError(1003, 'Invalid parameter value');
|
||||||
|
}
|
||||||
|
$totalAmount = bcadd($betAmount, '0', 4);
|
||||||
|
|
||||||
|
$numbers = $this->parseBetNumbersFromRequest($numbersRaw);
|
||||||
|
if ($numbers === []) {
|
||||||
|
return $this->mobileError(1003, 'Invalid parameter value');
|
||||||
|
}
|
||||||
|
$maxSelect = $this->getPickMaxNumberCount();
|
||||||
|
if (count($numbers) > $maxSelect) {
|
||||||
return $this->mobileError(1003, 'Invalid parameter value');
|
return $this->mobileError(1003, 'Invalid parameter value');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,8 +175,6 @@ class Game extends MobileBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->auth->getUser();
|
$user = $this->auth->getUser();
|
||||||
$pickCount = count($numbers);
|
|
||||||
$totalAmount = bcmul($betAmount, (string) $pickCount, 4);
|
|
||||||
if (bccomp((string) $user->coin, $totalAmount, 4) < 0) {
|
if (bccomp((string) $user->coin, $totalAmount, 4) < 0) {
|
||||||
return $this->mobileError(2001, 'Insufficient balance');
|
return $this->mobileError(2001, 'Insufficient balance');
|
||||||
}
|
}
|
||||||
@@ -194,8 +208,6 @@ class Game extends MobileBase
|
|||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'channel_id' => $user->channel_id,
|
'channel_id' => $user->channel_id,
|
||||||
'pick_numbers' => $numbers,
|
'pick_numbers' => $numbers,
|
||||||
'unit_amount' => $betAmount,
|
|
||||||
'pick_count' => $pickCount,
|
|
||||||
'total_amount' => $totalAmount,
|
'total_amount' => $totalAmount,
|
||||||
'streak_at_bet' => $user->current_streak ?? 0,
|
'streak_at_bet' => $user->current_streak ?? 0,
|
||||||
'is_auto' => 0,
|
'is_auto' => 0,
|
||||||
@@ -220,41 +232,14 @@ class Game extends MobileBase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function betRebet(Request $request): Response
|
|
||||||
{
|
|
||||||
$response = $this->initializeMobile($request);
|
|
||||||
if ($response !== null) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
return $this->mobileError(3001, 'Current process does not allow this operation');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function autoBetCreate(Request $request): Response
|
|
||||||
{
|
|
||||||
$response = $this->initializeMobile($request);
|
|
||||||
if ($response !== null) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
return $this->mobileError(3001, 'Current process does not allow this operation');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function autoBetStop(Request $request): Response
|
|
||||||
{
|
|
||||||
$response = $this->initializeMobile($request);
|
|
||||||
if ($response !== null) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
return $this->mobileError(3001, 'Current process does not allow this operation');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function betMyOrders(Request $request): Response
|
public function betMyOrders(Request $request): Response
|
||||||
{
|
{
|
||||||
$response = $this->initializeMobile($request);
|
$response = $this->initializeMobile($request);
|
||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$page = $this->intValue($request->get('page', 1));
|
$page = $this->intValue($request->input('page', 1));
|
||||||
$pageSize = $this->intValue($request->get('page_size', 20));
|
$pageSize = $this->intValue($request->input('page_size', 20));
|
||||||
$paginate = BetOrder::where('user_id', $this->auth->id)->order('id', 'desc')->paginate([
|
$paginate = BetOrder::where('user_id', $this->auth->id)->order('id', 'desc')->paginate([
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'list_rows' => $pageSize,
|
'list_rows' => $pageSize,
|
||||||
@@ -266,7 +251,8 @@ class Game extends MobileBase
|
|||||||
'order_no' => (string) $item->id,
|
'order_no' => (string) $item->id,
|
||||||
'period_no' => $item->period_no,
|
'period_no' => $item->period_no,
|
||||||
'numbers' => $item->pick_numbers ?? [],
|
'numbers' => $item->pick_numbers ?? [],
|
||||||
'bet_amount' => $item->unit_amount,
|
// 整笔压注金额(与请求 bet_amount 语义一致)
|
||||||
|
'bet_amount' => $item->total_amount,
|
||||||
'total_amount' => $item->total_amount,
|
'total_amount' => $item->total_amount,
|
||||||
'result_number' => null,
|
'result_number' => null,
|
||||||
'win_amount' => $item->win_amount,
|
'win_amount' => $item->win_amount,
|
||||||
@@ -285,6 +271,49 @@ class Game extends MobileBase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下注号码:`numbers` 为逗号分隔字符串(如 `1,8,16`);兼容旧版 JSON 数组。
|
||||||
|
*
|
||||||
|
* @return list<int>
|
||||||
|
*/
|
||||||
|
private function parseBetNumbersFromRequest($numbersRaw): array
|
||||||
|
{
|
||||||
|
if (is_array($numbersRaw)) {
|
||||||
|
$out = [];
|
||||||
|
foreach ($numbersRaw as $v) {
|
||||||
|
$n = filter_var($v, FILTER_VALIDATE_INT);
|
||||||
|
if ($n === false || $n < 1 || $n > 36) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$out[] = $n;
|
||||||
|
}
|
||||||
|
$out = array_values(array_unique($out));
|
||||||
|
sort($out);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
$raw = trim((string) $numbersRaw);
|
||||||
|
if ($raw === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$parts = preg_split('/\s*,\s*/', $raw);
|
||||||
|
$out = [];
|
||||||
|
foreach ($parts as $p) {
|
||||||
|
if ($p === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$n = filter_var($p, FILTER_VALIDATE_INT);
|
||||||
|
if ($n === false || $n < 1 || $n > 36) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$out[] = $n;
|
||||||
|
}
|
||||||
|
$out = array_values(array_unique($out));
|
||||||
|
sort($out);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
private function mapPeriodStatus($status): string
|
private function mapPeriodStatus($status): string
|
||||||
{
|
{
|
||||||
if ($this->intValue($status) === 0) {
|
if ($this->intValue($status) === 0) {
|
||||||
@@ -299,6 +328,22 @@ class Game extends MobileBase
|
|||||||
return 'finished';
|
return 'finished';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单注最多可选号码个数:`game_config.config_key = pick_max_number_count`
|
||||||
|
*/
|
||||||
|
private function getPickMaxNumberCount(): int
|
||||||
|
{
|
||||||
|
$v = $this->intValue($this->getConfigValue('pick_max_number_count', '10'));
|
||||||
|
if ($v < 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ($v > 36) {
|
||||||
|
return 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
|
||||||
private function getConfigValue(string $key, string $default): string
|
private function getConfigValue(string $key, string $default): string
|
||||||
{
|
{
|
||||||
$value = GameConfig::where('config_key', $key)->value('config_value');
|
$value = GameConfig::where('config_key', $key)->value('config_value');
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ class Notice extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$page = $this->intValue($request->get('page', 1), 1);
|
$page = $this->intValue($request->input('page', 1), 1);
|
||||||
$pageSize = $this->intValue($request->get('page_size', 20), 20);
|
$pageSize = $this->intValue($request->input('page_size', 20), 20);
|
||||||
|
|
||||||
$paginate = OperationNotice::where('status', 1)->order('id', 'desc')->paginate([
|
$paginate = OperationNotice::where('status', 1)->order('id', 'desc')->paginate([
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@@ -55,7 +55,7 @@ class Notice extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$id = $this->intValue($request->get('id', 0), 0);
|
$id = $this->intValue($request->input('notice_id', 0), 0);
|
||||||
if ($id < 1) {
|
if ($id < 1) {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ class Notice extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$noticeId = $this->intValue($request->post('notice_id', 0), 0);
|
$noticeId = $this->intValue($request->input('notice_id', 0), 0);
|
||||||
if ($noticeId < 1) {
|
if ($noticeId < 1) {
|
||||||
return $this->mobileError(1001, 'Missing parameters');
|
return $this->mobileError(1001, 'Missing parameters');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,15 @@ class User extends Frontend
|
|||||||
->where('invite_code', $params['invite_code'])
|
->where('invite_code', $params['invite_code'])
|
||||||
->find();
|
->find();
|
||||||
if (!$inviterAdmin) {
|
if (!$inviterAdmin) {
|
||||||
return $this->error(__('Parameter error'));
|
return $this->error(__('Invite code does not exist'));
|
||||||
|
}
|
||||||
|
$ch = $inviterAdmin['channel_id'] ?? null;
|
||||||
|
if ($ch === null || $ch === '' || intval(trim((string) $ch)) <= 0) {
|
||||||
|
return $this->error(__('Invite code not bound to channel'));
|
||||||
}
|
}
|
||||||
$extend['register_invite_code'] = $params['invite_code'];
|
$extend['register_invite_code'] = $params['invite_code'];
|
||||||
$extend['inviter_admin_id'] = $inviterAdmin['id'];
|
$extend['admin_id'] = $inviterAdmin['id'];
|
||||||
$extend['channel_id'] = $inviterAdmin['channel_id'] ?? null;
|
$extend['channel_id'] = intval(trim((string) $ch));
|
||||||
}
|
}
|
||||||
$res = $this->auth->register($params['username'], $params['password'], $params['mobile'], $params['email'], 1, $extend);
|
$res = $this->auth->register($params['username'], $params['password'], $params['mobile'], $params['email'], 1, $extend);
|
||||||
}
|
}
|
||||||
@@ -96,6 +100,10 @@ class User extends Frontend
|
|||||||
'routePath' => '/user'
|
'routePath' => '/user'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
$dup = $this->auth->getRegisterDuplicateKind();
|
||||||
|
if ($params['tab'] === 'register' && ($dup === 'username' || $dup === 'email' || $dup === 'phone')) {
|
||||||
|
return $this->error(__('Account already registered'));
|
||||||
|
}
|
||||||
$msg = $this->auth->getError();
|
$msg = $this->auth->getError();
|
||||||
return $this->error($msg ?: __('Check in failed, please try again or contact the website administrator~'));
|
return $this->error($msg ?: __('Check in failed, please try again or contact the website administrator~'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\library\finance\WithdrawFlow;
|
||||||
use app\common\model\UserWalletRecord;
|
use app\common\model\UserWalletRecord;
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
@@ -17,12 +18,30 @@ class Wallet extends MobileBase
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$user = $this->auth->getUser();
|
$user = $this->auth->getUser();
|
||||||
|
$coinBalance = WithdrawFlow::amountString($user->coin ?? '0');
|
||||||
|
$flow = WithdrawFlow::status(intval($user->id), [
|
||||||
|
'total_deposit_coin' => $user->total_deposit_coin ?? '0',
|
||||||
|
'total_withdraw_coin' => $user->total_withdraw_coin ?? '0',
|
||||||
|
'bet_flow_coin' => $user->bet_flow_coin ?? '0',
|
||||||
|
]);
|
||||||
|
$maxWithdrawable = WithdrawFlow::maxWithdrawable($coinBalance, $flow);
|
||||||
return $this->mobileSuccess([
|
return $this->mobileSuccess([
|
||||||
'coin_balance' => $user->coin,
|
'coin_balance' => $coinBalance,
|
||||||
'frozen_balance' => '0.0000',
|
'frozen_balance' => '0.0000',
|
||||||
'total_deposit_coin' => $user->total_deposit_coin ?? '0.0000',
|
'withdrawable_balance' => $coinBalance,
|
||||||
'total_valid_bet_coin' => $user->total_valid_bet_coin ?? '0.0000',
|
'max_withdrawable' => $maxWithdrawable,
|
||||||
'withdrawable_balance' => $user->coin,
|
'total_deposit_coin' => WithdrawFlow::amountString($user->total_deposit_coin ?? '0'),
|
||||||
|
'total_withdraw_coin' => WithdrawFlow::amountString($user->total_withdraw_coin ?? '0'),
|
||||||
|
'bet_flow_coin' => $flow['bet_flow_coin'],
|
||||||
|
'withdraw_flow' => [
|
||||||
|
'ratio' => $flow['ratio'],
|
||||||
|
'net_deposit' => $flow['net_deposit'],
|
||||||
|
'required_bet_flow' => $flow['required_bet_flow'],
|
||||||
|
'remaining_bet_flow' => $flow['remaining_bet_flow'],
|
||||||
|
'eligible' => $flow['eligible'],
|
||||||
|
'max_withdraw_by_flow' => $flow['flow_unlimited'] ? null : $flow['max_withdraw_by_flow'],
|
||||||
|
'flow_unlimited' => $flow['flow_unlimited'],
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +51,9 @@ class Wallet extends MobileBase
|
|||||||
if ($response !== null) {
|
if ($response !== null) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$type = trim((string) $request->get('type', 'all'));
|
$type = trim((string) $request->input('type', 'all'));
|
||||||
$page = $this->intValue($request->get('page', 1), 1);
|
$page = $this->intValue($request->input('page', 1), 1);
|
||||||
$pageSize = $this->intValue($request->get('page_size', 20), 20);
|
$pageSize = $this->intValue($request->input('page_size', 20), 20);
|
||||||
|
|
||||||
$query = UserWalletRecord::where('user_id', $this->auth->id)->order('id', 'desc');
|
$query = UserWalletRecord::where('user_id', $this->auth->id)->order('id', 'desc');
|
||||||
if ($type !== '' && $type !== 'all') {
|
if ($type !== '' && $type !== 'all') {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ return [
|
|||||||
'Please login first' => 'Please login first!',
|
'Please login first' => 'Please login first!',
|
||||||
'You have no permission' => 'No permission to operate!',
|
'You have no permission' => 'No permission to operate!',
|
||||||
'Captcha error' => 'Captcha error!',
|
'Captcha error' => 'Captcha error!',
|
||||||
'ok' => 'ok',
|
'ok' => 'success',
|
||||||
'Missing parameters' => 'Missing parameters',
|
'Missing parameters' => 'Missing parameters',
|
||||||
'Invalid parameter format' => 'Invalid parameter format',
|
'Invalid parameter format' => 'Invalid parameter format',
|
||||||
'Invalid parameter value' => 'Invalid parameter value',
|
'Invalid parameter value' => 'Invalid parameter value',
|
||||||
@@ -23,6 +23,9 @@ return [
|
|||||||
'Invalid timestamp' => 'Invalid timestamp',
|
'Invalid timestamp' => 'Invalid timestamp',
|
||||||
'Invite code does not exist' => 'Invite code does not exist',
|
'Invite code does not exist' => 'Invite code does not exist',
|
||||||
'Register only supports phone' => 'Register only supports phone',
|
'Register only supports phone' => 'Register only supports phone',
|
||||||
|
'Invite code required' => 'Invite code is required',
|
||||||
|
'Invite code not bound to channel' => 'This invite code is not bound to a valid channel',
|
||||||
|
'Account already registered' => 'This phone number is already registered. Please sign in.',
|
||||||
'Please enter the correct mobile number' => 'Please enter the correct mobile number',
|
'Please enter the correct mobile number' => 'Please enter the correct mobile number',
|
||||||
'Registered successfully but login failed' => 'Registered successfully but login failed',
|
'Registered successfully but login failed' => 'Registered successfully but login failed',
|
||||||
'Incorrect account or password' => 'Incorrect account or password',
|
'Incorrect account or password' => 'Incorrect account or password',
|
||||||
@@ -35,6 +38,14 @@ return [
|
|||||||
'Current process does not allow this operation' => 'Current process does not allow this operation',
|
'Current process does not allow this operation' => 'Current process does not allow this operation',
|
||||||
'Order does not exist' => 'Order does not exist',
|
'Order does not exist' => 'Order does not exist',
|
||||||
'Notice does not exist' => 'Notice does not exist',
|
'Notice does not exist' => 'Notice does not exist',
|
||||||
|
// Deposit / Withdraw
|
||||||
|
'Idempotency key is too long' => 'Idempotency key is too long',
|
||||||
|
'Idempotency key conflict' => 'Idempotency key conflict, please do not submit repeatedly',
|
||||||
|
'Deposit tier not available' => 'The selected deposit tier is not available',
|
||||||
|
'Order not found after settle' => 'Order not found after settlement',
|
||||||
|
'Invalid withdraw amount' => 'Invalid withdraw amount',
|
||||||
|
'Withdraw exceeds available bet flow' => 'The withdraw amount exceeds the available bet-flow quota',
|
||||||
|
'Too many pending withdraw orders' => 'You already have withdraw orders under review, please wait for them to be processed',
|
||||||
// Member center account
|
// Member center account
|
||||||
'Data updated successfully~' => 'Data updated successfully~',
|
'Data updated successfully~' => 'Data updated successfully~',
|
||||||
'Password has been changed~' => 'Password has been changed~',
|
'Password has been changed~' => 'Password has been changed~',
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ return [
|
|||||||
'Invalid timestamp' => '时间戳无效',
|
'Invalid timestamp' => '时间戳无效',
|
||||||
'Invite code does not exist' => '邀请码不存在',
|
'Invite code does not exist' => '邀请码不存在',
|
||||||
'Register only supports phone' => '注册仅支持手机号',
|
'Register only supports phone' => '注册仅支持手机号',
|
||||||
|
'Invite code required' => '请填写邀请码',
|
||||||
|
'Invite code not bound to channel' => '该邀请码未绑定有效渠道',
|
||||||
|
'Account already registered' => '该手机号已注册,请直接登录',
|
||||||
'Please enter the correct mobile number' => '请输入正确的手机号',
|
'Please enter the correct mobile number' => '请输入正确的手机号',
|
||||||
'Registered successfully but login failed' => '注册成功但登录失败',
|
'Registered successfully but login failed' => '注册成功但登录失败',
|
||||||
'Incorrect account or password' => '账号或密码错误',
|
'Incorrect account or password' => '账号或密码错误',
|
||||||
@@ -67,6 +70,14 @@ return [
|
|||||||
'Current process does not allow this operation' => '当前流程不允许该操作',
|
'Current process does not allow this operation' => '当前流程不允许该操作',
|
||||||
'Order does not exist' => '订单不存在',
|
'Order does not exist' => '订单不存在',
|
||||||
'Notice does not exist' => '公告不存在',
|
'Notice does not exist' => '公告不存在',
|
||||||
|
// 充值 / 提现
|
||||||
|
'Idempotency key is too long' => '幂等键过长',
|
||||||
|
'Idempotency key conflict' => '幂等键冲突(请勿重复提交)',
|
||||||
|
'Deposit tier not available' => '所选充值档位不可用',
|
||||||
|
'Order not found after settle' => '充值成功后未找到订单',
|
||||||
|
'Invalid withdraw amount' => '提现金额不合法',
|
||||||
|
'Withdraw exceeds available bet flow' => '提现金额超出可提现额度',
|
||||||
|
'Too many pending withdraw orders' => '用户当前存在多笔提现订单,请等待审核',
|
||||||
// 会员中心 account
|
// 会员中心 account
|
||||||
'Data updated successfully~' => '资料更新成功~',
|
'Data updated successfully~' => '资料更新成功~',
|
||||||
'Password has been changed~' => '密码已修改~',
|
'Password has been changed~' => '密码已修改~',
|
||||||
|
|||||||
@@ -27,7 +27,14 @@ class Auth extends \ba\Auth
|
|||||||
protected int $keepTime = 86400;
|
protected int $keepTime = 86400;
|
||||||
protected int $refreshTokenKeepTime = 2592000;
|
protected int $refreshTokenKeepTime = 2592000;
|
||||||
|
|
||||||
protected array $allowFields = ['id', 'username', 'nickname', 'email', 'mobile', 'avatar', 'gender', 'birthday', 'money', 'score', 'join_time', 'motto', 'last_login_time', 'last_login_ip'];
|
/** 注册失败原因:`username`/`email` 表示账号已占用,供接口返回友好提示 */
|
||||||
|
protected string $registerDuplicateKind = '';
|
||||||
|
|
||||||
|
protected array $allowFields = [
|
||||||
|
'id', 'username', 'nickname', 'email', 'phone', 'avatar', 'gender', 'birthday',
|
||||||
|
'coin', 'channel_id', 'risk_flags', 'uuid',
|
||||||
|
'join_time', 'motto', 'last_login_time', 'last_login_ip',
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct(array $config = [])
|
public function __construct(array $config = [])
|
||||||
{
|
{
|
||||||
@@ -73,7 +80,7 @@ class Auth extends \ba\Auth
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->loginSuccessful();
|
$this->loginEd = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,6 +91,7 @@ class Auth extends \ba\Auth
|
|||||||
|
|
||||||
public function register(string $username, string $password = '', string $phone = '', string $email = '', int $group = 1, array $extend = []): bool
|
public function register(string $username, string $password = '', string $phone = '', string $email = '', int $group = 1, array $extend = []): bool
|
||||||
{
|
{
|
||||||
|
$this->registerDuplicateKind = '';
|
||||||
$request = function_exists('request') ? request() : null;
|
$request = function_exists('request') ? request() : null;
|
||||||
$ip = $request ? $request->getRealIp() : '0.0.0.0';
|
$ip = $request ? $request->getRealIp() : '0.0.0.0';
|
||||||
|
|
||||||
@@ -98,13 +106,20 @@ class Auth extends \ba\Auth
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (User::where('email', $email)->find() && $email) {
|
if (User::where('email', $email)->find() && $email) {
|
||||||
|
$this->registerDuplicateKind = 'email';
|
||||||
$this->setError(__('Email') . ' ' . __('already exists'));
|
$this->setError(__('Email') . ' ' . __('already exists'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (User::where('username', $username)->find()) {
|
if (User::where('username', $username)->find()) {
|
||||||
|
$this->registerDuplicateKind = 'username';
|
||||||
$this->setError(__('Username') . ' ' . __('already exists'));
|
$this->setError(__('Username') . ' ' . __('already exists'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($phone !== '' && User::where('phone', $phone)->find()) {
|
||||||
|
$this->registerDuplicateKind = 'phone';
|
||||||
|
$this->setError(__('Mobile') . ' ' . __('already exists'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$nickname = preg_replace_callback('/1[3-9]\d{9}/', fn($m) => substr($m[0], 0, 3) . '****' . substr($m[0], 7), $username);
|
$nickname = preg_replace_callback('/1[3-9]\d{9}/', fn($m) => substr($m[0], 0, 3) . '****' . substr($m[0], 7), $username);
|
||||||
$time = time();
|
$time = time();
|
||||||
@@ -116,6 +131,8 @@ class Auth extends \ba\Auth
|
|||||||
'last_login_ip' => $ip,
|
'last_login_ip' => $ip,
|
||||||
'last_login_time' => $time,
|
'last_login_time' => $time,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
|
'uuid' => User::generateUniquePublicCode10(),
|
||||||
|
'remark' => User::formatLoginRemark($time, $ip),
|
||||||
];
|
];
|
||||||
$data = array_merge(compact('username', 'password', 'phone', 'email'), $data, $extend);
|
$data = array_merge(compact('username', 'password', 'phone', 'email'), $data, $extend);
|
||||||
|
|
||||||
@@ -215,6 +232,7 @@ class Auth extends \ba\Auth
|
|||||||
$this->model->login_failure = 0;
|
$this->model->login_failure = 0;
|
||||||
$this->model->last_login_time = time();
|
$this->model->last_login_time = time();
|
||||||
$this->model->last_login_ip = $ip;
|
$this->model->last_login_ip = $ip;
|
||||||
|
$this->model->remark = User::formatLoginRemark(time(), $ip);
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
$this->loginEd = true;
|
$this->loginEd = true;
|
||||||
$this->model->commit();
|
$this->model->commit();
|
||||||
@@ -344,6 +362,11 @@ class Auth extends \ba\Auth
|
|||||||
return $this->error ? __($this->error) : '';
|
return $this->error ? __($this->error) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRegisterDuplicateKind(): string
|
||||||
|
{
|
||||||
|
return $this->registerDuplicateKind;
|
||||||
|
}
|
||||||
|
|
||||||
protected function reset(bool $deleteToken = true): bool
|
protected function reset(bool $deleteToken = true): bool
|
||||||
{
|
{
|
||||||
if ($deleteToken && $this->token) {
|
if ($deleteToken && $this->token) {
|
||||||
@@ -353,6 +376,7 @@ class Auth extends \ba\Auth
|
|||||||
$this->loginEd = false;
|
$this->loginEd = false;
|
||||||
$this->model = null;
|
$this->model = null;
|
||||||
$this->refreshToken = '';
|
$this->refreshToken = '';
|
||||||
|
$this->registerDuplicateKind = '';
|
||||||
$this->setError('');
|
$this->setError('');
|
||||||
$this->setKeepTime((int)config('buildadmin.user_token_keep_time', 86400));
|
$this->setKeepTime((int)config('buildadmin.user_token_keep_time', 86400));
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
218
app/common/library/finance/DepositSettlement.php
Normal file
218
app/common/library/finance/DepositSettlement.php
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\library\finance;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
use support\think\Db;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值订单结算公共库
|
||||||
|
*
|
||||||
|
* 所有"把 deposit_order 变为成功并给玩家钱包加币"的逻辑必须收敛到这里,
|
||||||
|
* 以便 mock 支付瞬时成功、未来第三方网关回调、历史数据的人工补单共用同一事务边界。
|
||||||
|
*
|
||||||
|
* 关键约束:
|
||||||
|
* - 只结算 status=0 的订单,幂等;重复调用同一订单返回现有结算结果;
|
||||||
|
* - 钱包流水 user_wallet_record 以 "deposit_settle_{order_no}" 为 idempotency_key,保证不重复入账;
|
||||||
|
* - 同时更新 user.coin 与 update_time,user_wallet_record 记录 balance_before/after 快照。
|
||||||
|
*/
|
||||||
|
final class DepositSettlement
|
||||||
|
{
|
||||||
|
public const SOURCE_MOCK_GATEWAY = 'mock_gateway';
|
||||||
|
|
||||||
|
public const SOURCE_ADMIN_APPROVE = 'admin_approve';
|
||||||
|
|
||||||
|
public const SOURCE_THIRD_PARTY = 'third_party';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算指定订单。
|
||||||
|
*
|
||||||
|
* @param int $orderId deposit_order.id
|
||||||
|
* @param string $source 来源(SOURCE_* 常量),写入 remark
|
||||||
|
* @param string $sourceLabel 人类可读描述,写入 remark,如 "mock gateway auto settled"
|
||||||
|
* @param int|null $operatorAdminId 操作管理员 ID(仅管理员审核时有值)
|
||||||
|
* @param string|null $extraRemark 追加到订单 remark(可选)
|
||||||
|
*
|
||||||
|
* @return array{
|
||||||
|
* order_id: int,
|
||||||
|
* order_no: string,
|
||||||
|
* amount: string,
|
||||||
|
* balance_before: string,
|
||||||
|
* balance_after: string,
|
||||||
|
* pay_time: int,
|
||||||
|
* already_settled: bool,
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @throws RuntimeException 订单不存在、金额非法、并发冲突等
|
||||||
|
*/
|
||||||
|
public static function settle(
|
||||||
|
int $orderId,
|
||||||
|
string $source,
|
||||||
|
string $sourceLabel,
|
||||||
|
?int $operatorAdminId = null,
|
||||||
|
?string $extraRemark = null
|
||||||
|
): array {
|
||||||
|
if ($orderId <= 0) {
|
||||||
|
throw new RuntimeException('订单 ID 非法');
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = Db::name('deposit_order')->where('id', $orderId)->find();
|
||||||
|
if (!$order) {
|
||||||
|
throw new RuntimeException('订单不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderNo = is_string($order['order_no']) ? $order['order_no'] : strval($order['order_no']);
|
||||||
|
if ($orderNo === '') {
|
||||||
|
throw new RuntimeException('订单号为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusRaw = $order['status'] ?? 0;
|
||||||
|
$status = is_numeric($statusRaw) ? intval($statusRaw) : 0;
|
||||||
|
|
||||||
|
// 如果已结算,直接返回已有结果(幂等)
|
||||||
|
if ($status === 1) {
|
||||||
|
$userId = is_numeric($order['user_id'] ?? null) ? intval($order['user_id']) : 0;
|
||||||
|
$coinAfter = '0.0000';
|
||||||
|
if ($userId > 0) {
|
||||||
|
$coin = Db::name('user')->where('id', $userId)->value('coin');
|
||||||
|
$coinAfter = is_string($coin) ? $coin : strval($coin);
|
||||||
|
}
|
||||||
|
$amt = self::amountString($order['amount'] ?? '0');
|
||||||
|
$bns = self::amountString($order['bonus_amount'] ?? '0');
|
||||||
|
return [
|
||||||
|
'order_id' => $orderId,
|
||||||
|
'order_no' => $orderNo,
|
||||||
|
'amount' => $amt,
|
||||||
|
'bonus_amount' => $bns,
|
||||||
|
'credit' => bcadd($amt, $bns, 4),
|
||||||
|
'balance_before' => $coinAfter,
|
||||||
|
'balance_after' => $coinAfter,
|
||||||
|
'pay_time' => is_numeric($order['pay_time'] ?? null) ? intval($order['pay_time']) : 0,
|
||||||
|
'already_settled' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($status !== 0) {
|
||||||
|
throw new RuntimeException('订单状态不允许结算');
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount = self::amountString($order['amount'] ?? '0');
|
||||||
|
if (bccomp($amount, '0', 4) <= 0) {
|
||||||
|
throw new RuntimeException('订单金额异常');
|
||||||
|
}
|
||||||
|
$bonus = self::amountString($order['bonus_amount'] ?? '0');
|
||||||
|
if (bccomp($bonus, '0', 4) < 0) {
|
||||||
|
$bonus = '0.0000';
|
||||||
|
}
|
||||||
|
$credit = bcadd($amount, $bonus, 4);
|
||||||
|
|
||||||
|
$userId = is_numeric($order['user_id'] ?? null) ? intval($order['user_id']) : 0;
|
||||||
|
if ($userId <= 0) {
|
||||||
|
throw new RuntimeException('订单所属玩家无效');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Db::name('user')->where('id', $userId)->find();
|
||||||
|
if (!$user) {
|
||||||
|
throw new RuntimeException('玩家不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
$channelId = is_numeric($order['channel_id'] ?? null) ? intval($order['channel_id']) : null;
|
||||||
|
$balanceBefore = self::amountString($user['coin'] ?? '0');
|
||||||
|
$balanceAfter = bcadd($balanceBefore, $credit, 4);
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$baseRemark = is_string($order['remark'] ?? null) ? $order['remark'] : '';
|
||||||
|
// 备注包含充值与赠送的明细,方便后续稽核
|
||||||
|
$detail = sprintf('amount=%s,bonus=%s,credit=%s', $amount, $bonus, $credit);
|
||||||
|
$note = sprintf('[%s] %s (%s)', $source, $sourceLabel, $detail);
|
||||||
|
$combined = $baseRemark === '' ? $note : ($baseRemark . ' | ' . $note);
|
||||||
|
if ($extraRemark !== null && $extraRemark !== '') {
|
||||||
|
$combined .= ' | ' . $extraRemark;
|
||||||
|
}
|
||||||
|
$finalRemark = mb_substr($combined, 0, 255);
|
||||||
|
|
||||||
|
$walletIdem = 'deposit_settle_' . $orderNo;
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$affected = Db::name('deposit_order')
|
||||||
|
->where('id', $orderId)
|
||||||
|
->where('status', 0)
|
||||||
|
->update([
|
||||||
|
'status' => 1,
|
||||||
|
'pay_time' => $now,
|
||||||
|
'review_admin_id' => $operatorAdminId,
|
||||||
|
'review_time' => $operatorAdminId !== null ? $now : null,
|
||||||
|
'remark' => $finalRemark,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
if ($affected <= 0) {
|
||||||
|
throw new RuntimeException('订单状态已变更,请刷新后重试');
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $balanceAfter,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$walletExists = Db::name('user_wallet_record')
|
||||||
|
->where('idempotency_key', $walletIdem)
|
||||||
|
->value('id');
|
||||||
|
if (!$walletExists) {
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $channelId,
|
||||||
|
'biz_type' => 'deposit',
|
||||||
|
'direction' => 1,
|
||||||
|
'amount' => $credit,
|
||||||
|
'balance_before' => $balanceBefore,
|
||||||
|
'balance_after' => $balanceAfter,
|
||||||
|
'ref_type' => 'deposit_order',
|
||||||
|
'ref_id' => $orderId,
|
||||||
|
'idempotency_key' => $walletIdem,
|
||||||
|
'operator_admin_id' => $operatorAdminId,
|
||||||
|
'remark' => mb_substr($note, 0, 500),
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new RuntimeException($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'order_id' => $orderId,
|
||||||
|
'order_no' => $orderNo,
|
||||||
|
'amount' => $amount,
|
||||||
|
'bonus_amount' => $bonus,
|
||||||
|
'credit' => $credit,
|
||||||
|
'balance_before' => $balanceBefore,
|
||||||
|
'balance_after' => $balanceAfter,
|
||||||
|
'pay_time' => $now,
|
||||||
|
'already_settled' => false,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将任意数值输入格式化为 4 位小数字符串(不做强制类型转换)
|
||||||
|
*/
|
||||||
|
private static function amountString($raw): string
|
||||||
|
{
|
||||||
|
if (is_string($raw)) {
|
||||||
|
$s = trim($raw);
|
||||||
|
} elseif (is_int($raw) || is_float($raw)) {
|
||||||
|
$s = strval($raw);
|
||||||
|
} else {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
if (!is_numeric($s)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
return bcadd($s, '0', 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
164
app/common/library/finance/WithdrawFlow.php
Normal file
164
app/common/library/finance/WithdrawFlow.php
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\library\finance;
|
||||||
|
|
||||||
|
use support\think\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现打码量(流水)门槛工具库
|
||||||
|
*
|
||||||
|
* 业务口径(打码量即提现配额模型):
|
||||||
|
* - 每笔提现消耗等额打码配额:折算 = withdraw_coin × ratio
|
||||||
|
* - lifetime_withdrawable_from_flow = bet_flow_coin / ratio
|
||||||
|
* - max_withdraw_by_flow = max(0, lifetime_withdrawable_from_flow - total_withdraw_coin)
|
||||||
|
* - 单笔上限:max_withdrawable = min(coin_balance, max_withdraw_by_flow)
|
||||||
|
* - ratio 来自 game_config.withdraw_bet_flow_ratio;ratio = 0 代表不限制打码量,此时
|
||||||
|
* max_withdraw_by_flow 视为"无限大"(由 UNLIMITED_FLOW 哨兵值表示,API 层兜底用余额)
|
||||||
|
*
|
||||||
|
* 向后兼容:原门槛 bet_flow_coin >= (total_deposit - total_withdraw) × ratio 已被
|
||||||
|
* "单笔上限 ≤ max_withdraw_by_flow" 取代且语义等价更细腻:任何通过新校验的请求必然
|
||||||
|
* 也满足旧门槛口径。字段 required_bet_flow / remaining_bet_flow / eligible 保留仅作展示。
|
||||||
|
*/
|
||||||
|
final class WithdrawFlow
|
||||||
|
{
|
||||||
|
public const CONFIG_KEY = 'withdraw_bet_flow_ratio';
|
||||||
|
|
||||||
|
public const DEFAULT_RATIO = '1.0000';
|
||||||
|
|
||||||
|
/** 当 ratio = 0(不限打码)时,max_withdraw_by_flow 用此哨兵表示"无限"。14 位整数位足够覆盖任何业务金额。 */
|
||||||
|
public const UNLIMITED_FLOW = '99999999999999.9999';
|
||||||
|
|
||||||
|
/** 单用户最多允许同时存在的「待审核」(withdraw_order.status=0) 提现订单数。 */
|
||||||
|
public const MAX_PENDING_WITHDRAW = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取当前打码倍数(字符串 4 位小数,至少 0)
|
||||||
|
*/
|
||||||
|
public static function ratio(): string
|
||||||
|
{
|
||||||
|
$row = Db::name('game_config')->where('config_key', self::CONFIG_KEY)->find();
|
||||||
|
if (!$row) {
|
||||||
|
return self::DEFAULT_RATIO;
|
||||||
|
}
|
||||||
|
$val = $row['config_value'] ?? '';
|
||||||
|
if (!is_string($val) || trim($val) === '' || !is_numeric(trim($val))) {
|
||||||
|
return self::DEFAULT_RATIO;
|
||||||
|
}
|
||||||
|
$normalized = bcadd(trim($val), '0', 4);
|
||||||
|
if (bccomp($normalized, '0', 4) < 0) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
return $normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 归一化金额字段到 4 位小数字符串,非法输入返回 '0.0000'
|
||||||
|
*/
|
||||||
|
public static function amountString($raw): string
|
||||||
|
{
|
||||||
|
if ($raw === null || $raw === '') {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
if (is_string($raw)) {
|
||||||
|
$s = trim($raw);
|
||||||
|
} elseif (is_int($raw) || is_float($raw)) {
|
||||||
|
$s = strval($raw);
|
||||||
|
} else {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
if (!is_numeric($s)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
return bcadd($s, '0', 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核算玩家当前打码量状态
|
||||||
|
*
|
||||||
|
* @param array{
|
||||||
|
* total_deposit_coin?: mixed,
|
||||||
|
* total_withdraw_coin?: mixed,
|
||||||
|
* bet_flow_coin?: mixed,
|
||||||
|
* }|null $userSnapshot 允许外部传入字典(节省一次查询);为 null 时按 $userId 从库取
|
||||||
|
*
|
||||||
|
* @return array{
|
||||||
|
* ratio: string,
|
||||||
|
* net_deposit: string,
|
||||||
|
* required_bet_flow: string,
|
||||||
|
* bet_flow_coin: string,
|
||||||
|
* remaining_bet_flow: string,
|
||||||
|
* eligible: bool,
|
||||||
|
* max_withdraw_by_flow: string,
|
||||||
|
* flow_unlimited: bool,
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function status(?int $userId, ?array $userSnapshot = null): array
|
||||||
|
{
|
||||||
|
if ($userSnapshot === null && $userId !== null) {
|
||||||
|
$userSnapshot = Db::name('user')
|
||||||
|
->field(['total_deposit_coin', 'total_withdraw_coin', 'bet_flow_coin'])
|
||||||
|
->where('id', $userId)
|
||||||
|
->find();
|
||||||
|
}
|
||||||
|
$userSnapshot = is_array($userSnapshot) ? $userSnapshot : [];
|
||||||
|
|
||||||
|
$deposit = self::amountString($userSnapshot['total_deposit_coin'] ?? '0');
|
||||||
|
$withdraw = self::amountString($userSnapshot['total_withdraw_coin'] ?? '0');
|
||||||
|
$flow = self::amountString($userSnapshot['bet_flow_coin'] ?? '0');
|
||||||
|
|
||||||
|
$net = bcsub($deposit, $withdraw, 4);
|
||||||
|
if (bccomp($net, '0', 4) < 0) {
|
||||||
|
$net = '0.0000';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ratio = self::ratio();
|
||||||
|
$required = bcmul($net, $ratio, 4);
|
||||||
|
$remaining = bcsub($required, $flow, 4);
|
||||||
|
if (bccomp($remaining, '0', 4) < 0) {
|
||||||
|
$remaining = '0.0000';
|
||||||
|
}
|
||||||
|
$eligible = bccomp($flow, $required, 4) >= 0;
|
||||||
|
|
||||||
|
// max_withdraw_by_flow = max(0, bet_flow_coin / ratio - total_withdraw_coin)
|
||||||
|
$unlimited = bccomp($ratio, '0', 4) === 0;
|
||||||
|
if ($unlimited) {
|
||||||
|
$maxByFlow = self::UNLIMITED_FLOW;
|
||||||
|
} else {
|
||||||
|
$lifetime = bcdiv($flow, $ratio, 4);
|
||||||
|
$maxByFlow = bcsub($lifetime, $withdraw, 4);
|
||||||
|
if (bccomp($maxByFlow, '0', 4) < 0) {
|
||||||
|
$maxByFlow = '0.0000';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ratio' => $ratio,
|
||||||
|
'net_deposit' => $net,
|
||||||
|
'required_bet_flow' => $required,
|
||||||
|
'bet_flow_coin' => $flow,
|
||||||
|
'remaining_bet_flow' => $remaining,
|
||||||
|
'eligible' => $eligible,
|
||||||
|
'max_withdraw_by_flow' => $maxByFlow,
|
||||||
|
'flow_unlimited' => $unlimited,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取单笔最大可提现额 = min(coin_balance, max_withdraw_by_flow)。
|
||||||
|
* 返回值为 4 位小数字符串,已与 ratio=0(不限)逻辑兼容。
|
||||||
|
*/
|
||||||
|
public static function maxWithdrawable(string $coinBalance, array $flowStatus): string
|
||||||
|
{
|
||||||
|
$coin = self::amountString($coinBalance);
|
||||||
|
if (bccomp($coin, '0', 4) < 0) {
|
||||||
|
$coin = '0.0000';
|
||||||
|
}
|
||||||
|
if (!empty($flowStatus['flow_unlimited'])) {
|
||||||
|
return $coin;
|
||||||
|
}
|
||||||
|
$byFlow = self::amountString($flowStatus['max_withdraw_by_flow'] ?? '0');
|
||||||
|
return bccomp($coin, $byFlow, 4) <= 0 ? $coin : $byFlow;
|
||||||
|
}
|
||||||
|
}
|
||||||
351
app/common/library/game/DepositTier.php
Normal file
351
app/common/library/game/DepositTier.php
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\library\game;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值档位(game_config.deposit_tier):仅存 JSON 数组
|
||||||
|
*
|
||||||
|
* 每一项字段(mock/第三方支付模式,已不再保存收款账户信息;支持中英文双语):
|
||||||
|
* - id : string,档位稳定 ID(如 t_xxxxxxxx)
|
||||||
|
* - title : string,档位中文名称(必填,前端中文环境展示)
|
||||||
|
* - title_en : string,档位英文名称(可选,前端英文环境展示;为空时回退到 title)
|
||||||
|
* - amount : string,充值金额(4 位小数)
|
||||||
|
* - bonus_amount : string,赠送金额(4 位小数,可为 0)
|
||||||
|
* - desc : string,档位中文描述(可空,<=255)
|
||||||
|
* - desc_en : string,档位英文描述(可空,<=255,为空时回退到 desc)
|
||||||
|
* - sort : int,排序权重(小值在前)
|
||||||
|
* - status : int,0=停用,1=启用
|
||||||
|
*
|
||||||
|
* 历史数据兼容:老字段 name 会在 title 缺失时作为 title 兜底(更老的 account_name 亦会兜底)。
|
||||||
|
*/
|
||||||
|
final class DepositTier
|
||||||
|
{
|
||||||
|
public const CONFIG_KEY = 'deposit_tier';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 game_config.config_value 中解析出档位数组(容错)
|
||||||
|
*
|
||||||
|
* @return list<array{
|
||||||
|
* id: string,
|
||||||
|
* title: string,
|
||||||
|
* title_en: string,
|
||||||
|
* amount: string,
|
||||||
|
* bonus_amount: string,
|
||||||
|
* desc: string,
|
||||||
|
* desc_en: string,
|
||||||
|
* sort: int,
|
||||||
|
* status: int,
|
||||||
|
* }>
|
||||||
|
*/
|
||||||
|
public static function parseFromConfigValue($raw): array
|
||||||
|
{
|
||||||
|
if (!is_string($raw) || trim($raw) === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$decoded = json_decode($raw, true);
|
||||||
|
if (!is_array($decoded)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (isset($decoded['tiers']) && is_array($decoded['tiers'])) {
|
||||||
|
$list = $decoded['tiers'];
|
||||||
|
} else {
|
||||||
|
$list = $decoded;
|
||||||
|
}
|
||||||
|
return self::normalizeList($list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<mixed> $items
|
||||||
|
*/
|
||||||
|
public static function normalizeList(array $items): array
|
||||||
|
{
|
||||||
|
$out = [];
|
||||||
|
foreach ($items as $row) {
|
||||||
|
if (!is_array($row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$id = isset($row['id']) && is_string($row['id']) ? trim($row['id']) : '';
|
||||||
|
if ($id === '') {
|
||||||
|
$id = self::generateId();
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = self::stringField($row, 'title');
|
||||||
|
if ($title === '') {
|
||||||
|
// 兼容历史:字段名 name 或更老的 account_name
|
||||||
|
$title = self::stringField($row, 'name');
|
||||||
|
if ($title === '') {
|
||||||
|
$title = self::stringField($row, 'account_name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$titleEn = self::stringField($row, 'title_en');
|
||||||
|
|
||||||
|
$amount = self::normalizeAmount($row['amount'] ?? '');
|
||||||
|
$bonus = self::normalizeAmount($row['bonus_amount'] ?? '0');
|
||||||
|
|
||||||
|
$desc = self::stringField($row, 'desc');
|
||||||
|
if ($desc === '') {
|
||||||
|
$desc = self::stringField($row, 'remark');
|
||||||
|
}
|
||||||
|
$descEn = self::stringField($row, 'desc_en');
|
||||||
|
|
||||||
|
$sort = isset($row['sort']) && is_numeric($row['sort']) ? intval($row['sort']) : 0;
|
||||||
|
$status = isset($row['status']) && is_numeric($row['status']) ? intval($row['status']) : 1;
|
||||||
|
$status = $status === 1 ? 1 : 0;
|
||||||
|
|
||||||
|
$out[] = [
|
||||||
|
'id' => $id,
|
||||||
|
'title' => $title,
|
||||||
|
'title_en' => $titleEn,
|
||||||
|
'amount' => $amount,
|
||||||
|
'bonus_amount' => $bonus,
|
||||||
|
'desc' => $desc,
|
||||||
|
'desc_en' => $descEn,
|
||||||
|
'sort' => $sort,
|
||||||
|
'status' => $status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
usort($out, static function (array $a, array $b): int {
|
||||||
|
if ($a['sort'] !== $b['sort']) {
|
||||||
|
return $a['sort'] <=> $b['sort'];
|
||||||
|
}
|
||||||
|
$ida = is_string($a['id']) ? $a['id'] : '';
|
||||||
|
$idb = is_string($b['id']) ? $b['id'] : '';
|
||||||
|
return strcmp($ida, $idb);
|
||||||
|
});
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验 POST 数据并输出用于入库的清洁数据
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $items
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public static function prepareItemsForSave(array $items): array
|
||||||
|
{
|
||||||
|
$seenId = [];
|
||||||
|
$out = [];
|
||||||
|
foreach ($items as $idx => $row) {
|
||||||
|
$no = $idx + 1;
|
||||||
|
if (!is_array($row)) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行格式错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = isset($row['id']) && is_string($row['id']) ? trim($row['id']) : '';
|
||||||
|
if ($id === '') {
|
||||||
|
$id = self::generateId();
|
||||||
|
}
|
||||||
|
if (!preg_match('/^[a-zA-Z0-9_\-]{1,32}$/', $id)) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行 ID 非法');
|
||||||
|
}
|
||||||
|
if (isset($seenId[$id])) {
|
||||||
|
throw new InvalidArgumentException('档位 ID 重复:' . $id);
|
||||||
|
}
|
||||||
|
$seenId[$id] = true;
|
||||||
|
|
||||||
|
$title = self::stringField($row, 'title');
|
||||||
|
if ($title === '') {
|
||||||
|
// 兼容上游(例如自动迁移脚本)传递历史 name 字段
|
||||||
|
$title = self::stringField($row, 'name');
|
||||||
|
}
|
||||||
|
if ($title === '') {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行中文充值名称不能为空');
|
||||||
|
}
|
||||||
|
if (mb_strlen($title) > 64) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行中文充值名称过长');
|
||||||
|
}
|
||||||
|
|
||||||
|
$titleEn = self::stringField($row, 'title_en');
|
||||||
|
if (mb_strlen($titleEn) > 64) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行英文充值名称过长');
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount = self::normalizeAmount($row['amount'] ?? '');
|
||||||
|
if (bccomp($amount, '0', 4) <= 0) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行充值金额必须大于 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bonus = self::normalizeAmount($row['bonus_amount'] ?? '0');
|
||||||
|
if (bccomp($bonus, '0', 4) < 0) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行赠送金额不能为负数');
|
||||||
|
}
|
||||||
|
|
||||||
|
$desc = self::stringField($row, 'desc');
|
||||||
|
if (mb_strlen($desc) > 255) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行中文描述过长');
|
||||||
|
}
|
||||||
|
|
||||||
|
$descEn = self::stringField($row, 'desc_en');
|
||||||
|
if (mb_strlen($descEn) > 255) {
|
||||||
|
throw new InvalidArgumentException('第 ' . $no . ' 行英文描述过长');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sort = isset($row['sort']) && is_numeric($row['sort']) ? intval($row['sort']) : 0;
|
||||||
|
$statusRaw = isset($row['status']) && is_numeric($row['status']) ? intval($row['status']) : 1;
|
||||||
|
$status = $statusRaw === 1 ? 1 : 0;
|
||||||
|
|
||||||
|
$out[] = [
|
||||||
|
'id' => $id,
|
||||||
|
'title' => $title,
|
||||||
|
'title_en' => $titleEn,
|
||||||
|
'amount' => $amount,
|
||||||
|
'bonus_amount' => $bonus,
|
||||||
|
'desc' => $desc,
|
||||||
|
'desc_en' => $descEn,
|
||||||
|
'sort' => $sort,
|
||||||
|
'status' => $status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($out, static function (array $a, array $b): int {
|
||||||
|
if ($a['sort'] !== $b['sort']) {
|
||||||
|
return $a['sort'] <=> $b['sort'];
|
||||||
|
}
|
||||||
|
$ida = is_string($a['id']) ? $a['id'] : '';
|
||||||
|
$idb = is_string($b['id']) ? $b['id'] : '';
|
||||||
|
return strcmp($ida, $idb);
|
||||||
|
});
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $items
|
||||||
|
*/
|
||||||
|
public static function encodeForDb(array $items): string
|
||||||
|
{
|
||||||
|
$encoded = json_encode($items, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
if ($encoded === false) {
|
||||||
|
throw new InvalidArgumentException('JSON 编码失败');
|
||||||
|
}
|
||||||
|
return $encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤出启用档位并按 sort 升序,供移动端选择
|
||||||
|
*/
|
||||||
|
public static function publicList(array $items): array
|
||||||
|
{
|
||||||
|
$enabled = array_values(array_filter($items, static function (array $row): bool {
|
||||||
|
if (!isset($row['status'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$val = is_numeric($row['status']) ? intval($row['status']) : 0;
|
||||||
|
return $val === 1;
|
||||||
|
}));
|
||||||
|
usort($enabled, static function (array $a, array $b): int {
|
||||||
|
$sa = isset($a['sort']) && is_numeric($a['sort']) ? intval($a['sort']) : 0;
|
||||||
|
$sb = isset($b['sort']) && is_numeric($b['sort']) ? intval($b['sort']) : 0;
|
||||||
|
if ($sa !== $sb) {
|
||||||
|
return $sa <=> $sb;
|
||||||
|
}
|
||||||
|
$ida = isset($a['id']) && is_string($a['id']) ? $a['id'] : '';
|
||||||
|
$idb = isset($b['id']) && is_string($b['id']) ? $b['id'] : '';
|
||||||
|
return strcmp($ida, $idb);
|
||||||
|
});
|
||||||
|
return $enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按 ID 从档位列表中取出指定档位;未找到返回 null
|
||||||
|
*/
|
||||||
|
public static function findById(array $items, string $id): ?array
|
||||||
|
{
|
||||||
|
foreach ($items as $row) {
|
||||||
|
if (!is_array($row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$rid = $row['id'] ?? '';
|
||||||
|
if (is_string($rid) && $rid === $id) {
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据语言选择档位对外展示的 title/desc。
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $item
|
||||||
|
* @return array{title: string, desc: string}
|
||||||
|
*/
|
||||||
|
public static function localize(array $item, string $lang): array
|
||||||
|
{
|
||||||
|
$title = self::stringField($item, 'title');
|
||||||
|
$titleEn = self::stringField($item, 'title_en');
|
||||||
|
$desc = self::stringField($item, 'desc');
|
||||||
|
$descEn = self::stringField($item, 'desc_en');
|
||||||
|
|
||||||
|
$isEn = self::isEnglishLang($lang);
|
||||||
|
$pickedTitle = $isEn ? ($titleEn !== '' ? $titleEn : $title) : ($title !== '' ? $title : $titleEn);
|
||||||
|
$pickedDesc = $isEn ? ($descEn !== '' ? $descEn : $desc) : ($desc !== '' ? $desc : $descEn);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'title' => $pickedTitle,
|
||||||
|
'desc' => $pickedDesc,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 10 位稳定 ID(t_ + 8 位随机 base32)
|
||||||
|
*/
|
||||||
|
public static function generateId(): string
|
||||||
|
{
|
||||||
|
$chars = 'abcdefghijkmnpqrstuvwxyz23456789';
|
||||||
|
$len = strlen($chars);
|
||||||
|
$id = 't_';
|
||||||
|
for ($i = 0; $i < 8; $i++) {
|
||||||
|
$id .= $chars[random_int(0, $len - 1)];
|
||||||
|
}
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将金额归一化为 4 位小数字符串;非法输入返回 '0.0000'
|
||||||
|
*/
|
||||||
|
public static function normalizeAmount($raw): string
|
||||||
|
{
|
||||||
|
if ($raw === null || $raw === '') {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
if (is_string($raw)) {
|
||||||
|
$s = trim($raw);
|
||||||
|
} elseif (is_int($raw) || is_float($raw)) {
|
||||||
|
$s = strval($raw);
|
||||||
|
} else {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
$s = str_replace(',', '.', $s);
|
||||||
|
if (!is_numeric($s)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
return bcadd($s, '0', 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数组取字符串字段并 trim,非字符串返回空串
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $row
|
||||||
|
*/
|
||||||
|
private static function stringField(array $row, string $key): string
|
||||||
|
{
|
||||||
|
if (!isset($row[$key])) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$v = $row[$key];
|
||||||
|
return is_string($v) ? trim($v) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function isEnglishLang(string $lang): bool
|
||||||
|
{
|
||||||
|
$normalized = strtolower(str_replace('_', '-', trim($lang)));
|
||||||
|
if ($normalized === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $normalized === 'en' || str_starts_with($normalized, 'en-');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,12 +16,10 @@ class BetOrder extends Model
|
|||||||
'create_time' => 'integer',
|
'create_time' => 'integer',
|
||||||
'update_time' => 'integer',
|
'update_time' => 'integer',
|
||||||
'pick_numbers' => 'json',
|
'pick_numbers' => 'json',
|
||||||
'unit_amount' => 'string',
|
|
||||||
'total_amount' => 'string',
|
'total_amount' => 'string',
|
||||||
'win_amount' => 'string',
|
'win_amount' => 'string',
|
||||||
'jackpot_extra_amount' => 'string',
|
'jackpot_extra_amount' => 'string',
|
||||||
'status' => 'integer',
|
'status' => 'integer',
|
||||||
'pick_count' => 'integer',
|
|
||||||
'streak_at_bet' => 'integer',
|
'streak_at_bet' => 'integer',
|
||||||
'is_auto' => 'integer',
|
'is_auto' => 'integer',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -29,14 +29,4 @@ class Channel extends Model
|
|||||||
{
|
{
|
||||||
return is_null($value) ? null : (float)$value;
|
return is_null($value) ? null : (float)$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adminGroup(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\admin\model\AdminGroup::class, 'admin_group_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function admin(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\admin\model\Admin::class, 'admin_id', 'id');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/common/model/ChannelAdminShare.php
Normal file
20
app/common/model/ChannelAdminShare.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use support\think\Model;
|
||||||
|
|
||||||
|
class ChannelAdminShare extends Model
|
||||||
|
{
|
||||||
|
protected $name = 'channel_admin_share';
|
||||||
|
|
||||||
|
protected $autoWriteTimestamp = true;
|
||||||
|
|
||||||
|
protected $type = [
|
||||||
|
'create_time' => 'integer',
|
||||||
|
'update_time' => 'integer',
|
||||||
|
'share_rate' => 'string',
|
||||||
|
'status' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
@@ -11,13 +11,15 @@ class GameRecord extends Model
|
|||||||
protected $autoWriteTimestamp = true;
|
protected $autoWriteTimestamp = true;
|
||||||
|
|
||||||
protected $type = [
|
protected $type = [
|
||||||
'create_time' => 'integer',
|
'create_time' => 'integer',
|
||||||
'update_time' => 'integer',
|
'update_time' => 'integer',
|
||||||
'period_start_at' => 'integer',
|
'period_start_at' => 'integer',
|
||||||
'status' => 'integer',
|
'status' => 'integer',
|
||||||
'draw_mode' => 'integer',
|
'draw_mode' => 'integer',
|
||||||
'preset_number' => 'integer',
|
'preset_number' => 'integer',
|
||||||
'result_number' => 'integer',
|
'result_number' => 'integer',
|
||||||
|
'platform_profit_amount' => 'string',
|
||||||
|
'winner_user_count' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function setPeriodStartAtAttr($value, $data = [])
|
public function setPeriodStartAtAttr($value, $data = [])
|
||||||
|
|||||||
@@ -13,12 +13,37 @@ class User extends Model
|
|||||||
|
|
||||||
protected $autoWriteTimestamp = true;
|
protected $autoWriteTimestamp = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 10 位唯一对外标识(大写字母与数字,排除易混淆字符)
|
||||||
|
*/
|
||||||
|
public static function generateUniquePublicCode10(): string
|
||||||
|
{
|
||||||
|
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
||||||
|
$len = strlen($chars);
|
||||||
|
for ($attempt = 0; $attempt < 80; $attempt++) {
|
||||||
|
$code = '';
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
$code .= $chars[random_int(0, $len - 1)];
|
||||||
|
}
|
||||||
|
if (!self::where('uuid', $code)->find()) {
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new \RuntimeException('Failed to generate unique user uuid');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function formatLoginRemark(int $timestamp, string $ip): string
|
||||||
|
{
|
||||||
|
return '最后登录:' . date('Y-m-d H:i:s', $timestamp) . ' IP:' . $ip;
|
||||||
|
}
|
||||||
|
|
||||||
protected $type = [
|
protected $type = [
|
||||||
'create_time' => 'integer',
|
'create_time' => 'integer',
|
||||||
'update_time' => 'integer',
|
'update_time' => 'integer',
|
||||||
'coin' => 'string',
|
'coin' => 'string',
|
||||||
'total_deposit_coin' => 'string',
|
'total_deposit_coin' => 'string',
|
||||||
'total_valid_bet_coin' => 'string',
|
'total_withdraw_coin' => 'string',
|
||||||
|
'bet_flow_coin' => 'string',
|
||||||
'risk_flags' => 'integer',
|
'risk_flags' => 'integer',
|
||||||
'current_streak' => 'integer',
|
'current_streak' => 'integer',
|
||||||
];
|
];
|
||||||
|
|||||||
205
app/common/service/GameBetSettleService.php
Normal file
205
app/common/service/GameBetSettleService.php
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use support\think\Db;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开奖后结算注单:写入 win_amount、status=已结算;中奖时入账并记 user_wallet_record(biz_type=payout)。
|
||||||
|
*/
|
||||||
|
final class GameBetSettleService
|
||||||
|
{
|
||||||
|
private const BASE_ODDS = 33;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对指定期次按开奖号码结算所有「待开奖」注单;同一注单幂等(仅 status=1 会更新)。
|
||||||
|
*
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public static function settleBetsForDraw(int $recordId, int $resultNumber): void
|
||||||
|
{
|
||||||
|
if ($recordId <= 0 || $resultNumber < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$bets = Db::name('bet_order')
|
||||||
|
->where('period_id', $recordId)
|
||||||
|
->where('status', 1)
|
||||||
|
->order('id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
foreach ($bets as $bet) {
|
||||||
|
$betId = (int) ($bet['id'] ?? 0);
|
||||||
|
if ($betId <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$win = self::computeWinAmount($bet, $resultNumber);
|
||||||
|
$jackpot = '0.0000';
|
||||||
|
|
||||||
|
$affected = Db::name('bet_order')
|
||||||
|
->where('id', $betId)
|
||||||
|
->where('status', 1)
|
||||||
|
->update([
|
||||||
|
'win_amount' => $win,
|
||||||
|
'jackpot_extra_amount' => $jackpot,
|
||||||
|
'status' => 2,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($affected === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 结算刚刚成功(status 1 → 2):把本单下注总额 1:1 累加到用户打码量
|
||||||
|
self::creditUserBetFlow($bet, $now);
|
||||||
|
|
||||||
|
if (bccomp($win, '0', 4) <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::creditUserPayout($bet, $betId, $win, $now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补偿:库中已结束局次但注单仍为待开奖的,可重复调用(幂等)。
|
||||||
|
*/
|
||||||
|
public static function settlePendingForEndedRecords(): int
|
||||||
|
{
|
||||||
|
$rows = Db::name('game_record')
|
||||||
|
->where('status', 4)
|
||||||
|
->whereNotNull('result_number')
|
||||||
|
->field(['id', 'result_number'])
|
||||||
|
->order('id', 'asc')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$rid = (int) ($row['id'] ?? 0);
|
||||||
|
$rn = (int) ($row['result_number'] ?? 0);
|
||||||
|
if ($rid <= 0 || $rn < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$pending = Db::name('bet_order')
|
||||||
|
->where('period_id', $rid)
|
||||||
|
->where('status', 1)
|
||||||
|
->count();
|
||||||
|
if ($pending === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
self::settleBetsForDraw($rid, $rn);
|
||||||
|
Db::commit();
|
||||||
|
$count++;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应付派彩:开奖号码 ∈ pick_numbers 即中奖;整笔 total_amount × (连胜+1) × 33(与 GameLiveService 一致)。
|
||||||
|
*/
|
||||||
|
public static function computeWinAmount(array $bet, int $resultNumber): string
|
||||||
|
{
|
||||||
|
$pickNumbers = $bet['pick_numbers'] ?? null;
|
||||||
|
if (is_string($pickNumbers)) {
|
||||||
|
$decoded = json_decode($pickNumbers, true);
|
||||||
|
$pickNumbers = is_array($decoded) ? $decoded : [];
|
||||||
|
}
|
||||||
|
if (!is_array($pickNumbers)) {
|
||||||
|
$pickNumbers = [];
|
||||||
|
}
|
||||||
|
if (!in_array($resultNumber, array_map('intval', $pickNumbers), true)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
$total = (string) ($bet['total_amount'] ?? '0');
|
||||||
|
$streak = (int) ($bet['streak_at_bet'] ?? 0);
|
||||||
|
$odds = (string) (($streak + 1) * self::BASE_ODDS);
|
||||||
|
|
||||||
|
return bcmul($total, $odds, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累加玩家打码量(流水):按本注单 total_amount 1:1 加到 user.bet_flow_coin。
|
||||||
|
*
|
||||||
|
* 幂等性由调用点保证:只有 bet_order 首次从 status=1 变更为 status=2(返回 $affected=1)
|
||||||
|
* 时才会调用本方法,重复结算不会触发。
|
||||||
|
*/
|
||||||
|
private static function creditUserBetFlow(array $bet, int $now): void
|
||||||
|
{
|
||||||
|
$userId = isset($bet['user_id']) && is_numeric($bet['user_id']) ? intval($bet['user_id']) : 0;
|
||||||
|
if ($userId <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$totalRaw = $bet['total_amount'] ?? '0';
|
||||||
|
$total = is_string($totalRaw) ? trim($totalRaw) : (is_numeric($totalRaw) ? strval($totalRaw) : '0');
|
||||||
|
if ($total === '' || !is_numeric($total)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$flow = bcadd($total, '0', 4);
|
||||||
|
if (bccomp($flow, '0', 4) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 原子加法:避免读-改-写导致的并发覆盖;$flow 已由 bcadd 归一化为纯数字字符串,不存在 SQL 注入
|
||||||
|
Db::name('user')
|
||||||
|
->where('id', $userId)
|
||||||
|
->update([
|
||||||
|
'bet_flow_coin' => Db::raw('bet_flow_coin + ' . $flow),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function creditUserPayout(array $bet, int $betId, string $winAmount, int $now): void
|
||||||
|
{
|
||||||
|
$userId = (int) ($bet['user_id'] ?? 0);
|
||||||
|
if ($userId <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$idem = 'payout_bet_' . $betId;
|
||||||
|
if (Db::name('user_wallet_record')->where('idempotency_key', $idem)->value('id')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Db::name('user')->where('id', $userId)->find();
|
||||||
|
if (!$user) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$before = (string) ($user['coin'] ?? '0');
|
||||||
|
$after = bcadd($before, $winAmount, 4);
|
||||||
|
|
||||||
|
Db::name('user_wallet_record')->insert([
|
||||||
|
'user_id' => $userId,
|
||||||
|
'channel_id' => $bet['channel_id'] ?? null,
|
||||||
|
'biz_type' => 'payout',
|
||||||
|
'direction' => 1,
|
||||||
|
'amount' => $winAmount,
|
||||||
|
'balance_before' => $before,
|
||||||
|
'balance_after' => $after,
|
||||||
|
'ref_type' => 'bet_order',
|
||||||
|
'ref_id' => $betId,
|
||||||
|
'idempotency_key' => $idem,
|
||||||
|
'operator_admin_id' => null,
|
||||||
|
'remark' => '压注派彩',
|
||||||
|
'create_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::name('user')->where('id', $userId)->update([
|
||||||
|
'coin' => $after,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,9 @@ final class GameLiveService
|
|||||||
private const KEY_BET_SECONDS = 'bet_seconds';
|
private const KEY_BET_SECONDS = 'bet_seconds';
|
||||||
private const KEY_PICK_MAX_NUMBER_COUNT = 'pick_max_number_count';
|
private const KEY_PICK_MAX_NUMBER_COUNT = 'pick_max_number_count';
|
||||||
|
|
||||||
|
/** 开奖结果号码池:1 至此上限(与单注可选号码个数配置无关) */
|
||||||
|
private const DRAW_NUMBER_MAX = 36;
|
||||||
|
|
||||||
public static function buildSnapshot(?int $recordId = null): array
|
public static function buildSnapshot(?int $recordId = null): array
|
||||||
{
|
{
|
||||||
$record = self::resolveRecord($recordId);
|
$record = self::resolveRecord($recordId);
|
||||||
@@ -30,6 +33,7 @@ final class GameLiveService
|
|||||||
'period_seconds' => self::getConfigInt(self::KEY_PERIOD_SECONDS, 30),
|
'period_seconds' => self::getConfigInt(self::KEY_PERIOD_SECONDS, 30),
|
||||||
'bet_seconds' => self::getConfigInt(self::KEY_BET_SECONDS, 20),
|
'bet_seconds' => self::getConfigInt(self::KEY_BET_SECONDS, 20),
|
||||||
'pick_max_number_count' => self::getPickMaxNumberCount(),
|
'pick_max_number_count' => self::getPickMaxNumberCount(),
|
||||||
|
'draw_number_max' => self::DRAW_NUMBER_MAX,
|
||||||
'remaining_seconds' => 0,
|
'remaining_seconds' => 0,
|
||||||
'bet_remaining_seconds' => 0,
|
'bet_remaining_seconds' => 0,
|
||||||
'can_calculate' => false,
|
'can_calculate' => false,
|
||||||
@@ -59,7 +63,7 @@ final class GameLiveService
|
|||||||
$status = (int) $record['status'];
|
$status = (int) $record['status'];
|
||||||
$canCalculate = $elapsed >= $betSeconds && ($status === 0 || $status === 1);
|
$canCalculate = $elapsed >= $betSeconds && ($status === 0 || $status === 1);
|
||||||
if ($canCalculate) {
|
if ($canCalculate) {
|
||||||
for ($n = 1; $n <= $pickMax; $n++) {
|
for ($n = 1; $n <= self::DRAW_NUMBER_MAX; $n++) {
|
||||||
$loss = self::estimateLossForNumber($bets, $n);
|
$loss = self::estimateLossForNumber($bets, $n);
|
||||||
$candidates[] = [
|
$candidates[] = [
|
||||||
'number' => $n,
|
'number' => $n,
|
||||||
@@ -85,7 +89,6 @@ final class GameLiveService
|
|||||||
'user_id' => (int) $row['user_id'],
|
'user_id' => (int) $row['user_id'],
|
||||||
'period_no' => (string) $row['period_no'],
|
'period_no' => (string) $row['period_no'],
|
||||||
'pick_numbers' => $row['pick_numbers'],
|
'pick_numbers' => $row['pick_numbers'],
|
||||||
'unit_amount' => (string) $row['unit_amount'],
|
|
||||||
'total_amount' => (string) $row['total_amount'],
|
'total_amount' => (string) $row['total_amount'],
|
||||||
'streak_at_bet' => (int) $row['streak_at_bet'],
|
'streak_at_bet' => (int) $row['streak_at_bet'],
|
||||||
'create_time' => (int) $row['create_time'],
|
'create_time' => (int) $row['create_time'],
|
||||||
@@ -97,6 +100,7 @@ final class GameLiveService
|
|||||||
'period_seconds' => $periodSeconds,
|
'period_seconds' => $periodSeconds,
|
||||||
'bet_seconds' => $betSeconds,
|
'bet_seconds' => $betSeconds,
|
||||||
'pick_max_number_count' => $pickMax,
|
'pick_max_number_count' => $pickMax,
|
||||||
|
'draw_number_max' => self::DRAW_NUMBER_MAX,
|
||||||
'remaining_seconds' => $remaining,
|
'remaining_seconds' => $remaining,
|
||||||
'bet_remaining_seconds' => $betRemaining,
|
'bet_remaining_seconds' => $betRemaining,
|
||||||
'can_calculate' => $canCalculate,
|
'can_calculate' => $canCalculate,
|
||||||
@@ -129,7 +133,7 @@ final class GameLiveService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pickMax = self::getPickMaxNumberCount();
|
$pickMax = self::getPickMaxNumberCount();
|
||||||
if ($manualNumber !== null && ($manualNumber < 1 || $manualNumber > $pickMax)) {
|
if ($manualNumber !== null && ($manualNumber < 1 || $manualNumber > self::DRAW_NUMBER_MAX)) {
|
||||||
return ['ok' => false, 'msg' => '手动开奖号码超出允许范围'];
|
return ['ok' => false, 'msg' => '手动开奖号码超出允许范围'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +142,7 @@ final class GameLiveService
|
|||||||
$bestNumber = null;
|
$bestNumber = null;
|
||||||
$bestLoss = null;
|
$bestLoss = null;
|
||||||
$bestNumbers = [];
|
$bestNumbers = [];
|
||||||
for ($n = 1; $n <= $pickMax; $n++) {
|
for ($n = 1; $n <= self::DRAW_NUMBER_MAX; $n++) {
|
||||||
$loss = self::estimateLossForNumber($bets, $n);
|
$loss = self::estimateLossForNumber($bets, $n);
|
||||||
$candidates[] = ['number' => $n, 'estimated_loss' => $loss];
|
$candidates[] = ['number' => $n, 'estimated_loss' => $loss];
|
||||||
if ($bestLoss === null || bccomp((string) $loss, (string) $bestLoss, 4) < 0) {
|
if ($bestLoss === null || bccomp((string) $loss, (string) $bestLoss, 4) < 0) {
|
||||||
@@ -165,6 +169,7 @@ final class GameLiveService
|
|||||||
'period_seconds' => $periodSeconds,
|
'period_seconds' => $periodSeconds,
|
||||||
'bet_seconds' => $betSeconds,
|
'bet_seconds' => $betSeconds,
|
||||||
'pick_max_number_count' => $pickMax,
|
'pick_max_number_count' => $pickMax,
|
||||||
|
'draw_number_max' => self::DRAW_NUMBER_MAX,
|
||||||
'candidate_numbers' => $candidates,
|
'candidate_numbers' => $candidates,
|
||||||
'ai_default_number' => $bestNumber,
|
'ai_default_number' => $bestNumber,
|
||||||
'final_number' => $finalNumber,
|
'final_number' => $finalNumber,
|
||||||
@@ -189,8 +194,10 @@ final class GameLiveService
|
|||||||
'draw_mode' => $manualNumber === null ? 0 : 1,
|
'draw_mode' => $manualNumber === null ? 0 : 1,
|
||||||
'update_time' => $now,
|
'update_time' => $now,
|
||||||
]);
|
]);
|
||||||
|
GameBetSettleService::settleBetsForDraw((int) $record['id'], $finalNumber);
|
||||||
GameRecordService::createNextRecordAfterDraw();
|
GameRecordService::createNextRecordAfterDraw();
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
GameRecordStatService::refreshForRecordId((int) $record['id']);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
return ['ok' => false, 'msg' => $e->getMessage()];
|
return ['ok' => false, 'msg' => $e->getMessage()];
|
||||||
@@ -295,10 +302,10 @@ final class GameLiveService
|
|||||||
if (!in_array($number, array_map('intval', $pickNumbers), true)) {
|
if (!in_array($number, array_map('intval', $pickNumbers), true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$unit = (string) ($bet['unit_amount'] ?? '0');
|
$total = (string) ($bet['total_amount'] ?? '0');
|
||||||
$streak = (int) ($bet['streak_at_bet'] ?? 0);
|
$streak = (int) ($bet['streak_at_bet'] ?? 0);
|
||||||
$odds = (string) (($streak + 1) * self::BASE_ODDS);
|
$odds = (string) (($streak + 1) * self::BASE_ODDS);
|
||||||
$orderPayout = bcmul($unit, $odds, 4);
|
$orderPayout = bcmul($total, $odds, 4);
|
||||||
$payout = bcadd($payout, $orderPayout, 4);
|
$payout = bcadd($payout, $orderPayout, 4);
|
||||||
}
|
}
|
||||||
return $payout;
|
return $payout;
|
||||||
|
|||||||
106
app/common/service/GameRecordStatService.php
Normal file
106
app/common/service/GameRecordStatService.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use support\think\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对局维度统计:平台盈亏、中奖人数(与 GameLiveService 单号派彩口径一致)。
|
||||||
|
*/
|
||||||
|
final class GameRecordStatService
|
||||||
|
{
|
||||||
|
private const BASE_ODDS = 33;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据注单与开奖号码回写 game_record 统计字段(已结束对局)。
|
||||||
|
*/
|
||||||
|
public static function refreshForRecordId(int $recordId): void
|
||||||
|
{
|
||||||
|
if ($recordId <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$record = Db::name('game_record')->where('id', $recordId)->find();
|
||||||
|
if (!$record) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$status = (int) ($record['status'] ?? 0);
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
if ($status !== 4) {
|
||||||
|
Db::name('game_record')->where('id', $recordId)->update([
|
||||||
|
'platform_profit_amount' => '0.0000',
|
||||||
|
'winner_user_count' => 0,
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resultRaw = $record['result_number'] ?? null;
|
||||||
|
if ($resultRaw === null || $resultRaw === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$resultNum = (int) $resultRaw;
|
||||||
|
|
||||||
|
$bets = Db::name('bet_order')->where('period_id', $recordId)->select()->toArray();
|
||||||
|
$totalBet = '0.0000';
|
||||||
|
$totalPayout = '0.0000';
|
||||||
|
$winnerUserIds = [];
|
||||||
|
|
||||||
|
foreach ($bets as $bet) {
|
||||||
|
$st = (int) ($bet['status'] ?? 0);
|
||||||
|
if ($st === 3) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tb = (string) ($bet['total_amount'] ?? '0');
|
||||||
|
$totalBet = bcadd($totalBet, $tb, 4);
|
||||||
|
|
||||||
|
if ($st === 2) {
|
||||||
|
$payout = bcadd((string) ($bet['win_amount'] ?? '0'), (string) ($bet['jackpot_extra_amount'] ?? '0'), 4);
|
||||||
|
} else {
|
||||||
|
$payout = self::estimatePayoutForBet($bet, $resultNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalPayout = bcadd($totalPayout, $payout, 4);
|
||||||
|
if (bccomp($payout, '0', 4) > 0) {
|
||||||
|
$uid = (int) ($bet['user_id'] ?? 0);
|
||||||
|
if ($uid > 0) {
|
||||||
|
$winnerUserIds[$uid] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$profit = bcsub($totalBet, $totalPayout, 4);
|
||||||
|
|
||||||
|
Db::name('game_record')->where('id', $recordId)->update([
|
||||||
|
'platform_profit_amount' => $profit,
|
||||||
|
'winner_user_count' => count($winnerUserIds),
|
||||||
|
'update_time' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 与 GameLiveService::estimateLossForNumber 中派彩一致:命中号码时 total_amount × (streak+1) × 33。
|
||||||
|
*/
|
||||||
|
private static function estimatePayoutForBet(array $bet, int $resultNumber): string
|
||||||
|
{
|
||||||
|
$pickNumbers = $bet['pick_numbers'] ?? null;
|
||||||
|
if (is_string($pickNumbers)) {
|
||||||
|
$decoded = json_decode($pickNumbers, true);
|
||||||
|
$pickNumbers = is_array($decoded) ? $decoded : [];
|
||||||
|
}
|
||||||
|
if (!is_array($pickNumbers)) {
|
||||||
|
$pickNumbers = [];
|
||||||
|
}
|
||||||
|
if (!in_array($resultNumber, array_map('intval', $pickNumbers), true)) {
|
||||||
|
return '0.0000';
|
||||||
|
}
|
||||||
|
$total = (string) ($bet['total_amount'] ?? '0');
|
||||||
|
$streak = (int) ($bet['streak_at_bet'] ?? 0);
|
||||||
|
$odds = (string) (($streak + 1) * self::BASE_ODDS);
|
||||||
|
|
||||||
|
return bcmul($total, $odds, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,12 +15,11 @@ class Channel extends Validate
|
|||||||
'name' => 'require|max:255',
|
'name' => 'require|max:255',
|
||||||
'agent_mode' => 'require|in:turnover,affiliate',
|
'agent_mode' => 'require|in:turnover,affiliate',
|
||||||
'status' => 'in:0,1',
|
'status' => 'in:0,1',
|
||||||
'admin_id' => 'require|integer|gt:0',
|
|
||||||
'remark' => 'max:255',
|
'remark' => 'max:255',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $scene = [
|
protected $scene = [
|
||||||
'add' => ['code', 'name', 'agent_mode', 'status', 'admin_id', 'remark'],
|
'add' => ['code', 'name', 'agent_mode', 'status', 'remark'],
|
||||||
'edit' => ['name', 'agent_mode', 'status', 'admin_id', 'remark'],
|
'edit' => ['name', 'agent_mode', 'status', 'remark'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,39 +112,40 @@ Route::post('/api/account/retrievePassword', [\app\api\controller\Account::class
|
|||||||
Route::post('/api/ems/send', [\app\api\controller\Ems::class, 'send']);
|
Route::post('/api/ems/send', [\app\api\controller\Ems::class, 'send']);
|
||||||
|
|
||||||
// ==================== 移动端用户接口(统一收口到 /api/user/*) ====================
|
// ==================== 移动端用户接口(统一收口到 /api/user/*) ====================
|
||||||
|
// 约定:移动端所有业务接口一律使用 POST 调用;查询类同时兼容 GET 便于浏览器调试。
|
||||||
Route::post('/api/user/register', [\app\api\controller\Auth::class, 'userRegister']);
|
Route::post('/api/user/register', [\app\api\controller\Auth::class, 'userRegister']);
|
||||||
Route::post('/api/user/login', [\app\api\controller\Auth::class, 'userLogin']);
|
Route::post('/api/user/login', [\app\api\controller\Auth::class, 'userLogin']);
|
||||||
Route::post('/api/user/refreshToken', [\app\api\controller\Auth::class, 'tokenRefresh']);
|
Route::post('/api/user/refreshToken', [\app\api\controller\Auth::class, 'tokenRefresh']);
|
||||||
Route::get('/api/user/profile', [\app\api\controller\Account::class, 'userProfile']);
|
Route::add(['GET', 'POST'], '/api/user/profile', [\app\api\controller\Account::class, 'userProfile']);
|
||||||
Route::post('/api/user/retrievePassword', [\app\api\controller\Account::class, 'retrievePassword']);
|
Route::post('/api/user/retrievePassword', [\app\api\controller\Account::class, 'retrievePassword']);
|
||||||
|
|
||||||
// 兼容旧移动端路径,后续客户端切换完成后可移除
|
// 兼容旧移动端路径,后续客户端切换完成后可移除
|
||||||
Route::post('/api/auth/userRegister', [\app\api\controller\Auth::class, 'userRegister']);
|
Route::post('/api/auth/userRegister', [\app\api\controller\Auth::class, 'userRegister']);
|
||||||
Route::post('/api/auth/userLogin', [\app\api\controller\Auth::class, 'userLogin']);
|
Route::post('/api/auth/userLogin', [\app\api\controller\Auth::class, 'userLogin']);
|
||||||
Route::post('/api/auth/tokenRefresh', [\app\api\controller\Auth::class, 'tokenRefresh']);
|
Route::post('/api/auth/tokenRefresh', [\app\api\controller\Auth::class, 'tokenRefresh']);
|
||||||
Route::get('/api/account/userProfile', [\app\api\controller\Account::class, 'userProfile']);
|
Route::add(['GET', 'POST'], '/api/account/userProfile', [\app\api\controller\Account::class, 'userProfile']);
|
||||||
|
|
||||||
Route::get('/api/game/lobbyInit', [\app\api\controller\Game::class, 'lobbyInit']);
|
Route::add(['GET', 'POST'], '/api/game/lobbyInit', [\app\api\controller\Game::class, 'lobbyInit']);
|
||||||
Route::get('/api/game/dictionaryList', [\app\api\controller\Game::class, 'dictionaryList']);
|
Route::add(['GET', 'POST'], '/api/game/dictionaryList', [\app\api\controller\Game::class, 'dictionaryList']);
|
||||||
Route::get('/api/game/periodHistory', [\app\api\controller\Game::class, 'periodHistory']);
|
Route::add(['GET', 'POST'], '/api/game/periodHistory', [\app\api\controller\Game::class, 'periodHistory']);
|
||||||
Route::get('/api/game/periodCurrent', [\app\api\controller\Game::class, 'periodCurrent']);
|
Route::add(['GET', 'POST'], '/api/game/periodCurrent', [\app\api\controller\Game::class, 'periodCurrent']);
|
||||||
Route::post('/api/game/betPlace', [\app\api\controller\Game::class, 'betPlace']);
|
Route::post('/api/game/betPlace', [\app\api\controller\Game::class, 'betPlace']);
|
||||||
Route::post('/api/game/betRebet', [\app\api\controller\Game::class, 'betRebet']);
|
Route::add(['GET', 'POST'], '/api/game/betMyOrders', [\app\api\controller\Game::class, 'betMyOrders']);
|
||||||
Route::post('/api/game/autoBetCreate', [\app\api\controller\Game::class, 'autoBetCreate']);
|
|
||||||
Route::post('/api/game/autoBetStop', [\app\api\controller\Game::class, 'autoBetStop']);
|
|
||||||
Route::get('/api/game/betMyOrders', [\app\api\controller\Game::class, 'betMyOrders']);
|
|
||||||
|
|
||||||
Route::get('/api/wallet/balanceSummary', [\app\api\controller\Wallet::class, 'balanceSummary']);
|
Route::add(['GET', 'POST'], '/api/wallet/balanceSummary', [\app\api\controller\Wallet::class, 'balanceSummary']);
|
||||||
Route::get('/api/wallet/recordList', [\app\api\controller\Wallet::class, 'recordList']);
|
Route::add(['GET', 'POST'], '/api/wallet/recordList', [\app\api\controller\Wallet::class, 'recordList']);
|
||||||
|
|
||||||
|
Route::add(['GET', 'POST'], '/api/finance/depositTierList', [\app\api\controller\Finance::class, 'depositTierList']);
|
||||||
Route::post('/api/finance/depositCreate', [\app\api\controller\Finance::class, 'depositCreate']);
|
Route::post('/api/finance/depositCreate', [\app\api\controller\Finance::class, 'depositCreate']);
|
||||||
Route::get('/api/finance/depositDetail', [\app\api\controller\Finance::class, 'depositDetail']);
|
Route::add(['GET', 'POST'], '/api/finance/depositDetail', [\app\api\controller\Finance::class, 'depositDetail']);
|
||||||
|
Route::add(['GET', 'POST'], '/api/finance/depositList', [\app\api\controller\Finance::class, 'depositList']);
|
||||||
Route::post('/api/finance/withdrawCreate', [\app\api\controller\Finance::class, 'withdrawCreate']);
|
Route::post('/api/finance/withdrawCreate', [\app\api\controller\Finance::class, 'withdrawCreate']);
|
||||||
Route::get('/api/finance/withdrawDetail', [\app\api\controller\Finance::class, 'withdrawDetail']);
|
Route::add(['GET', 'POST'], '/api/finance/withdrawDetail', [\app\api\controller\Finance::class, 'withdrawDetail']);
|
||||||
|
Route::add(['GET', 'POST'], '/api/finance/withdrawList', [\app\api\controller\Finance::class, 'withdrawList']);
|
||||||
|
|
||||||
Route::get('/api/notice/noticeList', [\app\api\controller\Notice::class, 'noticeList']);
|
Route::get('/api/notice/noticeList', [\app\api\controller\Notice::class, 'noticeList']);
|
||||||
Route::get('/api/notice/noticeDetail', [\app\api\controller\Notice::class, 'noticeDetail']);
|
Route::get('/api/notice/noticeDetail', [\app\api\controller\Notice::class, 'noticeDetail']);
|
||||||
Route::post('/api/notice/noticeConfirm', [\app\api\controller\Notice::class, 'noticeConfirm']);
|
Route::get('/api/notice/noticeConfirm', [\app\api\controller\Notice::class, 'noticeConfirm']);
|
||||||
|
|
||||||
// ==================== Admin 路由 ====================
|
// ==================== Admin 路由 ====================
|
||||||
// Admin 多为 JSON API,前端可能用 GET 传参查列表、POST 提交表单,使用 any 确保兼容
|
// Admin 多为 JSON API,前端可能用 GET 传参查列表、POST 提交表单,使用 any 确保兼容
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -6,11 +6,6 @@ export default {
|
|||||||
email: 'Email',
|
email: 'Email',
|
||||||
mobile: 'Mobile Number',
|
mobile: 'Mobile Number',
|
||||||
invite_code: 'Invite code',
|
invite_code: 'Invite code',
|
||||||
commission_rate: 'Commission rate(%)',
|
|
||||||
commission_rate_desc_title: 'Admin commission notes',
|
|
||||||
commission_rate_desc_1: 'Admin commission means this admin allocation ratio inside assigned group.',
|
|
||||||
commission_rate_desc_2: 'Current admin commission = current group commission × current admin commission rate.',
|
|
||||||
commission_rate_desc_3: 'Within same group, total admin commission rate cannot exceed 100%; exceed and remaining are returned on validation.',
|
|
||||||
'Please select exactly one group': 'Please select exactly one group',
|
'Please select exactly one group': 'Please select exactly one group',
|
||||||
'Last login': 'Last login',
|
'Last login': 'Last login',
|
||||||
Password: 'Password',
|
Password: 'Password',
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
export default {
|
export default {
|
||||||
GroupName: 'Group Name',
|
GroupName: 'Group Name',
|
||||||
'Group name': 'Group Name',
|
'Group name': 'Group Name',
|
||||||
commission_rate: 'Commission rate (%)',
|
channel_id: 'Channel',
|
||||||
commission_rate_desc_title: 'Group commission notes',
|
channel_name: 'Channel name',
|
||||||
commission_rate_desc_1: 'The total group commission rate under the same parent cannot exceed 100%.',
|
channel_admin: 'Channel admin',
|
||||||
commission_rate_desc_2: 'Current group commission = channel commission × (1 - parent group commission rate) × current group commission rate.',
|
channel_auto_bind: 'Will bind to the current account channel automatically',
|
||||||
commission_rate_desc_3: 'If exceeded, the system returns both exceeded value and remaining quota under current parent.',
|
channel_inherit_hint:
|
||||||
|
'Sub groups do not pick a channel separately: saving uses the parent group channel; changing parent syncs automatically.',
|
||||||
|
system_group_no_channel: 'System (no channel)',
|
||||||
jurisdiction: 'Permissions',
|
jurisdiction: 'Permissions',
|
||||||
'Parent group': 'Superior group',
|
'Parent group': 'Superior group',
|
||||||
'The parent group cannot be the group itself': 'The parent group cannot be the group itself',
|
'The parent group cannot be the group itself': 'The parent group cannot be the group itself',
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default {
|
|||||||
admingroup__name: 'name',
|
admingroup__name: 'name',
|
||||||
admin_id: 'admin_id',
|
admin_id: 'admin_id',
|
||||||
admin_tree_tip: 'Admins are grouped by channel. Pick a leaf under a channel name. One channel maps to one admin.',
|
admin_tree_tip: 'Admins are grouped by channel. Pick a leaf under a channel name. One channel maps to one admin.',
|
||||||
|
admin_select_tip: 'Only administrators within your data permission scope are listed; search by username.',
|
||||||
manual_settle: 'Manual settle',
|
manual_settle: 'Manual settle',
|
||||||
manual_settle_confirm: 'Confirm trigger manual settlement for this channel?',
|
manual_settle_confirm: 'Confirm trigger manual settlement for this channel?',
|
||||||
manual_settle_settlement_no: 'Settlement No.',
|
manual_settle_settlement_no: 'Settlement No.',
|
||||||
@@ -70,8 +71,16 @@ export default {
|
|||||||
manual_settle_calc_base: 'Settlement base',
|
manual_settle_calc_base: 'Settlement base',
|
||||||
manual_settle_commission_amount: 'Commission amount',
|
manual_settle_commission_amount: 'Commission amount',
|
||||||
manual_settle_remark: 'Remark',
|
manual_settle_remark: 'Remark',
|
||||||
admin_id_placeholder: 'Select a channel admin account',
|
share_config: 'Share config',
|
||||||
admin__username: 'username',
|
share_config_title: 'Channel admin share config',
|
||||||
|
share_config_tip: 'Only enabled rows participate in settlement split, and enabled share total must equal 100%.',
|
||||||
|
share_rate_percent: 'Share rate(%)',
|
||||||
|
share_total_enabled: 'Enabled total',
|
||||||
|
share_total_must_100: 'Enabled share total must equal 100%',
|
||||||
|
admin_id_placeholder: 'Select an admin (within your permission scope)',
|
||||||
|
admin__username: 'Person in charge',
|
||||||
|
admin_group_names: 'Role group',
|
||||||
|
admin_group_paths: 'Role hierarchy',
|
||||||
create_time: 'create_time',
|
create_time: 'create_time',
|
||||||
update_time: 'update_time',
|
update_time: 'update_time',
|
||||||
'quick Search Fields': 'id,code,name',
|
'quick Search Fields': 'id,code,name',
|
||||||
|
|||||||
29
web/src/lang/backend/en/config/depositTier.ts
Normal file
29
web/src/lang/backend/en/config/depositTier.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export default {
|
||||||
|
title: 'Deposit Tiers',
|
||||||
|
desc: 'Configure the deposit tiers players can pick when creating a deposit order. In the third-party payment mode, only tier specs (name, amount, bonus, description) are maintained; receiving accounts are no longer stored here. Maintain both Chinese and English text for the title and description: the mobile API returns the language matching the request `lang` header, falling back to Chinese if English is blank. Changes take effect immediately.',
|
||||||
|
btn_add: 'Add Tier',
|
||||||
|
btn_save: 'Save',
|
||||||
|
btn_remove: 'Delete',
|
||||||
|
confirm_remove: 'Delete this deposit tier?',
|
||||||
|
tier_id: 'Tier ID',
|
||||||
|
auto_id: '(generated on save)',
|
||||||
|
sort: 'Sort',
|
||||||
|
status: 'Enabled',
|
||||||
|
title_col: 'Title (ZH)',
|
||||||
|
title_ph: 'e.g. 新手首充、VIP 高额充值',
|
||||||
|
title_en_col: 'Title (EN)',
|
||||||
|
title_en_ph: 'e.g. Starter Pack, VIP Recharge',
|
||||||
|
amount: 'Amount',
|
||||||
|
amount_ph: 'e.g. 100.00',
|
||||||
|
bonus_amount: 'Bonus',
|
||||||
|
bonus_ph: 'e.g. 20.00, use 0 if none',
|
||||||
|
desc_col: 'Description (ZH)',
|
||||||
|
desc_ph: 'Optional Chinese description, up to 255 chars',
|
||||||
|
desc_en_col: 'Description (EN)',
|
||||||
|
desc_en_ph: 'Optional English description, up to 255 chars',
|
||||||
|
currency: '',
|
||||||
|
operate: 'Action',
|
||||||
|
err_title: 'Row {no}: Chinese title is required',
|
||||||
|
err_amount: 'Row {no}: amount must be a number greater than 0',
|
||||||
|
err_bonus: 'Row {no}: bonus must be a number no less than 0',
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@ export default {
|
|||||||
user_id: 'User ID',
|
user_id: 'User ID',
|
||||||
channel_id: 'Channel ID',
|
channel_id: 'Channel ID',
|
||||||
pick_numbers: 'Picks',
|
pick_numbers: 'Picks',
|
||||||
unit_amount: 'Unit amount',
|
total_amount: 'Total bet amount',
|
||||||
pick_count: 'Pick count',
|
|
||||||
total_amount: 'Total',
|
|
||||||
streak_at_bet: 'Streak at bet',
|
streak_at_bet: 'Streak at bet',
|
||||||
is_auto: 'Auto',
|
is_auto: 'Auto',
|
||||||
'is_auto 0': 'Manual',
|
'is_auto 0': 'Manual',
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ export default {
|
|||||||
bet_id: 'Bet ID',
|
bet_id: 'Bet ID',
|
||||||
user_id: 'Player ID',
|
user_id: 'Player ID',
|
||||||
pick_numbers: 'Pick numbers',
|
pick_numbers: 'Pick numbers',
|
||||||
unit_amount: 'Unit amount',
|
total_amount: 'Total bet amount',
|
||||||
streak_at_bet: 'Streak at bet',
|
streak_at_bet: 'Streak at bet',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
export default {
|
|
||||||
'quick Search Fields': 'Period No. / ID',
|
|
||||||
id: 'ID',
|
|
||||||
period_no: 'Period No.',
|
|
||||||
period_start_at: 'Start time',
|
|
||||||
status: 'Status',
|
|
||||||
'status 0': 'Betting open',
|
|
||||||
'status 1': 'Closed',
|
|
||||||
'status 2': 'Settling',
|
|
||||||
'status 3': 'Paying',
|
|
||||||
'status 4': 'Ended',
|
|
||||||
'status 5': 'Void',
|
|
||||||
draw_mode: 'Draw mode',
|
|
||||||
'draw_mode 0': 'Auto AI',
|
|
||||||
'draw_mode 1': 'Manual preset',
|
|
||||||
preset_number: 'Preset number',
|
|
||||||
result_number: 'Result number',
|
|
||||||
void_reason: 'Void reason',
|
|
||||||
create_time: 'Created',
|
|
||||||
update_time: 'Updated',
|
|
||||||
section_auto: 'Auto draw & new period',
|
|
||||||
auto_create_label: 'Allow auto-create next period',
|
|
||||||
auto_create_tip: 'When enabled, a background ticker inserts a new period if none is in progress',
|
|
||||||
manual_create_label: 'Allow manual create next period',
|
|
||||||
manual_create_tip: 'When enabled, the button below can create the next period',
|
|
||||||
btn_create_next: 'Create next period (manual)',
|
|
||||||
saving: 'Saving…',
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,8 @@ export default {
|
|||||||
'draw_mode 1': 'Manual preset',
|
'draw_mode 1': 'Manual preset',
|
||||||
preset_number: 'Preset number',
|
preset_number: 'Preset number',
|
||||||
result_number: 'Result number',
|
result_number: 'Result number',
|
||||||
|
platform_profit_amount: 'Round P/L (platform)',
|
||||||
|
winner_user_count: 'Winners',
|
||||||
void_reason: 'Void reason',
|
void_reason: 'Void reason',
|
||||||
create_time: 'Created',
|
create_time: 'Created',
|
||||||
update_time: 'Updated',
|
update_time: 'Updated',
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ export default {
|
|||||||
coin: 'Coin balance',
|
coin: 'Coin balance',
|
||||||
coin_placeholder: 'decimal(18,4)',
|
coin_placeholder: 'decimal(18,4)',
|
||||||
total_deposit_coin: 'Total deposit (coin)',
|
total_deposit_coin: 'Total deposit (coin)',
|
||||||
total_valid_bet_coin: 'Total valid bet (coin)',
|
total_withdraw_coin: 'Total withdraw (coin)',
|
||||||
|
bet_flow_coin: 'Bet flow (coin)',
|
||||||
risk_flags: 'Risk',
|
risk_flags: 'Risk',
|
||||||
risk_none: 'None',
|
risk_none: 'None',
|
||||||
risk_no_login: 'No login',
|
risk_no_login: 'No login',
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
user_id: 'User ID',
|
user_id: 'User ID',
|
||||||
channel_id: 'Channel ID',
|
channel_id: 'Channel ID',
|
||||||
pick_numbers: 'Picks',
|
pick_numbers: 'Picks',
|
||||||
unit_amount: 'Unit amount',
|
total_amount: 'Total bet amount',
|
||||||
pick_count: 'Pick count',
|
|
||||||
total_amount: 'Total',
|
|
||||||
streak_at_bet: 'Streak at bet',
|
streak_at_bet: 'Streak at bet',
|
||||||
is_auto: 'Auto',
|
is_auto: 'Auto',
|
||||||
'is_auto 0': 'Manual',
|
'is_auto 0': 'Manual',
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
export default {
|
export default {
|
||||||
'quick Search Fields': 'Order No./User ID/Pay channel',
|
'quick Search Fields': 'Order No./User ID/Pay channel/Tier/Idempotency key',
|
||||||
id: 'ID',
|
id: 'ID',
|
||||||
order_no: 'Order No.',
|
order_no: 'Order No.',
|
||||||
|
idempotency_key: 'Idempotency key',
|
||||||
user_id: 'User ID',
|
user_id: 'User ID',
|
||||||
channel_id: 'Channel ID',
|
channel_id: 'Channel ID',
|
||||||
amount: 'Amount',
|
amount: 'Amount',
|
||||||
|
bonus_amount: 'Bonus',
|
||||||
|
total_credit: 'Total credit',
|
||||||
status: 'Status',
|
status: 'Status',
|
||||||
'status 0': 'Pending',
|
'status 0': 'Pending',
|
||||||
'status 1': 'Success',
|
'status 1': 'Success',
|
||||||
@@ -12,9 +15,12 @@ export default {
|
|||||||
'status 3': 'Canceled',
|
'status 3': 'Canceled',
|
||||||
pay_channel: 'Pay channel',
|
pay_channel: 'Pay channel',
|
||||||
pay_time: 'Pay time',
|
pay_time: 'Pay time',
|
||||||
|
deposit_tier_id: 'Deposit tier',
|
||||||
remark: 'Remark',
|
remark: 'Remark',
|
||||||
create_time: 'Created',
|
create_time: 'Created',
|
||||||
update_time: 'Updated',
|
update_time: 'Updated',
|
||||||
user_username: 'Username',
|
user_username: 'Username',
|
||||||
channel_name: 'Channel',
|
channel_name: 'Channel',
|
||||||
|
detail_title: 'Deposit Order Detail',
|
||||||
|
close_btn: 'Close',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,20 @@ export default {
|
|||||||
remark: 'Remark',
|
remark: 'Remark',
|
||||||
create_time: 'Created',
|
create_time: 'Created',
|
||||||
update_time: 'Updated',
|
update_time: 'Updated',
|
||||||
user_username: 'Username',
|
user_username: 'User',
|
||||||
channel_name: 'Channel',
|
channel_name: 'Channel',
|
||||||
review_admin_username: 'Reviewer',
|
review_admin_username: 'Reviewer',
|
||||||
|
review_title: 'Withdraw review',
|
||||||
|
review_reject_title: 'Reject withdraw',
|
||||||
|
review_btn_approve: 'Approve',
|
||||||
|
review_btn_reject: 'Reject',
|
||||||
|
review_btn_back: 'Back',
|
||||||
|
review_btn_confirm_reject: 'Confirm reject',
|
||||||
|
review_reject_tip: 'Rejected withdrawals will refund the frozen amount back to the user wallet.',
|
||||||
|
review_reject_placeholder: 'Enter reject reason (visible to the user on mobile history)',
|
||||||
|
reject_reason_required: 'Please enter reject reason',
|
||||||
|
already_reviewed: 'This order has already been reviewed',
|
||||||
|
amount_invalid: 'Apply amount must be greater than 0',
|
||||||
|
fee_invalid: 'Fee cannot be negative',
|
||||||
|
fee_exceed_amount: 'Fee cannot exceed apply amount',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ export default {
|
|||||||
head_image: 'Avatar',
|
head_image: 'Avatar',
|
||||||
remark: 'Remark',
|
remark: 'Remark',
|
||||||
coin: 'Coin balance',
|
coin: 'Coin balance',
|
||||||
coin_placeholder: 'decimal(18,4)',
|
coin_placeholder: 'Amounts are displayed with 2 decimals',
|
||||||
total_deposit_coin: 'Total deposit (coin)',
|
total_deposit_coin: 'Total deposit (coin)',
|
||||||
total_valid_bet_coin: 'Total valid bet (coin)',
|
total_withdraw_coin: 'Total withdraw (coin)',
|
||||||
|
bet_flow_coin: 'Bet flow (coin)',
|
||||||
risk_flags: 'Risk',
|
risk_flags: 'Risk',
|
||||||
risk_none: 'None',
|
risk_none: 'None',
|
||||||
risk_no_login: 'No login',
|
risk_no_login: 'No login',
|
||||||
@@ -42,4 +43,12 @@ export default {
|
|||||||
section_risk: 'Risk control',
|
section_risk: 'Risk control',
|
||||||
section_streak: 'Streak (fallback)',
|
section_streak: 'Streak (fallback)',
|
||||||
section_other: 'Other',
|
section_other: 'Other',
|
||||||
|
wallet_adjust_title: 'Wallet adjustment',
|
||||||
|
wallet_adjust_op: 'Operation',
|
||||||
|
wallet_adjust_credit: 'Credit',
|
||||||
|
wallet_adjust_deduct: 'Deduct',
|
||||||
|
wallet_adjust_amount: 'Amount',
|
||||||
|
wallet_adjust_amount_invalid: 'Please enter an amount greater than 0',
|
||||||
|
wallet_adjust_operator_admin: 'operator admin',
|
||||||
|
wallet_adjust_default_remark: 'Backend admin ({admin}) {action} {amount} (value)',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,6 @@ export default {
|
|||||||
email: '电子邮箱',
|
email: '电子邮箱',
|
||||||
mobile: '手机号',
|
mobile: '手机号',
|
||||||
invite_code: '邀请码',
|
invite_code: '邀请码',
|
||||||
commission_rate: '分红比(%)',
|
|
||||||
commission_rate_desc_title: '管理员分红说明',
|
|
||||||
commission_rate_desc_1: '管理员分红用于该管理员在所属角色组内的分配比例。',
|
|
||||||
commission_rate_desc_2: '当前管理员分红=当前角色分红×当前管理员分红比例。',
|
|
||||||
commission_rate_desc_3: '同一角色组内,管理员分红比例总和不能超过100%;超额会提示超出值与剩余额度。',
|
|
||||||
'Please select exactly one group': '请选择且仅选择一个角色组',
|
'Please select exactly one group': '请选择且仅选择一个角色组',
|
||||||
'Last login': '最后登录',
|
'Last login': '最后登录',
|
||||||
Password: '密码',
|
Password: '密码',
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
export default {
|
export default {
|
||||||
GroupName: '组名',
|
GroupName: '组名',
|
||||||
'Group name': '组别名称',
|
'Group name': '组别名称',
|
||||||
commission_rate: '分红比例(%)',
|
channel_id: '所属渠道',
|
||||||
commission_rate_desc_title: '角色组分红说明',
|
channel_name: '渠道名称',
|
||||||
commission_rate_desc_1: '同一父级下角色组分红比例总和不能超过100%。',
|
channel_admin: '渠道管理员',
|
||||||
commission_rate_desc_2: '当前角色分红=渠道设置获取分红×(1-上级角色分红比例)×当前角色分红比例。',
|
channel_auto_bind: '将自动绑定为当前账号所属渠道',
|
||||||
commission_rate_desc_3: '提交超额时,系统会提示超出值与当前父级剩余额度。',
|
channel_inherit_hint: '子级不单独选渠道:保存时将使用上级分组对应渠道,变更上级时会自动同步。',
|
||||||
|
system_group_no_channel: '系统级(未绑定渠道)',
|
||||||
jurisdiction: '权限',
|
jurisdiction: '权限',
|
||||||
'Parent group': '上级分组',
|
'Parent group': '上级分组',
|
||||||
'The parent group cannot be the group itself': '上级分组不能是分组本身',
|
'The parent group cannot be the group itself': '上级分组不能是分组本身',
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default {
|
|||||||
admingroup__name: '组名',
|
admingroup__name: '组名',
|
||||||
admin_id: '管理员',
|
admin_id: '管理员',
|
||||||
admin_tree_tip: '按渠道分组展示可关联的管理员账号,请在「渠道名称」下选择具体管理员(叶子节点)。渠道负责人仅对应一名管理员。',
|
admin_tree_tip: '按渠道分组展示可关联的管理员账号,请在「渠道名称」下选择具体管理员(叶子节点)。渠道负责人仅对应一名管理员。',
|
||||||
|
admin_select_tip: '仅列出当前账号数据权限范围内的管理员,支持搜索用户名。',
|
||||||
manual_settle: '手动结算',
|
manual_settle: '手动结算',
|
||||||
manual_settle_confirm: '确认触发当前渠道手动结算?',
|
manual_settle_confirm: '确认触发当前渠道手动结算?',
|
||||||
manual_settle_settlement_no: '结算单号',
|
manual_settle_settlement_no: '结算单号',
|
||||||
@@ -70,8 +71,16 @@ export default {
|
|||||||
manual_settle_calc_base: '结算基数',
|
manual_settle_calc_base: '结算基数',
|
||||||
manual_settle_commission_amount: '佣金金额',
|
manual_settle_commission_amount: '佣金金额',
|
||||||
manual_settle_remark: '备注',
|
manual_settle_remark: '备注',
|
||||||
admin_id_placeholder: '请选择渠道下的管理员账号',
|
share_config: '分配比例',
|
||||||
admin__username: '用户名',
|
share_config_title: '渠道管理员分配比例',
|
||||||
|
share_config_tip: '仅启用项参与结算拆分,且启用项占比总和必须等于100%。',
|
||||||
|
share_rate_percent: '分配比例(%)',
|
||||||
|
share_total_enabled: '启用项合计',
|
||||||
|
share_total_must_100: '启用项分配比例总和必须等于100%',
|
||||||
|
admin_id_placeholder: '请选择管理员(仅当前权限范围内)',
|
||||||
|
admin__username: '负责人',
|
||||||
|
admin_group_names: '角色组',
|
||||||
|
admin_group_paths: '角色组层级',
|
||||||
create_time: '创建时间',
|
create_time: '创建时间',
|
||||||
update_time: '修改时间',
|
update_time: '修改时间',
|
||||||
'quick Search Fields': 'ID、渠道标识、渠道名',
|
'quick Search Fields': 'ID、渠道标识、渠道名',
|
||||||
|
|||||||
29
web/src/lang/backend/zh-cn/config/depositTier.ts
Normal file
29
web/src/lang/backend/zh-cn/config/depositTier.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export default {
|
||||||
|
title: '充值档位',
|
||||||
|
desc: '配置玩家创建充值订单时可选的充值档位。第三方支付模式下仅需维护档位规格:名称、充值金额、赠送金额、描述等;不再保存收款账户信息。充值名称/描述需分别维护中英文两套:移动端接口会根据请求头 `lang` 返回对应语言,英文缺省时回退到中文。修改后立即生效。',
|
||||||
|
btn_add: '新增档位',
|
||||||
|
btn_save: '保存',
|
||||||
|
btn_remove: '删除',
|
||||||
|
confirm_remove: '确定删除该充值档位?',
|
||||||
|
tier_id: '档位 ID',
|
||||||
|
auto_id: '(保存时生成)',
|
||||||
|
sort: '排序',
|
||||||
|
status: '启用',
|
||||||
|
title_col: '充值名称(中文)',
|
||||||
|
title_ph: '例如:新手首充、VIP 高额充值',
|
||||||
|
title_en_col: '充值名称(英文)',
|
||||||
|
title_en_ph: 'e.g. Starter Pack, VIP Recharge',
|
||||||
|
amount: '充值金额',
|
||||||
|
amount_ph: '例如:100.00',
|
||||||
|
bonus_amount: '赠送金额',
|
||||||
|
bonus_ph: '例如:20.00,无赠送填 0',
|
||||||
|
desc_col: '描述(中文)',
|
||||||
|
desc_ph: '可选,展示给中文玩家的档位说明,最长 255 字',
|
||||||
|
desc_en_col: '描述(英文)',
|
||||||
|
desc_en_ph: 'Optional English description for EN players, up to 255 chars',
|
||||||
|
currency: '币',
|
||||||
|
operate: '操作',
|
||||||
|
err_title: '第 {no} 行:中文充值名称不能为空',
|
||||||
|
err_amount: '第 {no} 行:充值金额必须为大于 0 的数字',
|
||||||
|
err_bonus: '第 {no} 行:赠送金额必须为不小于 0 的数字',
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@ export default {
|
|||||||
user_id: '用户ID',
|
user_id: '用户ID',
|
||||||
channel_id: '渠道ID',
|
channel_id: '渠道ID',
|
||||||
pick_numbers: '选号',
|
pick_numbers: '选号',
|
||||||
unit_amount: '单号金额',
|
total_amount: '压注总额',
|
||||||
pick_count: '选号个数',
|
|
||||||
total_amount: '总金额',
|
|
||||||
streak_at_bet: '下注时连胜',
|
streak_at_bet: '下注时连胜',
|
||||||
is_auto: '托管',
|
is_auto: '托管',
|
||||||
'is_auto 0': '手动',
|
'is_auto 0': '手动',
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ export default {
|
|||||||
bet_id: '注单ID',
|
bet_id: '注单ID',
|
||||||
user_id: '玩家ID',
|
user_id: '玩家ID',
|
||||||
pick_numbers: '压注号码',
|
pick_numbers: '压注号码',
|
||||||
unit_amount: '单号金额',
|
total_amount: '压注总额',
|
||||||
streak_at_bet: '下注时连胜',
|
streak_at_bet: '下注时连胜',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
export default {
|
|
||||||
'quick Search Fields': '期号/ID',
|
|
||||||
id: 'ID',
|
|
||||||
period_no: '期号',
|
|
||||||
period_start_at: '开始时间',
|
|
||||||
status: '状态',
|
|
||||||
'status 0': '下注开放',
|
|
||||||
'status 1': '已封盘',
|
|
||||||
'status 2': '算票中',
|
|
||||||
'status 3': '派彩中',
|
|
||||||
'status 4': '已结束',
|
|
||||||
'status 5': '已作废',
|
|
||||||
draw_mode: '开奖方式',
|
|
||||||
'draw_mode 0': '自动AI',
|
|
||||||
'draw_mode 1': '手动预设',
|
|
||||||
preset_number: '预设号码',
|
|
||||||
result_number: '开奖号码',
|
|
||||||
void_reason: '作废原因',
|
|
||||||
create_time: '创建时间',
|
|
||||||
update_time: '更新时间',
|
|
||||||
section_auto: '自动开奖与新建期',
|
|
||||||
auto_create_label: '允许自动创建下一期',
|
|
||||||
auto_create_tip: '开启后由后台定时任务在无进行中期号时自动插入新期',
|
|
||||||
manual_create_label: '允许手动创建下一期',
|
|
||||||
manual_create_tip: '开启后可在本页使用「手动创建下一期」按钮',
|
|
||||||
btn_create_next: '手动创建下一期',
|
|
||||||
saving: '保存中…',
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,8 @@ export default {
|
|||||||
'draw_mode 1': '手动预设',
|
'draw_mode 1': '手动预设',
|
||||||
preset_number: '预设号码',
|
preset_number: '预设号码',
|
||||||
result_number: '开奖号码',
|
result_number: '开奖号码',
|
||||||
|
platform_profit_amount: '对局盈亏(平台)',
|
||||||
|
winner_user_count: '中奖人数',
|
||||||
void_reason: '作废原因',
|
void_reason: '作废原因',
|
||||||
create_time: '创建时间',
|
create_time: '创建时间',
|
||||||
update_time: '更新时间',
|
update_time: '更新时间',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export default {
|
|||||||
id: 'ID',
|
id: 'ID',
|
||||||
username: '用户名',
|
username: '用户名',
|
||||||
password: '密码',
|
password: '密码',
|
||||||
uuid: '用户唯一标识',
|
uuid: 'uuid',
|
||||||
phone: '手机号',
|
phone: '手机号',
|
||||||
email: '邮箱',
|
email: '邮箱',
|
||||||
email_placeholder: '可选,与手机号二选一注册时填写',
|
email_placeholder: '可选,与手机号二选一注册时填写',
|
||||||
@@ -11,7 +11,8 @@ export default {
|
|||||||
coin: '游戏币余额',
|
coin: '游戏币余额',
|
||||||
coin_placeholder: 'decimal(18,4),禁止业务用浮点存库',
|
coin_placeholder: 'decimal(18,4),禁止业务用浮点存库',
|
||||||
total_deposit_coin: '累计充值(币)',
|
total_deposit_coin: '累计充值(币)',
|
||||||
total_valid_bet_coin: '累计有效投注(币)',
|
total_withdraw_coin: '累计提现(币)',
|
||||||
|
bet_flow_coin: '打码量/流水(币)',
|
||||||
risk_flags: '风控',
|
risk_flags: '风控',
|
||||||
risk_none: '无限制',
|
risk_none: '无限制',
|
||||||
risk_no_login: '禁止登录',
|
risk_no_login: '禁止登录',
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
user_id: '用户ID',
|
user_id: '用户ID',
|
||||||
channel_id: '渠道ID',
|
channel_id: '渠道ID',
|
||||||
pick_numbers: '选号',
|
pick_numbers: '选号',
|
||||||
unit_amount: '单号金额',
|
total_amount: '压注总额',
|
||||||
pick_count: '选号个数',
|
|
||||||
total_amount: '总金额',
|
|
||||||
streak_at_bet: '下注时连胜',
|
streak_at_bet: '下注时连胜',
|
||||||
is_auto: '托管',
|
is_auto: '托管',
|
||||||
'is_auto 0': '手动',
|
'is_auto 0': '手动',
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
export default {
|
export default {
|
||||||
'quick Search Fields': '订单号/用户ID/支付通道',
|
'quick Search Fields': '订单号/用户ID/支付通道/档位ID/幂等键',
|
||||||
id: 'ID',
|
id: 'ID',
|
||||||
order_no: '订单号',
|
order_no: '订单号',
|
||||||
|
idempotency_key: '幂等键',
|
||||||
user_id: '用户ID',
|
user_id: '用户ID',
|
||||||
user_username: '用户名',
|
user_username: '用户名',
|
||||||
channel_id: '渠道ID',
|
channel_id: '渠道ID',
|
||||||
channel_name: '渠道',
|
channel_name: '渠道',
|
||||||
amount: '金额',
|
amount: '金额',
|
||||||
|
bonus_amount: '赠送金额',
|
||||||
|
total_credit: '实际到账',
|
||||||
status: '状态',
|
status: '状态',
|
||||||
'status 0': '待处理',
|
'status 0': '待支付',
|
||||||
'status 1': '成功',
|
'status 1': '成功',
|
||||||
'status 2': '失败',
|
'status 2': '失败',
|
||||||
'status 3': '已取消',
|
'status 3': '已取消',
|
||||||
pay_channel: '支付通道',
|
pay_channel: '支付通道',
|
||||||
pay_time: '支付时间',
|
pay_time: '支付时间',
|
||||||
|
deposit_tier_id: '充值档位',
|
||||||
remark: '备注',
|
remark: '备注',
|
||||||
create_time: '创建时间',
|
create_time: '创建时间',
|
||||||
update_time: '更新时间',
|
update_time: '更新时间',
|
||||||
|
detail_title: '充值订单详情',
|
||||||
|
close_btn: '关闭',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,20 @@ export default {
|
|||||||
remark: '备注',
|
remark: '备注',
|
||||||
create_time: '创建时间',
|
create_time: '创建时间',
|
||||||
update_time: '更新时间',
|
update_time: '更新时间',
|
||||||
user_username: '用户名',
|
user_username: '用户',
|
||||||
channel_name: '渠道',
|
channel_name: '渠道',
|
||||||
review_admin_username: '审核人',
|
review_admin_username: '审核人',
|
||||||
|
review_title: '提现审核',
|
||||||
|
review_reject_title: '提现拒绝',
|
||||||
|
review_btn_approve: '通过',
|
||||||
|
review_btn_reject: '拒绝',
|
||||||
|
review_btn_back: '返回',
|
||||||
|
review_btn_confirm_reject: '确认拒绝',
|
||||||
|
review_reject_tip: '拒绝审核后,冻结的提现金额将原路退回用户钱包余额。',
|
||||||
|
review_reject_placeholder: '请输入拒绝原因,玩家可在提现记录中看到该说明',
|
||||||
|
reject_reason_required: '请输入拒绝原因',
|
||||||
|
already_reviewed: '该订单已审核,无需重复操作',
|
||||||
|
amount_invalid: '申请金额必须大于 0',
|
||||||
|
fee_invalid: '手续费不能为负',
|
||||||
|
fee_exceed_amount: '手续费不能大于申请金额',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,17 @@ export default {
|
|||||||
id: 'ID',
|
id: 'ID',
|
||||||
username: '用户名',
|
username: '用户名',
|
||||||
password: '密码',
|
password: '密码',
|
||||||
uuid: '用户唯一标识',
|
uuid: 'uuid',
|
||||||
phone: '手机号',
|
phone: '手机号',
|
||||||
email: '邮箱',
|
email: '邮箱',
|
||||||
email_placeholder: '可选,与手机号二选一注册时填写',
|
email_placeholder: '可选,与手机号二选一注册时填写',
|
||||||
head_image: '头像',
|
head_image: '头像',
|
||||||
remark: '备注',
|
remark: '备注',
|
||||||
coin: '游戏币余额',
|
coin: '余额',
|
||||||
coin_placeholder: 'decimal(18,4),禁止业务用浮点存库',
|
coin_placeholder: '金额展示统一两位小数',
|
||||||
total_deposit_coin: '累计充值(币)',
|
total_deposit_coin: '累计充值(币)',
|
||||||
total_valid_bet_coin: '累计有效投注(币)',
|
total_withdraw_coin: '累计提现(币)',
|
||||||
|
bet_flow_coin: '打码量/流水(币)',
|
||||||
risk_flags: '风控',
|
risk_flags: '风控',
|
||||||
risk_none: '无限制',
|
risk_none: '无限制',
|
||||||
risk_no_login: '禁止登录',
|
risk_no_login: '禁止登录',
|
||||||
@@ -42,4 +43,12 @@ export default {
|
|||||||
section_risk: '风控',
|
section_risk: '风控',
|
||||||
section_streak: '连胜(兜底)',
|
section_streak: '连胜(兜底)',
|
||||||
section_other: '其他',
|
section_other: '其他',
|
||||||
|
wallet_adjust_title: '钱包加减点',
|
||||||
|
wallet_adjust_op: '操作类型',
|
||||||
|
wallet_adjust_credit: '加点',
|
||||||
|
wallet_adjust_deduct: '扣点',
|
||||||
|
wallet_adjust_amount: '操作金额',
|
||||||
|
wallet_adjust_amount_invalid: '请输入大于0的金额',
|
||||||
|
wallet_adjust_operator_admin: '操作管理员',
|
||||||
|
wallet_adjust_default_remark: '后台管理员({admin}){action}{amount}(值)',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,6 @@ optButtons[1].display = (row) => {
|
|||||||
return row.id != adminInfo.id
|
return row.id != adminInfo.id
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatRatePercent = (_row: any, _column: any, cellValue: number | string | null) => {
|
|
||||||
if (cellValue === null || cellValue === undefined || cellValue === '') return '--'
|
|
||||||
const num = Number(cellValue)
|
|
||||||
if (Number.isNaN(num)) return '--'
|
|
||||||
return `${num.toFixed(2)}%`
|
|
||||||
}
|
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/auth.Admin/'),
|
new baTableApi('/admin/auth.Admin/'),
|
||||||
{
|
{
|
||||||
@@ -64,14 +57,6 @@ const baTable = new baTableClass(
|
|||||||
render: 'tags',
|
render: 'tags',
|
||||||
},
|
},
|
||||||
{ label: t('auth.admin.invite_code'), prop: 'invite_code', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
{ label: t('auth.admin.invite_code'), prop: 'invite_code', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||||
{
|
|
||||||
label: t('auth.admin.commission_rate'),
|
|
||||||
prop: 'commission_rate',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 90,
|
|
||||||
operator: 'RANGE',
|
|
||||||
formatter: formatRatePercent,
|
|
||||||
},
|
|
||||||
{ label: t('auth.admin.avatar'), prop: 'avatar', align: 'center', render: 'image', operator: false },
|
{ label: t('auth.admin.avatar'), prop: 'avatar', align: 'center', render: 'image', operator: false },
|
||||||
{ label: t('auth.admin.email'), prop: 'email', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
{ label: t('auth.admin.email'), prop: 'email', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||||
{ label: t('auth.admin.mobile'), prop: 'mobile', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
{ label: t('auth.admin.mobile'), prop: 'mobile', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||||
@@ -89,10 +74,16 @@ const baTable = new baTableClass(
|
|||||||
label: t('State'),
|
label: t('State'),
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: 'tag',
|
operator: 'eq',
|
||||||
effect: 'dark',
|
sortable: false,
|
||||||
custom: { disable: 'danger', enable: 'success' },
|
render: 'switch',
|
||||||
replaceValue: { disable: t('Disable'), enable: t('Enable') },
|
replaceValue: { disable: t('Disable'), enable: t('Enable') },
|
||||||
|
customRenderAttr: {
|
||||||
|
switch: () => ({
|
||||||
|
activeValue: 'enable',
|
||||||
|
inactiveValue: 'disable',
|
||||||
|
}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Operate'),
|
label: t('Operate'),
|
||||||
|
|||||||
@@ -56,23 +56,6 @@
|
|||||||
placeholder: t('Click select'),
|
placeholder: t('Click select'),
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<FormItem
|
|
||||||
:label="t('auth.admin.commission_rate')"
|
|
||||||
v-model="baTable.form.items!.commission_rate"
|
|
||||||
type="number"
|
|
||||||
prop="commission_rate"
|
|
||||||
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100, disabled: shouldDisableCommissionRate() }"
|
|
||||||
:placeholder="t('Please input field', { field: t('auth.admin.commission_rate') })"
|
|
||||||
/>
|
|
||||||
<el-alert class="commission-rate-alert" :title="t('auth.admin.commission_rate_desc_title')" type="info" :closable="false" show-icon>
|
|
||||||
<template #default>
|
|
||||||
<ul class="commission-rate-desc-list">
|
|
||||||
<li>{{ t('auth.admin.commission_rate_desc_1') }}</li>
|
|
||||||
<li>{{ t('auth.admin.commission_rate_desc_2') }}</li>
|
|
||||||
<li>{{ t('auth.admin.commission_rate_desc_3') }}</li>
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
</el-alert>
|
|
||||||
<FormItem
|
<FormItem
|
||||||
v-if="baTable.form.operate == 'Edit'"
|
v-if="baTable.form.operate == 'Edit'"
|
||||||
:label="t('auth.admin.invite_code')"
|
:label="t('auth.admin.invite_code')"
|
||||||
@@ -156,32 +139,6 @@ const baTable = inject('baTable') as baTableClass
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
/** 解析管理员分红比例:与后端 isValidCommissionRate 一致地拒绝非法字符,避免 Number('30,00') 等为 NaN 导致误报 */
|
|
||||||
function parseAdminCommissionRateInput(raw: unknown): { kind: 'empty' } | { kind: 'invalid' } | { kind: 'ok'; value: number } {
|
|
||||||
if (raw === null || raw === undefined || raw === '') {
|
|
||||||
return { kind: 'empty' }
|
|
||||||
}
|
|
||||||
if (typeof raw === 'number') {
|
|
||||||
if (!Number.isFinite(raw)) {
|
|
||||||
return { kind: 'invalid' }
|
|
||||||
}
|
|
||||||
return { kind: 'ok', value: raw }
|
|
||||||
}
|
|
||||||
const s = String(raw).trim()
|
|
||||||
if (s === '') {
|
|
||||||
return { kind: 'empty' }
|
|
||||||
}
|
|
||||||
const normalized = s.replace(',', '.')
|
|
||||||
const n = parseFloat(normalized)
|
|
||||||
if (!Number.isFinite(n)) {
|
|
||||||
return { kind: 'invalid' }
|
|
||||||
}
|
|
||||||
return { kind: 'ok', value: n }
|
|
||||||
}
|
|
||||||
|
|
||||||
const shouldDisableCommissionRate = () => {
|
|
||||||
return adminInfo.id == baTable.form.items!.id
|
|
||||||
}
|
|
||||||
const singleGroupValue = computed({
|
const singleGroupValue = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
const group = baTable.form.items?.group_arr
|
const group = baTable.form.items?.group_arr
|
||||||
@@ -241,26 +198,6 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
commission_rate: [
|
|
||||||
{
|
|
||||||
validator: (_rule: unknown, val: unknown, callback: (e?: Error) => void) => {
|
|
||||||
const parsed = parseAdminCommissionRateInput(val)
|
|
||||||
if (parsed.kind === 'empty') {
|
|
||||||
return callback()
|
|
||||||
}
|
|
||||||
if (parsed.kind === 'invalid') {
|
|
||||||
return callback(new Error(t('Please enter the correct field', { field: t('auth.admin.commission_rate') })))
|
|
||||||
}
|
|
||||||
const n = parsed.value
|
|
||||||
const rounded = Math.round(n * 100) / 100
|
|
||||||
if (rounded < -0.000001 || rounded > 100.000001) {
|
|
||||||
return callback(new Error(t('Please enter the correct field', { field: t('auth.admin.commission_rate') })))
|
|
||||||
}
|
|
||||||
return callback()
|
|
||||||
},
|
|
||||||
trigger: ['blur', 'change'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -285,14 +222,6 @@ watch(
|
|||||||
width: 110px;
|
width: 110px;
|
||||||
height: 110px;
|
height: 110px;
|
||||||
}
|
}
|
||||||
.commission-rate-alert {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.commission-rate-desc-list {
|
|
||||||
margin: 6px 0 0;
|
|
||||||
padding-left: 18px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
.avatar-uploader:hover {
|
.avatar-uploader:hover {
|
||||||
border-color: var(--el-color-primary);
|
border-color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const baTable: baTableClass = new baTableClass(
|
|||||||
new baTableApi('/admin/auth.Group/'),
|
new baTableApi('/admin/auth.Group/'),
|
||||||
{
|
{
|
||||||
expandAll: true,
|
expandAll: true,
|
||||||
dblClickNotEditColumn: [undefined],
|
dblClickNotEditColumn: [undefined, 'status'],
|
||||||
column: [
|
column: [
|
||||||
{ type: 'selection', align: 'center' },
|
{ type: 'selection', align: 'center' },
|
||||||
{
|
{
|
||||||
@@ -60,15 +60,20 @@ const baTable: baTableClass = new baTableClass(
|
|||||||
align: 'left',
|
align: 'left',
|
||||||
minWidth: '180',
|
minWidth: '180',
|
||||||
},
|
},
|
||||||
{ label: t('auth.group.commission_rate'), prop: 'commission_rate', align: 'center', formatter: formatRatePercent },
|
{
|
||||||
|
label: t('auth.group.channel_name'),
|
||||||
|
prop: 'channel_name',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: '140',
|
||||||
|
},
|
||||||
{ label: t('auth.group.jurisdiction'), prop: 'rules', align: 'center' },
|
{ label: t('auth.group.jurisdiction'), prop: 'rules', align: 'center' },
|
||||||
{
|
{
|
||||||
label: t('State'),
|
label: t('State'),
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: 'tag',
|
operator: 'eq',
|
||||||
effect: 'dark',
|
sortable: false,
|
||||||
custom: { 0: 'danger', 1: 'success' },
|
render: 'switch',
|
||||||
replaceValue: { 0: t('Disable'), 1: t('Enable') },
|
replaceValue: { 0: t('Disable'), 1: t('Enable') },
|
||||||
},
|
},
|
||||||
{ label: t('Update time'), prop: 'update_time', align: 'center', width: '160', render: 'datetime' },
|
{ label: t('Update time'), prop: 'update_time', align: 'center', width: '160', render: 'datetime' },
|
||||||
@@ -86,6 +91,7 @@ const baTable: baTableClass = new baTableClass(
|
|||||||
{
|
{
|
||||||
defaultItems: {
|
defaultItems: {
|
||||||
status: 1,
|
status: 1,
|
||||||
|
channel_id: null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -94,9 +100,18 @@ const baTable: baTableClass = new baTableClass(
|
|||||||
baTable.before.onSubmit = ({ formEl, operate, items }) => {
|
baTable.before.onSubmit = ({ formEl, operate, items }) => {
|
||||||
let submitCallback = () => {
|
let submitCallback = () => {
|
||||||
baTable.form.submitLoading = true
|
baTable.form.submitLoading = true
|
||||||
|
const postItems: anyObj = { ...items }
|
||||||
|
const pid = Number(postItems.pid ?? 0)
|
||||||
|
if (pid !== 0) {
|
||||||
|
delete postItems.channel_id
|
||||||
|
delete postItems.channel_name
|
||||||
|
delete postItems.channel_admin_username
|
||||||
|
} else if (!adminInfo.super) {
|
||||||
|
delete postItems.channel_id
|
||||||
|
}
|
||||||
baTable.api
|
baTable.api
|
||||||
.postData(operate, {
|
.postData(operate, {
|
||||||
...items,
|
...postItems,
|
||||||
rules: formRef.value?.getCheckeds(),
|
rules: formRef.value?.getCheckeds(),
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -153,6 +168,10 @@ baTable.after.toggleForm = ({ operate }) => {
|
|||||||
|
|
||||||
// 编辑请求完成后钩子
|
// 编辑请求完成后钩子
|
||||||
baTable.after.getEditData = () => {
|
baTable.after.getEditData = () => {
|
||||||
|
const pid = Number(baTable.form.items?.pid ?? 0)
|
||||||
|
if (pid !== 0 && baTable.form.items) {
|
||||||
|
delete baTable.form.items.channel_id
|
||||||
|
}
|
||||||
menuRuleTreeUpdate()
|
menuRuleTreeUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,13 +198,6 @@ const menuRuleTreeUpdate = () => {
|
|||||||
|
|
||||||
provide('baTable', baTable)
|
provide('baTable', baTable)
|
||||||
|
|
||||||
function formatRatePercent(row: anyObj, _column: any, cellValue: number | string | null) {
|
|
||||||
if (cellValue === null || cellValue === undefined || cellValue === '') {
|
|
||||||
return '0%'
|
|
||||||
}
|
|
||||||
return `${cellValue}%`
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
baTable.table.ref = tableRef.value
|
baTable.table.ref = tableRef.value
|
||||||
baTable.mount()
|
baTable.mount()
|
||||||
|
|||||||
@@ -41,6 +41,42 @@
|
|||||||
valueOnClear: 0,
|
valueOnClear: 0,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
<p
|
||||||
|
v-if="!isRootGroup"
|
||||||
|
class="group-channel-inherit-hint"
|
||||||
|
:style="{ paddingLeft: (baTable.form.labelWidth ?? 120) + 'px' }"
|
||||||
|
>
|
||||||
|
{{ t('auth.group.channel_inherit_hint') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- 顶级+超管:可选渠道;展示只读渠道名称(channel_id 仅由表单传给后端) -->
|
||||||
|
<FormItem
|
||||||
|
v-if="isRootGroup && adminInfo.super"
|
||||||
|
:label="t('auth.group.channel_id')"
|
||||||
|
v-model="baTable.form.items!.channel_id"
|
||||||
|
type="remoteSelect"
|
||||||
|
prop="channel_id"
|
||||||
|
:input-attr="{
|
||||||
|
pk: 'id',
|
||||||
|
field: 'name',
|
||||||
|
remoteUrl: '/admin/channel/index',
|
||||||
|
placeholder: t('Click select'),
|
||||||
|
emptyValues: ['', null, undefined, 0],
|
||||||
|
valueOnClear: null,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<template v-if="isRootGroup && adminInfo.super && channelPreviewName">
|
||||||
|
<el-form-item :label="t('auth.group.channel_name')">
|
||||||
|
<el-input :model-value="channelPreviewName" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 子级:只读展示上级对应渠道名称,不提交 channel_id(由后端按父级写入) -->
|
||||||
|
<template v-if="!isRootGroup && channelPreviewName">
|
||||||
|
<el-form-item :label="t('auth.group.channel_name')">
|
||||||
|
<el-input :model-value="channelPreviewName" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
<el-form-item prop="name" :label="t('auth.group.Group name')">
|
<el-form-item prop="name" :label="t('auth.group.Group name')">
|
||||||
<el-input
|
<el-input
|
||||||
@@ -49,23 +85,6 @@
|
|||||||
:placeholder="t('Please input field', { field: t('auth.group.Group name') })"
|
:placeholder="t('Please input field', { field: t('auth.group.Group name') })"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<FormItem
|
|
||||||
:label="t('auth.group.commission_rate')"
|
|
||||||
v-model="baTable.form.items!.commission_rate"
|
|
||||||
type="number"
|
|
||||||
prop="commission_rate"
|
|
||||||
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100, disabled: shouldDisableCommissionRate() }"
|
|
||||||
:placeholder="t('Please input field', { field: t('auth.group.commission_rate') })"
|
|
||||||
/>
|
|
||||||
<el-alert class="commission-rate-alert" :title="t('auth.group.commission_rate_desc_title')" type="info" :closable="false" show-icon>
|
|
||||||
<template #default>
|
|
||||||
<ul class="commission-rate-desc-list">
|
|
||||||
<li>{{ t('auth.group.commission_rate_desc_1') }}</li>
|
|
||||||
<li>{{ t('auth.group.commission_rate_desc_2') }}</li>
|
|
||||||
<li>{{ t('auth.group.commission_rate_desc_3') }}</li>
|
|
||||||
</ul>
|
|
||||||
</template>
|
|
||||||
</el-alert>
|
|
||||||
<el-form-item prop="auth" :label="t('auth.group.jurisdiction')">
|
<el-form-item prop="auth" :label="t('auth.group.jurisdiction')">
|
||||||
<el-tree
|
<el-tree
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
@@ -103,7 +122,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, inject, useTemplateRef } from 'vue'
|
import { reactive, inject, useTemplateRef, computed, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
import FormItem from '/@/components/formItem/index.vue'
|
||||||
@@ -112,6 +131,7 @@ import { buildValidatorData } from '/@/utils/validate'
|
|||||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||||
|
import createAxios from '/@/utils/axios'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const adminInfo = useAdminInfo()
|
const adminInfo = useAdminInfo()
|
||||||
@@ -120,31 +140,98 @@ const treeRef = useTemplateRef('treeRef')
|
|||||||
const baTable = inject('baTable') as baTableClass
|
const baTable = inject('baTable') as baTableClass
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const shouldDisableCommissionRate = () => {
|
const isRootGroup = computed(() => {
|
||||||
return false
|
const p = baTable.form.items?.pid
|
||||||
|
if (p === undefined || p === null || p === '') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return Number(p) === 0
|
||||||
|
})
|
||||||
|
|
||||||
|
const strFromRow = (key: string): string => {
|
||||||
|
const row = baTable.form.items
|
||||||
|
if (!row) return ''
|
||||||
|
const v = row[key]
|
||||||
|
return typeof v === 'string' ? v : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const channelPreviewName = computed(() => strFromRow('channel_name'))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子角色组:选择上级分组后,只拉取展示用渠道名;channel_id 由后端按父级保存,不在此写入提交字段。
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => baTable.form.items?.pid,
|
||||||
|
async (pid, oldPid) => {
|
||||||
|
const items = baTable.form.items
|
||||||
|
if (!items || !baTable.form.operate || !['Add', 'Edit'].includes(baTable.form.operate)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const pidNum = Number(pid ?? 0)
|
||||||
|
const oldNum = oldPid === undefined || oldPid === null || oldPid === '' ? null : Number(oldPid)
|
||||||
|
|
||||||
|
if (pidNum === 0) {
|
||||||
|
if (adminInfo.super && oldNum !== null && oldNum !== 0) {
|
||||||
|
items.channel_id = null
|
||||||
|
items['channel_name'] = ''
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
delete items.channel_id
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/auth.Group/edit',
|
||||||
|
method: 'get',
|
||||||
|
params: { id: pidNum },
|
||||||
|
},
|
||||||
|
{ showErrorMessage: false, showCodeMessage: false }
|
||||||
|
)
|
||||||
|
const row = res.data.row
|
||||||
|
if (row) {
|
||||||
|
items['channel_name'] = typeof row.channel_name === 'string' ? row.channel_name : ''
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
items['channel_name'] = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/** 顶级+超管:所选渠道变更时刷新只读渠道名 */
|
||||||
|
watch(
|
||||||
|
() => baTable.form.items?.channel_id,
|
||||||
|
async (cid) => {
|
||||||
|
const items = baTable.form.items
|
||||||
|
if (!items || !baTable.form.operate || !['Add', 'Edit'].includes(baTable.form.operate)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!isRootGroup.value || !adminInfo.super) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (cid === null || cid === undefined || cid === '') {
|
||||||
|
items['channel_name'] = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/auth.Group/channelBindPreview',
|
||||||
|
method: 'get',
|
||||||
|
params: { channel_id: cid },
|
||||||
|
},
|
||||||
|
{ showErrorMessage: false, showCodeMessage: false }
|
||||||
|
)
|
||||||
|
items['channel_name'] = typeof res.data.channel_name === 'string' ? res.data.channel_name : ''
|
||||||
|
} catch {
|
||||||
|
items['channel_name'] = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||||
name: [buildValidatorData({ name: 'required', title: t('auth.group.Group name') })],
|
name: [buildValidatorData({ name: 'required', title: t('auth.group.Group name') })],
|
||||||
commission_rate: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
validator: (_rule: any, val: number | string, callback: Function) => {
|
|
||||||
if (shouldDisableCommissionRate()) {
|
|
||||||
return callback()
|
|
||||||
}
|
|
||||||
const strVal = String(val ?? '').trim()
|
|
||||||
if (!strVal) {
|
|
||||||
return callback(new Error(t('Please input field', { field: t('auth.group.commission_rate') })))
|
|
||||||
}
|
|
||||||
if (!/^(100(\.00?)?|[0-9]{1,2}(\.[0-9]{1,2})?)$/.test(strVal)) {
|
|
||||||
return callback(new Error(t('auth.admin.Commission rate must be between 0 and 100 with up to 2 decimals')))
|
|
||||||
}
|
|
||||||
return callback()
|
|
||||||
},
|
|
||||||
trigger: 'blur',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
auth: [
|
auth: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
@@ -194,14 +281,12 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.commission-rate-alert {
|
.group-channel-inherit-hint {
|
||||||
margin-bottom: 12px;
|
margin: -6px 0 14px;
|
||||||
}
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
.commission-rate-desc-list {
|
color: var(--el-text-color-secondary);
|
||||||
margin: 6px 0 0;
|
box-sizing: border-box;
|
||||||
padding-left: 18px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.penultimate-node) {
|
:deep(.penultimate-node) {
|
||||||
|
|||||||
@@ -44,6 +44,15 @@
|
|||||||
<el-form-item :label="t('channel.manual_settle_commission_amount')">
|
<el-form-item :label="t('channel.manual_settle_commission_amount')">
|
||||||
<el-input v-model="manualSettle.form.commission_amount" readonly />
|
<el-input v-model="manualSettle.form.commission_amount" readonly />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('channel.share_config')">
|
||||||
|
<el-table :data="manualSettle.form.commission_split" border size="small" class="w100">
|
||||||
|
<el-table-column prop="admin_username" :label="t('channel.admin__username')" min-width="100" />
|
||||||
|
<el-table-column prop="share_rate" :label="t('channel.share_rate_percent')" min-width="90">
|
||||||
|
<template #default="scope">{{ scope.row.share_rate }}%</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="commission_amount" :label="t('channel.manual_settle_commission_amount')" min-width="110" />
|
||||||
|
</el-table>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="t('channel.manual_settle_remark')">
|
<el-form-item :label="t('channel.manual_settle_remark')">
|
||||||
<el-input v-model="manualSettle.form.remark" type="textarea" :rows="2" />
|
<el-input v-model="manualSettle.form.remark" type="textarea" :rows="2" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -56,12 +65,59 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog class="ba-operate-dialog" :close-on-click-modal="false" :model-value="shareDialog.visible" @close="closeShareDialog">
|
||||||
|
<template #header>
|
||||||
|
<div class="title">{{ t('channel.share_config_title') }}</div>
|
||||||
|
</template>
|
||||||
|
<div v-loading="shareDialog.loading" class="manual-settle-dialog-body">
|
||||||
|
<el-alert type="info" :closable="false" show-icon class="mb-12">
|
||||||
|
{{ t('channel.share_config_tip') }}
|
||||||
|
</el-alert>
|
||||||
|
<el-table :data="shareDialog.list" border size="small">
|
||||||
|
<el-table-column :label="t('channel.admin_group_names')" min-width="260">
|
||||||
|
<template #default="scope">
|
||||||
|
<span v-if="scope.row.role_group_name" class="share-group-single">{{ scope.row.role_group_name }}</span>
|
||||||
|
<span v-else class="share-group-empty">-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="username" :label="t('channel.admin__username')" min-width="120" />
|
||||||
|
<el-table-column :label="t('channel.status')" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column :label="t('channel.share_rate_percent')" min-width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input-number
|
||||||
|
v-model="scope.row.share_rate"
|
||||||
|
:disabled="scope.row.status !== 1"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:step="0.01"
|
||||||
|
:precision="2"
|
||||||
|
class="w100"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="share-total-row">
|
||||||
|
<span>{{ t('channel.share_total_enabled') }}: </span>
|
||||||
|
<el-tag :type="shareEnabledTotal === '100.00' ? 'success' : 'danger'">{{ shareEnabledTotal }}%</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="closeShareDialog">{{ t('Cancel') }}</el-button>
|
||||||
|
<el-button type="primary" :loading="shareDialog.saving" @click="saveShareDialog">{{ t('Save') }}</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, provide, reactive, useTemplateRef } from 'vue'
|
import { computed, onMounted, provide, reactive, useTemplateRef } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import PopupForm from './popupForm.vue'
|
import PopupForm from './popupForm.vue'
|
||||||
import { baTableApi } from '/@/api/common'
|
import { baTableApi } from '/@/api/common'
|
||||||
import { auth } from '/@/utils/common'
|
import { auth } from '/@/utils/common'
|
||||||
@@ -78,6 +134,20 @@ defineOptions({
|
|||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const tableRef = useTemplateRef('tableRef')
|
const tableRef = useTemplateRef('tableRef')
|
||||||
let optButtons: OptButton[] = [
|
let optButtons: OptButton[] = [
|
||||||
|
{
|
||||||
|
render: 'tipButton',
|
||||||
|
name: 'shareConfig',
|
||||||
|
title: 'channel.share_config',
|
||||||
|
text: '',
|
||||||
|
type: 'primary',
|
||||||
|
icon: 'el-icon-Setting',
|
||||||
|
class: 'table-row-share-config',
|
||||||
|
disabledTip: false,
|
||||||
|
display: () => auth('edit'),
|
||||||
|
click: (row: TableRow) => {
|
||||||
|
void openShareDialog(row)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
render: 'tipButton',
|
render: 'tipButton',
|
||||||
name: 'manualSettle',
|
name: 'manualSettle',
|
||||||
@@ -94,12 +164,6 @@ let optButtons: OptButton[] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
optButtons = optButtons.concat(defaultOptButtons(['edit', 'delete']))
|
optButtons = optButtons.concat(defaultOptButtons(['edit', 'delete']))
|
||||||
const formatRatePercent = (_row: any, _column: any, cellValue: number | string | null) => {
|
|
||||||
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
|
||||||
const num = Number(cellValue)
|
|
||||||
if (Number.isNaN(num)) return '-'
|
|
||||||
return `${num.toFixed(2)}%`
|
|
||||||
}
|
|
||||||
const formatAmountInt = (_row: any, _column: any, cellValue: number | string | null) => {
|
const formatAmountInt = (_row: any, _column: any, cellValue: number | string | null) => {
|
||||||
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
||||||
const num = Number(cellValue)
|
const num = Number(cellValue)
|
||||||
@@ -131,10 +195,103 @@ const manualSettle = reactive({
|
|||||||
commission_rate: '',
|
commission_rate: '',
|
||||||
calc_base_amount: '',
|
calc_base_amount: '',
|
||||||
commission_amount: '',
|
commission_amount: '',
|
||||||
|
commission_split: [] as Array<{ admin_id: number; admin_username: string; share_rate: string; commission_amount: string }>,
|
||||||
remark: '',
|
remark: '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const shareDialog = reactive({
|
||||||
|
visible: false,
|
||||||
|
loading: false,
|
||||||
|
saving: false,
|
||||||
|
channelId: 0,
|
||||||
|
list: [] as Array<{ admin_id: number; username: string; role_group_name: string; role_level: number; status: number; share_rate: number | null }>,
|
||||||
|
})
|
||||||
|
|
||||||
|
const shareEnabledTotal = computed(() => {
|
||||||
|
let sum = 0
|
||||||
|
for (const row of shareDialog.list) {
|
||||||
|
if (row.status === 1) {
|
||||||
|
const n = Number(row.share_rate ?? 0)
|
||||||
|
if (Number.isFinite(n)) {
|
||||||
|
sum += n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum.toFixed(2)
|
||||||
|
})
|
||||||
|
|
||||||
|
const closeShareDialog = () => {
|
||||||
|
shareDialog.visible = false
|
||||||
|
shareDialog.channelId = 0
|
||||||
|
shareDialog.list = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const openShareDialog = async (row: TableRow) => {
|
||||||
|
shareDialog.channelId = Number(row.id || 0)
|
||||||
|
shareDialog.visible = true
|
||||||
|
shareDialog.loading = true
|
||||||
|
try {
|
||||||
|
const res = await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/channel/channelAdminShareList',
|
||||||
|
method: 'get',
|
||||||
|
params: { id: row.id },
|
||||||
|
},
|
||||||
|
{ showErrorMessage: true }
|
||||||
|
)
|
||||||
|
if (res.code !== 1 || !res.data) {
|
||||||
|
closeShareDialog()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const list = Array.isArray(res.data.list) ? res.data.list : []
|
||||||
|
shareDialog.list = list.map((item: anyObj) => {
|
||||||
|
const rate = item.share_rate
|
||||||
|
return {
|
||||||
|
admin_id: Number(item.admin_id || 0),
|
||||||
|
username: String(item.username || ''),
|
||||||
|
role_group_name: String(item.role_group_name || ''),
|
||||||
|
role_level: Number(item.role_level ?? 9999),
|
||||||
|
status: Number(item.status ?? 1) === 1 ? 1 : 0,
|
||||||
|
share_rate: rate === null || rate === undefined || rate === '' ? null : Number(rate),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
shareDialog.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveShareDialog = async () => {
|
||||||
|
if (!shareDialog.channelId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (shareEnabledTotal.value !== '100.00') {
|
||||||
|
ElMessage.error(t('channel.share_total_must_100'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
shareDialog.saving = true
|
||||||
|
try {
|
||||||
|
await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/channel/saveChannelAdminShare',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
id: shareDialog.channelId,
|
||||||
|
list: shareDialog.list.map((row) => ({
|
||||||
|
admin_id: row.admin_id,
|
||||||
|
status: row.status,
|
||||||
|
share_rate: Number(row.share_rate || 0).toFixed(2),
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ showSuccessMessage: true }
|
||||||
|
)
|
||||||
|
closeShareDialog()
|
||||||
|
} finally {
|
||||||
|
shareDialog.saving = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const resetManualSettleForm = () => {
|
const resetManualSettleForm = () => {
|
||||||
manualSettle.form.settlement_no = ''
|
manualSettle.form.settlement_no = ''
|
||||||
manualSettle.form.period_start_at = ''
|
manualSettle.form.period_start_at = ''
|
||||||
@@ -145,6 +302,7 @@ const resetManualSettleForm = () => {
|
|||||||
manualSettle.form.commission_rate = ''
|
manualSettle.form.commission_rate = ''
|
||||||
manualSettle.form.calc_base_amount = ''
|
manualSettle.form.calc_base_amount = ''
|
||||||
manualSettle.form.commission_amount = ''
|
manualSettle.form.commission_amount = ''
|
||||||
|
manualSettle.form.commission_split = []
|
||||||
manualSettle.form.remark = ''
|
manualSettle.form.remark = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +339,7 @@ const openManualSettleDialog = async (row: TableRow) => {
|
|||||||
manualSettle.form.commission_rate = d.commission_rate ?? ''
|
manualSettle.form.commission_rate = d.commission_rate ?? ''
|
||||||
manualSettle.form.calc_base_amount = d.calc_base_amount ?? ''
|
manualSettle.form.calc_base_amount = d.calc_base_amount ?? ''
|
||||||
manualSettle.form.commission_amount = d.commission_amount ?? ''
|
manualSettle.form.commission_amount = d.commission_amount ?? ''
|
||||||
|
manualSettle.form.commission_split = Array.isArray(d.commission_split) ? d.commission_split : []
|
||||||
manualSettle.form.remark = `${t('channel.manual_settle')}-CH${row.id}`
|
manualSettle.form.remark = `${t('channel.manual_settle')}-CH${row.id}`
|
||||||
} catch {
|
} catch {
|
||||||
manualSettle.visible = false
|
manualSettle.visible = false
|
||||||
@@ -251,33 +410,6 @@ const baTable = new baTableClass(
|
|||||||
affiliate: t('channel.agent_mode affiliate'),
|
affiliate: t('channel.agent_mode affiliate'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: t('channel.turnover_share_rate'),
|
|
||||||
prop: 'turnover_share_rate',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 110,
|
|
||||||
sortable: false,
|
|
||||||
operator: 'RANGE',
|
|
||||||
formatter: formatRatePercent,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('channel.affiliate_share_rate'),
|
|
||||||
prop: 'affiliate_share_rate',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 110,
|
|
||||||
sortable: false,
|
|
||||||
operator: 'RANGE',
|
|
||||||
formatter: formatRatePercent,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('channel.affiliate_fee_rate'),
|
|
||||||
prop: 'affiliate_fee_rate',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 140,
|
|
||||||
sortable: false,
|
|
||||||
operator: 'RANGE',
|
|
||||||
formatter: formatRatePercent,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: t('channel.carryover_balance'),
|
label: t('channel.carryover_balance'),
|
||||||
prop: 'carryover_balance',
|
prop: 'carryover_balance',
|
||||||
@@ -394,26 +526,6 @@ const baTable = new baTableClass(
|
|||||||
render: 'switch',
|
render: 'switch',
|
||||||
replaceValue: { '0': t('channel.status 0'), '1': t('channel.status 1') },
|
replaceValue: { '0': t('channel.status 0'), '1': t('channel.status 1') },
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: t('channel.admingroup__name'),
|
|
||||||
prop: 'adminGroup.name',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 110,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('channel.admin__username'),
|
|
||||||
prop: 'admin.username',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 90,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: t('channel.create_time'),
|
label: t('channel.create_time'),
|
||||||
prop: 'create_time',
|
prop: 'create_time',
|
||||||
@@ -464,4 +576,25 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.mb-12 {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-total-row {
|
||||||
|
margin-top: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-group-single {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: var(--el-text-color-regular);
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-group-empty {
|
||||||
|
color: var(--el-text-color-placeholder);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -172,21 +172,6 @@
|
|||||||
@keyup.ctrl.enter="baTable.onSubmit(formRef)"
|
@keyup.ctrl.enter="baTable.onSubmit(formRef)"
|
||||||
:placeholder="t('Please input field', { field: t('channel.remark') })"
|
:placeholder="t('Please input field', { field: t('channel.remark') })"
|
||||||
/>
|
/>
|
||||||
<el-alert type="info" :closable="false" show-icon class="channel-admin-tree-tip">
|
|
||||||
{{ t('channel.admin_tree_tip') }}
|
|
||||||
</el-alert>
|
|
||||||
<el-form-item :label="t('channel.admin_id')" prop="admin_id">
|
|
||||||
<el-tree-select
|
|
||||||
v-model="baTable.form.items!.admin_id"
|
|
||||||
class="w100"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
:data="channelAdminTree"
|
|
||||||
:props="channelAdminTreeProps"
|
|
||||||
:render-after-expand="false"
|
|
||||||
:placeholder="t('channel.admin_id_placeholder')"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
@@ -209,7 +194,6 @@ import { useI18n } from 'vue-i18n'
|
|||||||
import FormItem from '/@/components/formItem/index.vue'
|
import FormItem from '/@/components/formItem/index.vue'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
import createAxios from '/@/utils/axios'
|
|
||||||
import { buildValidatorData } from '/@/utils/validate'
|
import { buildValidatorData } from '/@/utils/validate'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
@@ -218,23 +202,6 @@ const baTable = inject('baTable') as baTableClass
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
type ChannelAdminTreeNode = {
|
|
||||||
value: string
|
|
||||||
label: string
|
|
||||||
disabled?: boolean
|
|
||||||
children?: ChannelAdminTreeNode[]
|
|
||||||
channel_id?: number
|
|
||||||
is_leaf?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const channelAdminTree = ref<ChannelAdminTreeNode[]>([])
|
|
||||||
const channelAdminTreeProps = {
|
|
||||||
value: 'value',
|
|
||||||
label: 'label',
|
|
||||||
children: 'children',
|
|
||||||
disabled: 'disabled',
|
|
||||||
}
|
|
||||||
|
|
||||||
type LadderRuleRow = { minLoss: number; shareRate: number }
|
type LadderRuleRow = { minLoss: number; shareRate: number }
|
||||||
const ladderRuleList = ref<LadderRuleRow[]>([])
|
const ladderRuleList = ref<LadderRuleRow[]>([])
|
||||||
|
|
||||||
@@ -317,14 +284,6 @@ const onSettlePlanChange = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadChannelAdminTree = async () => {
|
|
||||||
const res = await createAxios({
|
|
||||||
url: '/admin/channel/adminTree',
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
channelAdminTree.value = (res.data?.list ?? []) as ChannelAdminTreeNode[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentAgentMode = computed(() => baTable.form.items?.agent_mode ?? 'turnover')
|
const currentAgentMode = computed(() => baTable.form.items?.agent_mode ?? 'turnover')
|
||||||
const currentAgentModeDescList = computed(() => {
|
const currentAgentModeDescList = computed(() => {
|
||||||
if (currentAgentMode.value === 'turnover') {
|
if (currentAgentMode.value === 'turnover') {
|
||||||
@@ -390,19 +349,9 @@ const removeLadderRule = (idx: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadChannelAdminTree()
|
|
||||||
syncSettlePlanFromItems()
|
syncSettlePlanFromItems()
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
|
||||||
() => baTable.form.operate,
|
|
||||||
(op) => {
|
|
||||||
if (op === 'Add' || op === 'Edit') {
|
|
||||||
loadChannelAdminTree()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [baTable.form.operate, baTable.form.items?.id] as const,
|
() => [baTable.form.operate, baTable.form.items?.id] as const,
|
||||||
() => {
|
() => {
|
||||||
@@ -410,9 +359,6 @@ watch(
|
|||||||
if (!items || baTable.form.operate !== 'Edit') {
|
if (!items || baTable.form.operate !== 'Edit') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (items.admin_id !== undefined && items.admin_id !== null && items.admin_id !== '') {
|
|
||||||
items.admin_id = String(items.admin_id) as any
|
|
||||||
}
|
|
||||||
items.affiliate_ladder_rules = normalizeLadderRulesToText(items.affiliate_ladder_rules) as any
|
items.affiliate_ladder_rules = normalizeLadderRulesToText(items.affiliate_ladder_rules) as any
|
||||||
syncSettlePlanFromItems()
|
syncSettlePlanFromItems()
|
||||||
syncLadderRuleRowsFromItems()
|
syncLadderRuleRowsFromItems()
|
||||||
@@ -557,7 +503,6 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|||||||
settle_time: [buildValidatorData({ name: 'required', title: t('channel.settle_time') })],
|
settle_time: [buildValidatorData({ name: 'required', title: t('channel.settle_time') })],
|
||||||
affiliate_effective_start_at: [buildValidatorData({ name: 'required', title: t('channel.affiliate_effective_start_at') })],
|
affiliate_effective_start_at: [buildValidatorData({ name: 'required', title: t('channel.affiliate_effective_start_at') })],
|
||||||
carryover_balance: [buildValidatorData({ name: 'number', title: t('channel.carryover_balance') })],
|
carryover_balance: [buildValidatorData({ name: 'number', title: t('channel.carryover_balance') })],
|
||||||
admin_id: [buildValidatorData({ name: 'required', title: t('channel.admin_id') })],
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -571,8 +516,4 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|||||||
padding-left: 18px;
|
padding-left: 18px;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-admin-tree-tip {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
251
web/src/views/backend/config/depositTier/index.vue
Normal file
251
web/src/views/backend/config/depositTier/index.vue
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
<template>
|
||||||
|
<div class="default-main ba-table-box deposit-tier-page">
|
||||||
|
<el-alert type="info" :closable="false" show-icon>
|
||||||
|
{{ t('config.depositTier.desc') }}
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<div class="toolbar">
|
||||||
|
<el-button type="primary" :disabled="loading" @click="onAdd">
|
||||||
|
<Icon name="el-icon-Plus" />
|
||||||
|
<span class="ml-6">{{ t('config.depositTier.btn_add') }}</span>
|
||||||
|
</el-button>
|
||||||
|
<el-button type="success" :loading="saving" :disabled="loading" @click="onSave">
|
||||||
|
{{ t('config.depositTier.btn_save') }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" border stripe :data="items" row-key="_rowKey" max-height="720">
|
||||||
|
<el-table-column prop="sort" :label="t('config.depositTier.sort')" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input-number v-model="row.sort" :min="0" :max="9999" :controls="false" style="width: 100%" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.status')" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-switch v-model="row.status" :active-value="1" :inactive-value="0" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.title_col')" min-width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.title" maxlength="64" :placeholder="t('config.depositTier.title_ph')" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.title_en_col')" min-width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.title_en" maxlength="64" :placeholder="t('config.depositTier.title_en_ph')" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.amount')" min-width="140">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.amount" :placeholder="t('config.depositTier.amount_ph')">
|
||||||
|
<template #suffix>
|
||||||
|
<span class="currency">{{ t('config.depositTier.currency') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.bonus_amount')" min-width="140">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.bonus_amount" :placeholder="t('config.depositTier.bonus_ph')">
|
||||||
|
<template #suffix>
|
||||||
|
<span class="currency">{{ t('config.depositTier.currency') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.desc_col')" min-width="220">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.desc" maxlength="255" :autosize="{ minRows: 1, maxRows: 3 }" type="textarea" :placeholder="t('config.depositTier.desc_ph')" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.desc_en_col')" min-width="220">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.desc_en" maxlength="255" :autosize="{ minRows: 1, maxRows: 3 }" type="textarea" :placeholder="t('config.depositTier.desc_en_ph')" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.tier_id')" width="140">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-text class="tier-id" truncated>{{ row.id || t('config.depositTier.auto_id') }}</el-text>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column :label="t('config.depositTier.operate')" width="90" align="center" fixed="right">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
<el-button type="danger" link @click="onRemove($index)">
|
||||||
|
{{ t('config.depositTier.btn_remove') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import createAxios from '/@/utils/axios'
|
||||||
|
import { auth } from '/@/utils/common'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'config/depositTier',
|
||||||
|
})
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
type Tier = {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
title_en: string
|
||||||
|
amount: string
|
||||||
|
bonus_amount: string
|
||||||
|
desc: string
|
||||||
|
desc_en: string
|
||||||
|
sort: number
|
||||||
|
status: number
|
||||||
|
_rowKey?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const saving = ref(false)
|
||||||
|
const items = ref<Tier[]>([])
|
||||||
|
|
||||||
|
function genRowKey(): string {
|
||||||
|
return 'r_' + Math.random().toString(36).slice(2, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function emptyTier(): Tier {
|
||||||
|
return {
|
||||||
|
id: '',
|
||||||
|
title: '',
|
||||||
|
title_en: '',
|
||||||
|
amount: '',
|
||||||
|
bonus_amount: '0',
|
||||||
|
desc: '',
|
||||||
|
desc_en: '',
|
||||||
|
sort: 0,
|
||||||
|
status: 1,
|
||||||
|
_rowKey: genRowKey(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await createAxios({
|
||||||
|
url: '/admin/config.DepositTier/index',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
if (res.code === 1 && res.data) {
|
||||||
|
const list = (res.data.items || []) as Tier[]
|
||||||
|
items.value = (Array.isArray(list) ? list : []).map((it) => ({
|
||||||
|
...emptyTier(),
|
||||||
|
...it,
|
||||||
|
_rowKey: genRowKey(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAdd() {
|
||||||
|
items.value.push(emptyTier())
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onRemove(idx: number) {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(t('config.depositTier.confirm_remove'), t('Warning'), {
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonText: t('Delete'),
|
||||||
|
cancelButtonText: t('Cancel'),
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
items.value.splice(idx, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSave() {
|
||||||
|
if (!auth('save')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (let i = 0; i < items.value.length; i++) {
|
||||||
|
const row = items.value[i]
|
||||||
|
if (!row.title || !row.title.trim()) {
|
||||||
|
ElMessage.warning(t('config.depositTier.err_title', { no: i + 1 }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const amount = Number(row.amount)
|
||||||
|
if (!row.amount || Number.isNaN(amount) || amount <= 0) {
|
||||||
|
ElMessage.warning(t('config.depositTier.err_amount', { no: i + 1 }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const bonusRaw = row.bonus_amount === '' || row.bonus_amount === null || row.bonus_amount === undefined ? '0' : row.bonus_amount
|
||||||
|
const bonus = Number(bonusRaw)
|
||||||
|
if (Number.isNaN(bonus) || bonus < 0) {
|
||||||
|
ElMessage.warning(t('config.depositTier.err_bonus', { no: i + 1 }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
await createAxios({
|
||||||
|
url: '/admin/config.DepositTier/save',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
items: items.value.map((r) => ({
|
||||||
|
id: r.id,
|
||||||
|
title: r.title,
|
||||||
|
title_en: r.title_en || '',
|
||||||
|
amount: r.amount,
|
||||||
|
bonus_amount: r.bonus_amount === '' || r.bonus_amount === null || r.bonus_amount === undefined ? '0' : r.bonus_amount,
|
||||||
|
desc: r.desc || '',
|
||||||
|
desc_en: r.desc_en || '',
|
||||||
|
sort: r.sort,
|
||||||
|
status: r.status,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
showSuccessMessage: true,
|
||||||
|
})
|
||||||
|
await load()
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void load()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.deposit-tier-page {
|
||||||
|
.toolbar {
|
||||||
|
margin: 12px 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.currency {
|
||||||
|
color: var(--el-text-color-placeholder);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tier-id {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 120px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<div>{{ t('game.live.countdown') }}: {{ countdownText }}</div>
|
<div>{{ t('game.live.countdown') }}: {{ countdownText }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<el-input-number v-model="manualNumber" :min="1" :max="36" :step="1" />
|
<el-input-number v-model="manualNumber" :min="1" :max="snapshot.draw_number_max ?? 36" :step="1" />
|
||||||
<el-button :loading="calcLoading" :disabled="!snapshot.can_calculate" @click="onCalculate">
|
<el-button :loading="calcLoading" :disabled="!snapshot.can_calculate" @click="onCalculate">
|
||||||
{{ t('game.live.btn_calc') }}
|
{{ t('game.live.btn_calc') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
{{ formatPicks(scope.row.pick_numbers) }}
|
{{ formatPicks(scope.row.pick_numbers) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="unit_amount" :label="t('game.live.unit_amount')" width="120" />
|
<el-table-column prop="total_amount" :label="t('game.live.total_amount')" width="120" />
|
||||||
<el-table-column prop="streak_at_bet" :label="t('game.live.streak_at_bet')" width="90" />
|
<el-table-column prop="streak_at_bet" :label="t('game.live.streak_at_bet')" width="90" />
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
@@ -70,6 +70,8 @@ interface Snapshot {
|
|||||||
period_seconds?: number
|
period_seconds?: number
|
||||||
bet_seconds?: number
|
bet_seconds?: number
|
||||||
pick_max_number_count?: number
|
pick_max_number_count?: number
|
||||||
|
/** 开奖号码池上限(1–draw_number_max),与单注可选号码上限无关 */
|
||||||
|
draw_number_max?: number
|
||||||
remaining_seconds?: number
|
remaining_seconds?: number
|
||||||
bet_remaining_seconds?: number
|
bet_remaining_seconds?: number
|
||||||
can_calculate?: boolean
|
can_calculate?: boolean
|
||||||
@@ -87,7 +89,8 @@ const snapshot = reactive<Snapshot>({
|
|||||||
ai_default_number: null,
|
ai_default_number: null,
|
||||||
period_seconds: 30,
|
period_seconds: 30,
|
||||||
bet_seconds: 20,
|
bet_seconds: 20,
|
||||||
pick_max_number_count: 36,
|
pick_max_number_count: 10,
|
||||||
|
draw_number_max: 36,
|
||||||
remaining_seconds: 0,
|
remaining_seconds: 0,
|
||||||
bet_remaining_seconds: 0,
|
bet_remaining_seconds: 0,
|
||||||
can_calculate: false,
|
can_calculate: false,
|
||||||
@@ -121,12 +124,14 @@ async function loadSnapshot() {
|
|||||||
snapshot.ai_default_number = res.data.ai_default_number
|
snapshot.ai_default_number = res.data.ai_default_number
|
||||||
snapshot.period_seconds = res.data.period_seconds ?? 30
|
snapshot.period_seconds = res.data.period_seconds ?? 30
|
||||||
snapshot.bet_seconds = res.data.bet_seconds ?? 20
|
snapshot.bet_seconds = res.data.bet_seconds ?? 20
|
||||||
snapshot.pick_max_number_count = 36
|
snapshot.pick_max_number_count = res.data.pick_max_number_count ?? 10
|
||||||
|
snapshot.draw_number_max = res.data.draw_number_max ?? 36
|
||||||
snapshot.remaining_seconds = res.data.remaining_seconds ?? 0
|
snapshot.remaining_seconds = res.data.remaining_seconds ?? 0
|
||||||
snapshot.bet_remaining_seconds = res.data.bet_remaining_seconds ?? 0
|
snapshot.bet_remaining_seconds = res.data.bet_remaining_seconds ?? 0
|
||||||
snapshot.can_calculate = !!res.data.can_calculate
|
snapshot.can_calculate = !!res.data.can_calculate
|
||||||
snapshot.can_draw = !!res.data.can_draw
|
snapshot.can_draw = !!res.data.can_draw
|
||||||
if (manualNumber.value === null || manualNumber.value < 1 || manualNumber.value > 36) manualNumber.value = 1
|
const dmax = res.data.draw_number_max ?? 36
|
||||||
|
if (manualNumber.value === null || manualNumber.value < 1 || manualNumber.value > dmax) manualNumber.value = 1
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -169,7 +174,8 @@ async function initPush() {
|
|||||||
snapshot.ai_default_number = payload.ai_default_number ?? null
|
snapshot.ai_default_number = payload.ai_default_number ?? null
|
||||||
snapshot.period_seconds = payload.period_seconds ?? 30
|
snapshot.period_seconds = payload.period_seconds ?? 30
|
||||||
snapshot.bet_seconds = payload.bet_seconds ?? 20
|
snapshot.bet_seconds = payload.bet_seconds ?? 20
|
||||||
snapshot.pick_max_number_count = 36
|
snapshot.pick_max_number_count = payload.pick_max_number_count ?? 10
|
||||||
|
snapshot.draw_number_max = payload.draw_number_max ?? 36
|
||||||
snapshot.remaining_seconds = payload.remaining_seconds ?? 0
|
snapshot.remaining_seconds = payload.remaining_seconds ?? 0
|
||||||
snapshot.bet_remaining_seconds = payload.bet_remaining_seconds ?? 0
|
snapshot.bet_remaining_seconds = payload.bet_remaining_seconds ?? 0
|
||||||
snapshot.can_calculate = !!payload.can_calculate
|
snapshot.can_calculate = !!payload.can_calculate
|
||||||
|
|||||||
@@ -1,303 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="default-main ba-table-box">
|
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
|
||||||
|
|
||||||
<el-card v-if="canSettings" class="period-settings-card" shadow="never">
|
|
||||||
<template #header>
|
|
||||||
<span>{{ t('game.period.section_auto') }}</span>
|
|
||||||
</template>
|
|
||||||
<div v-loading="settingsLoading" class="period-settings-body">
|
|
||||||
<div class="period-setting-row">
|
|
||||||
<span class="period-setting-label">{{ t('game.period.auto_create_label') }}</span>
|
|
||||||
<el-switch v-model="autoCreate" :disabled="settingsSaving" @change="onSwitchChange" />
|
|
||||||
<span class="period-setting-tip">{{ t('game.period.auto_create_tip') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="period-setting-row">
|
|
||||||
<span class="period-setting-label">{{ t('game.period.manual_create_label') }}</span>
|
|
||||||
<el-switch v-model="manualCreate" :disabled="settingsSaving" @change="onSwitchChange" />
|
|
||||||
<span class="period-setting-tip">{{ t('game.period.manual_create_tip') }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="canManual" class="period-setting-actions">
|
|
||||||
<el-button type="primary" :loading="createLoading" @click="onCreateNextManual">
|
|
||||||
{{ t('game.period.btn_create_next') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<TableHeader
|
|
||||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('game.period.quick Search Fields') })"
|
|
||||||
></TableHeader>
|
|
||||||
|
|
||||||
<Table ref="tableRef"></Table>
|
|
||||||
|
|
||||||
<PopupForm />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onMounted, provide, ref, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import PopupForm from './popupForm.vue'
|
|
||||||
import { baTableApi } from '/@/api/common'
|
|
||||||
import { defaultOptButtons } from '/@/components/table'
|
|
||||||
import TableHeader from '/@/components/table/header/index.vue'
|
|
||||||
import Table from '/@/components/table/index.vue'
|
|
||||||
import createAxios from '/@/utils/axios'
|
|
||||||
import baTableClass from '/@/utils/baTable'
|
|
||||||
import { auth } from '/@/utils/common'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: 'game/period',
|
|
||||||
})
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const tableRef = useTemplateRef('tableRef')
|
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
|
||||||
|
|
||||||
const settingsLoading = ref(false)
|
|
||||||
const settingsSaving = ref(false)
|
|
||||||
const createLoading = ref(false)
|
|
||||||
const autoCreate = ref(false)
|
|
||||||
const manualCreate = ref(false)
|
|
||||||
/** 避免初次拉取开关值时触发保存 */
|
|
||||||
const settingsReady = ref(false)
|
|
||||||
|
|
||||||
const canSettings = computed(() => auth('periodSettings'))
|
|
||||||
const canManual = computed(() => auth('createNextManual'))
|
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
|
||||||
new baTableApi('/admin/game.Period/'),
|
|
||||||
{
|
|
||||||
pk: 'id',
|
|
||||||
column: [
|
|
||||||
{ type: 'selection', align: 'center', operator: false },
|
|
||||||
{ label: t('game.period.id'), prop: 'id', align: 'center', width: 100, operator: 'RANGE', sortable: 'custom' },
|
|
||||||
{
|
|
||||||
label: t('game.period.period_no'),
|
|
||||||
prop: 'period_no',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 180,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
operator: 'LIKE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.period_start_at'),
|
|
||||||
prop: 'period_start_at',
|
|
||||||
align: 'center',
|
|
||||||
width: 170,
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.status'),
|
|
||||||
prop: 'status',
|
|
||||||
align: 'center',
|
|
||||||
width: 110,
|
|
||||||
operator: 'eq',
|
|
||||||
render: 'tag',
|
|
||||||
effect: 'dark',
|
|
||||||
custom: {
|
|
||||||
'0': 'success',
|
|
||||||
'1': 'warning',
|
|
||||||
'2': 'info',
|
|
||||||
'3': 'primary',
|
|
||||||
'4': 'warning',
|
|
||||||
'5': 'danger',
|
|
||||||
},
|
|
||||||
replaceValue: {
|
|
||||||
'0': t('game.period.status 0'),
|
|
||||||
'1': t('game.period.status 1'),
|
|
||||||
'2': t('game.period.status 2'),
|
|
||||||
'3': t('game.period.status 3'),
|
|
||||||
'4': t('game.period.status 4'),
|
|
||||||
'5': t('game.period.status 5'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.draw_mode'),
|
|
||||||
prop: 'draw_mode',
|
|
||||||
align: 'center',
|
|
||||||
width: 110,
|
|
||||||
operator: 'eq',
|
|
||||||
render: 'tag',
|
|
||||||
custom: {
|
|
||||||
'0': 'info',
|
|
||||||
'1': 'warning',
|
|
||||||
},
|
|
||||||
replaceValue: {
|
|
||||||
'0': t('game.period.draw_mode 0'),
|
|
||||||
'1': t('game.period.draw_mode 1'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.preset_number'),
|
|
||||||
prop: 'preset_number',
|
|
||||||
align: 'center',
|
|
||||||
width: 100,
|
|
||||||
operator: 'RANGE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.result_number'),
|
|
||||||
prop: 'result_number',
|
|
||||||
align: 'center',
|
|
||||||
width: 100,
|
|
||||||
operator: 'RANGE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.void_reason'),
|
|
||||||
prop: 'void_reason',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 140,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
operator: 'LIKE',
|
|
||||||
showOverflowTooltip: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.create_time'),
|
|
||||||
prop: 'create_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 170,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.period.update_time'),
|
|
||||||
prop: 'update_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 170,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{ label: t('Operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
|
||||||
],
|
|
||||||
dblClickNotEditColumn: [undefined],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
defaultItems: {
|
|
||||||
status: 0,
|
|
||||||
draw_mode: 0,
|
|
||||||
void_reason: '',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
provide('baTable', baTable)
|
|
||||||
|
|
||||||
async function loadPeriodSettings() {
|
|
||||||
if (!canSettings.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
settingsLoading.value = true
|
|
||||||
try {
|
|
||||||
const res = await createAxios({
|
|
||||||
url: '/admin/game.Period/periodSettings',
|
|
||||||
method: 'get',
|
|
||||||
showCodeMessage: false,
|
|
||||||
})
|
|
||||||
if (res.code === 1 && res.data) {
|
|
||||||
autoCreate.value = res.data.period_auto_create_enabled === 1
|
|
||||||
manualCreate.value = res.data.period_manual_create_enabled === 1
|
|
||||||
settingsReady.value = true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// 无权限或接口异常时不打断列表
|
|
||||||
} finally {
|
|
||||||
settingsLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onSaveSettings() {
|
|
||||||
if (!canSettings.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
settingsSaving.value = true
|
|
||||||
try {
|
|
||||||
await createAxios({
|
|
||||||
url: '/admin/game.Period/periodSettings',
|
|
||||||
method: 'post',
|
|
||||||
data: {
|
|
||||||
period_auto_create_enabled: autoCreate.value ? 1 : 0,
|
|
||||||
period_manual_create_enabled: manualCreate.value ? 1 : 0,
|
|
||||||
},
|
|
||||||
showSuccessMessage: true,
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
settingsSaving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSwitchChange() {
|
|
||||||
if (!settingsReady.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
void onSaveSettings()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onCreateNextManual() {
|
|
||||||
if (!canManual.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
createLoading.value = true
|
|
||||||
try {
|
|
||||||
await createAxios({
|
|
||||||
url: '/admin/game.Period/createNextManual',
|
|
||||||
method: 'post',
|
|
||||||
showSuccessMessage: true,
|
|
||||||
})
|
|
||||||
await baTable.getData()
|
|
||||||
} finally {
|
|
||||||
createLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
baTable.table.ref = tableRef.value
|
|
||||||
baTable.mount()
|
|
||||||
void loadPeriodSettings()
|
|
||||||
baTable.getData()?.then(() => {
|
|
||||||
baTable.initSort()
|
|
||||||
baTable.dragSort()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.period-settings-card {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.period-settings-body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.period-setting-row {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.period-setting-label {
|
|
||||||
min-width: 160px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.period-setting-tip {
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
.period-setting-actions {
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
class="ba-operate-dialog"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
|
||||||
@close="baTable.toggleForm"
|
|
||||||
>
|
|
||||||
<template #header>
|
|
||||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
|
||||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
|
||||||
<div
|
|
||||||
class="ba-operate-form"
|
|
||||||
:class="'ba-' + baTable.form.operate + '-form'"
|
|
||||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
v-if="!baTable.form.loading"
|
|
||||||
ref="formRef"
|
|
||||||
@submit.prevent=""
|
|
||||||
@keyup.enter="baTable.onSubmit(formRef)"
|
|
||||||
:model="baTable.form.items"
|
|
||||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
|
||||||
:label-width="baTable.form.labelWidth + 'px'"
|
|
||||||
:rules="rules"
|
|
||||||
>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.period_no')"
|
|
||||||
type="string"
|
|
||||||
v-model="baTable.form.items!.period_no"
|
|
||||||
prop="period_no"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.period.period_no') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.period_start_at')"
|
|
||||||
type="datetime"
|
|
||||||
v-model="baTable.form.items!.period_start_at"
|
|
||||||
prop="period_start_at"
|
|
||||||
:placeholder="t('Please select field', { field: t('game.period.period_start_at') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.status')"
|
|
||||||
type="radio"
|
|
||||||
v-model="baTable.form.items!.status"
|
|
||||||
prop="status"
|
|
||||||
:input-attr="{
|
|
||||||
content: {
|
|
||||||
'0': t('game.period.status 0'),
|
|
||||||
'1': t('game.period.status 1'),
|
|
||||||
'2': t('game.period.status 2'),
|
|
||||||
'3': t('game.period.status 3'),
|
|
||||||
'4': t('game.period.status 4'),
|
|
||||||
'5': t('game.period.status 5'),
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.draw_mode')"
|
|
||||||
type="radio"
|
|
||||||
v-model="baTable.form.items!.draw_mode"
|
|
||||||
prop="draw_mode"
|
|
||||||
:input-attr="{
|
|
||||||
content: {
|
|
||||||
'0': t('game.period.draw_mode 0'),
|
|
||||||
'1': t('game.period.draw_mode 1'),
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.preset_number')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.preset_number"
|
|
||||||
prop="preset_number"
|
|
||||||
:input-attr="{ step: 1, min: 1, max: 36 }"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.result_number')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.result_number"
|
|
||||||
prop="result_number"
|
|
||||||
:input-attr="{ step: 1, min: 1, max: 36 }"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.period.void_reason')"
|
|
||||||
type="textarea"
|
|
||||||
v-model="baTable.form.items!.void_reason"
|
|
||||||
prop="void_reason"
|
|
||||||
:input-attr="{ rows: 3 }"
|
|
||||||
/>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
<template #footer>
|
|
||||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
|
||||||
<el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
|
|
||||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
|
||||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { FormItemRule } from 'element-plus'
|
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
|
||||||
import { useConfig } from '/@/stores/config'
|
|
||||||
import type baTableClass from '/@/utils/baTable'
|
|
||||||
|
|
||||||
const config = useConfig()
|
|
||||||
const formRef = useTemplateRef('formRef')
|
|
||||||
const baTable = inject('baTable') as baTableClass
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|
||||||
period_no: [buildRequired()],
|
|
||||||
})
|
|
||||||
|
|
||||||
function buildRequired(): FormItemRule {
|
|
||||||
return {
|
|
||||||
required: true,
|
|
||||||
message: t('Please input field', { field: t('game.period.period_no') }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
|
||||||
@@ -31,6 +31,13 @@ const { t } = useI18n()
|
|||||||
const tableRef = useTemplateRef('tableRef')
|
const tableRef = useTemplateRef('tableRef')
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit'])
|
const optButtons: OptButton[] = defaultOptButtons(['edit'])
|
||||||
|
|
||||||
|
const formatCoin = (_row: any, _column: any, cellValue: number | string | null | undefined) => {
|
||||||
|
if (cellValue === null || cellValue === undefined || cellValue === '') return '—'
|
||||||
|
const n = Number(cellValue)
|
||||||
|
if (Number.isNaN(n)) return '—'
|
||||||
|
return n.toFixed(4)
|
||||||
|
}
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/game.Record/'),
|
new baTableApi('/admin/game.Record/'),
|
||||||
{
|
{
|
||||||
@@ -63,6 +70,23 @@ const baTable = new baTableClass(
|
|||||||
},
|
},
|
||||||
{ label: t('game.record.preset_number'), prop: 'preset_number', align: 'center', width: 100, operator: 'RANGE' },
|
{ label: t('game.record.preset_number'), prop: 'preset_number', align: 'center', width: 100, operator: 'RANGE' },
|
||||||
{ label: t('game.record.result_number'), prop: 'result_number', align: 'center', width: 100, operator: 'RANGE' },
|
{ label: t('game.record.result_number'), prop: 'result_number', align: 'center', width: 100, operator: 'RANGE' },
|
||||||
|
{
|
||||||
|
label: t('game.record.platform_profit_amount'),
|
||||||
|
prop: 'platform_profit_amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 130,
|
||||||
|
operator: 'RANGE',
|
||||||
|
sortable: false,
|
||||||
|
formatter: formatCoin,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('game.record.winner_user_count'),
|
||||||
|
prop: 'winner_user_count',
|
||||||
|
align: 'center',
|
||||||
|
width: 110,
|
||||||
|
operator: 'RANGE',
|
||||||
|
sortable: false,
|
||||||
|
},
|
||||||
{ label: t('game.record.void_reason'), prop: 'void_reason', align: 'center', minWidth: 140, operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', showOverflowTooltip: true },
|
{ label: t('game.record.void_reason'), prop: 'void_reason', align: 'center', minWidth: 140, operatorPlaceholder: t('Fuzzy query'), operator: 'LIKE', showOverflowTooltip: true },
|
||||||
{ label: t('game.record.create_time'), prop: 'create_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
{ label: t('game.record.create_time'), prop: 'create_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
||||||
{ label: t('game.record.update_time'), prop: 'update_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
{ label: t('game.record.update_time'), prop: 'update_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
/>
|
/>
|
||||||
<FormItem :label="t('game.record.preset_number')" type="number" v-model="baTable.form.items!.preset_number" prop="preset_number" :input-attr="{ step: 1, min: 1, max: 36 }" />
|
<FormItem :label="t('game.record.preset_number')" type="number" v-model="baTable.form.items!.preset_number" prop="preset_number" :input-attr="{ step: 1, min: 1, max: 36 }" />
|
||||||
<FormItem :label="t('game.record.result_number')" type="number" v-model="baTable.form.items!.result_number" prop="result_number" :input-attr="{ step: 1, min: 1, max: 36 }" />
|
<FormItem :label="t('game.record.result_number')" type="number" v-model="baTable.form.items!.result_number" prop="result_number" :input-attr="{ step: 1, min: 1, max: 36 }" />
|
||||||
|
<FormItem :label="t('game.record.platform_profit_amount')" type="string" v-model="baTable.form.items!.platform_profit_amount" prop="platform_profit_amount" />
|
||||||
|
<FormItem :label="t('game.record.winner_user_count')" type="number" v-model="baTable.form.items!.winner_user_count" prop="winner_user_count" :input-attr="{ step: 1, min: 0 }" />
|
||||||
<FormItem :label="t('game.record.void_reason')" type="textarea" v-model="baTable.form.items!.void_reason" prop="void_reason" :input-attr="{ rows: 3 }" />
|
<FormItem :label="t('game.record.void_reason')" type="textarea" v-model="baTable.form.items!.void_reason" prop="void_reason" :input-attr="{ rows: 3 }" />
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -66,9 +66,8 @@ const baTable = new baTableClass(
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
width: 100,
|
width: 100,
|
||||||
operator: 'eq',
|
operator: 'eq',
|
||||||
render: 'tag',
|
sortable: false,
|
||||||
effect: 'dark',
|
render: 'switch',
|
||||||
custom: { 0: 'info', 1: 'success' },
|
|
||||||
replaceValue: {
|
replaceValue: {
|
||||||
'0': t('operation.operationNotice.status 0'),
|
'0': t('operation.operationNotice.status 0'),
|
||||||
'1': t('operation.operationNotice.status 1'),
|
'1': t('operation.operationNotice.status 1'),
|
||||||
@@ -109,6 +108,7 @@ const baTable = new baTableClass(
|
|||||||
},
|
},
|
||||||
{ label: t('Operate'), align: 'center', minWidth: 80, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
{ label: t('Operate'), align: 'center', minWidth: 80, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
||||||
],
|
],
|
||||||
|
dblClickNotEditColumn: [undefined, 'status'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
defaultItems: { status: 0, notice_type: 0 },
|
defaultItems: { status: 0, notice_type: 0 },
|
||||||
|
|||||||
@@ -58,23 +58,30 @@ const baTable = new baTableClass(
|
|||||||
pk: 'id',
|
pk: 'id',
|
||||||
column: [
|
column: [
|
||||||
{ label: t('order.betOrder.id'), prop: 'id', align: 'center', width: 100, operator: 'RANGE', sortable: 'custom' },
|
{ label: t('order.betOrder.id'), prop: 'id', align: 'center', width: 100, operator: 'RANGE', sortable: 'custom' },
|
||||||
{ label: t('order.betOrder.period_id'), prop: 'period_id', align: 'center', width: 100, operator: 'RANGE' },
|
|
||||||
{
|
{
|
||||||
label: t('order.betOrder.period_no'),
|
label: t('order.betOrder.period_id'),
|
||||||
prop: 'period_no',
|
prop: 'period_id',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 160,
|
show: false,
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
width: 100,
|
||||||
operator: 'LIKE',
|
operator: 'RANGE',
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// label: t('order.betOrder.period_no'),
|
||||||
|
// prop: 'period_no',
|
||||||
|
// align: 'center',
|
||||||
|
// minWidth: 160,
|
||||||
|
// operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
// operator: 'LIKE',
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
label: t('order.betOrder.gameRecord_period_no'),
|
label: t('order.betOrder.gameRecord_period_no'),
|
||||||
prop: 'gameRecord.period_no',
|
prop: 'gameRecord.period_no',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 160,
|
minWidth: 200,
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
render: 'tags',
|
render: 'tag',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('order.betOrder.gameRecord_status'),
|
label: t('order.betOrder.gameRecord_status'),
|
||||||
@@ -135,15 +142,6 @@ const baTable = new baTableClass(
|
|||||||
operator: false,
|
operator: false,
|
||||||
formatter: formatPickNumbers,
|
formatter: formatPickNumbers,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: t('order.betOrder.unit_amount'),
|
|
||||||
prop: 'unit_amount',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 110,
|
|
||||||
operator: 'RANGE',
|
|
||||||
formatter: formatAmount,
|
|
||||||
},
|
|
||||||
{ label: t('order.betOrder.pick_count'), prop: 'pick_count', align: 'center', width: 90, operator: 'RANGE' },
|
|
||||||
{
|
{
|
||||||
label: t('order.betOrder.total_amount'),
|
label: t('order.betOrder.total_amount'),
|
||||||
prop: 'total_amount',
|
prop: 'total_amount',
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main ba-table-box">
|
<div class="default-main ba-table-box">
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||||
|
|
||||||
<TableHeader
|
<TableHeader
|
||||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
:buttons="['refresh', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('order.depositOrder.quick Search Fields') })"
|
:quick-search-placeholder="t('Quick search placeholder', { fields: t('order.depositOrder.quick Search Fields') })"
|
||||||
></TableHeader>
|
></TableHeader>
|
||||||
|
|
||||||
@@ -29,7 +29,19 @@ defineOptions({
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const tableRef = useTemplateRef('tableRef')
|
const tableRef = useTemplateRef('tableRef')
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
const optButtons: OptButton[] = defaultOptButtons(['edit'])
|
||||||
|
|
||||||
|
function formatAmount(_row: anyObj, _column: any, cellValue: unknown) {
|
||||||
|
if (cellValue === null || cellValue === undefined || cellValue === '') {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
const s = String(cellValue).trim().replace(',', '.')
|
||||||
|
const n = parseFloat(s)
|
||||||
|
if (!Number.isFinite(n)) {
|
||||||
|
return String(cellValue)
|
||||||
|
}
|
||||||
|
return n.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/order.DepositOrder/'),
|
new baTableApi('/admin/order.DepositOrder/'),
|
||||||
@@ -46,12 +58,11 @@ const baTable = new baTableClass(
|
|||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
},
|
},
|
||||||
{ label: t('order.depositOrder.user_id'), prop: 'user_id', align: 'center', width: 90, operator: 'RANGE' },
|
|
||||||
{
|
{
|
||||||
label: t('order.depositOrder.user_username'),
|
label: t('order.depositOrder.user_username'),
|
||||||
prop: 'user.username',
|
prop: 'user.username',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 120,
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
render: 'tags',
|
render: 'tags',
|
||||||
@@ -65,7 +76,22 @@ const baTable = new baTableClass(
|
|||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
render: 'tags',
|
render: 'tags',
|
||||||
},
|
},
|
||||||
{ label: t('order.depositOrder.amount'), prop: 'amount', align: 'center', minWidth: 110, operator: 'RANGE' },
|
{
|
||||||
|
label: t('order.depositOrder.amount'),
|
||||||
|
prop: 'amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmount,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.depositOrder.bonus_amount'),
|
||||||
|
prop: 'bonus_amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmount,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('order.depositOrder.status'),
|
label: t('order.depositOrder.status'),
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
@@ -76,9 +102,9 @@ const baTable = new baTableClass(
|
|||||||
effect: 'dark',
|
effect: 'dark',
|
||||||
custom: {
|
custom: {
|
||||||
'0': 'info',
|
'0': 'info',
|
||||||
'1': 'warning',
|
'1': 'success',
|
||||||
'2': 'success',
|
'2': 'danger',
|
||||||
'3': 'danger',
|
'3': 'warning',
|
||||||
},
|
},
|
||||||
replaceValue: {
|
replaceValue: {
|
||||||
'0': t('order.depositOrder.status 0'),
|
'0': t('order.depositOrder.status 0'),
|
||||||
@@ -91,10 +117,19 @@ const baTable = new baTableClass(
|
|||||||
label: t('order.depositOrder.pay_channel'),
|
label: t('order.depositOrder.pay_channel'),
|
||||||
prop: 'pay_channel',
|
prop: 'pay_channel',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 130,
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: t('order.depositOrder.deposit_tier_id'),
|
||||||
|
prop: 'deposit_tier_id',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('order.depositOrder.pay_time'),
|
label: t('order.depositOrder.pay_time'),
|
||||||
prop: 'pay_time',
|
prop: 'pay_time',
|
||||||
@@ -106,6 +141,16 @@ const baTable = new baTableClass(
|
|||||||
width: 170,
|
width: 170,
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: t('order.depositOrder.idempotency_key'),
|
||||||
|
prop: 'idempotency_key',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 170,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
showOverflowTooltip: true,
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('order.depositOrder.remark'),
|
label: t('order.depositOrder.remark'),
|
||||||
prop: 'remark',
|
prop: 'remark',
|
||||||
@@ -136,6 +181,7 @@ const baTable = new baTableClass(
|
|||||||
sortable: 'custom',
|
sortable: 'custom',
|
||||||
width: 170,
|
width: 170,
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||||
|
show: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('Operate'),
|
label: t('Operate'),
|
||||||
@@ -149,7 +195,7 @@ const baTable = new baTableClass(
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
defaultItems: { status: 0, amount: '0.0000' },
|
defaultItems: { status: 0, amount: '0.0000', bonus_amount: '0.0000' },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,231 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog class="ba-operate-dialog" :close-on-click-modal="false" :model-value="['Add', 'Edit'].includes(baTable.form.operate!)" @close="baTable.toggleForm">
|
<el-dialog
|
||||||
|
class="ba-operate-dialog deposit-detail-dialog"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:model-value="isOpen"
|
||||||
|
width="640px"
|
||||||
|
@close="onDialogClose"
|
||||||
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">{{ baTable.form.operate ? t(baTable.form.operate) : '' }}</div>
|
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
||||||
|
{{ t('order.depositOrder.detail_title') }}
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
|
||||||
<div class="ba-operate-form" :class="'ba-' + baTable.form.operate + '-form'" :style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'">
|
<el-scrollbar v-loading="loading" class="ba-table-form-scrollbar">
|
||||||
<el-form v-if="!baTable.form.loading" ref="formRef" @submit.prevent="" @keyup.enter="baTable.onSubmit(formRef)" :model="baTable.form.items" :label-position="config.layout.shrink ? 'top' : 'right'" :label-width="baTable.form.labelWidth + 'px'" :rules="rules">
|
<div
|
||||||
<FormItem :label="t('order.depositOrder.order_no')" type="string" v-model="baTable.form.items!.order_no" prop="order_no" />
|
class="ba-operate-form ba-edit-form"
|
||||||
<FormItem :label="t('order.depositOrder.user_id')" type="number" v-model="baTable.form.items!.user_id" prop="user_id" :input-attr="{ min: 1, step: 1 }" />
|
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + (baTable.form.labelWidth ?? 120) / 2 + 'px)'"
|
||||||
<FormItem :label="t('order.depositOrder.channel_id')" type="number" v-model="baTable.form.items!.channel_id" prop="channel_id" :input-attr="{ min: 1, step: 1 }" />
|
>
|
||||||
<FormItem :label="t('order.depositOrder.amount')" type="number" v-model="baTable.form.items!.amount" prop="amount" :input-attr="{ step: 0.0001, precision: 4, min: 0 }" />
|
<el-form
|
||||||
<FormItem :label="t('order.depositOrder.status')" type="radio" v-model="baTable.form.items!.status" prop="status" :input-attr="{ content: { '0': t('order.depositOrder.status 0'), '1': t('order.depositOrder.status 1'), '2': t('order.depositOrder.status 2'), '3': t('order.depositOrder.status 3') } }" />
|
v-if="!loading"
|
||||||
<FormItem :label="t('order.depositOrder.pay_channel')" type="string" v-model="baTable.form.items!.pay_channel" prop="pay_channel" />
|
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||||
<FormItem :label="t('order.depositOrder.pay_time')" type="datetime" v-model="baTable.form.items!.pay_time" prop="pay_time" />
|
:label-width="(baTable.form.labelWidth ?? 120) + 'px'"
|
||||||
<FormItem :label="t('order.depositOrder.remark')" type="textarea" v-model="baTable.form.items!.remark" prop="remark" :input-attr="{ rows: 2 }" />
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-form-item :label="t('order.depositOrder.order_no')">
|
||||||
|
<el-input :model-value="form.order_no" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.idempotency_key')">
|
||||||
|
<el-input :model-value="form.idempotency_key || '-'" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.user_username')">
|
||||||
|
<el-input :model-value="form.user_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.channel_name')">
|
||||||
|
<el-input :model-value="form.channel_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.status')">
|
||||||
|
<el-tag :type="statusTagType" effect="dark" size="small">{{ statusLabel }}</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label="t('order.depositOrder.amount')">
|
||||||
|
<el-input :model-value="amountText" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.bonus_amount')">
|
||||||
|
<el-input :model-value="bonusText" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.total_credit')">
|
||||||
|
<el-input :model-value="totalCreditText" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label="t('order.depositOrder.pay_channel')">
|
||||||
|
<el-input :model-value="form.pay_channel || '-'" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.pay_time')">
|
||||||
|
<el-input :model-value="form.pay_time_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.deposit_tier_id')">
|
||||||
|
<el-input :model-value="form.deposit_tier_id || '-'" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.remark')">
|
||||||
|
<el-input v-model="form.remark" type="textarea" :rows="2" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.depositOrder.create_time')">
|
||||||
|
<el-input :model-value="form.create_time_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
<div class="detail-footer">
|
||||||
<el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
|
<el-button type="primary" v-blur @click="onDialogClose">{{ t('order.depositOrder.close_btn') }}</el-button>
|
||||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormItemRule } from 'element-plus'
|
import { computed, inject, reactive, ref, watch } from 'vue'
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const formRef = useTemplateRef('formRef')
|
|
||||||
const baTable = inject('baTable') as baTableClass
|
const baTable = inject('baTable') as baTableClass
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
const loading = ref(false)
|
||||||
order_no: [{ required: true, message: t('Please input field', { field: t('order.depositOrder.order_no') }) }],
|
|
||||||
user_id: [{ required: true, message: t('Please input field', { field: t('order.depositOrder.user_id') }) }],
|
const form = reactive({
|
||||||
|
id: 0,
|
||||||
|
order_no: '',
|
||||||
|
idempotency_key: '',
|
||||||
|
user_text: '-',
|
||||||
|
channel_text: '-',
|
||||||
|
pay_channel: '',
|
||||||
|
pay_time_text: '-',
|
||||||
|
deposit_tier_id: '',
|
||||||
|
remark: '',
|
||||||
|
create_time_text: '-',
|
||||||
|
amount: 0,
|
||||||
|
bonus_amount: 0,
|
||||||
|
status: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isOpen = computed(() => ['Edit'].includes(baTable.form.operate ?? ''))
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => ({ visible: isOpen.value, loadingState: baTable.form.loading, items: baTable.form.items }),
|
||||||
|
({ visible, loadingState }) => {
|
||||||
|
if (!visible) return
|
||||||
|
loading.value = loadingState === true
|
||||||
|
if (loadingState) return
|
||||||
|
hydrate()
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const hydrate = () => {
|
||||||
|
const row = baTable.form.items as Record<string, unknown> | undefined
|
||||||
|
if (!row || !row['id']) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.id = Number(row['id'] ?? 0)
|
||||||
|
form.order_no = String(row['order_no'] ?? '')
|
||||||
|
form.idempotency_key = String(row['idempotency_key'] ?? '')
|
||||||
|
form.pay_channel = String(row['pay_channel'] ?? '')
|
||||||
|
form.deposit_tier_id = String(row['deposit_tier_id'] ?? '')
|
||||||
|
form.remark = String(row['remark'] ?? '')
|
||||||
|
form.amount = parseNumber(row['amount'])
|
||||||
|
form.bonus_amount = parseNumber(row['bonus_amount'])
|
||||||
|
form.status = Number(row['status'] ?? 0)
|
||||||
|
form.create_time_text = formatTime(row['create_time'])
|
||||||
|
form.pay_time_text = formatTime(row['pay_time'])
|
||||||
|
form.user_text = resolveRelationText(row, 'user', row['user_id'])
|
||||||
|
form.channel_text = resolveRelationText(row, 'channel', row['channel_id'])
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusLabel = computed(() => t('order.depositOrder.status ' + form.status))
|
||||||
|
const statusTagType = computed(() => {
|
||||||
|
switch (form.status) {
|
||||||
|
case 1:
|
||||||
|
return 'success'
|
||||||
|
case 2:
|
||||||
|
return 'danger'
|
||||||
|
case 3:
|
||||||
|
return 'warning'
|
||||||
|
default:
|
||||||
|
return 'info'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const amountText = computed(() => formatAmount(form.amount))
|
||||||
|
const bonusText = computed(() => formatAmount(form.bonus_amount))
|
||||||
|
const totalCreditText = computed(() => formatAmount(Number((form.amount + form.bonus_amount).toFixed(2))))
|
||||||
|
|
||||||
|
const onDialogClose = () => {
|
||||||
|
baTable.toggleForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseNumber(raw: unknown): number {
|
||||||
|
if (raw === null || raw === undefined || raw === '') return 0
|
||||||
|
const n = Number(raw)
|
||||||
|
if (!Number.isFinite(n)) return 0
|
||||||
|
return Number(n.toFixed(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAmount(value: number): string {
|
||||||
|
if (!Number.isFinite(value)) return '0.00'
|
||||||
|
return value.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(raw: unknown): string {
|
||||||
|
if (raw === null || raw === undefined || raw === '' || raw === 0) return '-'
|
||||||
|
const sec = Number(raw)
|
||||||
|
if (!Number.isFinite(sec) || sec <= 0) return '-'
|
||||||
|
const d = new Date(sec * 1000)
|
||||||
|
const pad = (n: number) => (n < 10 ? '0' + n : String(n))
|
||||||
|
return (
|
||||||
|
d.getFullYear() +
|
||||||
|
'-' +
|
||||||
|
pad(d.getMonth() + 1) +
|
||||||
|
'-' +
|
||||||
|
pad(d.getDate()) +
|
||||||
|
' ' +
|
||||||
|
pad(d.getHours()) +
|
||||||
|
':' +
|
||||||
|
pad(d.getMinutes()) +
|
||||||
|
':' +
|
||||||
|
pad(d.getSeconds())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveRelationText(row: Record<string, unknown>, relationKey: string, fallbackId: unknown): string {
|
||||||
|
const rel = row[relationKey]
|
||||||
|
if (rel && typeof rel === 'object') {
|
||||||
|
const r = rel as Record<string, unknown>
|
||||||
|
const name = r['username'] ?? r['name']
|
||||||
|
if (typeof name === 'string' && name !== '') {
|
||||||
|
const id = fallbackId === null || fallbackId === undefined || fallbackId === '' ? '' : ' (ID: ' + String(fallbackId) + ')'
|
||||||
|
return name + id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fallbackId === null || fallbackId === undefined || fallbackId === '') {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
return 'ID: ' + String(fallbackId)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.deposit-detail-dialog {
|
||||||
|
:deep(.el-dialog__body) {
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
:deep(.deposit-detail-dialog) {
|
||||||
|
width: calc(100vw - 24px) !important;
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||||
|
|
||||||
<TableHeader
|
<TableHeader
|
||||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
:buttons="['refresh', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('order.withdrawOrder.quick Search Fields') })"
|
:quick-search-placeholder="t('Quick search placeholder', { fields: t('order.withdrawOrder.quick Search Fields') })"
|
||||||
></TableHeader>
|
></TableHeader>
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ defineOptions({
|
|||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const tableRef = useTemplateRef('tableRef')
|
const tableRef = useTemplateRef('tableRef')
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
const optButtons: OptButton[] = defaultOptButtons(['edit'])
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/order.WithdrawOrder/'),
|
new baTableApi('/admin/order.WithdrawOrder/'),
|
||||||
@@ -38,10 +38,33 @@ const baTable = new baTableClass(
|
|||||||
column: [
|
column: [
|
||||||
{ type: 'selection', align: 'center', operator: false },
|
{ type: 'selection', align: 'center', operator: false },
|
||||||
{ label: t('order.withdrawOrder.id'), prop: 'id', align: 'center', width: 80, operator: 'RANGE', sortable: 'custom' },
|
{ label: t('order.withdrawOrder.id'), prop: 'id', align: 'center', width: 80, operator: 'RANGE', sortable: 'custom' },
|
||||||
{ label: t('order.withdrawOrder.order_no'), prop: 'order_no', align: 'center', minWidth: 170, operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
{
|
||||||
{ label: t('order.withdrawOrder.user_id'), prop: 'user_id', align: 'center', width: 90, operator: 'RANGE' },
|
label: t('order.withdrawOrder.order_no'),
|
||||||
{ label: t('order.withdrawOrder.user_username'), prop: 'user.username', align: 'center', minWidth: 110, operator: 'LIKE', operatorPlaceholder: t('Fuzzy query'), render: 'tags' },
|
prop: 'order_no',
|
||||||
{ label: t('order.withdrawOrder.channel_name'), prop: 'channel.name', align: 'center', minWidth: 110, operator: 'LIKE', operatorPlaceholder: t('Fuzzy query'), render: 'tags' },
|
align: 'center',
|
||||||
|
minWidth: 170,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
},
|
||||||
|
// { label: t('order.withdrawOrder.user_id'), prop: 'user_id', align: 'center', width: 90, operator: 'RANGE' },
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.user_username'),
|
||||||
|
prop: 'user.username',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
render: 'tags',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.channel_name'),
|
||||||
|
prop: 'channel.name',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
render: 'tags',
|
||||||
|
},
|
||||||
{ label: t('order.withdrawOrder.amount'), prop: 'amount', align: 'center', minWidth: 110, operator: 'RANGE' },
|
{ label: t('order.withdrawOrder.amount'), prop: 'amount', align: 'center', minWidth: 110, operator: 'RANGE' },
|
||||||
{ label: t('order.withdrawOrder.fee'), prop: 'fee', align: 'center', minWidth: 110, operator: 'RANGE' },
|
{ label: t('order.withdrawOrder.fee'), prop: 'fee', align: 'center', minWidth: 110, operator: 'RANGE' },
|
||||||
{ label: t('order.withdrawOrder.actual_amount'), prop: 'actual_amount', align: 'center', minWidth: 110, operator: 'RANGE' },
|
{ label: t('order.withdrawOrder.actual_amount'), prop: 'actual_amount', align: 'center', minWidth: 110, operator: 'RANGE' },
|
||||||
@@ -59,13 +82,64 @@ const baTable = new baTableClass(
|
|||||||
'2': 'success',
|
'2': 'success',
|
||||||
'3': 'danger',
|
'3': 'danger',
|
||||||
},
|
},
|
||||||
replaceValue: { '0': t('order.withdrawOrder.status 0'), '1': t('order.withdrawOrder.status 1'), '2': t('order.withdrawOrder.status 2'), '3': t('order.withdrawOrder.status 3') },
|
replaceValue: {
|
||||||
|
'0': t('order.withdrawOrder.status 0'),
|
||||||
|
'1': t('order.withdrawOrder.status 1'),
|
||||||
|
'2': t('order.withdrawOrder.status 2'),
|
||||||
|
'3': t('order.withdrawOrder.status 3'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.review_admin_username'),
|
||||||
|
prop: 'reviewAdmin.username',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 100,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
render: 'tags',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.review_time'),
|
||||||
|
prop: 'review_time',
|
||||||
|
align: 'center',
|
||||||
|
render: 'datetime',
|
||||||
|
operator: 'RANGE',
|
||||||
|
comSearchRender: 'datetime',
|
||||||
|
sortable: 'custom',
|
||||||
|
width: 170,
|
||||||
|
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.remark'),
|
||||||
|
prop: 'remark',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 150,
|
||||||
|
operator: 'LIKE',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
showOverflowTooltip: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.create_time'),
|
||||||
|
prop: 'create_time',
|
||||||
|
align: 'center',
|
||||||
|
render: 'datetime',
|
||||||
|
operator: 'RANGE',
|
||||||
|
comSearchRender: 'datetime',
|
||||||
|
sortable: 'custom',
|
||||||
|
width: 170,
|
||||||
|
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('order.withdrawOrder.update_time'),
|
||||||
|
prop: 'update_time',
|
||||||
|
align: 'center',
|
||||||
|
render: 'datetime',
|
||||||
|
operator: 'RANGE',
|
||||||
|
comSearchRender: 'datetime',
|
||||||
|
sortable: 'custom',
|
||||||
|
width: 170,
|
||||||
|
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||||
},
|
},
|
||||||
{ label: t('order.withdrawOrder.review_admin_username'), prop: 'reviewAdmin.username', align: 'center', minWidth: 100, operator: 'LIKE', operatorPlaceholder: t('Fuzzy query'), render: 'tags' },
|
|
||||||
{ label: t('order.withdrawOrder.review_time'), prop: 'review_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
|
||||||
{ label: t('order.withdrawOrder.remark'), prop: 'remark', align: 'center', minWidth: 150, operator: 'LIKE', operatorPlaceholder: t('Fuzzy query'), showOverflowTooltip: true },
|
|
||||||
{ label: t('order.withdrawOrder.create_time'), prop: 'create_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
|
||||||
{ label: t('order.withdrawOrder.update_time'), prop: 'update_time', align: 'center', render: 'datetime', operator: 'RANGE', comSearchRender: 'datetime', sortable: 'custom', width: 170, timeFormat: 'yyyy-mm-dd hh:MM:ss' },
|
|
||||||
{ label: t('Operate'), align: 'center', width: 90, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
{ label: t('Operate'), align: 'center', width: 90, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,50 +1,434 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog class="ba-operate-dialog" :close-on-click-modal="false" :model-value="['Add', 'Edit'].includes(baTable.form.operate!)" @close="baTable.toggleForm">
|
<el-dialog
|
||||||
|
class="ba-operate-dialog withdraw-review-dialog"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:model-value="isOpen"
|
||||||
|
width="640px"
|
||||||
|
@close="onDialogClose"
|
||||||
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">{{ baTable.form.operate ? t(baTable.form.operate) : '' }}</div>
|
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
||||||
|
{{ step === 'reject' ? t('order.withdrawOrder.review_reject_title') : t('order.withdrawOrder.review_title') }}
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
|
||||||
<div class="ba-operate-form" :class="'ba-' + baTable.form.operate + '-form'" :style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'">
|
<el-scrollbar v-loading="loading" class="ba-table-form-scrollbar">
|
||||||
<el-form v-if="!baTable.form.loading" ref="formRef" @submit.prevent="" @keyup.enter="baTable.onSubmit(formRef)" :model="baTable.form.items" :label-position="config.layout.shrink ? 'top' : 'right'" :label-width="baTable.form.labelWidth + 'px'" :rules="rules">
|
<div class="ba-operate-form ba-edit-form" :style="config.layout.shrink ? '' : 'width: calc(100% - ' + (baTable.form.labelWidth ?? 120) / 2 + 'px)'">
|
||||||
<FormItem :label="t('order.withdrawOrder.order_no')" type="string" v-model="baTable.form.items!.order_no" prop="order_no" />
|
<!-- 第一页:关联信息 + 申请金额 / 手续费 -->
|
||||||
<FormItem :label="t('order.withdrawOrder.user_id')" type="number" v-model="baTable.form.items!.user_id" prop="user_id" :input-attr="{ min: 1, step: 1 }" />
|
<el-form
|
||||||
<FormItem :label="t('order.withdrawOrder.channel_id')" type="number" v-model="baTable.form.items!.channel_id" prop="channel_id" :input-attr="{ min: 1, step: 1 }" />
|
v-if="!loading && step === 'review'"
|
||||||
<FormItem :label="t('order.withdrawOrder.amount')" type="number" v-model="baTable.form.items!.amount" prop="amount" :input-attr="{ step: 0.0001, precision: 4, min: 0 }" />
|
ref="reviewFormRef"
|
||||||
<FormItem :label="t('order.withdrawOrder.fee')" type="number" v-model="baTable.form.items!.fee" prop="fee" :input-attr="{ step: 0.0001, precision: 4, min: 0 }" />
|
:model="form"
|
||||||
<FormItem :label="t('order.withdrawOrder.actual_amount')" type="number" v-model="baTable.form.items!.actual_amount" prop="actual_amount" :input-attr="{ step: 0.0001, precision: 4, min: 0 }" />
|
:rules="reviewRules"
|
||||||
<FormItem :label="t('order.withdrawOrder.status')" type="radio" v-model="baTable.form.items!.status" prop="status" :input-attr="{ content: { '0': t('order.withdrawOrder.status 0'), '1': t('order.withdrawOrder.status 1'), '2': t('order.withdrawOrder.status 2'), '3': t('order.withdrawOrder.status 3') } }" />
|
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||||
<FormItem :label="t('order.withdrawOrder.review_admin_id')" type="number" v-model="baTable.form.items!.review_admin_id" prop="review_admin_id" :input-attr="{ min: 1, step: 1 }" />
|
:label-width="(baTable.form.labelWidth ?? 120) + 'px'"
|
||||||
<FormItem :label="t('order.withdrawOrder.review_time')" type="datetime" v-model="baTable.form.items!.review_time" prop="review_time" />
|
@submit.prevent=""
|
||||||
<FormItem :label="t('order.withdrawOrder.remark')" type="textarea" v-model="baTable.form.items!.remark" prop="remark" :input-attr="{ rows: 2 }" />
|
>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.order_no')">
|
||||||
|
<el-input v-model="form.order_no" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.user_username')">
|
||||||
|
<el-input :model-value="form.user_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.channel_name')">
|
||||||
|
<el-input :model-value="form.channel_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.status')">
|
||||||
|
<el-tag :type="statusTagType" effect="dark" size="small">{{ statusLabel }}</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.create_time')">
|
||||||
|
<el-input :model-value="form.create_time_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.amount')" prop="amount">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.amount"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
:step="1"
|
||||||
|
:controls="false"
|
||||||
|
:disabled="!isPending"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.fee')" prop="fee">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.fee"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
:step="0.1"
|
||||||
|
:controls="false"
|
||||||
|
:disabled="!isPending"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.actual_amount')">
|
||||||
|
<el-input :model-value="actualAmountText" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item v-if="!isPending" :label="t('order.withdrawOrder.review_admin_username')">
|
||||||
|
<el-input :model-value="form.review_admin_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="!isPending" :label="t('order.withdrawOrder.review_time')">
|
||||||
|
<el-input :model-value="form.review_time_text" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="!isPending" :label="t('order.withdrawOrder.remark')">
|
||||||
|
<el-input v-model="form.remark" type="textarea" :rows="2" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<!-- 第二页:拒绝 -> 必填备注 -->
|
||||||
|
<el-form
|
||||||
|
v-if="!loading && step === 'reject'"
|
||||||
|
ref="rejectFormRef"
|
||||||
|
:model="rejectForm"
|
||||||
|
:rules="rejectRules"
|
||||||
|
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||||
|
:label-width="(baTable.form.labelWidth ?? 120) + 'px'"
|
||||||
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-alert
|
||||||
|
class="review-reject-hint"
|
||||||
|
type="warning"
|
||||||
|
show-icon
|
||||||
|
:closable="false"
|
||||||
|
:title="t('order.withdrawOrder.review_reject_tip')"
|
||||||
|
/>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.order_no')">
|
||||||
|
<el-input v-model="form.order_no" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.amount')">
|
||||||
|
<el-input :model-value="amountText" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('order.withdrawOrder.remark')" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="rejectForm.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
maxlength="255"
|
||||||
|
show-word-limit
|
||||||
|
:placeholder="t('order.withdrawOrder.review_reject_placeholder')"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
<div class="review-footer">
|
||||||
<el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
|
<template v-if="step === 'review'">
|
||||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}</el-button>
|
<el-button @click="onDialogClose">{{ t('Cancel') }}</el-button>
|
||||||
|
<template v-if="isPending">
|
||||||
|
<el-button type="danger" :loading="submitting" @click="gotoReject">{{ t('order.withdrawOrder.review_btn_reject') }}</el-button>
|
||||||
|
<el-button type="primary" v-blur :loading="submitting" @click="submitApprove">{{ t('order.withdrawOrder.review_btn_approve') }}</el-button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<el-button @click="backToReview">{{ t('order.withdrawOrder.review_btn_back') }}</el-button>
|
||||||
|
<el-button type="danger" v-blur :loading="submitting" @click="submitReject">{{ t('order.withdrawOrder.review_btn_confirm_reject') }}</el-button>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormItemRule } from 'element-plus'
|
import type { FormInstance, FormItemRule } from 'element-plus'
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { computed, inject, reactive, ref, useTemplateRef, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
import createAxios from '/@/utils/axios'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const formRef = useTemplateRef('formRef')
|
|
||||||
const baTable = inject('baTable') as baTableClass
|
const baTable = inject('baTable') as baTableClass
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
const reviewFormRef = useTemplateRef<FormInstance>('reviewFormRef')
|
||||||
order_no: [{ required: true, message: t('Please input field', { field: t('order.withdrawOrder.order_no') }) }],
|
const rejectFormRef = useTemplateRef<FormInstance>('rejectFormRef')
|
||||||
user_id: [{ required: true, message: t('Please input field', { field: t('order.withdrawOrder.user_id') }) }],
|
|
||||||
|
type Step = 'review' | 'reject'
|
||||||
|
const step = ref<Step>('review')
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
id: 0,
|
||||||
|
order_no: '',
|
||||||
|
user_text: '-',
|
||||||
|
channel_text: '-',
|
||||||
|
create_time_text: '',
|
||||||
|
review_admin_text: '-',
|
||||||
|
review_time_text: '-',
|
||||||
|
amount: 0,
|
||||||
|
fee: 0,
|
||||||
|
status: 0,
|
||||||
|
remark: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const rejectForm = reactive({
|
||||||
|
remark: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const isOpen = computed(() => ['Edit'].includes(baTable.form.operate ?? ''))
|
||||||
|
const isPending = computed(() => form.status === 0)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
isOpen,
|
||||||
|
(visible) => {
|
||||||
|
if (!visible) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
step.value = 'review'
|
||||||
|
rejectForm.remark = ''
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => ({ visible: isOpen.value, loadingState: baTable.form.loading, items: baTable.form.items }),
|
||||||
|
({ visible, loadingState }) => {
|
||||||
|
if (!visible) return
|
||||||
|
loading.value = loadingState === true
|
||||||
|
if (loadingState) return
|
||||||
|
hydrate()
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
const hydrate = () => {
|
||||||
|
const row = baTable.form.items as Record<string, unknown> | undefined
|
||||||
|
if (!row || !row['id']) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.id = Number(row['id'] ?? 0)
|
||||||
|
form.order_no = String(row['order_no'] ?? '')
|
||||||
|
form.amount = parseNumber(row['amount'])
|
||||||
|
form.fee = parseNumber(row['fee'])
|
||||||
|
form.status = Number(row['status'] ?? 0)
|
||||||
|
form.remark = String(row['remark'] ?? '')
|
||||||
|
form.create_time_text = formatTime(row['create_time'])
|
||||||
|
form.review_time_text = formatTime(row['review_time'])
|
||||||
|
form.user_text = resolveRelationText(row, 'user', row['user_id'])
|
||||||
|
form.channel_text = resolveRelationText(row, 'channel', row['channel_id'])
|
||||||
|
form.review_admin_text = resolveRelationText(row, 'reviewAdmin', row['review_admin_id'])
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusLabel = computed(() => t('order.withdrawOrder.status ' + form.status))
|
||||||
|
const statusTagType = computed(() => {
|
||||||
|
switch (form.status) {
|
||||||
|
case 1:
|
||||||
|
return 'success'
|
||||||
|
case 2:
|
||||||
|
return 'danger'
|
||||||
|
case 3:
|
||||||
|
return 'success'
|
||||||
|
default:
|
||||||
|
return 'warning'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const amountText = computed(() => formatAmount(form.amount))
|
||||||
|
const actualAmountText = computed(() => {
|
||||||
|
const actual = Number((form.amount - form.fee).toFixed(2))
|
||||||
|
return formatAmount(actual < 0 ? 0 : actual)
|
||||||
|
})
|
||||||
|
|
||||||
|
const reviewRules: Record<string, FormItemRule[]> = {
|
||||||
|
amount: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: (_r, value, cb) => {
|
||||||
|
if (value === null || value === undefined || Number(value) <= 0) {
|
||||||
|
cb(new Error(t('order.withdrawOrder.amount_invalid')))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fee: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: (_r, value, cb) => {
|
||||||
|
if (value === null || value === undefined || Number(value) < 0) {
|
||||||
|
cb(new Error(t('order.withdrawOrder.fee_invalid')))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (Number(value) > Number(form.amount)) {
|
||||||
|
cb(new Error(t('order.withdrawOrder.fee_exceed_amount')))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const rejectRules: Record<string, FormItemRule[]> = {
|
||||||
|
remark: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: (_r, value, cb) => {
|
||||||
|
const text = typeof value === 'string' ? value.trim() : ''
|
||||||
|
if (text === '') {
|
||||||
|
cb(new Error(t('order.withdrawOrder.reject_reason_required')))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb()
|
||||||
|
},
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const onDialogClose = () => {
|
||||||
|
if (submitting.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
step.value = 'review'
|
||||||
|
baTable.toggleForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
const gotoReject = async () => {
|
||||||
|
step.value = 'reject'
|
||||||
|
rejectForm.remark = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const backToReview = () => {
|
||||||
|
step.value = 'review'
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitApprove = async () => {
|
||||||
|
if (!isPending.value) {
|
||||||
|
ElMessage.warning(t('order.withdrawOrder.already_reviewed'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const formEl = reviewFormRef.value
|
||||||
|
if (!formEl) return
|
||||||
|
const valid = await formEl.validate().catch(() => false)
|
||||||
|
if (!valid) return
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/order.WithdrawOrder/approve',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
id: form.id,
|
||||||
|
amount: form.amount.toFixed(4),
|
||||||
|
fee: form.fee.toFixed(4),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ showSuccessMessage: true }
|
||||||
|
)
|
||||||
|
baTable.onTableHeaderAction('refresh', {})
|
||||||
|
baTable.toggleForm()
|
||||||
|
} catch (_e) {
|
||||||
|
// errors already surfaced by axios interceptor
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitReject = async () => {
|
||||||
|
const formEl = rejectFormRef.value
|
||||||
|
if (!formEl) return
|
||||||
|
const valid = await formEl.validate().catch(() => false)
|
||||||
|
if (!valid) return
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
await createAxios(
|
||||||
|
{
|
||||||
|
url: '/admin/order.WithdrawOrder/reject',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
id: form.id,
|
||||||
|
remark: rejectForm.remark.trim(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ showSuccessMessage: true }
|
||||||
|
)
|
||||||
|
baTable.onTableHeaderAction('refresh', {})
|
||||||
|
baTable.toggleForm()
|
||||||
|
} catch (_e) {
|
||||||
|
// errors already surfaced by axios interceptor
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseNumber(raw: unknown): number {
|
||||||
|
if (raw === null || raw === undefined || raw === '') return 0
|
||||||
|
const n = Number(raw)
|
||||||
|
if (!Number.isFinite(n)) return 0
|
||||||
|
return Number(n.toFixed(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAmount(value: number): string {
|
||||||
|
if (!Number.isFinite(value)) return '0.00'
|
||||||
|
return value.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(raw: unknown): string {
|
||||||
|
if (raw === null || raw === undefined || raw === '' || raw === 0) return '-'
|
||||||
|
const sec = Number(raw)
|
||||||
|
if (!Number.isFinite(sec) || sec <= 0) return '-'
|
||||||
|
const d = new Date(sec * 1000)
|
||||||
|
const pad = (n: number) => (n < 10 ? '0' + n : String(n))
|
||||||
|
return (
|
||||||
|
d.getFullYear() +
|
||||||
|
'-' +
|
||||||
|
pad(d.getMonth() + 1) +
|
||||||
|
'-' +
|
||||||
|
pad(d.getDate()) +
|
||||||
|
' ' +
|
||||||
|
pad(d.getHours()) +
|
||||||
|
':' +
|
||||||
|
pad(d.getMinutes()) +
|
||||||
|
':' +
|
||||||
|
pad(d.getSeconds())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveRelationText(row: Record<string, unknown>, relationKey: string, fallbackId: unknown): string {
|
||||||
|
const rel = row[relationKey]
|
||||||
|
if (rel && typeof rel === 'object') {
|
||||||
|
const r = rel as Record<string, unknown>
|
||||||
|
const name = r['username'] ?? r['name']
|
||||||
|
if (typeof name === 'string' && name !== '') {
|
||||||
|
const id = fallbackId === null || fallbackId === undefined || fallbackId === '' ? '' : ' (ID: ' + String(fallbackId) + ')'
|
||||||
|
return name + id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fallbackId === null || fallbackId === undefined || fallbackId === '') {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
return 'ID: ' + String(fallbackId)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.withdraw-review-dialog {
|
||||||
|
:deep(.el-dialog__body) {
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-reject-hint {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.review-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
:deep(.withdraw-review-dialog) {
|
||||||
|
width: calc(100vw - 24px) !important;
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ const baTable = new baTableClass(
|
|||||||
label: t('State'),
|
label: t('State'),
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: 'tag',
|
operator: 'eq',
|
||||||
effect: 'dark',
|
sortable: false,
|
||||||
custom: { 0: 'danger', 1: 'success' },
|
render: 'switch',
|
||||||
replaceValue: { 0: t('Disable'), 1: t('security.dataRecycle.Deleting monitoring') },
|
replaceValue: { 0: t('Disable'), 1: t('security.dataRecycle.Deleting monitoring') },
|
||||||
},
|
},
|
||||||
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ const baTable = new sensitiveDataClass(
|
|||||||
label: t('State'),
|
label: t('State'),
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: 'tag',
|
operator: 'eq',
|
||||||
effect: 'dark',
|
sortable: false,
|
||||||
custom: { 0: 'danger', 1: 'success' },
|
render: 'switch',
|
||||||
replaceValue: { 0: t('Disable'), 1: t('security.sensitiveData.Modifying monitoring') },
|
replaceValue: { 0: t('Disable'), 1: t('security.sensitiveData.Modifying monitoring') },
|
||||||
},
|
},
|
||||||
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||||
@@ -101,7 +101,7 @@ const baTable = new sensitiveDataClass(
|
|||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
dblClickNotEditColumn: [undefined],
|
dblClickNotEditColumn: [undefined, 'status'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
defaultItems: {
|
defaultItems: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main ba-table-box">
|
<div class="default-main ba-table-box">
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||||
|
|
||||||
@@ -10,24 +10,71 @@
|
|||||||
<Table ref="tableRef"></Table>
|
<Table ref="tableRef"></Table>
|
||||||
|
|
||||||
<PopupForm />
|
<PopupForm />
|
||||||
|
|
||||||
|
<el-dialog v-model="walletDialogVisible" class="ba-operate-dialog wallet-adjust-dialog" :close-on-click-modal="false" width="520px">
|
||||||
|
<template #header>
|
||||||
|
<div class="title">{{ t('user.user.wallet_adjust_title') }}</div>
|
||||||
|
</template>
|
||||||
|
<el-scrollbar class="ba-table-form-scrollbar">
|
||||||
|
<div class="ba-operate-form wallet-adjust-form">
|
||||||
|
<el-form :label-position="config.layout.shrink ? 'top' : 'right'" :label-width="config.layout.shrink ? '' : '110px'">
|
||||||
|
<el-form-item :label="t('user.user.username')">
|
||||||
|
<el-input :model-value="walletForm.username" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('user.user.coin')">
|
||||||
|
<el-tag type="primary">{{ walletForm.current_coin }}</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('user.user.wallet_adjust_op')">
|
||||||
|
<el-radio-group v-model="walletForm.op" class="wallet-adjust-op-group" @change="syncWalletRemark">
|
||||||
|
<el-radio label="credit">{{ t('user.user.wallet_adjust_credit') }}</el-radio>
|
||||||
|
<el-radio label="deduct">{{ t('user.user.wallet_adjust_deduct') }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('user.user.wallet_adjust_amount')">
|
||||||
|
<el-input-number
|
||||||
|
class="wallet-adjust-amount-input"
|
||||||
|
v-model="walletForm.amount"
|
||||||
|
:min="0.01"
|
||||||
|
:step="0.01"
|
||||||
|
:precision="2"
|
||||||
|
@change="syncWalletRemark"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="t('user.user.remark')">
|
||||||
|
<el-input v-model="walletForm.remark" type="textarea" :rows="3" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</el-scrollbar>
|
||||||
|
<template #footer>
|
||||||
|
<div class="wallet-adjust-dialog-footer">
|
||||||
|
<el-button @click="walletDialogVisible = false">{{ t('Cancel') }}</el-button>
|
||||||
|
<el-button type="primary" :loading="walletSubmitting" @click="submitWalletAdjust">{{ t('Save') }}</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, provide, useTemplateRef } from 'vue'
|
import { onMounted, provide, reactive, ref, useTemplateRef } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import PopupForm from './popupForm.vue'
|
import PopupForm from './popupForm.vue'
|
||||||
import { baTableApi } from '/@/api/common'
|
import { baTableApi } from '/@/api/common'
|
||||||
import { defaultOptButtons } from '/@/components/table'
|
import { defaultOptButtons } from '/@/components/table'
|
||||||
import TableHeader from '/@/components/table/header/index.vue'
|
import TableHeader from '/@/components/table/header/index.vue'
|
||||||
import Table from '/@/components/table/index.vue'
|
import Table from '/@/components/table/index.vue'
|
||||||
import baTableClass from '/@/utils/baTable'
|
import baTableClass from '/@/utils/baTable'
|
||||||
|
import createAxios from '/@/utils/axios'
|
||||||
|
import { useConfig } from '/@/stores/config'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'user/user',
|
name: 'user/user',
|
||||||
})
|
})
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const config = useConfig()
|
||||||
const tableRef = useTemplateRef('tableRef')
|
const tableRef = useTemplateRef('tableRef')
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
||||||
|
|
||||||
@@ -40,7 +87,7 @@ function formatCoin(_row: anyObj, _column: any, cellValue: unknown) {
|
|||||||
if (!Number.isFinite(n)) {
|
if (!Number.isFinite(n)) {
|
||||||
return String(cellValue)
|
return String(cellValue)
|
||||||
}
|
}
|
||||||
return n.toFixed(4)
|
return n.toFixed(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 杩斿洖澶氭爣绛炬枃妗堟暟缁勶紝渚?render: tags 浣跨敤 */
|
/** 杩斿洖澶氭爣绛炬枃妗堟暟缁勶紝渚?render: tags 浣跨敤 */
|
||||||
@@ -55,6 +102,73 @@ function formatRiskFlags(row: anyObj, _column: any, cellValue: unknown) {
|
|||||||
return parts
|
return parts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildDisplayAmount(v: unknown): string {
|
||||||
|
if (v === null || v === undefined || v === '') return '0.00'
|
||||||
|
const n = parseFloat(String(v).trim().replace(',', '.'))
|
||||||
|
if (!Number.isFinite(n)) return '0.00'
|
||||||
|
return n.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
const walletDialogVisible = ref(false)
|
||||||
|
const walletSubmitting = ref(false)
|
||||||
|
const walletForm = reactive({
|
||||||
|
user_id: 0,
|
||||||
|
username: '',
|
||||||
|
current_coin: '0.00',
|
||||||
|
op: 'credit',
|
||||||
|
amount: 100,
|
||||||
|
remark: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
function syncWalletRemark() {
|
||||||
|
const action = walletForm.op === 'credit' ? t('user.user.wallet_adjust_credit') : t('user.user.wallet_adjust_deduct')
|
||||||
|
walletForm.remark = t('user.user.wallet_adjust_default_remark', {
|
||||||
|
admin: t('user.user.wallet_adjust_operator_admin'),
|
||||||
|
action,
|
||||||
|
amount: Number(walletForm.amount || 0).toFixed(2),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWalletDialog(row: anyObj) {
|
||||||
|
walletForm.user_id = Number(row.id || 0)
|
||||||
|
walletForm.username = String(row.username ?? '-')
|
||||||
|
walletForm.current_coin = buildDisplayAmount(row.coin)
|
||||||
|
walletForm.op = 'credit'
|
||||||
|
walletForm.amount = 100
|
||||||
|
syncWalletRemark()
|
||||||
|
walletDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitWalletAdjust() {
|
||||||
|
if (!walletForm.user_id) return
|
||||||
|
if (!(walletForm.amount > 0)) {
|
||||||
|
ElMessage.error(t('user.user.wallet_adjust_amount_invalid'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
walletSubmitting.value = true
|
||||||
|
try {
|
||||||
|
const res = await createAxios({
|
||||||
|
url: '/admin/user.User/walletAdjust',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
user_id: walletForm.user_id,
|
||||||
|
op: walletForm.op,
|
||||||
|
amount: Number(walletForm.amount).toFixed(2),
|
||||||
|
remark: walletForm.remark,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (res.code === 1) {
|
||||||
|
ElMessage.success(res.msg || t('Success'))
|
||||||
|
walletDialogVisible.value = false
|
||||||
|
await baTable.getData()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.msg || t('Unknown error'))
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
walletSubmitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/user.User/'),
|
new baTableApi('/admin/user.User/'),
|
||||||
{
|
{
|
||||||
@@ -105,7 +219,22 @@ const baTable = new baTableClass(
|
|||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
},
|
},
|
||||||
{ label: t('user.user.coin'), prop: 'coin', align: 'center', sortable: false, operator: 'RANGE', formatter: formatCoin },
|
{
|
||||||
|
label: t('user.user.coin'),
|
||||||
|
prop: 'coin',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 100,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
render: 'tag',
|
||||||
|
formatter: formatCoin,
|
||||||
|
customRenderAttr: {
|
||||||
|
tag: ({ row }) => ({
|
||||||
|
class: 'wallet-balance-tag',
|
||||||
|
onClick: () => openWalletDialog(row),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('user.user.total_deposit_coin'),
|
label: t('user.user.total_deposit_coin'),
|
||||||
prop: 'total_deposit_coin',
|
prop: 'total_deposit_coin',
|
||||||
@@ -116,8 +245,17 @@ const baTable = new baTableClass(
|
|||||||
formatter: formatCoin,
|
formatter: formatCoin,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('user.user.total_valid_bet_coin'),
|
label: t('user.user.total_withdraw_coin'),
|
||||||
prop: 'total_valid_bet_coin',
|
prop: 'total_withdraw_coin',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatCoin,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('user.user.bet_flow_coin'),
|
||||||
|
prop: 'bet_flow_coin',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
sortable: false,
|
sortable: false,
|
||||||
@@ -221,9 +359,10 @@ const baTable = new baTableClass(
|
|||||||
{
|
{
|
||||||
defaultItems: {
|
defaultItems: {
|
||||||
status: '1',
|
status: '1',
|
||||||
coin: '0.0000',
|
coin: '0.00',
|
||||||
total_deposit_coin: '0.0000',
|
total_deposit_coin: '0.00',
|
||||||
total_valid_bet_coin: '0.0000',
|
total_withdraw_coin: '0.00',
|
||||||
|
bet_flow_coin: '0.00',
|
||||||
risk_flags: 0,
|
risk_flags: 0,
|
||||||
current_streak: 0,
|
current_streak: 0,
|
||||||
last_bet_period_no: '',
|
last_bet_period_no: '',
|
||||||
@@ -246,6 +385,54 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.wallet-balance-tag {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-form :deep(.el-form-item) {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-op-group {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-amount-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-amount-input :deep(.el-input__wrapper) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.wallet-adjust-dialog :deep(.el-dialog) {
|
||||||
|
width: calc(100vw - 16px) !important;
|
||||||
|
margin-top: 4vh !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-op-group {
|
||||||
|
gap: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-adjust-dialog-footer .el-button {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,30 +99,6 @@
|
|||||||
:placeholder="t('user.user.register_invite_code_auto_placeholder')"
|
:placeholder="t('user.user.register_invite_code_auto_placeholder')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<el-divider content-position="left">{{ t('user.user.section_finance') }}</el-divider>
|
|
||||||
<FormItem
|
|
||||||
:label="t('user.user.coin')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.coin"
|
|
||||||
prop="coin"
|
|
||||||
:input-attr="{ step: 0.0001, min: 0, precision: 4 }"
|
|
||||||
:placeholder="t('user.user.coin_placeholder')"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('user.user.total_deposit_coin')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.total_deposit_coin"
|
|
||||||
prop="total_deposit_coin"
|
|
||||||
:input-attr="{ step: 0.0001, min: 0, precision: 4 }"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('user.user.total_valid_bet_coin')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.total_valid_bet_coin"
|
|
||||||
prop="total_valid_bet_coin"
|
|
||||||
:input-attr="{ step: 0.0001, min: 0, precision: 4 }"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<el-divider content-position="left">{{ t('user.user.section_risk') }}</el-divider>
|
<el-divider content-position="left">{{ t('user.user.section_risk') }}</el-divider>
|
||||||
<el-form-item :label="t('user.user.risk_flags')">
|
<el-form-item :label="t('user.user.risk_flags')">
|
||||||
<div class="risk-flag-row">
|
<div class="risk-flag-row">
|
||||||
@@ -455,27 +431,10 @@ const validatorGameUserPassword = (rule: any, val: string, callback: (error?: Er
|
|||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
const decimalRule = (fieldTitle: string): FormItemRule => ({
|
|
||||||
trigger: 'blur',
|
|
||||||
validator: (_rule, val, callback) => {
|
|
||||||
if (val === null || val === undefined || val === '') {
|
|
||||||
return callback()
|
|
||||||
}
|
|
||||||
const n = typeof val === 'number' ? val : parseFloat(String(val).trim().replace(',', '.'))
|
|
||||||
if (!Number.isFinite(n) || n < 0) {
|
|
||||||
return callback(new Error(t('Please enter the correct field', { field: fieldTitle })))
|
|
||||||
}
|
|
||||||
return callback()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||||
username: [buildValidatorData({ name: 'required', title: t('user.user.username') })],
|
username: [buildValidatorData({ name: 'required', title: t('user.user.username') })],
|
||||||
password: [{ validator: validatorGameUserPassword, trigger: 'blur' }],
|
password: [{ validator: validatorGameUserPassword, trigger: 'blur' }],
|
||||||
phone: [buildValidatorData({ name: 'required', title: t('user.user.phone') })],
|
phone: [buildValidatorData({ name: 'required', title: t('user.user.phone') })],
|
||||||
coin: [decimalRule(t('user.user.coin'))],
|
|
||||||
total_deposit_coin: [decimalRule(t('user.user.total_deposit_coin'))],
|
|
||||||
total_valid_bet_coin: [decimalRule(t('user.user.total_valid_bet_coin'))],
|
|
||||||
admin_id: [buildValidatorData({ name: 'required', title: t('user.user.admin_affiliation') })],
|
admin_id: [buildValidatorData({ name: 'required', title: t('user.user.admin_affiliation') })],
|
||||||
create_time: [buildValidatorData({ name: 'date', title: t('user.user.create_time') })],
|
create_time: [buildValidatorData({ name: 'date', title: t('user.user.create_time') })],
|
||||||
update_time: [buildValidatorData({ name: 'date', title: t('user.user.update_time') })],
|
update_time: [buildValidatorData({ name: 'date', title: t('user.user.update_time') })],
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main ba-table-box">
|
<div class="default-main ba-table-box">
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||||
|
|
||||||
<TableHeader
|
<TableHeader
|
||||||
:buttons="['refresh', 'comSearch', 'quickSearch', 'columnDisplay']"
|
:buttons="['refresh', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('record.userWalletRecord.quick Search Fields') })"
|
:quick-search-placeholder="t('Quick search placeholder', { fields: t('user.userWalletRecord.quick Search Fields') })"
|
||||||
></TableHeader>
|
></TableHeader>
|
||||||
|
|
||||||
<Table ref="tableRef"></Table>
|
<Table ref="tableRef"></Table>
|
||||||
@@ -20,7 +20,7 @@ import Table from '/@/components/table/index.vue'
|
|||||||
import baTableClass from '/@/utils/baTable'
|
import baTableClass from '/@/utils/baTable'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'record/userWalletRecord',
|
name: 'user/userWalletRecord',
|
||||||
})
|
})
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
@@ -35,23 +35,23 @@ function formatAmount(_row: anyObj, _column: any, cellValue: unknown) {
|
|||||||
if (!Number.isFinite(n)) {
|
if (!Number.isFinite(n)) {
|
||||||
return String(cellValue)
|
return String(cellValue)
|
||||||
}
|
}
|
||||||
return n.toFixed(4)
|
return n.toFixed(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const bizReplace = {
|
const bizReplace = {
|
||||||
deposit: t('record.userWalletRecord.biz deposit'),
|
deposit: t('user.userWalletRecord.biz deposit'),
|
||||||
withdraw: t('record.userWalletRecord.biz withdraw'),
|
withdraw: t('user.userWalletRecord.biz withdraw'),
|
||||||
withdraw_freeze: t('record.userWalletRecord.biz withdraw_freeze'),
|
withdraw_freeze: t('user.userWalletRecord.biz withdraw_freeze'),
|
||||||
withdraw_unfreeze: t('record.userWalletRecord.biz withdraw_unfreeze'),
|
withdraw_unfreeze: t('user.userWalletRecord.biz withdraw_unfreeze'),
|
||||||
platform_in: t('record.userWalletRecord.biz platform_in'),
|
platform_in: t('user.userWalletRecord.biz platform_in'),
|
||||||
platform_out: t('record.userWalletRecord.biz platform_out'),
|
platform_out: t('user.userWalletRecord.biz platform_out'),
|
||||||
admin_credit: t('record.userWalletRecord.biz admin_credit'),
|
admin_credit: t('user.userWalletRecord.biz admin_credit'),
|
||||||
admin_deduct: t('record.userWalletRecord.biz admin_deduct'),
|
admin_deduct: t('user.userWalletRecord.biz admin_deduct'),
|
||||||
bet: t('record.userWalletRecord.biz bet'),
|
bet: t('user.userWalletRecord.biz bet'),
|
||||||
payout: t('record.userWalletRecord.biz payout'),
|
payout: t('user.userWalletRecord.biz payout'),
|
||||||
fee: t('record.userWalletRecord.biz fee'),
|
fee: t('user.userWalletRecord.biz fee'),
|
||||||
void_refund: t('record.userWalletRecord.biz void_refund'),
|
void_refund: t('user.userWalletRecord.biz void_refund'),
|
||||||
adjust: t('record.userWalletRecord.biz adjust'),
|
adjust: t('user.userWalletRecord.biz adjust'),
|
||||||
}
|
}
|
||||||
|
|
||||||
const bizTypeTagCustom = {
|
const bizTypeTagCustom = {
|
||||||
@@ -71,18 +71,18 @@ const bizTypeTagCustom = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dirReplace = {
|
const dirReplace = {
|
||||||
'1': t('record.userWalletRecord.direction in'),
|
'1': t('user.userWalletRecord.direction in'),
|
||||||
'2': t('record.userWalletRecord.direction out'),
|
'2': t('user.userWalletRecord.direction out'),
|
||||||
}
|
}
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const baTable = new baTableClass(
|
||||||
new baTableApi('/admin/record.UserWalletRecord/'),
|
new baTableApi('/admin/user.UserWalletRecord/'),
|
||||||
{
|
{
|
||||||
pk: 'id',
|
pk: 'id',
|
||||||
column: [
|
column: [
|
||||||
{ label: t('record.userWalletRecord.id'), prop: 'id', align: 'center', width: 100, operator: 'RANGE', sortable: 'custom' },
|
{ label: t('user.userWalletRecord.id'), prop: 'id', align: 'center', width: 100, operator: 'RANGE', sortable: 'custom' },
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.user_id'),
|
label: t('user.userWalletRecord.user_id'),
|
||||||
prop: 'user_id',
|
prop: 'user_id',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 90,
|
width: 90,
|
||||||
@@ -91,7 +91,7 @@ const baTable = new baTableClass(
|
|||||||
sortable: false,
|
sortable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.user__username'),
|
label: t('user.userWalletRecord.user__username'),
|
||||||
prop: 'user.username',
|
prop: 'user.username',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
@@ -101,7 +101,7 @@ const baTable = new baTableClass(
|
|||||||
comSearchRender: 'string',
|
comSearchRender: 'string',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.channel__name'),
|
label: t('user.userWalletRecord.channel__name'),
|
||||||
prop: 'channel.name',
|
prop: 'channel.name',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
@@ -111,7 +111,7 @@ const baTable = new baTableClass(
|
|||||||
comSearchRender: 'string',
|
comSearchRender: 'string',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.biz_type'),
|
label: t('user.userWalletRecord.biz_type'),
|
||||||
prop: 'biz_type',
|
prop: 'biz_type',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
@@ -121,7 +121,7 @@ const baTable = new baTableClass(
|
|||||||
replaceValue: bizReplace,
|
replaceValue: bizReplace,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.direction'),
|
label: t('user.userWalletRecord.direction'),
|
||||||
prop: 'direction',
|
prop: 'direction',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 90,
|
width: 90,
|
||||||
@@ -134,7 +134,7 @@ const baTable = new baTableClass(
|
|||||||
replaceValue: dirReplace,
|
replaceValue: dirReplace,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.amount'),
|
label: t('user.userWalletRecord.amount'),
|
||||||
prop: 'amount',
|
prop: 'amount',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
@@ -142,7 +142,7 @@ const baTable = new baTableClass(
|
|||||||
formatter: formatAmount,
|
formatter: formatAmount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.balance_before'),
|
label: t('user.userWalletRecord.balance_before'),
|
||||||
prop: 'balance_before',
|
prop: 'balance_before',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
@@ -150,7 +150,7 @@ const baTable = new baTableClass(
|
|||||||
formatter: formatAmount,
|
formatter: formatAmount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.balance_after'),
|
label: t('user.userWalletRecord.balance_after'),
|
||||||
prop: 'balance_after',
|
prop: 'balance_after',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 110,
|
minWidth: 110,
|
||||||
@@ -158,16 +158,16 @@ const baTable = new baTableClass(
|
|||||||
formatter: formatAmount,
|
formatter: formatAmount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.ref_type'),
|
label: t('user.userWalletRecord.ref_type'),
|
||||||
prop: 'ref_type',
|
prop: 'ref_type',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
},
|
},
|
||||||
{ label: t('record.userWalletRecord.ref_id'), prop: 'ref_id', align: 'center', width: 100, operator: 'RANGE' },
|
{ label: t('user.userWalletRecord.ref_id'), prop: 'ref_id', align: 'center', width: 100, operator: 'RANGE' },
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.idempotency_key'),
|
label: t('user.userWalletRecord.idempotency_key'),
|
||||||
prop: 'idempotency_key',
|
prop: 'idempotency_key',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
@@ -175,7 +175,7 @@ const baTable = new baTableClass(
|
|||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.operator_admin__username'),
|
label: t('user.userWalletRecord.operator_admin__username'),
|
||||||
prop: 'operatorAdmin.username',
|
prop: 'operatorAdmin.username',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 100,
|
minWidth: 100,
|
||||||
@@ -185,7 +185,7 @@ const baTable = new baTableClass(
|
|||||||
comSearchRender: 'string',
|
comSearchRender: 'string',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.remark'),
|
label: t('user.userWalletRecord.remark'),
|
||||||
prop: 'remark',
|
prop: 'remark',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
@@ -193,7 +193,7 @@ const baTable = new baTableClass(
|
|||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('record.userWalletRecord.create_time'),
|
label: t('user.userWalletRecord.create_time'),
|
||||||
prop: 'create_time',
|
prop: 'create_time',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: 'datetime',
|
render: 'datetime',
|
||||||
Reference in New Issue
Block a user