Compare commits
81 Commits
330bd3b525
...
master-v2
| Author | SHA1 | Date | |
|---|---|---|---|
| 68092759d3 | |||
| 8702cb0571 | |||
| ca620eb536 | |||
| 8684fdc9f0 | |||
| d72868eb76 | |||
| 6ff65afcb5 | |||
| b689a40595 | |||
| f9f8a1e169 | |||
| 3dbd68829a | |||
| 333e85f7d9 | |||
| db0e420a8f | |||
| f63616e735 | |||
| bdf50e61f5 | |||
| e7b8f4cae9 | |||
| d4cf708bc1 | |||
| eb8123c7b3 | |||
| 683bd5d97a | |||
| 150d31eac5 | |||
| 1892c7bcb7 | |||
| 5b5e923a0b | |||
| f6b4fb99f0 | |||
| 216d3ac8fe | |||
| c790f74905 | |||
| 4a7397ce04 | |||
| 861d5c49b3 | |||
| 8e51ca8930 | |||
| 425e9feb56 | |||
| e5543ae6e4 | |||
| 0b2f4a026e | |||
| 1213f8e58a | |||
| 27e9de0ac9 | |||
| 502404af17 | |||
| 76aa9bde8b | |||
| 72b43759f1 | |||
| ed46f18415 | |||
| 05d592dcbc | |||
| 2419f81955 | |||
| 2de54e17c3 | |||
| 0b26afde70 | |||
| f5eaf8da30 | |||
| b79904f75e | |||
| 6b21626878 | |||
| 7445dc4cb0 | |||
| e8620998ae | |||
| 3182d04956 | |||
| cc7e2d9a1a | |||
| 7e4ba86afa | |||
| 064ce06393 | |||
| 2af7fedcce | |||
| bb166350fd | |||
| 84d499145d | |||
| 54aa0bd34f | |||
| 1a748745cb | |||
| bc034727b0 | |||
| e56c3ada34 | |||
| 296991f53a | |||
| 1f8d76e80b | |||
| 5afaa9fcb2 | |||
| 6f56574aac | |||
| fdd8f6dffa | |||
| b1efeb8b31 | |||
| 275f94f96d | |||
| 9452fd28e2 | |||
| 7716929447 | |||
| a6d87d5c0d | |||
| e94ebd3fe6 | |||
| 99a0b63f0e | |||
| fbf8f9d39d | |||
| e726fc3041 | |||
| a37da0b6f5 | |||
| 1de9af703a | |||
| 4cf0da8092 | |||
| 6632923213 | |||
| 316506b597 | |||
| 282d73a203 | |||
| 4b6bbab9d1 | |||
| e312154b0f | |||
| fe1ceeb4fb | |||
| 7e5585aee0 | |||
| e087f89df5 | |||
| 1cb2e26a77 |
272
API对接文档.md
Normal file
272
API对接文档.md
Normal file
@@ -0,0 +1,272 @@
|
||||
# 大富翁-摇色子 对接文档
|
||||
|
||||
本文覆盖**平台侧对接接口**(`/api/v1/*`,使用 `auth-token` 鉴权)以及(可选)**玩家侧接口**(`/api/*`,使用 `token` 鉴权)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 基本约定
|
||||
|
||||
### 1.1 服务地址(Base URL)
|
||||
|
||||
由部署方提供:
|
||||
|
||||
- 测试环境:`https://dice-api.yuliao666.top`
|
||||
|
||||
下文所有路径均为相对路径,如:`/api/v1/getGameUrl`。
|
||||
|
||||
### 1.2 请求方式与编码
|
||||
|
||||
- **请求方法**:项目路由多数使用 `Route::any`,对接建议统一使用 **POST**(便于 body 传参);个别接口文档中标注了 GET 参数。
|
||||
- **编码**:`UTF-8`
|
||||
- **Content-Type**:建议 `application/x-www-form-urlencoded` 或 `application/json`(以平台实际实现为准)
|
||||
|
||||
### 1.3 统一返回结构
|
||||
|
||||
所有接口统一返回 JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
- `code`:业务状态码(见“返回 code 对照表”)
|
||||
- `message`:提示信息(可根据请求头 `lang` 返回中英文)
|
||||
- `data`:成功时返回数据;失败时通常不返回该字段
|
||||
|
||||
### 1.4 多语言(lang)
|
||||
|
||||
服务端会根据请求头 `lang` 翻译 `message`(以及部分接口字段):
|
||||
|
||||
- `lang: zh`(默认)
|
||||
- `lang: en`
|
||||
|
||||
> 注意:平台 v1 接口的 `getGameUrl` 还支持 body 参数 `lang`(`zh/en`),用于拼接游戏地址语言参数。
|
||||
|
||||
---
|
||||
|
||||
## 2. 鉴权与对接流程(平台侧 /api/v1)
|
||||
|
||||
平台侧接口分两步:
|
||||
|
||||
1. **获取 `auth-token`**
|
||||
2. **携带 `auth-token` 调用 `/api/v1/*` 业务接口**
|
||||
|
||||
### 2.1 获取 auth-token
|
||||
|
||||
- **路径**:`/api/v1/authToken`
|
||||
- **方法**:GET / POST 均可(建议 GET,参数放 query)
|
||||
- **说明**:用于平台调用 v1 业务接口的授权 token(JWT)
|
||||
|
||||
#### 请求参数(query/body)
|
||||
|
||||
| 参数名 | 必填 | 类型 | 说明 |
|
||||
| --- | --- | --- |---------------------------------------------------|
|
||||
| agent_id | 是 | string | 平台/代理标识(后台查看对应管理员agent_id) |
|
||||
| secret | 是 | string | 双方约定的密钥(服务端配置 `xF75oK91TQj13s0UmNIr1NBWMWGfflNO`) |
|
||||
| time | 是 | int/string | Unix 时间戳(秒),服务端会做时间容忍校验 |
|
||||
| signature | 是 | string | 签名:`md5(agent_id + secret + time)` |
|
||||
- **agent_id**:通过后台获取系统管理-用户管理-代理ID
|
||||
- **secret**:xF75oK91TQj13s0UmNIr1NBWMWGfflNO(服务器配置)
|
||||
- **后台地址**:https://dice.yuliao666.top 账号: zhuguan 密码:123456
|
||||
#### 签名规则
|
||||
|
||||
- **签名字符串**:直接拼接 `agent_id.secret.time`(无分隔符)
|
||||
- **算法**:MD5(32 位小写/大写均可,按实现一致即可)
|
||||
|
||||
示例(伪代码):
|
||||
|
||||
```text
|
||||
signature = md5(agent_id + secret + time)
|
||||
```
|
||||
|
||||
#### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"authtoken": "xxxx.yyyy.zzzz"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 失败场景
|
||||
|
||||
- 缺少参数:`code=400`
|
||||
- 密钥错误/签名错误/时间戳无效:`code=403`
|
||||
- 服务端未配置密钥或生成失败:`code=500`
|
||||
|
||||
### 2.2 调用 v1 业务接口(携带 auth-token)
|
||||
|
||||
除 `/api/v1/authToken` 外,其余 `/api/v1/*` 接口需要在请求头携带:
|
||||
|
||||
- `auth-token: <authtoken>`
|
||||
|
||||
当 `auth-token` 过期或失效,返回 `code=402`,需要重新调用 `/api/v1/authToken` 获取新 token。
|
||||
|
||||
---
|
||||
|
||||
## 3. 平台 v1 业务接口清单(/api/v1)
|
||||
|
||||
### 3.1 获取游戏地址
|
||||
|
||||
- **路径**:`/api/v1/getGameUrl`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
- **说明**:根据平台用户名创建/登录玩家并生成登录 JWT,返回可直接打开的游戏地址。
|
||||
|
||||
#### 请求参数(body)
|
||||
|
||||
| 参数名 | 必填 | 类型 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| username | 是 | string | 玩家唯一账号(平台侧用户名) |
|
||||
| password | 否 | string | 默认 `123456` |
|
||||
| time | 否 | int/string | 默认当前时间戳 |
|
||||
| lang | 否 | string | `zh` / `en`,默认 `zh` |
|
||||
|
||||
#### 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"url": "https://dice-game.yuliao666.top/?token=...&lang=zh"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 获取用户信息
|
||||
|
||||
- **路径**:`/api/v1/getPlayerInfo`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
|
||||
#### 请求参数
|
||||
|
||||
| 参数名 | 必填 | 类型 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| username | 是 | string | 玩家账号 |
|
||||
|
||||
#### 响应说明
|
||||
|
||||
返回玩家基础信息(已隐藏敏感字段,如 `password` 等)。
|
||||
|
||||
### 3.3 获取游戏记录
|
||||
|
||||
- **路径**:`/api/v1/getPlayerGameRecord`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
|
||||
#### 请求参数
|
||||
|
||||
| 参数名 | 必填 | 类型 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| username | 否 | string | 不传则查询全量(按时间/分页) |
|
||||
| start_create_time | 否 | string | 开始时间(与数据库存储格式一致) |
|
||||
| end_create_time | 否 | string | 结束时间(与数据库存储格式一致) |
|
||||
| page | 否 | int | 默认 1 |
|
||||
| limit | 否 | int | 默认 20,最大 100 |
|
||||
|
||||
#### 响应说明
|
||||
|
||||
返回游玩记录列表,并附带 `dice_player`(包含 `id/username/phone`)。
|
||||
|
||||
### 3.4 获取钱包流水
|
||||
|
||||
- **路径**:`/api/v1/getPlayerWalletRecord`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
|
||||
参数与分页规则同 3.3,返回钱包流水列表(附带 `dice_player`)。
|
||||
|
||||
### 3.5 获取中奖券获取记录
|
||||
|
||||
- **路径**:`/api/v1/getPlayerTicketRecord`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
|
||||
参数与分页规则同 3.3,返回中奖券记录列表(附带 `dice_player`)。
|
||||
|
||||
### 3.6 平台钱包转入/转出
|
||||
|
||||
- **路径**:`/api/v1/setPlayerWallet`
|
||||
- **方法**:POST
|
||||
- **请求头**:`auth-token`
|
||||
- **说明**:平台为玩家加币/扣币,生成钱包流水。
|
||||
|
||||
#### 请求参数
|
||||
|
||||
| 参数名 | 必填 | 类型 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| username | 是 | string | 玩家账号 |
|
||||
| coin | 是 | number | 转入:`>0`;转出:`<0`;不允许为 0 |
|
||||
|
||||
#### 业务规则
|
||||
|
||||
- 当 `coin < 0` 且余额不足时:`code=422`,`message=余额不足,无法转出`
|
||||
|
||||
---
|
||||
|
||||
## 4. 玩家侧接口(可选 /api)
|
||||
|
||||
若甲方平台需要在**服务端**直接调用“购买抽奖券/开局”等接口,可按本节对接(此类接口需要 `token`,与 `auth-token` 不同)。
|
||||
|
||||
### 4.1 获取 token(玩家登录)
|
||||
|
||||
- **路径**:`/api/user/Login`
|
||||
- **方法**:POST
|
||||
- **说明**:创建/登录玩家并返回登录 token 以及游戏地址。
|
||||
|
||||
请求参数:`username`、`password`(必填),`lang/coin/time`(可选)。
|
||||
|
||||
响应 `data.token` 可用于后续 `/api/*` 请求头 `token` 或 `Authorization: Bearer <token>`。
|
||||
|
||||
### 4.2 需要 token 的接口
|
||||
|
||||
请求头携带(任选一种):
|
||||
|
||||
- `token: <token>`
|
||||
- `Authorization: Bearer <token>`
|
||||
|
||||
接口列表:
|
||||
|
||||
- `/api/user/logout`
|
||||
- `/api/user/info`
|
||||
- `/api/user/balance`
|
||||
- `/api/user/walletRecord`
|
||||
- `/api/user/playGameRecord`
|
||||
- `/api/game/config`
|
||||
- `/api/game/buyLotteryTickets`
|
||||
- `/api/game/lotteryPool`
|
||||
- `/api/game/playStart`
|
||||
|
||||
---
|
||||
|
||||
## 5. 返回 code 对照表
|
||||
|
||||
项目定义的统一状态码如下(与 HTTP 语义对齐):
|
||||
|
||||
| code | 含义 | 常见场景 |
|
||||
| --- | --- | --- |
|
||||
| 200 | 成功 | 请求成功 |
|
||||
| 400 | 请求参数错误 | 缺参、参数格式不合法、范围错误 |
|
||||
| 401 | 未授权 | 未携带 `auth-token` 或 `token` |
|
||||
| 402 | token 无效或已过期 | `auth-token/token` 过期、签名错误、被挤下线等 |
|
||||
| 403 | 鉴权失败 | `secret` 错误、签名验证失败、时间戳无效等 |
|
||||
| 404 | 资源不存在 | 用户不存在等 |
|
||||
| 422 | 业务逻辑错误 | 余额不足、业务校验失败等 |
|
||||
| 500 | 服务器内部错误 | 服务端异常或配置缺失 |
|
||||
|
||||
---
|
||||
|
||||
## 6. 联调建议
|
||||
|
||||
- **时间戳校验**:`/api/v1/authToken` 会校验 `time` 与服务器时间差(默认容忍 300 秒),请确保平台服务器时间同步。
|
||||
- **token 失效处理**:当 `code=402` 时,按业务类型重新获取 `auth-token` 或重新登录获取 `token`。
|
||||
- **语言**:如需英文提示,请在请求头带 `lang: en`。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>SaiAdmin</title>
|
||||
<title>Dafuweng-Dice</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
"eslint-plugin-vue": "^9.27.0",
|
||||
"globals": "^15.9.0",
|
||||
"husky": "^9.1.5",
|
||||
"iconv-lite": "^0.7.2",
|
||||
"lint-staged": "^15.5.2",
|
||||
"prettier": "^3.5.3",
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
|
||||
11
saiadmin-artd/pnpm-lock.yaml
generated
11
saiadmin-artd/pnpm-lock.yaml
generated
@@ -144,6 +144,9 @@ importers:
|
||||
husky:
|
||||
specifier: ^9.1.5
|
||||
version: 9.1.7
|
||||
iconv-lite:
|
||||
specifier: ^0.7.2
|
||||
version: 0.7.2
|
||||
lint-staged:
|
||||
specifier: ^15.5.2
|
||||
version: 15.5.2
|
||||
@@ -2549,6 +2552,10 @@ packages:
|
||||
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
iconv-lite@0.7.2:
|
||||
resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
ieee754@1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
|
||||
@@ -6767,6 +6774,10 @@ snapshots:
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
|
||||
iconv-lite@0.7.2:
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
|
||||
ieee754@1.2.1: {}
|
||||
|
||||
ignore@5.3.2: {}
|
||||
|
||||
@@ -1,31 +1,66 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 基础数据统计
|
||||
* 大富翁工作台卡片统计(玩家注册、充值、提现、游玩次数,含较上周对比)
|
||||
* @returns 响应
|
||||
*/
|
||||
export function fetchStatistics() {
|
||||
return request.get<any>({
|
||||
url: '/core/system/statistics'
|
||||
url: '/core/dice/dashboard/statistics'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录统计图表数据
|
||||
* 近期玩家充值统计(近10天每日充值金额)
|
||||
* @returns 响应
|
||||
*/
|
||||
export function fetchLoginChart() {
|
||||
export function fetchRechargeChart() {
|
||||
return request.get<any>({
|
||||
url: '/core/system/loginChart'
|
||||
url: '/core/dice/dashboard/rechargeChart'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录统计图表数据
|
||||
* 月度玩家充值汇总(当年1-12月每月充值金额)
|
||||
* @returns 响应
|
||||
*/
|
||||
export function fetchLoginBarChart() {
|
||||
export function fetchRechargeBarChart() {
|
||||
return request.get<any>({
|
||||
url: '/core/system/loginBarChart'
|
||||
url: '/core/dice/dashboard/rechargeBarChart'
|
||||
})
|
||||
}
|
||||
|
||||
/** 玩家充值记录项 */
|
||||
export interface WalletRecordItem {
|
||||
player_name: string
|
||||
coin: number
|
||||
create_time: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作台-玩家充值记录(最新50条)
|
||||
* @returns 列表
|
||||
*/
|
||||
export function fetchWalletRecordList() {
|
||||
return request.get<WalletRecordItem[]>({
|
||||
url: '/core/dice/dashboard/walletRecordList'
|
||||
})
|
||||
}
|
||||
|
||||
/** 新增玩家记录项 */
|
||||
export interface NewPlayerItem {
|
||||
name: string
|
||||
coin: number
|
||||
total_ticket_count: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作台-新增玩家记录(最新50条)
|
||||
* @returns 列表
|
||||
*/
|
||||
export function fetchNewPlayerList() {
|
||||
return request.get<NewPlayerItem[]>({
|
||||
url: '/core/dice/dashboard/newPlayerList'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// 数据配置
|
||||
data: () => [0, 0, 0, 0, 0, 0, 0],
|
||||
xAxisData: () => [],
|
||||
xAxisName: '',
|
||||
barWidth: '40%',
|
||||
stack: false,
|
||||
|
||||
@@ -124,24 +125,30 @@
|
||||
} = useChartComponent({
|
||||
props,
|
||||
checkEmpty: () => {
|
||||
// 检查单数据情况
|
||||
if (Array.isArray(props.data) && typeof props.data[0] === 'number') {
|
||||
if (!Array.isArray(props.data) || !props.data.length) return true
|
||||
|
||||
const first = props.data[0]
|
||||
// 单数据情况:number[] 或可转为数字的数组(兼容后端 int 返回为 string)
|
||||
if (typeof first === 'number' && !Number.isNaN(first)) {
|
||||
const singleData = props.data as number[]
|
||||
return !singleData.length || singleData.every((val) => val === 0)
|
||||
return singleData.every((val) => val === 0 || Number.isNaN(Number(val)))
|
||||
}
|
||||
if (typeof first === 'string' && !Number.isNaN(Number(first))) {
|
||||
const singleData = props.data.map((v) => Number(v))
|
||||
return singleData.every((val) => val === 0 || Number.isNaN(val))
|
||||
}
|
||||
|
||||
// 检查多数据情况
|
||||
if (Array.isArray(props.data) && typeof props.data[0] === 'object') {
|
||||
// 多数据情况
|
||||
if (typeof first === 'object' && first !== null && 'name' in first) {
|
||||
const multiData = props.data as BarDataItem[]
|
||||
return (
|
||||
!multiData.length ||
|
||||
multiData.every((item) => !item.data?.length || item.data.every((val) => val === 0))
|
||||
return multiData.every(
|
||||
(item) => !item.data?.length || item.data.every((val) => val === 0 || Number.isNaN(Number(val)))
|
||||
)
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
watchSources: [() => props.data, () => props.xAxisData, () => props.colors],
|
||||
watchSources: [() => props.data, () => props.xAxisData, () => props.xAxisName, () => props.colors],
|
||||
generateOptions: (): EChartsOption => {
|
||||
const options: EChartsOption = {
|
||||
grid: getGridWithLegend(props.showLegend && isMultipleData.value, props.legendPosition, {
|
||||
@@ -152,6 +159,9 @@
|
||||
tooltip: props.showTooltip ? getTooltipStyle() : undefined,
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
name: props.xAxisName || undefined,
|
||||
nameLocation: 'middle',
|
||||
nameGap: 25,
|
||||
data: props.xAxisData,
|
||||
axisTick: getAxisTickStyle(),
|
||||
axisLine: getAxisLineStyle(props.showAxisLine),
|
||||
|
||||
@@ -117,7 +117,8 @@
|
||||
right: 0,
|
||||
left: 0,
|
||||
bottom: 0, // 增加底部间距
|
||||
containLabel: true
|
||||
outerBoundsMode: 'same' as const,
|
||||
outerBoundsContain: 'axisLabel' as const
|
||||
}
|
||||
|
||||
const options: EChartsOption = {
|
||||
|
||||
@@ -75,7 +75,8 @@
|
||||
right: 20,
|
||||
bottom: props.showDataZoom ? 80 : 20,
|
||||
left: 20,
|
||||
containLabel: true
|
||||
outerBoundsMode: 'same',
|
||||
outerBoundsContain: 'axisLabel'
|
||||
},
|
||||
tooltip: getTooltipStyle('axis', {
|
||||
axisPointer: {
|
||||
|
||||
@@ -64,7 +64,8 @@
|
||||
right: 20,
|
||||
bottom: 20,
|
||||
left: 20,
|
||||
containLabel: true
|
||||
outerBoundsMode: 'same',
|
||||
outerBoundsContain: 'axisLabel'
|
||||
},
|
||||
tooltip: props.showTooltip
|
||||
? getTooltipStyle('item', {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
>
|
||||
<span
|
||||
class="block max-w-46 overflow-hidden text-ellipsis whitespace-nowrap px-1.5 text-sm text-g-600 dark:text-g-800"
|
||||
>{{ formatMenuTitle(item.meta?.title as string) }}</span
|
||||
>{{ formatMenuTitle(item.meta?.title as string, item.path) }}</span
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
@click="searchGoPage(item)"
|
||||
@mouseenter="highlightOnHover(index)"
|
||||
>
|
||||
{{ formatMenuTitle(item.meta.title) }}
|
||||
{{ formatMenuTitle(item.meta.title, item.path) }}
|
||||
<ArtSvgIcon v-show="isHighlighted(index)" icon="fluent:arrow-enter-left-20-filled" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,7 +60,7 @@
|
||||
@click="searchGoPage(item)"
|
||||
@mouseenter="highlightOnHoverHistory(index)"
|
||||
>
|
||||
{{ formatMenuTitle(item.meta.title) }}
|
||||
{{ formatMenuTitle(item.meta.title, item.path) }}
|
||||
<div
|
||||
class="size-5 selected-icon select-none rounded-full text-g-500 flex-cc c-p"
|
||||
@click.stop="deleteHistory(index)"
|
||||
@@ -182,7 +182,7 @@
|
||||
const flattenAndMatch = (item: AppRouteRecord) => {
|
||||
if (item.meta?.isHide) return
|
||||
|
||||
const lowerItemTitle = formatMenuTitle(item.meta.title).toLowerCase()
|
||||
const lowerItemTitle = formatMenuTitle(item.meta.title, item.path).toLowerCase()
|
||||
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(flattenAndMatch)
|
||||
|
||||
@@ -178,6 +178,7 @@
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
import AppConfig from '@/config'
|
||||
import { languageOptions } from '@/locales'
|
||||
import { invalidatePageLocaleCache, loadPageLocale } from '@/locales/pageLocaleLoader'
|
||||
import { mittBus } from '@/utils/sys'
|
||||
import { themeAnimation } from '@/utils/ui/animation'
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
@@ -284,11 +285,12 @@
|
||||
* 切换系统语言
|
||||
* @param {LanguageEnum} lang - 目标语言类型
|
||||
*/
|
||||
const changeLanguage = (lang: LanguageEnum): void => {
|
||||
const changeLanguage = async (lang: LanguageEnum): Promise<void> => {
|
||||
if (locale.value === lang) return
|
||||
locale.value = lang
|
||||
userStore.setLanguage(lang)
|
||||
reload(50)
|
||||
invalidatePageLocaleCache()
|
||||
await loadPageLocale(router.currentRoute.value.path)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</li>
|
||||
<li class="btn-item" @click="clearCache()">
|
||||
<ArtSvgIcon icon="ri:eraser-line" />
|
||||
<span>清除缓存</span>
|
||||
<span>{{ $t('topBar.user.clearCache') }}</span>
|
||||
</li>
|
||||
<li class="btn-item" @click="lockScreen()">
|
||||
<ArtSvgIcon icon="ri:lock-line" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ElSubMenu v-if="hasChildren" :index="item.path || item.meta.title" class="!p-0">
|
||||
<template #title>
|
||||
<ArtSvgIcon :icon="item.meta.icon" :color="theme?.iconColor" class="mr-1 text-lg" />
|
||||
<span class="text-md">{{ formatMenuTitle(item.meta.title) }}</span>
|
||||
<span class="text-md">{{ formatMenuTitle(item.meta.title, item.path) }}</span>
|
||||
<div v-if="item.meta.showBadge" class="art-badge art-badge-horizontal" />
|
||||
<div v-if="item.meta.showTextBadge" class="art-text-badge">
|
||||
{{ item.meta.showTextBadge }}
|
||||
@@ -32,7 +32,7 @@
|
||||
class="mr-1 text-lg"
|
||||
:style="{ color: theme.iconColor }"
|
||||
/>
|
||||
<span class="text-md">{{ formatMenuTitle(item.meta.title) }}</span>
|
||||
<span class="text-md">{{ formatMenuTitle(item.meta.title, item.path) }}</span>
|
||||
<div
|
||||
v-if="item.meta.showBadge"
|
||||
class="art-badge"
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
return props.list.map((item) => ({
|
||||
...item,
|
||||
isActive: isMenuItemActive(item),
|
||||
formattedTitle: formatMenuTitle(item.meta.title)
|
||||
formattedTitle: formatMenuTitle(item.meta.title, item.path)
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<ElTooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:content="$t(menu.meta.title)"
|
||||
:content="formatMenuTitle(menu.meta.title, menu.path)"
|
||||
placement="right"
|
||||
:offset="15"
|
||||
:hide-after="0"
|
||||
@@ -43,7 +43,7 @@
|
||||
}"
|
||||
/>
|
||||
<span v-if="dualMenuShowText" class="text-md text-g-700">
|
||||
{{ $t(menu.meta.title) }}
|
||||
{{ formatMenuTitle(menu.meta.title, menu.path) }}
|
||||
</span>
|
||||
<div v-if="menu.meta.showBadge" class="art-badge art-badge-dual" />
|
||||
</div>
|
||||
@@ -136,6 +136,7 @@
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
import { isIframe } from '@/utils/navigation'
|
||||
import { handleMenuJump } from '@/utils/navigation'
|
||||
import { formatMenuTitle } from '@/utils/router'
|
||||
import SidebarSubmenu from './widget/SidebarSubmenu.vue'
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
import { useWindowSize, useTimeoutFn } from '@vueuse/core'
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/>
|
||||
</div>
|
||||
<span class="menu-name">
|
||||
{{ formatMenuTitle(item.meta.title) }}
|
||||
{{ formatMenuTitle(item.meta.title, item.path) }}
|
||||
</span>
|
||||
<div v-if="item.meta.showBadge" class="art-badge" style="right: 10px" />
|
||||
</template>
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<template #title>
|
||||
<span class="menu-name">
|
||||
{{ formatMenuTitle(item.meta.title) }}
|
||||
{{ formatMenuTitle(item.meta.title, item.path) }}
|
||||
</span>
|
||||
<div v-if="item.meta.showBadge" class="art-badge" />
|
||||
<div v-if="item.meta.showTextBadge && (level > 0 || menuOpen)" class="art-text-badge">
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
class="text-base mr-1 group-hover:text-theme"
|
||||
:class="item.path === activeTab ? 'text-theme' : 'text-g-600'"
|
||||
/>
|
||||
{{ item.customTitle || formatMenuTitle(item.title) }}
|
||||
{{ item.customTitle || formatMenuTitle(item.title, item.path) }}
|
||||
<span
|
||||
v-if="list.length > 1 && !item.fixedTab"
|
||||
class="inline-flex flex-cc relative ml-0.5 p-1 rounded-full tad-200 hover:bg-g-200"
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
:disabled="item.disabled"
|
||||
class="flex-1 min-w-0 [&_.el-checkbox__label]:overflow-hidden [&_.el-checkbox__label]:text-ellipsis [&_.el-checkbox__label]:whitespace-nowrap"
|
||||
>{{
|
||||
item.label || (item.type === 'selection' ? t('table.selection') : '')
|
||||
getColumnDisplayLabel(item.label, item.type)
|
||||
}}</ElCheckbox
|
||||
>
|
||||
</div>
|
||||
@@ -173,6 +173,15 @@
|
||||
(e: 'update:showSearchBar', value: boolean): void
|
||||
}>()
|
||||
|
||||
/** 列标题显示:table./page. 开头的 key 用 t() 翻译,随语言切换更新 */
|
||||
const getColumnDisplayLabel = (label: unknown, type?: string): string => {
|
||||
if (type === 'selection') return t('table.selection')
|
||||
if (label && typeof label === 'string' && (label.startsWith('table.') || label.startsWith('page.'))) {
|
||||
return t(label)
|
||||
}
|
||||
return (label as string) || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列的显示状态
|
||||
* 优先使用 visible 字段,如果不存在则使用 checked 字段
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
v-bind="{ ...$attrs, ...props, height, stripe, border, size, headerCellStyle }"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
<template v-for="col in columns" :key="col.prop || col.type">
|
||||
<template v-for="col in displayColumns" :key="col.prop || col.type">
|
||||
<!-- 渲染全局序号列 -->
|
||||
<ElTableColumn v-if="col.type === 'globalIndex'" v-bind="{ ...col }">
|
||||
<template #default="{ $index }">
|
||||
@@ -138,6 +138,7 @@
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
import { useTableHeight } from '@/hooks/core/useTableHeight'
|
||||
import { useResizeObserver, useWindowSize } from '@vueuse/core'
|
||||
import i18n, { $t } from '@/locales'
|
||||
|
||||
defineOptions({ name: 'ArtTable' })
|
||||
|
||||
@@ -307,6 +308,21 @@
|
||||
// 是否显示分页器
|
||||
const showPagination = computed(() => props.pagination && !isEmpty.value)
|
||||
|
||||
/** 表头 label 为 table. 或 page. 开头的 i18n key 时自动翻译,切换语言后表头随动 */
|
||||
const displayColumns = computed(() => {
|
||||
const list = props.columns || []
|
||||
const localeRef = i18n.global.locale as { value?: string }
|
||||
const currentLocale = localeRef && typeof localeRef === 'object' && 'value' in localeRef ? localeRef.value : (i18n.global.locale as string)
|
||||
void currentLocale
|
||||
return list.map((col) => {
|
||||
const label = col.label
|
||||
if (label && typeof label === 'string' && (label.startsWith('table.') || label.startsWith('page.'))) {
|
||||
return { ...col, label: $t(label) }
|
||||
}
|
||||
return col
|
||||
})
|
||||
})
|
||||
|
||||
// 清理列属性,移除插槽相关的自定义属性,确保它们不会被 ElTableColumn 错误解释
|
||||
const cleanColumnProps = (col: ColumnOption) => {
|
||||
const columnProps = { ...col }
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({ name: 'SaCheckbox', inheritAttrs: false })
|
||||
|
||||
@@ -69,6 +70,7 @@
|
||||
const modelValue = defineModel<(string | number)[]>()
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const { t, te, locale } = useI18n()
|
||||
|
||||
const canConvertToNumberStrict = (value: any) => {
|
||||
if (value == null) return false
|
||||
@@ -81,9 +83,20 @@
|
||||
}
|
||||
|
||||
const options = computed(() => {
|
||||
// 让字典选项在切换语言时可响应更新
|
||||
locale.value
|
||||
|
||||
const list = dictStore.getByCode(props.dict) || []
|
||||
|
||||
if (!props.valueType) return list
|
||||
if (!props.valueType) {
|
||||
return list.map((item) => {
|
||||
const key = `dict.${props.dict}.${item.value}`
|
||||
return {
|
||||
...item,
|
||||
label: te(key) ? t(key) : item.label
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return list.map((item) => {
|
||||
let newValue = item.value
|
||||
@@ -101,7 +114,11 @@
|
||||
|
||||
return {
|
||||
...item,
|
||||
value: newValue
|
||||
value: newValue,
|
||||
label: (() => {
|
||||
const key = `dict.${props.dict}.${newValue}`
|
||||
return te(key) ? t(key) : item.label
|
||||
})()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
:round="round"
|
||||
class="mr-1 last:mr-0"
|
||||
>
|
||||
{{ getData(item)?.label || item }}
|
||||
{{ getDisplayLabel(item) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span v-for="(item, index) in normalizedValues" :key="index">
|
||||
{{ getData(item)?.label || item }}{{ index < normalizedValues.length - 1 ? '、' : '' }}
|
||||
{{ getDisplayLabel(item) }}{{ index < normalizedValues.length - 1 ? '、' : '' }}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({ name: 'SaDict' })
|
||||
|
||||
@@ -50,6 +51,7 @@
|
||||
})
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const { t, te, locale } = useI18n()
|
||||
|
||||
// 统一处理 value,转换为数组格式
|
||||
const normalizedValues = computed(() => {
|
||||
@@ -64,6 +66,16 @@
|
||||
// 根据值获取字典数据
|
||||
const getData = (value: string) => dictStore.getDataByValue(props.dict, value)
|
||||
|
||||
const getDisplayLabel = (value: string) => {
|
||||
// 让显示在切换语言时可响应更新
|
||||
locale.value
|
||||
|
||||
const key = `dict.${props.dict}.${value}`
|
||||
if (te(key)) return t(key)
|
||||
|
||||
return getData(value)?.label || value
|
||||
}
|
||||
|
||||
const getColor = (color: string | undefined, type: 'bg' | 'border' | 'text') => {
|
||||
// 如果没有指定颜色,使用默认主色调
|
||||
if (!color) {
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({ name: 'SaRadio', inheritAttrs: false })
|
||||
|
||||
@@ -82,6 +83,7 @@
|
||||
const modelValue = defineModel<string | number | undefined>()
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const { t, te, locale } = useI18n()
|
||||
|
||||
// 判断能否转成数字
|
||||
const canConvertToNumberStrict = (value: any) => {
|
||||
@@ -97,10 +99,21 @@
|
||||
|
||||
// 核心逻辑:在 computed 中处理数据类型转换
|
||||
const options = computed(() => {
|
||||
// 让字典选项在切换语言时可响应更新
|
||||
locale.value
|
||||
|
||||
const list = dictStore.getByCode(props.dict) || []
|
||||
|
||||
// 如果没有指定 valueType,直接返回原始字典
|
||||
if (!props.valueType) return list
|
||||
if (!props.valueType) {
|
||||
return list.map((item) => {
|
||||
const key = `dict.${props.dict}.${item.value}`
|
||||
return {
|
||||
...item,
|
||||
label: te(key) ? t(key) : item.label
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 如果指定了类型,进行映射转换
|
||||
return list.map((item) => {
|
||||
@@ -119,7 +132,11 @@
|
||||
|
||||
return {
|
||||
...item,
|
||||
value: newValue
|
||||
value: newValue,
|
||||
label: (() => {
|
||||
const key = `dict.${props.dict}.${newValue}`
|
||||
return te(key) ? t(key) : item.label
|
||||
})()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({ name: 'SaSelect', inheritAttrs: false })
|
||||
|
||||
@@ -75,6 +76,7 @@
|
||||
const modelValue = defineModel<string | number | Array<string | number>>()
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const { t, te, locale } = useI18n()
|
||||
|
||||
// 判断能否转成数字
|
||||
const canConvertToNumberStrict = (value: any) => {
|
||||
@@ -90,10 +92,21 @@
|
||||
|
||||
// 计算属性:获取字典数据并处理类型转换
|
||||
const options = computed(() => {
|
||||
// 让字典选项在切换语言时可响应更新
|
||||
locale.value
|
||||
|
||||
const list = dictStore.getByCode(props.dict) || []
|
||||
|
||||
// 1. 如果没有指定 valueType,直接返回
|
||||
if (!props.valueType) return list
|
||||
if (!props.valueType) {
|
||||
return list.map((item) => {
|
||||
const key = `dict.${props.dict}.${item.value}`
|
||||
return {
|
||||
...item,
|
||||
label: te(key) ? t(key) : item.label
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 2. 如果指定了类型,进行映射转换
|
||||
return list.map((item) => {
|
||||
@@ -111,7 +124,11 @@
|
||||
|
||||
return {
|
||||
...item,
|
||||
value: newValue
|
||||
value: newValue,
|
||||
label: (() => {
|
||||
const key = `dict.${props.dict}.${newValue}`
|
||||
return te(key) ? t(key) : item.label
|
||||
})()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@ import { headerBarConfig } from './modules/headerBar'
|
||||
const appConfig: SystemConfig = {
|
||||
// 系统信息
|
||||
systemInfo: {
|
||||
name: 'SaiAdmin' // 系统名称
|
||||
name: 'Dafuweng-Dice' // 系统名称
|
||||
},
|
||||
// 系统主题
|
||||
systemThemeStyles: {
|
||||
|
||||
@@ -345,7 +345,9 @@ export function useChart(options: UseChartOptions = {}) {
|
||||
right: 15,
|
||||
bottom: 8,
|
||||
left: 0,
|
||||
containLabel: true,
|
||||
// ECharts 6:替代已弃用的 containLabel(需配合 outerBounds 布局,避免控制台告警)
|
||||
outerBoundsMode: 'same' as const,
|
||||
outerBoundsContain: 'axisLabel' as const,
|
||||
...baseGrid
|
||||
}
|
||||
|
||||
|
||||
42
saiadmin-artd/src/locales/langs/README.md
Normal file
42
saiadmin-artd/src/locales/langs/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# 多语言文件说明
|
||||
|
||||
## 全局翻译(所有页面共用)
|
||||
|
||||
- `zh.json`、`en.json`:放在 `langs/` 根目录,包含菜单、公共表格操作(删除/添加/选择/操作/刷新等)、公共搜索栏(查询/重置/展开/收起、请输入/请选择、全部/启用/禁用等)、以及非页面级的文案(httpMsg、topBar、common、setting、login 等)。
|
||||
|
||||
## 页面级翻译(按路由加载)
|
||||
|
||||
路径规则:`langs/{语言}/{目录名}/{菜单名}.json`
|
||||
|
||||
示例:路由 `/dice/lottery_pool_config/index` 对应:
|
||||
|
||||
- 中文:`langs/zh/dice/lottery_pool_config.json`
|
||||
- 英文:`langs/en/dice/lottery_pool_config.json`
|
||||
|
||||
### 单文件结构
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "名称",
|
||||
"search": {
|
||||
"字段或占位 key": "中文文案"
|
||||
},
|
||||
"table": {
|
||||
"列 key": "表头中文文案"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- 顶层字段(如 `name`):该页面用到的通用字段标签,在搜索或表格中通过 `$t('page.name')` 使用。
|
||||
- `search`:搜索栏专用,如 `$t('page.search.poolType')`、`$t('page.search.placeholderName')`。
|
||||
- `table`:表格列头专用,如 `$t('page.table.poolType')`;列配置里 `label: 'page.table.xxx'` 会由表格组件自动翻译。
|
||||
|
||||
### 使用方式
|
||||
|
||||
- 搜索栏:`$t('page.name')`、`$t('page.search.xxx')`。
|
||||
- 表格列:`label: 'page.table.xxx'`(art-table 会自动对 `page.` 开头的 label 做 `$t`)。
|
||||
- 公共操作(删除、新增、操作等):继续使用 `$t('table.actions.xxx')`,来自全局 `zh.json` / `en.json`。
|
||||
|
||||
### 加载逻辑
|
||||
|
||||
- 进入某路由时,`pageLocaleLoader` 根据 path 解析出 `目录名/菜单名`,动态加载对应语言的 json 并合并到 i18n 的 `page` 命名空间;切换语言会清空缓存,下次进入或刷新后加载新语言文件。
|
||||
@@ -22,6 +22,7 @@
|
||||
"userCenter": "User center",
|
||||
"docs": "Document",
|
||||
"github": "Github",
|
||||
"clearCache": "clear Cache",
|
||||
"lockScreen": "Lock screen",
|
||||
"logout": "Log out"
|
||||
},
|
||||
@@ -38,6 +39,25 @@
|
||||
"confirm": "Confirm",
|
||||
"logOutTips": "Do you want to log out?"
|
||||
},
|
||||
"form": {
|
||||
"placeholderInput": "Please enter",
|
||||
"placeholderSelect": "Please select",
|
||||
"labelRemark": "Remark",
|
||||
"labelStatus": "Status",
|
||||
"labelName": "Name",
|
||||
"close": "Close"
|
||||
},
|
||||
"dict": {
|
||||
"data_status": {
|
||||
"1": "Normal",
|
||||
"2": "Disabled"
|
||||
},
|
||||
"gender": {
|
||||
"1": "Male",
|
||||
"2": "Female",
|
||||
"3": "Unknown"
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "Search page",
|
||||
"historyTitle": "Search history",
|
||||
@@ -150,8 +170,8 @@
|
||||
},
|
||||
"login": {
|
||||
"leftView": {
|
||||
"title": "A backend system of beauty and efficiency",
|
||||
"subTitle": "A sleek and practical interface for a great user experience"
|
||||
"title": "Monopoly Game Management",
|
||||
"subTitle": "Monopoly Game Management"
|
||||
},
|
||||
"title": "Welcome back",
|
||||
"subTitle": "Please enter your account and password to login",
|
||||
@@ -230,6 +250,56 @@
|
||||
"500": "Sorry, there was an error on the server",
|
||||
"gohome": "Go Home"
|
||||
},
|
||||
"console": {
|
||||
"card": {
|
||||
"playerRegister": "Player Register",
|
||||
"playerCharge": "Player Charge",
|
||||
"playerWithdraw": "Player Withdraw",
|
||||
"playerPlayCount": "Player Play Count",
|
||||
"vsLastWeek": "vs Last Week"
|
||||
},
|
||||
"newPlayer": {
|
||||
"title": "New Players",
|
||||
"subtitle": "Latest 50 new player records",
|
||||
"player": "Player",
|
||||
"balance": "Balance",
|
||||
"ticket": "Tickets"
|
||||
},
|
||||
"walletRecord": {
|
||||
"title": "Player Charge Records",
|
||||
"subtitle": "Latest 50 charge records",
|
||||
"player": "Player",
|
||||
"chargeAmount": "Amount",
|
||||
"chargeTime": "Charge Time"
|
||||
},
|
||||
"salesOverview": {
|
||||
"title": "Recent Player Charge Stats"
|
||||
},
|
||||
"activeUser": {
|
||||
"title": "Monthly Player Charge Summary"
|
||||
},
|
||||
"todo": {
|
||||
"title": "To Do",
|
||||
"pending": "Pending"
|
||||
},
|
||||
"newUser": {
|
||||
"title": "New Users",
|
||||
"growth": "Growth this month",
|
||||
"thisMonth": "This Month",
|
||||
"lastMonth": "Last Month",
|
||||
"thisYear": "This Year",
|
||||
"avatar": "Avatar",
|
||||
"region": "Region",
|
||||
"gender": "Gender",
|
||||
"progress": "Progress",
|
||||
"male": "Male",
|
||||
"female": "Female"
|
||||
},
|
||||
"dynamic": {
|
||||
"title": "Activity",
|
||||
"newCount": "New"
|
||||
}
|
||||
},
|
||||
"menus": {
|
||||
"login": {
|
||||
"title": "Login"
|
||||
@@ -245,7 +315,11 @@
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Dashboard",
|
||||
"console": "Console"
|
||||
"console": "Console",
|
||||
"userCenter": "User Center"
|
||||
},
|
||||
"userCenter": {
|
||||
"title": "User Center"
|
||||
},
|
||||
"result": {
|
||||
"title": "Result Page",
|
||||
@@ -259,11 +333,43 @@
|
||||
"serverError": "500"
|
||||
},
|
||||
"system": {
|
||||
"title": "System Settings",
|
||||
"user": "User Manage",
|
||||
"role": "Role Manage",
|
||||
"title": "System Management",
|
||||
"user": "User Management",
|
||||
"role": "Role Management",
|
||||
"userCenter": "User Center",
|
||||
"menu": "Menu Manage"
|
||||
"menu": "Menu Management",
|
||||
"dept": "Department Management",
|
||||
"post": "Post Management",
|
||||
"config": "System Config"
|
||||
},
|
||||
"safeguard": {
|
||||
"title": "Operations Management",
|
||||
"dict": "Data Dictionary",
|
||||
"server": "Server Monitor",
|
||||
"operLog": "Operation Log",
|
||||
"loginLog": "Login Log",
|
||||
"emailLog": "Email Log",
|
||||
"database": "Database",
|
||||
"cache": "Cache Management",
|
||||
"attachment": "Attachment"
|
||||
},
|
||||
"tool": {
|
||||
"title": "Development Tools",
|
||||
"crontab": "Crontab",
|
||||
"code": "Code Generator"
|
||||
},
|
||||
"dice": {
|
||||
"title": "Dice Game",
|
||||
"lotteryPoolConfig": "Lottery Tier Weight Config",
|
||||
"player": "Player Management",
|
||||
"playerWalletRecord": "Player Wallet Records",
|
||||
"playRecord": "Player Draw Records",
|
||||
"playerTicketRecord": "Player Ticket Records",
|
||||
"rewardConfig": "Reward Config",
|
||||
"reward": "Dice Point Weight Config",
|
||||
"rewardConfigRecord": "Dice Weight Test Records",
|
||||
"playRecordTest": "Draw Records (Test Weight)",
|
||||
"config": "Game Config"
|
||||
}
|
||||
},
|
||||
"table": {
|
||||
@@ -277,7 +383,54 @@
|
||||
"expand": "Expand",
|
||||
"collapse": "Collapse",
|
||||
"searchInputPlaceholder": "Please enter",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
"searchSelectPlaceholder": "Please select",
|
||||
"all": "All",
|
||||
"min": "Min",
|
||||
"max": "Max",
|
||||
"startTime": "Start Time",
|
||||
"endTime": "End Time",
|
||||
"placeholderUsername": "Username",
|
||||
"placeholderNickname": "Nickname",
|
||||
"placeholderPhone": "Phone",
|
||||
"placeholderPhoneFuzzy": "Phone (fuzzy)",
|
||||
"placeholderName": "Name",
|
||||
"placeholderGroup": "Group",
|
||||
"placeholderTitle": "Title",
|
||||
"placeholderConfigName": "Config Name",
|
||||
"placeholderTaskName": "Task Name",
|
||||
"placeholderTableName": "Table Name",
|
||||
"placeholderDataSource": "Data Source",
|
||||
"placeholderDeptName": "Dept Name",
|
||||
"placeholderDeptCode": "Dept Code",
|
||||
"placeholderRoleName": "Role Name",
|
||||
"placeholderRoleCode": "Role Code",
|
||||
"placeholderPostName": "Post Name",
|
||||
"placeholderPostCode": "Post Code",
|
||||
"placeholderMenuName": "Menu Name",
|
||||
"placeholderMenuRoute": "Menu Route",
|
||||
"placeholderOperator": "Operator",
|
||||
"placeholderOperRouter": "Route",
|
||||
"placeholderOperIp": "IP",
|
||||
"placeholderLoginUser": "Login User",
|
||||
"placeholderLoginIp": "Login IP",
|
||||
"placeholderLoginStatus": "Login Status",
|
||||
"labelFrom": "From",
|
||||
"labelTo": "To",
|
||||
"placeholderFrom": "From",
|
||||
"placeholderTo": "To",
|
||||
"placeholderSendStatus": "Send Status",
|
||||
"placeholderPoolType": "Pool Type",
|
||||
"usernameFuzzy": "Username (fuzzy)",
|
||||
"nameFuzzy": "Name (fuzzy)",
|
||||
"uiTextFuzzy": "UI Text (fuzzy)",
|
||||
"fuzzyQuery": "Fuzzy",
|
||||
"byUsername": "Search by username",
|
||||
"exactSearch": "Exact",
|
||||
"enable": "Enable",
|
||||
"disable": "Disable",
|
||||
"rangeSeparator": "To",
|
||||
"success": "Success",
|
||||
"failure": "Failure"
|
||||
},
|
||||
"selection": "Select",
|
||||
"sizeOptions": {
|
||||
@@ -290,6 +443,184 @@
|
||||
"expand": "Expand",
|
||||
"index": "Index"
|
||||
},
|
||||
"actions": {
|
||||
"add": "Add",
|
||||
"delete": "Delete",
|
||||
"edit": "Edit",
|
||||
"operation": "Operation",
|
||||
"refresh": "Refresh",
|
||||
"export": "Export",
|
||||
"import": "Import"
|
||||
},
|
||||
"columns": {
|
||||
"common": {
|
||||
"id": "ID",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time",
|
||||
"operation": "Operation",
|
||||
"remark": "Remark",
|
||||
"sort": "Sort",
|
||||
"name": "Name",
|
||||
"no": "No.",
|
||||
"description": "Description",
|
||||
"select": "Select"
|
||||
},
|
||||
"system": {
|
||||
"username": "Username",
|
||||
"phone": "Phone",
|
||||
"dept": "Department",
|
||||
"dashboard": "Dashboard",
|
||||
"loginTime": "Last Login",
|
||||
"agentId": "Agent ID",
|
||||
"postName": "Post Name",
|
||||
"postCode": "Post Code",
|
||||
"deptName": "Dept Name",
|
||||
"deptCode": "Dept Code",
|
||||
"leader": "Leader",
|
||||
"roleName": "Role Name",
|
||||
"roleCode": "Role Code",
|
||||
"level": "Level",
|
||||
"roleRemark": "Role Description",
|
||||
"menuName": "Menu Name",
|
||||
"menuType": "Menu Type",
|
||||
"icon": "Icon",
|
||||
"component": "Component",
|
||||
"route": "Route",
|
||||
"auth": "Auth",
|
||||
"configKey": "Config Key",
|
||||
"configTitle": "Config Title",
|
||||
"inputType": "Input Type",
|
||||
"configName": "Config Name",
|
||||
"group": "Group",
|
||||
"title": "Title",
|
||||
"titleEn": "Title (EN)",
|
||||
"value": "Value",
|
||||
"valueEn": "Value (EN)",
|
||||
"noParentDept": "No Parent Dept",
|
||||
"noParentMenu": "No Parent Menu",
|
||||
"input": "Input",
|
||||
"textarea": "Textarea",
|
||||
"select": "Select",
|
||||
"radio": "Radio",
|
||||
"uploadImage": "Image Upload",
|
||||
"uploadFile": "File Upload",
|
||||
"wangEditor": "Rich Editor",
|
||||
"createDate": "Create Date",
|
||||
"updateDate": "Update Date"
|
||||
},
|
||||
"safeguard": {
|
||||
"operator": "Operator",
|
||||
"serviceName": "Service",
|
||||
"router": "Route",
|
||||
"operIp": "IP",
|
||||
"operLocation": "Location",
|
||||
"operTime": "Time",
|
||||
"loginUser": "Login User",
|
||||
"loginStatus": "Login Status",
|
||||
"loginIp": "Login IP",
|
||||
"loginLocation": "Location",
|
||||
"os": "OS",
|
||||
"browser": "Browser",
|
||||
"tableName": "Table Name",
|
||||
"tableComment": "Table Comment",
|
||||
"engine": "Engine",
|
||||
"tableEngine": "Table Engine",
|
||||
"totalRows": "Total Rows",
|
||||
"fragmentSize": "Fragment Size",
|
||||
"dataSize": "Data Size",
|
||||
"collation": "Collation",
|
||||
"dictName": "Dict Name",
|
||||
"dictCode": "Dict Code",
|
||||
"dictLabel": "Dict Label",
|
||||
"dictValue": "Dict Value",
|
||||
"color": "Color",
|
||||
"preview": "Preview",
|
||||
"fileName": "File Name",
|
||||
"storageMode": "Storage",
|
||||
"fileType": "File Type",
|
||||
"fileSize": "File Size",
|
||||
"uploadTime": "Upload Time",
|
||||
"deleteTime": "Delete Time",
|
||||
"dataDetail": "Data Detail",
|
||||
"executeTime": "Execute Time",
|
||||
"target": "Target",
|
||||
"parameter": "Parameter",
|
||||
"executeStatus": "Status",
|
||||
"loginMessage": "Login Message",
|
||||
"loginTime": "Login Time",
|
||||
"gateway": "Gateway",
|
||||
"emailFrom": "From",
|
||||
"emailTo": "To",
|
||||
"emailCode": "Code",
|
||||
"emailResponse": "Response",
|
||||
"sendTime": "Send Time",
|
||||
"sendStatus": "Send Status"
|
||||
},
|
||||
"tool": {
|
||||
"taskName": "Task Name",
|
||||
"taskType": "Task Type",
|
||||
"rule": "Rule",
|
||||
"updateDate": "Update Date",
|
||||
"tableDesc": "Table Desc",
|
||||
"template": "Template",
|
||||
"namespace": "Namespace",
|
||||
"stub": "Stub",
|
||||
"tplCategory": "Gen Type",
|
||||
"topMenu": "Top Menu"
|
||||
},
|
||||
"dice": {
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
"rewardWinCoin": "Reward Win Coin",
|
||||
"direction": "Direction",
|
||||
"startIndex": "Start Index",
|
||||
"targetIndex": "Target Index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"user": "User",
|
||||
"coinChange": "Coin Change",
|
||||
"type": "Type",
|
||||
"operator": "Operator",
|
||||
"walletBefore": "Wallet Before",
|
||||
"walletAfter": "Wallet After",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"paidDraw": "Paid Draw",
|
||||
"freeDraw": "Free Draw",
|
||||
"platformProfit": "Platform Profit",
|
||||
"createdBy": "Created By",
|
||||
"rewardTier": "Reward Tier",
|
||||
"poolType": "Pool Type",
|
||||
"safetyLine": "Safety Line",
|
||||
"t1PoolWeight": "T1 Pool Weight",
|
||||
"t2PoolWeight": "T2 Pool Weight",
|
||||
"t3PoolWeight": "T3 Pool Weight",
|
||||
"t4PoolWeight": "T4 Pool Weight",
|
||||
"t5PoolWeight": "T5 Pool Weight",
|
||||
"endIndex": "End Index",
|
||||
"tier": "Tier",
|
||||
"dicePoints": "Dice Points",
|
||||
"displayText": "Display Text",
|
||||
"realEv": "Real EV",
|
||||
"weight": "Weight",
|
||||
"nickname": "Nickname",
|
||||
"coin": "Coin",
|
||||
"t1Weight": "T1 Weight",
|
||||
"t2Weight": "T2 Weight",
|
||||
"t3Weight": "T3 Weight",
|
||||
"t4Weight": "T4 Weight",
|
||||
"t5Weight": "T5 Weight",
|
||||
"playerUsername": "Player Username",
|
||||
"useCoins": "Use Coins"
|
||||
}
|
||||
},
|
||||
"zebra": "Zebra",
|
||||
"border": "Border",
|
||||
"headerBackground": "Header BG"
|
||||
|
||||
41
saiadmin-artd/src/locales/langs/en/dice/config.json
Normal file
41
saiadmin-artd/src/locales/langs/en/dice/config.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Dice Config",
|
||||
"dialogTitleEdit": "Edit Dice Config",
|
||||
"group": "Group",
|
||||
"placeholderGroup": "Please enter group",
|
||||
"title": "Title",
|
||||
"placeholderTitleZh": "Please enter title (ZH)",
|
||||
"titleEn": "Title (EN)",
|
||||
"placeholderTitleEn": "Please enter title (EN)",
|
||||
"configName": "Config Name",
|
||||
"placeholderConfigName": "Please enter config name",
|
||||
"value": "Value",
|
||||
"placeholderValueZh": "Please enter value (ZH)",
|
||||
"valueEn": "Value (EN)",
|
||||
"placeholderValueEn": "Please enter value (EN)",
|
||||
"ruleGroupRequired": "Group is required",
|
||||
"ruleTitleRequired": "Title is required",
|
||||
"ruleTitleEnMax": "Title (EN) max 255 characters",
|
||||
"ruleConfigNameRequired": "Config name is required",
|
||||
"ruleValueRequired": "Value is required",
|
||||
"saveSuccess": "Added",
|
||||
"updateSuccess": "Updated"
|
||||
},
|
||||
"search": {
|
||||
"group": "Group",
|
||||
"title": "Title",
|
||||
"configName": "Config Name",
|
||||
"placeholderGroup": "Please enter group",
|
||||
"placeholderTitle": "Please enter title",
|
||||
"placeholderConfigName": "Please enter config name"
|
||||
},
|
||||
"table": {
|
||||
"group": "Group",
|
||||
"title": "Title",
|
||||
"titleEn": "Title (EN)",
|
||||
"configName": "Config Name",
|
||||
"value": "Value",
|
||||
"valueEn": "Value (EN)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "Name",
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Lottery Pool Config",
|
||||
"dialogTitleEdit": "Edit Lottery Pool Config",
|
||||
"placeholderName": "Please enter name",
|
||||
"placeholderRemark": "Please enter remark",
|
||||
"poolType": "Pool Type",
|
||||
"placeholderPoolType": "Please select pool type",
|
||||
"poolTypeNormal": "Normal",
|
||||
"poolTypeKill": "Kill",
|
||||
"poolTypeT1": "T1 High",
|
||||
"safetyLine": "Safety Line",
|
||||
"t1Weight": "T1 Pool Weight (%)",
|
||||
"t2Weight": "T2 Pool Weight (%)",
|
||||
"t3Weight": "T3 Pool Weight (%)",
|
||||
"t4Weight": "T4 Pool Weight (%)",
|
||||
"t5Weight": "T5 Pool Weight (%)",
|
||||
"weightsSumHint": "Total pool weights: ",
|
||||
"weightsSumUnit": "% / 100% (must equal 100%)",
|
||||
"currentPoolTitle": "Current Lottery Pool",
|
||||
"loading": "Loading...",
|
||||
"poolName": "Pool Name",
|
||||
"playerProfit": "Player Total Profit (profit_amount):",
|
||||
"realtime": "Live",
|
||||
"profitCalcHint": "Sum of (win amount including BIGWIN minus 100 ticket cost) per round; refreshes every 2s while open.",
|
||||
"tierRuleTitle": "Tier Rule",
|
||||
"tierRuleContent": "When player profit in this pool is below safety line, use player T*_weight; when above or equal, use pool T*_weight (kill).",
|
||||
"killScoreWeights": "Kill weights",
|
||||
"killWeightNote": "(Kill weights from pool config type=1; edit in list.)",
|
||||
"btnResetProfit": "Reset Player Total Profit",
|
||||
"btnSaveSafetyLine": "Save Safety Line",
|
||||
"ruleSafetyLineRequired": "Please enter safety line",
|
||||
"msgGetPoolFailed": "Failed to get lottery pool",
|
||||
"msgSaveSuccess": "Save Success",
|
||||
"msgResetProfitSuccess": "Player total profit reset to 0",
|
||||
"msgResetFailed": "Reset failed",
|
||||
"ruleNameRequired": "Name is required",
|
||||
"rulePoolTypeRequired": "Please select pool type",
|
||||
"ruleT1Required": "T1 weight is required",
|
||||
"ruleT2Required": "T2 weight is required",
|
||||
"ruleT3Required": "T3 weight is required",
|
||||
"ruleT4Required": "T4 weight is required",
|
||||
"ruleT5Required": "T5 weight is required",
|
||||
"msgWeightsMust100": "Total pool weights must equal 100%",
|
||||
"msgAddSuccess": "Added",
|
||||
"msgUpdateSuccess": "Updated"
|
||||
},
|
||||
"toolbar": {
|
||||
"viewCurrentPool": "View Current Pool"
|
||||
},
|
||||
"search": {
|
||||
"poolType": "Pool Type",
|
||||
"placeholderName": "Please enter name",
|
||||
"placeholderPoolType": "Please select pool type",
|
||||
"poolTypeNormal": "Normal",
|
||||
"poolTypeKill": "Force Kill",
|
||||
"poolTypeT1": "T1 High Rate"
|
||||
},
|
||||
"table": {
|
||||
"name": "Name",
|
||||
"poolType": "Pool Type",
|
||||
"safetyLine": "Safety Line",
|
||||
"t1PoolWeight": "T1 Pool Weight",
|
||||
"t2PoolWeight": "T2 Pool Weight",
|
||||
"t3PoolWeight": "T3 Pool Weight",
|
||||
"t4PoolWeight": "T4 Pool Weight",
|
||||
"t5PoolWeight": "T5 Pool Weight"
|
||||
}
|
||||
}
|
||||
80
saiadmin-artd/src/locales/langs/en/dice/play_record.json
Normal file
80
saiadmin-artd/src/locales/langs/en/dice/play_record.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Play Record",
|
||||
"dialogTitleEdit": "Edit Play Record",
|
||||
"player": "Player",
|
||||
"placeholderPlayer": "Select player (by username)",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"placeholderLotteryPool": "Select lottery pool config",
|
||||
"drawType": "Draw Type",
|
||||
"paid": "Paid",
|
||||
"free": "Free",
|
||||
"isBigWin": "Big Win",
|
||||
"noBigWin": "No",
|
||||
"bigWin": "Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"placeholderWinCoin": "= Super + Reward",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
"placeholderSuperWinCoin": "On BIGWIN",
|
||||
"rewardWinCoin": "Reward Win Coin",
|
||||
"placeholderRewardWinCoin": "Dice reward",
|
||||
"direction": "Direction",
|
||||
"placeholderDirection": "Select direction",
|
||||
"clockwise": "Clockwise",
|
||||
"anticlockwise": "Anticlockwise",
|
||||
"startIndex": "Start Index",
|
||||
"placeholderStartIndex": "Start index",
|
||||
"targetIndex": "Target Index",
|
||||
"placeholderTargetIndex": "Target index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollArrayHint": "5 numbers, each 1–6",
|
||||
"rollNumber": "Roll Sum",
|
||||
"placeholderRollNumber": "Sum of 5 dice (5–30)",
|
||||
"rewardConfig": "Reward Config",
|
||||
"placeholderRewardConfig": "Select reward config (by UI text)",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully",
|
||||
"validateFailed": "Validation failed, please check required fields and format"
|
||||
},
|
||||
"toolbar": {
|
||||
"platformTotalProfit": "Platform Total Profit"
|
||||
},
|
||||
"search": {
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"isBigWin": "Is Big Win",
|
||||
"direction": "Direction",
|
||||
"winCoin": "Win Coin",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"rewardTier": "Reward Tier",
|
||||
"usernameFuzzy": "Username (fuzzy)",
|
||||
"nameFuzzy": "Name (fuzzy)",
|
||||
"uiTextFuzzy": "UI Text (fuzzy)",
|
||||
"paid": "Paid",
|
||||
"free": "Free",
|
||||
"noBigWin": "No",
|
||||
"bigWin": "Big Win",
|
||||
"clockwise": "Clockwise",
|
||||
"anticlockwise": "Anticlockwise"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
"rewardWinCoin": "Reward Win Coin",
|
||||
"direction": "Direction",
|
||||
"startIndex": "Start Index",
|
||||
"targetIndex": "Target Index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"clearAllData": "Clear All Data",
|
||||
"platformTotalProfit": "Platform Total Profit"
|
||||
},
|
||||
"search": {
|
||||
"drawType": "Draw Type",
|
||||
"direction": "Direction",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"rewardTier": "Reward Tier",
|
||||
"rollNumber": "Roll Number",
|
||||
"paid": "Paid",
|
||||
"free": "Free",
|
||||
"clockwise": "Clockwise",
|
||||
"anticlockwise": "Anticlockwise",
|
||||
"noBigWin": "No",
|
||||
"bigWin": "Big Win"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
"rewardWinCoin": "Reward Win Coin",
|
||||
"direction": "Direction",
|
||||
"startIndex": "Start Index",
|
||||
"targetIndex": "Target Index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Player Draw Record (Test)",
|
||||
"titleEdit": "Edit Player Draw Record (Test)",
|
||||
"labelLotteryConfigId": "Lottery Config ID",
|
||||
"placeholderLotteryConfigId": "Please enter lottery config id",
|
||||
"placeholderWinCoin": "Win coin",
|
||||
"placeholderRewardTier": "Please select tier (will auto fill reward config id)",
|
||||
"rewardConfigId": "Reward Config ID",
|
||||
"placeholderRewardConfigId": "Auto fill by tier or enter manually",
|
||||
"placeholderStartIndex": "Please enter start index",
|
||||
"labelTargetIndex": "Target Index",
|
||||
"placeholderTargetIndex": "Please enter target index",
|
||||
"placeholderRollNumber": "Please enter roll number",
|
||||
"labelRollArray": "Roll Array [1,2,3,4,5,6]",
|
||||
"placeholderRollArray": "Please enter roll array [1,2,3,4,5,6]",
|
||||
"labelStatus": "Status (0=fail, 1=success)",
|
||||
"placeholderSuperWinCoin": "Please enter super win coin",
|
||||
"placeholderRewardWinCoin": "Please enter reward win coin",
|
||||
"labelAdminId": "Admin ID",
|
||||
"placeholderAdminId": "Please enter admin id",
|
||||
"ruleLotteryConfigIdRequired": "Lottery config id is required",
|
||||
"ruleDrawTypeRequired": "Draw type is required",
|
||||
"ruleIsBigWinRequired": "Is big win is required",
|
||||
"ruleDirectionRequired": "Direction is required",
|
||||
"ruleRewardConfigIdRequired": "Reward config id is required",
|
||||
"ruleStatusRequired": "Status is required",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
80
saiadmin-artd/src/locales/langs/en/dice/player.json
Normal file
80
saiadmin-artd/src/locales/langs/en/dice/player.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "Name",
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Dice Player",
|
||||
"dialogTitleEdit": "Edit Dice Player",
|
||||
"username": "Username",
|
||||
"placeholderUsername": "Please enter username",
|
||||
"nickname": "Nickname",
|
||||
"placeholderNickname": "Please enter nickname",
|
||||
"phone": "Phone",
|
||||
"placeholderPhone": "Please enter phone",
|
||||
"password": "Password",
|
||||
"placeholderPasswordEdit": "Leave blank to keep unchanged",
|
||||
"status": "Status",
|
||||
"adminId": "Admin",
|
||||
"placeholderAdmin": "Select admin (optional)",
|
||||
"coin": "Coin",
|
||||
"placeholderCoinAdd": "Default 0 on create, read-only",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"placeholderLotteryPool": "Leave empty for custom weights below, or select pool",
|
||||
"currentConfig": "Current Config",
|
||||
"configLabelName": "Name",
|
||||
"configLabelType": "Type",
|
||||
"configLabelWeights": "T1–T5 Weights",
|
||||
"configLabelRemark": "Remark",
|
||||
"t1Weight": "T1 Pool Weight (%)",
|
||||
"t2Weight": "T2 Pool Weight (%)",
|
||||
"t3Weight": "T3 Pool Weight (%)",
|
||||
"t4Weight": "T4 Pool Weight (%)",
|
||||
"t5Weight": "T5 Pool Weight (%)",
|
||||
"weightsSumHint": "Total pool weights: ",
|
||||
"weightsSumUnit": "% / 100% (must equal 100%)",
|
||||
"ruleWeightsSumMustBe100": "Total pool weights must equal 100%",
|
||||
"walletTitle": "Player Wallet Operation",
|
||||
"walletPlayer": "Player",
|
||||
"walletBalance": "Balance",
|
||||
"operationType": "Operation Type",
|
||||
"typeAdd": "Add",
|
||||
"typeSub": "Deduct",
|
||||
"coinChange": "Coin Change",
|
||||
"placeholderCoinChange": "Positive; deduct cannot exceed balance",
|
||||
"placeholderRemarkOptional": "Optional",
|
||||
"ruleSelectType": "Please select operation type",
|
||||
"ruleEnterCoin": "Please enter coin change",
|
||||
"ruleCoinPositive": "Coin change must be greater than 0",
|
||||
"ruleDeductExceed": "Deduct cannot exceed current balance",
|
||||
"operateSuccess": "Success"
|
||||
},
|
||||
"search": {
|
||||
"username": "Username",
|
||||
"nickname": "Nickname",
|
||||
"phone": "Phone",
|
||||
"status": "Status",
|
||||
"coin": "Coin",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"placeholderUsername": "Please enter username",
|
||||
"placeholderNickname": "Please enter nickname",
|
||||
"placeholderPhoneFuzzy": "Phone (fuzzy)",
|
||||
"placeholderAll": "All",
|
||||
"exactSearch": "Exact"
|
||||
},
|
||||
"table": {
|
||||
"username": "Username",
|
||||
"phone": "Phone",
|
||||
"nickname": "Nickname",
|
||||
"status": "Status",
|
||||
"coin": "Coin",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"t1Weight": "T1 Weight",
|
||||
"t2Weight": "T2 Weight",
|
||||
"t3Weight": "T3 Weight",
|
||||
"t4Weight": "T4 Weight",
|
||||
"t5Weight": "T5 Weight",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Ticket Record",
|
||||
"dialogTitleEdit": "Edit Ticket Record",
|
||||
"player": "Player",
|
||||
"placeholderPlayer": "Select player (by username)",
|
||||
"useCoins": "Use Coins",
|
||||
"placeholderUseCoins": "Please enter use coins",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"placeholderPaidDrawCount": "Please enter paid draw count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"placeholderFreeDrawCount": "Please enter free draw count",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"placeholderTotalDrawCount": "Auto sum",
|
||||
"placeholderRemark": "Remark (required)",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"search": {
|
||||
"player": "Player",
|
||||
"useCoins": "Use Coins",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"createTime": "Create Time",
|
||||
"byUsername": "By username"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"playerUsername": "Player Username",
|
||||
"useCoins": "Use Coins",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"remark": "Remark",
|
||||
"createTime": "Create Time"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "Add Wallet Record",
|
||||
"dialogTitleEdit": "Edit Wallet Record",
|
||||
"user": "User",
|
||||
"placeholderUser": "Select user (by username)",
|
||||
"type": "Type",
|
||||
"placeholderType": "Please select type",
|
||||
"typeRecharge": "Recharge",
|
||||
"typeWithdraw": "Withdraw",
|
||||
"typeBuyTicket": "Buy Tickets",
|
||||
"typeAdminAdd": "Admin Add",
|
||||
"typeAdminSub": "Admin Deduct",
|
||||
"coinChange": "Coin Change",
|
||||
"placeholderCoinChange": "Positive add, negative subtract",
|
||||
"walletBefore": "Before",
|
||||
"placeholderWalletBefore": "Auto from selected user",
|
||||
"walletAfter": "After",
|
||||
"placeholderWalletAfter": "Auto calculated",
|
||||
"placeholderRemark": "Optional",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"search": {
|
||||
"type": "Type",
|
||||
"user": "User",
|
||||
"coin": "Coin",
|
||||
"createTime": "Create Time",
|
||||
"typeRecharge": "Recharge",
|
||||
"typeWithdraw": "Withdraw",
|
||||
"typeBuyTicket": "Buy Draw",
|
||||
"typeAdminAdd": "Admin Add",
|
||||
"typeAdminSub": "Admin Deduct",
|
||||
"byUsername": "By username"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"user": "User",
|
||||
"coinChange": "Coin Change",
|
||||
"type": "Type",
|
||||
"operator": "Operator",
|
||||
"walletBefore": "Wallet Before",
|
||||
"walletAfter": "Wallet After",
|
||||
"remark": "Remark",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
"createTime": "Create Time",
|
||||
"typeDraw": "Draw"
|
||||
}
|
||||
}
|
||||
84
saiadmin-artd/src/locales/langs/en/dice/reward.json
Normal file
84
saiadmin-artd/src/locales/langs/en/dice/reward.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"weightRatio": "Weight Ratio",
|
||||
"weightTest": "Test Weights"
|
||||
},
|
||||
"search": {
|
||||
"tier": "Tier",
|
||||
"clockwise": "Clockwise",
|
||||
"anticlockwise": "Counter-clockwise",
|
||||
"optionBigwin": "BIGWIN"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "Start Index",
|
||||
"endIndex": "End Index",
|
||||
"tier": "Tier",
|
||||
"dicePoints": "Dice Points",
|
||||
"displayText": "Display Text",
|
||||
"realEv": "Real EV",
|
||||
"remark": "Remark",
|
||||
"weight": "Weight"
|
||||
},
|
||||
"weightShared": {
|
||||
"xAxisEndIndex": "End Index",
|
||||
"xAxisGridNumber": "Points",
|
||||
"emptyTier": "No data for this tier",
|
||||
"sumLineDual": "Tier weight sum (clockwise): {cw}; counter-clockwise: {ccw} (each row 1–10000, ratio draw within tier, sum not limited)",
|
||||
"sumLineSingle": "Tier weight sum: {sum} (each row 1–10000, ratio draw within tier, sum not limited)",
|
||||
"t4t5NoteSingle": "T4 and T5 have a single outcome; no weight configuration.",
|
||||
"t4t5NoteDual": "T4 and T5 have a single outcome when hit; no weight configuration.",
|
||||
"colEndIndexId": "End Index (id)",
|
||||
"colGridNumber": "Points (grid_number)",
|
||||
"colDicePoints": "Dice Points",
|
||||
"colRealEv": "Real EV",
|
||||
"colUiText": "Display Text",
|
||||
"colRemark": "Remark",
|
||||
"colWeightCwDir": "Clockwise weight (direction=0)",
|
||||
"colWeightCcwDir": "Counter-clockwise weight (direction=1)",
|
||||
"weightColSuffix": "Weight (1-10000)",
|
||||
"fetchFail": "Failed to load weight data",
|
||||
"nothingToSubmit": "Nothing to submit",
|
||||
"submitFail": "Save failed",
|
||||
"btnCancel": "Cancel",
|
||||
"btnSubmit": "Submit",
|
||||
"saveSuccess": "Saved successfully"
|
||||
},
|
||||
"weightEdit": {
|
||||
"title": "Dice Reward (dice_reward) Weight Ratio",
|
||||
"globalTip": "You are editing weights on dice_reward (DiceReward), split by end_index into clockwise and counter-clockwise; the draw uses the set for the current direction."
|
||||
},
|
||||
"weightRatio": {
|
||||
"title": "Weight Ratio",
|
||||
"globalTip": "Configure dice_reward weights: first by direction (clockwise / counter-clockwise), then by tier (T1–T5); each row weight 1–10000, ratio draw within tier.",
|
||||
"tabClockwise": "Clockwise",
|
||||
"tabCounterclockwise": "Counter-clockwise"
|
||||
},
|
||||
"weightTest": {
|
||||
"title": "One-Click Weight Test",
|
||||
"alertTitle": "Bonus pool logic",
|
||||
"alertBody": "Same as playStart draw: uses name=default safety line and kill switch; when profit is below the line, paid tickets use player tier weights (custom below), free tickets use killScore; when profit reaches the line and kill is on, both use killScore.",
|
||||
"stepPaid": "Paid ticket",
|
||||
"stepFree": "Free ticket",
|
||||
"labelLotteryTypePaid": "Test pool type",
|
||||
"labelLotteryTypeFree": "Test pool type",
|
||||
"placeholderPaidPool": "Leave empty for custom tier odds below (default: default)",
|
||||
"placeholderFreePool": "Leave empty for custom tier odds below (default: killScore)",
|
||||
"tierProbHint": "Custom tier odds (T1–T5), each 0–100%, sum of five must not exceed 100%",
|
||||
"tierFieldLabel": "Tier {tier} (%)",
|
||||
"tierSumError": "Current sum of five tiers is {sum}%, cannot exceed 100%",
|
||||
"labelCwCount": "Clockwise spins",
|
||||
"labelCcwCount": "Counter-clockwise spins",
|
||||
"placeholderSelect": "Please select",
|
||||
"btnPrev": "Back",
|
||||
"btnNext": "Next",
|
||||
"btnStart": "Start test",
|
||||
"btnCancel": "Cancel",
|
||||
"warnTotalSpins": "At least one of paid/free direction spin counts must be greater than 0",
|
||||
"warnPaidTierSumPositive": "When no paid pool is selected, T1–T5 odds sum must be greater than 0",
|
||||
"warnPaidTierSumMax": "Paid T1–T5 odds sum cannot exceed 100%",
|
||||
"warnFreeTierSumPositive": "When no free pool is selected, T1–T5 odds sum must be greater than 0",
|
||||
"warnFreeTierSumMax": "Free T1–T5 odds sum cannot exceed 100%",
|
||||
"successCreated": "Test job created and will run in background. Check player draw records (test data) for results.",
|
||||
"failCreate": "Failed to create test job"
|
||||
}
|
||||
}
|
||||
119
saiadmin-artd/src/locales/langs/en/dice/reward_config.json
Normal file
119
saiadmin-artd/src/locales/langs/en/dice/reward_config.json
Normal file
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"gameRewardConfig": "Game Reward Config",
|
||||
"createRewardRef": "Create Reward Reference",
|
||||
"createRewardRefTitle": "Rule: start_index=config(grid_number).id; clockwise end_index=(start_index+grid_number)%26; counter-clockwise end_index=start_index-grid_number>=0?start_index-grid_number:26+start_index-grid_number"
|
||||
},
|
||||
"configPage": {
|
||||
"tabIndex": "Reward Index",
|
||||
"tabBigwin": "Big Win Weights",
|
||||
"tipIndex": "Dice points must be between 5 and 30 and unique in this table.",
|
||||
"tipBigwin": "Left to right: big-win points (read-only), display text, real EV, remark, weight (0~10000). Points 5 and 30 are fixed at 100%. This tab saves big-win weights only.",
|
||||
"colId": "Index (id)",
|
||||
"colDicePoints": "Dice Points",
|
||||
"colDisplayText": "Display Text",
|
||||
"colDisplayTextEn": "Display Text (EN)",
|
||||
"colRealEv": "Real Settlement",
|
||||
"colTier": "Tier",
|
||||
"colRemark": "Remark",
|
||||
"placeholderTierSelect": "Tier",
|
||||
"placeholderDisplayZh": "Display text (Chinese)",
|
||||
"placeholderDisplayEn": "Display text (English)",
|
||||
"placeholderRemark": "Remark",
|
||||
"btnSave": "Save",
|
||||
"btnReset": "Reset",
|
||||
"colBigwinPoints": "Big-Win Points",
|
||||
"colDisplayInfo": "Display Info",
|
||||
"colDisplayInfoEn": "Display Info (EN)",
|
||||
"colRealPrize": "Real Prize",
|
||||
"colWeightRange": "Weight (0-10000)",
|
||||
"placeholderDisplayInfoZh": "Display info (Chinese)",
|
||||
"placeholderDisplayInfoEn": "Display info (English)",
|
||||
"weightFixedTip": "Points 5 and 30 are fixed at 100%",
|
||||
"emptyBigwin": "No BIGWIN tier rows. Set tier to BIGWIN in the Reward Index tab first.",
|
||||
"confirmCreateRefTitle": "Create Reward Reference",
|
||||
"confirmCreateRefMsg": "Create reward reference by rule: start_index is the id of the cell for grid_number in reward config; clockwise end_index=(start_index+roll)%26; counter-clockwise end_index=start_index-roll if >=0 else 26+start_index-roll. Existing data will be cleared, then 26 points (5–30) for both directions will be generated. Continue?",
|
||||
"confirmCreateRefOk": "Create",
|
||||
"confirmCreateRefCancel": "Cancel",
|
||||
"createRefSuccess": "Created for 26 dice points (5–30), clockwise + counter-clockwise: clockwise added {cwNew}, counter-clockwise added {ccwNew}; clockwise updated {cwUp}, counter-clockwise updated {ccwUp}{skippedPart}",
|
||||
"createRefSuccessSkipped": "; {n} point(s) used fallback start index",
|
||||
"createRefSuccessSimple": "Created successfully",
|
||||
"createRefFail": "Failed to create reward reference",
|
||||
"loadIndexFail": "Failed to load reward index config",
|
||||
"saveSuccess": "Saved successfully",
|
||||
"saveFail": "Save failed",
|
||||
"resetIndexReloaded": "Reward index reloaded from server",
|
||||
"resetBigwinReloaded": "Big win weights reloaded from server",
|
||||
"warnNoIndexToSave": "No reward index rows to save",
|
||||
"warnGridRange": "Dice points must be between {min} and {max}",
|
||||
"dupJoiner": ", ",
|
||||
"warnDupGrid": "Duplicate dice points in this table: {list}",
|
||||
"warnNoBigwinToSave": "No BIGWIN rows to save",
|
||||
"warnBigwinDupGrid": "Duplicate big-win points in this table: {list}",
|
||||
"infoNoBigwin": "No BIGWIN rows. Set tier to BIGWIN in the Reward Index tab first."
|
||||
},
|
||||
"weightRatio": {
|
||||
"title": "T1–T5 Weight Ratio (Clockwise / Counter-clockwise)",
|
||||
"globalTip": "Weights come from dice_reward, split by end index (DiceRewardConfig.id) into clockwise and counter-clockwise; draw uses the weight set for the current direction.",
|
||||
"xAxisEndIndex": "End Index",
|
||||
"emptyTier": "No data for this tier",
|
||||
"sumLine": "Tier weight sum (clockwise): {cw}; counter-clockwise: {ccw} (each row 1–10000, ratio draw within tier, sum not limited)",
|
||||
"t4t5Note": "T4 and T5 have a single outcome; no weight configuration.",
|
||||
"colEndIndexId": "End Index (id)",
|
||||
"colDicePoints": "Dice Points",
|
||||
"colRealEv": "Real EV",
|
||||
"colUiText": "Display Text",
|
||||
"colWeightCw": "Clockwise weight (1-10000)",
|
||||
"colWeightCcw": "Counter-clockwise weight (1-10000)",
|
||||
"fetchFail": "Failed to load weight ratio data",
|
||||
"nothingToSubmit": "Nothing to submit",
|
||||
"submitFail": "Save failed",
|
||||
"saveSuccess": "Saved successfully"
|
||||
},
|
||||
"search": {
|
||||
"dicePoints": "Dice Points",
|
||||
"displayText": "Display Text",
|
||||
"realEv": "Real EV",
|
||||
"tier": "Tier",
|
||||
"fuzzyQuery": "Fuzzy"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "Start Index",
|
||||
"endIndex": "End Index",
|
||||
"tier": "Tier",
|
||||
"dicePoints": "Dice Points",
|
||||
"displayText": "Display Text",
|
||||
"realEv": "Real EV",
|
||||
"remark": "Remark",
|
||||
"weight": "Weight"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Reward Config",
|
||||
"titleEdit": "Edit Reward Config",
|
||||
"labelDicePoints": "Dice Points",
|
||||
"placeholderDicePoints": "Please enter dice points",
|
||||
"labelUiText": "Display Text",
|
||||
"placeholderUiText": "Please enter display text (Chinese)",
|
||||
"labelUiTextEn": "Display Text (EN)",
|
||||
"placeholderUiTextEn": "Please enter display text (English)",
|
||||
"labelRealEv": "Real EV",
|
||||
"placeholderRealEv": "Please enter real EV",
|
||||
"labelTier": "Tier",
|
||||
"placeholderTier": "Please select tier",
|
||||
"tierBigWin": "BIGWIN (Super Prize)",
|
||||
"labelBigWinWeight": "Big Win Weight",
|
||||
"placeholderBigWinWeight": "0~10000, 10000=100% win",
|
||||
"bigWinWeightDisabledTip": "For points 5 and 30, big win is guaranteed. Weight is fixed to 10000.",
|
||||
"bigWinWeightTip": "10000=100% win, 0=0% win; only effective for points 10/15/20/25",
|
||||
"labelRemark": "Remark",
|
||||
"placeholderRemark": "Please enter remark",
|
||||
"ruleDicePointsRequired": "Dice points is required",
|
||||
"ruleUiTextRequired": "Display text is required",
|
||||
"ruleUiTextEnMax": "Display text (EN) must be less than 255 characters",
|
||||
"ruleRealEvRequired": "Real EV is required",
|
||||
"ruleTierRequired": "Tier is required",
|
||||
"ruleBigWinWeightRange": "Big win weight must be between 0 and 10000",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"viewDetail": "View Detail"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"clockwiseAbbr": "CW",
|
||||
"counterclockwiseAbbr": "CCW",
|
||||
"status": "Status",
|
||||
"paidDraw": "Paid Draw",
|
||||
"freeDraw": "Free Draw",
|
||||
"platformProfit": "Platform Profit",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"createdBy": "Created By",
|
||||
"createTime": "Create Time",
|
||||
"statusFail": "Failed",
|
||||
"statusDone": "Done",
|
||||
"statusTesting": "Testing"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Reward Config Weight Test Record",
|
||||
"titleEdit": "Edit Reward Config Weight Test Record",
|
||||
"labelTestCount": "Test Count: 100/500/1000",
|
||||
"placeholderTestCount": "Please enter test count: 100/500/1000",
|
||||
"labelWeightSnapshot": "Weight Snapshot: save id,grid_number,tier,weight by tier",
|
||||
"placeholderWeightSnapshot": "Please enter weight snapshot: id,grid_number,tier,weight by tier",
|
||||
"labelResultCounts": "Result Counts: grid_number => count",
|
||||
"placeholderResultCounts": "Please enter result counts: grid_number => count",
|
||||
"ruleTestCountRequired": "Test count is required",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"detail": {
|
||||
"title": "Test Record Detail",
|
||||
"sectionBasic": "Basic Info",
|
||||
"recordId": "Record ID",
|
||||
"testCount": "Test count",
|
||||
"testCountSuffix": " runs",
|
||||
"createTime": "Created at",
|
||||
"admin": "Operator",
|
||||
"paidPoolId": "Paid lottery pool config ID",
|
||||
"freePoolId": "Free lottery pool config ID",
|
||||
"bigwinSnapshot": "BIGWIN weight snapshot",
|
||||
"sectionPaidTier": "Paid draw tier odds (T1–T5, used in test)",
|
||||
"sectionFreeTier": "Free draw tier odds (T1–T5, used in test)",
|
||||
"colTier": "Tier",
|
||||
"colWeight": "Weight",
|
||||
"colPercent": "Share",
|
||||
"emptyPaidTier": "No paid tier data (legacy records may only have tier_weights_snapshot)",
|
||||
"emptyFreeTier": "No free tier data",
|
||||
"sectionSnapshot": "Weight snapshot (T1–T5 / BIGWIN used in test)",
|
||||
"subCw": "Clockwise (non-BIGWIN)",
|
||||
"subCcw": "Counter-clockwise (non-BIGWIN)",
|
||||
"colGridNumber": "Dice points",
|
||||
"emptyCw": "No clockwise data",
|
||||
"emptyCcw": "No counter-clockwise data",
|
||||
"subBigwin": "BIGWIN (DiceRewardConfig snapshot)",
|
||||
"emptyBigwinTable": "No BIGWIN data",
|
||||
"sectionResult": "Landing stats (count per grid_number)",
|
||||
"chartXAxis": "Dice points (grid_number)",
|
||||
"emptyResult": "No landing data",
|
||||
"resultTotal": "Total landings: {n}",
|
||||
"btnImport": "Import to current config",
|
||||
"importTitle": "Import to production config",
|
||||
"importDesc": "Import this test record into DiceReward (cell weights), DiceRewardConfig (BIGWIN weight), and DiceLotteryPoolConfig (paid/free T1–T5 odds). Select target pools.",
|
||||
"importPaidLabel": "Import paid tier odds to pool",
|
||||
"importPaidPlaceholder": "Select a pool (paid pool recommended)",
|
||||
"importPaidTip": "If empty, uses paid pool ID saved on this record",
|
||||
"importFreeLabel": "Import free tier odds to pool",
|
||||
"importFreePlaceholder": "Select a pool (free pool recommended)",
|
||||
"importFreeTip": "If empty, uses free pool ID saved on this record",
|
||||
"btnConfirmImport": "Confirm import",
|
||||
"importSuccess": "Imported. DiceReward, DiceRewardConfig (BIGWIN), and pool config refreshed.",
|
||||
"importFail": "Import failed",
|
||||
"dash": "—",
|
||||
"dirCw": "Clockwise",
|
||||
"dirCcw": "Counter-clockwise"
|
||||
}
|
||||
}
|
||||
26
saiadmin-artd/src/locales/langs/en/safeguard/attachment.json
Normal file
26
saiadmin-artd/src/locales/langs/en/safeguard/attachment.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"search": {
|
||||
"username": "Username",
|
||||
"phone": "Phone",
|
||||
"status": "Status",
|
||||
"placeholderUsername": "Please enter username",
|
||||
"placeholderPhone": "Please enter phone",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"preview": "Preview",
|
||||
"fileName": "File Name",
|
||||
"storageMode": "Storage",
|
||||
"fileType": "File Type",
|
||||
"fileSize": "File Size",
|
||||
"uploadTime": "Upload Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add File",
|
||||
"titleEdit": "Edit File",
|
||||
"labelFileName": "File Name",
|
||||
"placeholderFileName": "Please enter file name",
|
||||
"ruleFileNameRequired": "Please enter file name",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
19
saiadmin-artd/src/locales/langs/en/safeguard/database.json
Normal file
19
saiadmin-artd/src/locales/langs/en/safeguard/database.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"search": {
|
||||
"tableName": "Table Name",
|
||||
"placeholderTableName": "Please enter table name"
|
||||
},
|
||||
"table": {
|
||||
"tableName": "Table Name",
|
||||
"tableComment": "Table Comment",
|
||||
"tableEngine": "Table Engine",
|
||||
"updateTime": "Update Time",
|
||||
"totalRows": "Total Rows",
|
||||
"fragmentSize": "Fragment Size",
|
||||
"dataSize": "Data Size",
|
||||
"collation": "Collation",
|
||||
"createTime": "Create Time",
|
||||
"deleteTime": "Delete Time",
|
||||
"dataDetail": "Data Detail"
|
||||
}
|
||||
}
|
||||
12
saiadmin-artd/src/locales/langs/en/safeguard/dict.json
Normal file
12
saiadmin-artd/src/locales/langs/en/safeguard/dict.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"table": {
|
||||
"select": "Select",
|
||||
"dictName": "Dict Name",
|
||||
"dictCode": "Dict Code",
|
||||
"dictLabel": "Dict Label",
|
||||
"dictValue": "Dict Value",
|
||||
"color": "Color",
|
||||
"sort": "Sort",
|
||||
"status": "Status"
|
||||
}
|
||||
}
|
||||
22
saiadmin-artd/src/locales/langs/en/safeguard/login-log.json
Normal file
22
saiadmin-artd/src/locales/langs/en/safeguard/login-log.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"search": {
|
||||
"loginUser": "Login User",
|
||||
"loginIp": "Login IP",
|
||||
"loginStatus": "Login Status",
|
||||
"operTime": "Time",
|
||||
"placeholderLoginUser": "Please enter login user",
|
||||
"placeholderLoginIp": "Please enter login IP",
|
||||
"placeholderLoginStatus": "Please select login status"
|
||||
},
|
||||
"table": {
|
||||
"no": "No.",
|
||||
"loginUser": "Login User",
|
||||
"loginStatus": "Login Status",
|
||||
"loginIp": "Login IP",
|
||||
"operLocation": "Location",
|
||||
"os": "OS",
|
||||
"browser": "Browser",
|
||||
"loginMessage": "Login Message",
|
||||
"loginTime": "Login Time"
|
||||
}
|
||||
}
|
||||
20
saiadmin-artd/src/locales/langs/en/safeguard/oper-log.json
Normal file
20
saiadmin-artd/src/locales/langs/en/safeguard/oper-log.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"search": {
|
||||
"operator": "Operator",
|
||||
"router": "Route",
|
||||
"operIp": "IP",
|
||||
"operTime": "Time",
|
||||
"placeholderOperator": "Please enter operator",
|
||||
"placeholderOperRouter": "Please enter route",
|
||||
"placeholderOperIp": "Please enter IP"
|
||||
},
|
||||
"table": {
|
||||
"no": "No.",
|
||||
"operator": "Operator",
|
||||
"serviceName": "Service",
|
||||
"router": "Route",
|
||||
"operIp": "IP",
|
||||
"operLocation": "Location",
|
||||
"operTime": "Time"
|
||||
}
|
||||
}
|
||||
15
saiadmin-artd/src/locales/langs/en/system/config.json
Normal file
15
saiadmin-artd/src/locales/langs/en/system/config.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"search": {
|
||||
"group": "Group",
|
||||
"title": "Title",
|
||||
"configName": "Config Name",
|
||||
"placeholderGroup": "Please enter group",
|
||||
"placeholderTitle": "Please enter title",
|
||||
"placeholderConfigName": "Please enter config name"
|
||||
},
|
||||
"table": {
|
||||
"select": "Select",
|
||||
"configName": "Config Name",
|
||||
"configKey": "Config Key"
|
||||
}
|
||||
}
|
||||
39
saiadmin-artd/src/locales/langs/en/system/dept.json
Normal file
39
saiadmin-artd/src/locales/langs/en/system/dept.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"search": {
|
||||
"deptName": "channel(Department) Name",
|
||||
"deptCode": "Dept Code",
|
||||
"status": "Status",
|
||||
"placeholderDeptName": "Please enter dept name",
|
||||
"placeholderDeptCode": "Please enter dept code",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"deptName": "channel(Department) Name",
|
||||
"deptCode": "Dept Code",
|
||||
"leader": "Leader",
|
||||
"sort": "Sort",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Department",
|
||||
"titleEdit": "Edit Department",
|
||||
"labelParentDept": "Parent Department",
|
||||
"labelDeptName": "Dept Name",
|
||||
"labelDeptCode": "Dept Code",
|
||||
"labelLeader": "Leader",
|
||||
"labelRemark": "Description",
|
||||
"labelSort": "Sort",
|
||||
"labelStatus": "Enabled",
|
||||
"placeholderDeptName": "Please enter dept name",
|
||||
"placeholderDeptCode": "Please enter dept code",
|
||||
"placeholderRemark": "Please enter description",
|
||||
"placeholderSort": "Please enter sort",
|
||||
"noParentDept": "No parent department",
|
||||
"ruleParentDeptRequired": "Please select parent department",
|
||||
"ruleDeptNameRequired": "Please enter dept name",
|
||||
"ruleDeptCodeRequired": "Please enter dept code",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
65
saiadmin-artd/src/locales/langs/en/system/menu.json
Normal file
65
saiadmin-artd/src/locales/langs/en/system/menu.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"search": {
|
||||
"menuName": "Menu Name",
|
||||
"route": "Route",
|
||||
"status": "Status",
|
||||
"placeholderMenuName": "Please enter menu name",
|
||||
"placeholderMenuRoute": "Please enter menu route",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"menuName": "Menu Name",
|
||||
"menuType": "Menu Type",
|
||||
"icon": "Icon",
|
||||
"route": "Route",
|
||||
"component": "Component",
|
||||
"auth": "Auth",
|
||||
"sort": "Sort",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Menu",
|
||||
"titleEdit": "Edit Menu",
|
||||
"labelMenuType": "Menu Type",
|
||||
"labelParentMenu": "Parent Menu",
|
||||
"labelMenuName": "Menu Name",
|
||||
"labelRoutePath": "Route Path",
|
||||
"labelRoutePathTip": "Top-level: absolute path starting with / (e.g. /dashboard). Sub-level: relative path (e.g. console, user).",
|
||||
"placeholderRoutePath": "e.g. /dashboard or console",
|
||||
"labelComponentName": "Component Name",
|
||||
"placeholderComponentName": "e.g. User",
|
||||
"labelComponentPath": "Component Path",
|
||||
"labelComponentPathTip": "Fill component path under views. For directory menu, leave empty.",
|
||||
"placeholderComponentPath": "e.g. /system/user or leave empty",
|
||||
"labelMenuIcon": "Menu Icon",
|
||||
"labelPermSlug": "Permission Slug",
|
||||
"placeholderPermSlug": "Please enter permission slug",
|
||||
"labelLinkUrl": "External Link",
|
||||
"placeholderLinkUrl": "e.g. https://saithink.top",
|
||||
"labelSort": "Sort",
|
||||
"labelSortTip": "Larger number comes first",
|
||||
"placeholderSort": "Please enter sort",
|
||||
"labelStatus": "Status",
|
||||
"labelStatusTip": "After disabled, this menu item will be unavailable",
|
||||
"labelIsIframe": "Embedded",
|
||||
"labelIsIframeTip": "Only effective in external link mode",
|
||||
"labelIsKeepAlive": "Keep Alive",
|
||||
"labelIsKeepAliveTip": "Switching tabs won't refresh",
|
||||
"labelIsHidden": "Hidden",
|
||||
"labelIsHiddenTip": "Hidden in menu but accessible via route",
|
||||
"labelIsFixedTab": "Fixed Tab",
|
||||
"labelIsFixedTabTip": "Fixed in tabs bar",
|
||||
"labelIsFullPage": "Full Page",
|
||||
"labelIsFullPageTip": "Do not inherit side menu and top bar",
|
||||
"noParentMenu": "No parent menu",
|
||||
"ruleParentMenuRequired": "Please select parent menu",
|
||||
"ruleMenuNameRequired": "Please enter menu name",
|
||||
"ruleRoutePathRequired": "Please enter route path",
|
||||
"ruleComponentNameRequired": "Please enter component name",
|
||||
"rulePermSlugRequired": "Please enter permission slug",
|
||||
"ruleLinkUrlRequired": "Please enter external link",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
34
saiadmin-artd/src/locales/langs/en/system/post.json
Normal file
34
saiadmin-artd/src/locales/langs/en/system/post.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"search": {
|
||||
"postName": "Post Name",
|
||||
"postCode": "Post Code",
|
||||
"status": "Status",
|
||||
"placeholderPostName": "Please enter post name",
|
||||
"placeholderPostCode": "Please enter post code",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"postName": "Post Name",
|
||||
"postCode": "Post Code",
|
||||
"sort": "Sort",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Post",
|
||||
"titleEdit": "Edit Post",
|
||||
"labelName": "Post Name",
|
||||
"labelCode": "Post Code",
|
||||
"labelRemark": "Description",
|
||||
"labelSort": "Sort",
|
||||
"labelStatus": "Enabled",
|
||||
"placeholderName": "Please enter post name",
|
||||
"placeholderCode": "Please enter post code",
|
||||
"placeholderRemark": "Please enter description",
|
||||
"placeholderSort": "Please enter sort",
|
||||
"ruleNameRequired": "Please enter post name",
|
||||
"ruleCodeRequired": "Please enter post code",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
38
saiadmin-artd/src/locales/langs/en/system/role.json
Normal file
38
saiadmin-artd/src/locales/langs/en/system/role.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"search": {
|
||||
"roleName": "Role Name",
|
||||
"roleCode": "Role Code",
|
||||
"status": "Status",
|
||||
"placeholderRoleName": "Please enter role name",
|
||||
"placeholderRoleCode": "Please enter role code",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"roleName": "Role Name",
|
||||
"roleCode": "Role Code",
|
||||
"level": "Level",
|
||||
"roleRemark": "Role Description",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Role",
|
||||
"titleEdit": "Edit Role",
|
||||
"labelName": "Role Name",
|
||||
"labelCode": "Role Code",
|
||||
"labelLevel": "Role Level",
|
||||
"levelTip": "Controls role permission level, cannot operate roles with higher level than your own",
|
||||
"labelRemark": "Description",
|
||||
"labelSort": "Sort",
|
||||
"labelStatus": "Enabled",
|
||||
"placeholderName": "Please enter role name",
|
||||
"placeholderCode": "Please enter role code",
|
||||
"placeholderRemark": "Please enter role description",
|
||||
"placeholderSort": "Please enter sort",
|
||||
"ruleNameRequired": "Please enter role name",
|
||||
"ruleCodeRequired": "Please enter role code",
|
||||
"ruleLevelRequired": "Please enter role level",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
51
saiadmin-artd/src/locales/langs/en/system/user.json
Normal file
51
saiadmin-artd/src/locales/langs/en/system/user.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"search": {
|
||||
"username": "Username",
|
||||
"phone": "Phone",
|
||||
"status": "Status",
|
||||
"placeholderUsername": "Please enter username",
|
||||
"placeholderPhone": "Please enter phone",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"username": "Username",
|
||||
"phone": "Phone",
|
||||
"dept": "Department",
|
||||
"dashboard": "Dashboard",
|
||||
"loginTime": "Last Login",
|
||||
"agentId": "Agent ID",
|
||||
"status": "Status",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add User",
|
||||
"titleEdit": "Edit User",
|
||||
"labelAvatar": "Avatar",
|
||||
"labelUsername": "Username",
|
||||
"labelRealname": "Real Name",
|
||||
"labelPassword": "Password",
|
||||
"labelPasswordConfirm": "Confirm Password",
|
||||
"labelEmail": "Email",
|
||||
"labelPhone": "Phone",
|
||||
"labelDept": "Department",
|
||||
"labelRole": "Role",
|
||||
"labelPost": "Post",
|
||||
"labelGender": "Gender",
|
||||
"labelStatus": "Status",
|
||||
"labelRemark": "Remark",
|
||||
"placeholderEmail": "Please enter email",
|
||||
"placeholderPhone": "Please enter phone",
|
||||
"placeholderRemark": "Please enter remark",
|
||||
"rulePasswordNotMatch": "Passwords do not match",
|
||||
"ruleUsernameRequired": "Please enter username",
|
||||
"ruleUsernameLength": "Length must be between 2 and 20 characters",
|
||||
"rulePasswordRequired": "Please enter password",
|
||||
"rulePasswordLength": "Length must be between 6 and 20 characters",
|
||||
"rulePasswordConfirmRequired": "Please enter confirm password",
|
||||
"ruleDeptRequired": "Please select department",
|
||||
"ruleRoleRequired": "Please select role",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
20
saiadmin-artd/src/locales/langs/en/tool/code.json
Normal file
20
saiadmin-artd/src/locales/langs/en/tool/code.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"search": {
|
||||
"tableName": "Table Name",
|
||||
"placeholderTableName": "Please enter table name",
|
||||
"placeholderDataSource": "Please enter data source"
|
||||
},
|
||||
"table": {
|
||||
"tableName": "Table Name",
|
||||
"tableDesc": "Table Desc",
|
||||
"tableComment": "Table Comment",
|
||||
"engine": "Engine",
|
||||
"collation": "Collation",
|
||||
"template": "Template",
|
||||
"namespace": "Namespace",
|
||||
"stub": "Stub",
|
||||
"tplCategory": "Gen Type",
|
||||
"updateTime": "Update Time",
|
||||
"createTime": "Create Time"
|
||||
}
|
||||
}
|
||||
62
saiadmin-artd/src/locales/langs/en/tool/crontab.json
Normal file
62
saiadmin-artd/src/locales/langs/en/tool/crontab.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"search": {
|
||||
"taskName": "Task Name",
|
||||
"taskType": "Task Type",
|
||||
"status": "Status",
|
||||
"placeholderTaskName": "Please enter task name",
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"no": "No.",
|
||||
"taskName": "Task Name",
|
||||
"taskType": "Task Type",
|
||||
"rule": "Rule",
|
||||
"target": "Target",
|
||||
"status": "Status",
|
||||
"updateDate": "Update Date",
|
||||
"executeTime": "Execute Time",
|
||||
"parameter": "Parameter",
|
||||
"executeStatus": "Status"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Scheduled Task",
|
||||
"titleEdit": "Edit Scheduled Task",
|
||||
"labelName": "Task Name",
|
||||
"labelType": "Task Type",
|
||||
"labelTaskStyle": "Schedule Rule",
|
||||
"labelTarget": "Target",
|
||||
"labelParams": "Parameters",
|
||||
"labelStatus": "Status",
|
||||
"labelRemark": "Remark",
|
||||
"placeholderName": "Please enter task name",
|
||||
"placeholderTarget": "Please enter target",
|
||||
"placeholderParams": "Please enter parameters",
|
||||
"placeholderRemark": "Please enter remark",
|
||||
"taskStyleEveryDay": "Every day",
|
||||
"taskStyleEveryHour": "Every hour",
|
||||
"taskStyleNHours": "N hours",
|
||||
"taskStyleNMinutes": "N minutes",
|
||||
"taskStyleNSeconds": "N seconds",
|
||||
"taskStyleEveryWeek": "Every week",
|
||||
"taskStyleEveryMonth": "Every month",
|
||||
"taskStyleEveryYear": "Every year",
|
||||
"weekMon": "Mon",
|
||||
"weekTue": "Tue",
|
||||
"weekWed": "Wed",
|
||||
"weekThu": "Thu",
|
||||
"weekFri": "Fri",
|
||||
"weekSat": "Sat",
|
||||
"weekSun": "Sun",
|
||||
"unitMonth": "Month",
|
||||
"unitDay": "Day",
|
||||
"unitHour": "Hour",
|
||||
"unitMinute": "Minute",
|
||||
"unitSecond": "Second",
|
||||
"ruleNameRequired": "Task name is required",
|
||||
"ruleTypeRequired": "Task type is required",
|
||||
"ruleTaskStyleRequired": "Schedule rule is required",
|
||||
"ruleTargetRequired": "Target is required",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
"userCenter": "个人中心",
|
||||
"docs": "使用文档",
|
||||
"github": "Github",
|
||||
"clearCache": "清除缓存",
|
||||
"lockScreen": "锁定屏幕",
|
||||
"logout": "退出登录"
|
||||
},
|
||||
@@ -38,6 +39,25 @@
|
||||
"confirm": "确定",
|
||||
"logOutTips": "您是否要退出登录?"
|
||||
},
|
||||
"form": {
|
||||
"placeholderInput": "请输入",
|
||||
"placeholderSelect": "请选择",
|
||||
"labelRemark": "备注",
|
||||
"labelStatus": "状态",
|
||||
"labelName": "名称",
|
||||
"close": "关闭"
|
||||
},
|
||||
"dict": {
|
||||
"data_status": {
|
||||
"1": "正常",
|
||||
"2": "停用"
|
||||
},
|
||||
"gender": {
|
||||
"1": "男",
|
||||
"2": "女",
|
||||
"3": "未知"
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "搜索页面",
|
||||
"historyTitle": "搜索历史",
|
||||
@@ -150,8 +170,8 @@
|
||||
},
|
||||
"login": {
|
||||
"leftView": {
|
||||
"title": "一款兼具设计美学与高效开发的后台系统",
|
||||
"subTitle": "美观实用的界面,经过视觉优化,确保卓越的用户体验"
|
||||
"title": "大富翁游戏管理",
|
||||
"subTitle": "大富翁游戏管理"
|
||||
},
|
||||
"title": "欢迎回来",
|
||||
"subTitle": "输入您的账号和密码登录",
|
||||
@@ -230,6 +250,56 @@
|
||||
"500": "抱歉,服务器出错了",
|
||||
"gohome": "返回首页"
|
||||
},
|
||||
"console": {
|
||||
"card": {
|
||||
"playerRegister": "玩家注册",
|
||||
"playerCharge": "玩家充值",
|
||||
"playerWithdraw": "玩家提现",
|
||||
"playerPlayCount": "玩家游玩次数",
|
||||
"vsLastWeek": "较上周"
|
||||
},
|
||||
"newPlayer": {
|
||||
"title": "新增玩家",
|
||||
"subtitle": "最新50条新增玩家记录",
|
||||
"player": "玩家",
|
||||
"balance": "余额",
|
||||
"ticket": "抽奖券"
|
||||
},
|
||||
"walletRecord": {
|
||||
"title": "玩家充值记录",
|
||||
"subtitle": "最新50条充值记录",
|
||||
"player": "玩家",
|
||||
"chargeAmount": "充值金额",
|
||||
"chargeTime": "充值时间"
|
||||
},
|
||||
"salesOverview": {
|
||||
"title": "近期玩家充值统计"
|
||||
},
|
||||
"activeUser": {
|
||||
"title": "月度玩家充值汇总"
|
||||
},
|
||||
"todo": {
|
||||
"title": "代办事项",
|
||||
"pending": "待处理"
|
||||
},
|
||||
"newUser": {
|
||||
"title": "新用户",
|
||||
"growth": "这个月增长",
|
||||
"thisMonth": "本月",
|
||||
"lastMonth": "上月",
|
||||
"thisYear": "今年",
|
||||
"avatar": "头像",
|
||||
"region": "地区",
|
||||
"gender": "性别",
|
||||
"progress": "进度",
|
||||
"male": "男",
|
||||
"female": "女"
|
||||
},
|
||||
"dynamic": {
|
||||
"title": "动态",
|
||||
"newCount": "新增"
|
||||
}
|
||||
},
|
||||
"menus": {
|
||||
"login": {
|
||||
"title": "登录"
|
||||
@@ -263,7 +333,39 @@
|
||||
"user": "用户管理",
|
||||
"role": "角色管理",
|
||||
"userCenter": "个人中心",
|
||||
"menu": "菜单管理"
|
||||
"menu": "菜单管理",
|
||||
"dept": "渠道(部门)管理",
|
||||
"post": "岗位管理",
|
||||
"config": "系统配置"
|
||||
},
|
||||
"safeguard": {
|
||||
"title": "运维管理",
|
||||
"dict": "数据字典",
|
||||
"server": "服务监控",
|
||||
"operLog": "操作日志",
|
||||
"loginLog": "登录日志",
|
||||
"emailLog": "邮件日志",
|
||||
"database": "数据库",
|
||||
"cache": "缓存管理",
|
||||
"attachment": "附件管理"
|
||||
},
|
||||
"tool": {
|
||||
"title": "开发工具",
|
||||
"crontab": "定时任务",
|
||||
"code": "代码生成"
|
||||
},
|
||||
"dice": {
|
||||
"title": "大富翁-色子游戏",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"player": "玩家管理",
|
||||
"playerWalletRecord": "玩家钱包记录",
|
||||
"playRecord": "玩家抽奖记录",
|
||||
"playerTicketRecord": "玩家票券记录",
|
||||
"rewardConfig": "奖励配置",
|
||||
"reward": "色子奖励权重",
|
||||
"rewardConfigRecord": "权重测试记录",
|
||||
"playRecordTest": "抽奖记录(测试权重)",
|
||||
"config": "游戏配置"
|
||||
}
|
||||
},
|
||||
"table": {
|
||||
@@ -277,7 +379,54 @@
|
||||
"expand": "展开",
|
||||
"collapse": "收起",
|
||||
"searchInputPlaceholder": "请输入",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
"searchSelectPlaceholder": "请选择",
|
||||
"all": "全部",
|
||||
"min": "最小",
|
||||
"max": "最大",
|
||||
"startTime": "开始时间",
|
||||
"endTime": "结束时间",
|
||||
"placeholderUsername": "请输入用户名",
|
||||
"placeholderNickname": "请输入昵称",
|
||||
"placeholderPhone": "请输入手机号",
|
||||
"placeholderPhoneFuzzy": "手机号模糊查询",
|
||||
"placeholderName": "请输入名称",
|
||||
"placeholderGroup": "请输入分组",
|
||||
"placeholderTitle": "请输入标题",
|
||||
"placeholderConfigName": "请输入配置名称",
|
||||
"placeholderTaskName": "请输入任务名称",
|
||||
"placeholderTableName": "请输入数据表名称",
|
||||
"placeholderDataSource": "请输入数据源名称",
|
||||
"placeholderDeptName": "请输入部门名称",
|
||||
"placeholderDeptCode": "请输入部门编码",
|
||||
"placeholderRoleName": "请输入角色名称",
|
||||
"placeholderRoleCode": "请输入角色编码",
|
||||
"placeholderPostName": "请输入岗位名称",
|
||||
"placeholderPostCode": "请输入岗位编码",
|
||||
"placeholderMenuName": "请输入菜单名称",
|
||||
"placeholderMenuRoute": "请输入菜单路由",
|
||||
"placeholderOperator": "请输入操作用户",
|
||||
"placeholderOperRouter": "请输入操作路由",
|
||||
"placeholderOperIp": "请输入操作IP",
|
||||
"placeholderLoginUser": "请输入登录用户",
|
||||
"placeholderLoginIp": "请输入登录IP",
|
||||
"placeholderLoginStatus": "请选择登录状态",
|
||||
"labelFrom": "发件人",
|
||||
"labelTo": "收件人",
|
||||
"placeholderFrom": "请输入发件人",
|
||||
"placeholderTo": "请输入收件人",
|
||||
"placeholderSendStatus": "请选择发送状态",
|
||||
"placeholderPoolType": "请选择奖池类型",
|
||||
"usernameFuzzy": "用户名模糊",
|
||||
"nameFuzzy": "名称模糊",
|
||||
"uiTextFuzzy": "前端显示文本模糊",
|
||||
"fuzzyQuery": "模糊查询",
|
||||
"byUsername": "按用户名搜索",
|
||||
"exactSearch": "精确搜索",
|
||||
"enable": "启用",
|
||||
"disable": "禁用",
|
||||
"rangeSeparator": "至",
|
||||
"success": "成功",
|
||||
"failure": "失败"
|
||||
},
|
||||
"selection": "选择",
|
||||
"sizeOptions": {
|
||||
@@ -290,6 +439,184 @@
|
||||
"expand": "展开",
|
||||
"index": "序号"
|
||||
},
|
||||
"actions": {
|
||||
"add": "新增",
|
||||
"delete": "删除",
|
||||
"edit": "编辑",
|
||||
"operation": "操作",
|
||||
"refresh": "刷新",
|
||||
"export": "导出",
|
||||
"import": "导入"
|
||||
},
|
||||
"columns": {
|
||||
"common": {
|
||||
"id": "ID",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间",
|
||||
"operation": "操作",
|
||||
"remark": "备注",
|
||||
"sort": "排序",
|
||||
"name": "名称",
|
||||
"no": "编号",
|
||||
"description": "描述",
|
||||
"select": "选中"
|
||||
},
|
||||
"system": {
|
||||
"username": "用户名",
|
||||
"phone": "手机号",
|
||||
"dept": "部门",
|
||||
"dashboard": "首页",
|
||||
"loginTime": "上次登录",
|
||||
"agentId": "代理ID",
|
||||
"postName": "岗位名称",
|
||||
"postCode": "岗位编码",
|
||||
"deptName": "部门名称",
|
||||
"deptCode": "部门编码",
|
||||
"leader": "部门领导",
|
||||
"roleName": "角色名称",
|
||||
"roleCode": "角色编码",
|
||||
"level": "角色级别",
|
||||
"roleRemark": "角色描述",
|
||||
"menuName": "菜单名称",
|
||||
"menuType": "菜单类型",
|
||||
"icon": "图标",
|
||||
"component": "组件名称",
|
||||
"route": "路由",
|
||||
"auth": "权限标识",
|
||||
"configKey": "配置标识",
|
||||
"configTitle": "配置标题",
|
||||
"inputType": "组件类型",
|
||||
"configName": "配置名称",
|
||||
"group": "分组",
|
||||
"title": "标题",
|
||||
"titleEn": "标题(英文)",
|
||||
"value": "值",
|
||||
"valueEn": "值(英文)",
|
||||
"noParentDept": "无上级部门",
|
||||
"noParentMenu": "无上级菜单",
|
||||
"input": "文本框",
|
||||
"textarea": "文本域",
|
||||
"select": "下拉选择框",
|
||||
"radio": "单选框",
|
||||
"uploadImage": "图片上传",
|
||||
"uploadFile": "文件上传",
|
||||
"wangEditor": "富文本编辑器",
|
||||
"createDate": "创建日期",
|
||||
"updateDate": "更新日期"
|
||||
},
|
||||
"safeguard": {
|
||||
"operator": "操作用户",
|
||||
"serviceName": "业务名称",
|
||||
"router": "路由",
|
||||
"operIp": "操作IP",
|
||||
"operLocation": "操作地点",
|
||||
"operTime": "操作时间",
|
||||
"loginUser": "登录用户",
|
||||
"loginStatus": "登录状态",
|
||||
"loginIp": "登录IP",
|
||||
"loginLocation": "登录地点",
|
||||
"os": "操作系统",
|
||||
"browser": "浏览器",
|
||||
"tableName": "表名称",
|
||||
"tableComment": "表注释",
|
||||
"engine": "引擎",
|
||||
"tableEngine": "表引擎",
|
||||
"totalRows": "总行数",
|
||||
"fragmentSize": "碎片大小",
|
||||
"dataSize": "数据大小",
|
||||
"collation": "编码",
|
||||
"dictName": "字典名称",
|
||||
"dictCode": "字典标识",
|
||||
"dictLabel": "字典标签",
|
||||
"dictValue": "字典键值",
|
||||
"color": "颜色",
|
||||
"preview": "预览",
|
||||
"fileName": "文件名称",
|
||||
"storageMode": "存储模式",
|
||||
"fileType": "文件类型",
|
||||
"fileSize": "文件大小",
|
||||
"uploadTime": "上传时间",
|
||||
"deleteTime": "删除时间",
|
||||
"dataDetail": "数据详情",
|
||||
"executeTime": "执行时间",
|
||||
"target": "调用目标",
|
||||
"parameter": "任务参数",
|
||||
"executeStatus": "执行状态",
|
||||
"loginMessage": "登录信息",
|
||||
"loginTime": "登录时间",
|
||||
"gateway": "服务Host",
|
||||
"emailFrom": "发件人",
|
||||
"emailTo": "收件人",
|
||||
"emailCode": "验证码",
|
||||
"emailResponse": "发送结果",
|
||||
"sendTime": "发送时间",
|
||||
"sendStatus": "发送状态"
|
||||
},
|
||||
"tool": {
|
||||
"taskName": "任务名称",
|
||||
"taskType": "任务类型",
|
||||
"rule": "定时规则",
|
||||
"updateDate": "更新日期",
|
||||
"tableDesc": "表描述",
|
||||
"template": "应用类型",
|
||||
"namespace": "应用名称",
|
||||
"stub": "模板类型",
|
||||
"tplCategory": "生成类型",
|
||||
"topMenu": "顶级菜单"
|
||||
},
|
||||
"dice": {
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
"rewardWinCoin": "摇色子中奖平台币",
|
||||
"direction": "方向",
|
||||
"startIndex": "起始索引",
|
||||
"targetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"user": "用户",
|
||||
"coinChange": "平台币变化",
|
||||
"type": "类型",
|
||||
"operator": "操作人",
|
||||
"walletBefore": "钱包操作前",
|
||||
"walletAfter": "钱包操作后",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"paidDraw": "付费抽取",
|
||||
"freeDraw": "免费抽取",
|
||||
"platformProfit": "平台赚取金额",
|
||||
"createdBy": "创建管理员",
|
||||
"rewardTier": "奖励档位",
|
||||
"poolType": "奖池类型",
|
||||
"safetyLine": "安全线",
|
||||
"t1PoolWeight": "T1池权重",
|
||||
"t2PoolWeight": "T2池权重",
|
||||
"t3PoolWeight": "T3池权重",
|
||||
"t4PoolWeight": "T4池权重",
|
||||
"t5PoolWeight": "T5池权重",
|
||||
"endIndex": "结束索引(end_index)",
|
||||
"tier": "档位",
|
||||
"dicePoints": "色子点数(摇取5-30)",
|
||||
"displayText": "显示文本",
|
||||
"realEv": "实际中奖金额",
|
||||
"weight": "权重(1-10000)",
|
||||
"nickname": "昵称",
|
||||
"coin": "平台币",
|
||||
"t1Weight": "T1权重",
|
||||
"t2Weight": "T2权重",
|
||||
"t3Weight": "T3权重",
|
||||
"t4Weight": "T4权重",
|
||||
"t5Weight": "T5权重",
|
||||
"playerUsername": "玩家用户名",
|
||||
"useCoins": "消耗硬币"
|
||||
}
|
||||
},
|
||||
"zebra": "斑马纹",
|
||||
"border": "边框",
|
||||
"headerBackground": "表头背景"
|
||||
|
||||
41
saiadmin-artd/src/locales/langs/zh/dice/config.json
Normal file
41
saiadmin-artd/src/locales/langs/zh/dice/config.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增摇色子配置",
|
||||
"dialogTitleEdit": "编辑摇色子配置",
|
||||
"group": "分组",
|
||||
"placeholderGroup": "请输入分组",
|
||||
"title": "标题",
|
||||
"placeholderTitleZh": "请输入标题(中文)",
|
||||
"titleEn": "标题(英文)",
|
||||
"placeholderTitleEn": "请输入标题(英文)",
|
||||
"configName": "配置名称",
|
||||
"placeholderConfigName": "请输入配置名称",
|
||||
"value": "值",
|
||||
"placeholderValueZh": "请输入值(中文)",
|
||||
"valueEn": "值(英文)",
|
||||
"placeholderValueEn": "请输入值(英文)",
|
||||
"ruleGroupRequired": "分组必需填写",
|
||||
"ruleTitleRequired": "标题必需填写",
|
||||
"ruleTitleEnMax": "英文标题长度需小于 255 字符",
|
||||
"ruleConfigNameRequired": "配置名称必需填写",
|
||||
"ruleValueRequired": "值必需填写",
|
||||
"saveSuccess": "新增成功",
|
||||
"updateSuccess": "修改成功"
|
||||
},
|
||||
"search": {
|
||||
"group": "分组",
|
||||
"title": "标题",
|
||||
"configName": "配置名称",
|
||||
"placeholderGroup": "请输入分组",
|
||||
"placeholderTitle": "请输入标题",
|
||||
"placeholderConfigName": "请输入配置名称"
|
||||
},
|
||||
"table": {
|
||||
"group": "分组",
|
||||
"title": "标题",
|
||||
"titleEn": "标题(英文)",
|
||||
"configName": "配置名称",
|
||||
"value": "值",
|
||||
"valueEn": "值(英文)"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "名称",
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增色子奖池配置",
|
||||
"dialogTitleEdit": "编辑色子奖池配置",
|
||||
"placeholderName": "请输入名称",
|
||||
"placeholderRemark": "请输入备注",
|
||||
"poolType": "奖池类型",
|
||||
"placeholderPoolType": "请选择奖池类型",
|
||||
"poolTypeNormal": "正常",
|
||||
"poolTypeKill": "强制杀猪",
|
||||
"poolTypeT1": "T1高倍率",
|
||||
"safetyLine": "安全线",
|
||||
"t1Weight": "T1池权重(%)",
|
||||
"t2Weight": "T2池权重(%)",
|
||||
"t3Weight": "T3池权重(%)",
|
||||
"t4Weight": "T4池权重(%)",
|
||||
"t5Weight": "T5池权重(%)",
|
||||
"weightsSumHint": "五个池权重总和:",
|
||||
"weightsSumUnit": "% / 100%(必须为100%)",
|
||||
"currentPoolTitle": "当前彩金池",
|
||||
"loading": "加载中...",
|
||||
"poolName": "池子名称",
|
||||
"playerProfit": "玩家累计盈利(profit_amount):",
|
||||
"realtime": "实时",
|
||||
"profitCalcHint": "计算方式:每局按“当前中奖金额(含超级大奖 BIGWIN)减去抽奖券费用 100”累加,弹窗打开期间每 2 秒自动刷新",
|
||||
"tierRuleTitle": "抽奖档位规则",
|
||||
"tierRuleContent": "当玩家在当前彩金池的累计盈利 低于安全线 时,按 玩家 的 T*_weight 权重抽取档位;当累计盈利 高于或等于安全线 时,按 当前彩金池 的 T*_weight 权重抽取档位(杀分)。",
|
||||
"killScoreWeights": "杀分权重",
|
||||
"killWeightNote": "(杀分权重来自奖池配置,请在列表中编辑对应记录)",
|
||||
"btnResetProfit": "重置玩家累计盈利",
|
||||
"btnSaveSafetyLine": "保存安全线",
|
||||
"ruleSafetyLineRequired": "请输入安全线",
|
||||
"msgGetPoolFailed": "获取彩金池失败",
|
||||
"msgSaveSuccess": "保存成功",
|
||||
"msgResetProfitSuccess": "玩家累计盈利已重置为 0",
|
||||
"msgResetFailed": "重置失败",
|
||||
"ruleNameRequired": "名称必需填写",
|
||||
"rulePoolTypeRequired": "请选择奖池类型",
|
||||
"ruleT1Required": "T1池权重必需填写",
|
||||
"ruleT2Required": "T2池权重必需填写",
|
||||
"ruleT3Required": "T3池权重必需填写",
|
||||
"ruleT4Required": "T4池权重必需填写",
|
||||
"ruleT5Required": "T5池权重必需填写",
|
||||
"msgWeightsMust100": "五个池权重总和必须为100%",
|
||||
"msgAddSuccess": "新增成功",
|
||||
"msgUpdateSuccess": "修改成功"
|
||||
},
|
||||
"toolbar": {
|
||||
"viewCurrentPool": "查看当前彩金池"
|
||||
},
|
||||
"search": {
|
||||
"poolType": "奖池类型",
|
||||
"placeholderName": "请输入名称",
|
||||
"placeholderPoolType": "请选择奖池类型",
|
||||
"poolTypeNormal": "正常",
|
||||
"poolTypeKill": "强制杀猪",
|
||||
"poolTypeT1": "T1高倍率"
|
||||
},
|
||||
"table": {
|
||||
"name": "名称",
|
||||
"poolType": "奖池类型",
|
||||
"safetyLine": "安全线",
|
||||
"t1PoolWeight": "T1池权重",
|
||||
"t2PoolWeight": "T2池权重",
|
||||
"t3PoolWeight": "T3池权重",
|
||||
"t4PoolWeight": "T4池权重",
|
||||
"t5PoolWeight": "T5池权重"
|
||||
}
|
||||
}
|
||||
80
saiadmin-artd/src/locales/langs/zh/dice/play_record.json
Normal file
80
saiadmin-artd/src/locales/langs/zh/dice/play_record.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增玩家抽奖记录",
|
||||
"dialogTitleEdit": "编辑玩家抽奖记录",
|
||||
"player": "玩家",
|
||||
"placeholderPlayer": "请选择玩家(显示用户名)",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"placeholderLotteryPool": "请选择彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"isBigWin": "是否中大奖",
|
||||
"noBigWin": "无",
|
||||
"bigWin": "中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"placeholderWinCoin": "= 中大奖 + 摇色子中奖",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
"placeholderSuperWinCoin": "豹子时发放",
|
||||
"rewardWinCoin": "摇色子中奖平台币",
|
||||
"placeholderRewardWinCoin": "摇色子中奖",
|
||||
"direction": "方向",
|
||||
"placeholderDirection": "请选择方向",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针",
|
||||
"startIndex": "起始索引",
|
||||
"placeholderStartIndex": "起始索引",
|
||||
"targetIndex": "终点索引",
|
||||
"placeholderTargetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollArrayHint": "固定 5 个数,每个 1~6",
|
||||
"rollNumber": "摇取点数和",
|
||||
"placeholderRollNumber": "5 个色子点数之和(5~30)",
|
||||
"rewardConfig": "奖励配置",
|
||||
"placeholderRewardConfig": "请选择奖励配置(显示前端文本)",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功",
|
||||
"validateFailed": "表单验证失败,请检查必填项与格式"
|
||||
},
|
||||
"toolbar": {
|
||||
"platformTotalProfit": "平台总盈利"
|
||||
},
|
||||
"search": {
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"isBigWin": "是否中大奖",
|
||||
"direction": "方向",
|
||||
"winCoin": "赢取平台币",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"rewardTier": "奖励档位",
|
||||
"usernameFuzzy": "用户名模糊",
|
||||
"nameFuzzy": "名称模糊",
|
||||
"uiTextFuzzy": "前端显示文本模糊",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"noBigWin": "无",
|
||||
"bigWin": "中大奖",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
"rewardWinCoin": "摇色子中奖平台币",
|
||||
"direction": "方向",
|
||||
"startIndex": "起始索引",
|
||||
"targetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"clearAllData": "一键删除所有数据",
|
||||
"platformTotalProfit": "平台总盈利"
|
||||
},
|
||||
"search": {
|
||||
"drawType": "抽奖类型",
|
||||
"direction": "方向",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"rewardTier": "奖励档位",
|
||||
"rollNumber": "摇取点数和",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针",
|
||||
"noBigWin": "无",
|
||||
"bigWin": "中大奖"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
"rewardWinCoin": "摇色子中奖平台币",
|
||||
"direction": "方向",
|
||||
"startIndex": "起始索引",
|
||||
"targetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增玩家抽奖记录(测试数据)",
|
||||
"titleEdit": "编辑玩家抽奖记录(测试数据)",
|
||||
"labelLotteryConfigId": "彩金池配置id",
|
||||
"placeholderLotteryConfigId": "请输入彩金池配置id",
|
||||
"placeholderWinCoin": "赢取平台币",
|
||||
"placeholderRewardTier": "请选择档位(选后自动带出奖励配置ID)",
|
||||
"rewardConfigId": "奖励配置id",
|
||||
"placeholderRewardConfigId": "可选中奖档位自动带出或手动输入",
|
||||
"placeholderStartIndex": "请输入起始索引",
|
||||
"labelTargetIndex": "结束索引",
|
||||
"placeholderTargetIndex": "请输入结束索引",
|
||||
"placeholderRollNumber": "请输入摇取点数和",
|
||||
"labelRollArray": "摇取点数:[1,2,3,4,5,6]",
|
||||
"placeholderRollArray": "请输入摇取点数:[1,2,3,4,5,6]",
|
||||
"labelStatus": "状态:0=失败,1=成功",
|
||||
"placeholderSuperWinCoin": "请输入中大奖平台币",
|
||||
"placeholderRewardWinCoin": "请输入摇色子中奖平台币",
|
||||
"labelAdminId": "所属管理员",
|
||||
"placeholderAdminId": "请输入所属管理员",
|
||||
"ruleLotteryConfigIdRequired": "彩金池配置id必需填写",
|
||||
"ruleDrawTypeRequired": "抽奖类型必需填写",
|
||||
"ruleIsBigWinRequired": "是否中大奖必需填写",
|
||||
"ruleDirectionRequired": "方向必需填写",
|
||||
"ruleRewardConfigIdRequired": "奖励配置id必需填写",
|
||||
"ruleStatusRequired": "状态必需填写",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
80
saiadmin-artd/src/locales/langs/zh/dice/player.json
Normal file
80
saiadmin-artd/src/locales/langs/zh/dice/player.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "名称",
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增大富翁-玩家",
|
||||
"dialogTitleEdit": "编辑大富翁-玩家",
|
||||
"username": "用户名",
|
||||
"placeholderUsername": "请输入用户名",
|
||||
"nickname": "昵称",
|
||||
"placeholderNickname": "请输入昵称",
|
||||
"phone": "手机号",
|
||||
"placeholderPhone": "请输入手机号",
|
||||
"password": "密码",
|
||||
"placeholderPasswordEdit": "编辑留空则不修改",
|
||||
"status": "状态",
|
||||
"adminId": "所属管理员",
|
||||
"placeholderAdmin": "选择后台管理员(可选)",
|
||||
"coin": "平台币",
|
||||
"placeholderCoinAdd": "创建时默认0,不可改",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"placeholderLotteryPool": "留空则使用下方自定义权重,或选择彩金池",
|
||||
"currentConfig": "当前配置",
|
||||
"configLabelName": "名称",
|
||||
"configLabelType": "类型",
|
||||
"configLabelWeights": "T1~T5 权重",
|
||||
"configLabelRemark": "备注",
|
||||
"t1Weight": "T1池权重(%)",
|
||||
"t2Weight": "T2池权重(%)",
|
||||
"t3Weight": "T3池权重(%)",
|
||||
"t4Weight": "T4池权重(%)",
|
||||
"t5Weight": "T5池权重(%)",
|
||||
"weightsSumHint": "五个池权重总和:",
|
||||
"weightsSumUnit": "% / 100%(必须为100%)",
|
||||
"ruleWeightsSumMustBe100": "五个池权重总和必须为100%",
|
||||
"walletTitle": "玩家钱包操作",
|
||||
"walletPlayer": "玩家",
|
||||
"walletBalance": "钱包余额",
|
||||
"operationType": "操作类型",
|
||||
"typeAdd": "加点",
|
||||
"typeSub": "扣点",
|
||||
"coinChange": "平台币变动",
|
||||
"placeholderCoinChange": "正数,扣点时不能超过余额",
|
||||
"placeholderRemarkOptional": "选填,不填则按类型自动填写",
|
||||
"ruleSelectType": "请选择操作类型",
|
||||
"ruleEnterCoin": "请输入平台币变动",
|
||||
"ruleCoinPositive": "平台币变动必须大于 0",
|
||||
"ruleDeductExceed": "扣点不能超过当前余额",
|
||||
"operateSuccess": "操作成功"
|
||||
},
|
||||
"search": {
|
||||
"username": "用户名",
|
||||
"nickname": "昵称",
|
||||
"phone": "手机号",
|
||||
"status": "状态",
|
||||
"coin": "平台币",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"placeholderUsername": "请输入用户名",
|
||||
"placeholderNickname": "请输入昵称",
|
||||
"placeholderPhoneFuzzy": "手机号模糊查询",
|
||||
"placeholderAll": "全部",
|
||||
"exactSearch": "精确搜索"
|
||||
},
|
||||
"table": {
|
||||
"username": "用户名",
|
||||
"phone": "手机号",
|
||||
"nickname": "昵称",
|
||||
"status": "状态",
|
||||
"coin": "平台币",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"t1Weight": "T1权重",
|
||||
"t2Weight": "T2权重",
|
||||
"t3Weight": "T3权重",
|
||||
"t4Weight": "T4权重",
|
||||
"t5Weight": "T5权重",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增抽奖券获取记录",
|
||||
"dialogTitleEdit": "编辑抽奖券获取记录",
|
||||
"player": "玩家",
|
||||
"placeholderPlayer": "请选择玩家(显示用户名)",
|
||||
"useCoins": "消耗硬币",
|
||||
"placeholderUseCoins": "请输入消耗硬币",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"placeholderPaidDrawCount": "请输入购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"placeholderFreeDrawCount": "请输入赠送抽奖次数",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"placeholderTotalDrawCount": "自动求和",
|
||||
"placeholderRemark": "请输入备注(必填)",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"search": {
|
||||
"player": "玩家",
|
||||
"useCoins": "消耗硬币",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"createTime": "创建时间",
|
||||
"byUsername": "按用户名搜索"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"playerUsername": "玩家用户名",
|
||||
"useCoins": "消耗硬币",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"remark": "备注",
|
||||
"createTime": "创建时间"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"form": {
|
||||
"dialogTitleAdd": "新增玩家钱包流水",
|
||||
"dialogTitleEdit": "编辑玩家钱包流水",
|
||||
"user": "用户",
|
||||
"placeholderUser": "请选择用户(显示用户名)",
|
||||
"type": "类型",
|
||||
"placeholderType": "请选择类型",
|
||||
"typeRecharge": "充值",
|
||||
"typeWithdraw": "提现",
|
||||
"typeBuyTicket": "购买抽奖次数",
|
||||
"typeAdminAdd": "管理员加点",
|
||||
"typeAdminSub": "管理员扣点",
|
||||
"coinChange": "平台币变化",
|
||||
"placeholderCoinChange": "正数增加、负数减少",
|
||||
"walletBefore": "钱包操作前",
|
||||
"placeholderWalletBefore": "选择用户后自动带出当前平台币",
|
||||
"walletAfter": "钱包操作后",
|
||||
"placeholderWalletAfter": "根据平台币变化自动计算",
|
||||
"placeholderRemark": "选填",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"search": {
|
||||
"type": "类型",
|
||||
"user": "用户",
|
||||
"coin": "平台币",
|
||||
"createTime": "创建时间",
|
||||
"typeRecharge": "充值",
|
||||
"typeWithdraw": "提现",
|
||||
"typeBuyTicket": "购买抽奖次数",
|
||||
"typeAdminAdd": "管理员加点",
|
||||
"typeAdminSub": "管理员扣点",
|
||||
"byUsername": "按用户名搜索"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"user": "用户",
|
||||
"coinChange": "平台币变化",
|
||||
"type": "类型",
|
||||
"operator": "操作人",
|
||||
"walletBefore": "钱包操作前",
|
||||
"walletAfter": "钱包操作后",
|
||||
"remark": "备注",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
"createTime": "创建时间",
|
||||
"typeDraw": "抽奖"
|
||||
}
|
||||
}
|
||||
84
saiadmin-artd/src/locales/langs/zh/dice/reward.json
Normal file
84
saiadmin-artd/src/locales/langs/zh/dice/reward.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"weightRatio": "权重配比",
|
||||
"weightTest": "一键测试权重"
|
||||
},
|
||||
"search": {
|
||||
"tier": "档位",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针",
|
||||
"optionBigwin": "BIGWIN"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "起始索引",
|
||||
"endIndex": "结束索引(end_index)",
|
||||
"tier": "档位",
|
||||
"dicePoints": "色子点数(摇取5-30)",
|
||||
"displayText": "显示文本",
|
||||
"realEv": "实际中奖金额",
|
||||
"remark": "备注",
|
||||
"weight": "权重(1-10000)"
|
||||
},
|
||||
"weightShared": {
|
||||
"xAxisEndIndex": "结束索引",
|
||||
"xAxisGridNumber": "点数",
|
||||
"emptyTier": "该档位暂无配置数据",
|
||||
"sumLineDual": "当前档位权重合计(顺时针):{cw};逆时针:{ccw}(各条 1-10000,档位内按权重比抽取,和不限制)",
|
||||
"sumLineSingle": "当前档位权重合计:{sum}(各条 1-10000,档位内按权重比抽取,和不限制)",
|
||||
"t4t5NoteSingle": "T4、T5 仅单一结果,无需配置权重。",
|
||||
"t4t5NoteDual": "T4、T5 档位抽中时仅有一个结果,无需配置权重。",
|
||||
"colEndIndexId": "结束索引(id)",
|
||||
"colGridNumber": "点数(grid_number)",
|
||||
"colDicePoints": "色子点数",
|
||||
"colRealEv": "实际中奖金额",
|
||||
"colUiText": "显示文本",
|
||||
"colRemark": "备注",
|
||||
"colWeightCwDir": "顺时针权重(direction=0)",
|
||||
"colWeightCcwDir": "逆时针权重(direction=1)",
|
||||
"weightColSuffix": "权重(1-10000)",
|
||||
"fetchFail": "获取权重数据失败",
|
||||
"nothingToSubmit": "没有可提交的配置",
|
||||
"submitFail": "保存失败",
|
||||
"btnCancel": "取消",
|
||||
"btnSubmit": "提交",
|
||||
"saveSuccess": "保存成功"
|
||||
},
|
||||
"weightEdit": {
|
||||
"title": "奖励对照表(dice_reward)权重配比",
|
||||
"globalTip": "编辑的是奖励对照表(dice_reward / DiceReward 模型)的权重,按结束索引(end_index)区分顺时针与逆时针两套权重;抽奖时按当前方向取对应权重。"
|
||||
},
|
||||
"weightRatio": {
|
||||
"title": "权重配比",
|
||||
"globalTip": "配置奖励对照表(dice_reward)的权重,一级按方向(顺时针/逆时针),二级按档位(T1-T5);各条权重 1-10000,档位内按权重比抽取。",
|
||||
"tabClockwise": "顺时针",
|
||||
"tabCounterclockwise": "逆时针"
|
||||
},
|
||||
"weightTest": {
|
||||
"title": "一键测试权重",
|
||||
"alertTitle": "彩金池逻辑说明",
|
||||
"alertBody": "与 playStart 抽奖逻辑一致:使用 name=default 的安全线、杀分开关;盈利未达安全线时,付费抽奖券使用玩家自身权重(下方自定义档位),免费抽奖券使用 killScore 配置;盈利达到安全线且杀分开启时,付费/免费均使用 killScore 配置。",
|
||||
"stepPaid": "付费抽奖券",
|
||||
"stepFree": "免费抽奖券",
|
||||
"labelLotteryTypePaid": "测试数据档位类型",
|
||||
"labelLotteryTypeFree": "测试数据档位类型",
|
||||
"placeholderPaidPool": "不选则下方自定义档位概率(默认 default)",
|
||||
"placeholderFreePool": "不选则下方自定义档位概率(默认 killScore)",
|
||||
"tierProbHint": "自定义档位概率(T1~T5),每档 0-100%,五档之和不能超过 100%",
|
||||
"tierFieldLabel": "档位 {tier}(%)",
|
||||
"tierSumError": "当前五档之和为 {sum}%,不能超过 100%",
|
||||
"labelCwCount": "顺时针次数",
|
||||
"labelCcwCount": "逆时针次数",
|
||||
"placeholderSelect": "请选择",
|
||||
"btnPrev": "上一步",
|
||||
"btnNext": "下一步",
|
||||
"btnStart": "开始测试",
|
||||
"btnCancel": "取消",
|
||||
"warnTotalSpins": "付费或免费至少一种方向次数之和大于 0",
|
||||
"warnPaidTierSumPositive": "付费未选奖池时,T1~T5 档位概率之和需大于 0",
|
||||
"warnPaidTierSumMax": "付费档位概率 T1~T5 之和不能超过 100%",
|
||||
"warnFreeTierSumPositive": "免费未选奖池时,T1~T5 档位概率之和需大于 0",
|
||||
"warnFreeTierSumMax": "免费档位概率 T1~T5 之和不能超过 100%",
|
||||
"successCreated": "测试任务已创建,后台将自动执行。请在【玩家抽奖记录(测试数据)】中查看生成的测试数据",
|
||||
"failCreate": "创建测试任务失败"
|
||||
}
|
||||
}
|
||||
119
saiadmin-artd/src/locales/langs/zh/dice/reward_config.json
Normal file
119
saiadmin-artd/src/locales/langs/zh/dice/reward_config.json
Normal file
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"gameRewardConfig": "游戏奖励配置",
|
||||
"createRewardRef": "创建奖励对照",
|
||||
"createRewardRefTitle": "按规则:start_index=config(grid_number).id;顺时针 end_index=(start_index+grid_number)%26;逆时针 end_index=start_index-grid_number≥0?start_index-grid_number:26+start_index-grid_number"
|
||||
},
|
||||
"configPage": {
|
||||
"tabIndex": "奖励索引",
|
||||
"tabBigwin": "大奖权重",
|
||||
"tipIndex": "色子点数须在 5~30 之间且本表内不重复。",
|
||||
"tipBigwin": "从左至右:中大奖点数(不可改)、显示信息、实际中奖、备注、权重(0~10000)。点数 5、30 权重固定 100%。本表单独立提交,仅提交大奖权重。",
|
||||
"colId": "索引(id)",
|
||||
"colDicePoints": "色子点数",
|
||||
"colDisplayText": "显示文本",
|
||||
"colDisplayTextEn": "显示文本(英文)",
|
||||
"colRealEv": "真实结算",
|
||||
"colTier": "所属档位",
|
||||
"colRemark": "备注",
|
||||
"placeholderTierSelect": "档位",
|
||||
"placeholderDisplayZh": "显示文本(中文)",
|
||||
"placeholderDisplayEn": "显示文本(英文)",
|
||||
"placeholderRemark": "备注",
|
||||
"btnSave": "保存",
|
||||
"btnReset": "重置",
|
||||
"colBigwinPoints": "中大奖点数",
|
||||
"colDisplayInfo": "显示信息",
|
||||
"colDisplayInfoEn": "显示信息(英文)",
|
||||
"colRealPrize": "实际中奖",
|
||||
"colWeightRange": "权重(0-10000)",
|
||||
"placeholderDisplayInfoZh": "显示信息(中文)",
|
||||
"placeholderDisplayInfoEn": "显示信息(英文)",
|
||||
"weightFixedTip": "点数 5、30 固定 100%",
|
||||
"emptyBigwin": "暂无 BIGWIN 档位配置,请在「奖励索引」中设置 tier 为 BIGWIN。",
|
||||
"confirmCreateRefTitle": "创建奖励对照",
|
||||
"confirmCreateRefMsg": "按规则创建奖励对照:起始索引 start_index=奖励配置中 grid_number 对应格位的 id;顺时针 end_index=(start_index+摇取点数)%26;逆时针 end_index=start_index-摇取点数≥0 则取该值,否则 26+start_index-摇取点数。先清空现有数据再为 5-30 共 26 个点数、顺/逆时针分别生成。是否继续?",
|
||||
"confirmCreateRefOk": "确定创建",
|
||||
"confirmCreateRefCancel": "取消",
|
||||
"createRefSuccess": "已按 5-30 共 26 个点数、顺时针+逆时针创建:顺时针新增 {cwNew} 条、逆时针新增 {ccwNew} 条;顺时针更新 {cwUp} 条、逆时针更新 {ccwUp} 条{skippedPart}",
|
||||
"createRefSuccessSkipped": ";{n} 个点数使用兜底起始索引",
|
||||
"createRefSuccessSimple": "创建成功",
|
||||
"createRefFail": "创建奖励对照失败",
|
||||
"loadIndexFail": "获取奖励索引配置失败",
|
||||
"saveSuccess": "保存成功",
|
||||
"saveFail": "保存失败",
|
||||
"resetIndexReloaded": "已重新加载奖励索引,恢复为服务器最新数据",
|
||||
"resetBigwinReloaded": "已重新加载,大奖权重恢复为服务器最新数据",
|
||||
"warnNoIndexToSave": "暂无奖励索引数据可保存",
|
||||
"warnGridRange": "色子点数必须在 {min}~{max} 之间",
|
||||
"dupJoiner": "、",
|
||||
"warnDupGrid": "色子点数在本表内不能重复,重复的点数为:{list}",
|
||||
"warnNoBigwinToSave": "暂无 BIGWIN 档位配置可保存",
|
||||
"warnBigwinDupGrid": "大奖权重本表内点数不能重复,重复的点数为:{list}",
|
||||
"infoNoBigwin": "暂无 BIGWIN 档位配置,请先在「奖励索引」中设置 tier 为 BIGWIN"
|
||||
},
|
||||
"weightRatio": {
|
||||
"title": "T1-T5 权重配比(顺时针/逆时针)",
|
||||
"globalTip": "权重来自奖励对照表(dice_reward),按结束索引(DiceRewardConfig.id)区分顺时针与逆时针两套权重;抽奖时按当前方向取对应权重。",
|
||||
"xAxisEndIndex": "结束索引",
|
||||
"emptyTier": "该档位暂无配置数据",
|
||||
"sumLine": "当前档位权重合计(顺时针):{cw};逆时针:{ccw}(各条 1-10000,档位内按权重比抽取,和不限制)",
|
||||
"t4t5Note": "T4、T5 档位抽中时仅有一个结果,无需配置权重。",
|
||||
"colEndIndexId": "结束索引(id)",
|
||||
"colDicePoints": "色子点数",
|
||||
"colRealEv": "实际中奖金额",
|
||||
"colUiText": "显示文本",
|
||||
"colWeightCw": "顺时针权重(1-10000)",
|
||||
"colWeightCcw": "逆时针权重(1-10000)",
|
||||
"fetchFail": "获取权重配比数据失败",
|
||||
"nothingToSubmit": "没有可提交的配置",
|
||||
"submitFail": "保存失败",
|
||||
"saveSuccess": "保存成功"
|
||||
},
|
||||
"search": {
|
||||
"dicePoints": "色子点数(摇取5-30)",
|
||||
"displayText": "显示文本",
|
||||
"realEv": "实际中奖金额",
|
||||
"tier": "档位",
|
||||
"fuzzyQuery": "模糊查询"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "起始索引",
|
||||
"endIndex": "结束索引(end_index)",
|
||||
"tier": "档位",
|
||||
"dicePoints": "色子点数(摇取5-30)",
|
||||
"displayText": "显示文本",
|
||||
"realEv": "实际中奖金额",
|
||||
"remark": "备注",
|
||||
"weight": "权重(1-10000)"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增奖励配置",
|
||||
"titleEdit": "编辑奖励配置",
|
||||
"labelDicePoints": "色子点数",
|
||||
"placeholderDicePoints": "请输入色子点数",
|
||||
"labelUiText": "前端显示文本",
|
||||
"placeholderUiText": "请输入前端显示文本(中文)",
|
||||
"labelUiTextEn": "前端显示文本(英文)",
|
||||
"placeholderUiTextEn": "请输入前端显示文本(英文)",
|
||||
"labelRealEv": "真实资金结算",
|
||||
"placeholderRealEv": "请输入真实资金结算",
|
||||
"labelTier": "所属档位",
|
||||
"placeholderTier": "请选择所属档位",
|
||||
"tierBigWin": "BIGWIN(超级大奖)",
|
||||
"labelBigWinWeight": "大奖权重",
|
||||
"placeholderBigWinWeight": "0~10000,10000=100%中奖",
|
||||
"bigWinWeightDisabledTip": "点数 5、30 摇到必中大奖,权重固定 10000",
|
||||
"bigWinWeightTip": "10000=100% 中奖,0=0% 中奖;仅对点数 10/15/20/25 生效",
|
||||
"labelRemark": "备注",
|
||||
"placeholderRemark": "请输入备注",
|
||||
"ruleDicePointsRequired": "色子点数必需填写",
|
||||
"ruleUiTextRequired": "前端显示文本必需填写",
|
||||
"ruleUiTextEnMax": "前端显示文本(英文)长度需小于 255 字符",
|
||||
"ruleRealEvRequired": "真实资金结算必需填写",
|
||||
"ruleTierRequired": "所属档位必需填写",
|
||||
"ruleBigWinWeightRange": "大奖权重 0~10000",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"viewDetail": "查看详情"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"clockwiseAbbr": "顺",
|
||||
"counterclockwiseAbbr": "逆",
|
||||
"status": "状态",
|
||||
"paidDraw": "付费抽取",
|
||||
"freeDraw": "免费抽取",
|
||||
"platformProfit": "平台赚取金额",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"createdBy": "创建管理员",
|
||||
"createTime": "创建时间",
|
||||
"statusFail": "失败",
|
||||
"statusDone": "完成",
|
||||
"statusTesting": "测试中"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增奖励配置权重测试记录",
|
||||
"titleEdit": "编辑奖励配置权重测试记录",
|
||||
"labelTestCount": "测试次数:100/500/1000",
|
||||
"placeholderTestCount": "请输入测试次数:100/500/1000",
|
||||
"labelWeightSnapshot": "测试时权重配比快照:按档位保存 id,grid_number,tier,weight",
|
||||
"placeholderWeightSnapshot": "请输入测试时权重配比快照:按档位保存 id,grid_number,tier,weight",
|
||||
"labelResultCounts": "落点统计:grid_number=>出现次数",
|
||||
"placeholderResultCounts": "请输入落点统计:grid_number=>出现次数",
|
||||
"ruleTestCountRequired": "测试次数:100/500/1000必需填写",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"detail": {
|
||||
"title": "测试记录详情",
|
||||
"sectionBasic": "基本信息",
|
||||
"recordId": "记录ID",
|
||||
"testCount": "测试次数",
|
||||
"testCountSuffix": "次",
|
||||
"createTime": "创建时间",
|
||||
"admin": "执行管理员",
|
||||
"paidPoolId": "付费奖池配置ID",
|
||||
"freePoolId": "免费奖池配置ID",
|
||||
"bigwinSnapshot": "BIGWIN 权重快照",
|
||||
"sectionPaidTier": "付费抽奖档位概率(T1-T5,测试时使用)",
|
||||
"sectionFreeTier": "免费抽奖档位概率(T1-T5,测试时使用)",
|
||||
"colTier": "档位",
|
||||
"colWeight": "权重",
|
||||
"colPercent": "占比",
|
||||
"emptyPaidTier": "暂无付费档位数据(旧记录可能仅保存 tier_weights_snapshot)",
|
||||
"emptyFreeTier": "暂无免费档位数据",
|
||||
"sectionSnapshot": "权重配比快照(测试时使用的 T1-T5/BIGWIN 配置)",
|
||||
"subCw": "顺时针(非 BIGWIN)",
|
||||
"subCcw": "逆时针(非 BIGWIN)",
|
||||
"colGridNumber": "色子点数",
|
||||
"emptyCw": "暂无顺时针数据",
|
||||
"emptyCcw": "暂无逆时针数据",
|
||||
"subBigwin": "BIGWIN(按 DiceRewardConfig 配置快照)",
|
||||
"emptyBigwinTable": "暂无 BIGWIN 数据",
|
||||
"sectionResult": "落点统计(各 grid_number 出现次数)",
|
||||
"chartXAxis": "色子点数 (grid_number)",
|
||||
"emptyResult": "暂无落点数据",
|
||||
"resultTotal": "总落点次数:{n}",
|
||||
"btnImport": "导入到当前配置",
|
||||
"importTitle": "导入到正式配置",
|
||||
"importDesc": "将本测试记录导入:DiceReward(格子权重)、DiceRewardConfig(BIGWIN weight)、DiceLotteryPoolConfig(付费/免费 T1-T5 档位概率)。请选择要写入的奖池。",
|
||||
"importPaidLabel": "导入付费档位概率到奖池",
|
||||
"importPaidPlaceholder": "选择任意奖池(建议付费池)",
|
||||
"importPaidTip": "不选则使用本记录保存时的付费奖池配置 ID",
|
||||
"importFreeLabel": "导入免费档位概率到奖池",
|
||||
"importFreePlaceholder": "选择任意奖池(建议免费池)",
|
||||
"importFreeTip": "不选则使用本记录保存时的免费奖池配置 ID",
|
||||
"btnConfirmImport": "确认导入",
|
||||
"importSuccess": "导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置",
|
||||
"importFail": "导入失败",
|
||||
"dash": "—",
|
||||
"dirCw": "顺时针",
|
||||
"dirCcw": "逆时针"
|
||||
}
|
||||
}
|
||||
26
saiadmin-artd/src/locales/langs/zh/safeguard/attachment.json
Normal file
26
saiadmin-artd/src/locales/langs/zh/safeguard/attachment.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"search": {
|
||||
"username": "用户名",
|
||||
"phone": "手机号",
|
||||
"status": "状态",
|
||||
"placeholderUsername": "请输入用户名",
|
||||
"placeholderPhone": "请输入手机号",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"preview": "预览",
|
||||
"fileName": "文件名称",
|
||||
"storageMode": "存储模式",
|
||||
"fileType": "文件类型",
|
||||
"fileSize": "文件大小",
|
||||
"uploadTime": "上传时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增文件",
|
||||
"titleEdit": "编辑文件",
|
||||
"labelFileName": "文件名称",
|
||||
"placeholderFileName": "请输入文件名称",
|
||||
"ruleFileNameRequired": "请输入文件名称",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
19
saiadmin-artd/src/locales/langs/zh/safeguard/database.json
Normal file
19
saiadmin-artd/src/locales/langs/zh/safeguard/database.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"search": {
|
||||
"tableName": "表名称",
|
||||
"placeholderTableName": "请输入数据表名称"
|
||||
},
|
||||
"table": {
|
||||
"tableName": "表名称",
|
||||
"tableComment": "表注释",
|
||||
"tableEngine": "表引擎",
|
||||
"updateTime": "更新时间",
|
||||
"totalRows": "总行数",
|
||||
"fragmentSize": "碎片大小",
|
||||
"dataSize": "数据大小",
|
||||
"collation": "编码",
|
||||
"createTime": "创建时间",
|
||||
"deleteTime": "删除时间",
|
||||
"dataDetail": "数据详情"
|
||||
}
|
||||
}
|
||||
12
saiadmin-artd/src/locales/langs/zh/safeguard/dict.json
Normal file
12
saiadmin-artd/src/locales/langs/zh/safeguard/dict.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"table": {
|
||||
"select": "选中",
|
||||
"dictName": "字典名称",
|
||||
"dictCode": "字典标识",
|
||||
"dictLabel": "字典标签",
|
||||
"dictValue": "字典键值",
|
||||
"color": "颜色",
|
||||
"sort": "排序",
|
||||
"status": "状态"
|
||||
}
|
||||
}
|
||||
20
saiadmin-artd/src/locales/langs/zh/safeguard/email-log.json
Normal file
20
saiadmin-artd/src/locales/langs/zh/safeguard/email-log.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"search": {
|
||||
"labelFrom": "发件人",
|
||||
"labelTo": "收件人",
|
||||
"placeholderSendStatus": "请选择发送状态",
|
||||
"placeholderFrom": "请输入发件人",
|
||||
"placeholderTo": "请输入收件人",
|
||||
"operTime": "发送时间"
|
||||
},
|
||||
"table": {
|
||||
"no": "编号",
|
||||
"gateway": "服务Host",
|
||||
"emailFrom": "发件人",
|
||||
"emailTo": "收件人",
|
||||
"emailCode": "验证码",
|
||||
"sendStatus": "发送状态",
|
||||
"emailResponse": "发送结果",
|
||||
"sendTime": "发送时间"
|
||||
}
|
||||
}
|
||||
22
saiadmin-artd/src/locales/langs/zh/safeguard/login-log.json
Normal file
22
saiadmin-artd/src/locales/langs/zh/safeguard/login-log.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"search": {
|
||||
"loginUser": "登录用户",
|
||||
"loginIp": "登录IP",
|
||||
"loginStatus": "登录状态",
|
||||
"operTime": "操作时间",
|
||||
"placeholderLoginUser": "请输入登录用户",
|
||||
"placeholderLoginIp": "请输入登录IP",
|
||||
"placeholderLoginStatus": "请选择登录状态"
|
||||
},
|
||||
"table": {
|
||||
"no": "编号",
|
||||
"loginUser": "登录用户",
|
||||
"loginStatus": "登录状态",
|
||||
"loginIp": "登录IP",
|
||||
"operLocation": "操作地点",
|
||||
"os": "操作系统",
|
||||
"browser": "浏览器",
|
||||
"loginMessage": "登录信息",
|
||||
"loginTime": "登录时间"
|
||||
}
|
||||
}
|
||||
20
saiadmin-artd/src/locales/langs/zh/safeguard/oper-log.json
Normal file
20
saiadmin-artd/src/locales/langs/zh/safeguard/oper-log.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"search": {
|
||||
"operator": "操作用户",
|
||||
"router": "路由",
|
||||
"operIp": "操作IP",
|
||||
"operTime": "操作时间",
|
||||
"placeholderOperator": "请输入操作用户",
|
||||
"placeholderOperRouter": "请输入操作路由",
|
||||
"placeholderOperIp": "请输入操作IP"
|
||||
},
|
||||
"table": {
|
||||
"no": "编号",
|
||||
"operator": "操作用户",
|
||||
"serviceName": "业务名称",
|
||||
"router": "路由",
|
||||
"operIp": "操作IP",
|
||||
"operLocation": "操作地点",
|
||||
"operTime": "操作时间"
|
||||
}
|
||||
}
|
||||
15
saiadmin-artd/src/locales/langs/zh/system/config.json
Normal file
15
saiadmin-artd/src/locales/langs/zh/system/config.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"search": {
|
||||
"group": "分组",
|
||||
"title": "标题",
|
||||
"configName": "配置名称",
|
||||
"placeholderGroup": "请输入分组",
|
||||
"placeholderTitle": "请输入标题",
|
||||
"placeholderConfigName": "请输入配置名称"
|
||||
},
|
||||
"table": {
|
||||
"select": "选中",
|
||||
"configName": "配置名称",
|
||||
"configKey": "配置标识"
|
||||
}
|
||||
}
|
||||
39
saiadmin-artd/src/locales/langs/zh/system/dept.json
Normal file
39
saiadmin-artd/src/locales/langs/zh/system/dept.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"search": {
|
||||
"deptName": "渠道(部门)名称",
|
||||
"deptCode": "部门编码",
|
||||
"status": "状态",
|
||||
"placeholderDeptName": "请输入部门名称",
|
||||
"placeholderDeptCode": "请输入部门编码",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"deptName": "渠道(部门)名称",
|
||||
"deptCode": "部门编码",
|
||||
"leader": "部门领导",
|
||||
"sort": "排序",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增部门",
|
||||
"titleEdit": "编辑部门",
|
||||
"labelParentDept": "上级部门",
|
||||
"labelDeptName": "部门名称",
|
||||
"labelDeptCode": "部门编码",
|
||||
"labelLeader": "部门领导",
|
||||
"labelRemark": "描述",
|
||||
"labelSort": "排序",
|
||||
"labelStatus": "启用",
|
||||
"placeholderDeptName": "请输入部门名称",
|
||||
"placeholderDeptCode": "请输入部门编码",
|
||||
"placeholderRemark": "请输入部门描述",
|
||||
"placeholderSort": "请输入排序",
|
||||
"noParentDept": "无上级部门",
|
||||
"ruleParentDeptRequired": "请选择上级部门",
|
||||
"ruleDeptNameRequired": "请输入部门名称",
|
||||
"ruleDeptCodeRequired": "请输入部门编码",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
65
saiadmin-artd/src/locales/langs/zh/system/menu.json
Normal file
65
saiadmin-artd/src/locales/langs/zh/system/menu.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"search": {
|
||||
"menuName": "菜单名称",
|
||||
"route": "路由",
|
||||
"status": "状态",
|
||||
"placeholderMenuName": "请输入菜单名称",
|
||||
"placeholderMenuRoute": "请输入菜单路由",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"menuName": "菜单名称",
|
||||
"menuType": "菜单类型",
|
||||
"icon": "图标",
|
||||
"route": "路由",
|
||||
"component": "组件名称",
|
||||
"auth": "权限标识",
|
||||
"sort": "排序",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增菜单",
|
||||
"titleEdit": "编辑菜单",
|
||||
"labelMenuType": "菜单类型",
|
||||
"labelParentMenu": "上级菜单",
|
||||
"labelMenuName": "菜单名称",
|
||||
"labelRoutePath": "路由地址",
|
||||
"labelRoutePathTip": "一级菜单:以 / 开头的绝对路径(如 /dashboard) 二级及以下:相对路径(如 console、user)",
|
||||
"placeholderRoutePath": "如:/dashboard 或 console",
|
||||
"labelComponentName": "组件名称",
|
||||
"placeholderComponentName": "如: User",
|
||||
"labelComponentPath": "组件路径",
|
||||
"labelComponentPathTip": "填写组件路径(views目录下) 目录菜单:留空",
|
||||
"placeholderComponentPath": "如:/system/user 或留空",
|
||||
"labelMenuIcon": "菜单图标",
|
||||
"labelPermSlug": "权限标识",
|
||||
"placeholderPermSlug": "请输入权限标识",
|
||||
"labelLinkUrl": "外链地址",
|
||||
"placeholderLinkUrl": "如:https://saithink.top",
|
||||
"labelSort": "排序",
|
||||
"labelSortTip": "数字越大越靠前",
|
||||
"placeholderSort": "请输入排序",
|
||||
"labelStatus": "状态",
|
||||
"labelStatusTip": "禁用后,该菜单项将不可用",
|
||||
"labelIsIframe": "是否内嵌",
|
||||
"labelIsIframeTip": "外链模式下有效",
|
||||
"labelIsKeepAlive": "是否缓存",
|
||||
"labelIsKeepAliveTip": "切换tabs不刷新",
|
||||
"labelIsHidden": "是否隐藏",
|
||||
"labelIsHiddenTip": "不在菜单栏显示,但是可以通过路由访问",
|
||||
"labelIsFixedTab": "是否固定",
|
||||
"labelIsFixedTabTip": "固定在tabs导航栏",
|
||||
"labelIsFullPage": "是否全屏",
|
||||
"labelIsFullPageTip": "不继承左侧菜单和顶部导航栏",
|
||||
"noParentMenu": "无上级菜单",
|
||||
"ruleParentMenuRequired": "请选择上级菜单",
|
||||
"ruleMenuNameRequired": "请输入菜单名称",
|
||||
"ruleRoutePathRequired": "请输入路由地址",
|
||||
"ruleComponentNameRequired": "请输入组件名称",
|
||||
"rulePermSlugRequired": "请输入权限标识",
|
||||
"ruleLinkUrlRequired": "请输入外链地址",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
34
saiadmin-artd/src/locales/langs/zh/system/post.json
Normal file
34
saiadmin-artd/src/locales/langs/zh/system/post.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"search": {
|
||||
"postName": "岗位名称",
|
||||
"postCode": "岗位编码",
|
||||
"status": "状态",
|
||||
"placeholderPostName": "请输入岗位名称",
|
||||
"placeholderPostCode": "请输入岗位编码",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"postName": "岗位名称",
|
||||
"postCode": "岗位编码",
|
||||
"sort": "排序",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增岗位",
|
||||
"titleEdit": "编辑岗位",
|
||||
"labelName": "岗位名称",
|
||||
"labelCode": "岗位编码",
|
||||
"labelRemark": "描述",
|
||||
"labelSort": "排序",
|
||||
"labelStatus": "启用",
|
||||
"placeholderName": "请输入岗位名称",
|
||||
"placeholderCode": "请输入岗位编码",
|
||||
"placeholderRemark": "请输入岗位描述",
|
||||
"placeholderSort": "请输入排序",
|
||||
"ruleNameRequired": "请输入岗位名称",
|
||||
"ruleCodeRequired": "请输入岗位编码",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
38
saiadmin-artd/src/locales/langs/zh/system/role.json
Normal file
38
saiadmin-artd/src/locales/langs/zh/system/role.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"search": {
|
||||
"roleName": "角色名称",
|
||||
"roleCode": "角色编码",
|
||||
"status": "状态",
|
||||
"placeholderRoleName": "请输入角色名称",
|
||||
"placeholderRoleCode": "请输入角色编码",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"roleName": "角色名称",
|
||||
"roleCode": "角色编码",
|
||||
"level": "角色级别",
|
||||
"roleRemark": "角色描述",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增角色",
|
||||
"titleEdit": "编辑角色",
|
||||
"labelName": "角色名称",
|
||||
"labelCode": "角色标识",
|
||||
"labelLevel": "角色级别",
|
||||
"levelTip": "控制角色的权限层级, 不能操作职级高于自己的角色",
|
||||
"labelRemark": "描述",
|
||||
"labelSort": "排序",
|
||||
"labelStatus": "启用",
|
||||
"placeholderName": "请输入角色名称",
|
||||
"placeholderCode": "请输入角色编码",
|
||||
"placeholderRemark": "请输入角色描述",
|
||||
"placeholderSort": "请输入排序",
|
||||
"ruleNameRequired": "请输入角色名称",
|
||||
"ruleCodeRequired": "请输入角色编码",
|
||||
"ruleLevelRequired": "请输入角色级别",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
51
saiadmin-artd/src/locales/langs/zh/system/user.json
Normal file
51
saiadmin-artd/src/locales/langs/zh/system/user.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"search": {
|
||||
"username": "用户名",
|
||||
"phone": "手机号",
|
||||
"status": "状态",
|
||||
"placeholderUsername": "请输入用户名",
|
||||
"placeholderPhone": "请输入手机号",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"username": "用户名",
|
||||
"phone": "手机号",
|
||||
"dept": "部门",
|
||||
"dashboard": "首页",
|
||||
"loginTime": "上次登录",
|
||||
"agentId": "代理ID",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增用户",
|
||||
"titleEdit": "编辑用户",
|
||||
"labelAvatar": "头像",
|
||||
"labelUsername": "用户名",
|
||||
"labelRealname": "真实姓名",
|
||||
"labelPassword": "密码",
|
||||
"labelPasswordConfirm": "确认密码",
|
||||
"labelEmail": "邮箱",
|
||||
"labelPhone": "手机号",
|
||||
"labelDept": "部门",
|
||||
"labelRole": "角色",
|
||||
"labelPost": "岗位",
|
||||
"labelGender": "性别",
|
||||
"labelStatus": "状态",
|
||||
"labelRemark": "备注",
|
||||
"placeholderEmail": "请输入邮箱",
|
||||
"placeholderPhone": "请输入手机号",
|
||||
"placeholderRemark": "请输入备注",
|
||||
"rulePasswordNotMatch": "两次输入的密码不一致",
|
||||
"ruleUsernameRequired": "请输入用户名",
|
||||
"ruleUsernameLength": "长度在 2 到 20 个字符",
|
||||
"rulePasswordRequired": "请输入密码",
|
||||
"rulePasswordLength": "长度在 6 到 20 个字符",
|
||||
"rulePasswordConfirmRequired": "请输入确认密码",
|
||||
"ruleDeptRequired": "请选择部门",
|
||||
"ruleRoleRequired": "请选择角色",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
20
saiadmin-artd/src/locales/langs/zh/tool/code.json
Normal file
20
saiadmin-artd/src/locales/langs/zh/tool/code.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"search": {
|
||||
"tableName": "表名称",
|
||||
"placeholderTableName": "请输入数据表名称",
|
||||
"placeholderDataSource": "请输入数据源名称"
|
||||
},
|
||||
"table": {
|
||||
"tableName": "表名称",
|
||||
"tableDesc": "表描述",
|
||||
"tableComment": "表注释",
|
||||
"engine": "引擎",
|
||||
"collation": "编码",
|
||||
"template": "应用类型",
|
||||
"namespace": "应用名称",
|
||||
"stub": "模板类型",
|
||||
"tplCategory": "生成类型",
|
||||
"updateTime": "更新时间",
|
||||
"createTime": "创建时间"
|
||||
}
|
||||
}
|
||||
62
saiadmin-artd/src/locales/langs/zh/tool/crontab.json
Normal file
62
saiadmin-artd/src/locales/langs/zh/tool/crontab.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"search": {
|
||||
"taskName": "任务名称",
|
||||
"taskType": "任务类型",
|
||||
"status": "状态",
|
||||
"placeholderTaskName": "请输入任务名称",
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"no": "编号",
|
||||
"taskName": "任务名称",
|
||||
"taskType": "任务类型",
|
||||
"rule": "定时规则",
|
||||
"target": "调用目标",
|
||||
"status": "状态",
|
||||
"updateDate": "更新日期",
|
||||
"executeTime": "执行时间",
|
||||
"parameter": "任务参数",
|
||||
"executeStatus": "执行状态"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增定时任务",
|
||||
"titleEdit": "编辑定时任务",
|
||||
"labelName": "任务名称",
|
||||
"labelType": "任务类型",
|
||||
"labelTaskStyle": "定时规则",
|
||||
"labelTarget": "调用目标",
|
||||
"labelParams": "任务参数",
|
||||
"labelStatus": "状态",
|
||||
"labelRemark": "备注",
|
||||
"placeholderName": "请输入任务名称",
|
||||
"placeholderTarget": "请输入调用目标",
|
||||
"placeholderParams": "请输入任务参数",
|
||||
"placeholderRemark": "请输入备注",
|
||||
"taskStyleEveryDay": "每天",
|
||||
"taskStyleEveryHour": "每小时",
|
||||
"taskStyleNHours": "N小时",
|
||||
"taskStyleNMinutes": "N分钟",
|
||||
"taskStyleNSeconds": "N秒",
|
||||
"taskStyleEveryWeek": "每周",
|
||||
"taskStyleEveryMonth": "每月",
|
||||
"taskStyleEveryYear": "每年",
|
||||
"weekMon": "周一",
|
||||
"weekTue": "周二",
|
||||
"weekWed": "周三",
|
||||
"weekThu": "周四",
|
||||
"weekFri": "周五",
|
||||
"weekSat": "周六",
|
||||
"weekSun": "周日",
|
||||
"unitMonth": "月",
|
||||
"unitDay": "日",
|
||||
"unitHour": "时",
|
||||
"unitMinute": "分",
|
||||
"unitSecond": "秒",
|
||||
"ruleNameRequired": "任务名称不能为空",
|
||||
"ruleTypeRequired": "任务类型不能为空",
|
||||
"ruleTaskStyleRequired": "定时规则不能为空",
|
||||
"ruleTargetRequired": "调用目标不能为空",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
109
saiadmin-artd/src/locales/pageLocaleLoader.ts
Normal file
109
saiadmin-artd/src/locales/pageLocaleLoader.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* 按路由加载页面级翻译到 page 命名空间
|
||||
* 路由 /dice/lottery_pool_config/index -> 加载 langs/{locale}/dice/lottery_pool_config.json
|
||||
*/
|
||||
import i18n from '@/locales'
|
||||
import { LanguageEnum } from '@/enums/appEnum'
|
||||
|
||||
/** 路由 path 到 locale 文件路径的映射(无前导斜杠、无 /index) */
|
||||
export function getPageLocalePath(routePath: string): string | null {
|
||||
if (!routePath || routePath === '/') return null
|
||||
const normalized = routePath.replace(/\?.*$/, '').replace(/#.*$/, '').replace(/\/$/, '')
|
||||
const withoutIndex = normalized.replace(/\/index$/i, '') || '/'
|
||||
const path = withoutIndex.replace(/^\//, '') || ''
|
||||
if (!path) return null
|
||||
return path
|
||||
}
|
||||
|
||||
type PageLocaleModule = { default: Record<string, unknown> }
|
||||
|
||||
const enModules = import.meta.glob<PageLocaleModule>('./langs/en/**/*.json')
|
||||
const zhModules = import.meta.glob<PageLocaleModule>('./langs/zh/**/*.json')
|
||||
|
||||
function getModuleKey(locale: string, path: string): string {
|
||||
return `./langs/${locale}/${path}.json`
|
||||
}
|
||||
|
||||
let lastLoadedPath: string | null = null
|
||||
let lastLoadedLocale: string | null = null
|
||||
|
||||
/** 获取当前语言(locale 可能是 string 或 Ref) */
|
||||
function getCurrentLocale(): string {
|
||||
const loc = i18n.global.locale
|
||||
return typeof loc === 'string' ? loc : (loc as { value: string }).value
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载并合并页面翻译到 i18n 的 page 命名空间
|
||||
*/
|
||||
export async function loadPageLocale(routePath: string): Promise<void> {
|
||||
const path = getPageLocalePath(routePath)
|
||||
if (!path) {
|
||||
clearPageLocale()
|
||||
return
|
||||
}
|
||||
const locale = getCurrentLocale()
|
||||
const modules = locale === LanguageEnum.EN ? enModules : zhModules
|
||||
|
||||
const tryPaths: string[] = [path]
|
||||
// 兼容别名路由:例如 /user 实际页面为 /system/user
|
||||
if (!path.includes('/')) {
|
||||
tryPaths.push(`system/${path}`)
|
||||
}
|
||||
if (path === 'user') {
|
||||
tryPaths.push('system/user')
|
||||
}
|
||||
|
||||
let matchedPath: string | null = null
|
||||
let loader: (() => Promise<PageLocaleModule>) | undefined
|
||||
for (const p of tryPaths) {
|
||||
const key = getModuleKey(locale, p)
|
||||
const l = modules[key]
|
||||
if (l) {
|
||||
matchedPath = p
|
||||
loader = l
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!loader) {
|
||||
clearPageLocale()
|
||||
return
|
||||
}
|
||||
if (lastLoadedPath === matchedPath && lastLoadedLocale === locale) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const mod = await loader()
|
||||
const message = mod?.default
|
||||
if (message && typeof message === 'object') {
|
||||
i18n.global.mergeLocaleMessage(locale, { page: message })
|
||||
lastLoadedPath = matchedPath
|
||||
lastLoadedLocale = locale
|
||||
}
|
||||
} catch {
|
||||
clearPageLocale()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 page 命名空间(进入无页面翻译的路由时调用)
|
||||
*/
|
||||
export function clearPageLocale(): void {
|
||||
const locale = getCurrentLocale()
|
||||
const messages = i18n.global.getLocaleMessage(locale) as Record<string, unknown>
|
||||
if (messages && 'page' in messages) {
|
||||
const next = { ...messages }
|
||||
delete next.page
|
||||
i18n.global.setLocaleMessage(locale, next)
|
||||
}
|
||||
lastLoadedPath = null
|
||||
lastLoadedLocale = null
|
||||
}
|
||||
|
||||
/**
|
||||
* 语言切换时清空缓存,下次进入页面会重新加载
|
||||
*/
|
||||
export function invalidatePageLocaleCache(): void {
|
||||
lastLoadedPath = null
|
||||
lastLoadedLocale = null
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import { useMenuStore } from '@/store/modules/menu'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { setWorktab } from '@/utils/navigation'
|
||||
import { setPageTitle } from '@/utils/router'
|
||||
import { loadPageLocale } from '@/locales/pageLocaleLoader'
|
||||
import { RoutesAlias } from '../routesAlias'
|
||||
import { staticRoutes } from '../routes/staticRoutes'
|
||||
import { loadingService } from '@/utils/ui'
|
||||
@@ -190,6 +191,7 @@ async function handleRouteGuard(
|
||||
if (to.matched.length > 0) {
|
||||
setWorktab(to)
|
||||
setPageTitle(to)
|
||||
await loadPageLocale(to.path)
|
||||
next()
|
||||
return
|
||||
}
|
||||
@@ -207,8 +209,23 @@ function handleLoginStatus(
|
||||
userStore: ReturnType<typeof useUserStore>,
|
||||
next: NavigationGuardNext
|
||||
): boolean {
|
||||
// 已登录或访问登录页或静态路由,直接放行
|
||||
if (userStore.isLogin || to.path === RoutesAlias.Login || isStaticRoute(to.path)) {
|
||||
// 已登录或访问登录页,直接放行
|
||||
if (userStore.isLogin || to.path === RoutesAlias.Login) {
|
||||
return true
|
||||
}
|
||||
|
||||
// 未登录时访问根路径(首页),重定向到登录页
|
||||
if (to.path === '/') {
|
||||
userStore.logOut()
|
||||
next({
|
||||
name: 'Login',
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
// 其他静态路由(注册、忘记密码、错误页等)放行
|
||||
if (isStaticRoute(to.path)) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ export interface BarChartProps extends BaseChartProps, AxisDisplayProps, Interac
|
||||
data: number[] | BarDataItem[]
|
||||
/** X轴标签数据 */
|
||||
xAxisData?: string[]
|
||||
/** X轴名称(如:色子点数) */
|
||||
xAxisName?: string
|
||||
/** 柱状图宽度 */
|
||||
barWidth?: string | number
|
||||
/** 是否堆叠显示 */
|
||||
|
||||
@@ -16,13 +16,21 @@
|
||||
|
||||
import axios, { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import i18n from '@/locales'
|
||||
import { ApiStatus } from './status'
|
||||
import { HttpError, handleError, showError, showSuccess } from './error'
|
||||
import { $t } from '@/locales'
|
||||
import { BaseResponse } from '@/types'
|
||||
|
||||
/** 请求配置常量 */
|
||||
const REQUEST_TIMEOUT = 15000
|
||||
/** 当前语言(zh/en),供请求头 lang 使用,无 header 时后端按后台语言回包 */
|
||||
function getRequestLang(): string {
|
||||
const locale = i18n.global.locale as string | { value: string }
|
||||
const lang = typeof locale === 'string' ? locale : (locale && 'value' in locale ? locale.value : 'zh')
|
||||
return lang === 'en' ? 'en' : 'zh'
|
||||
}
|
||||
|
||||
/** 请求配置常量(超时时间 30s) */
|
||||
const REQUEST_TIMEOUT = 30000
|
||||
const LOGOUT_DELAY = 500
|
||||
const MAX_RETRIES = 0
|
||||
const RETRY_DELAY = 1000
|
||||
@@ -66,6 +74,7 @@ axiosInstance.interceptors.request.use(
|
||||
(request: InternalAxiosRequestConfig) => {
|
||||
const { accessToken } = useUserStore()
|
||||
if (accessToken) request.headers.set('Authorization', `Bearer ` + accessToken)
|
||||
request.headers.set('lang', getRequestLang())
|
||||
|
||||
if (request.data && !(request.data instanceof FormData) && !request.headers['Content-Type']) {
|
||||
request.headers.set('Content-Type', 'application/json')
|
||||
|
||||
@@ -11,6 +11,62 @@ import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import i18n, { $t } from '@/locales'
|
||||
|
||||
/**
|
||||
* 路径到菜单 i18n key 的映射
|
||||
* 当后端返回的菜单名为中文或非 i18n key 时,根据 path 仍可显示多语言
|
||||
*/
|
||||
export const MAP_PATH_TO_MENU_I18N_KEY: Record<string, string> = {
|
||||
'/dashboard': 'menus.dashboard.title',
|
||||
'/dashboard/console': 'menus.dashboard.console',
|
||||
'/dashboard/user-center': 'menus.userCenter.title',
|
||||
'/system': 'menus.system.title',
|
||||
'/system/user': 'menus.system.user',
|
||||
'/system/role': 'menus.system.role',
|
||||
'/system/user-center': 'menus.system.userCenter',
|
||||
'/system/menu': 'menus.system.menu',
|
||||
'/system/dept': 'menus.system.dept',
|
||||
'/system/post': 'menus.system.post',
|
||||
'/system/config': 'menus.system.config',
|
||||
'/safeguard': 'menus.safeguard.title',
|
||||
'/safeguard/dict': 'menus.safeguard.dict',
|
||||
'/safeguard/server': 'menus.safeguard.server',
|
||||
'/safeguard/oper-log': 'menus.safeguard.operLog',
|
||||
'/safeguard/login-log': 'menus.safeguard.loginLog',
|
||||
'/safeguard/email-log': 'menus.safeguard.emailLog',
|
||||
'/safeguard/database': 'menus.safeguard.database',
|
||||
'/safeguard/cache': 'menus.safeguard.cache',
|
||||
'/safeguard/attachment': 'menus.safeguard.attachment',
|
||||
'/tool': 'menus.tool.title',
|
||||
'/tool/crontab': 'menus.tool.crontab',
|
||||
'/tool/code': 'menus.tool.code',
|
||||
'/dice': 'menus.dice.title',
|
||||
'/dice/lottery_pool_config': 'menus.dice.lotteryPoolConfig',
|
||||
'/dice/lottery_pool_config/index': 'menus.dice.lotteryPoolConfig',
|
||||
'/dice/player': 'menus.dice.player',
|
||||
'/dice/player/index': 'menus.dice.player',
|
||||
'/dice/player_wallet_record': 'menus.dice.playerWalletRecord',
|
||||
'/dice/player_wallet_record/index': 'menus.dice.playerWalletRecord',
|
||||
'/dice/play_record': 'menus.dice.playRecord',
|
||||
'/dice/play_record/index': 'menus.dice.playRecord',
|
||||
'/dice/player_ticket_record': 'menus.dice.playerTicketRecord',
|
||||
'/dice/player_ticket_record/index': 'menus.dice.playerTicketRecord',
|
||||
'/dice/reward_config': 'menus.dice.rewardConfig',
|
||||
'/dice/reward_config/index': 'menus.dice.rewardConfig',
|
||||
'/dice/reward': 'menus.dice.reward',
|
||||
'/dice/reward/index': 'menus.dice.reward',
|
||||
'/dice/reward_config_record': 'menus.dice.rewardConfigRecord',
|
||||
'/dice/reward_config_record/index': 'menus.dice.rewardConfigRecord',
|
||||
'/dice/play_record_test': 'menus.dice.playRecordTest',
|
||||
'/dice/play_record_test/index': 'menus.dice.playRecordTest',
|
||||
'/dice/config': 'menus.dice.config',
|
||||
'/dice/config/index': 'menus.dice.config',
|
||||
'/result/success': 'menus.result.success',
|
||||
'/result/fail': 'menus.result.fail',
|
||||
'/exception/403': 'menus.exception.forbidden',
|
||||
'/exception/404': 'menus.exception.notFound',
|
||||
'/exception/500': 'menus.exception.serverError'
|
||||
}
|
||||
|
||||
/** 扩展的路由配置类型 */
|
||||
export type AppRouteRecordRaw = RouteRecordRaw & {
|
||||
hidden?: boolean
|
||||
@@ -34,28 +90,42 @@ export const setPageTitle = (to: RouteLocationNormalized): void => {
|
||||
const { title } = to.meta
|
||||
if (title) {
|
||||
setTimeout(() => {
|
||||
document.title = `${formatMenuTitle(String(title))} - ${AppConfig.systemInfo.name}`
|
||||
document.title = `${formatMenuTitle(String(title), to.path)} - ${AppConfig.systemInfo.name}`
|
||||
}, 150)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路径获取对应的菜单 i18n key(若有)
|
||||
*/
|
||||
export const getMenuI18nKeyByPath = (path: string): string | undefined => {
|
||||
if (!path) return undefined
|
||||
const normalized = path.replace(/\?.*$/, '').replace(/#.*$/, '').replace(/\/$/, '') || '/'
|
||||
return MAP_PATH_TO_MENU_I18N_KEY[normalized]
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化菜单标题
|
||||
* @param title 菜单标题,可以是 i18n 的 key,也可以是字符串
|
||||
* @param title 菜单标题,可以是 i18n 的 key(如 menus.dashboard.title),也可以是中文等纯文本
|
||||
* @param path 可选,当前菜单路由 path;当 title 非 i18n key 时,用 path 查表得到 key 再翻译,以实现多语言切换
|
||||
* @returns 格式化后的菜单标题
|
||||
*/
|
||||
export const formatMenuTitle = (title: string): string => {
|
||||
if (title) {
|
||||
if (title.startsWith('menus.')) {
|
||||
// 使用 te() 方法检查翻译键值是否存在,避免控制台警告
|
||||
if (i18n.global.te(title)) {
|
||||
return $t(title)
|
||||
} else {
|
||||
// 如果翻译不存在,返回键值的最后部分作为fallback
|
||||
return title.split('.').pop() || title
|
||||
}
|
||||
export const formatMenuTitle = (title: string, path?: string): string => {
|
||||
if (!title) return ''
|
||||
|
||||
if (title.startsWith('menus.')) {
|
||||
if (i18n.global.te(title)) {
|
||||
return $t(title)
|
||||
}
|
||||
return title
|
||||
return title.split('.').pop() || title
|
||||
}
|
||||
return ''
|
||||
|
||||
if (path) {
|
||||
const i18nKey = getMenuI18nKeyByPath(path)
|
||||
if (i18nKey && i18n.global.te(i18nKey)) {
|
||||
return $t(i18nKey)
|
||||
}
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// ANSI 转义码生成网站 https://patorjk.com/software/taag/#p=display&f=Big&t=ABB%0A
|
||||
const asciiArt = `
|
||||
\x1b[32m欢迎使用 SaiAdmin 6.x
|
||||
\x1b[0m
|
||||
\x1b[36mSaiAdmin 官网: https://saithink.top
|
||||
\x1b[0m
|
||||
`
|
||||
console.log(asciiArt)
|
||||
|
||||
@@ -40,9 +40,9 @@ export const tableConfig = {
|
||||
// 总条数
|
||||
totalFields: ['total', 'count'],
|
||||
// 当前页码
|
||||
currentFields: ['current', 'page', 'pageNum'],
|
||||
currentFields: ['current', 'page', 'pageNum', 'current_page'],
|
||||
// 每页大小
|
||||
sizeFields: ['size', 'pageSize', 'limit'],
|
||||
sizeFields: ['size', 'pageSize', 'limit', 'per_page'],
|
||||
|
||||
// 请求参数映射配置,前端发送请求时使用的分页参数名
|
||||
// useTable 组合式函数传递分页参数的时候 用 current 跟 size
|
||||
|
||||
@@ -143,10 +143,10 @@ export const defaultResponseAdapter = <T>(response: unknown): ApiResponse<T> =>
|
||||
total = extractTotal(res, records, tableConfig.totalFields)
|
||||
pagination = extractPagination(res)
|
||||
|
||||
// 如果没有找到,检查嵌套data
|
||||
// 如果没有找到,检查嵌套 data(如 ThinkPHP paginate: { data: { total, per_page, current_page, data: [] } })
|
||||
if (records.length === 0 && 'data' in res && typeof res.data === 'object') {
|
||||
const data = res.data as Record<string, unknown>
|
||||
records = extractRecords(data, ['list', 'records', 'items'])
|
||||
records = extractRecords(data, ['list', 'data', 'records', 'items'])
|
||||
total = extractTotal(data, records, tableConfig.totalFields)
|
||||
pagination = extractPagination(res, data)
|
||||
|
||||
|
||||
@@ -12,6 +12,15 @@
|
||||
<SalesOverview />
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :sm="24" :md="12" :lg="12">
|
||||
<WalletRecordList />
|
||||
</ElCol>
|
||||
<ElCol :sm="24" :md="12" :lg="12">
|
||||
<NewPlayerList />
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
</template>
|
||||
|
||||
<template v-if="userInfo.dashboard === 'work'">
|
||||
@@ -27,8 +36,6 @@
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
</template>
|
||||
|
||||
<AboutProject />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -36,7 +43,8 @@
|
||||
import CardList from './modules/card-list.vue'
|
||||
import ActiveUser from './modules/active-user.vue'
|
||||
import SalesOverview from './modules/sales-overview.vue'
|
||||
import AboutProject from './modules/about-project.vue'
|
||||
import WalletRecordList from './modules/wallet-record-list.vue'
|
||||
import NewPlayerList from './modules/new-player-list.vue'
|
||||
import NewUser from './modules/new-user.vue'
|
||||
import Dynamic from './modules/dynamic-stats.vue'
|
||||
import TodoList from './modules/todo-list.vue'
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<template>
|
||||
<div class="art-card p-5 flex-b mb-5 max-sm:mb-4">
|
||||
<div>
|
||||
<h2 class="text-2xl font-medium">关于项目</h2>
|
||||
<p class="text-g-700 mt-1">{{ systemName }} 是一款兼具设计美学与高效开发的后台系统</p>
|
||||
<p class="text-g-700 mt-1">使用了 webman + Vue3 + Element Plus 高性能、高颜值技术栈</p>
|
||||
|
||||
<div class="flex flex-wrap gap-3.5 max-w-150 mt-9">
|
||||
<div
|
||||
class="w-60 flex-cb h-12.5 px-3.5 border border-g-300 c-p rounded-lg text-sm bg-g-100 duration-300 hover:-translate-y-1 max-sm:w-full"
|
||||
v-for="link in linkList"
|
||||
:key="link.label"
|
||||
@click="goPage(link.url)"
|
||||
>
|
||||
<span class="text-g-700">{{ link.label }}</span>
|
||||
<ArtSvgIcon icon="ri:arrow-right-s-line" class="text-lg text-g-600" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<img class="w-75 max-md:!hidden" src="@imgs/draw/draw1.png" alt="draw1" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import AppConfig from '@/config'
|
||||
|
||||
const systemName = AppConfig.systemInfo.name
|
||||
|
||||
const linkList = [
|
||||
{ label: '项目官网', url: 'https://saithink.top/' },
|
||||
{ label: '文档', url: 'https://saithink.top/documents/' },
|
||||
{ label: 'Github', url: 'https://github.com/saithink/saiadmin' },
|
||||
{ label: '插件市场', url: 'https://saas.saithink.top/' }
|
||||
]
|
||||
|
||||
/**
|
||||
* 在新标签页中打开指定 URL
|
||||
* @param url 要打开的网页地址
|
||||
*/
|
||||
const goPage = (url: string): void => {
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
</script>
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="art-card h-105 p-4 box-border mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header">
|
||||
<div class="title">
|
||||
<h4>月度登录汇总</h4>
|
||||
<h4>{{ $t('console.activeUser.title') }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<ArtBarChart
|
||||
@@ -17,22 +17,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchLoginBarChart } from '@/api/dashboard'
|
||||
import { fetchRechargeBarChart } from '@/api/dashboard'
|
||||
|
||||
/**
|
||||
* 登录数据
|
||||
* 充值金额数据
|
||||
*/
|
||||
const yData = ref<number[]>([])
|
||||
|
||||
/**
|
||||
* 时间数据
|
||||
* 月份数据
|
||||
*/
|
||||
const xData = ref<string[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
fetchLoginBarChart().then((data) => {
|
||||
yData.value = data.login_count
|
||||
xData.value = data.login_month
|
||||
fetchRechargeBarChart().then((data: any) => {
|
||||
yData.value = data?.recharge_amount ?? []
|
||||
xData.value = data?.recharge_month ?? []
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -2,73 +2,95 @@
|
||||
<ElRow :gutter="20" class="flex">
|
||||
<ElCol :sm="12" :md="6" :lg="6">
|
||||
<div class="art-card relative flex flex-col justify-center h-35 px-5 mb-5 max-sm:mb-4">
|
||||
<span class="text-g-700 text-sm">用户统计</span>
|
||||
<ArtCountTo class="text-[26px] font-medium mt-2" :target="statData.user" :duration="1300" />
|
||||
<span class="text-g-700 text-sm">{{ $t('console.card.playerRegister') }}</span>
|
||||
<ArtCountTo class="text-[26px] font-medium mt-2" :target="statData.player_count" :duration="1300" />
|
||||
<div class="flex-c mt-1">
|
||||
<span class="text-xs text-g-600">较上周</span>
|
||||
<span class="ml-1 text-xs font-semibold text-success">+10%</span>
|
||||
<span class="text-xs text-g-600">{{ $t('console.card.vsLastWeek') }}</span>
|
||||
<span
|
||||
class="ml-1 text-xs font-semibold"
|
||||
:class="changeClass(statData.player_count_change)"
|
||||
>
|
||||
{{ formatChange(statData.player_count_change) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="absolute top-0 bottom-0 right-5 m-auto size-12.5 rounded-xl flex-cc bg-theme/10"
|
||||
>
|
||||
<ArtSvgIcon icon="ri:group-line" class="text-xl text-theme" />
|
||||
<ArtSvgIcon icon="ri:user-add-line" class="text-xl text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</ElCol>
|
||||
<ElCol :sm="12" :md="6" :lg="6">
|
||||
<div class="art-card relative flex flex-col justify-center h-35 px-5 mb-5 max-sm:mb-4">
|
||||
<span class="text-g-700 text-sm">附件统计</span>
|
||||
<span class="text-g-700 text-sm">{{ $t('console.card.playerCharge') }}</span>
|
||||
<ArtCountTo
|
||||
class="text-[26px] font-medium mt-2"
|
||||
:target="statData.attach"
|
||||
:target="statData.charge_amount"
|
||||
:duration="1300"
|
||||
:decimals="2"
|
||||
/>
|
||||
<div class="flex-c mt-1">
|
||||
<span class="text-xs text-g-600">较上周</span>
|
||||
<span class="ml-1 text-xs font-semibold text-success">+10%</span>
|
||||
<span class="text-xs text-g-600">{{ $t('console.card.vsLastWeek') }}</span>
|
||||
<span
|
||||
class="ml-1 text-xs font-semibold"
|
||||
:class="changeClass(statData.charge_amount_change)"
|
||||
>
|
||||
{{ formatChange(statData.charge_amount_change) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="absolute top-0 bottom-0 right-5 m-auto size-12.5 rounded-xl flex-cc bg-theme/10"
|
||||
>
|
||||
<ArtSvgIcon icon="ri:attachment-line" class="text-xl text-theme" />
|
||||
<ArtSvgIcon icon="ri:money-dollar-circle-line" class="text-xl text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</ElCol>
|
||||
<ElCol :sm="12" :md="6" :lg="6">
|
||||
<div class="art-card relative flex flex-col justify-center h-35 px-5 mb-5 max-sm:mb-4">
|
||||
<span class="text-g-700 text-sm">登录统计</span>
|
||||
<span class="text-g-700 text-sm">{{ $t('console.card.playerWithdraw') }}</span>
|
||||
<ArtCountTo
|
||||
class="text-[26px] font-medium mt-2"
|
||||
:target="statData.login"
|
||||
:target="statData.withdraw_amount"
|
||||
:duration="1300"
|
||||
:decimals="2"
|
||||
/>
|
||||
<div class="flex-c mt-1">
|
||||
<span class="text-xs text-g-600">较上周</span>
|
||||
<span class="ml-1 text-xs font-semibold text-success">+12%</span>
|
||||
<span class="text-xs text-g-600">{{ $t('console.card.vsLastWeek') }}</span>
|
||||
<span
|
||||
class="ml-1 text-xs font-semibold"
|
||||
:class="changeClass(statData.withdraw_amount_change)"
|
||||
>
|
||||
{{ formatChange(statData.withdraw_amount_change) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="absolute top-0 bottom-0 right-5 m-auto size-12.5 rounded-xl flex-cc bg-theme/10"
|
||||
>
|
||||
<ArtSvgIcon icon="ri:fire-line" class="text-xl text-theme" />
|
||||
<ArtSvgIcon icon="ri:bank-card-line" class="text-xl text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</ElCol>
|
||||
<ElCol :sm="12" :md="6" :lg="6">
|
||||
<div class="art-card relative flex flex-col justify-center h-35 px-5 mb-5 max-sm:mb-4">
|
||||
<span class="text-g-700 text-sm">操作统计</span>
|
||||
<span class="text-g-700 text-sm">{{ $t('console.card.playerPlayCount') }}</span>
|
||||
<ArtCountTo
|
||||
class="text-[26px] font-medium mt-2"
|
||||
:target="statData.operate"
|
||||
:target="statData.play_count"
|
||||
:duration="1300"
|
||||
/>
|
||||
<div class="flex-c mt-1">
|
||||
<span class="text-xs text-g-600">较上周</span>
|
||||
<span class="ml-1 text-xs font-semibold text-danger">-5%</span>
|
||||
<span class="text-xs text-g-600">{{ $t('console.card.vsLastWeek') }}</span>
|
||||
<span
|
||||
class="ml-1 text-xs font-semibold"
|
||||
:class="changeClass(statData.play_count_change)"
|
||||
>
|
||||
{{ formatChange(statData.play_count_change) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="absolute top-0 bottom-0 right-5 m-auto size-12.5 rounded-xl flex-cc bg-theme/10"
|
||||
>
|
||||
<ArtSvgIcon icon="ri:pie-chart-line" class="text-xl text-theme" />
|
||||
<ArtSvgIcon icon="ri:gamepad-line" class="text-xl text-theme" />
|
||||
</div>
|
||||
</div>
|
||||
</ElCol>
|
||||
@@ -79,15 +101,40 @@
|
||||
import { fetchStatistics } from '@/api/dashboard'
|
||||
|
||||
const statData = ref({
|
||||
user: 0,
|
||||
attach: 0,
|
||||
login: 0,
|
||||
operate: 0
|
||||
player_count: 0,
|
||||
player_count_change: 0,
|
||||
charge_amount: 0,
|
||||
charge_amount_change: 0,
|
||||
withdraw_amount: 0,
|
||||
withdraw_amount_change: 0,
|
||||
play_count: 0,
|
||||
play_count_change: 0
|
||||
})
|
||||
|
||||
function formatChange(val: number): string {
|
||||
if (val > 0) return `+${val}%`
|
||||
if (val < 0) return `${val}%`
|
||||
return '0%'
|
||||
}
|
||||
|
||||
function changeClass(val: number): string {
|
||||
if (val > 0) return 'text-success'
|
||||
if (val < 0) return 'text-danger'
|
||||
return 'text-g-600'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchStatistics().then((data) => {
|
||||
statData.value = data
|
||||
fetchStatistics().then((data: any) => {
|
||||
statData.value = {
|
||||
player_count: data?.player_count ?? 0,
|
||||
player_count_change: data?.player_count_change ?? 0,
|
||||
charge_amount: data?.charge_amount ?? 0,
|
||||
charge_amount_change: data?.charge_amount_change ?? 0,
|
||||
withdraw_amount: data?.withdraw_amount ?? 0,
|
||||
withdraw_amount_change: data?.withdraw_amount_change ?? 0,
|
||||
play_count: data?.play_count ?? 0,
|
||||
play_count_change: data?.play_count_change ?? 0
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<div class="art-card h-128 p-5 mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header">
|
||||
<div class="title">
|
||||
<h4>动态</h4>
|
||||
<p>新增<span class="text-success">+6</span></p>
|
||||
<h4>{{ $t('console.dynamic.title') }}</h4>
|
||||
<p>{{ $t('console.dynamic.newCount') }}<span class="text-success">+6</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<div class="art-card p-5 overflow-hidden mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header mb-4">
|
||||
<div class="title">
|
||||
<h4>{{ $t('console.newPlayer.title') }}</h4>
|
||||
<p class="text-g-600 text-sm mt-1">{{ $t('console.newPlayer.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<ArtTable
|
||||
class="w-full"
|
||||
:data="tableData"
|
||||
style="width: 100%"
|
||||
size="default"
|
||||
:border="false"
|
||||
:stripe="true"
|
||||
:header-cell-style="{ background: 'transparent' }"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn :label="$t('console.newPlayer.player')" prop="name" min-width="120" align="center" />
|
||||
<ElTableColumn :label="$t('console.newPlayer.balance')" prop="coin" min-width="120" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatCoin(scope.row.coin) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('console.newPlayer.ticket')" prop="total_ticket_count" min-width="100" align="center" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchNewPlayerList, type NewPlayerItem } from '@/api/dashboard'
|
||||
|
||||
const tableData = ref<NewPlayerItem[]>([])
|
||||
|
||||
function formatCoin(val: number | undefined): string {
|
||||
if (val === undefined || val === null) return '0.00'
|
||||
return Number(val).toFixed(2)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchNewPlayerList().then((data) => {
|
||||
tableData.value = Array.isArray(data) ? data : []
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@@ -2,13 +2,13 @@
|
||||
<div class="art-card p-5 h-128 overflow-hidden mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header">
|
||||
<div class="title">
|
||||
<h4>新用户</h4>
|
||||
<p>这个月增长<span class="text-success">+20%</span></p>
|
||||
<h4>{{ $t('console.newUser.title') }}</h4>
|
||||
<p>{{ $t('console.newUser.growth') }}<span class="text-success">+20%</span></p>
|
||||
</div>
|
||||
<ElRadioGroup v-model="radio2">
|
||||
<ElRadioButton value="本月" label="本月"></ElRadioButton>
|
||||
<ElRadioButton value="上月" label="上月"></ElRadioButton>
|
||||
<ElRadioButton value="今年" label="今年"></ElRadioButton>
|
||||
<ElRadioButton label="thisMonth">{{ $t('console.newUser.thisMonth') }}</ElRadioButton>
|
||||
<ElRadioButton label="lastMonth">{{ $t('console.newUser.lastMonth') }}</ElRadioButton>
|
||||
<ElRadioButton label="thisYear">{{ $t('console.newUser.thisYear') }}</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
</div>
|
||||
<ArtTable
|
||||
@@ -21,7 +21,7 @@
|
||||
:header-cell-style="{ background: 'transparent' }"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn label="头像" prop="avatar" width="150px">
|
||||
<ElTableColumn :label="$t('console.newUser.avatar')" prop="avatar" width="150px">
|
||||
<template #default="scope">
|
||||
<div style="display: flex; align-items: center">
|
||||
<img class="size-9 rounded-lg" :src="scope.row.avatar" alt="avatar" />
|
||||
@@ -29,15 +29,15 @@
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="地区" prop="province" />
|
||||
<ElTableColumn label="性别" prop="avatar">
|
||||
<ElTableColumn :label="$t('console.newUser.region')" prop="province" />
|
||||
<ElTableColumn :label="$t('console.newUser.gender')" prop="avatar">
|
||||
<template #default="scope">
|
||||
<div style="display: flex; align-items: center">
|
||||
<span style="margin-left: 10px">{{ scope.row.sex === 1 ? '男' : '女' }}</span>
|
||||
<span style="margin-left: 10px">{{ scope.row.sex === 1 ? $t('console.newUser.male') : $t('console.newUser.female') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="进度" width="240">
|
||||
<ElTableColumn :label="$t('console.newUser.progress')" width="240">
|
||||
<template #default="scope">
|
||||
<ElProgress
|
||||
:percentage="scope.row.pro"
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
const ANIMATION_DELAY = 100
|
||||
|
||||
const radio2 = ref('本月')
|
||||
const radio2 = ref('thisMonth')
|
||||
|
||||
/**
|
||||
* 新用户表格数据
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="art-card h-105 p-5 mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header">
|
||||
<div class="title">
|
||||
<h4>近期登录统计</h4>
|
||||
<h4>{{ $t('console.salesOverview.title') }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<ArtLineChart
|
||||
@@ -16,22 +16,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchLoginChart } from '@/api/dashboard'
|
||||
import { fetchRechargeChart } from '@/api/dashboard'
|
||||
|
||||
/**
|
||||
* 登录数据
|
||||
* 充值金额数据
|
||||
*/
|
||||
const yData = ref<number[]>([])
|
||||
|
||||
/**
|
||||
* 时间数据
|
||||
* 日期数据
|
||||
*/
|
||||
const xData = ref<string[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
fetchLoginChart().then((data) => {
|
||||
yData.value = data.login_count
|
||||
xData.value = data.login_date
|
||||
fetchRechargeChart().then((data: any) => {
|
||||
yData.value = data?.recharge_amount ?? []
|
||||
xData.value = data?.recharge_date ?? []
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<div class="art-card h-128 p-5 mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header">
|
||||
<div class="title">
|
||||
<h4>代办事项</h4>
|
||||
<p>待处理<span class="text-danger">3</span></p>
|
||||
<h4>{{ $t('console.todo.title') }}</h4>
|
||||
<p>{{ $t('console.todo.pending') }}<span class="text-danger">3</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<div class="art-card p-5 overflow-hidden mb-5 max-sm:mb-4">
|
||||
<div class="art-card-header mb-4">
|
||||
<div class="title">
|
||||
<h4>{{ $t('console.walletRecord.title') }}</h4>
|
||||
<p class="text-g-600 text-sm mt-1">{{ $t('console.walletRecord.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<ArtTable
|
||||
class="w-full"
|
||||
:data="tableData"
|
||||
style="width: 100%"
|
||||
size="default"
|
||||
:border="false"
|
||||
:stripe="true"
|
||||
:header-cell-style="{ background: 'transparent' }"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn :label="$t('console.walletRecord.player')" prop="player_name" min-width="120" align="center" />
|
||||
<ElTableColumn :label="$t('console.walletRecord.chargeAmount')" prop="coin" min-width="120" align="center">
|
||||
<template #default="scope">
|
||||
{{ formatCoin(scope.row.coin) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('console.walletRecord.chargeTime')" prop="create_time" min-width="170" align="center" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchWalletRecordList, type WalletRecordItem } from '@/api/dashboard'
|
||||
|
||||
const tableData = ref<WalletRecordItem[]>([])
|
||||
|
||||
function formatCoin(val: number | undefined): string {
|
||||
if (val === undefined || val === null) return '0.00'
|
||||
return Number(val).toFixed(2)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchWalletRecordList().then((data) => {
|
||||
tableData.value = Array.isArray(data) ? data : []
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,135 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 色子奖池配置 API 接口
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* 获取数据列表(DiceLotteryPoolConfig)
|
||||
* @param params 搜索参数
|
||||
* @returns 数据列表
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,含 id、name、t1_weight~t5_weight,用于一键测试权重档位类型下拉
|
||||
* name 映射:default=原 type=0,killScore=原 type=1,up=原 type=2
|
||||
*/
|
||||
async getOptions(): Promise<
|
||||
Array<{
|
||||
id: number
|
||||
name: string
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
t4_weight: number
|
||||
t5_weight: number
|
||||
}>
|
||||
> {
|
||||
const res = await request.get<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/getOptions'
|
||||
})
|
||||
const rows = Array.isArray(res) ? res : (Array.isArray((res as any)?.data) ? (res as any).data : [])
|
||||
if (!Array.isArray(rows)) return []
|
||||
return rows.map((r: any) => ({
|
||||
id: Number(r.id),
|
||||
name: String(r.name ?? r.id ?? ''),
|
||||
t1_weight: Number(r.t1_weight ?? 0),
|
||||
t2_weight: Number(r.t2_weight ?? 0),
|
||||
t3_weight: Number(r.t3_weight ?? 0),
|
||||
t4_weight: Number(r.t4_weight ?? 0),
|
||||
t5_weight: Number(r.t5_weight ?? 0)
|
||||
}))
|
||||
},
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param id 数据ID
|
||||
* @returns 数据详情
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建数据
|
||||
* @param params 数据参数
|
||||
* @returns 执行结果
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param params 数据参数
|
||||
* @returns 执行结果
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param id 数据ID
|
||||
* @returns 执行结果
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取当前彩金池(Redis 实例化,无则按 type=0 创建),含玩家累计盈利 profit_amount 实时值
|
||||
*/
|
||||
getCurrentPool() {
|
||||
return request.get<{
|
||||
id: number
|
||||
name: string
|
||||
safety_line: number
|
||||
kill_enabled: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
t4_weight: number
|
||||
t5_weight: number
|
||||
profit_amount: number
|
||||
}>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/getCurrentPool'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新当前彩金池:仅 safety_line、t1_weight~t5_weight,不可改 profit_amount
|
||||
*/
|
||||
updateCurrentPool(params: { safety_line?: number; kill_enabled?: number }) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/updateCurrentPool',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 重置当前彩金池的玩家累计盈利(profit_amount 置为 0)
|
||||
*/
|
||||
resetProfitAmount() {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/resetProfitAmount'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 色子奖池配置 API接口
|
||||
* 玩家抽奖记录(测试数据) API接口
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/lottery_config/DiceLotteryConfig/index',
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/lottery_config/DiceLotteryConfig/read?id=' + id
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/lottery_config/DiceLotteryConfig/save',
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/lottery_config/DiceLotteryConfig/update',
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,8 +58,17 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/lottery_config/DiceLotteryConfig/destroy',
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 一键删除所有测试数据
|
||||
*/
|
||||
clearAll() {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/clearAll'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -71,5 +71,41 @@ export default {
|
||||
url: '/dice/player/DicePlayer/updateStatus',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取彩金池配置选项(DiceLotteryPoolConfig.id、name),供 lottery_config_id 下拉使用
|
||||
* @returns [ { id, name } ]
|
||||
*/
|
||||
async getLotteryConfigOptions(): Promise<Array<{ id: number; name: string }>> {
|
||||
const res = await request.get<any>({
|
||||
url: '/dice/player/DicePlayer/getLotteryConfigOptions'
|
||||
})
|
||||
const rows = (Array.isArray(res) ? res : (res?.data ?? [])) as Array<{ id: number; name: string }>
|
||||
return rows.map((r) => ({ id: Number(r.id), name: String(r.name ?? r.id ?? '') }))
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取后台管理员选项(SystemUser),供 admin_id 下拉使用
|
||||
* @returns [ { id, username, realname, label } ]
|
||||
*/
|
||||
async getSystemUserOptions(): Promise<
|
||||
Array<{ id: number; username: string; realname: string; label: string }>
|
||||
> {
|
||||
const res = await request.get<any>({
|
||||
url: '/dice/player/DicePlayer/getSystemUserOptions'
|
||||
})
|
||||
const rows = (Array.isArray(res) ? res : (res?.data ?? [])) as Array<{
|
||||
id: number
|
||||
username: string
|
||||
realname: string
|
||||
label: string
|
||||
}>
|
||||
return rows.map((r) => ({
|
||||
id: Number(r.id),
|
||||
username: String(r.username ?? ''),
|
||||
realname: String(r.realname ?? ''),
|
||||
label: String(r.label ?? r.username ?? r.id ?? '')
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/index',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/read?id=' + id
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/save',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/update',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/destroy',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -68,7 +68,7 @@ export default {
|
||||
*/
|
||||
getPlayerOptions() {
|
||||
return request.get<{ id: number; username: string }[]>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions'
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions'
|
||||
})
|
||||
},
|
||||
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
*/
|
||||
getPlayerWalletBefore(playerId: number | string) {
|
||||
return request.get<{ wallet_before: number }>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore',
|
||||
params: { player_id: playerId }
|
||||
})
|
||||
},
|
||||
@@ -93,7 +93,7 @@ export default {
|
||||
remark?: string
|
||||
}) {
|
||||
return request.post<any>({
|
||||
url: '/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate',
|
||||
url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
98
saiadmin-artd/src/views/plugin/dice/api/reward/index.ts
Normal file
98
saiadmin-artd/src/views/plugin/dice/api/reward/index.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 奖励对照(dice_reward)API
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* 分页列表,按 direction 区分顺时针(0)/逆时针(1)
|
||||
* @param params direction(必), tier(选), page, limit, orderField, orderType
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/core/dice/reward/DiceReward/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按档位分组获取当前方向的配置+权重(单方向)
|
||||
* @param direction 0=顺时针 1=逆时针
|
||||
*/
|
||||
weightRatioList(direction: 0 | 1) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/reward/DiceReward/weightRatioList',
|
||||
params: { direction }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按档位分组获取配置+顺时针/逆时针权重(dice_reward 双方向)
|
||||
*/
|
||||
weightRatioListWithDirection() {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/reward/DiceReward/weightRatioListWithDirection'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按 DiceReward 主键 id 批量更新 weight
|
||||
* @param items [{ id: DiceReward.id, weight: 1-10000 }, ...]
|
||||
*/
|
||||
batchUpdateWeights(items: Array<{ id: number; weight: number }>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/reward/DiceReward/batchUpdateWeights',
|
||||
data: { items }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:批量更新当前方向的权重(单方向)
|
||||
*/
|
||||
batchUpdateWeightsByDirection(direction: 0 | 1, items: Array<{ id: number; weight: number }>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/reward/DiceReward/batchUpdateWeightsByDirection',
|
||||
data: { direction, items }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 一键测试权重:创建测试记录并启动后台执行,按付费/免费、顺逆方向交替抽奖
|
||||
* 可选 lottery_config_id;不选则传 paid_tier_weights / free_tier_weights(T1-T5)
|
||||
*/
|
||||
startWeightTest(params: {
|
||||
lottery_config_id?: number
|
||||
paid_lottery_config_id?: number
|
||||
free_lottery_config_id?: number
|
||||
s_count?: number
|
||||
n_count?: number
|
||||
paid_s_count?: number
|
||||
paid_n_count?: number
|
||||
free_s_count?: number
|
||||
free_n_count?: number
|
||||
paid_tier_weights?: Record<string, number>
|
||||
free_tier_weights?: Record<string, number>
|
||||
}) {
|
||||
return request.post<{ record_id: number }>({
|
||||
url: '/core/dice/reward/DiceReward/startWeightTest',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询一键测试进度
|
||||
*/
|
||||
getTestProgress(recordId: number) {
|
||||
return request.get<{
|
||||
total_play_count: number
|
||||
over_play_count: number
|
||||
status: number
|
||||
remark: string | null
|
||||
result_counts: Record<number, number> | null
|
||||
tier_counts: Record<string, number> | null
|
||||
}>({
|
||||
url: '/core/dice/reward/DiceReward/getTestProgress',
|
||||
params: { record_id: recordId }
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/reward_config/DiceRewardConfig/index',
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/reward_config/DiceRewardConfig/read?id=' + id
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/reward_config/DiceRewardConfig/save',
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/reward_config/DiceRewardConfig/update',
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,8 +58,62 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/reward_config/DiceRewardConfig/destroy',
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量更新奖励索引配置(第一页:id、grid_number、ui_text、real_ev、tier、remark)
|
||||
*/
|
||||
batchUpdate(items: Array<{ id: number; grid_number?: number; ui_text?: string; real_ev?: number; tier?: string; remark?: string }>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/batchUpdate',
|
||||
data: { items }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* T1-T5、BIGWIN 权重配比:按档位分组获取配置列表
|
||||
*/
|
||||
weightRatioList() {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/weightRatioList'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* T1-T5、BIGWIN 权重配比:批量更新顺时针/逆时针权重(写入 dice_reward)
|
||||
*/
|
||||
/** 按 DiceReward 主键 id 批量更新 weight;items: [{ id, weight }, ...] */
|
||||
batchUpdateWeights(items: Array<{ id: number; weight: number }>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/batchUpdateWeights',
|
||||
data: { items }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 大奖权重:按 grid_number 批量保存 BIGWIN 权重(无需 reward id,不存在则自动创建)
|
||||
*/
|
||||
saveBigwinWeightsByGrid(items: Array<{ grid_number: number; weight: number }>) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/saveBigwinWeightsByGrid',
|
||||
data: { items }
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建奖励对照:按当前奖励配置为顺时针(0)、逆时针(1)生成所有色子可能对应的 dice_reward 记录,权重默认 1,可在奖励对照页权重编辑中调整
|
||||
*/
|
||||
createRewardReference() {
|
||||
return request.post<{
|
||||
created_clockwise: number
|
||||
created_counterclockwise: number
|
||||
updated_clockwise: number
|
||||
updated_counterclockwise: number
|
||||
}>({
|
||||
url: '/core/dice/reward_config/DiceRewardConfig/createRewardReference'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录 API接口
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* 获取数据列表
|
||||
* @param params 搜索参数
|
||||
* @returns 数据列表
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param id 数据ID
|
||||
* @returns 数据详情
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建数据
|
||||
* @param params 数据参数
|
||||
* @returns 执行结果
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param params 数据参数
|
||||
* @returns 执行结果
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param id 数据ID
|
||||
* @returns 执行结果
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 导入:测试记录 → DiceReward、DiceRewardConfig(BIGWIN)、DiceLotteryPoolConfig(付费/免费 T1-T5)
|
||||
* @param record_id 测试记录 ID
|
||||
* @param paid_lottery_config_id 可选,导入付费档位概率到的奖池(type=0)
|
||||
* @param free_lottery_config_id 可选,导入免费档位概率到的奖池(type=1)
|
||||
* @param lottery_config_id 兼容旧版,不传 paid/free 时用作统一奖池
|
||||
*/
|
||||
importFromRecord(params: {
|
||||
record_id: number
|
||||
paid_lottery_config_id?: number | null
|
||||
free_lottery_config_id?: number | null
|
||||
lottery_config_id?: number | null
|
||||
}) {
|
||||
return request.post<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/importFromRecord',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,23 @@
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<!-- <ElButton v-permission="'dice:config:index:save'" @click="showDialog('add')" v-ripple>-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:add-fill" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:config:index:destroy'"-->
|
||||
<!-- :disabled="selectedRows.length === 0"-->
|
||||
<!-- @click="deleteSelectedRows(api.delete, refreshData)"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:delete-bin-5-line" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 删除-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton v-permission="'dice:config:index:save'" @click="showDialog('add')" v-ripple>-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:add-fill" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:config:index:destroy'"-->
|
||||
<!-- :disabled="selectedRows.length === 0"-->
|
||||
<!-- @click="deleteSelectedRows(api.delete, refreshData)"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:delete-bin-5-line" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 删除-->
|
||||
<!-- </ElButton>-->
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
@@ -50,11 +50,11 @@
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:config:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:config:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
@@ -108,12 +108,21 @@
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'group', label: '分组', minWidth: 140 },
|
||||
{ prop: 'title', label: '标题', minWidth: 160 },
|
||||
{ prop: 'name', label: '配置名称' },
|
||||
{ prop: 'value', label: '值', minWidth: 240 },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
// { type: 'selection' },
|
||||
{ prop: 'group', label: 'page.table.group', minWidth: 140, align: 'center' },
|
||||
{ prop: 'title', label: 'page.table.title', minWidth: 160, align: 'center' },
|
||||
{ prop: 'title_en', label: 'page.table.titleEn', minWidth: 160, align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.configName', align: 'center' },
|
||||
{ prop: 'value', label: 'page.table.value', minWidth: 240, align: 'center' },
|
||||
{ prop: 'value_en', label: 'page.table.valueEn', minWidth: 240, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -124,9 +133,9 @@
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
// deleteRow,
|
||||
// deleteSelectedRows,
|
||||
handleSelectionChange
|
||||
// selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
|
||||
@@ -1,29 +1,43 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增摇色子配置' : '编辑摇色子配置'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="分组" prop="group">
|
||||
<el-input v-model="formData.group" placeholder="请输入分组" />
|
||||
<el-form-item :label="$t('page.form.group')" prop="group">
|
||||
<el-input
|
||||
v-model="formData.group"
|
||||
:placeholder="$t('page.form.placeholderGroup')"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="请输入标题" />
|
||||
<el-form-item :label="$t('page.form.title')" prop="title">
|
||||
<el-input v-model="formData.title" :placeholder="$t('page.form.placeholderTitleZh')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="配置名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入配置名称" />
|
||||
<el-form-item :label="$t('page.form.titleEn')" prop="title_en">
|
||||
<el-input v-model="formData.title_en" :placeholder="$t('page.form.placeholderTitleEn')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="值" prop="value">
|
||||
<el-input v-model="formData.value" type="textarea" :rows="5" placeholder="请输入值" />
|
||||
<el-form-item :label="$t('page.form.configName')" prop="name">
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
:placeholder="$t('page.form.placeholderConfigName')"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.value')" prop="value">
|
||||
<el-input v-model="formData.value" type="textarea" :rows="5" :placeholder="$t('page.form.placeholderValueZh')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.valueEn')" prop="value_en">
|
||||
<el-input v-model="formData.value_en" type="textarea" :rows="5" :placeholder="$t('page.form.placeholderValueEn')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -32,6 +46,9 @@
|
||||
import api from '../../../api/config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -65,12 +82,13 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
group: [{ required: true, message: '分组必需填写', trigger: 'blur' }],
|
||||
title: [{ required: true, message: '标题必需填写', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '配置名称必需填写', trigger: 'blur' }],
|
||||
value: [{ required: true, message: '值必需填写', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
group: [{ required: true, message: t('page.form.ruleGroupRequired'), trigger: 'blur' }],
|
||||
title: [{ required: true, message: t('page.form.ruleTitleRequired'), trigger: 'blur' }],
|
||||
title_en: [{ max: 255, message: t('page.form.ruleTitleEnMax'), trigger: 'blur' }],
|
||||
name: [{ required: true, message: t('page.form.ruleConfigNameRequired'), trigger: 'blur' }],
|
||||
value: [{ required: true, message: t('page.form.ruleValueRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -78,9 +96,11 @@
|
||||
const initialFormData = {
|
||||
id: null,
|
||||
value: '',
|
||||
value_en: '',
|
||||
name: '',
|
||||
group: '',
|
||||
title: ''
|
||||
title: '',
|
||||
title_en: ''
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,10 +163,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.saveSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.updateSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="分组" prop="group">
|
||||
<el-input v-model="formData.group" placeholder="请输入分组" clearable />
|
||||
<el-form-item :label="$t('page.search.group')" prop="group">
|
||||
<el-input v-model="formData.group" :placeholder="$t('page.search.placeholderGroup')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="请输入标题" clearable />
|
||||
<el-form-item :label="$t('page.search.title')" prop="title">
|
||||
<el-input v-model="formData.title" :placeholder="$t('page.search.placeholderTitle')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="配置名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入配置名称" clearable />
|
||||
<el-form-item :label="$t('page.search.configName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderConfigName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:lottery_config:index:save'"
|
||||
@click="showDialog('add')"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:lottery_config:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 操作列 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:lottery_config:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:lottery_config:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/lottery_config/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: undefined,
|
||||
type: undefined
|
||||
})
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
// 奖池类型展示:0=正常 1=强制杀猪 2=T1高倍率
|
||||
const typeFormatter = (row: Record<string, unknown>) =>
|
||||
row.type === 0 ? '正常' : row.type === 1 ? '强制杀猪' : row.type === 2 ? 'T1高倍率' : '-'
|
||||
|
||||
// 权重列带 %
|
||||
const weightFormatter = (prop: string) => (row: Record<string, unknown>) => {
|
||||
const v = row[prop]
|
||||
return v != null && v !== '' ? `${v}%` : '-'
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: '名称' },
|
||||
{ prop: 'type', label: '奖池类型', width: 100, formatter: typeFormatter },
|
||||
{ prop: 'safety_line', label: '安全线' },
|
||||
{ prop: 't1_wight', label: 'T1池权重', width: 100, formatter: weightFormatter('t1_wight') },
|
||||
{ prop: 't2_wight', label: 'T2池权重', width: 100, formatter: weightFormatter('t2_wight') },
|
||||
{ prop: 't3_wight', label: 'T3池权重', width: 100, formatter: weightFormatter('t3_wight') },
|
||||
{ prop: 't4_wight', label: 'T4池权重', width: 100, formatter: weightFormatter('t4_wight') },
|
||||
{ prop: 't5_wight', label: 'T5池权重', width: 100, formatter: weightFormatter('t5_wight') },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 编辑配置
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElButton
|
||||
v-permission="'dice:lottery_pool_config:index:index'"
|
||||
type="primary"
|
||||
@click="showCurrentPoolDialog"
|
||||
>
|
||||
{{ $t('page.toolbar.viewCurrentPool') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 操作列 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:lottery_pool_config:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:lottery_pool_config:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
<!-- 当前彩金池弹窗 -->
|
||||
<CurrentPoolDialog v-model="currentPoolVisible" @success="refreshData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/lottery_pool_config/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
import CurrentPoolDialog from './modules/current-pool-dialog.vue'
|
||||
const { t } = useI18n()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: undefined,
|
||||
// type 字段已移除,改用 name 区分:default/killScore/up
|
||||
})
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
// 奖池类型展示:按 name 映射
|
||||
const typeFormatter = (row: Record<string, unknown>) => {
|
||||
const n = String(row.name ?? '')
|
||||
if (n === 'default') return t('page.search.poolTypeNormal')
|
||||
if (n === 'killScore') return t('page.search.poolTypeKill')
|
||||
if (n === 'up') return t('page.search.poolTypeT1')
|
||||
return n || '-'
|
||||
}
|
||||
|
||||
// 权重列带 %
|
||||
const weightFormatter = (prop: string) => (row: Record<string, unknown>) => {
|
||||
const v = row[prop]
|
||||
return v != null && v !== '' ? `${v}%` : '-'
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'name', label: 'page.table.name', align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.poolType', width: 100, align: 'center', formatter: typeFormatter },
|
||||
{ prop: 'safety_line', label: 'page.table.safetyLine', align: 'center' },
|
||||
{
|
||||
prop: 't1_weight',
|
||||
label: 'page.table.t1PoolWeight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t1_weight')
|
||||
},
|
||||
{
|
||||
prop: 't2_weight',
|
||||
label: 'page.table.t2PoolWeight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t2_weight')
|
||||
},
|
||||
{
|
||||
prop: 't3_weight',
|
||||
label: 'page.table.t3PoolWeight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t3_weight')
|
||||
},
|
||||
{
|
||||
prop: 't4_weight',
|
||||
label: 'page.table.t4PoolWeight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t4_weight')
|
||||
},
|
||||
{
|
||||
prop: 't5_weight',
|
||||
label: 'page.table.t5PoolWeight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t5_weight')
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 编辑配置
|
||||
const { dialogType, dialogVisible, dialogData, showDialog, handleSelectionChange } = useSaiAdmin()
|
||||
|
||||
const currentPoolVisible = ref(false)
|
||||
function showCurrentPoolDialog() {
|
||||
currentPoolVisible.value = true
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,293 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="$t('page.form.currentPoolTitle')"
|
||||
width="560px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div v-if="loading && !pool" class="flex justify-center py-8">{{ $t('page.form.loading') }}</div>
|
||||
<template v-else-if="pool">
|
||||
<div class="pool-info mb-4">
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<span class="text-gray-500">{{ $t('page.form.poolName') }}:</span>
|
||||
<span>{{ pool.name }}</span>
|
||||
</div>
|
||||
<div class="profit-row mb-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-500">{{ $t('page.form.playerProfit') }}</span>
|
||||
<span class="font-mono text-lg" :class="profitAmountClass">{{
|
||||
displayProfitAmount
|
||||
}}</span>
|
||||
<span class="realtime-badge">{{ $t('page.form.realtime') }}</span>
|
||||
</div>
|
||||
<div class="profit-calc-hint">
|
||||
{{ $t('page.form.profitCalcHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tip-block">
|
||||
<div class="tip-title">{{ $t('page.form.tierRuleTitle') }}</div>
|
||||
<div class="tip-content">
|
||||
{{ $t('page.form.tierRuleContent') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item :label="$t('page.form.safetyLine')" prop="safety_line">
|
||||
<el-input-number
|
||||
v-model="formData.safety_line"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开启杀分">
|
||||
<el-switch v-model="formData.kill_enabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.killScoreWeights')">
|
||||
<div class="text-gray-500 text-sm">
|
||||
T1: {{ pool.t1_weight }}% / T2: {{ pool.t2_weight }}% / T3: {{ pool.t3_weight }}% / T4: {{ pool.t4_weight }}% / T5: {{ pool.t5_weight }}%
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="text-gray-500 text-sm">
|
||||
{{ $t('page.form.killWeightNote') }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('form.close') }}</el-button>
|
||||
<el-button
|
||||
v-permission="'dice:lottery_pool_config:index:resetProfitAmount'"
|
||||
:loading="resetting"
|
||||
:disabled="!pool"
|
||||
@click="handleResetProfit"
|
||||
>
|
||||
{{ $t('page.form.btnResetProfit') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-permission="'dice:lottery_pool_config:index:updateCurrentPool'"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="!pool"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
{{ $t('page.form.btnSaveSafetyLine') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/lottery_pool_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface PoolData {
|
||||
id: number
|
||||
name: string
|
||||
safety_line: number
|
||||
kill_enabled: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
t4_weight: number
|
||||
t5_weight: number
|
||||
profit_amount: number
|
||||
}
|
||||
|
||||
const props = defineProps<{ modelValue: boolean }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'success'): void }>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const resetting = ref(false)
|
||||
const pool = ref<PoolData | null>(null)
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const formData = reactive({
|
||||
safety_line: 0,
|
||||
kill_enabled: 1
|
||||
})
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
safety_line: [{ required: true, message: t('page.form.ruleSafetyLineRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
const weightsSum = computed(() => {
|
||||
const p = pool.value
|
||||
if (!p) return 0
|
||||
return (p.t1_weight ?? 0) + (p.t2_weight ?? 0) + (p.t3_weight ?? 0) + (p.t4_weight ?? 0) + (p.t5_weight ?? 0)
|
||||
})
|
||||
|
||||
const displayProfitAmount = computed(() => {
|
||||
const v = pool.value?.profit_amount
|
||||
if (v == null || Number.isNaN(v)) return '-'
|
||||
return Number(v).toFixed(2)
|
||||
})
|
||||
|
||||
const profitAmountClass = computed(() => {
|
||||
const v = pool.value?.profit_amount
|
||||
if (v == null) return ''
|
||||
if (v > 0) return 'text-green-600'
|
||||
if (v < 0) return 'text-red-600'
|
||||
return ''
|
||||
})
|
||||
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||
const POLL_INTERVAL = 2000
|
||||
|
||||
async function loadPool() {
|
||||
if (!visible.value) return
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await api.getCurrentPool()
|
||||
const data = res as unknown as PoolData
|
||||
if (data && typeof data === 'object') {
|
||||
pool.value = data
|
||||
formData.safety_line = data.safety_line ?? 0
|
||||
formData.kill_enabled = (data.kill_enabled ?? 1) === 1 ? 1 : 0
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.form.msgGetPoolFailed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
stopPolling()
|
||||
pollTimer = setInterval(() => {
|
||||
if (!visible.value) {
|
||||
stopPolling()
|
||||
return
|
||||
}
|
||||
api.getCurrentPool().then((res) => {
|
||||
const data = res as unknown as PoolData
|
||||
if (pool.value && data && typeof data === 'object' && data.profit_amount != null) {
|
||||
pool.value.profit_amount = data.profit_amount
|
||||
}
|
||||
})
|
||||
}, POLL_INTERVAL)
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!pool.value) return
|
||||
try {
|
||||
await formRef.value?.validate?.()
|
||||
saving.value = true
|
||||
await api.updateCurrentPool({
|
||||
safety_line: formData.safety_line,
|
||||
kill_enabled: formData.kill_enabled
|
||||
})
|
||||
ElMessage.success(t('page.form.msgSaveSuccess'))
|
||||
await loadPool()
|
||||
emit('success')
|
||||
} catch (e: any) {
|
||||
if (e?.message) ElMessage.error(e.message)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleResetProfit() {
|
||||
if (!pool.value) return
|
||||
try {
|
||||
resetting.value = true
|
||||
await api.resetProfitAmount()
|
||||
ElMessage.success(t('page.form.msgResetProfitSuccess'))
|
||||
await loadPool()
|
||||
emit('success')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.form.msgResetFailed'))
|
||||
} finally {
|
||||
resetting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
stopPolling()
|
||||
visible.value = false
|
||||
pool.value = null
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (open) {
|
||||
loadPool().then(() => startPolling())
|
||||
} else {
|
||||
stopPolling()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
onUnmounted(() => stopPolling())
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pool-info {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.profit-row {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.profit-calc-hint {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.realtime-badge {
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: var(--el-color-success-light-9);
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.tip-block {
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid var(--el-color-primary);
|
||||
}
|
||||
|
||||
.tip-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.tip-content {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.tip-content strong {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -1,39 +1,32 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增色子奖池配置' : '编辑色子奖池配置'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名称" />
|
||||
<el-form-item :label="$t('form.labelName')" prop="name">
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
:placeholder="$t('page.form.placeholderName')"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item :label="$t('form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖池类型" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
placeholder="请选择奖池类型"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="正常" :value="0" />
|
||||
<el-option label="强制杀猪" :value="1" />
|
||||
<el-option label="T1高倍率" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="安全线" prop="safety_line">
|
||||
<!-- dice_lottery_pool_config 已移除 type 字段,按 name 区分 default/killScore/up;name 在新增时填写,编辑时禁用 -->
|
||||
<el-form-item :label="$t('page.form.safetyLine')" prop="safety_line">
|
||||
<el-input-number
|
||||
v-model="formData.safety_line"
|
||||
:min="0"
|
||||
@@ -41,41 +34,44 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="T1池权重(%)" prop="t1_wight">
|
||||
<el-slider v-model="formData.t1_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t1Weight')" prop="t1_weight">
|
||||
<el-slider v-model="formData.t1_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T2池权重(%)" prop="t2_wight">
|
||||
<el-slider v-model="formData.t2_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t2Weight')" prop="t2_weight">
|
||||
<el-slider v-model="formData.t2_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T3池权重(%)" prop="t3_wight">
|
||||
<el-slider v-model="formData.t3_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t3Weight')" prop="t3_weight">
|
||||
<el-slider v-model="formData.t3_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T4池权重(%)" prop="t4_wight">
|
||||
<el-slider v-model="formData.t4_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t4Weight')" prop="t4_weight">
|
||||
<el-slider v-model="formData.t4_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T5池权重(%)" prop="t5_wight">
|
||||
<el-slider v-model="formData.t5_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t5Weight')" prop="t5_weight">
|
||||
<el-slider v-model="formData.t5_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="text-gray-500 text-sm">
|
||||
五个池权重总和:<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
|
||||
{{ $t('page.form.weightsSumHint') }}<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
|
||||
weightsSum
|
||||
}}</span
|
||||
>% / 100%(必须为100%)
|
||||
>{{ $t('page.form.weightsSumUnit') }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/lottery_config/index'
|
||||
import api from '../../../api/lottery_pool_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -107,7 +103,7 @@
|
||||
})
|
||||
|
||||
/** 五个权重字段名,用于总和校验 */
|
||||
const WEIGHT_KEYS = ['t1_wight', 't2_wight', 't3_wight', 't4_wight', 't5_wight'] as const
|
||||
const WEIGHT_KEYS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
|
||||
|
||||
/** 五个池权重总和(用于展示与校验) */
|
||||
const weightsSum = computed(() => {
|
||||
@@ -117,15 +113,14 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '名称必需填写', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '请选择奖池类型', trigger: 'change' }],
|
||||
t1_wight: [{ required: true, message: 'T1池权重必需填写', trigger: 'blur' }],
|
||||
t2_wight: [{ required: true, message: 'T2池权重必需填写', trigger: 'blur' }],
|
||||
t3_wight: [{ required: true, message: 'T3池权重必需填写', trigger: 'blur' }],
|
||||
t4_wight: [{ required: true, message: 'T4池权重必需填写', trigger: 'blur' }],
|
||||
t5_wight: [{ required: true, message: 'T5池权重必需填写', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
t1_weight: [{ required: true, message: t('page.form.ruleT1Required'), trigger: 'blur' }],
|
||||
t2_weight: [{ required: true, message: t('page.form.ruleT2Required'), trigger: 'blur' }],
|
||||
t3_weight: [{ required: true, message: t('page.form.ruleT3Required'), trigger: 'blur' }],
|
||||
t4_weight: [{ required: true, message: t('page.form.ruleT4Required'), trigger: 'blur' }],
|
||||
t5_weight: [{ required: true, message: t('page.form.ruleT5Required'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据(权重为数字便于输入与校验)
|
||||
@@ -134,13 +129,12 @@
|
||||
id: null as number | null,
|
||||
name: '',
|
||||
remark: '',
|
||||
type: null as number | null,
|
||||
safety_line: 0 as number,
|
||||
t1_wight: 0 as number,
|
||||
t2_wight: 0 as number,
|
||||
t3_wight: 0 as number,
|
||||
t4_wight: 0 as number,
|
||||
t5_wight: 0 as number
|
||||
t1_weight: 0 as number,
|
||||
t2_weight: 0 as number,
|
||||
t3_weight: 0 as number,
|
||||
t4_weight: 0 as number,
|
||||
t5_weight: 0 as number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,13 +174,12 @@
|
||||
if (!props.data) return
|
||||
const numKeys = [
|
||||
'id',
|
||||
'type',
|
||||
'safety_line',
|
||||
't1_wight',
|
||||
't2_wight',
|
||||
't3_wight',
|
||||
't4_wight',
|
||||
't5_wight'
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
't4_weight',
|
||||
't5_weight'
|
||||
]
|
||||
for (const key of Object.keys(formData)) {
|
||||
if (!(key in props.data)) continue
|
||||
@@ -216,15 +209,15 @@
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
ElMessage.warning('五个池权重总和必须为100%')
|
||||
ElMessage.warning(t('page.form.msgWeightsMust100'))
|
||||
return
|
||||
}
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.msgAddSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.msgUpdateSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
@@ -9,24 +9,16 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名称" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="奖池类型" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:options="typeOptions"
|
||||
placeholder="请选择奖池类型"
|
||||
clearable
|
||||
/>
|
||||
<el-form-item :label="$t('page.name')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- dice_lottery_pool_config 已移除 type 字段,按 name 区分 default/killScore/up -->
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
interface Props {
|
||||
modelValue: Record<string, any>
|
||||
}
|
||||
@@ -40,11 +32,8 @@
|
||||
// 展开/收起
|
||||
const isExpanded = ref<boolean>(false)
|
||||
|
||||
const typeOptions = [
|
||||
{ name: '0', value: '正常' },
|
||||
{ name: '1', value: '强制杀猪' },
|
||||
{ name: '2', value: 'T1高倍率' }
|
||||
]
|
||||
const { t } = useI18n()
|
||||
// type 字段已移除
|
||||
// 表单数据双向绑定
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
@@ -7,29 +7,32 @@
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:play_record:index:save'"
|
||||
@click="showDialog('add')"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:play_record:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
<span v-if="totalWinCoin !== null" class="table-summary-inline">
|
||||
{{ $t('page.toolbar.platformTotalProfit') }}:<strong>{{ totalWinCoin }}</strong>
|
||||
</span>
|
||||
<!-- <ElSpace wrap>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:play_record:index:save'"-->
|
||||
<!-- @click="showDialog('add')"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:add-fill" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:play_record:index:destroy'"-->
|
||||
<!-- :disabled="selectedRows.length === 0"-->
|
||||
<!-- @click="deleteSelectedRows(api.delete, refreshData)"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:delete-bin-5-line" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 删除-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- </ElSpace>-->
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
@@ -53,19 +56,19 @@
|
||||
<!-- 抽奖类型 tag -->
|
||||
<template #lottery_type="{ row }">
|
||||
<ElTag size="small" :type="row.lottery_type === 0 ? 'warning' : 'success'">
|
||||
{{ row.lottery_type === 0 ? '付费' : row.lottery_type === 1 ? '赠送' : '-' }}
|
||||
{{ row.lottery_type === 0 ? t('page.search.paid') : row.lottery_type === 1 ? t('page.search.free') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 中奖 tag -->
|
||||
<!-- 是否中大奖 tag -->
|
||||
<template #is_win="{ row }">
|
||||
<ElTag size="small" :type="row.is_win === 1 ? 'success' : 'info'">
|
||||
{{ row.is_win === 0 ? '无' : row.is_win === 1 ? '中奖' : '-' }}
|
||||
{{ row.is_win === 0 ? t('page.search.noBigWin') : row.is_win === 1 ? t('page.search.bigWin') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 方向 tag -->
|
||||
<template #direction="{ row }">
|
||||
<ElTag size="small" :type="row.direction === 0 ? 'primary' : 'warning'">
|
||||
{{ row.direction === 0 ? '顺时针' : row.direction === 1 ? '逆时针' : '-' }}
|
||||
{{ row.direction === 0 ? t('page.search.clockwise') : row.direction === 1 ? t('page.search.anticlockwise') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 摇取点数 tag -->
|
||||
@@ -82,11 +85,11 @@
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:play_record:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:play_record:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
@@ -103,11 +106,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/play_record/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
const { t } = useI18n()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
@@ -117,11 +122,22 @@
|
||||
is_win: undefined,
|
||||
win_coin_min: undefined,
|
||||
win_coin_max: undefined,
|
||||
roll_number_min: undefined,
|
||||
roll_number_max: undefined,
|
||||
reward_ui_text: undefined,
|
||||
reward_tier: undefined,
|
||||
direction: undefined
|
||||
})
|
||||
|
||||
/** 当前筛选下平台总盈利(付费抽奖次数×100 - 玩家总收益) */
|
||||
const totalWinCoin = ref<number | null>(null)
|
||||
|
||||
const listApi = async (params: Record<string, any>) => {
|
||||
const res = await api.list(params)
|
||||
totalWinCoin.value = (res as any)?.total_win_coin ?? null
|
||||
return res
|
||||
}
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
@@ -131,7 +147,7 @@
|
||||
const usernameFormatter = (row: Record<string, any>) =>
|
||||
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
||||
const lotteryConfigNameFormatter = (row: Record<string, any>) =>
|
||||
row?.diceLotteryConfig?.name ?? row?.lottery_config_id ?? '-'
|
||||
row?.diceLotteryPoolConfig?.name ?? row?.lottery_config_id ?? '-'
|
||||
const rewardTierFormatter = (row: Record<string, any>) =>
|
||||
row?.diceRewardConfig?.tier ?? row?.reward_config_id ?? '-'
|
||||
|
||||
@@ -166,36 +182,40 @@
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiFn: listApi,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'ID', width: 80 },
|
||||
// { type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80 },
|
||||
{
|
||||
prop: 'player_id',
|
||||
label: '玩家',
|
||||
label: 'page.table.player',
|
||||
formatter: (row: Record<string, any>) => usernameFormatter(row)
|
||||
},
|
||||
{
|
||||
prop: 'lottery_config_id',
|
||||
label: '彩金池配置',
|
||||
label: 'page.table.lotteryPoolConfig',
|
||||
width: 120,
|
||||
useSlot: true
|
||||
},
|
||||
{ prop: 'lottery_type', label: '抽奖类型', width: 100, useSlot: true },
|
||||
{ prop: 'is_win', label: '中奖', width: 80, useSlot: true },
|
||||
{ prop: 'win_coin', label: '赢取平台币' },
|
||||
{ prop: 'direction', label: '方向', width: 90, useSlot: true },
|
||||
{ prop: 'start_index', label: '起始索引', width: 90 },
|
||||
{ prop: 'target_index', label: '终点索引', width: 90 },
|
||||
{ prop: 'roll_array', label: '摇取点数', width: 140, useSlot: true },
|
||||
{ prop: 'lottery_type', label: 'page.table.drawType', width: 100, useSlot: true },
|
||||
{ prop: 'is_win', label: 'page.table.isBigWin', width: 100, useSlot: true },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110 },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120 },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140 },
|
||||
{ prop: 'direction', label: 'page.table.direction', width: 90, useSlot: true },
|
||||
{ prop: 'start_index', label: 'page.table.startIndex', width: 90 },
|
||||
{ prop: 'target_index', label: 'page.table.targetIndex', width: 90 },
|
||||
{ prop: 'roll_array', label: 'page.table.rollArray', width: 140, useSlot: true },
|
||||
{ prop: 'roll_number', label: 'page.table.rollNumber', width: 110, sortable: true },
|
||||
{
|
||||
prop: 'reward_config_id',
|
||||
label: '奖励配置',
|
||||
label: 'page.table.rewardConfig',
|
||||
formatter: (row: Record<string, any>) => rewardTierFormatter(row)
|
||||
},
|
||||
{ prop: 'create_time', label: '创建时间', width: 170 },
|
||||
{ prop: 'update_time', label: '修改时间', width: 170 },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170 },
|
||||
{ prop: 'update_time', label: 'page.table.updateTime', width: 170 },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -206,9 +226,21 @@
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
// deleteRow,
|
||||
// deleteSelectedRows,
|
||||
handleSelectionChange
|
||||
// selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.table-summary-inline {
|
||||
margin-right: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-regular);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-summary-inline strong {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增玩家抽奖记录' : '编辑玩家抽奖记录'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="玩家" prop="player_id">
|
||||
<el-form-item :label="$t('page.form.player')" prop="player_id">
|
||||
<el-select
|
||||
v-model="formData.player_id"
|
||||
placeholder="请选择玩家(显示用户名)"
|
||||
:placeholder="$t('page.form.placeholderPlayer')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -25,10 +25,10 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="彩金池配置" prop="lottery_config_id">
|
||||
<el-form-item :label="$t('page.form.lotteryPoolConfig')" prop="lottery_config_id">
|
||||
<el-select
|
||||
v-model="formData.lottery_config_id"
|
||||
placeholder="请选择彩金池配置"
|
||||
:placeholder="$t('page.form.placeholderLotteryPool')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -42,70 +42,90 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="抽奖类型" prop="lottery_type">
|
||||
<el-form-item :label="$t('page.form.drawType')" prop="lottery_type">
|
||||
<el-select
|
||||
v-model="formData.lottery_type"
|
||||
placeholder="请选择"
|
||||
:placeholder="$t('form.placeholderSelect')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option label="付费" :value="0" />
|
||||
<el-option label="赠送" :value="1" />
|
||||
<el-option :label="$t('page.form.paid')" :value="0" />
|
||||
<el-option :label="$t('page.form.free')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="中奖" prop="is_win">
|
||||
<el-form-item :label="$t('page.form.isBigWin')" prop="is_win">
|
||||
<el-select
|
||||
v-model="formData.is_win"
|
||||
placeholder="请选择"
|
||||
:placeholder="$t('form.placeholderSelect')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option label="无" :value="0" />
|
||||
<el-option label="中奖" :value="1" />
|
||||
<el-option :label="$t('page.form.noBigWin')" :value="0" />
|
||||
<el-option :label="$t('page.form.bigWin')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="赢取平台币" prop="win_coin">
|
||||
<el-form-item :label="$t('page.form.winCoin')" prop="win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.win_coin"
|
||||
placeholder="请输入赢取平台币"
|
||||
:placeholder="$t('page.form.placeholderWinCoin')"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="方向" prop="direction">
|
||||
<el-form-item :label="$t('page.form.superWinCoin')" prop="super_win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.super_win_coin"
|
||||
:placeholder="$t('page.form.placeholderSuperWinCoin')"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.rewardWinCoin')" prop="reward_win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.reward_win_coin"
|
||||
:placeholder="$t('page.form.placeholderRewardWinCoin')"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.direction')" prop="direction">
|
||||
<el-select
|
||||
v-model="formData.direction"
|
||||
placeholder="请选择方向"
|
||||
:placeholder="$t('page.form.placeholderDirection')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option label="顺时针" :value="0" />
|
||||
<el-option label="逆时针" :value="1" />
|
||||
<el-option :label="$t('page.form.clockwise')" :value="0" />
|
||||
<el-option :label="$t('page.form.anticlockwise')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="起始索引" prop="start_index">
|
||||
<el-form-item :label="$t('page.form.startIndex')" prop="start_index">
|
||||
<el-input-number
|
||||
v-model="formData.start_index"
|
||||
placeholder="起始索引"
|
||||
:placeholder="$t('page.form.placeholderStartIndex')"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="终点索引" prop="target_index">
|
||||
<el-form-item :label="$t('page.form.targetIndex')" prop="target_index">
|
||||
<el-input-number
|
||||
v-model="formData.target_index"
|
||||
placeholder="终点索引"
|
||||
:placeholder="$t('page.form.placeholderTargetIndex')"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="摇取点数" prop="rollArrayItems">
|
||||
<el-form-item :label="$t('page.form.rollArray')" prop="rollArrayItems">
|
||||
<div class="roll-array-wrap">
|
||||
<el-input-number
|
||||
v-for="(_, i) in 5"
|
||||
@@ -120,12 +140,23 @@
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</div>
|
||||
<div class="roll-array-hint">固定 5 个数,每个 1~6</div>
|
||||
<div class="roll-array-hint">{{ $t('page.form.rollArrayHint') }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖励配置" prop="reward_config_id">
|
||||
<el-form-item :label="$t('page.form.rollNumber')" prop="roll_number">
|
||||
<el-input-number
|
||||
v-model="formData.roll_number"
|
||||
:placeholder="$t('page.form.placeholderRollNumber')"
|
||||
:min="5"
|
||||
:max="30"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.rewardConfig')" prop="reward_config_id">
|
||||
<el-select
|
||||
v-model="formData.reward_config_id"
|
||||
placeholder="请选择奖励配置(显示前端文本)"
|
||||
:placeholder="$t('page.form.placeholderRewardConfig')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -145,17 +176,20 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ dialogType === 'edit' ? '关闭' : '取消' }}</el-button>
|
||||
<el-button v-if="dialogType === 'add'" type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ dialogType === 'edit' ? $t('form.close') : $t('common.cancel') }}</el-button>
|
||||
<el-button v-if="dialogType === 'add'" type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/play_record/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
@@ -186,7 +220,7 @@
|
||||
player_id: [{ required: true, message: '请选择玩家', trigger: 'change' }],
|
||||
lottery_config_id: [{ required: true, message: '请选择彩金池配置', trigger: 'change' }],
|
||||
lottery_type: [{ required: true, message: '请选择抽奖类型', trigger: 'change' }],
|
||||
is_win: [{ required: true, message: '请选择中奖', trigger: 'change' }],
|
||||
is_win: [{ required: true, message: '请选择是否中大奖', trigger: 'change' }],
|
||||
win_coin: [{ required: true, message: '赢取平台币必填', trigger: 'blur' }],
|
||||
rollArrayItems: [
|
||||
{
|
||||
@@ -219,10 +253,13 @@
|
||||
lottery_type: null as number | null,
|
||||
is_win: null as number | null,
|
||||
win_coin: null as number | null,
|
||||
super_win_coin: null as number | null,
|
||||
reward_win_coin: null as number | null,
|
||||
direction: null as number | null,
|
||||
start_index: null as number | null,
|
||||
target_index: null as number | null,
|
||||
roll_array: null as string | number[] | null,
|
||||
roll_number: null as number | null,
|
||||
reward_config_id: null as number | null
|
||||
}
|
||||
|
||||
@@ -278,10 +315,13 @@
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'super_win_coin',
|
||||
'reward_win_coin',
|
||||
'direction',
|
||||
'start_index',
|
||||
'target_index',
|
||||
'roll_array',
|
||||
'roll_number',
|
||||
'reward_config_id'
|
||||
]
|
||||
keys.forEach((key) => {
|
||||
@@ -295,6 +335,17 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
// 若后端未返回 roll_number,根据摇取点数计算
|
||||
if (formData.roll_number == null && formData.rollArrayItems.length === 5) {
|
||||
formData.roll_number = formData.rollArrayItems.reduce((s, n) => (s ?? 0) + (n ?? 0), 0) || null
|
||||
}
|
||||
// 点数和有值但五个点数为空或无效时,根据 roll_number 补全显示(兼容历史错误数据)
|
||||
const sum = formData.roll_number != null ? Number(formData.roll_number) : 0
|
||||
const hasNull = formData.rollArrayItems.some((n) => n == null)
|
||||
const itemsSum = formData.rollArrayItems.reduce((s, n) => (s ?? 0) + (n ?? 0), 0) ?? 0
|
||||
if (sum >= 5 && sum <= 30 && (hasNull || itemsSum !== sum)) {
|
||||
formData.rollArrayItems = defaultRollArrayItems(sum)
|
||||
}
|
||||
}
|
||||
|
||||
/** 将接口的 roll_array 转为固定 5 项数组,不足补 null */
|
||||
@@ -319,6 +370,16 @@
|
||||
return items.slice(0, 5)
|
||||
}
|
||||
|
||||
/** 点数和有值但五个点数缺失时,根据点数和生成默认 5 个数(与后端 defaultRollArrayForSum 一致) */
|
||||
function defaultRollArrayItems(sum: number): (number | null)[] {
|
||||
const s = Math.max(5, Math.min(30, Math.floor(Number(sum))))
|
||||
const base = Math.floor(s / 5)
|
||||
const rem = s - 5 * base
|
||||
const arr: number[] = Array(5).fill(base)
|
||||
for (let i = 0; i < rem; i++) arr[i]++
|
||||
return arr.map((v) => Math.max(1, Math.min(6, v)))
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
formRef.value?.resetFields()
|
||||
@@ -331,23 +392,25 @@
|
||||
const payload = { ...formData } as Record<string, unknown>
|
||||
// 将 5 个输入值拼成 [1,2,3,4,5] 格式,确保每项为 1~6 的整数
|
||||
const items = formData.rollArrayItems
|
||||
payload.roll_array = items.map((n) => {
|
||||
const rollArray = items.map((n) => {
|
||||
const v = n != null ? Number(n) : 1
|
||||
return Math.min(6, Math.max(1, Number.isNaN(v) ? 1 : Math.floor(v)))
|
||||
})
|
||||
payload.roll_array = rollArray
|
||||
payload.roll_number = formData.roll_number ?? rollArray.reduce((s, n) => s + n, 0)
|
||||
delete payload.rollArrayItems
|
||||
if (props.dialogType === 'add') {
|
||||
delete payload.id
|
||||
await api.save(payload)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (error: any) {
|
||||
let msg = '表单验证失败,请检查必填项与格式'
|
||||
let msg = t('page.form.validateFailed')
|
||||
if (error?.message) {
|
||||
msg = error.message
|
||||
} else if (typeof error === 'string') {
|
||||
|
||||
@@ -9,53 +9,53 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="玩家" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="用户名模糊" clearable />
|
||||
<el-form-item :label="$t('page.search.player')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.usernameFuzzy')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="彩金池配置" prop="lottery_config_name">
|
||||
<el-input v-model="formData.lottery_config_name" placeholder="名称模糊" clearable />
|
||||
<el-form-item :label="$t('page.search.lotteryPoolConfig')" prop="lottery_config_name">
|
||||
<el-input v-model="formData.lottery_config_name" :placeholder="$t('page.search.nameFuzzy')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="抽奖类型" prop="lottery_type">
|
||||
<el-select v-model="formData.lottery_type" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="付费" :value="0" />
|
||||
<el-option label="赠送" :value="1" />
|
||||
<el-form-item :label="$t('page.search.drawType')" prop="lottery_type">
|
||||
<el-select v-model="formData.lottery_type" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.paid')" :value="0" />
|
||||
<el-option :label="$t('page.search.free')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="中奖" prop="is_win">
|
||||
<el-select v-model="formData.is_win" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="无" :value="0" />
|
||||
<el-option label="中奖" :value="1" />
|
||||
<el-form-item :label="$t('page.search.isBigWin')" prop="is_win">
|
||||
<el-select v-model="formData.is_win" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.noBigWin')" :value="0" />
|
||||
<el-option :label="$t('page.search.bigWin')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="方向" prop="direction">
|
||||
<el-select v-model="formData.direction" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="顺时针" :value="0" />
|
||||
<el-option label="逆时针" :value="1" />
|
||||
<el-form-item :label="$t('page.search.direction')" prop="direction">
|
||||
<el-select v-model="formData.direction" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.clockwise')" :value="0" />
|
||||
<el-option :label="$t('page.search.anticlockwise')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="赢取平台币" prop="win_coin_min">
|
||||
<el-form-item :label="$t('page.search.winCoin')" prop="win_coin_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -64,13 +64,38 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="奖励配置" prop="reward_ui_text">
|
||||
<el-input v-model="formData.reward_ui_text" placeholder="前端显示文本模糊" clearable />
|
||||
<el-form-item :label="$t('page.search.rollNumber')" prop="roll_number_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.roll_number_min"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:min="5"
|
||||
:max="30"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.roll_number_max"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:min="5"
|
||||
:max="30"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="中奖名(档位)" prop="reward_tier">
|
||||
<el-select v-model="formData.reward_tier" placeholder="全部" clearable style="width: 100%">
|
||||
<el-form-item :label="$t('page.search.rewardConfig')" prop="reward_ui_text">
|
||||
<el-input v-model="formData.reward_ui_text" :placeholder="$t('page.search.uiTextFuzzy')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.rewardTier')" prop="reward_tier">
|
||||
<el-select v-model="formData.reward_tier" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部:汇总与操作按钮同一行,避免占用表格高度导致无法翻页 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<span v-if="totalWinCoin !== null" class="table-summary-inline">
|
||||
{{ $t('page.toolbar.platformTotalProfit') }}:<strong>{{ totalWinCoin }}</strong>
|
||||
</span>
|
||||
<ElSpace wrap class="table-toolbar-buttons">
|
||||
<ElButton
|
||||
v-permission="'dice:play_record_test:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:play_record_test:index:clearAll'"
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleClearAll"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-2-line" />
|
||||
</template>
|
||||
{{ $t('page.toolbar.clearAllData') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 彩金池配置:显示 DiceLotteryPoolConfig.name -->
|
||||
<template #lottery_config_id="{ row }">
|
||||
<ElTag size="small">{{ lotteryConfigNameFormatter(row) }}</ElTag>
|
||||
</template>
|
||||
<!-- 抽奖类型 -->
|
||||
<template #lottery_type="{ row }">
|
||||
<ElTag size="small" :type="row.lottery_type === 0 ? 'warning' : 'success'">
|
||||
{{ row.lottery_type === 0 ? t('page.search.paid') : row.lottery_type === 1 ? t('page.search.free') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 是否中大奖 -->
|
||||
<template #is_win="{ row }">
|
||||
<ElTag size="small" :type="row.is_win === 1 ? 'success' : 'info'">
|
||||
{{ row.is_win === 0 ? t('page.search.noBigWin') : row.is_win === 1 ? t('page.search.bigWin') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 方向 -->
|
||||
<template #direction="{ row }">
|
||||
<ElTag size="small" :type="row.direction === 0 ? 'primary' : 'warning'">
|
||||
{{ row.direction === 0 ? t('page.search.clockwise') : row.direction === 1 ? t('page.search.anticlockwise') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 摇取点数 -->
|
||||
<template #roll_array="{ row }">
|
||||
<ElTag size="small">
|
||||
{{ formatRollArray(row.roll_array) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 奖励档位:显示 DiceRewardConfig.tier -->
|
||||
<template #reward_config_id="{ row }">
|
||||
<ElTag size="small">{{ rewardTierFormatter(row) }}</ElTag>
|
||||
</template>
|
||||
<!-- 状态 -->
|
||||
<template #status="{ row }">
|
||||
<ElTag size="small" :type="row.status === 1 ? 'success' : 'info'">
|
||||
{{ row.status === 1 ? t('table.searchBar.success') : t('table.searchBar.failure') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:play_record_test:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:play_record_test:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/play_record_test/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
const { t } = useI18n()
|
||||
|
||||
// 搜索表单(与 play_record 对齐:方向、赢取平台币范围、是否中大奖、中奖档位、点数和)
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
lottery_type: undefined,
|
||||
direction: undefined,
|
||||
is_win: undefined,
|
||||
win_coin_min: undefined,
|
||||
win_coin_max: undefined,
|
||||
reward_tier: undefined,
|
||||
roll_number: undefined
|
||||
})
|
||||
|
||||
// 当前筛选下平台总盈利(付费抽奖次数×100 - 玩家总收益)
|
||||
const totalWinCoin = ref<number | null>(null)
|
||||
|
||||
const listApi = async (params: Record<string, any>) => {
|
||||
const res = await api.list(params)
|
||||
totalWinCoin.value = (res as any)?.total_win_coin ?? null
|
||||
return res
|
||||
}
|
||||
|
||||
const lotteryConfigNameFormatter = (row: Record<string, any>) =>
|
||||
row?.diceLotteryPoolConfig?.name ?? row?.lottery_config_id ?? '-'
|
||||
const rewardTierFormatter = (row: Record<string, any>) =>
|
||||
row?.diceRewardConfig?.tier ?? row?.reward_config_id ?? '-'
|
||||
|
||||
/** 摇取点数格式化为 1,3,4,5,6 */
|
||||
function formatRollArray(val: unknown): string {
|
||||
if (val == null || val === '') return '-'
|
||||
if (Array.isArray(val)) return val.join(',')
|
||||
if (typeof val === 'string') {
|
||||
try {
|
||||
const arr = JSON.parse(val)
|
||||
return Array.isArray(arr) ? arr.join(',') : val
|
||||
} catch {
|
||||
return val
|
||||
}
|
||||
}
|
||||
return String(val)
|
||||
}
|
||||
|
||||
const handleClearAll = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定清空所有玩家抽奖测试数据?', '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
await api.clearAll()
|
||||
ElMessage.success('已清空所有测试数据')
|
||||
getData()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
ElMessage.error(e?.message || '清空失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: listApi,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80 },
|
||||
{ prop: 'lottery_config_id', label: 'page.table.lotteryPoolConfig', width: 120, useSlot: true },
|
||||
{ prop: 'lottery_type', label: 'page.table.drawType', width: 100, useSlot: true },
|
||||
{ prop: 'is_win', label: 'page.table.isBigWin', width: 100, useSlot: true },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110 },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120 },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140 },
|
||||
{ prop: 'direction', label: 'page.table.direction', width: 90, useSlot: true },
|
||||
{ prop: 'start_index', label: 'page.table.startIndex', width: 90 },
|
||||
{ prop: 'target_index', label: 'page.table.targetIndex', width: 90 },
|
||||
{ prop: 'roll_array', label: 'page.table.rollArray', width: 140, useSlot: true },
|
||||
{ prop: 'roll_number', label: 'page.table.rollNumber', width: 110, sortable: true },
|
||||
{ prop: 'reward_config_id', label: 'page.table.rewardConfig', width: 100, useSlot: true },
|
||||
{ prop: 'status', label: 'page.table.status', width: 80, useSlot: true },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170 },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 编辑配置
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.table-summary-inline {
|
||||
margin-right: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-regular);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-summary-inline strong {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
.table-toolbar-buttons {
|
||||
display: inline-flex;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,272 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item :label="$t('page.form.labelLotteryConfigId')" prop="lottery_config_id">
|
||||
<el-input v-model="formData.lottery_config_id" :placeholder="$t('page.form.placeholderLotteryConfigId')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.drawType')" prop="lottery_type">
|
||||
<el-select
|
||||
v-model="formData.lottery_type"
|
||||
:placeholder="$t('form.placeholderSelect')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option :label="$t('page.search.paid')" :value="0" />
|
||||
<el-option :label="$t('page.search.free')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.search.direction')" prop="direction">
|
||||
<el-select v-model="formData.direction" :placeholder="$t('form.placeholderSelect')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.clockwise')" :value="0" />
|
||||
<el-option :label="$t('page.search.anticlockwise')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.search.isBigWin')" prop="is_win">
|
||||
<el-select v-model="formData.is_win" :placeholder="$t('form.placeholderSelect')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.noBigWin')" :value="0" />
|
||||
<el-option :label="$t('page.search.bigWin')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.search.winCoin')" prop="win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.win_coin"
|
||||
:placeholder="$t('page.form.placeholderWinCoin')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.search.rewardTier')" prop="reward_tier">
|
||||
<el-select
|
||||
v-model="formData.reward_tier"
|
||||
:placeholder="$t('page.form.placeholderRewardTier')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="onRewardTierChange"
|
||||
>
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.rewardConfigId')" prop="reward_config_id">
|
||||
<el-input
|
||||
v-model="formData.reward_config_id"
|
||||
:placeholder="$t('page.form.placeholderRewardConfigId')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.table.startIndex')" prop="start_index">
|
||||
<el-input v-model="formData.start_index" :placeholder="$t('page.form.placeholderStartIndex')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelTargetIndex')" prop="target_index">
|
||||
<el-input v-model="formData.target_index" :placeholder="$t('page.form.placeholderTargetIndex')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.search.rollNumber')" prop="roll_number">
|
||||
<el-input v-model="formData.roll_number" :placeholder="$t('page.form.placeholderRollNumber')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelRollArray')" prop="roll_array">
|
||||
<el-input v-model="formData.roll_array" :placeholder="$t('page.form.placeholderRollArray')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.table.superWinCoin')" prop="super_win_coin">
|
||||
<el-input v-model="formData.super_win_coin" :placeholder="$t('page.form.placeholderSuperWinCoin')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.table.rewardWinCoin')" prop="reward_win_coin">
|
||||
<el-input v-model="formData.reward_win_coin" :placeholder="$t('page.form.placeholderRewardWinCoin')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelAdminId')" prop="admin_id">
|
||||
<el-input v-model="formData.admin_id" :placeholder="$t('page.form.placeholderAdminId')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/play_record_test/index'
|
||||
import rewardConfigApi from '../../../api/reward_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
data?: Record<string, any>
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false,
|
||||
dialogType: 'add',
|
||||
data: undefined
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
/**
|
||||
* 弹窗显示状态双向绑定
|
||||
*/
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = computed<FormRules>(() => ({
|
||||
lottery_config_id: [{ required: true, message: t('page.form.ruleLotteryConfigIdRequired'), trigger: 'blur' }],
|
||||
lottery_type: [{ required: true, message: t('page.form.ruleDrawTypeRequired'), trigger: 'blur' }],
|
||||
is_win: [{ required: true, message: t('page.form.ruleIsBigWinRequired'), trigger: 'blur' }],
|
||||
direction: [{ required: true, message: t('page.form.ruleDirectionRequired'), trigger: 'blur' }],
|
||||
reward_config_id: [{ required: true, message: t('page.form.ruleRewardConfigIdRequired'), trigger: 'blur' }],
|
||||
status: [{ required: true, message: t('page.form.ruleStatusRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
*/
|
||||
const initialFormData = {
|
||||
id: null,
|
||||
lottery_config_id: null,
|
||||
lottery_type: null,
|
||||
is_win: null,
|
||||
win_coin: 0,
|
||||
direction: null,
|
||||
reward_tier: undefined as string | undefined,
|
||||
reward_config_id: null,
|
||||
start_index: null,
|
||||
target_index: null,
|
||||
roll_number: null,
|
||||
roll_array: '',
|
||||
status: 1,
|
||||
super_win_coin: '0.00',
|
||||
reward_win_coin: '0.00',
|
||||
admin_id: null
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据
|
||||
*/
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
/**
|
||||
* 监听弹窗打开,初始化表单数据
|
||||
*/
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
initPage()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* 初始化页面数据
|
||||
*/
|
||||
const initPage = async () => {
|
||||
// 先重置为初始值
|
||||
Object.assign(formData, initialFormData)
|
||||
// 如果有数据,则填充数据
|
||||
if (props.data) {
|
||||
await nextTick()
|
||||
initForm()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化表单数据
|
||||
*/
|
||||
const initForm = () => {
|
||||
if (props.data) {
|
||||
for (const key in formData) {
|
||||
if (key === 'reward_tier') continue
|
||||
if (props.data[key] != null && props.data[key] !== undefined) {
|
||||
;(formData as Record<string, unknown>)[key] = props.data[key]
|
||||
}
|
||||
}
|
||||
if (typeof formData.win_coin === 'string') {
|
||||
formData.win_coin = parseFloat(formData.win_coin) || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖档位变更:按档位拉取奖励配置并取第一条的 id 填入 reward_config_id
|
||||
*/
|
||||
async function onRewardTierChange(tier: string) {
|
||||
if (!tier) {
|
||||
formData.reward_config_id = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await rewardConfigApi.list({
|
||||
saiType: 'all',
|
||||
tier: tier
|
||||
})
|
||||
const list = (res as any)?.data ?? (Array.isArray(res) ? res : [])
|
||||
const first = Array.isArray(list) ? list[0] : (list?.data?.[0] ?? list?.[0])
|
||||
if (first && first.id != null) {
|
||||
formData.reward_config_id = first.id
|
||||
} else {
|
||||
formData.reward_config_id = null
|
||||
}
|
||||
} catch {
|
||||
formData.reward_config_id = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并重置表单
|
||||
*/
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交表单
|
||||
*/
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
const payload = { ...formData }
|
||||
delete (payload as Record<string, unknown>).reward_tier
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(payload)
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (error) {
|
||||
console.log('表单验证失败:', error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<sa-search-bar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
label-width="120px"
|
||||
:showExpand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.drawType')" prop="lottery_type">
|
||||
<el-select v-model="formData.lottery_type" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.paid')" :value="0" />
|
||||
<el-option :label="$t('page.search.free')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.direction')" prop="direction">
|
||||
<el-select v-model="formData.direction" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.clockwise')" :value="0" />
|
||||
<el-option :label="$t('page.search.anticlockwise')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.isBigWin')" prop="is_win">
|
||||
<el-select v-model="formData.is_win" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.noBigWin')" :value="0" />
|
||||
<el-option :label="$t('page.search.bigWin')" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.winCoin')" prop="win_coin_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_min"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_max"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.rewardTier')" prop="reward_tier">
|
||||
<el-select v-model="formData.reward_tier" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.rollNumber')" prop="roll_number">
|
||||
<el-select
|
||||
v-model="formData.roll_number"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="n in 26"
|
||||
:key="n + 4"
|
||||
:label="String(n + 4)"
|
||||
:value="n + 4"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
modelValue: Record<string, any>
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: Record<string, any>): void
|
||||
(e: 'search', params: Record<string, any>): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
const isExpanded = ref<boolean>(false)
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val)
|
||||
})
|
||||
|
||||
function handleReset() {
|
||||
searchBarRef.value?.ref.resetFields()
|
||||
emit('reset')
|
||||
}
|
||||
|
||||
async function handleSearch() {
|
||||
emit('search', formData.value)
|
||||
}
|
||||
|
||||
function handleExpand(expanded: boolean) {
|
||||
isExpanded.value = expanded
|
||||
}
|
||||
|
||||
const setSpan = (span: number) => ({
|
||||
span,
|
||||
xs: 24,
|
||||
sm: span >= 12 ? span : 12,
|
||||
md: span >= 8 ? span : 8,
|
||||
lg: span,
|
||||
xl: span
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.range-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.range-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.range-sep {
|
||||
color: var(--el-text-color-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<!-- 搜索条件 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部 -->
|
||||
<!-- 表格操作 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
@@ -12,7 +12,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:player:index:destroy'"
|
||||
@@ -23,7 +23,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -42,7 +42,7 @@
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 状态:开关直接修改 -->
|
||||
<!-- 状态列 -->
|
||||
<template #status="{ row }">
|
||||
<ElSwitch
|
||||
v-permission="'dice:player:index:update'"
|
||||
@@ -51,7 +51,7 @@
|
||||
@change="(v: string | number | boolean) => handleStatusChange(row, v ? 1 : 0)"
|
||||
/>
|
||||
</template>
|
||||
<!-- 平台币:tag 可点击打开钱包操作弹窗 -->
|
||||
<!-- 平台币,点击可操作 -->
|
||||
<template #coin="{ row }">
|
||||
<ElTag
|
||||
type="info"
|
||||
@@ -62,7 +62,7 @@
|
||||
{{ row.coin ?? 0 }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<!-- 操作 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
@@ -88,7 +88,7 @@
|
||||
@success="refreshData"
|
||||
/>
|
||||
|
||||
<!-- 钱包操作弹窗(加点/扣点) -->
|
||||
<!-- 钱包操作弹窗 -->
|
||||
<WalletOperateDialog
|
||||
v-model="walletDialogVisible"
|
||||
:player="walletOperatePlayer"
|
||||
@@ -112,34 +112,26 @@
|
||||
phone: undefined,
|
||||
status: undefined,
|
||||
coin: undefined,
|
||||
is_up: undefined
|
||||
lottery_config_id: undefined
|
||||
})
|
||||
|
||||
// 搜索处理
|
||||
// 搜索
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
// 权重列带 % 的 formatter(ColumnOption.formatter 仅接收 row)
|
||||
// 权重列显示为百分比
|
||||
const weightFormatter = (prop: string) => (row: any) => {
|
||||
const cellValue = row[prop]
|
||||
return cellValue != null && cellValue !== '' ? `${cellValue}%` : '-'
|
||||
}
|
||||
|
||||
// 倍率列展示:0=正常 1=强制杀猪 2=T1高倍率
|
||||
const isUpFormatter = (row: any) => {
|
||||
const cellValue = row.is_up
|
||||
return cellValue === 0
|
||||
? '正常'
|
||||
: cellValue === 1
|
||||
? '强制杀猪'
|
||||
: cellValue === 2
|
||||
? 'T1高倍率'
|
||||
: '-'
|
||||
}
|
||||
// 根据 lottery_config_id 显示彩金池配置名称
|
||||
const lotteryConfigNameFormatter = (row: any) =>
|
||||
row?.diceLotteryPoolConfig?.name ?? (row?.lottery_config_id ? `#${row.lottery_config_id}` : '未知')
|
||||
|
||||
// 表格配置
|
||||
// 表格
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
@@ -158,28 +150,83 @@
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'username', label: '用户名' },
|
||||
{ prop: 'phone', label: '手机号' },
|
||||
{ prop: 'name', label: '昵称' },
|
||||
{ prop: 'status', label: '状态', width: 88, useSlot: true },
|
||||
{ prop: 'coin', label: '平台币', width: 100, useSlot: true },
|
||||
{ prop: 'is_up', label: '倍率', width: 80, formatter: isUpFormatter },
|
||||
{ prop: 't1_wight', label: 'T1池权重', width: 100, formatter: weightFormatter('t1_wight') },
|
||||
{ prop: 't2_wight', label: 'T2池权重', width: 100, formatter: weightFormatter('t2_wight') },
|
||||
{ prop: 't3_wight', label: 'T3池权重', width: 100, formatter: weightFormatter('t3_wight') },
|
||||
{ prop: 't4_wight', label: 'T4池权重', width: 100, formatter: weightFormatter('t4_wight') },
|
||||
{ prop: 't5_wight', label: 'T5池权重', width: 100, formatter: weightFormatter('t5_wight') },
|
||||
{ prop: 'total_ticket_count', label: '总抽奖次数' },
|
||||
{ prop: 'paid_ticket_count', label: '购买抽奖次数' },
|
||||
{ prop: 'free_ticket_count', label: '赠送抽奖次数' },
|
||||
{ prop: 'created_at', label: '创建时间' },
|
||||
{ prop: 'updated_at', label: '更新时间' },
|
||||
{ prop: 'operation', label: '操作', width: 120, fixed: 'right', useSlot: true }
|
||||
{ prop: 'username', label: 'page.table.username', align: 'center' },
|
||||
{ prop: 'phone', label: 'page.table.phone', align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.nickname', align: 'center' },
|
||||
{
|
||||
prop: 'status',
|
||||
label: 'page.table.status',
|
||||
width: 88,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'coin',
|
||||
label: 'page.table.coin',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'lottery_config_id',
|
||||
label: 'page.table.lotteryPoolConfig',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
formatter: (row: any) => lotteryConfigNameFormatter(row)
|
||||
},
|
||||
{
|
||||
prop: 't1_weight',
|
||||
label: 'page.table.t1Weight',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t1_weight')
|
||||
},
|
||||
{
|
||||
prop: 't2_weight',
|
||||
label: 'page.table.t2Weight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t2_weight')
|
||||
},
|
||||
{
|
||||
prop: 't3_weight',
|
||||
label: 'page.table.t3Weight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t3_weight')
|
||||
},
|
||||
{
|
||||
prop: 't4_weight',
|
||||
label: 'page.table.t4Weight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t4_weight')
|
||||
},
|
||||
{
|
||||
prop: 't5_weight',
|
||||
label: 'page.table.t5Weight',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: weightFormatter('t5_weight')
|
||||
},
|
||||
{ prop: 'total_ticket_count', label: 'page.table.totalDrawCount', align: 'center' },
|
||||
{ prop: 'paid_ticket_count', label: 'page.table.paidDrawCount', align: 'center' },
|
||||
{ prop: 'free_ticket_count', label: 'page.table.freeDrawCount', align: 'center' },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', align: 'center' },
|
||||
{ prop: 'update_time', label: 'page.table.updateTime', align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 状态开关切换(列表内直接修改)
|
||||
// 状态切换
|
||||
const handleStatusChange = async (row: Record<string, any>, status: number) => {
|
||||
row._statusLoading = true
|
||||
try {
|
||||
@@ -192,7 +239,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑配置
|
||||
// 弹窗与删除
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
@@ -204,7 +251,7 @@
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
|
||||
// 钱包操作弹窗(从平台币 tag 点击打开)
|
||||
// 钱包操作弹窗
|
||||
const walletDialogVisible = ref(false)
|
||||
type WalletPlayer = { id: number; username?: string; coin?: number }
|
||||
const walletOperatePlayer = ref<WalletPlayer | null>(null)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="玩家钱包操作"
|
||||
:title="$t('page.form.walletTitle')"
|
||||
width="480px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="玩家">
|
||||
<el-form-item :label="$t('page.form.walletPlayer')">
|
||||
<el-input :model-value="player?.username" disabled placeholder="-" />
|
||||
</el-form-item>
|
||||
<el-form-item label="钱包余额">
|
||||
<el-form-item :label="$t('page.form.walletBalance')">
|
||||
<el-input-number
|
||||
:model-value="walletBalance"
|
||||
disabled
|
||||
@@ -20,36 +20,36 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择" clearable style="width: 100%">
|
||||
<el-option label="加点" :value="3" />
|
||||
<el-option label="扣点" :value="4" />
|
||||
<el-form-item :label="$t('page.form.operationType')" prop="type">
|
||||
<el-select v-model="formData.type" :placeholder="$t('form.placeholderSelect')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.form.typeAdd')" :value="3" />
|
||||
<el-option :label="$t('page.form.typeSub')" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="平台币变动" prop="coin">
|
||||
<el-form-item :label="$t('page.form.coinChange')" prop="coin">
|
||||
<el-input-number
|
||||
v-model="formData.coin"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
placeholder="正数,扣点时不能超过余额"
|
||||
:placeholder="$t('page.form.placeholderCoinChange')"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item :label="$t('form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="选填,不填则按类型自动填写"
|
||||
:placeholder="$t('page.form.placeholderRemarkOptional')"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">确定</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -58,6 +58,9 @@
|
||||
import walletRecordApi from '../../../api/player_wallet_record/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface PlayerRow {
|
||||
id: number
|
||||
@@ -95,19 +98,19 @@
|
||||
return c != null ? Number(c) : 0
|
||||
})
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
type: [{ required: true, message: '请选择操作类型', trigger: 'change' }],
|
||||
const rules = computed<FormRules>(() => ({
|
||||
type: [{ required: true, message: t('page.form.ruleSelectType'), trigger: 'change' }],
|
||||
coin: [
|
||||
{ required: true, message: '请输入平台币变动', trigger: 'blur' },
|
||||
{ required: true, message: t('page.form.ruleEnterCoin'), trigger: 'blur' },
|
||||
{
|
||||
validator: (_rule, value, callback) => {
|
||||
const n = Number(value)
|
||||
if (Number.isNaN(n) || n <= 0) {
|
||||
callback(new Error('平台币变动必须大于 0'))
|
||||
callback(new Error(t('page.form.ruleCoinPositive')))
|
||||
return
|
||||
}
|
||||
if (formData.type === 4 && n > walletBalance.value) {
|
||||
callback(new Error('扣点不能超过当前余额'))
|
||||
callback(new Error(t('page.form.ruleDeductExceed')))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
@@ -115,7 +118,7 @@
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
})
|
||||
}))
|
||||
|
||||
const initialFormData = {
|
||||
type: null as 3 | 4 | null,
|
||||
@@ -146,11 +149,11 @@
|
||||
await formRef.value.validate()
|
||||
const coin = Number(formData.coin) || 0
|
||||
if (coin <= 0) {
|
||||
ElMessage.warning('平台币变动必须大于 0')
|
||||
ElMessage.warning(t('page.form.ruleCoinPositive'))
|
||||
return
|
||||
}
|
||||
if (formData.type === 4 && coin > walletBalance.value) {
|
||||
ElMessage.warning('扣点不能超过当前余额')
|
||||
ElMessage.warning(t('page.form.ruleDeductExceed'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
@@ -160,7 +163,7 @@
|
||||
coin,
|
||||
remark: formData.remark?.trim() || undefined
|
||||
})
|
||||
ElMessage.success('操作成功')
|
||||
ElMessage.success(t('page.form.operateSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,86 +1,183 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增大富翁-玩家' : '编辑大富翁-玩家'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入用户名" />
|
||||
<el-form-item :label="$t('page.form.username')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.form.placeholderUsername')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="昵称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入昵称" />
|
||||
<el-form-item :label="$t('page.form.nickname')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderNickname')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable maxlength="20" show-word-limit />
|
||||
<el-form-item :label="$t('page.form.phone')" prop="phone">
|
||||
<el-input
|
||||
v-model="formData.phone"
|
||||
:placeholder="$t('page.form.placeholderPhone')"
|
||||
clearable
|
||||
maxlength="20"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password" :rules="passwordRules">
|
||||
<el-form-item :label="$t('page.form.password')" prop="password" :rules="passwordRules">
|
||||
<el-input
|
||||
v-model="formData.password"
|
||||
type="password"
|
||||
placeholder="编辑留空则不修改"
|
||||
:placeholder="$t('page.form.placeholderPasswordEdit')"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-form-item :label="$t('page.form.status')" prop="status">
|
||||
<sa-switch v-model="formData.status" />
|
||||
</el-form-item>
|
||||
<el-form-item label="平台币" prop="coin">
|
||||
<el-form-item :label="$t('page.form.adminId')" prop="admin_id">
|
||||
<el-select
|
||||
v-model="formData.admin_id"
|
||||
:placeholder="$t('page.form.placeholderAdmin')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:loading="systemUserOptionsLoading"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in systemUserOptions"
|
||||
:key="item.id"
|
||||
:label="item.label || item.username || `#${item.id}`"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.coin')" prop="coin">
|
||||
<el-input-number
|
||||
v-model="formData.coin"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:disabled="dialogType === 'add'"
|
||||
placeholder="创建时默认0,不可改"
|
||||
:placeholder="$t('page.form.placeholderCoinAdd')"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="倍率" prop="is_up">
|
||||
<el-select v-model="formData.is_up" placeholder="请选择倍率" clearable style="width: 100%">
|
||||
<el-option label="正常" :value="0" />
|
||||
<el-option label="强制杀猪" :value="1" />
|
||||
<el-option label="T1高倍率" :value="2" />
|
||||
<!-- lottery_config_id:空 = 自定义权重,否则 = DiceLotteryConfig.id;选择后该配置的五个 weight 会写入下方 player.*_weight -->
|
||||
<el-form-item :label="$t('page.form.lotteryPoolConfig')" prop="lottery_config_id">
|
||||
<el-select
|
||||
v-model="formData.lottery_config_id"
|
||||
:placeholder="$t('page.form.placeholderLotteryPool')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:loading="lotteryConfigLoading"
|
||||
@change="onLotteryConfigChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in lotteryConfigOptions"
|
||||
:key="item.id"
|
||||
:label="(item.name && String(item.name).trim()) || `#${item.id}`"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="T1池权重(%)" prop="t1_wight">
|
||||
<el-slider v-model="formData.t1_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<!-- 当前选中的 DiceLotteryConfig 数据展示 -->
|
||||
<el-form-item v-if="currentLotteryConfig" :label="$t('page.form.currentConfig')" class="current-config-block">
|
||||
<div class="current-lottery-config">
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelName') }}:</span>
|
||||
<span>{{ currentLotteryConfig.name ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelType') }}:</span>
|
||||
<span>{{ lotteryConfigTypeText(currentLotteryConfig.name) }}</span>
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelWeights') }}:</span>
|
||||
<span>{{ currentLotteryConfigWeightsText }}</span>
|
||||
</div>
|
||||
<div v-if="currentLotteryConfig.remark" class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelRemark') }}:</span>
|
||||
<span>{{ currentLotteryConfig.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="T2池权重(%)" prop="t2_wight">
|
||||
<el-slider v-model="formData.t2_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<!-- lottery_config_id 为空时自定义权重可编辑;有值时来自所选 DiceLotteryConfig,仅展示不可编辑 -->
|
||||
<el-form-item :label="$t('page.form.t1Weight')" prop="t1_weight">
|
||||
<el-slider
|
||||
v-model="formData.t1_weight"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
show-input
|
||||
:disabled="!isLotteryConfigEmpty()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="T3池权重(%)" prop="t3_wight">
|
||||
<el-slider v-model="formData.t3_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t2Weight')" prop="t2_weight">
|
||||
<el-slider
|
||||
v-model="formData.t2_weight"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
show-input
|
||||
:disabled="!isLotteryConfigEmpty()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="T4池权重(%)" prop="t4_wight">
|
||||
<el-slider v-model="formData.t4_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t3Weight')" prop="t3_weight">
|
||||
<el-slider
|
||||
v-model="formData.t3_weight"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
show-input
|
||||
:disabled="!isLotteryConfigEmpty()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="T5池权重(%)" prop="t5_wight">
|
||||
<el-slider v-model="formData.t5_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||
<el-form-item :label="$t('page.form.t4Weight')" prop="t4_weight">
|
||||
<el-slider
|
||||
v-model="formData.t4_weight"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
show-input
|
||||
:disabled="!isLotteryConfigEmpty()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item :label="$t('page.form.t5Weight')" prop="t5_weight">
|
||||
<el-slider
|
||||
v-model="formData.t5_weight"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:step="0.01"
|
||||
show-input
|
||||
:disabled="!isLotteryConfigEmpty()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isLotteryConfigEmpty()">
|
||||
<div class="text-gray-500 text-sm">
|
||||
五个池权重总和:<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
|
||||
{{ $t('page.form.weightsSumHint') }}<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
|
||||
weightsSum
|
||||
}}</span
|
||||
>% / 100%(必须为100%)
|
||||
>{{ $t('page.form.weightsSumUnit') }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/player/index'
|
||||
import lotteryConfigApi from '../../../api/lottery_pool_config/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const { t } = useI18n()
|
||||
const WEIGHT_FIELDS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
@@ -107,9 +204,20 @@
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const WEIGHT_KEYS = ['t1_wight', 't2_wight', 't3_wight', 't4_wight', 't5_wight'] as const
|
||||
const weightsSum = computed(() => {
|
||||
return WEIGHT_KEYS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
|
||||
return WEIGHT_FIELDS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
|
||||
})
|
||||
|
||||
/** 当前彩金池配置的 T1~T5 权重展示文案 */
|
||||
const currentLotteryConfigWeightsText = computed(() => {
|
||||
const c = currentLotteryConfig.value
|
||||
if (!c) return '-'
|
||||
const t1 = c.t1_weight ?? 0
|
||||
const t2 = c.t2_weight ?? 0
|
||||
const t3 = c.t3_weight ?? 0
|
||||
const t4 = c.t4_weight ?? 0
|
||||
const t5 = c.t5_weight ?? 0
|
||||
return `${t1}% / ${t2}% / ${t3}% / ${t4}% / ${t5}%`
|
||||
})
|
||||
|
||||
/** 新增时密码必填,编辑时选填 */
|
||||
@@ -132,17 +240,70 @@
|
||||
phone: '',
|
||||
password: '',
|
||||
status: 1 as number,
|
||||
/** 所属后台管理员 ID(SystemUser.id) */
|
||||
admin_id: null as number | null,
|
||||
coin: 0 as number,
|
||||
is_up: null as number | null,
|
||||
t1_wight: 0 as number,
|
||||
t2_wight: 0 as number,
|
||||
t3_wight: 0 as number,
|
||||
t4_wight: 0 as number,
|
||||
t5_wight: 0 as number
|
||||
/** 彩金池配置 ID:空 = 自定义权重,否则 = DiceLotteryConfig.id */
|
||||
lottery_config_id: null as number | null,
|
||||
t1_weight: 0 as number,
|
||||
t2_weight: 0 as number,
|
||||
t3_weight: 0 as number,
|
||||
t4_weight: 0 as number,
|
||||
t5_weight: 0 as number
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
/** 彩金池配置下拉选项(DiceLotteryConfig id、name) */
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
/** 彩金池选项加载中 */
|
||||
const lotteryConfigLoading = ref(false)
|
||||
/** 后台管理员下拉选项(SystemUser) */
|
||||
const systemUserOptions = ref<
|
||||
Array<{ id: number; username: string; realname: string; label: string }>
|
||||
>([])
|
||||
/** 管理员选项加载中 */
|
||||
const systemUserOptionsLoading = ref(false)
|
||||
/** 当前选中的 DiceLotteryConfig 完整数据(用于展示) */
|
||||
const currentLotteryConfig = ref<Record<string, any> | null>(null)
|
||||
|
||||
function lotteryConfigTypeText(name: unknown): string {
|
||||
const n = String(name ?? '')
|
||||
if (n === 'default') return '默认'
|
||||
if (n === 'killScore') return '杀分'
|
||||
if (n === 'up') return '上分'
|
||||
return n || '-'
|
||||
}
|
||||
|
||||
/** 是否为空/自定义权重(未选彩金池或选 0) */
|
||||
function isLotteryConfigEmpty(): boolean {
|
||||
const v = formData.lottery_config_id
|
||||
return v == null || v === 0
|
||||
}
|
||||
|
||||
/** 根据当前 lottery_config_id 加载 DiceLotteryConfig,并将五个权重写入当前 player.*_weight */
|
||||
async function loadCurrentLotteryConfig() {
|
||||
const id = formData.lottery_config_id
|
||||
if (id == null || id === 0) {
|
||||
currentLotteryConfig.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await lotteryConfigApi.read(id)
|
||||
const row = (res as any)?.data ?? (res as any)
|
||||
if (row && typeof row === 'object') {
|
||||
currentLotteryConfig.value = row
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as any)[key] = Number(row[key] ?? 0)
|
||||
})
|
||||
} else {
|
||||
currentLotteryConfig.value = null
|
||||
}
|
||||
} catch {
|
||||
currentLotteryConfig.value = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
@@ -150,11 +311,63 @@
|
||||
}
|
||||
)
|
||||
|
||||
/** 选择彩金池后,拉取该配置的五个权重并写入当前 player.*_weight,并更新当前配置展示 */
|
||||
async function onLotteryConfigChange(lotteryConfigId: number | null | undefined) {
|
||||
if (lotteryConfigId == null || lotteryConfigId === 0) {
|
||||
currentLotteryConfig.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await lotteryConfigApi.read(lotteryConfigId)
|
||||
const row = (res as any)?.data ?? (res as any)
|
||||
if (row && typeof row === 'object') {
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as any)[key] = Number(row[key] ?? 0)
|
||||
})
|
||||
currentLotteryConfig.value = row
|
||||
} else {
|
||||
currentLotteryConfig.value = null
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('拉取彩金池配置失败', err)
|
||||
currentLotteryConfig.value = null
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载后台管理员选项 */
|
||||
async function loadSystemUserOptions() {
|
||||
systemUserOptionsLoading.value = true
|
||||
try {
|
||||
systemUserOptions.value = await api.getSystemUserOptions()
|
||||
} catch {
|
||||
systemUserOptions.value = []
|
||||
} finally {
|
||||
systemUserOptionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const initPage = async () => {
|
||||
currentLotteryConfig.value = null
|
||||
Object.assign(formData, initialFormData)
|
||||
await Promise.all([loadLotteryConfigOptions(), loadSystemUserOptions()])
|
||||
if (props.data) {
|
||||
await nextTick()
|
||||
initForm()
|
||||
if (!isLotteryConfigEmpty()) {
|
||||
await loadCurrentLotteryConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 从玩家控制器获取 DiceLotteryConfig id/name 列表,供 lottery_config_id 下拉使用 */
|
||||
async function loadLotteryConfigOptions() {
|
||||
lotteryConfigLoading.value = true
|
||||
try {
|
||||
lotteryConfigOptions.value = await api.getLotteryConfigOptions()
|
||||
} catch {
|
||||
lotteryConfigOptions.value = []
|
||||
} finally {
|
||||
lotteryConfigLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,12 +375,12 @@
|
||||
'id',
|
||||
'status',
|
||||
'coin',
|
||||
'is_up',
|
||||
't1_wight',
|
||||
't2_wight',
|
||||
't3_wight',
|
||||
't4_wight',
|
||||
't5_wight'
|
||||
'lottery_config_id',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
't4_weight',
|
||||
't5_weight'
|
||||
]
|
||||
|
||||
const initForm = () => {
|
||||
@@ -180,8 +393,14 @@
|
||||
}
|
||||
const val = props.data[key]
|
||||
if (numKeys.includes(key)) {
|
||||
;(formData as any)[key] =
|
||||
key === 'id' ? (val != null ? Number(val) || null : null) : Number(val) || 0
|
||||
if (key === 'id') {
|
||||
;(formData as any)[key] = val != null ? Number(val) || null : null
|
||||
} else if (key === 'lottery_config_id' || key === 'admin_id') {
|
||||
const num = Number(val)
|
||||
;(formData as any)[key] = val != null && !Number.isNaN(num) && num !== 0 ? num : null
|
||||
} else {
|
||||
;(formData as any)[key] = Number(val) || 0
|
||||
}
|
||||
} else {
|
||||
;(formData as any)[key] = val ?? ''
|
||||
}
|
||||
@@ -197,20 +416,24 @@
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
ElMessage.warning('五个池权重总和必须为100%')
|
||||
const useCustomWeights = isLotteryConfigEmpty()
|
||||
if (useCustomWeights && Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
ElMessage.warning(t('page.form.ruleWeightsSumMustBe100'))
|
||||
return
|
||||
}
|
||||
const payload = { ...formData }
|
||||
if (isLotteryConfigEmpty()) {
|
||||
;(payload as any).lottery_config_id = null
|
||||
}
|
||||
if (props.dialogType === 'edit' && !payload.password) {
|
||||
delete (payload as any).password
|
||||
}
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(payload)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
@@ -219,3 +442,31 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.current-config-block {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.current-lottery-config {
|
||||
padding: 10px 12px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
|
||||
.config-row {
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.5;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.config-label {
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,46 +9,54 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入用户名" clearable />
|
||||
<el-form-item :label="$t('page.search.username')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.placeholderUsername')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="昵称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入昵称" clearable />
|
||||
<el-form-item :label="$t('page.search.nickname')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderNickname')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="手机号模糊查询" clearable />
|
||||
<el-form-item :label="$t('page.search.phone')" prop="phone">
|
||||
<el-input v-model="formData.phone" :placeholder="$t('page.search.placeholderPhoneFuzzy')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<el-select v-model="formData.status" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('table.searchBar.enable')" :value="1" />
|
||||
<el-option :label="$t('table.searchBar.disable')" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="平台币" prop="coin">
|
||||
<el-form-item :label="$t('page.search.coin')" prop="coin">
|
||||
<el-input-number
|
||||
v-model="formData.coin"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="精确搜索"
|
||||
:placeholder="$t('page.search.exactSearch')"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="倍率" prop="is_up">
|
||||
<el-select v-model="formData.is_up" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="正常" :value="0" />
|
||||
<el-option label="强制杀猪" :value="1" />
|
||||
<el-option label="T1高倍率" :value="2" />
|
||||
<el-form-item :label="$t('page.search.lotteryPoolConfig')" prop="lottery_config_id">
|
||||
<el-select
|
||||
v-model="formData.lottery_config_id"
|
||||
:placeholder="$t('page.search.placeholderAll')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in lotteryConfigOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -56,6 +64,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/player/index'
|
||||
|
||||
interface Props {
|
||||
modelValue: Record<string, any>
|
||||
}
|
||||
@@ -67,6 +77,16 @@
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
const isExpanded = ref<boolean>(false)
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
/** 从玩家控制器获取 DiceLotteryPoolConfig id/name 列表,用于 lottery_config_id 筛选 */
|
||||
onMounted(async () => {
|
||||
try {
|
||||
lotteryConfigOptions.value = await api.getLotteryConfigOptions()
|
||||
} catch {
|
||||
lotteryConfigOptions.value = []
|
||||
}
|
||||
})
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
|
||||
@@ -8,23 +8,23 @@
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton v-permission="'dice:player_ticket_record:index:save'" @click="showDialog('add')" v-ripple>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:player_ticket_record:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
<!-- <ElButton v-permission="'dice:player_ticket_record:index:save'" @click="showDialog('add')" v-ripple>-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:add-fill" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:player_ticket_record:index:destroy'"-->
|
||||
<!-- :disabled="selectedRows.length === 0"-->
|
||||
<!-- @click="deleteSelectedRows(api.delete, refreshData)"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:delete-bin-5-line" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 删除-->
|
||||
<!-- </ElButton>-->
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
@@ -50,11 +50,11 @@
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:player_ticket_record:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:player_ticket_record:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
@@ -77,7 +77,6 @@
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
username: undefined,
|
||||
@@ -123,20 +122,33 @@
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => {
|
||||
const usernameFormatter = (row: Record<string, any>) =>
|
||||
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
||||
return [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'ID', width: 80 },
|
||||
{ prop: 'player_id', label: '玩家用户名', formatter: (row: Record<string, any>) => usernameFormatter(row) },
|
||||
{ prop: 'use_coins', label: '消耗硬币' },
|
||||
{ prop: 'total_ticket_count', label: '总抽奖次数' },
|
||||
{ prop: 'paid_ticket_count', label: '购买抽奖次数' },
|
||||
{ prop: 'free_ticket_count', label: '赠送抽奖次数' },
|
||||
{ prop: 'remark', label: '备注', width: 100, showOverflowTooltip: true },
|
||||
{ prop: 'create_time', label: '创建时间', width: 170 },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
// { type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||
{
|
||||
prop: 'player_id',
|
||||
label: 'page.table.playerUsername',
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => usernameFormatter(row)
|
||||
},
|
||||
{ prop: 'use_coins', label: 'page.table.useCoins', align: 'center' },
|
||||
{ prop: 'total_ticket_count', label: 'page.table.totalDrawCount', align: 'center' },
|
||||
{ prop: 'paid_ticket_count', label: 'page.table.paidDrawCount', align: 'center' },
|
||||
{ prop: 'free_ticket_count', label: 'page.table.freeDrawCount', align: 'center' },
|
||||
{ prop: 'remark', label: 'page.table.remark', width: 100, align: 'center', showOverflowTooltip: true },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -148,10 +160,9 @@
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
// deleteRow,
|
||||
// deleteSelectedRows,
|
||||
handleSelectionChange
|
||||
// selectedRows
|
||||
} = useSaiAdmin()
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增抽奖券获取记录' : '编辑抽奖券获取记录'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="玩家" prop="player_id">
|
||||
<el-form-item :label="$t('page.form.player')" prop="player_id">
|
||||
<el-select
|
||||
v-model="formData.player_id"
|
||||
placeholder="请选择玩家(显示用户名)"
|
||||
:placeholder="$t('page.form.placeholderPlayer')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -25,56 +25,68 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="消耗硬币" prop="use_coins">
|
||||
<el-input-number v-model="formData.use_coins" placeholder="请输入消耗硬币" :min="0" />
|
||||
<el-form-item :label="$t('page.form.useCoins')" prop="use_coins">
|
||||
<el-input-number
|
||||
v-model="formData.use_coins"
|
||||
:placeholder="$t('page.form.placeholderUseCoins')"
|
||||
:min="0"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="购买抽奖次数" prop="paid_ticket_count">
|
||||
<el-form-item :label="$t('page.form.paidDrawCount')" prop="paid_ticket_count">
|
||||
<el-input-number
|
||||
v-model="formData.paid_ticket_count"
|
||||
placeholder="请输入购买抽奖次数"
|
||||
:placeholder="$t('page.form.placeholderPaidDrawCount')"
|
||||
:min="0"
|
||||
@change="onTicketCountChange"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送抽奖次数" prop="free_ticket_count">
|
||||
<el-form-item :label="$t('page.form.freeDrawCount')" prop="free_ticket_count">
|
||||
<el-input-number
|
||||
v-model="formData.free_ticket_count"
|
||||
placeholder="请输入赠送抽奖次数"
|
||||
:placeholder="$t('page.form.placeholderFreeDrawCount')"
|
||||
:min="0"
|
||||
@change="onTicketCountChange"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="总抽奖次数" prop="total_ticket_count">
|
||||
<el-form-item :label="$t('page.form.totalDrawCount')" prop="total_ticket_count">
|
||||
<el-input-number
|
||||
:model-value="totalTicketCountComputed"
|
||||
placeholder="自动求和"
|
||||
:placeholder="$t('page.form.placeholderTotalDrawCount')"
|
||||
:min="0"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item :label="$t('form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注(必填)"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/player_ticket_record/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
@@ -221,10 +233,10 @@
|
||||
const rest = { ...formData } as Record<string, unknown>
|
||||
delete rest.id
|
||||
await api.save(rest)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,24 +9,24 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="玩家(用户名)" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="按用户名搜索" clearable />
|
||||
<el-form-item :label="$t('page.search.player')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.byUsername')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="消耗硬币" prop="use_coins_min">
|
||||
<el-form-item :label="$t('page.search.useCoins')" prop="use_coins_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.use_coins_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.use_coins_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -35,19 +35,19 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="总抽奖次数" prop="total_ticket_count_min">
|
||||
<el-form-item :label="$t('page.search.totalDrawCount')" prop="total_ticket_count_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.total_ticket_count_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.total_ticket_count_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -56,19 +56,19 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="购买抽奖次数" prop="paid_ticket_count_min">
|
||||
<el-form-item :label="$t('page.search.paidDrawCount')" prop="paid_ticket_count_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.paid_ticket_count_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.paid_ticket_count_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -77,19 +77,19 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="赠送抽奖次数" prop="free_ticket_count_min">
|
||||
<el-form-item :label="$t('page.search.freeDrawCount')" prop="free_ticket_count_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.free_ticket_count_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.free_ticket_count_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -98,13 +98,13 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(8)">
|
||||
<el-form-item label="创建时间" prop="create_time_min">
|
||||
<el-form-item :label="$t('page.search.createTime')" prop="create_time_min">
|
||||
<el-date-picker
|
||||
v-model="formData.create_time"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:range-separator="$t('table.searchBar.rangeSeparator')"
|
||||
:start-placeholder="$t('table.searchBar.startTime')"
|
||||
:end-placeholder="$t('table.searchBar.endTime')"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
|
||||
@@ -7,29 +7,29 @@
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:player_wallet_record:index:save'"
|
||||
@click="showDialog('add')"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:player_wallet_record:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
<!-- <ElSpace wrap>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:player_wallet_record:index:save'"-->
|
||||
<!-- @click="showDialog('add')"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:add-fill" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:player_wallet_record:index:destroy'"-->
|
||||
<!-- :disabled="selectedRows.length === 0"-->
|
||||
<!-- @click="deleteSelectedRows(api.delete, refreshData)"-->
|
||||
<!-- v-ripple-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ArtSvgIcon icon="ri:delete-bin-5-line" />-->
|
||||
<!-- </template>-->
|
||||
<!-- 删除-->
|
||||
<!-- </ElButton>-->
|
||||
<!-- </ElSpace>-->
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
@@ -60,11 +60,11 @@
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:player_wallet_record:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
<!-- <SaButton-->
|
||||
<!-- v-permission="'dice:player_wallet_record:index:destroy'"-->
|
||||
<!-- type="error"-->
|
||||
<!-- @click="deleteRow(row, api.delete, refreshData)"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
@@ -81,6 +81,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/player_wallet_record/index'
|
||||
@@ -108,15 +109,16 @@
|
||||
getData()
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
// 类型展示:0=充值 1=提现 2=购买抽奖次数 3=管理员加点 4=管理员扣点 5=抽奖
|
||||
const typeFormatter = (row: Record<string, unknown>) => {
|
||||
const t = row.type
|
||||
if (t === 0) return '充值'
|
||||
if (t === 1) return '提现'
|
||||
if (t === 2) return '购买抽奖次数'
|
||||
if (t === 3) return '管理员加点'
|
||||
if (t === 4) return '管理员扣点'
|
||||
if (t === 5) return '抽奖'
|
||||
const ty = row.type
|
||||
if (ty === 0) return t('page.search.typeRecharge')
|
||||
if (ty === 1) return t('page.search.typeWithdraw')
|
||||
if (ty === 2) return t('page.search.typeBuyTicket')
|
||||
if (ty === 3) return t('page.search.typeAdminAdd')
|
||||
if (ty === 4) return t('page.search.typeAdminSub')
|
||||
if (ty === 5) return t('page.table.typeDraw')
|
||||
return '-'
|
||||
}
|
||||
|
||||
@@ -161,20 +163,21 @@
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection', align: 'center' },
|
||||
{ prop: 'id', label: 'ID', width: 80, align: 'center' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||
{
|
||||
prop: 'player_id',
|
||||
label: '用户',
|
||||
label: 'page.table.user',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
formatter: usernameFormatter
|
||||
},
|
||||
{ prop: 'coin', label: '平台币变化', width: 110, align: 'center' },
|
||||
{ prop: 'coin', label: 'page.table.coinChange', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'type',
|
||||
label: '类型',
|
||||
label: 'page.table.type',
|
||||
width: 140,
|
||||
align: 'center',
|
||||
useSlot: true,
|
||||
@@ -182,28 +185,28 @@
|
||||
},
|
||||
{
|
||||
prop: 'user_id',
|
||||
label: '操作人',
|
||||
label: 'page.table.operator',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
formatter: operatorFormatter
|
||||
},
|
||||
{ prop: 'wallet_before', label: '钱包操作前', width: 110, align: 'center' },
|
||||
{ prop: 'wallet_after', label: '钱包操作后', width: 110, align: 'center' },
|
||||
{ prop: 'wallet_before', label: 'page.table.walletBefore', width: 110, align: 'center' },
|
||||
{ prop: 'wallet_after', label: 'page.table.walletAfter', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '备注',
|
||||
label: 'page.table.remark',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'total_ticket_count', label: '总抽奖次数', align: 'center' },
|
||||
{ prop: 'paid_ticket_count', label: '购买抽奖次数', align: 'center' },
|
||||
{ prop: 'free_ticket_count', label: '赠送抽奖次数', align: 'center' },
|
||||
{ prop: 'create_time', label: '创建时间', width: 170, align: 'center' },
|
||||
{ prop: 'total_ticket_count', label: 'page.table.totalDrawCount', align: 'center' },
|
||||
{ prop: 'paid_ticket_count', label: 'page.table.paidDrawCount', align: 'center' },
|
||||
{ prop: 'free_ticket_count', label: 'page.table.freeDrawCount', align: 'center' },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 100,
|
||||
label: 'table.actions.operation',
|
||||
width: 60,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
@@ -218,10 +221,10 @@
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
// deleteRow,
|
||||
// deleteSelectedRows,
|
||||
handleSelectionChange
|
||||
// selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增玩家钱包流水' : '编辑玩家钱包流水'"
|
||||
:title="dialogType === 'add' ? $t('page.form.dialogTitleAdd') : $t('page.form.dialogTitleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="用户" prop="player_id">
|
||||
<el-form-item :label="$t('page.form.user')" prop="player_id">
|
||||
<el-select
|
||||
v-model="formData.player_id"
|
||||
placeholder="请选择用户(显示用户名)"
|
||||
:placeholder="$t('page.form.placeholderUser')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -26,65 +26,76 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择类型" clearable style="width: 100%">
|
||||
<el-option label="充值" :value="0" />
|
||||
<el-option label="提现" :value="1" />
|
||||
<el-option label="购买抽奖次数" :value="2" />
|
||||
<el-option label="管理员加点" :value="3" />
|
||||
<el-option label="管理员扣点" :value="4" />
|
||||
<el-form-item :label="$t('page.form.type')" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:placeholder="$t('page.form.placeholderType')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option :label="$t('page.form.typeRecharge')" :value="0" />
|
||||
<el-option :label="$t('page.form.typeWithdraw')" :value="1" />
|
||||
<el-option :label="$t('page.form.typeBuyTicket')" :value="2" />
|
||||
<el-option :label="$t('page.form.typeAdminAdd')" :value="3" />
|
||||
<el-option :label="$t('page.form.typeAdminSub')" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="平台币变化" prop="coin">
|
||||
<el-form-item :label="$t('page.form.coinChange')" prop="coin">
|
||||
<el-input-number
|
||||
v-model="formData.coin"
|
||||
placeholder="正数增加、负数减少"
|
||||
:placeholder="$t('page.form.placeholderCoinChange')"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
@change="onCoinChange"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="钱包操作前" prop="wallet_before">
|
||||
<el-form-item :label="$t('page.form.walletBefore')" prop="wallet_before">
|
||||
<el-input-number
|
||||
v-model="formData.wallet_before"
|
||||
placeholder="选择用户后自动带出当前平台币"
|
||||
:placeholder="$t('page.form.placeholderWalletBefore')"
|
||||
:precision="2"
|
||||
disabled
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="钱包操作后" prop="wallet_after">
|
||||
<el-form-item :label="$t('page.form.walletAfter')" prop="wallet_after">
|
||||
<el-input-number
|
||||
v-model="formData.wallet_after"
|
||||
placeholder="根据平台币变化自动计算"
|
||||
:placeholder="$t('page.form.placeholderWalletAfter')"
|
||||
:precision="2"
|
||||
disabled
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item :label="$t('form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="选填"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/player_wallet_record/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
@@ -217,10 +228,10 @@
|
||||
const payload = { ...formData }
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(payload)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,35 +9,35 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(5)">
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="充值" :value="0" />
|
||||
<el-option label="提现" :value="1" />
|
||||
<el-option label="购买抽奖次数" :value="2" />
|
||||
<el-option label="管理员加点" :value="3" />
|
||||
<el-option label="管理员扣点" :value="4" />
|
||||
<el-form-item :label="$t('page.search.type')" prop="type">
|
||||
<el-select v-model="formData.type" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option :label="$t('page.search.typeRecharge')" :value="0" />
|
||||
<el-option :label="$t('page.search.typeWithdraw')" :value="1" />
|
||||
<el-option :label="$t('page.search.typeBuyTicket')" :value="2" />
|
||||
<el-option :label="$t('page.search.typeAdminAdd')" :value="3" />
|
||||
<el-option :label="$t('page.search.typeAdminSub')" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(5)">
|
||||
<el-form-item label="用户(用户名)" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="按用户名搜索" clearable />
|
||||
<el-form-item :label="$t('page.search.user')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.byUsername')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(8)">
|
||||
<el-form-item label="平台币" prop="coin_min">
|
||||
<el-form-item :label="$t('page.search.coin')" prop="coin_min">
|
||||
<div class="coin-range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.coin_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="coin-range-input"
|
||||
/>
|
||||
<span class="coin-range-sep">至</span>
|
||||
<span class="coin-range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.coin_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="coin-range-input"
|
||||
@@ -46,13 +46,13 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(8)">
|
||||
<el-form-item label="创建时间" prop="create_time">
|
||||
<el-form-item :label="$t('page.search.createTime')" prop="create_time">
|
||||
<el-date-picker
|
||||
v-model="formData.create_time"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:range-separator="$t('table.searchBar.rangeSeparator')"
|
||||
:start-placeholder="$t('table.searchBar.startTime')"
|
||||
:end-placeholder="$t('table.searchBar.endTime')"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
|
||||
137
saiadmin-artd/src/views/plugin/dice/reward/index/index.vue
Normal file
137
saiadmin-artd/src/views/plugin/dice/reward/index/index.vue
Normal file
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 方向切换 + 搜索 -->
|
||||
<div class="direction-bar">
|
||||
<el-radio-group v-model="currentDirection" size="default" @change="onDirectionChange">
|
||||
<el-radio-button :value="0">{{ $t('page.search.clockwise') }}</el-radio-button>
|
||||
<el-radio-button :value="1">{{ $t('page.search.anticlockwise') }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:reward:index:batchUpdateWeights'"
|
||||
type="primary"
|
||||
@click="weightRatioVisible = true"
|
||||
v-ripple
|
||||
>
|
||||
{{ $t('page.toolbar.weightRatio') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:reward:index:startWeightTest'"
|
||||
@click="weightTestVisible = true"
|
||||
v-ripple
|
||||
>
|
||||
{{ $t('page.toolbar.weightTest') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
/>
|
||||
</ElCard>
|
||||
|
||||
<WeightRatioDialog v-model="weightRatioVisible" @success="refreshData" />
|
||||
<WeightTestDialog v-model="weightTestVisible" @success="refreshData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import api from '../../api/reward/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import WeightRatioDialog from './modules/weight-ratio-dialog.vue'
|
||||
import WeightTestDialog from './modules/weight-test-dialog.vue'
|
||||
|
||||
const currentDirection = ref<0 | 1>(0)
|
||||
const weightRatioVisible = ref(false)
|
||||
const weightTestVisible = ref(false)
|
||||
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
direction: 0,
|
||||
tier: undefined
|
||||
})
|
||||
|
||||
const listApi = (params: Record<string, any>) => {
|
||||
return api.list({ ...params, direction: currentDirection.value })
|
||||
}
|
||||
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, { ...params, direction: currentDirection.value })
|
||||
getData()
|
||||
}
|
||||
|
||||
const onDirectionChange = () => {
|
||||
searchForm.value.direction = currentDirection.value
|
||||
Object.assign(searchParams, { direction: currentDirection.value, tier: searchForm.value.tier })
|
||||
getData()
|
||||
}
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: listApi,
|
||||
apiParams: { direction: 0, limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ prop: 'start_index', label: 'page.table.startIndex', width: 100, align: 'center' },
|
||||
{ prop: 'end_index', label: 'page.table.endIndex', width: 110, align: 'center' },
|
||||
{ prop: 'tier', label: 'page.table.tier', width: 90, align: 'center', sortable: true },
|
||||
{
|
||||
prop: 'grid_number',
|
||||
label: 'page.table.dicePoints',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
sortable: true,
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'ui_text',
|
||||
label: 'page.table.displayText',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'real_ev', label: 'page.table.realEv', width: 110, align: 'center' },
|
||||
{ prop: 'remark', label: 'page.table.remark', minWidth: 80, align: 'center', showOverflowTooltip: true },
|
||||
{ prop: 'weight', label: 'page.table.weight', width: 110, align: 'center' }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
searchParams.direction = currentDirection.value
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.direction-bar {
|
||||
margin-bottom: 12px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<sa-search-bar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
label-width="100px"
|
||||
:showExpand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
>
|
||||
<el-col v-bind="setSpan(8)">
|
||||
<el-form-item :label="$t('page.search.tier')" prop="tier">
|
||||
<el-select v-model="formData.tier" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option :label="$t('page.search.optionBigwin')" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
modelValue: Record<string, any>
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: Record<string, any>): void
|
||||
(e: 'search', params: Record<string, any>): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val)
|
||||
})
|
||||
|
||||
function handleReset() {
|
||||
searchBarRef.value?.ref?.resetFields?.()
|
||||
emit('reset')
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
emit('search', { ...formData.value })
|
||||
}
|
||||
|
||||
const setSpan = (span: number) => ({
|
||||
span,
|
||||
xs: 24,
|
||||
sm: 12,
|
||||
md: 8,
|
||||
lg: span,
|
||||
xl: span
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,563 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="$t('page.weightEdit.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
{{ $t('page.weightEdit.globalTip') }}
|
||||
</div>
|
||||
<div v-loading="loading" class="dialog-body">
|
||||
<el-tabs v-model="activeTier" type="card">
|
||||
<el-tab-pane v-for="t in tierKeys" :key="t" :label="t" :name="t">
|
||||
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightShared.emptyTier') }}</div>
|
||||
<template v-else>
|
||||
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
|
||||
<div class="chart-row">
|
||||
<ArtBarChart
|
||||
:x-axis-name="$t('page.weightShared.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'clockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
<ArtBarChart
|
||||
:x-axis-name="$t('page.weightShared.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'counterclockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
{{
|
||||
$t('page.weightShared.sumLineDual', {
|
||||
cw: getTierSum(t, 'clockwise'),
|
||||
ccw: getTierSum(t, 'counterclockwise')
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>{{ $t('page.weightShared.t4t5NoteSingle') }}</div>
|
||||
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colDicePoints')"
|
||||
prop="grid_number"
|
||||
width="80"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column :label="$t('page.weightShared.colWeightCwDir')" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeight(row, 'clockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="
|
||||
(v: number | number[]) =>
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'clockwise',
|
||||
Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1)
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="isWeightDisabled(row, t) || getItemWeight(row, 'clockwise') <= 1"
|
||||
@click="
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'clockwise',
|
||||
Math.max(1, getItemWeight(row, 'clockwise') - 1)
|
||||
)
|
||||
"
|
||||
>-</el-button
|
||||
>
|
||||
<el-input-number
|
||||
:model-value="getItemWeight(row, 'clockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="
|
||||
(v: number | string | undefined) =>
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'clockwise',
|
||||
typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1
|
||||
)
|
||||
"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) || getItemWeight(row, 'clockwise') >= 10000
|
||||
"
|
||||
@click="
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'clockwise',
|
||||
Math.min(10000, getItemWeight(row, 'clockwise') + 1)
|
||||
)
|
||||
"
|
||||
>+</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('page.weightShared.colWeightCcwDir')" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeight(row, 'counterclockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="
|
||||
(v: number | number[]) =>
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'counterclockwise',
|
||||
Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1)
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) || getItemWeight(row, 'counterclockwise') <= 1
|
||||
"
|
||||
@click="
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'counterclockwise',
|
||||
Math.max(1, getItemWeight(row, 'counterclockwise') - 1)
|
||||
)
|
||||
"
|
||||
>-</el-button
|
||||
>
|
||||
<el-input-number
|
||||
:model-value="getItemWeight(row, 'counterclockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="
|
||||
(v: number | string | undefined) =>
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'counterclockwise',
|
||||
typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1
|
||||
)
|
||||
"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) ||
|
||||
getItemWeight(row, 'counterclockwise') >= 10000
|
||||
"
|
||||
@click="
|
||||
setItemWeightByRow(
|
||||
t,
|
||||
row,
|
||||
'counterclockwise',
|
||||
Math.min(10000, getItemWeight(row, 'counterclockwise') + 1)
|
||||
)
|
||||
"
|
||||
>+</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('page.weightShared.btnCancel') }}</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">{{
|
||||
$t('page.weightShared.btnSubmit')
|
||||
}}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward/index'
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
/** 供模板 v-for 使用 */
|
||||
const tierKeys = TIER_KEYS
|
||||
type DirectionKey = 'clockwise' | 'counterclockwise'
|
||||
|
||||
interface WeightRow {
|
||||
reward_id_clockwise?: number
|
||||
reward_id_counterclockwise?: number
|
||||
id?: number
|
||||
grid_number?: number
|
||||
real_ev?: number
|
||||
ui_text?: string
|
||||
remark?: string
|
||||
tier?: string
|
||||
weight_clockwise: number
|
||||
weight_counterclockwise: number
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const activeTier = ref('T1')
|
||||
const submitting = ref(false)
|
||||
const loading = ref(false)
|
||||
const grouped = ref<Record<string, WeightRow[]>>({
|
||||
T1: [],
|
||||
T2: [],
|
||||
T3: [],
|
||||
T4: [],
|
||||
T5: []
|
||||
})
|
||||
|
||||
function getTierItems(tier: string): WeightRow[] {
|
||||
return grouped.value[tier] ?? []
|
||||
}
|
||||
|
||||
function getTierChartLabels(tier: string): string[] {
|
||||
return getTierItems(tier).map((r) => String(r.grid_number ?? ''))
|
||||
}
|
||||
|
||||
function getTierChartData(tier: string, dir: DirectionKey): number[] {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
return getTierItems(tier).map((r) => toWeightPrecision(r[key] ?? 1))
|
||||
}
|
||||
|
||||
function getTierSum(tier: string, dir: DirectionKey): number {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
return getTierItems(tier).reduce((s, r) => s + toWeightPrecision(r[key] ?? 1), 0)
|
||||
}
|
||||
|
||||
function getItemWeight(row: WeightRow, dir: DirectionKey): number {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
const w = row[key]
|
||||
const num = typeof w === 'number' && !Number.isNaN(w) ? w : Number(w)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return toWeightPrecision(num)
|
||||
}
|
||||
|
||||
function toWeightPrecision(value: number): number {
|
||||
return Math.max(1, Math.min(10000, Math.floor(value)))
|
||||
}
|
||||
|
||||
function setItemWeightByRow(tier: string, row: WeightRow, dir: DirectionKey, value: number) {
|
||||
const v = toWeightPrecision(typeof value === 'number' && !Number.isNaN(value) ? value : 1)
|
||||
const list = grouped.value[tier]
|
||||
if (!list) return
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
const rid = dir === 'clockwise' ? row.reward_id_clockwise : row.reward_id_counterclockwise
|
||||
const idx = list.findIndex(
|
||||
(r) =>
|
||||
r === row ||
|
||||
(rid != null &&
|
||||
(dir === 'clockwise' ? r.reward_id_clockwise : r.reward_id_counterclockwise) === rid)
|
||||
)
|
||||
if (idx >= 0) list[idx][key] = v
|
||||
else row[key] = v
|
||||
}
|
||||
|
||||
function isWeightDisabled(row: WeightRow, tier: string): boolean {
|
||||
if (tier === 'T4' || tier === 'T5') return true
|
||||
return false
|
||||
}
|
||||
|
||||
function normalizeWeightValue(v: unknown): number {
|
||||
const num = typeof v === 'number' && !Number.isNaN(v) ? v : Number(v)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return Math.max(1, Math.min(10000, Math.floor(num)))
|
||||
}
|
||||
|
||||
/** 兼容接口返回 tier -> { 0: [], 1: [] },按 grid_number 合并为每档位一行,含 reward_id 与双方向权重 */
|
||||
function parsePayload(res: any): Record<string, WeightRow[]> {
|
||||
const empty: Record<string, WeightRow[]> = {
|
||||
T1: [],
|
||||
T2: [],
|
||||
T3: [],
|
||||
T4: [],
|
||||
T5: []
|
||||
}
|
||||
if (!res || typeof res !== 'object') return empty
|
||||
const raw = res?.data ?? res
|
||||
if (!raw || typeof raw !== 'object') return empty
|
||||
const out = { ...empty }
|
||||
for (const t of TIER_KEYS) {
|
||||
const tierData = raw[t]
|
||||
if (!tierData || typeof tierData !== 'object') continue
|
||||
const list0 = Array.isArray(tierData[0]) ? tierData[0] : []
|
||||
const list1 = Array.isArray(tierData[1]) ? tierData[1] : []
|
||||
const byGrid = new Map<
|
||||
number,
|
||||
{
|
||||
reward_id_clockwise?: number
|
||||
reward_id_counterclockwise?: number
|
||||
id?: number
|
||||
grid_number?: number
|
||||
real_ev?: number
|
||||
ui_text?: string
|
||||
remark?: string
|
||||
weight_clockwise: number
|
||||
weight_counterclockwise: number
|
||||
}
|
||||
>()
|
||||
for (const r of list0) {
|
||||
const gn = r.grid_number != null ? Number(r.grid_number) : NaN
|
||||
if (!Number.isNaN(gn)) {
|
||||
byGrid.set(gn, {
|
||||
reward_id_clockwise: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
id: r.id != null ? Number(r.id) : undefined,
|
||||
grid_number: gn,
|
||||
real_ev: r.real_ev,
|
||||
ui_text: r.ui_text,
|
||||
remark: r.remark,
|
||||
weight_clockwise: normalizeWeightValue(r.weight),
|
||||
weight_counterclockwise: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
for (const r of list1) {
|
||||
const gn = r.grid_number != null ? Number(r.grid_number) : NaN
|
||||
if (!Number.isNaN(gn)) {
|
||||
const cur = byGrid.get(gn)
|
||||
if (cur) {
|
||||
cur.reward_id_counterclockwise = r.reward_id != null ? Number(r.reward_id) : undefined
|
||||
cur.weight_counterclockwise = normalizeWeightValue(r.weight)
|
||||
} else {
|
||||
byGrid.set(gn, {
|
||||
reward_id_counterclockwise: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
id: r.id != null ? Number(r.id) : undefined,
|
||||
grid_number: gn,
|
||||
real_ev: r.real_ev,
|
||||
ui_text: r.ui_text,
|
||||
remark: r.remark,
|
||||
weight_clockwise: 1,
|
||||
weight_counterclockwise: normalizeWeightValue(r.weight)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
out[t] = Array.from(byGrid.values())
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
loading.value = true
|
||||
api
|
||||
.weightRatioListWithDirection()
|
||||
.then((res: any) => {
|
||||
grouped.value = parsePayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(t('page.weightShared.fetchFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 按 DiceReward 主键 id 收集:每条记录一条 { id, weight } */
|
||||
function collectItems(): Array<{ id: number; weight: number }> {
|
||||
const items: Array<{ id: number; weight: number }> = []
|
||||
for (const t of TIER_KEYS) {
|
||||
for (const row of getTierItems(t)) {
|
||||
const w0 = isWeightDisabled(row, t) ? 10000 : getItemWeight(row, 'clockwise')
|
||||
const w1 = isWeightDisabled(row, t) ? 10000 : getItemWeight(row, 'counterclockwise')
|
||||
const rid0 = row.reward_id_clockwise != null ? row.reward_id_clockwise : 0
|
||||
const rid1 = row.reward_id_counterclockwise != null ? row.reward_id_counterclockwise : 0
|
||||
if (rid0 > 0) items.push({ id: rid0, weight: w0 })
|
||||
if (rid1 > 0) items.push({ id: rid1, weight: w1 })
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info(t('page.weightShared.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success(t('page.weightShared.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? t('page.weightShared.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (open) {
|
||||
loadData()
|
||||
activeTier.value = 'T1'
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chart-wrap {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.chart-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
> * {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
.weight-sum {
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.weight-sum-t4t5 {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.global-tip {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.weight-table {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.weight-cell-vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.weight-slider-wrap {
|
||||
width: 100%;
|
||||
min-width: 80px;
|
||||
padding: 0 8px;
|
||||
:deep(.weight-slider) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.weight-input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.dialog-body {
|
||||
min-height: 320px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,600 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="$t('page.weightRatio.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
{{ $t('page.weightRatio.globalTip') }}
|
||||
</div>
|
||||
<div v-loading="loading" class="dialog-body">
|
||||
<!-- 一级:方向(懒加载避免逆时针柱状图在隐藏容器内初始化导致不显示);二级档位 -->
|
||||
<el-tabs v-model="activeDirection" type="card" class="direction-tabs" :lazy="true">
|
||||
<el-tab-pane :label="$t('page.weightRatio.tabClockwise')" name="0">
|
||||
<el-tabs v-model="activeTier" type="card" class="tier-tabs">
|
||||
<el-tab-pane v-for="t in tierKeys" :key="'cw-' + t" :label="t" :name="t">
|
||||
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightShared.emptyTier') }}</div>
|
||||
<template v-else>
|
||||
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
|
||||
<ArtBarChart
|
||||
:key="'cw-' + activeDirection + '-' + t"
|
||||
:x-axis-name="$t('page.weightShared.xAxisGridNumber')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartDataForCurrentDirection(t)"
|
||||
height="180px"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
{{
|
||||
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>{{ $t('page.weightShared.t4t5NoteSingle') }}</div>
|
||||
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colGridNumber')"
|
||||
prop="grid_number"
|
||||
width="110"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="currentWeightColumnLabel"
|
||||
min-width="200"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeightForCurrentDirection(row)"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="
|
||||
(v: number | number[]) =>
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1)
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) || getItemWeightForCurrentDirection(row) <= 1
|
||||
"
|
||||
@click="
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Math.max(1, getItemWeightForCurrentDirection(row) - 1)
|
||||
)
|
||||
"
|
||||
>-</el-button
|
||||
>
|
||||
<el-input-number
|
||||
:model-value="getItemWeightForCurrentDirection(row)"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="
|
||||
(v: number | string | undefined) =>
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1
|
||||
)
|
||||
"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) ||
|
||||
getItemWeightForCurrentDirection(row) >= 10000
|
||||
"
|
||||
@click="
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Math.min(10000, getItemWeightForCurrentDirection(row) + 1)
|
||||
)
|
||||
"
|
||||
>+</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('page.weightRatio.tabCounterclockwise')" name="1">
|
||||
<el-tabs v-model="activeTier" type="card" class="tier-tabs">
|
||||
<el-tab-pane v-for="t in tierKeys" :key="'ccw-' + t" :label="t" :name="t">
|
||||
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightShared.emptyTier') }}</div>
|
||||
<template v-else>
|
||||
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
|
||||
<ArtBarChart
|
||||
:key="'ccw-' + activeDirection + '-' + t"
|
||||
:x-axis-name="$t('page.weightShared.xAxisGridNumber')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartDataForCurrentDirection(t)"
|
||||
height="180px"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
{{
|
||||
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>{{ $t('page.weightShared.t4t5NoteSingle') }}</div>
|
||||
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colGridNumber')"
|
||||
prop="grid_number"
|
||||
width="110"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="currentWeightColumnLabel"
|
||||
min-width="200"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeightForCurrentDirection(row)"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="
|
||||
(v: number | number[]) =>
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1)
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) || getItemWeightForCurrentDirection(row) <= 1
|
||||
"
|
||||
@click="
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Math.max(1, getItemWeightForCurrentDirection(row) - 1)
|
||||
)
|
||||
"
|
||||
>-</el-button
|
||||
>
|
||||
<el-input-number
|
||||
:model-value="getItemWeightForCurrentDirection(row)"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="
|
||||
(v: number | string | undefined) =>
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1
|
||||
)
|
||||
"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="
|
||||
isWeightDisabled(row, t) ||
|
||||
getItemWeightForCurrentDirection(row) >= 10000
|
||||
"
|
||||
@click="
|
||||
setItemWeightForCurrentDirection(
|
||||
t,
|
||||
row,
|
||||
Math.min(10000, getItemWeightForCurrentDirection(row) + 1)
|
||||
)
|
||||
"
|
||||
>+</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('page.weightShared.btnCancel') }}</el-button>
|
||||
<el-button
|
||||
v-permission="'dice:reward:index:batchUpdateWeights'"
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
@click="handleSubmit"
|
||||
>{{ $t('page.weightShared.btnSubmit') }}</el-button
|
||||
>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward/index'
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
type DirectionKey = 'clockwise' | 'counterclockwise'
|
||||
|
||||
/** 当前方向下的行:reward_id=DiceReward 主键(用于提交更新),id=end_index 展示用,weight 为当前方向权重 */
|
||||
interface WeightRow {
|
||||
reward_id?: number
|
||||
id?: number
|
||||
grid_number?: number
|
||||
real_ev?: number
|
||||
ui_text?: string
|
||||
remark?: string
|
||||
weight: number
|
||||
}
|
||||
|
||||
/** 按档位、方向分组:tier -> { '0': 顺时针行列表, '1': 逆时针行列表 } */
|
||||
type GroupedByTierDirection = Record<string, { '0': WeightRow[]; '1': WeightRow[] }>
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const activeDirection = ref<'0' | '1'>('0')
|
||||
const activeTier = ref('T1')
|
||||
const submitting = ref(false)
|
||||
const loading = ref(false)
|
||||
const grouped = ref<GroupedByTierDirection>({
|
||||
T1: { '0': [], '1': [] },
|
||||
T2: { '0': [], '1': [] },
|
||||
T3: { '0': [], '1': [] },
|
||||
T4: { '0': [], '1': [] },
|
||||
T5: { '0': [], '1': [] }
|
||||
})
|
||||
|
||||
const currentWeightColumnLabel = computed(() => {
|
||||
locale.value
|
||||
const dirLabel =
|
||||
activeDirection.value === '0'
|
||||
? t('page.weightRatio.tabClockwise')
|
||||
: t('page.weightRatio.tabCounterclockwise')
|
||||
return `${dirLabel} ${t('page.weightShared.weightColSuffix')}`
|
||||
})
|
||||
|
||||
const tierKeys = TIER_KEYS
|
||||
|
||||
function getTierItems(tier: string): WeightRow[] {
|
||||
const dir = activeDirection.value
|
||||
const tierData = grouped.value[tier]
|
||||
if (!tierData || !tierData[dir]) return []
|
||||
return tierData[dir]
|
||||
}
|
||||
|
||||
function getTierChartLabels(tier: string): string[] {
|
||||
return getTierItems(tier).map((r) => String(r.grid_number ?? ''))
|
||||
}
|
||||
|
||||
function getTierChartDataForCurrentDirection(tier: string): number[] {
|
||||
return getTierItems(tier).map((r) => toWeightPrecision(r.weight ?? 1))
|
||||
}
|
||||
|
||||
function getTierSumForCurrentDirection(tier: string): number {
|
||||
return getTierItems(tier).reduce((s, r) => s + toWeightPrecision(r.weight ?? 1), 0)
|
||||
}
|
||||
|
||||
function getItemWeightForCurrentDirection(row: WeightRow): number {
|
||||
const w = row.weight
|
||||
const num = typeof w === 'number' && !Number.isNaN(w) ? w : Number(w)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return toWeightPrecision(num)
|
||||
}
|
||||
|
||||
function toWeightPrecision(value: number): number {
|
||||
return Math.max(1, Math.min(10000, Math.floor(value)))
|
||||
}
|
||||
|
||||
function setItemWeightForCurrentDirection(tier: string, row: WeightRow, value: number) {
|
||||
const v = toWeightPrecision(value)
|
||||
const dir = activeDirection.value
|
||||
const tierData = grouped.value[tier]
|
||||
if (!tierData || !tierData[dir]) return
|
||||
const list = tierData[dir]
|
||||
const rid = row.reward_id != null ? row.reward_id : undefined
|
||||
list.forEach((r) => {
|
||||
if (r === row || (rid != null && r.reward_id != null && r.reward_id === rid)) r.weight = v
|
||||
})
|
||||
grouped.value[tier][dir] = [...list]
|
||||
}
|
||||
|
||||
function isWeightDisabled(row: WeightRow, tier: string): boolean {
|
||||
if (tier === 'T4' || tier === 'T5') return true
|
||||
return false
|
||||
}
|
||||
|
||||
function normalizeWeightValue(v: unknown): number {
|
||||
const num = typeof v === 'number' && !Number.isNaN(v) ? v : Number(v)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return Math.max(1, Math.min(10000, Math.floor(num)))
|
||||
}
|
||||
|
||||
/** 兼容后端返回 tier -> { 0: [], 1: [] },每行含 reward_id, id(end_index), grid_number, ui_text, real_ev, remark, weight */
|
||||
function parsePayload(res: any): GroupedByTierDirection {
|
||||
const empty: GroupedByTierDirection = {
|
||||
T1: { '0': [], '1': [] },
|
||||
T2: { '0': [], '1': [] },
|
||||
T3: { '0': [], '1': [] },
|
||||
T4: { '0': [], '1': [] },
|
||||
T5: { '0': [], '1': [] }
|
||||
}
|
||||
if (!res || typeof res !== 'object') return empty
|
||||
const raw = res?.data ?? res
|
||||
if (!raw || typeof raw !== 'object') return empty
|
||||
const out = { ...empty }
|
||||
for (const t of TIER_KEYS) {
|
||||
const tierData = raw[t]
|
||||
if (!tierData || typeof tierData !== 'object') continue
|
||||
out[t] = {
|
||||
'0': Array.isArray(tierData[0])
|
||||
? tierData[0].map((r: any) => ({
|
||||
...r,
|
||||
reward_id: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
weight: normalizeWeightValue(r.weight)
|
||||
}))
|
||||
: [],
|
||||
'1': Array.isArray(tierData[1])
|
||||
? tierData[1].map((r: any) => ({
|
||||
...r,
|
||||
reward_id: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
weight: normalizeWeightValue(r.weight)
|
||||
}))
|
||||
: []
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
loading.value = true
|
||||
api
|
||||
.weightRatioListWithDirection()
|
||||
.then((res: any) => {
|
||||
grouped.value = parsePayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(t('page.weightShared.fetchFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 按 DiceReward 主键 id 收集:每条记录一条 { id, reward_id, weight },后端按 id 更新(reward_id 作回退) */
|
||||
function collectItems(): Array<{ id: number; reward_id: number; weight: number }> {
|
||||
const items: Array<{ id: number; reward_id: number; weight: number }> = []
|
||||
for (const t of TIER_KEYS) {
|
||||
const tierData = grouped.value[t]
|
||||
if (!tierData) continue
|
||||
for (const dir of ['0', '1'] as const) {
|
||||
const list = tierData[dir] ?? []
|
||||
for (const row of list) {
|
||||
const rid = row.reward_id != null ? Number(row.reward_id) : 0
|
||||
if (rid <= 0) continue
|
||||
const w = isWeightDisabled(row, t) ? 10000 : toWeightPrecision(row.weight ?? 1)
|
||||
items.push({ id: rid, reward_id: rid, weight: w })
|
||||
}
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info(t('page.weightShared.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success(t('page.weightShared.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? t('page.weightShared.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (open) {
|
||||
loadData()
|
||||
activeDirection.value = '0'
|
||||
activeTier.value = 'T1'
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.direction-tabs {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.tier-tabs {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.chart-wrap {
|
||||
margin-bottom: 12px;
|
||||
min-height: 200px;
|
||||
}
|
||||
.weight-sum {
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.weight-sum-t4t5 {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.global-tip {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.weight-table {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.weight-cell-vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.weight-slider-wrap {
|
||||
width: 100%;
|
||||
min-width: 80px;
|
||||
padding: 0 8px;
|
||||
.weight-slider {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.weight-input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.dialog-body {
|
||||
min-height: 320px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,415 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
:title="$t('page.weightTest.title')"
|
||||
width="560px"
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@close="onClose"
|
||||
>
|
||||
<ElAlert type="info" :closable="false" show-icon class="weight-test-tip">
|
||||
<template #title>{{ $t('page.weightTest.alertTitle') }}</template>
|
||||
{{ $t('page.weightTest.alertBody') }}
|
||||
</ElAlert>
|
||||
<ElForm ref="formRef" :model="form" label-width="140px">
|
||||
<ElSteps :active="currentStep" finish-status="success" simple class="steps-wrap">
|
||||
<ElStep :title="$t('page.weightTest.stepPaid')" />
|
||||
<ElStep :title="$t('page.weightTest.stepFree')" />
|
||||
</ElSteps>
|
||||
|
||||
<!-- 第一页:付费抽奖券 -->
|
||||
<div v-show="currentStep === 0" class="step-panel">
|
||||
<ElFormItem
|
||||
:label="$t('page.weightTest.labelLotteryTypePaid')"
|
||||
prop="paid_lottery_config_id"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="form.paid_lottery_config_id"
|
||||
:placeholder="$t('page.weightTest.placeholderPaidPool')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in paidLotteryOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<template v-if="form.paid_lottery_config_id == null">
|
||||
<div class="tier-label">{{ $t('page.weightTest.tierProbHint') }}</div>
|
||||
<ElRow :gutter="12" class="tier-row">
|
||||
<ElCol v-for="t in tierKeys" :key="'paid-' + t" :span="8">
|
||||
<div class="tier-field">
|
||||
<label class="tier-field-label">{{
|
||||
$t('page.weightTest.tierFieldLabel', { tier: t })
|
||||
}}</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="getPaidTier(t)"
|
||||
min="0"
|
||||
max="100"
|
||||
placeholder="0"
|
||||
class="tier-input"
|
||||
@input="setPaidTier(t, $event)"
|
||||
/>
|
||||
</div>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
<div v-if="paidTierSum > 100" class="tier-error">{{
|
||||
$t('page.weightTest.tierSumError', { sum: paidTierSum })
|
||||
}}</div>
|
||||
</template>
|
||||
<ElFormItem :label="$t('page.weightTest.labelCwCount')" prop="paid_s_count" required>
|
||||
<ElSelect
|
||||
v-model="form.paid_s_count"
|
||||
:placeholder="$t('page.weightTest.placeholderSelect')"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.weightTest.labelCcwCount')" prop="paid_n_count" required>
|
||||
<ElSelect
|
||||
v-model="form.paid_n_count"
|
||||
:placeholder="$t('page.weightTest.placeholderSelect')"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<!-- 第二页:免费抽奖券 -->
|
||||
<div v-show="currentStep === 1" class="step-panel">
|
||||
<ElFormItem
|
||||
:label="$t('page.weightTest.labelLotteryTypeFree')"
|
||||
prop="free_lottery_config_id"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="form.free_lottery_config_id"
|
||||
:placeholder="$t('page.weightTest.placeholderFreePool')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in freeLotteryOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<template v-if="form.free_lottery_config_id == null">
|
||||
<div class="tier-label">{{ $t('page.weightTest.tierProbHint') }}</div>
|
||||
<ElRow :gutter="12" class="tier-row">
|
||||
<ElCol v-for="t in tierKeys" :key="'free-' + t" :span="8">
|
||||
<div class="tier-field">
|
||||
<label class="tier-field-label">{{
|
||||
$t('page.weightTest.tierFieldLabel', { tier: t })
|
||||
}}</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="getFreeTier(t)"
|
||||
min="0"
|
||||
max="100"
|
||||
placeholder="0"
|
||||
class="tier-input"
|
||||
@input="setFreeTier(t, $event)"
|
||||
/>
|
||||
</div>
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
<div v-if="freeTierSum > 100" class="tier-error">{{
|
||||
$t('page.weightTest.tierSumError', { sum: freeTierSum })
|
||||
}}</div>
|
||||
</template>
|
||||
<ElFormItem :label="$t('page.weightTest.labelCwCount')" prop="free_s_count" required>
|
||||
<ElSelect
|
||||
v-model="form.free_s_count"
|
||||
:placeholder="$t('page.weightTest.placeholderSelect')"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.weightTest.labelCcwCount')" prop="free_n_count" required>
|
||||
<ElSelect
|
||||
v-model="form.free_n_count"
|
||||
:placeholder="$t('page.weightTest.placeholderSelect')"
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton v-if="currentStep > 0" :disabled="running" @click="currentStep--">{{
|
||||
$t('page.weightTest.btnPrev')
|
||||
}}</ElButton>
|
||||
<ElButton v-if="currentStep < 1" type="primary" :disabled="running" @click="currentStep++">{{
|
||||
$t('page.weightTest.btnNext')
|
||||
}}</ElButton>
|
||||
<ElButton
|
||||
v-if="currentStep === 1"
|
||||
v-permission="'dice:reward:index:startWeightTest'"
|
||||
type="primary"
|
||||
:loading="running"
|
||||
@click="handleStart"
|
||||
>{{ $t('page.weightTest.btnStart') }}</ElButton
|
||||
>
|
||||
<ElButton :disabled="running" @click="visible = false">{{
|
||||
$t('page.weightTest.btnCancel')
|
||||
}}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward/index'
|
||||
import lotteryPoolApi from '../../../api/lottery_pool_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const countOptions = [0, 100, 500, 1000, 5000]
|
||||
const tierKeys = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
|
||||
const visible = defineModel<boolean>({ default: false })
|
||||
const emit = defineEmits<{ (e: 'success'): void }>()
|
||||
|
||||
const formRef = ref()
|
||||
const currentStep = ref(0)
|
||||
const form = reactive({
|
||||
paid_lottery_config_id: undefined as number | undefined,
|
||||
free_lottery_config_id: undefined as number | undefined,
|
||||
paid_tier_weights: { T1: 20, T2: 20, T3: 20, T4: 20, T5: 20 } as Record<string, number>,
|
||||
free_tier_weights: { T1: 20, T2: 20, T3: 20, T4: 20, T5: 20 } as Record<string, number>,
|
||||
paid_s_count: 100,
|
||||
paid_n_count: 100,
|
||||
free_s_count: 100,
|
||||
free_n_count: 100
|
||||
})
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
/** 付费抽奖券可选档位:name=default */
|
||||
const paidLotteryOptions = computed(() =>
|
||||
lotteryOptions.value.filter((r) => r.name === 'default')
|
||||
)
|
||||
/** 免费抽奖券可选档位:优先 name=killScore,若无则显示全部以便下拉有选项 */
|
||||
const freeLotteryOptions = computed(() => {
|
||||
const list = lotteryOptions.value.filter((r) => r.name === 'killScore')
|
||||
return list.length > 0 ? list : lotteryOptions.value
|
||||
})
|
||||
const running = ref(false)
|
||||
|
||||
function onClose() {
|
||||
running.value = false
|
||||
currentStep.value = 0
|
||||
}
|
||||
|
||||
function getPaidTier(t: string): string {
|
||||
const v = form.paid_tier_weights[t]
|
||||
return v !== undefined && v !== null ? String(v) : ''
|
||||
}
|
||||
function setPaidTier(t: string, val: string | Event) {
|
||||
const raw =
|
||||
typeof val === 'string'
|
||||
? val
|
||||
: ((val as Event & { target: HTMLInputElement }).target?.value ?? '')
|
||||
const num = raw === '' ? 0 : Math.max(0, Math.min(100, Number(raw) || 0))
|
||||
form.paid_tier_weights[t] = num
|
||||
}
|
||||
const paidTierSum = computed(() =>
|
||||
tierKeys.reduce((s, t) => s + (form.paid_tier_weights[t] ?? 0), 0)
|
||||
)
|
||||
function getFreeTier(t: string): string {
|
||||
const v = form.free_tier_weights[t]
|
||||
return v !== undefined && v !== null ? String(v) : ''
|
||||
}
|
||||
function setFreeTier(t: string, val: string | Event) {
|
||||
const raw =
|
||||
typeof val === 'string'
|
||||
? val
|
||||
: ((val as Event & { target: HTMLInputElement }).target?.value ?? '')
|
||||
const num = raw === '' ? 0 : Math.max(0, Math.min(100, Number(raw) || 0))
|
||||
form.free_tier_weights[t] = num
|
||||
}
|
||||
const freeTierSum = computed(() =>
|
||||
tierKeys.reduce((s, t) => s + (form.free_tier_weights[t] ?? 0), 0)
|
||||
)
|
||||
|
||||
async function loadLotteryOptions() {
|
||||
try {
|
||||
const list = await lotteryPoolApi.getOptions()
|
||||
lotteryOptions.value = list.map((r: { id: number; name: string }) => ({
|
||||
id: r.id,
|
||||
name: r.name
|
||||
}))
|
||||
// 付费抽奖券默认使用 name=default
|
||||
const normal = list.find((r: { name?: string }) => r.name === 'default')
|
||||
if (normal) {
|
||||
form.paid_lottery_config_id = normal.id
|
||||
}
|
||||
// 免费抽奖券默认使用 name=killScore;若无则默认选第一项
|
||||
const kill = list.find((r: { name?: string }) => r.name === 'killScore')
|
||||
if (kill) {
|
||||
form.free_lottery_config_id = kill.id
|
||||
} else if (list.length > 0) {
|
||||
form.free_lottery_config_id = list[0].id
|
||||
}
|
||||
} catch {
|
||||
lotteryOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const payload: Record<string, unknown> = {
|
||||
paid_s_count: form.paid_s_count,
|
||||
paid_n_count: form.paid_n_count,
|
||||
free_s_count: form.free_s_count,
|
||||
free_n_count: form.free_n_count
|
||||
}
|
||||
if (form.paid_lottery_config_id != null) {
|
||||
payload.paid_lottery_config_id = form.paid_lottery_config_id
|
||||
} else {
|
||||
payload.paid_tier_weights = { ...form.paid_tier_weights }
|
||||
}
|
||||
if (form.free_lottery_config_id != null) {
|
||||
payload.free_lottery_config_id = form.free_lottery_config_id
|
||||
} else {
|
||||
payload.free_tier_weights = { ...form.free_tier_weights }
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
function validateForm(): boolean {
|
||||
if (form.paid_s_count + form.paid_n_count + form.free_s_count + form.free_n_count <= 0) {
|
||||
ElMessage.warning(t('page.weightTest.warnTotalSpins'))
|
||||
return false
|
||||
}
|
||||
const needPaidTier = form.paid_lottery_config_id == null
|
||||
const needFreeTier = form.free_lottery_config_id == null
|
||||
if (needPaidTier) {
|
||||
const sum = paidTierSum.value
|
||||
if (sum <= 0) {
|
||||
ElMessage.warning(t('page.weightTest.warnPaidTierSumPositive'))
|
||||
return false
|
||||
}
|
||||
if (sum > 100) {
|
||||
ElMessage.warning(t('page.weightTest.warnPaidTierSumMax'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (needFreeTier) {
|
||||
const sum = freeTierSum.value
|
||||
if (sum <= 0) {
|
||||
ElMessage.warning(t('page.weightTest.warnFreeTierSumPositive'))
|
||||
return false
|
||||
}
|
||||
if (sum > 100) {
|
||||
ElMessage.warning(t('page.weightTest.warnFreeTierSumMax'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleStart() {
|
||||
if (!validateForm()) return
|
||||
running.value = true
|
||||
try {
|
||||
await api.startWeightTest(buildPayload())
|
||||
ElMessage.success(t('page.weightTest.successCreated'))
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || t('page.weightTest.failCreate'))
|
||||
} finally {
|
||||
running.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(visible, (v) => {
|
||||
if (v) {
|
||||
loadLotteryOptions()
|
||||
} else {
|
||||
onClose()
|
||||
}
|
||||
})
|
||||
|
||||
// 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 killScore 的选项,避免显示错误
|
||||
watch(currentStep, (step) => {
|
||||
if (step === 1) {
|
||||
const freeOpts = freeLotteryOptions.value
|
||||
const id = form.free_lottery_config_id
|
||||
if (freeOpts.length && (id == null || !freeOpts.some((o) => o.id === id))) {
|
||||
form.free_lottery_config_id = freeOpts[0].id
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.weight-test-tip {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.steps-wrap {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.step-panel {
|
||||
min-height: 200px;
|
||||
}
|
||||
.tier-label {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.tier-row {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.tier-field {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.tier-field-label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.tier-input {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-text-color-regular);
|
||||
background-color: var(--el-fill-color-blank);
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.tier-input:hover {
|
||||
border-color: var(--el-border-color-hover);
|
||||
}
|
||||
.tier-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--el-color-primary);
|
||||
box-shadow: 0 0 0 2px var(--el-color-primary-light-7);
|
||||
}
|
||||
.tier-input::placeholder {
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
.tier-error {
|
||||
font-size: 12px;
|
||||
color: var(--el-color-danger);
|
||||
margin-top: 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,142 +1,588 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
<div class="art-full-height reward-config-form">
|
||||
<ElCard shadow="never" class="form-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>{{ $t('page.toolbar.gameRewardConfig') }}</span>
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:createRewardReference'"
|
||||
type="warning"
|
||||
:loading="createRewardLoading"
|
||||
@click="handleCreateRewardReference"
|
||||
v-ripple
|
||||
:title="$t('page.toolbar.createRewardRefTitle')"
|
||||
>
|
||||
{{ $t('page.toolbar.createRewardRef') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:save'"
|
||||
@click="showDialog('add')"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 操作列 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:reward_config:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:reward_config:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
<ElTabs v-model="activeTab" type="card" class="top-tabs">
|
||||
<ElTabPane :label="$t('page.configPage.tabIndex')" name="index">
|
||||
<div class="tab-panel">
|
||||
<div class="panel-tip">{{ $t('page.configPage.tipIndex') }}</div>
|
||||
<div class="table-scroll-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="indexRowsExcludeBigwin"
|
||||
border
|
||||
size="default"
|
||||
class="config-table"
|
||||
>
|
||||
<ElTableColumn :label="$t('page.configPage.colId')" prop="id" width="60" align="center">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.id }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colDicePoints')" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.grid_number"
|
||||
:min="5"
|
||||
:max="30"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="full-width"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colDisplayText')" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.ui_text"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayZh')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colDisplayTextEn')" min-width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.ui_text_en"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayEn')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colRealEv')" min-width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.real_ev"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="full-width"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colTier')" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElSelect
|
||||
v-model="row.tier"
|
||||
:placeholder="$t('page.configPage.placeholderTierSelect')"
|
||||
clearable
|
||||
size="small"
|
||||
class="full-width"
|
||||
>
|
||||
<ElOption label="T1" value="T1" />
|
||||
<ElOption label="T2" value="T2" />
|
||||
<ElOption label="T3" value="T3" />
|
||||
<ElOption label="T4" value="T4" />
|
||||
<ElOption label="T5" value="T5" />
|
||||
</ElSelect>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colRemark')" min-width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.remark"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderRemark')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
<div class="tab-footer">
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:batchUpdate'"
|
||||
type="primary"
|
||||
:loading="savingIndex"
|
||||
@click="handleSaveIndex"
|
||||
>{{ $t('page.configPage.btnSave') }}</ElButton
|
||||
>
|
||||
<ElButton @click="handleResetIndex">{{ $t('page.configPage.btnReset') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElTabPane>
|
||||
<ElTabPane :label="$t('page.configPage.tabBigwin')" name="bigwin">
|
||||
<div class="tab-panel">
|
||||
<div class="panel-tip">{{ $t('page.configPage.tipBigwin') }}</div>
|
||||
<div class="table-scroll-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="bigwinRows"
|
||||
border
|
||||
size="default"
|
||||
class="config-table bigwin-table"
|
||||
>
|
||||
<ElTableColumn :label="$t('page.configPage.colBigwinPoints')" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<span class="readonly-value">{{ row.grid_number }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colDisplayInfo')" min-width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.ui_text"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayInfoZh')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colDisplayInfoEn')" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.ui_text_en"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayInfoEn')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colRealPrize')" min-width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.real_ev"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="full-width"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colRemark')" min-width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElInput
|
||||
v-model="row.remark"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderRemark')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colWeightRange')" min-width="220" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell">
|
||||
<ElSlider
|
||||
v-model="row.weight"
|
||||
:min="0"
|
||||
:max="10000"
|
||||
:step="100"
|
||||
:disabled="isBigwinWeightDisabled(row)"
|
||||
/>
|
||||
<ElInputNumber
|
||||
v-model="row.weight"
|
||||
:min="0"
|
||||
:max="10000"
|
||||
:step="100"
|
||||
:disabled="isBigwinWeightDisabled(row)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="isBigwinWeightDisabled(row)" class="weight-tip">{{
|
||||
$t('page.configPage.weightFixedTip')
|
||||
}}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
<div v-if="bigwinRows.length === 0 && !loading" class="empty-tip">
|
||||
{{ $t('page.configPage.emptyBigwin') }}
|
||||
</div>
|
||||
<div class="tab-footer">
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:saveBigwinWeightsByGrid'"
|
||||
type="primary"
|
||||
:loading="savingBigwin"
|
||||
@click="handleSaveBigwin"
|
||||
>{{ $t('page.configPage.btnSave') }}</ElButton
|
||||
>
|
||||
<ElButton @click="handleResetBigwin">{{ $t('page.configPage.btnReset') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
</ElCard>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import api from '../../api/reward_config/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
grid_number_min: undefined,
|
||||
grid_number_max: undefined,
|
||||
ui_text: undefined,
|
||||
real_ev_min: undefined,
|
||||
real_ev_max: undefined,
|
||||
tier: undefined
|
||||
})
|
||||
const { t } = useI18n()
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
/** 第一页:奖励索引行(来自 DiceRewardConfig 表) */
|
||||
interface IndexRow {
|
||||
id: number
|
||||
grid_number: number
|
||||
ui_text: string
|
||||
ui_text_en: string
|
||||
real_ev: number
|
||||
tier: string
|
||||
remark: string
|
||||
weight: number
|
||||
}
|
||||
|
||||
// 表格配置(默认 100 条/页)
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'ID(索引)', width: 80 },
|
||||
{ prop: 'grid_number', label: '色子点数' },
|
||||
{ prop: 'ui_text', label: '前端显示文本' },
|
||||
{ prop: 'real_ev', label: '真实资金结算' },
|
||||
{ prop: 'tier', label: '所属档位', sortable: true },
|
||||
// { prop: 'create_time', label: '创建时间', sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
const activeTab = ref<'index' | 'bigwin'>('index')
|
||||
const loading = ref(false)
|
||||
const savingIndex = ref(false)
|
||||
const savingBigwin = ref(false)
|
||||
const createRewardLoading = ref(false)
|
||||
|
||||
// 编辑配置
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
/** 第一页数据(来自 api.list,即 DiceRewardConfig 表) */
|
||||
const indexRows = ref<IndexRow[]>([])
|
||||
/** 奖励索引 Tab:排除 tier=BIGWIN,仅显示 T1~T5 */
|
||||
const indexRowsExcludeBigwin = computed(() => indexRows.value.filter((r) => r.tier !== 'BIGWIN'))
|
||||
/** 第二页 BIGWIN 数据:来自同一张表 DiceRewardConfig,过滤 tier===BIGWIN */
|
||||
const bigwinRows = computed(() => indexRows.value.filter((r) => r.tier === 'BIGWIN'))
|
||||
/** 原始 list 快照,用于重置 */
|
||||
let indexRowsSnapshot: IndexRow[] = []
|
||||
|
||||
function toWeight(v: unknown): number {
|
||||
const n = typeof v === 'number' && !Number.isNaN(v) ? v : Number(v)
|
||||
if (Number.isNaN(n)) return 0
|
||||
return Math.max(0, Math.min(10000, Math.floor(n)))
|
||||
}
|
||||
|
||||
function normalizeIndexRow(raw: Record<string, unknown>): IndexRow {
|
||||
return {
|
||||
id: Number(raw.id) ?? 0,
|
||||
grid_number: Number(raw.grid_number) ?? 0,
|
||||
ui_text: String(raw.ui_text ?? ''),
|
||||
ui_text_en: String((raw as any).ui_text_en ?? ''),
|
||||
real_ev: Number(raw.real_ev) ?? 0,
|
||||
tier: String(raw.tier ?? ''),
|
||||
remark: String(raw.remark ?? ''),
|
||||
weight: toWeight((raw as any).weight)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreateRewardReference() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('page.configPage.confirmCreateRefMsg'),
|
||||
t('page.configPage.confirmCreateRefTitle'),
|
||||
{
|
||||
confirmButtonText: t('page.configPage.confirmCreateRefOk'),
|
||||
cancelButtonText: t('page.configPage.confirmCreateRefCancel'),
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
createRewardLoading.value = true
|
||||
try {
|
||||
const res: any = await api.createRewardReference()
|
||||
const data = res?.data ?? res
|
||||
let msg = t('page.configPage.createRefSuccessSimple')
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
const skipped = Number(data.skipped ?? 0)
|
||||
const skippedPart =
|
||||
skipped > 0 ? t('page.configPage.createRefSuccessSkipped', { n: skipped }) : ''
|
||||
msg = t('page.configPage.createRefSuccess', {
|
||||
cwNew: data.created_clockwise ?? 0,
|
||||
ccwNew: data.created_counterclockwise ?? 0,
|
||||
cwUp: data.updated_clockwise ?? 0,
|
||||
ccwUp: data.updated_counterclockwise ?? 0,
|
||||
skippedPart
|
||||
})
|
||||
}
|
||||
ElMessage.success(msg)
|
||||
loadIndexList()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.configPage.createRefFail'))
|
||||
} finally {
|
||||
createRewardLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function loadIndexList() {
|
||||
loading.value = true
|
||||
return api
|
||||
.list({ limit: 200 })
|
||||
.then((res: any) => {
|
||||
const list = res?.data?.records ?? res?.records ?? res?.data ?? []
|
||||
const rows = Array.isArray(list)
|
||||
? list.map((r: Record<string, unknown>) => normalizeIndexRow(r))
|
||||
: []
|
||||
indexRows.value = rows
|
||||
indexRowsSnapshot = rows.map((r) => ({ ...r }))
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(t('page.configPage.loadIndexFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function isBigwinWeightDisabled(row: IndexRow): boolean {
|
||||
return row.grid_number === 5 || row.grid_number === 30
|
||||
}
|
||||
|
||||
const GRID_NUMBER_MIN = 5
|
||||
const GRID_NUMBER_MAX = 30
|
||||
|
||||
/** 找出数组中出现多于一次的值 */
|
||||
function findDuplicateValues(arr: number[]): number[] {
|
||||
const count = new Map<number, number>()
|
||||
for (const v of arr) {
|
||||
count.set(v, (count.get(v) ?? 0) + 1)
|
||||
}
|
||||
const duplicates: number[] = []
|
||||
count.forEach((c, v) => {
|
||||
if (c > 1) duplicates.push(v)
|
||||
})
|
||||
return duplicates.sort((a, b) => a - b)
|
||||
}
|
||||
|
||||
/** 奖励索引表单校验:仅对本表内的行(不含 BIGWIN)校验,点数 5~30 且本批内不重复 */
|
||||
function validateIndexFormForSave(): string | null {
|
||||
const toSave = indexRows.value.filter((r) => r.tier !== 'BIGWIN')
|
||||
if (toSave.length === 0) {
|
||||
return t('page.configPage.warnNoIndexToSave')
|
||||
}
|
||||
const nums = toSave.map((r) => Number(r.grid_number))
|
||||
const outOfRange = nums.filter(
|
||||
(n) => Number.isNaN(n) || n < GRID_NUMBER_MIN || n > GRID_NUMBER_MAX
|
||||
)
|
||||
if (outOfRange.length > 0) {
|
||||
return t('page.configPage.warnGridRange', { min: GRID_NUMBER_MIN, max: GRID_NUMBER_MAX })
|
||||
}
|
||||
const duplicates = findDuplicateValues(nums)
|
||||
if (duplicates.length > 0) {
|
||||
return t('page.configPage.warnDupGrid', {
|
||||
list: duplicates.join(t('page.configPage.dupJoiner'))
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** 奖励索引表单:仅提交本表数据(T1~T5),不包含大奖权重 */
|
||||
async function handleSaveIndex() {
|
||||
const err = validateIndexFormForSave()
|
||||
if (err) {
|
||||
ElMessage.warning(err)
|
||||
return
|
||||
}
|
||||
const toSave = indexRows.value.filter((r) => r.tier !== 'BIGWIN')
|
||||
savingIndex.value = true
|
||||
try {
|
||||
const indexPayload = toSave.map((r) => ({
|
||||
id: r.id,
|
||||
grid_number: r.grid_number,
|
||||
ui_text: r.ui_text,
|
||||
ui_text_en: r.ui_text_en,
|
||||
real_ev: r.real_ev,
|
||||
tier: r.tier,
|
||||
remark: r.remark
|
||||
}))
|
||||
await api.batchUpdate(indexPayload)
|
||||
ElMessage.success(t('page.configPage.saveSuccess'))
|
||||
indexRowsSnapshot = indexRows.value.map((r) => ({ ...r }))
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.configPage.saveFail'))
|
||||
} finally {
|
||||
savingIndex.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 奖励索引页:重置为本页数据(重新拉取列表) */
|
||||
function handleResetIndex() {
|
||||
loadIndexList()
|
||||
ElMessage.info(t('page.configPage.resetIndexReloaded'))
|
||||
}
|
||||
|
||||
/** 大奖权重表单校验:点数在本表内不重复 */
|
||||
function validateBigwinFormForSave(): string | null {
|
||||
const rows = bigwinRows.value
|
||||
if (rows.length === 0) {
|
||||
return t('page.configPage.warnNoBigwinToSave')
|
||||
}
|
||||
const nums = rows.map((r) => Number(r.grid_number))
|
||||
const outOfRange = nums.filter(
|
||||
(n) => Number.isNaN(n) || n < GRID_NUMBER_MIN || n > GRID_NUMBER_MAX
|
||||
)
|
||||
if (outOfRange.length > 0) {
|
||||
return t('page.configPage.warnGridRange', { min: GRID_NUMBER_MIN, max: GRID_NUMBER_MAX })
|
||||
}
|
||||
const duplicates = findDuplicateValues(nums)
|
||||
if (duplicates.length > 0) {
|
||||
return t('page.configPage.warnBigwinDupGrid', {
|
||||
list: duplicates.join(t('page.configPage.dupJoiner'))
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** 大奖权重表单:提交 BIGWIN 的显示信息、英文、实际中奖、备注 + 权重(保存后后端会刷新缓存) */
|
||||
async function handleSaveBigwin() {
|
||||
const rows = bigwinRows.value
|
||||
if (rows.length === 0) {
|
||||
ElMessage.info(t('page.configPage.infoNoBigwin'))
|
||||
return
|
||||
}
|
||||
const err = validateBigwinFormForSave()
|
||||
if (err) {
|
||||
ElMessage.warning(err)
|
||||
return
|
||||
}
|
||||
savingBigwin.value = true
|
||||
try {
|
||||
const batchPayload = rows.map((r) => ({
|
||||
id: r.id,
|
||||
grid_number: r.grid_number,
|
||||
ui_text: r.ui_text,
|
||||
ui_text_en: r.ui_text_en,
|
||||
real_ev: r.real_ev,
|
||||
tier: r.tier,
|
||||
remark: r.remark
|
||||
}))
|
||||
await api.batchUpdate(batchPayload)
|
||||
const weightItems = rows.map((r) => ({
|
||||
grid_number: r.grid_number,
|
||||
weight: isBigwinWeightDisabled(r)
|
||||
? 10000
|
||||
: Math.max(0, Math.min(10000, Math.floor(r.weight)))
|
||||
}))
|
||||
await api.saveBigwinWeightsByGrid(weightItems)
|
||||
ElMessage.success(t('page.configPage.saveSuccess'))
|
||||
loadIndexList()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.configPage.saveFail'))
|
||||
} finally {
|
||||
savingBigwin.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 大奖权重页:重置(重新拉取列表,BIGWIN 数据随之更新) */
|
||||
function handleResetBigwin() {
|
||||
loadIndexList()
|
||||
ElMessage.info(t('page.configPage.resetBigwinReloaded'))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadIndexList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.reward-config-form {
|
||||
padding: 16px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
.form-card {
|
||||
margin-bottom: 16px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
:deep(.el-card__body) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.top-tabs {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
:deep(.el-tabs__header) {
|
||||
margin-bottom: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
:deep(.el-tabs__content) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
:deep(.el-tab-pane) {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.tab-panel {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
.table-scroll-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.tab-footer {
|
||||
flex-shrink: 0;
|
||||
margin-top: 12px;
|
||||
padding: 12px 0;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
.panel-tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.config-table {
|
||||
width: 100%;
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.weight-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 8px;
|
||||
.el-slider {
|
||||
flex: 1;
|
||||
}
|
||||
.weight-input {
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
.weight-tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.readonly-value {
|
||||
font-weight: 500;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.bigwin-table .full-width {
|
||||
width: 100%;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,50 +1,75 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增奖励配置' : '编辑奖励配置'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="色子点数" prop="grid_number">
|
||||
<el-input-number v-model="formData.grid_number" placeholder="请输入色子点数" />
|
||||
<el-form-item :label="$t('page.form.labelDicePoints')" prop="grid_number">
|
||||
<el-input-number
|
||||
v-model="formData.grid_number"
|
||||
:placeholder="$t('page.form.placeholderDicePoints')"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="前端显示文本" prop="ui_text">
|
||||
<el-input v-model="formData.ui_text" placeholder="请输入前端显示文本" />
|
||||
<el-form-item :label="$t('page.form.labelUiText')" prop="ui_text">
|
||||
<el-input v-model="formData.ui_text" :placeholder="$t('page.form.placeholderUiText')"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="真实资金结算" prop="real_ev">
|
||||
<el-input-number v-model="formData.real_ev" placeholder="请输入真实资金结算" />
|
||||
<el-form-item :label="$t('page.form.labelUiTextEn')" prop="ui_text_en">
|
||||
<el-input v-model="formData.ui_text_en" :placeholder="$t('page.form.placeholderUiTextEn')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属档位" prop="tier">
|
||||
<el-form-item :label="$t('page.form.labelRealEv')" prop="real_ev">
|
||||
<el-input-number v-model="formData.real_ev" :placeholder="$t('page.form.placeholderRealEv')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelTier')" prop="tier">
|
||||
<el-select
|
||||
v-model="formData.tier"
|
||||
placeholder="请选择所属档位"
|
||||
:placeholder="$t('page.form.placeholderTier')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option :label="$t('page.form.tierBigWin')" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<!-- BIGWIN 时可编辑权重:10000=100% 中奖,0=0% 中奖;点数 5、30 固定 100% 不可改 -->
|
||||
<el-form-item v-if="formData.tier === 'BIGWIN'" :label="$t('page.form.labelBigWinWeight')" prop="weight">
|
||||
<el-input-number
|
||||
v-model="formData.weight"
|
||||
:min="0"
|
||||
:max="10000"
|
||||
:step="100"
|
||||
:placeholder="$t('page.form.placeholderBigWinWeight')"
|
||||
:disabled="isBigwinWeightDisabled"
|
||||
/>
|
||||
<div v-if="isBigwinWeightDisabled" class="form-tip">
|
||||
{{ $t('page.form.bigWinWeightDisabledTip') }}
|
||||
</div>
|
||||
<div v-else class="form-tip">{{ $t('page.form.bigWinWeightTip') }}</div>
|
||||
</el-form-item>
|
||||
<!-- 权重已迁移至「T1-T5 与 BIGWIN 权重配比」弹窗(dice_reward 表);BIGWIN 时本弹窗可编辑 weight;起始索引已迁移至 dice_reward.start_index -->
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -53,6 +78,7 @@
|
||||
import api from '../../../api/reward_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -72,6 +98,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -84,14 +111,23 @@
|
||||
})
|
||||
|
||||
/**
|
||||
* 表单验证规则
|
||||
* 表单验证规则(权重已迁移至权重配比弹窗)
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
grid_number: [{ required: true, message: '色子点数必需填写', trigger: 'blur' }],
|
||||
ui_text: [{ required: true, message: '前端显示文本必需填写', trigger: 'blur' }],
|
||||
real_ev: [{ required: true, message: '真实资金结算必需填写', trigger: 'blur' }],
|
||||
tier: [{ required: true, message: '所属档位必需填写', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
grid_number: [{ required: true, message: t('page.form.ruleDicePointsRequired'), trigger: 'blur' }],
|
||||
ui_text: [{ required: true, message: t('page.form.ruleUiTextRequired'), trigger: 'blur' }],
|
||||
ui_text_en: [{ max: 255, message: t('page.form.ruleUiTextEnMax'), trigger: 'blur' }],
|
||||
real_ev: [{ required: true, message: t('page.form.ruleRealEvRequired'), trigger: 'blur' }],
|
||||
tier: [{ required: true, message: t('page.form.ruleTierRequired'), trigger: 'blur' }],
|
||||
weight: [
|
||||
{ type: 'number', min: 0, max: 10000, message: t('page.form.ruleBigWinWeightRange'), trigger: 'blur' }
|
||||
]
|
||||
}))
|
||||
|
||||
/** 点数 5、30 固定 100% 中大奖,权重不可改 */
|
||||
const isBigwinWeightDisabled = computed(
|
||||
() => formData.tier === 'BIGWIN' && [5, 30].includes(Number(formData.grid_number))
|
||||
)
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -100,9 +136,11 @@
|
||||
id: null,
|
||||
grid_number: null,
|
||||
ui_text: '',
|
||||
ui_text_en: '',
|
||||
real_ev: '',
|
||||
tier: '',
|
||||
remark: ''
|
||||
remark: '',
|
||||
weight: 10000 as number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,16 +174,32 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化表单数据
|
||||
* 初始化表单数据(数值字段转为 number,便于滑块/输入框正确回显)
|
||||
*/
|
||||
const initForm = () => {
|
||||
if (props.data) {
|
||||
for (const key in formData) {
|
||||
if (props.data[key] != null && props.data[key] != undefined) {
|
||||
;(formData as any)[key] = props.data[key]
|
||||
}
|
||||
if (!props.data) return
|
||||
const numKeys = ['id', 'grid_number', 'real_ev', 'weight']
|
||||
for (const key of Object.keys(formData)) {
|
||||
if (!(key in props.data)) continue
|
||||
const val = props.data[key]
|
||||
if (val == null || val === undefined) continue
|
||||
if (numKeys.includes(key)) {
|
||||
const numVal = Number(val)
|
||||
;(formData as Record<string, unknown>)[key] =
|
||||
key === 'id'
|
||||
? numVal || null
|
||||
: Number.isNaN(numVal)
|
||||
? key === 'weight'
|
||||
? 10000
|
||||
: 0
|
||||
: numVal
|
||||
} else {
|
||||
;(formData as Record<string, unknown>)[key] = val ?? ''
|
||||
}
|
||||
}
|
||||
if (formData.tier === 'BIGWIN' && (formData.weight === undefined || formData.weight === null)) {
|
||||
formData.weight = [5, 30].includes(Number(formData.grid_number)) ? 10000 : 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,12 +217,19 @@
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
const payload = { ...formData } as Record<string, unknown>
|
||||
if (formData.tier === 'BIGWIN') {
|
||||
const w = Number(formData.weight)
|
||||
payload.weight = isBigwinWeightDisabled.value ? 10000 : Number.isNaN(w) ? 10000 : w
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
delete payload.weight
|
||||
}
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(payload)
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
@@ -177,3 +238,11 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="色子点数" prop="grid_number_min">
|
||||
<el-form-item :label="$t('page.search.dicePoints')" prop="grid_number_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.grid_number_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.grid_number_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -28,24 +28,24 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="前端显示文本" prop="ui_text">
|
||||
<el-input v-model="formData.ui_text" placeholder="模糊查询" clearable />
|
||||
<el-form-item :label="$t('page.search.displayText')" prop="ui_text">
|
||||
<el-input v-model="formData.ui_text" :placeholder="$t('page.search.fuzzyQuery')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="真实资金结算" prop="real_ev_min">
|
||||
<el-form-item :label="$t('page.search.realEv')" prop="real_ev_min">
|
||||
<div class="range-wrap">
|
||||
<el-input-number
|
||||
v-model="formData.real_ev_min"
|
||||
placeholder="最小"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
<span class="range-sep">至</span>
|
||||
<span class="range-sep">{{ $t('table.searchBar.rangeSeparator') }}</span>
|
||||
<el-input-number
|
||||
v-model="formData.real_ev_max"
|
||||
placeholder="最大"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
@@ -54,8 +54,8 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="所属档位" prop="tier">
|
||||
<el-select v-model="formData.tier" placeholder="全部" clearable style="width: 100%">
|
||||
<el-form-item :label="$t('page.search.tier')" prop="tier">
|
||||
<el-select v-model="formData.tier" :placeholder="$t('table.searchBar.all')" clearable style="width: 100%">
|
||||
<el-option label="T1" value="T1" />
|
||||
<el-option label="T2" value="T2" />
|
||||
<el-option label="T3" value="T3" />
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="$t('page.weightRatio.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
{{ $t('page.weightRatio.globalTip') }}
|
||||
</div>
|
||||
<el-tabs v-model="activeTier" type="card">
|
||||
<el-tab-pane v-for="t in tierKeys" :key="t" :label="t" :name="t">
|
||||
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightRatio.emptyTier') }}</div>
|
||||
<template v-else>
|
||||
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
|
||||
<div class="chart-row">
|
||||
<ArtBarChart
|
||||
:x-axis-name="$t('page.weightRatio.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'clockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
<ArtBarChart
|
||||
:x-axis-name="$t('page.weightRatio.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'counterclockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
{{
|
||||
$t('page.weightRatio.sumLine', {
|
||||
cw: getTierSumForValidation(t, 'clockwise'),
|
||||
ccw: getTierSumForValidation(t, 'counterclockwise')
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>
|
||||
{{ $t('page.weightRatio.t4t5Note') }}
|
||||
</div>
|
||||
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
|
||||
<el-table-column
|
||||
:label="$t('page.weightRatio.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column :label="$t('page.weightRatio.colDicePoints')" prop="grid_number" width="80" align="center" />
|
||||
<el-table-column
|
||||
:label="$t('page.weightRatio.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('page.weightRatio.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column :label="$t('page.table.remark')" prop="remark" min-width="70" align="center" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('page.weightRatio.colWeightCw')" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeight(row, 'clockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="(v: number | number[]) => setItemWeightByRow(t, row, 'clockwise', Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1))"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="isWeightDisabled(row, t) || getItemWeight(row, 'clockwise') <= 1"
|
||||
@click="setItemWeightByRow(t, row, 'clockwise', Math.max(1, getItemWeight(row, 'clockwise') - 1))"
|
||||
>-</el-button>
|
||||
<el-input-number
|
||||
:model-value="getItemWeight(row, 'clockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="(v: number | string | undefined) => setItemWeightByRow(t, row, 'clockwise', typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1)"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="isWeightDisabled(row, t) || getItemWeight(row, 'clockwise') >= 10000"
|
||||
@click="setItemWeightByRow(t, row, 'clockwise', Math.min(10000, getItemWeight(row, 'clockwise') + 1))"
|
||||
>+</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('page.weightRatio.colWeightCcw')" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell-vertical">
|
||||
<div class="weight-slider-wrap">
|
||||
<el-slider
|
||||
:model-value="getItemWeight(row, 'counterclockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
size="small"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
class="weight-slider"
|
||||
@update:model-value="(v: number | number[]) => setItemWeightByRow(t, row, 'counterclockwise', Array.isArray(v) ? (v[0] ?? 1) : (v ?? 1))"
|
||||
/>
|
||||
</div>
|
||||
<div class="weight-input-wrap">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="isWeightDisabled(row, t) || getItemWeight(row, 'counterclockwise') <= 1"
|
||||
@click="setItemWeightByRow(t, row, 'counterclockwise', Math.max(1, getItemWeight(row, 'counterclockwise') - 1))"
|
||||
>-</el-button>
|
||||
<el-input-number
|
||||
:model-value="getItemWeight(row, 'counterclockwise')"
|
||||
:min="1"
|
||||
:max="10000"
|
||||
:step="1"
|
||||
:disabled="isWeightDisabled(row, t)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
class="weight-input"
|
||||
@update:model-value="(v: number | string | undefined) => setItemWeightByRow(t, row, 'counterclockwise', typeof v === 'number' && !Number.isNaN(v) ? v : Number(v) || 1)"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="isWeightDisabled(row, t) || getItemWeight(row, 'counterclockwise') >= 10000"
|
||||
@click="setItemWeightByRow(t, row, 'counterclockwise', Math.min(10000, getItemWeight(row, 'counterclockwise') + 1))"
|
||||
>+</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button
|
||||
v-permission="'dice:reward_config:index:batchUpdateWeights'"
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
@click="handleSubmit"
|
||||
>{{ $t('table.form.submit') }}</el-button
|
||||
>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward_config/index'
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
type DirectionKey = 'clockwise' | 'counterclockwise'
|
||||
|
||||
interface WeightRow {
|
||||
reward_id_clockwise?: number
|
||||
reward_id_counterclockwise?: number
|
||||
id?: number
|
||||
grid_number?: number
|
||||
real_ev?: number
|
||||
ui_text?: string
|
||||
remark?: string
|
||||
tier?: string
|
||||
weight_clockwise: number
|
||||
weight_counterclockwise: number
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const tierKeys = TIER_KEYS
|
||||
const activeTier = ref('T1')
|
||||
const submitting = ref(false)
|
||||
|
||||
const grouped = ref<Record<string, WeightRow[]>>({
|
||||
T1: [],
|
||||
T2: [],
|
||||
T3: [],
|
||||
T4: [],
|
||||
T5: []
|
||||
})
|
||||
|
||||
function getTierItems(tier: string): WeightRow[] {
|
||||
return grouped.value[tier] ?? []
|
||||
}
|
||||
|
||||
function getTierChartLabels(tier: string): string[] {
|
||||
return getTierItems(tier).map((r) => String(r.grid_number ?? ''))
|
||||
}
|
||||
|
||||
function getTierChartData(tier: string, dir: DirectionKey): number[] {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
return getTierItems(tier).map((r) => toWeightPrecision(r[key] ?? 1))
|
||||
}
|
||||
|
||||
function getTierSumForValidation(tier: string, dir: DirectionKey): number {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
return getTierItems(tier).reduce((s, r) => s + toWeightPrecision(r[key] ?? 1), 0)
|
||||
}
|
||||
|
||||
function getItemWeight(row: WeightRow, dir: DirectionKey): number {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
const w = row[key]
|
||||
const num = typeof w === 'number' && !Number.isNaN(w) ? w : Number(w)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return toWeightPrecision(num)
|
||||
}
|
||||
|
||||
function toWeightPrecision(value: number): number {
|
||||
const n = Math.max(1, Math.min(10000, Math.floor(value)))
|
||||
return n
|
||||
}
|
||||
|
||||
function setItemWeightByRow(tier: string, row: WeightRow, dir: DirectionKey, value: number) {
|
||||
const v = toWeightPrecision(value)
|
||||
const list = grouped.value[tier]
|
||||
if (!list) return
|
||||
const rid = dir === 'clockwise' ? row.reward_id_clockwise : row.reward_id_counterclockwise
|
||||
const idx = list.findIndex(
|
||||
(r) =>
|
||||
r === row ||
|
||||
(rid != null && (dir === 'clockwise' ? r.reward_id_clockwise : r.reward_id_counterclockwise) === rid)
|
||||
)
|
||||
if (idx >= 0) {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
list[idx][key] = v
|
||||
} else {
|
||||
const key = dir === 'clockwise' ? 'weight_clockwise' : 'weight_counterclockwise'
|
||||
row[key] = v
|
||||
}
|
||||
}
|
||||
|
||||
function isWeightDisabled(row: WeightRow, tier: string): boolean {
|
||||
if (tier === 'T4' || tier === 'T5') return true
|
||||
return false
|
||||
}
|
||||
|
||||
/** 解析 tier -> { 0: [], 1: [] },按 grid_number 合并为每档位一行,含 reward_id 与双方向权重 */
|
||||
function parseWeightRatioPayload(res: any): Record<string, WeightRow[]> {
|
||||
const empty: Record<string, WeightRow[]> = {
|
||||
T1: [],
|
||||
T2: [],
|
||||
T3: [],
|
||||
T4: [],
|
||||
T5: []
|
||||
}
|
||||
if (!res || typeof res !== 'object') return empty
|
||||
const raw = res?.data ?? res
|
||||
if (!raw || typeof raw !== 'object') return empty
|
||||
const out = { ...empty }
|
||||
for (const t of TIER_KEYS) {
|
||||
const tierData = raw[t]
|
||||
if (!tierData || typeof tierData !== 'object') continue
|
||||
const list0 = Array.isArray(tierData[0]) ? tierData[0] : []
|
||||
const list1 = Array.isArray(tierData[1]) ? tierData[1] : []
|
||||
const byGrid = new Map<
|
||||
number,
|
||||
{
|
||||
reward_id_clockwise?: number
|
||||
reward_id_counterclockwise?: number
|
||||
id?: number
|
||||
grid_number?: number
|
||||
real_ev?: number
|
||||
ui_text?: string
|
||||
remark?: string
|
||||
weight_clockwise: number
|
||||
weight_counterclockwise: number
|
||||
}
|
||||
>()
|
||||
for (const r of list0) {
|
||||
const gn = r.grid_number != null ? Number(r.grid_number) : NaN
|
||||
if (!Number.isNaN(gn)) {
|
||||
byGrid.set(gn, {
|
||||
reward_id_clockwise: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
id: r.id != null ? Number(r.id) : undefined,
|
||||
grid_number: gn,
|
||||
real_ev: r.real_ev != null ? Number(r.real_ev) : undefined,
|
||||
ui_text: r.ui_text,
|
||||
remark: r.remark,
|
||||
weight_clockwise: normalizeWeightValue(r.weight),
|
||||
weight_counterclockwise: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
for (const r of list1) {
|
||||
const gn = r.grid_number != null ? Number(r.grid_number) : NaN
|
||||
if (!Number.isNaN(gn)) {
|
||||
const cur = byGrid.get(gn)
|
||||
if (cur) {
|
||||
cur.reward_id_counterclockwise = r.reward_id != null ? Number(r.reward_id) : undefined
|
||||
cur.weight_counterclockwise = normalizeWeightValue(r.weight)
|
||||
} else {
|
||||
byGrid.set(gn, {
|
||||
reward_id_counterclockwise: r.reward_id != null ? Number(r.reward_id) : undefined,
|
||||
id: r.id != null ? Number(r.id) : undefined,
|
||||
grid_number: gn,
|
||||
real_ev: r.real_ev != null ? Number(r.real_ev) : undefined,
|
||||
ui_text: r.ui_text,
|
||||
remark: r.remark,
|
||||
weight_clockwise: 1,
|
||||
weight_counterclockwise: normalizeWeightValue(r.weight)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
out[t] = Array.from(byGrid.values())
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function normalizeWeightValue(v: unknown): number {
|
||||
const num = typeof v === 'number' && !Number.isNaN(v) ? v : Number(v)
|
||||
if (Number.isNaN(num)) return 1
|
||||
return Math.max(1, Math.min(10000, Math.floor(num)))
|
||||
}
|
||||
|
||||
function loadData() {
|
||||
api
|
||||
.weightRatioList()
|
||||
.then((res: any) => {
|
||||
grouped.value = parseWeightRatioPayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(t('page.weightRatio.fetchFail'))
|
||||
})
|
||||
}
|
||||
|
||||
/** 按 DiceReward 主键 id 收集:每条记录一条 { id, weight } */
|
||||
function collectItems(): Array<{ id: number; weight: number }> {
|
||||
const items: Array<{ id: number; weight: number }> = []
|
||||
for (const t of TIER_KEYS) {
|
||||
for (const row of getTierItems(t)) {
|
||||
const w0 = isWeightDisabled(row, t) ? 10000 : getItemWeight(row, 'clockwise')
|
||||
const w1 = isWeightDisabled(row, t) ? 10000 : getItemWeight(row, 'counterclockwise')
|
||||
const rid0 = row.reward_id_clockwise != null ? row.reward_id_clockwise : 0
|
||||
const rid1 = row.reward_id_counterclockwise != null ? row.reward_id_counterclockwise : 0
|
||||
if (rid0 > 0) items.push({ id: rid0, weight: w0 })
|
||||
if (rid1 > 0) items.push({ id: rid1, weight: w1 })
|
||||
}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info(t('page.weightRatio.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success(t('page.weightRatio.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? t('page.weightRatio.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (open) {
|
||||
loadData()
|
||||
activeTier.value = 'T1'
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chart-wrap {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.chart-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
> * {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
}
|
||||
.weight-sum {
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.weight-sum-t4t5 {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.global-tip {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.weight-table {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.weight-cell-vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.weight-slider-wrap {
|
||||
width: 100%;
|
||||
min-width: 80px;
|
||||
padding: 0 8px;
|
||||
.weight-slider {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.weight-input-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,240 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<!-- 搜索面板 -->
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config_record:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<!-- 状态:-1失败 0测试中 1完成 -->
|
||||
<template #status="{ row }">
|
||||
<span>{{ formatStatus(row.status) }}</span>
|
||||
</template>
|
||||
<!-- 付费抽取:顺时针、逆时针抽取次数(兼容旧数据用 s_count/n_count) -->
|
||||
<template #paid_draw="{ row }">
|
||||
<span
|
||||
>{{ $t('page.table.clockwiseAbbr') }} {{ getPaidS(row) }} /
|
||||
{{ $t('page.table.counterclockwiseAbbr') }} {{ getPaidN(row) }}</span
|
||||
>
|
||||
</template>
|
||||
<!-- 免费抽取:顺时针、逆时针抽取次数 -->
|
||||
<template #free_draw="{ row }">
|
||||
<span
|
||||
>{{ $t('page.table.clockwiseAbbr') }} {{ row.free_s_count ?? 0 }} /
|
||||
{{ $t('page.table.counterclockwiseAbbr') }} {{ row.free_n_count ?? 0 }}</span
|
||||
>
|
||||
</template>
|
||||
<!-- 平台赚取金额 -->
|
||||
<template #platform_profit="{ row }">
|
||||
<span>{{ formatPlatformProfit(row.platform_profit) }}</span>
|
||||
</template>
|
||||
<!-- 操作列 -->
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:reward_config_record:index:read'"
|
||||
type="success"
|
||||
:toolTip="$t('page.toolbar.viewDetail')"
|
||||
@click="openDetail(row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:reward_config_record:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
<!-- 详情抽屉:导入成功后刷新列表 -->
|
||||
<DetailDrawer v-model="detailVisible" :record="detailRecord" @import-done="refreshData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/reward_config_record/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
import DetailDrawer from './modules/detail-drawer.vue'
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({})
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
// 详情抽屉:打开时拉取完整记录(含 paid_tier_weights、free_tier_weights 等)
|
||||
const detailVisible = ref(false)
|
||||
const detailRecord = ref<Record<string, any> | null>(null)
|
||||
async function openDetail(row: Record<string, any>) {
|
||||
const id = row?.id
|
||||
if (id == null) return
|
||||
detailRecord.value = { ...row }
|
||||
detailVisible.value = true
|
||||
try {
|
||||
const res = await api.read(id)
|
||||
const data = res?.data ?? res
|
||||
if (data && typeof data === 'object') {
|
||||
detailRecord.value = data
|
||||
}
|
||||
} catch {
|
||||
// 读取失败时保留列表行数据
|
||||
}
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
// 状态文案:-1失败 0测试中 1完成(2=执行中也显示测试中)
|
||||
function formatStatus(status: unknown): string {
|
||||
const s = Number(status)
|
||||
if (s === -1) return t('page.table.statusFail')
|
||||
if (s === 1) return t('page.table.statusDone')
|
||||
if (s === 0 || s === 2) return t('page.table.statusTesting')
|
||||
return t('page.detail.dash')
|
||||
}
|
||||
|
||||
// 付费抽取次数(兼容旧数据:无 paid_s_count 时用 s_count)
|
||||
function getPaidS(row: Record<string, any>): number {
|
||||
const v = row.paid_s_count
|
||||
if (v !== undefined && v !== null && (Number(v) || 0) > 0) return Number(v)
|
||||
return Number(row.s_count ?? 0)
|
||||
}
|
||||
function getPaidN(row: Record<string, any>): number {
|
||||
const v = row.paid_n_count
|
||||
if (v !== undefined && v !== null && (Number(v) || 0) > 0) return Number(v)
|
||||
return Number(row.n_count ?? 0)
|
||||
}
|
||||
|
||||
// 平台赚取金额展示(未完成或空显示 —)
|
||||
function formatPlatformProfit(v: unknown): string {
|
||||
const dash = t('page.detail.dash')
|
||||
if (v === null || v === undefined || v === '') return dash
|
||||
const n = Number(v)
|
||||
if (Number.isNaN(n)) return dash
|
||||
return String(n)
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||
{
|
||||
prop: 'status',
|
||||
label: 'page.table.status',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'paid_draw',
|
||||
label: 'page.table.paidDraw',
|
||||
width: 160,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'free_draw',
|
||||
label: 'page.table.freeDraw',
|
||||
width: 160,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'platform_profit',
|
||||
label: 'page.table.platformProfit',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{ prop: 'total_play_count', label: 'page.table.totalDrawCount', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'admin_name',
|
||||
label: 'page.table.createdBy',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 编辑配置
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
@@ -0,0 +1,551 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
:title="$t('page.detail.title')"
|
||||
:size="drawerSize"
|
||||
direction="rtl"
|
||||
destroy-on-close
|
||||
@close="handleClose"
|
||||
>
|
||||
<template v-if="record">
|
||||
<div class="detail-section">
|
||||
<div class="section-title">{{ $t('page.detail.sectionBasic') }}</div>
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item :label="$t('page.detail.recordId')">
|
||||
{{ record.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('page.detail.testCount')"
|
||||
>{{ record.test_count }}{{ $t('page.detail.testCountSuffix') }}</el-descriptions-item
|
||||
>
|
||||
<el-descriptions-item :label="$t('page.detail.createTime')">
|
||||
{{ record.create_time || $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('page.detail.admin')">
|
||||
{{ record.admin_name ?? record.admin_id ?? $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('page.detail.paidPoolId')">
|
||||
{{ record.paid_lottery_config_id ?? record.lottery_config_id ?? $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('page.detail.freePoolId')">
|
||||
{{ record.free_lottery_config_id ?? $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('page.detail.bigwinSnapshot')">
|
||||
<template v-if="bigwinWeightDisplay.length">
|
||||
<span v-for="item in bigwinWeightDisplay" :key="item.grid" class="mr-2">
|
||||
{{ item.grid }}:{{ item.weight }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>{{ $t('page.detail.dash') }}</template>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">{{ $t('page.detail.sectionPaidTier') }}</div>
|
||||
<el-table
|
||||
v-if="paidTierTableData.length"
|
||||
:data="paidTierTableData"
|
||||
border
|
||||
size="small"
|
||||
class="tier-weights-table"
|
||||
max-height="160"
|
||||
>
|
||||
<el-table-column prop="tier" :label="$t('page.detail.colTier')" width="80" align="center" />
|
||||
<el-table-column prop="weight" :label="$t('page.detail.colWeight')" width="100" align="center" />
|
||||
<el-table-column prop="percent" :label="$t('page.detail.colPercent')" width="100" align="center" />
|
||||
</el-table>
|
||||
<div v-else class="empty-tip">
|
||||
{{ $t('page.detail.emptyPaidTier') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">{{ $t('page.detail.sectionFreeTier') }}</div>
|
||||
<el-table
|
||||
v-if="freeTierTableData.length"
|
||||
:data="freeTierTableData"
|
||||
border
|
||||
size="small"
|
||||
class="tier-weights-table"
|
||||
max-height="160"
|
||||
>
|
||||
<el-table-column prop="tier" :label="$t('page.detail.colTier')" width="80" align="center" />
|
||||
<el-table-column prop="weight" :label="$t('page.detail.colWeight')" width="100" align="center" />
|
||||
<el-table-column prop="percent" :label="$t('page.detail.colPercent')" width="100" align="center" />
|
||||
</el-table>
|
||||
<div v-else class="empty-tip">{{ $t('page.detail.emptyFreeTier') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">{{ $t('page.detail.sectionSnapshot') }}</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subCw') }}</div>
|
||||
<el-table
|
||||
:data="snapshotClockwise"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" :label="$t('page.detail.colTier')" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" :label="$t('page.detail.colGridNumber')" width="100" align="center" />
|
||||
<el-table-column prop="weight" :label="$t('page.detail.colWeight')" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!snapshotClockwise.length" class="empty-tip">{{ $t('page.detail.emptyCw') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subCcw') }}</div>
|
||||
<el-table
|
||||
:data="snapshotCounterclockwise"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" :label="$t('page.detail.colTier')" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" :label="$t('page.detail.colGridNumber')" width="100" align="center" />
|
||||
<el-table-column prop="weight" :label="$t('page.detail.colWeight')" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!snapshotCounterclockwise.length" class="empty-tip">{{ $t('page.detail.emptyCcw') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subBigwin') }}</div>
|
||||
<el-table
|
||||
:data="bigwinTableData"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="grid_number" :label="$t('page.detail.colGridNumber')" width="100" align="center" />
|
||||
<el-table-column prop="weight" :label="$t('page.detail.colWeight')" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!bigwinTableData.length" class="empty-tip">{{ $t('page.detail.emptyBigwinTable') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">{{ $t('page.detail.sectionResult') }}</div>
|
||||
<div class="chart-wrap">
|
||||
<ArtBarChart
|
||||
:x-axis-name="$t('page.detail.chartXAxis')"
|
||||
:x-axis-data="chartLabels"
|
||||
:data="chartData"
|
||||
height="280px"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="resultTotal === 0" class="empty-tip">{{ $t('page.detail.emptyResult') }}</div>
|
||||
<div v-else class="result-summary">{{ $t('page.detail.resultTotal', { n: resultTotal }) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section footer-actions">
|
||||
<el-button
|
||||
v-permission="'dice:reward_config_record:index:importFromRecord'"
|
||||
type="primary"
|
||||
:loading="importing"
|
||||
@click="openImport"
|
||||
>
|
||||
{{ $t('page.detail.btnImport') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<el-dialog
|
||||
v-model="importVisible"
|
||||
:title="$t('page.detail.importTitle')"
|
||||
width="520px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="import-desc">
|
||||
{{ $t('page.detail.importDesc') }}
|
||||
</p>
|
||||
<el-form label-width="160px">
|
||||
<el-form-item :label="$t('page.detail.importPaidLabel')">
|
||||
<el-select
|
||||
v-model="importPaidLotteryConfigId"
|
||||
:placeholder="$t('page.detail.importPaidPlaceholder')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in paidLotteryOptions"
|
||||
:key="opt.id"
|
||||
:label="opt.name"
|
||||
:value="opt.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">{{ $t('page.detail.importPaidTip') }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.detail.importFreeLabel')">
|
||||
<el-select
|
||||
v-model="importFreeLotteryConfigId"
|
||||
:placeholder="$t('page.detail.importFreePlaceholder')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in freeLotteryOptions"
|
||||
:key="opt.id"
|
||||
:label="opt.name"
|
||||
:value="opt.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">{{ $t('page.detail.importFreeTip') }}</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="importVisible = false">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button
|
||||
v-permission="'dice:reward_config_record:index:importFromRecord'"
|
||||
type="primary"
|
||||
:loading="importing"
|
||||
@click="confirmImport"
|
||||
>{{ $t('page.detail.btnConfirmImport') }}</el-button
|
||||
>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import recordApi from '../../../api/reward_config_record/index'
|
||||
import lotteryConfigApi from '../../../api/lottery_pool_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const GRID_NUMBERS = [
|
||||
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
30
|
||||
]
|
||||
|
||||
interface RecordRow {
|
||||
id?: number
|
||||
test_count?: number
|
||||
create_time?: string
|
||||
admin_id?: number | null
|
||||
admin_name?: string
|
||||
lottery_config_id?: number | null
|
||||
paid_lottery_config_id?: number | null
|
||||
free_lottery_config_id?: number | null
|
||||
bigwin_weight?: Record<string, number> | Array<[number, number]> | null
|
||||
// 新结构:{ paid: {T1..T5}, free: {T1..T5} },兼容旧结构直接是 {T1..T5}
|
||||
tier_weights_snapshot?:
|
||||
| {
|
||||
paid?: Record<string, number>
|
||||
free?: Record<string, number>
|
||||
[key: string]: any
|
||||
}
|
||||
| Record<string, number>
|
||||
paid_tier_weights?: Record<string, number>
|
||||
free_tier_weights?: Record<string, number>
|
||||
weight_config_snapshot?: Array<{
|
||||
id?: number
|
||||
grid_number?: number
|
||||
tier?: string
|
||||
weight?: number
|
||||
}>
|
||||
result_counts?: Record<string, number>
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
record: RecordRow | null
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'import-done'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false,
|
||||
record: null
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const drawerSize = ref('720px')
|
||||
|
||||
const importVisible = ref(false)
|
||||
const importing = ref(false)
|
||||
const importPaidLotteryConfigId = ref<number | null>(null)
|
||||
const importFreeLotteryConfigId = ref<number | null>(null)
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
function tierWeightsToTableData(weightsMap: Record<string, number> | null | undefined) {
|
||||
const dash = t('page.detail.dash')
|
||||
if (!weightsMap || typeof weightsMap !== 'object') return []
|
||||
const tiers = ['T1', 'T2', 'T3', 'T4', 'T5']
|
||||
const rows = tiers.map((tier) => {
|
||||
const w = weightsMap[tier] ?? weightsMap[tier.toLowerCase()] ?? 0
|
||||
return { tier, weight: w }
|
||||
})
|
||||
const total = rows.reduce((sum, r) => sum + r.weight, 0)
|
||||
return rows.map((r) => ({
|
||||
tier: r.tier,
|
||||
weight: r.weight,
|
||||
percent: total > 0 ? `${((r.weight / total) * 100).toFixed(1)}%` : dash
|
||||
}))
|
||||
}
|
||||
|
||||
const paidTierTableData = computed(() => {
|
||||
locale.value
|
||||
const r = props.record
|
||||
const paidFromRecord = r?.paid_tier_weights
|
||||
const snapshot = r?.tier_weights_snapshot
|
||||
let snapshotPaid: Record<string, number> | null = null
|
||||
if (snapshot && typeof snapshot === 'object') {
|
||||
if ('paid' in snapshot || 'free' in snapshot) {
|
||||
const s: any = snapshot
|
||||
if (s.paid && typeof s.paid === 'object') {
|
||||
snapshotPaid = s.paid
|
||||
}
|
||||
} else {
|
||||
// 兼容旧结构:直接是 T1-T5
|
||||
snapshotPaid = snapshot as Record<string, number>
|
||||
}
|
||||
}
|
||||
const source =
|
||||
paidFromRecord && Object.keys(paidFromRecord).length ? paidFromRecord : snapshotPaid
|
||||
return tierWeightsToTableData(source || undefined)
|
||||
})
|
||||
|
||||
const freeTierTableData = computed(() => {
|
||||
locale.value
|
||||
const r = props.record
|
||||
const freeFromRecord = r?.free_tier_weights
|
||||
const snapshot = r?.tier_weights_snapshot
|
||||
let snapshotFree: Record<string, number> | null = null
|
||||
if (snapshot && typeof snapshot === 'object') {
|
||||
if ('paid' in snapshot || 'free' in snapshot) {
|
||||
const s: any = snapshot
|
||||
if (s.free && typeof s.free === 'object') {
|
||||
snapshotFree = s.free
|
||||
}
|
||||
}
|
||||
}
|
||||
const source =
|
||||
freeFromRecord && Object.keys(freeFromRecord).length ? freeFromRecord : snapshotFree
|
||||
return tierWeightsToTableData(source || undefined)
|
||||
})
|
||||
|
||||
const bigwinWeightDisplay = computed(() => {
|
||||
const raw = props.record?.bigwin_weight
|
||||
if (!raw) return []
|
||||
const entries: Array<{ grid: number; weight: number }> = []
|
||||
if (Array.isArray(raw)) {
|
||||
raw.forEach(([grid, weight]) => {
|
||||
entries.push({ grid: Number(grid), weight: Number(weight) })
|
||||
})
|
||||
} else if (typeof raw === 'object') {
|
||||
Object.keys(raw).forEach((k) => {
|
||||
const grid = Number(k)
|
||||
const w = Number((raw as Record<string, number>)[k])
|
||||
if (!Number.isNaN(grid) && !Number.isNaN(w)) {
|
||||
entries.push({ grid, weight: w })
|
||||
}
|
||||
})
|
||||
}
|
||||
return entries.sort((a, b) => a.grid - b.grid)
|
||||
})
|
||||
|
||||
// 导入不限制奖池类型,两个下拉都可选任意 DiceLotteryPoolConfig
|
||||
const paidLotteryOptions = computed(() => lotteryConfigOptions.value)
|
||||
const freeLotteryOptions = computed(() => lotteryConfigOptions.value)
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
const snapshotTableData = computed(() => {
|
||||
locale.value
|
||||
const dash = t('page.detail.dash')
|
||||
const snapshot = props.record?.weight_config_snapshot as
|
||||
| Array<{
|
||||
tier?: string
|
||||
direction?: number
|
||||
grid_number?: number
|
||||
weight?: number
|
||||
}>
|
||||
| undefined
|
||||
if (!Array.isArray(snapshot)) return []
|
||||
return snapshot.map((item) => {
|
||||
const dir = item.direction
|
||||
return {
|
||||
tier: item.tier ?? dash,
|
||||
direction: dir,
|
||||
direction_label:
|
||||
dir === 0 ? t('page.detail.dirCw') : dir === 1 ? t('page.detail.dirCcw') : dash,
|
||||
grid_number: item.grid_number ?? dash,
|
||||
weight: item.weight ?? dash
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const snapshotClockwise = computed(() =>
|
||||
snapshotTableData.value.filter((row) => row.direction === 0 && row.tier !== 'BIGWIN')
|
||||
)
|
||||
const snapshotCounterclockwise = computed(() =>
|
||||
snapshotTableData.value.filter((row) => row.direction === 1 && row.tier !== 'BIGWIN')
|
||||
)
|
||||
const bigwinTableData = computed(() =>
|
||||
bigwinWeightDisplay.value.map((item) => ({
|
||||
grid_number: item.grid,
|
||||
weight: item.weight
|
||||
}))
|
||||
)
|
||||
|
||||
const chartLabels = computed(() => GRID_NUMBERS.map((n) => String(n)))
|
||||
|
||||
const chartData = computed(() => {
|
||||
const counts = props.record?.result_counts
|
||||
if (!counts) return GRID_NUMBERS.map(() => 0)
|
||||
|
||||
// 兼容两种结构:对象 {5:10,...} 或数组 [10, ...]
|
||||
if (Array.isArray(counts)) {
|
||||
// 如果是数组,按顺序映射到 GRID_NUMBERS
|
||||
return GRID_NUMBERS.map((_, idx) => {
|
||||
const v = counts[idx]
|
||||
return typeof v === 'number' && !Number.isNaN(v) ? v : 0
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof counts === 'object') {
|
||||
return GRID_NUMBERS.map((n) => {
|
||||
const byString = (counts as Record<string, number>)[String(n)]
|
||||
const byNumber = (counts as Record<number, number>)[n]
|
||||
const v = byString ?? byNumber
|
||||
return typeof v === 'number' && !Number.isNaN(v) ? v : 0
|
||||
})
|
||||
}
|
||||
|
||||
return GRID_NUMBERS.map(() => 0)
|
||||
})
|
||||
|
||||
const resultTotal = computed(() => {
|
||||
const data = chartData.value
|
||||
return data.reduce((sum, n) => sum + n, 0)
|
||||
})
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
importVisible.value = false
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
const updateDrawerSize = () => {
|
||||
drawerSize.value = window.innerWidth <= 768 ? '100%' : '720px'
|
||||
}
|
||||
updateDrawerSize()
|
||||
window.addEventListener('resize', updateDrawerSize)
|
||||
}
|
||||
|
||||
async function loadLotteryOptions() {
|
||||
try {
|
||||
const list = await lotteryConfigApi.getOptions()
|
||||
lotteryConfigOptions.value = Array.isArray(list) ? list : []
|
||||
} catch {
|
||||
lotteryConfigOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function openImport() {
|
||||
importPaidLotteryConfigId.value =
|
||||
props.record?.paid_lottery_config_id ?? props.record?.lottery_config_id ?? null
|
||||
importFreeLotteryConfigId.value = props.record?.free_lottery_config_id ?? null
|
||||
importVisible.value = true
|
||||
loadLotteryOptions()
|
||||
}
|
||||
|
||||
async function confirmImport() {
|
||||
const id = props.record?.id
|
||||
if (!id) return
|
||||
importing.value = true
|
||||
try {
|
||||
await recordApi.importFromRecord({
|
||||
record_id: id,
|
||||
paid_lottery_config_id: importPaidLotteryConfigId.value ?? undefined,
|
||||
free_lottery_config_id: importFreeLotteryConfigId.value ?? undefined
|
||||
})
|
||||
ElMessage.success(t('page.detail.importSuccess'))
|
||||
importVisible.value = false
|
||||
emit('import-done')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? t('page.detail.importFail'))
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-drawer__body) {
|
||||
padding: 16px;
|
||||
overflow: auto;
|
||||
max-height: calc(100vh - 60px);
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.snapshot-table {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.snapshot-group {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.snapshot-subtitle {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin: 4px 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.chart-wrap {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.result-summary {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.tier-weights-table {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.footer-actions {
|
||||
margin-top: 16px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.import-desc {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item :label="$t('page.form.labelTestCount')" prop="test_count">
|
||||
<el-input v-model="formData.test_count" :placeholder="$t('page.form.placeholderTestCount')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelWeightSnapshot')" prop="weight_config_snapshot">
|
||||
<el-input v-model="formData.weight_config_snapshot" :placeholder="$t('page.form.placeholderWeightSnapshot')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelResultCounts')" prop="result_counts">
|
||||
<el-input v-model="formData.result_counts" :placeholder="$t('page.form.placeholderResultCounts')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward_config_record/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
data?: Record<string, any>
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false,
|
||||
dialogType: 'add',
|
||||
data: undefined
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
/**
|
||||
* 弹窗显示状态双向绑定
|
||||
*/
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = computed<FormRules>(() => ({
|
||||
test_count: [{ required: true, message: t('page.form.ruleTestCountRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
*/
|
||||
const initialFormData = {
|
||||
id: null,
|
||||
test_count: 100,
|
||||
weight_config_snapshot: '',
|
||||
result_counts: '',
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据
|
||||
*/
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
/**
|
||||
* 监听弹窗打开,初始化表单数据
|
||||
*/
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
initPage()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* 初始化页面数据
|
||||
*/
|
||||
const initPage = async () => {
|
||||
// 先重置为初始值
|
||||
Object.assign(formData, initialFormData)
|
||||
// 如果有数据,则填充数据
|
||||
if (props.data) {
|
||||
await nextTick()
|
||||
initForm()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化表单数据
|
||||
*/
|
||||
const initForm = () => {
|
||||
if (props.data) {
|
||||
for (const key in formData) {
|
||||
if (props.data[key] != null && props.data[key] != undefined) {
|
||||
;(formData as any)[key] = props.data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并重置表单
|
||||
*/
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交表单
|
||||
*/
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (error) {
|
||||
console.log('表单验证失败:', error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<sa-search-bar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
label-width="100px"
|
||||
:showExpand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
modelValue: Record<string, any>
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: Record<string, any>): void
|
||||
(e: 'search', params: Record<string, any>): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
// 展开/收起
|
||||
const isExpanded = ref<boolean>(false)
|
||||
|
||||
// 表单数据双向绑定
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val)
|
||||
})
|
||||
|
||||
// 重置
|
||||
function handleReset() {
|
||||
searchBarRef.value?.ref.resetFields()
|
||||
emit('reset')
|
||||
}
|
||||
|
||||
// 搜索
|
||||
async function handleSearch() {
|
||||
emit('search', formData.value)
|
||||
}
|
||||
|
||||
// 展开/收起
|
||||
function handleExpand(expanded: boolean) {
|
||||
isExpanded.value = expanded
|
||||
}
|
||||
|
||||
// 栅格占据的列数
|
||||
const setSpan = (span: number) => {
|
||||
return {
|
||||
span: span,
|
||||
xs: 24, // 手机:满宽显示
|
||||
sm: span >= 12 ? span : 12, // 平板:大于等于12保持,否则用半宽
|
||||
md: span >= 8 ? span : 8, // 中等屏幕:大于等于8保持,否则用三分之一宽
|
||||
lg: span,
|
||||
xl: span
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -244,19 +244,19 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'url', label: '预览', saiType: 'image', width: 80 },
|
||||
{ prop: 'origin_name', label: '文件名称', minWidth: 160, showOverflowTooltip: true },
|
||||
{ prop: 'url', label: 'page.table.preview', saiType: 'image', width: 80 },
|
||||
{ prop: 'origin_name', label: 'page.table.fileName', minWidth: 160, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'storage_mode',
|
||||
label: '存储模式',
|
||||
label: 'page.table.storageMode',
|
||||
width: 100,
|
||||
saiType: 'dict',
|
||||
saiDict: 'upload_mode'
|
||||
},
|
||||
{ prop: 'mime_type', label: '文件类型', width: 160, showOverflowTooltip: true },
|
||||
{ prop: 'size_info', label: '文件大小', width: 100 },
|
||||
{ prop: 'create_time', label: '上传时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'mime_type', label: 'page.table.fileType', width: 160, showOverflowTooltip: true },
|
||||
{ prop: 'size_info', label: 'page.table.fileSize', width: 100 },
|
||||
{ prop: 'create_time', label: 'page.table.uploadTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增文件' : '编辑文件'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="800px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="文件名称" prop="origin_name">
|
||||
<el-input v-model="formData.origin_name" placeholder="请输入文件名称" />
|
||||
<el-form-item :label="$t('page.form.labelFileName')" prop="origin_name">
|
||||
<el-input v-model="formData.origin_name" :placeholder="$t('page.form.placeholderFileName')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -24,6 +24,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import api from '@/api/safeguard/attachment'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -43,6 +45,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -55,9 +58,9 @@
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
const rules: FormRules = {
|
||||
origin_name: [{ required: true, message: '请输入文件名称', trigger: 'blur' }]
|
||||
}
|
||||
const rules = computed<FormRules>(() => ({
|
||||
origin_name: [{ required: true, message: t('page.form.ruleFileNameRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
// 初始表单数据
|
||||
const initialFormData = {
|
||||
@@ -123,7 +126,7 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'edit') {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入用户名" clearable />
|
||||
<el-form-item :label="$t('page.search.username')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.placeholderUsername')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable />
|
||||
<el-form-item :label="$t('page.search.phone')" prop="phone">
|
||||
<el-input v-model="formData.phone" :placeholder="$t('page.search.placeholderPhone')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -125,16 +125,16 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: '表名称', minWidth: 200 },
|
||||
{ prop: 'comment', label: '表注释', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'engine', label: '表引擎', width: 120 },
|
||||
{ prop: 'update_time', label: '更新时间', width: 180, sortable: true },
|
||||
{ prop: 'rows', label: '总行数', width: 120 },
|
||||
{ prop: 'data_free', label: '碎片大小', width: 120 },
|
||||
{ prop: 'data_length', label: '数据大小', width: 120 },
|
||||
{ prop: 'collation', label: '字符集', width: 180 },
|
||||
{ prop: 'create_time', label: '创建时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'name', label: 'page.table.tableName', minWidth: 200 },
|
||||
{ prop: 'comment', label: 'page.table.tableComment', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'engine', label: 'page.table.tableEngine', width: 120 },
|
||||
{ prop: 'update_time', label: 'page.table.updateTime', width: 180, sortable: true },
|
||||
{ prop: 'rows', label: 'page.table.totalRows', width: 120 },
|
||||
{ prop: 'data_free', label: 'page.table.fragmentSize', width: 120 },
|
||||
{ prop: 'data_length', label: 'page.table.dataSize', width: 120 },
|
||||
{ prop: 'collation', label: 'page.table.collation', width: 180 },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -140,8 +140,8 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'delete_time', label: '删除时间', width: 180 },
|
||||
{ prop: 'json_data', label: '数据详情', useSlot: true, showOverflowTooltip: true }
|
||||
{ prop: 'delete_time', label: 'page.table.deleteTime', width: 180 },
|
||||
{ prop: 'json_data', label: 'page.table.dataDetail', useSlot: true, showOverflowTooltip: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="表名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入表名称" clearable />
|
||||
<el-form-item :label="$t('page.search.tableName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderTableName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -268,10 +268,10 @@
|
||||
...typeSearch.value
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ prop: 'id', label: '选中', width: 80, align: 'center', useSlot: true },
|
||||
{ prop: 'name', label: '字典名称', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'code', label: '字典标识', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status', width: 100 }
|
||||
{ prop: 'id', label: 'page.table.select', width: 80, align: 'center', useSlot: true },
|
||||
{ prop: 'name', label: 'page.table.dictName', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'code', label: 'page.table.dictCode', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status', width: 100 }
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -312,12 +312,12 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'label', label: '字典标签', useSlot: true },
|
||||
{ prop: 'value', label: '字典键值' },
|
||||
{ prop: 'color', label: '颜色' },
|
||||
{ prop: 'sort', label: '排序' },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'operation', label: '操作', useSlot: true, width: 120 }
|
||||
{ prop: 'label', label: 'page.table.dictLabel', useSlot: true },
|
||||
{ prop: 'value', label: 'page.table.dictValue' },
|
||||
{ prop: 'color', label: 'page.table.color' },
|
||||
{ prop: 'sort', label: 'page.table.sort' },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'operation', label: 'table.actions.operation', useSlot: true, width: 120 }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -103,15 +103,15 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: '编号', width: 100, align: 'center' },
|
||||
{ prop: 'gateway', label: '服务Host' },
|
||||
{ prop: 'from', label: '发件人', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'email', label: '收件人', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'code', label: '验证码' },
|
||||
{ prop: 'status', label: '发送状态', useSlot: true },
|
||||
{ prop: 'response', label: '发送结果', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'create_time', label: '发送时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 80, fixed: 'right', useSlot: true }
|
||||
{ prop: 'id', label: 'page.table.no', width: 100, align: 'center' },
|
||||
{ prop: 'gateway', label: 'page.table.gateway' },
|
||||
{ prop: 'from', label: 'page.table.emailFrom', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'email', label: 'page.table.emailTo', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'code', label: 'page.table.emailCode' },
|
||||
{ prop: 'status', label: 'page.table.sendStatus', useSlot: true },
|
||||
{ prop: 'response', label: 'page.table.emailResponse', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'create_time', label: 'page.table.sendTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 80, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,31 +9,31 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="发件人" prop="from">
|
||||
<el-input v-model="formData.from" placeholder="请输入发件人" clearable />
|
||||
<el-form-item :label="$t('page.search.labelFrom')" prop="from">
|
||||
<el-input v-model="formData.from" :placeholder="$t('page.search.placeholderFrom')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="收件人" prop="email">
|
||||
<el-input v-model="formData.email" placeholder="请输入收件人" clearable />
|
||||
<el-form-item :label="$t('page.search.labelTo')" prop="email">
|
||||
<el-input v-model="formData.email" :placeholder="$t('page.search.placeholderTo')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="发送状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择发送状态" clearable>
|
||||
<el-option label="成功" value="success" />
|
||||
<el-option label="失败" value="failure" />
|
||||
<el-form-item :label="$t('page.search.placeholderSendStatus')" prop="status">
|
||||
<el-select v-model="formData.status" :placeholder="$t('page.search.placeholderSendStatus')" clearable>
|
||||
<el-option :label="$t('table.searchBar.success')" value="success" />
|
||||
<el-option :label="$t('table.searchBar.failure')" value="failure" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(12)" v-show="isExpanded">
|
||||
<el-form-item label="发送时间" prop="create_time">
|
||||
<el-form-item :label="$t('page.search.operTime')" prop="create_time">
|
||||
<el-date-picker
|
||||
v-model="formData.create_time"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:range-separator="$t('table.searchBar.rangeSeparator')"
|
||||
:start-placeholder="$t('table.searchBar.startTime')"
|
||||
:end-placeholder="$t('table.searchBar.endTime')"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
|
||||
@@ -103,16 +103,16 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: '编号', width: 100, align: 'center' },
|
||||
{ prop: 'username', label: '登录用户' },
|
||||
{ prop: 'status', label: '登录状态', useSlot: true },
|
||||
{ prop: 'ip', label: '登录IP' },
|
||||
{ prop: 'ip_location', label: '登录地点' },
|
||||
{ prop: 'os', label: '操作系统' },
|
||||
{ prop: 'browser', label: '浏览器' },
|
||||
{ prop: 'message', label: '登录信息', showOverflowTooltip: true },
|
||||
{ prop: 'login_time', label: '登录时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 80, fixed: 'right', useSlot: true }
|
||||
{ prop: 'id', label: 'page.table.no', width: 100, align: 'center' },
|
||||
{ prop: 'username', label: 'page.table.loginUser' },
|
||||
{ prop: 'status', label: 'page.table.loginStatus', useSlot: true },
|
||||
{ prop: 'ip', label: 'page.table.loginIp' },
|
||||
{ prop: 'ip_location', label: 'page.table.operLocation' },
|
||||
{ prop: 'os', label: 'page.table.os' },
|
||||
{ prop: 'browser', label: 'page.table.browser' },
|
||||
{ prop: 'message', label: 'page.table.loginMessage', showOverflowTooltip: true },
|
||||
{ prop: 'login_time', label: 'page.table.loginTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 80, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,31 +9,31 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="登录用户" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入登录用户" clearable />
|
||||
<el-form-item :label="$t('page.search.loginUser')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.placeholderLoginUser')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="登录IP" prop="ip">
|
||||
<el-input v-model="formData.ip" placeholder="请输入登录IP" clearable />
|
||||
<el-form-item :label="$t('page.search.loginIp')" prop="ip">
|
||||
<el-input v-model="formData.ip" :placeholder="$t('page.search.placeholderLoginIp')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="登录状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择登录状态" clearable>
|
||||
<el-option label="成功" value="1" />
|
||||
<el-option label="失败" value="0" />
|
||||
<el-form-item :label="$t('page.search.loginStatus')" prop="status">
|
||||
<el-select v-model="formData.status" :placeholder="$t('page.search.placeholderLoginStatus')" clearable>
|
||||
<el-option :label="$t('table.searchBar.success')" value="1" />
|
||||
<el-option :label="$t('table.searchBar.failure')" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(12)" v-show="isExpanded">
|
||||
<el-form-item label="登录时间" prop="login_time">
|
||||
<el-form-item :label="$t('page.search.operTime')" prop="login_time">
|
||||
<el-date-picker
|
||||
v-model="formData.login_time"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:range-separator="$t('table.searchBar.rangeSeparator')"
|
||||
:start-placeholder="$t('table.searchBar.startTime')"
|
||||
:end-placeholder="$t('table.searchBar.endTime')"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -102,14 +102,14 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: '编号', width: 100, align: 'center' },
|
||||
{ prop: 'username', label: '操作用户' },
|
||||
{ prop: 'service_name', label: '业务名称' },
|
||||
{ prop: 'router', label: '路由', minWidth: 180, showOverflowTooltip: true },
|
||||
{ prop: 'ip', label: '操作IP' },
|
||||
{ prop: 'ip_location', label: '操作地点' },
|
||||
{ prop: 'create_time', label: '操作时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'id', label: 'page.table.no', width: 100, align: 'center' },
|
||||
{ prop: 'username', label: 'page.table.operator' },
|
||||
{ prop: 'service_name', label: 'page.table.serviceName' },
|
||||
{ prop: 'router', label: 'page.table.router', minWidth: 180, showOverflowTooltip: true },
|
||||
{ prop: 'ip', label: 'page.table.operIp' },
|
||||
{ prop: 'ip_location', label: 'page.table.operLocation' },
|
||||
{ prop: 'create_time', label: 'page.table.operTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,28 +9,28 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="操作用户" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入操作用户" clearable />
|
||||
<el-form-item :label="$t('page.search.operator')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.placeholderOperator')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="操作路由" prop="router">
|
||||
<el-input v-model="formData.router" placeholder="请输入操作路由" clearable />
|
||||
<el-form-item :label="$t('page.search.router')" prop="router">
|
||||
<el-input v-model="formData.router" :placeholder="$t('page.search.placeholderOperRouter')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="操作IP" prop="ip">
|
||||
<el-input v-model="formData.ip" placeholder="请输入操作IP" clearable />
|
||||
<el-form-item :label="$t('page.search.operIp')" prop="ip">
|
||||
<el-input v-model="formData.ip" :placeholder="$t('page.search.placeholderOperIp')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(12)" v-show="isExpanded">
|
||||
<el-form-item label="操作时间" prop="create_time">
|
||||
<el-form-item :label="$t('page.search.operTime')" prop="create_time">
|
||||
<el-date-picker
|
||||
v-model="formData.create_time"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:range-separator="$t('table.searchBar.rangeSeparator')"
|
||||
:start-placeholder="$t('table.searchBar.startTime')"
|
||||
:end-placeholder="$t('table.searchBar.endTime')"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
clearable
|
||||
/>
|
||||
|
||||
@@ -300,9 +300,9 @@
|
||||
...configSearch.value
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ prop: 'id', label: '选中', width: 80, align: 'center', useSlot: true },
|
||||
{ prop: 'name', label: '配置名称', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'code', label: '配置标识', useHeaderSlot: true, width: 150 }
|
||||
{ prop: 'id', label: 'page.table.select', width: 80, align: 'center', useSlot: true },
|
||||
{ prop: 'name', label: 'page.table.configName', useHeaderSlot: true, width: 150 },
|
||||
{ prop: 'code', label: 'page.table.configKey', useHeaderSlot: true, width: 150 }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -160,12 +160,12 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'key', label: '配置标识' },
|
||||
{ prop: 'name', label: '配置标题' },
|
||||
{ prop: 'input_type', label: '组件类型', width: 100 },
|
||||
{ prop: 'sort', label: '排序', width: 100, sortable: true },
|
||||
{ prop: 'remark', label: '备注' },
|
||||
{ prop: 'operation', label: '操作', useSlot: true, width: 100 }
|
||||
{ prop: 'key', label: 'table.columns.system.configKey' },
|
||||
{ prop: 'name', label: 'table.columns.system.configTitle' },
|
||||
{ prop: 'input_type', label: 'table.columns.system.inputType', width: 100 },
|
||||
{ prop: 'sort', label: 'table.columns.common.sort', width: 100, sortable: true },
|
||||
{ prop: 'remark', label: 'table.columns.common.remark' },
|
||||
{ prop: 'operation', label: 'table.actions.operation', useSlot: true, width: 100 }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
<ElButton @click="toggleExpand" v-ripple>
|
||||
<template #icon>
|
||||
<ArtSvgIcon v-if="isExpanded" icon="ri:collapse-diagonal-line" />
|
||||
<ArtSvgIcon v-else icon="ri:expand-diagonal-line" />
|
||||
</template>
|
||||
{{ isExpanded ? '收起' : '展开' }}
|
||||
{{ isExpanded ? $t('table.searchBar.collapse') : $t('table.searchBar.expand') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -106,14 +106,14 @@
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'name', label: '部门名称', minWidth: 200 },
|
||||
{ prop: 'code', label: '部门编码', minWidth: 120 },
|
||||
{ prop: 'leader.username', label: '部门领导', minWidth: 120 },
|
||||
{ prop: 'remark', label: '描述', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: '排序', width: 100 },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'create_time', label: '创建日期', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'name', label: 'page.table.deptName', minWidth: 200 },
|
||||
{ prop: 'code', label: 'page.table.deptCode', minWidth: 120 },
|
||||
{ prop: 'leader.username', label: 'page.table.leader', minWidth: 120 },
|
||||
{ prop: 'remark', label: 'table.columns.common.description', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: 'page.table.sort', width: 100 },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增部门' : '编辑部门'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="上级部门" prop="parent_id">
|
||||
<el-form-item :label="$t('page.form.labelParentDept')" prop="parent_id">
|
||||
<el-tree-select
|
||||
v-model="formData.parent_id"
|
||||
:data="optionData.treeData"
|
||||
@@ -17,33 +17,33 @@
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入部门名称" />
|
||||
<el-form-item :label="$t('page.form.labelDeptName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderDeptName')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入部门编码" />
|
||||
<el-form-item :label="$t('page.form.labelDeptCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.form.placeholderDeptCode')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门领导">
|
||||
<el-form-item :label="$t('page.form.labelLeader')">
|
||||
<sa-user v-model="formData.leader_id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="remark">
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入部门描述"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" placeholder="请输入排序" />
|
||||
<el-form-item :label="$t('page.form.labelSort')" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :placeholder="$t('page.form.placeholderSort')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="启用" prop="status">
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -52,6 +52,7 @@
|
||||
import api from '@/api/system/dept'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -71,6 +72,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const optionData = reactive({
|
||||
@@ -88,11 +90,13 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
parent_id: [{ required: true, message: '请选择上级部门', trigger: 'change' }],
|
||||
name: [{ required: true, message: '请输入部门名称', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入部门编码', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
parent_id: [
|
||||
{ required: true, message: t('page.form.ruleParentDeptRequired'), trigger: 'change' }
|
||||
],
|
||||
name: [{ required: true, message: t('page.form.ruleDeptNameRequired'), trigger: 'blur' }],
|
||||
code: [{ required: true, message: t('page.form.ruleDeptCodeRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -138,7 +142,7 @@
|
||||
{
|
||||
id: 0,
|
||||
value: 0,
|
||||
label: '无上级部门',
|
||||
label: t('page.form.noParentDept'),
|
||||
children: data
|
||||
}
|
||||
]
|
||||
@@ -180,10 +184,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入部门名称" clearable />
|
||||
<el-form-item :label="$t('page.search.deptName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderDeptName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="部门编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入部门编码" clearable />
|
||||
<el-form-item :label="$t('page.search.deptCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.search.placeholderDeptCode')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'core:menu:destroy'"
|
||||
@@ -27,7 +27,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
<ElButton @click="toggleExpand" v-ripple>
|
||||
<template #icon>
|
||||
@@ -129,10 +129,10 @@
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: '菜单名称', minWidth: 150 },
|
||||
{ prop: 'name', label: 'page.table.menuName', minWidth: 150 },
|
||||
{
|
||||
prop: 'type',
|
||||
label: '菜单类型',
|
||||
label: 'page.table.menuType',
|
||||
align: 'center',
|
||||
saiType: 'dict',
|
||||
saiDict: 'menu_type',
|
||||
@@ -140,17 +140,17 @@
|
||||
},
|
||||
{
|
||||
prop: 'icon',
|
||||
label: '图标',
|
||||
label: 'page.table.icon',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
formatter: (row: any) => {
|
||||
return h(ArtSvgIcon, { icon: row.icon })
|
||||
}
|
||||
},
|
||||
{ prop: 'code', label: '组件名称' },
|
||||
{ prop: 'code', label: 'page.table.component' },
|
||||
{
|
||||
prop: 'path',
|
||||
label: '路由',
|
||||
label: 'page.table.route',
|
||||
formatter: (row: any) => {
|
||||
if (row.type === 3) return ''
|
||||
return row.path || ''
|
||||
@@ -158,7 +158,7 @@
|
||||
},
|
||||
{
|
||||
prop: 'slug',
|
||||
label: '权限标识',
|
||||
label: 'page.table.auth',
|
||||
minWidth: 160,
|
||||
formatter: (row: any) => {
|
||||
if (row.type === 2) {
|
||||
@@ -170,9 +170,9 @@
|
||||
return ''
|
||||
}
|
||||
},
|
||||
{ prop: 'sort', label: '排序', width: 100 },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'operation', label: '操作', width: 140, fixed: 'right', useSlot: true }
|
||||
{ prop: 'sort', label: 'page.table.sort', width: 100 },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 140, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增菜单' : '编辑菜单'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="820px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="菜单类型" prop="type">
|
||||
<el-form-item :label="$t('page.form.labelMenuType')" prop="type">
|
||||
<sa-radio v-model="formData.type" type="button" dict="menu_type"></sa-radio>
|
||||
</el-form-item>
|
||||
<el-form-item label="上级菜单" prop="parent_id">
|
||||
<el-form-item :label="$t('page.form.labelParentMenu')" prop="parent_id">
|
||||
<el-tree-select
|
||||
v-model="formData.parent_id"
|
||||
:data="optionData.treeData"
|
||||
@@ -22,63 +22,63 @@
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="菜单名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入菜单名称" />
|
||||
<el-form-item :label="$t('page.form.labelMenuName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.labelMenuName')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="formData.type < 3">
|
||||
<el-form-item prop="path">
|
||||
<template #label>
|
||||
<sa-label
|
||||
label="路由地址"
|
||||
tooltip="一级菜单:以 / 开头的绝对路径(如 /dashboard) 二级及以下:相对路径(如 console、user)"
|
||||
:label="$t('page.form.labelRoutePath')"
|
||||
:tooltip="$t('page.form.labelRoutePathTip')"
|
||||
/>
|
||||
</template>
|
||||
<el-input v-model="formData.path" placeholder="如:/dashboard 或 console" />
|
||||
<el-input v-model="formData.path" :placeholder="$t('page.form.placeholderRoutePath')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="formData.type != 3">
|
||||
<el-form-item label="组件名称" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="如: User" />
|
||||
<el-form-item :label="$t('page.form.labelComponentName')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.form.placeholderComponentName')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="formData.type === 2">
|
||||
<el-form-item prop="component">
|
||||
<template #label>
|
||||
<sa-label label="组件路径" tooltip="填写组件路径(views目录下) 目录菜单:留空" />
|
||||
<sa-label :label="$t('page.form.labelComponentPath')" :tooltip="$t('page.form.labelComponentPathTip')" />
|
||||
</template>
|
||||
<el-autocomplete
|
||||
class="w-full"
|
||||
v-model="formData.component"
|
||||
:fetch-suggestions="querySearch"
|
||||
clearable
|
||||
placeholder="如:/system/user 或留空"
|
||||
:placeholder="$t('page.form.placeholderComponentPath')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="formData.type != 3">
|
||||
<el-form-item label="菜单图标" prop="icon">
|
||||
<el-form-item :label="$t('page.form.labelMenuIcon')" prop="icon">
|
||||
<sa-icon-picker v-model="formData.icon" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="formData.type === 3">
|
||||
<el-form-item label="权限标识" prop="slug">
|
||||
<el-input v-model="formData.slug" placeholder="请输入权限标识" />
|
||||
<el-form-item :label="$t('page.form.labelPermSlug')" prop="slug">
|
||||
<el-input v-model="formData.slug" :placeholder="$t('page.form.placeholderPermSlug')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" v-if="formData.type === 4">
|
||||
<el-form-item label="外链地址" prop="link_url">
|
||||
<el-input v-model="formData.link_url" placeholder="如:https://saithink.top" />
|
||||
<el-form-item :label="$t('page.form.labelLinkUrl')" prop="link_url">
|
||||
<el-input v-model="formData.link_url" :placeholder="$t('page.form.placeholderLinkUrl')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="sort">
|
||||
<template #label>
|
||||
<sa-label label="排序" tooltip="数字越大越靠前" />
|
||||
<sa-label :label="$t('page.form.labelSort')" :tooltip="$t('page.form.labelSortTip')" />
|
||||
</template>
|
||||
<el-input-number
|
||||
v-model="formData.sort"
|
||||
placeholder="请输入排序"
|
||||
:placeholder="$t('page.form.placeholderSort')"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -86,7 +86,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="status">
|
||||
<template #label>
|
||||
<sa-label label="状态" tooltip="禁用后,该菜单项将不可用" />
|
||||
<sa-label :label="$t('page.form.labelStatus')" :tooltip="$t('page.form.labelStatusTip')" />
|
||||
</template>
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
@@ -94,7 +94,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="is_iframe">
|
||||
<template #label>
|
||||
<sa-label label="是否内嵌" tooltip="外链模式下有效" />
|
||||
<sa-label :label="$t('page.form.labelIsIframe')" :tooltip="$t('page.form.labelIsIframeTip')" />
|
||||
</template>
|
||||
<sa-switch v-model="formData.is_iframe" dict="yes_or_no" :showText="false" />
|
||||
</el-form-item>
|
||||
@@ -102,7 +102,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="is_keep_alive">
|
||||
<template #label>
|
||||
<sa-label label="是否缓存" tooltip="切换tabs不刷新" />
|
||||
<sa-label :label="$t('page.form.labelIsKeepAlive')" :tooltip="$t('page.form.labelIsKeepAliveTip')" />
|
||||
</template>
|
||||
<sa-switch v-model="formData.is_keep_alive" dict="yes_or_no" :showText="false" />
|
||||
</el-form-item>
|
||||
@@ -110,7 +110,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="is_hidden">
|
||||
<template #label>
|
||||
<sa-label label="是否隐藏" tooltip="不在菜单栏显示,但是可以通过路由访问" />
|
||||
<sa-label :label="$t('page.form.labelIsHidden')" :tooltip="$t('page.form.labelIsHiddenTip')" />
|
||||
</template>
|
||||
<sa-switch v-model="formData.is_hidden" dict="yes_or_no" :showText="false" />
|
||||
</el-form-item>
|
||||
@@ -118,7 +118,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="is_fixed_tab">
|
||||
<template #label>
|
||||
<sa-label label="是否固定" tooltip="固定在tabs导航栏" />
|
||||
<sa-label :label="$t('page.form.labelIsFixedTab')" :tooltip="$t('page.form.labelIsFixedTabTip')" />
|
||||
</template>
|
||||
<sa-switch v-model="formData.is_fixed_tab" dict="yes_or_no" :showText="false" />
|
||||
</el-form-item>
|
||||
@@ -126,7 +126,7 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item prop="is_full_page">
|
||||
<template #label>
|
||||
<sa-label label="是否全屏" tooltip="不继承左侧菜单和顶部导航栏" />
|
||||
<sa-label :label="$t('page.form.labelIsFullPage')" :tooltip="$t('page.form.labelIsFullPageTip')" />
|
||||
</template>
|
||||
<sa-switch v-model="formData.is_full_page" dict="yes_or_no" :showText="false" />
|
||||
</el-form-item>
|
||||
@@ -134,8 +134,8 @@
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -144,6 +144,7 @@
|
||||
import api from '@/api/system/menu'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -163,6 +164,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const optionData = reactive({
|
||||
@@ -197,14 +199,14 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
parent_id: [{ required: true, message: '请选择上级菜单', trigger: 'change' }],
|
||||
name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
|
||||
path: [{ required: true, message: '请输入路由地址', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入组件名称', trigger: 'blur' }],
|
||||
slug: [{ required: true, message: '请输入权限标识', trigger: 'blur' }],
|
||||
link_url: [{ required: true, message: '请输入外链地址', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
parent_id: [{ required: true, message: t('page.form.ruleParentMenuRequired'), trigger: 'change' }],
|
||||
name: [{ required: true, message: t('page.form.ruleMenuNameRequired'), trigger: 'blur' }],
|
||||
path: [{ required: true, message: t('page.form.ruleRoutePathRequired'), trigger: 'blur' }],
|
||||
code: [{ required: true, message: t('page.form.ruleComponentNameRequired'), trigger: 'blur' }],
|
||||
slug: [{ required: true, message: t('page.form.rulePermSlugRequired'), trigger: 'blur' }],
|
||||
link_url: [{ required: true, message: t('page.form.ruleLinkUrlRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -302,10 +304,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="菜单名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入菜单名称" clearable />
|
||||
<el-form-item :label="$t('page.search.menuName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderMenuName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="菜单路由" prop="path">
|
||||
<el-input v-model="formData.path" placeholder="请输入菜单路由" clearable />
|
||||
<el-form-item :label="$t('page.search.route')" prop="path">
|
||||
<el-input v-model="formData.path" :placeholder="$t('page.search.placeholderMenuRoute')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'core:post:destroy'"
|
||||
@@ -23,7 +23,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
<SaImport
|
||||
v-permission="'core:post:import'"
|
||||
@@ -116,14 +116,14 @@
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: '编号', width: 100, align: 'center' },
|
||||
{ prop: 'name', label: '岗位名称', minWidth: 120 },
|
||||
{ prop: 'code', label: '岗位编码', minWidth: 120 },
|
||||
{ prop: 'remark', label: '描述', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: '排序', width: 100 },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'create_time', label: '创建日期', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||
{ prop: 'id', label: 'table.columns.common.no', width: 100, align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.postName', minWidth: 120 },
|
||||
{ prop: 'code', label: 'page.table.postCode', minWidth: 120 },
|
||||
{ prop: 'remark', label: 'table.columns.common.description', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: 'page.table.sort', width: 100 },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 100, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增岗位' : '编辑岗位'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="岗位名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入岗位名称" />
|
||||
<el-form-item :label="$t('page.form.labelName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderName')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="岗位编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入岗位编码" />
|
||||
<el-form-item :label="$t('page.form.labelCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.form.placeholderCode')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="remark">
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入岗位描述"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" placeholder="请输入排序" />
|
||||
<el-form-item :label="$t('page.form.labelSort')" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :placeholder="$t('page.form.placeholderSort')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="启用" prop="status">
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -40,6 +40,7 @@
|
||||
import api from '@/api/system/post'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -59,6 +60,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -73,10 +75,10 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '请输入岗位名称', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入岗位编码', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
code: [{ required: true, message: t('page.form.ruleCodeRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -150,10 +152,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="岗位名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入岗位名称" clearable />
|
||||
<el-form-item :label="$t('page.search.postName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderPostName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="岗位编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入岗位编码" clearable />
|
||||
<el-form-item :label="$t('page.search.postCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.search.placeholderPostCode')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -126,15 +126,15 @@
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'id', label: '编号', minWidth: 60, align: 'center' },
|
||||
{ prop: 'name', label: '角色名称', minWidth: 120 },
|
||||
{ prop: 'code', label: '角色编码', minWidth: 120 },
|
||||
{ prop: 'level', label: '角色级别', minWidth: 100, sortable: true },
|
||||
{ prop: 'remark', label: '角色描述', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: '排序', minWidth: 100 },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'create_time', label: '创建日期', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 140, fixed: 'right', useSlot: true }
|
||||
{ prop: 'id', label: 'table.columns.common.no', minWidth: 60, align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.roleName', minWidth: 120 },
|
||||
{ prop: 'code', label: 'page.table.roleCode', minWidth: 120 },
|
||||
{ prop: 'level', label: 'page.table.level', minWidth: 100, sortable: true },
|
||||
{ prop: 'remark', label: 'page.table.roleRemark', minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'sort', label: 'table.columns.common.sort', minWidth: 100 },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 140, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增角色' : '编辑角色'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="600px"
|
||||
align-center
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入角色名称" />
|
||||
<el-form-item :label="$t('page.form.labelName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderName')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色标识" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入角色编码" />
|
||||
<el-form-item :label="$t('page.form.labelCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.form.placeholderCode')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="角色级别" prop="level">
|
||||
<el-input-number v-model="formData.level" placeholder="角色级别" :max="99" :min="1" />
|
||||
<el-form-item :label="$t('page.form.labelLevel')" prop="level">
|
||||
<el-input-number v-model="formData.level" :placeholder="$t('page.form.labelLevel')" :max="99" :min="1" />
|
||||
</el-form-item>
|
||||
<div class="text-xs text-gray-400 pl-32 pb-4"
|
||||
>控制角色的权限层级, 不能操作职级高于自己的角色</div
|
||||
>
|
||||
<el-form-item label="描述" prop="remark">
|
||||
<div class="text-xs text-gray-400 pl-32 pb-4">{{ $t('page.form.levelTip') }}</div>
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入角色描述"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" placeholder="请输入排序" />
|
||||
<el-form-item :label="$t('page.form.labelSort')" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :placeholder="$t('page.form.placeholderSort')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="启用" prop="status">
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -45,6 +43,7 @@
|
||||
import api from '@/api/system/role'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -64,6 +63,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -78,11 +78,11 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入角色编码', trigger: 'blur' }],
|
||||
level: [{ required: true, message: '请输入角色级别', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
code: [{ required: true, message: t('page.form.ruleCodeRequired'), trigger: 'blur' }],
|
||||
level: [{ required: true, message: t('page.form.ruleLevelRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -157,10 +157,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="角色名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入角色名称" clearable />
|
||||
<el-form-item :label="$t('page.search.roleName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderRoleName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="角色编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入角色编码" clearable />
|
||||
<el-form-item :label="$t('page.search.roleCode')" prop="code">
|
||||
<el-input v-model="formData.code" :placeholder="$t('page.search.placeholderRoleCode')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -180,23 +180,30 @@
|
||||
...searchForm.value
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'index', width: 60, label: '序号' },
|
||||
{ type: 'index', width: 60, label: 'table.column.index' },
|
||||
{
|
||||
prop: 'avatar',
|
||||
label: '用户名',
|
||||
label: 'page.table.username',
|
||||
minWidth: 200,
|
||||
saiType: 'imageAndText',
|
||||
saiFirst: 'username',
|
||||
saiSecond: 'email'
|
||||
},
|
||||
{ prop: 'phone', label: '手机号', width: 120 },
|
||||
{ prop: 'depts.name', label: '部门', minWidth: 150 },
|
||||
{ prop: 'status', label: '状态', width: 80, saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'dashboard', label: '首页', width: 100, saiType: 'dict', saiDict: 'dashboard' },
|
||||
{ prop: 'login_time', label: '上次登录', width: 170, sortable: true },
|
||||
{ prop: 'phone', label: 'page.table.phone', width: 120 },
|
||||
{
|
||||
prop: 'dept_id',
|
||||
label: 'page.table.dept',
|
||||
minWidth: 150,
|
||||
sortable: true,
|
||||
formatter: (row: any) => row.depts?.name ?? ''
|
||||
},
|
||||
{ prop: 'status', label: 'page.table.status', width: 80, saiType: 'dict', saiDict: 'data_status' },
|
||||
{ prop: 'agent_id', label: 'page.table.agentId', width: 120, showOverflowTooltip: true },
|
||||
{ prop: 'dashboard', label: 'page.table.dashboard', width: 100, saiType: 'dict', saiDict: 'dashboard' },
|
||||
{ prop: 'login_time', label: 'page.table.loginTime', width: 170, sortable: true },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
label: 'table.actions.operation',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增用户' : '编辑用户'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="800px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||
<el-form-item label="头像" prop="avatar">
|
||||
<el-form-item :label="$t('page.form.labelAvatar')" prop="avatar">
|
||||
<sa-image-picker v-model="formData.avatar" round />
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-form-item :label="$t('page.form.labelUsername')" prop="username">
|
||||
<el-input v-model="formData.username" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="真实姓名" prop="realname">
|
||||
<el-form-item :label="$t('page.form.labelRealname')" prop="realname">
|
||||
<el-input v-model="formData.realname" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="dialogType === 'add'">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-form-item :label="$t('page.form.labelPassword')" prop="password">
|
||||
<el-input type="password" v-model="formData.password" show-password />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="确认密码" prop="password_confirm">
|
||||
<el-form-item :label="$t('page.form.labelPasswordConfirm')" prop="password_confirm">
|
||||
<el-input type="password" v-model="formData.password_confirm" show-password />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -38,20 +38,20 @@
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="formData.email" placeholder="请输入邮箱" />
|
||||
<el-form-item :label="$t('page.form.labelEmail')" prop="email">
|
||||
<el-input v-model="formData.email" :placeholder="$t('page.form.placeholderEmail')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" />
|
||||
<el-form-item :label="$t('page.form.labelPhone')" prop="phone">
|
||||
<el-input v-model="formData.phone" :placeholder="$t('page.form.placeholderPhone')" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门" prop="dept_id">
|
||||
<el-form-item :label="$t('page.form.labelDept')" prop="dept_id">
|
||||
<el-tree-select
|
||||
v-model="formData.dept_id"
|
||||
:data="optionData.deptData"
|
||||
@@ -62,7 +62,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="角色" prop="role_ids">
|
||||
<el-form-item :label="$t('page.form.labelRole')" prop="role_ids">
|
||||
<el-select v-model="formData.role_ids" multiple clearable>
|
||||
<el-option
|
||||
v-for="role in optionData.roleList"
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="岗位" prop="post_ids">
|
||||
<el-form-item :label="$t('page.form.labelPost')" prop="post_ids">
|
||||
<el-select v-model="formData.post_ids" multiple clearable>
|
||||
<el-option
|
||||
v-for="post in optionData.postList"
|
||||
@@ -89,14 +89,14 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="性别" prop="gender">
|
||||
<el-form-item :label="$t('page.form.labelGender')" prop="gender">
|
||||
<sa-radio v-model="formData.gender" dict="gender" valueType="string" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -104,12 +104,12 @@
|
||||
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -117,8 +117,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -130,6 +130,8 @@
|
||||
import deptApi from '@/api/system/dept'
|
||||
import roleApi from '@/api/system/role'
|
||||
import postApi from '@/api/system/post'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -149,6 +151,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const optionData = reactive({
|
||||
@@ -167,30 +170,30 @@
|
||||
|
||||
const validatePasswordConfirm = (rule: any, value: any, callback: any) => {
|
||||
if (value !== formData.password) {
|
||||
callback(new Error('两次输入的密码不一致'))
|
||||
callback(new Error(t('page.form.rulePasswordNotMatch')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
// 表单验证规则
|
||||
const rules: FormRules = {
|
||||
const rules = computed<FormRules>(() => ({
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
{ required: true, message: t('page.form.ruleUsernameRequired'), trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: t('page.form.ruleUsernameLength'), trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
|
||||
{ required: true, message: t('page.form.rulePasswordRequired'), trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: t('page.form.rulePasswordLength'), trigger: 'blur' }
|
||||
],
|
||||
password_confirm: [
|
||||
{ required: true, message: '请输入确认密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' },
|
||||
{ required: true, message: t('page.form.rulePasswordConfirmRequired'), trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: t('page.form.rulePasswordLength'), trigger: 'blur' },
|
||||
{ validator: validatePasswordConfirm, trigger: 'blur' }
|
||||
],
|
||||
dept_id: [{ required: true, message: '请选择部门', trigger: 'change' }],
|
||||
role_ids: [{ required: true, message: '请选择角色', trigger: 'blur' }]
|
||||
}
|
||||
dept_id: [{ required: true, message: t('page.form.ruleDeptRequired'), trigger: 'change' }],
|
||||
role_ids: [{ required: true, message: t('page.form.ruleRoleRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
// 初始表单数据
|
||||
const initialFormData = {
|
||||
@@ -287,10 +290,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="formData.username" placeholder="请输入用户名" clearable />
|
||||
<el-form-item :label="$t('page.search.username')" prop="username">
|
||||
<el-input v-model="formData.username" :placeholder="$t('page.search.placeholderUsername')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable />
|
||||
<el-form-item :label="$t('page.search.phone')" prop="phone">
|
||||
<el-input v-model="formData.phone" :placeholder="$t('page.search.placeholderPhone')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -217,11 +217,11 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: '表名称' },
|
||||
{ prop: 'comment', label: '表注释' },
|
||||
{ prop: 'engine', label: '引擎' },
|
||||
{ prop: 'collation', label: '编码' },
|
||||
{ prop: 'create_time', label: '创建时间' }
|
||||
{ prop: 'name', label: 'page.table.tableName' },
|
||||
{ prop: 'comment', label: 'page.table.tableComment' },
|
||||
{ prop: 'engine', label: 'page.table.engine' },
|
||||
{ prop: 'collation', label: 'page.table.collation' },
|
||||
{ prop: 'create_time', label: 'page.table.createTime' }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -195,14 +195,14 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection', width: 50 },
|
||||
{ prop: 'table_name', label: '表名称', minWidth: 180, align: 'left' },
|
||||
{ prop: 'table_comment', label: '表描述', minWidth: 150, align: 'left' },
|
||||
{ prop: 'template', label: '应用类型', minWidth: 120 },
|
||||
{ prop: 'namespace', label: '应用名称', minWidth: 120 },
|
||||
{ prop: 'stub', label: '模板类型', minWidth: 120 },
|
||||
{ prop: 'tpl_category', label: '生成类型', minWidth: 120, useSlot: true },
|
||||
{ prop: 'update_time', label: '更新时间', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 220, fixed: 'right', useSlot: true }
|
||||
{ prop: 'table_name', label: 'page.table.tableName', minWidth: 180, align: 'left' },
|
||||
{ prop: 'table_comment', label: 'page.table.tableDesc', minWidth: 150, align: 'left' },
|
||||
{ prop: 'template', label: 'page.table.template', minWidth: 120 },
|
||||
{ prop: 'namespace', label: 'page.table.namespace', minWidth: 120 },
|
||||
{ prop: 'stub', label: 'page.table.stub', minWidth: 120 },
|
||||
{ prop: 'tpl_category', label: 'page.table.tplCategory', minWidth: 120, useSlot: true },
|
||||
{ prop: 'update_time', label: 'page.table.updateTime', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 220, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
@search="handleSearch"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="表名称" prop="table_name">
|
||||
<el-input v-model="formData.table_name" placeholder="请输入数据表名称" clearable />
|
||||
<el-form-item :label="$t('page.search.tableName')" prop="table_name">
|
||||
<el-input v-model="formData.table_name" :placeholder="$t('page.search.placeholderTableName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="数据源" prop="source">
|
||||
<el-input v-model="formData.source" placeholder="请输入数据源名称" clearable />
|
||||
<el-form-item :label="$t('page.search.placeholderDataSource')" prop="source">
|
||||
<el-input v-model="formData.source" :placeholder="$t('page.search.placeholderDataSource')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
@@ -115,20 +115,20 @@
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'id', label: '编号', width: 100, align: 'center' },
|
||||
{ prop: 'name', label: '任务名称', minWidth: 120 },
|
||||
{ prop: 'id', label: 'page.table.no', width: 100, align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.taskName', minWidth: 120 },
|
||||
{
|
||||
prop: 'type',
|
||||
label: '任务类型',
|
||||
label: 'page.table.taskType',
|
||||
saiType: 'dict',
|
||||
saiDict: 'crontab_task_type',
|
||||
minWidth: 120
|
||||
},
|
||||
{ prop: 'rule', label: '定时规则', minWidth: 140 },
|
||||
{ prop: 'target', label: '调用目标', minWidth: 200, showOverflowTooltip: true },
|
||||
{ prop: 'status', label: '状态', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'update_time', label: '更新日期', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: '操作', width: 180, fixed: 'right', useSlot: true }
|
||||
{ prop: 'rule', label: 'page.table.rule', minWidth: 140 },
|
||||
{ prop: 'target', label: 'page.table.target', minWidth: 200, showOverflowTooltip: true },
|
||||
{ prop: 'status', label: 'page.table.status', saiType: 'dict', saiDict: 'data_status', width: 100 },
|
||||
{ prop: 'update_time', label: 'page.table.updateDate', width: 180, sortable: true },
|
||||
{ prop: 'operation', label: 'table.actions.operation', width: 180, fixed: 'right', useSlot: true }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增定时任务' : '编辑定时任务'"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="800px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="任务名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入任务名称" />
|
||||
<el-form-item :label="$t('page.form.labelName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderName')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="任务类型" prop="type">
|
||||
<el-form-item :label="$t('page.form.labelType')" prop="type">
|
||||
<sa-select v-model="formData.type" dict="crontab_task_type" />
|
||||
</el-form-item>
|
||||
<el-form-item label="定时规则" prop="task_style">
|
||||
<el-form-item :label="$t('page.form.labelTaskStyle')" prop="task_style">
|
||||
<el-space>
|
||||
<el-select v-model="formData.task_style" :style="{ width: '100px' }">
|
||||
<el-option :value="1" label="每天" />
|
||||
<el-option :value="2" label="每小时" />
|
||||
<el-option :value="3" label="N小时" />
|
||||
<el-option :value="4" label="N分钟" />
|
||||
<el-option :value="5" label="N秒" />
|
||||
<el-option :value="6" label="每周" />
|
||||
<el-option :value="7" label="每月" />
|
||||
<el-option :value="8" label="每年" />
|
||||
<el-option :value="1" :label="$t('page.form.taskStyleEveryDay')" />
|
||||
<el-option :value="2" :label="$t('page.form.taskStyleEveryHour')" />
|
||||
<el-option :value="3" :label="$t('page.form.taskStyleNHours')" />
|
||||
<el-option :value="4" :label="$t('page.form.taskStyleNMinutes')" />
|
||||
<el-option :value="5" :label="$t('page.form.taskStyleNSeconds')" />
|
||||
<el-option :value="6" :label="$t('page.form.taskStyleEveryWeek')" />
|
||||
<el-option :value="7" :label="$t('page.form.taskStyleEveryMonth')" />
|
||||
<el-option :value="8" :label="$t('page.form.taskStyleEveryYear')" />
|
||||
</el-select>
|
||||
<template v-if="formData.task_style == 8">
|
||||
<el-input-number
|
||||
@@ -35,7 +35,7 @@
|
||||
controls-position="right"
|
||||
:style="{ width: '100px' }"
|
||||
/>
|
||||
<span>月</span>
|
||||
<span>{{ $t('page.form.unitMonth') }}</span>
|
||||
</template>
|
||||
<template v-if="formData.task_style > 6">
|
||||
<el-input-number
|
||||
@@ -46,20 +46,20 @@
|
||||
controls-position="right"
|
||||
:style="{ width: '100px' }"
|
||||
/>
|
||||
<span>日</span>
|
||||
<span>{{ $t('page.form.unitDay') }}</span>
|
||||
</template>
|
||||
<el-select
|
||||
v-if="formData.task_style == 6"
|
||||
v-model="formData.week"
|
||||
:style="{ width: '100px' }"
|
||||
>
|
||||
<el-option :value="1" label="周一" />
|
||||
<el-option :value="2" label="周二" />
|
||||
<el-option :value="3" label="周三" />
|
||||
<el-option :value="4" label="周四" />
|
||||
<el-option :value="5" label="周五" />
|
||||
<el-option :value="6" label="周六" />
|
||||
<el-option :value="0" label="周日" />
|
||||
<el-option :value="1" :label="$t('page.form.weekMon')" />
|
||||
<el-option :value="2" :label="$t('page.form.weekTue')" />
|
||||
<el-option :value="3" :label="$t('page.form.weekWed')" />
|
||||
<el-option :value="4" :label="$t('page.form.weekThu')" />
|
||||
<el-option :value="5" :label="$t('page.form.weekFri')" />
|
||||
<el-option :value="6" :label="$t('page.form.weekSat')" />
|
||||
<el-option :value="0" :label="$t('page.form.weekSun')" />
|
||||
</el-select>
|
||||
<template v-if="[1, 3, 6, 7, 8].includes(formData.task_style)">
|
||||
<el-input-number
|
||||
@@ -70,7 +70,7 @@
|
||||
controls-position="right"
|
||||
:style="{ width: '100px' }"
|
||||
/>
|
||||
<span>时</span>
|
||||
<span>{{ $t('page.form.unitHour') }}</span>
|
||||
</template>
|
||||
<template v-if="formData.task_style != 5">
|
||||
<el-input-number
|
||||
@@ -81,7 +81,7 @@
|
||||
controls-position="right"
|
||||
:style="{ width: '100px' }"
|
||||
/>
|
||||
<span>分</span>
|
||||
<span>{{ $t('page.form.unitMinute') }}</span>
|
||||
</template>
|
||||
<template v-if="formData.task_style == 5">
|
||||
<el-input-number
|
||||
@@ -92,36 +92,41 @@
|
||||
controls-position="right"
|
||||
:style="{ width: '100px' }"
|
||||
/>
|
||||
<span>秒</span>
|
||||
<span>{{ $t('page.form.unitSecond') }}</span>
|
||||
</template>
|
||||
</el-space>
|
||||
</el-form-item>
|
||||
<el-form-item label="调用目标" prop="target">
|
||||
<el-form-item :label="$t('page.form.labelTarget')" prop="target">
|
||||
<el-input
|
||||
v-model="formData.target"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入调用目标"
|
||||
:placeholder="$t('page.form.placeholderTarget')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="任务参数" prop="params">
|
||||
<el-form-item :label="$t('page.form.labelParams')" prop="params">
|
||||
<el-input
|
||||
v-model="formData.parameter"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入任务参数"
|
||||
:placeholder="$t('page.form.placeholderParams')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-form-item :label="$t('page.form.labelStatus')" prop="status">
|
||||
<sa-radio v-model="formData.status" dict="data_status" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="请输入备注" />
|
||||
<el-form-item :label="$t('page.form.labelRemark')" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
:placeholder="$t('page.form.placeholderRemark')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('table.form.submit') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -130,6 +135,7 @@
|
||||
import api from '@/api/tool/crontab'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -149,6 +155,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -163,12 +170,12 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
name: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
|
||||
type: [{ required: true, message: '任务类型不能为空', trigger: 'blur' }],
|
||||
task_style: [{ required: true, message: '定时规则不能为空', trigger: 'blur' }],
|
||||
target: [{ required: true, message: '调用目标不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
type: [{ required: true, message: t('page.form.ruleTypeRequired'), trigger: 'blur' }],
|
||||
task_style: [{ required: true, message: t('page.form.ruleTaskStyleRequired'), trigger: 'blur' }],
|
||||
target: [{ required: true, message: t('page.form.ruleTargetRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -264,10 +271,10 @@
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -212,10 +212,10 @@
|
||||
},
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'create_time', label: '执行时间', sortable: true },
|
||||
{ prop: 'target', label: '调用目标' },
|
||||
{ prop: 'parameter', label: '任务参数' },
|
||||
{ prop: 'status', label: '执行状态', useSlot: true, width: 100 }
|
||||
{ prop: 'create_time', label: 'page.table.executeTime', sortable: true },
|
||||
{ prop: 'target', label: 'page.table.target' },
|
||||
{ prop: 'parameter', label: 'page.table.parameter' },
|
||||
{ prop: 'status', label: 'page.table.executeStatus', useSlot: true, width: 100 }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="任务名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入任务名称" clearable />
|
||||
<el-form-item :label="$t('page.search.taskName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderTaskName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="任务类型" prop="type">
|
||||
<sa-select v-model="formData.type" dict="crontab_task_type" clearable />
|
||||
<el-form-item :label="$t('page.search.taskType')" prop="type">
|
||||
<sa-select v-model="formData.type" dict="crontab_task_type" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" clearable />
|
||||
<el-form-item :label="$t('page.search.status')" prop="status">
|
||||
<sa-select v-model="formData.status" dict="data_status" :placeholder="$t('page.search.searchSelectPlaceholder')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
|
||||
@@ -1,37 +1,43 @@
|
||||
# 数据库配置
|
||||
DB_TYPE = mysql
|
||||
DB_HOST = 127.0.0.1
|
||||
DB_PORT = 3306
|
||||
DB_NAME = saiadmin
|
||||
DB_USER = root
|
||||
DB_PASSWORD = 123456
|
||||
DB_PREFIX =
|
||||
DB_TYPE=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_NAME=saiadmin
|
||||
DB_USER=root
|
||||
DB_PASSWORD=123456
|
||||
DB_PREFIX=
|
||||
DB_POOL_MAX=32
|
||||
DB_POOL_MIN=4
|
||||
|
||||
# 缓存方式,支持file|redis(API 用户登录缓存需使用 redis)
|
||||
CACHE_MODE = redis
|
||||
CACHE_MODE=redis
|
||||
REDIS_POOL_MAX=32
|
||||
|
||||
# Redis配置
|
||||
REDIS_HOST = 127.0.0.1
|
||||
REDIS_PORT = 6379
|
||||
REDIS_PASSWORD = ''
|
||||
REDIS_DB = 0
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=''
|
||||
REDIS_DB=0
|
||||
|
||||
# 游戏地址,用于 /api/v1/getGameUrl 返回
|
||||
GAME_URL=dice-game.yuliao666.top
|
||||
|
||||
# API 鉴权与用户(可选,不填则用默认值)
|
||||
# authToken 签名密钥(必填,与客户端约定,用于 signature 校验)
|
||||
API_AUTH_TOKEN_SECRET = xF75oK91TQj13s0UmNIr1NBWMWGfflNO
|
||||
API_AUTH_TOKEN_SECRET=xF75oK91TQj13s0UmNIr1NBWMWGfflNO
|
||||
# authToken 时间戳允许误差秒数,防重放,默认 300
|
||||
API_AUTH_TOKEN_TIME_TOLERANCE = 300
|
||||
API_AUTH_TOKEN_EXP = 86400
|
||||
# API_USER_TOKEN_EXP = 604800
|
||||
API_USER_CACHE_EXPIRE = 86400
|
||||
API_USER_ENCRYPT_KEY = Wj818SK8dhKBKNOY3PUTmZfhQDMCXEZi
|
||||
API_AUTH_TOKEN_TIME_TOLERANCE=300
|
||||
API_AUTH_TOKEN_EXP=86400
|
||||
# API_USER_TOKEN_EXP=604800
|
||||
API_USER_CACHE_EXPIRE=86400
|
||||
API_USER_ENCRYPT_KEY=Wj818SK8dhKBKNOY3PUTmZfhQDMCXEZi
|
||||
|
||||
# 验证码配置,支持cache|session
|
||||
CAPTCHA_MODE = cache
|
||||
LOGIN_CAPTCHA_ENABLE = false
|
||||
CAPTCHA_MODE=cache
|
||||
LOGIN_CAPTCHA_ENABLE=false
|
||||
|
||||
#前端目录
|
||||
FRONTEND_DIR = saiadmin-vue
|
||||
FRONTEND_DIR=saiadmin-vue
|
||||
|
||||
#生成环境
|
||||
APP_DEBUG = false
|
||||
APP_DEBUG=false
|
||||
83
server/app/api/cache/AuthTokenCache.php
vendored
Normal file
83
server/app/api/cache/AuthTokenCache.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\cache;
|
||||
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
* 平台 auth-token Redis 缓存
|
||||
* 用于 /api/v1/authToken 鉴权接口颁发的 token 存储与校验
|
||||
*/
|
||||
class AuthTokenCache
|
||||
{
|
||||
private static function devicePrefix(): string
|
||||
{
|
||||
return config('api.auth_token_device_prefix', 'api:auth_token:');
|
||||
}
|
||||
|
||||
private static function tokenPrefix(): string
|
||||
{
|
||||
return config('api.auth_token_prefix', 'api:auth_token:t:');
|
||||
}
|
||||
|
||||
private static function expire(): int
|
||||
{
|
||||
return (int) config('api.auth_token_exp', 86400);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储 auth-token(同一 agent_id 只保留最新一个)
|
||||
* @param string $agentId 代理 ID
|
||||
* @param string $token 生成的 auth-token
|
||||
*/
|
||||
public static function setToken(string $agentId, string $token): bool
|
||||
{
|
||||
if ($agentId === '' || $token === '') {
|
||||
return false;
|
||||
}
|
||||
$exp = self::expire();
|
||||
if ($exp <= 0) {
|
||||
return false;
|
||||
}
|
||||
$oldToken = Cache::get(self::devicePrefix() . $agentId);
|
||||
if ($oldToken !== null && $oldToken !== '') {
|
||||
Cache::delete(self::tokenPrefix() . $oldToken);
|
||||
}
|
||||
Cache::set(self::tokenPrefix() . $token, $agentId, $exp);
|
||||
Cache::set(self::devicePrefix() . $agentId, $token, $exp);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 agent_id 获取当前有效的 token,不存在或已过期返回 null
|
||||
*/
|
||||
public static function getTokenByAgentId(string $agentId): ?string
|
||||
{
|
||||
if ($agentId === '') {
|
||||
return null;
|
||||
}
|
||||
$val = Cache::get(self::devicePrefix() . $agentId);
|
||||
return $val !== null && $val !== '' ? (string) $val : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 auth-token 获取 agent_id,不存在或已过期返回 null
|
||||
*/
|
||||
public static function getAgentIdByToken(string $token): ?string
|
||||
{
|
||||
if ($token === '') {
|
||||
return null;
|
||||
}
|
||||
$val = Cache::get(self::tokenPrefix() . $token);
|
||||
return $val !== null && $val !== '' ? (string) $val : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 auth-token 是否有效
|
||||
*/
|
||||
public static function isValidToken(string $token): bool
|
||||
{
|
||||
return self::getAgentIdByToken($token) !== null;
|
||||
}
|
||||
}
|
||||
36
server/app/api/controller/BaseController.php
Normal file
36
server/app/api/controller/BaseController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\util\ApiLang;
|
||||
use plugin\saiadmin\basic\OpenController;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* API 控制器基类:根据请求头 lang(en=英文,zh=中文)对返回 message 做双语适配
|
||||
*/
|
||||
class BaseController extends OpenController
|
||||
{
|
||||
/**
|
||||
* 成功返回,message 按请求头 lang(en/zh)翻译
|
||||
*/
|
||||
public function success(array|string $data = [], string $msg = 'success', int $option = JSON_UNESCAPED_UNICODE): Response
|
||||
{
|
||||
if (is_string($data)) {
|
||||
$msg = $data;
|
||||
$data = [];
|
||||
}
|
||||
$msg = ApiLang::translate((string) $msg);
|
||||
return parent::success($data, $msg, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回,message 按 lang 翻译
|
||||
*/
|
||||
public function fail(string $msg = 'fail', int $code = 400): Response
|
||||
{
|
||||
$msg = ApiLang::translate($msg);
|
||||
return parent::fail($msg, $code);
|
||||
}
|
||||
}
|
||||
@@ -6,39 +6,62 @@ namespace app\api\controller;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
use app\api\logic\GameLogic;
|
||||
use app\api\logic\PlayStartLogic;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\dice\model\config\DiceConfig;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use plugin\saiadmin\basic\OpenController;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use app\api\controller\BaseController;
|
||||
use app\api\util\ApiLang;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
|
||||
/**
|
||||
* 游戏相关接口(购买抽奖券等)
|
||||
*/
|
||||
class GameController extends OpenController
|
||||
class GameController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取游戏配置(按 group 分组)
|
||||
* GET /api/game/config
|
||||
* header: lang = zh | en
|
||||
* 返回 data[group] = [ { name, title, value, create_time, update_time }, ... ]
|
||||
* - lang=zh 或默认:title/value = 中文
|
||||
* - lang=en:若存在英文配置则返回 title_en/value_en,否则回退到中文
|
||||
*/
|
||||
public function config(Request $request): Response
|
||||
{
|
||||
$rows = DiceConfig::select('name', 'group', 'title', 'value', 'create_time', 'update_time')->get();
|
||||
$rows = DiceConfig::select('name', 'group', 'title', 'title_en', 'value', 'value_en', 'create_time', 'update_time')->get();
|
||||
$lang = $request->header('lang', 'zh');
|
||||
if (!is_string($lang) || $lang === '') {
|
||||
$lang = 'zh';
|
||||
}
|
||||
$langLower = strtolower($lang);
|
||||
$isEn = $langLower === 'en' || str_starts_with($langLower, 'en-');
|
||||
$data = [];
|
||||
foreach ($rows as $row) {
|
||||
$group = $row->group ?? '';
|
||||
if (!isset($data[$group])) {
|
||||
$data[$group] = [];
|
||||
}
|
||||
$title = $row->title;
|
||||
$value = $row->value;
|
||||
if ($isEn) {
|
||||
$titleEn = $row->title_en ?? '';
|
||||
$valueEn = $row->value_en ?? '';
|
||||
if ($titleEn !== '') {
|
||||
$title = $titleEn;
|
||||
}
|
||||
if ($valueEn !== '') {
|
||||
$value = $valueEn;
|
||||
}
|
||||
}
|
||||
$data[$group][] = [
|
||||
'name' => $row->name,
|
||||
'title' => $row->title,
|
||||
'value' => $row->value,
|
||||
'title' => $title,
|
||||
'value' => $value,
|
||||
'create_time' => $row->create_time,
|
||||
'update_time' => $row->update_time,
|
||||
];
|
||||
@@ -57,7 +80,7 @@ class GameController extends OpenController
|
||||
$userId = (int) ($request->player_id ?? 0);
|
||||
$count = (int) $request->post('count', 0);
|
||||
if (!in_array($count, [1, 5, 10], true)) {
|
||||
return $this->fail('购买抽奖券错误', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('Invalid lottery ticket purchase', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -79,11 +102,35 @@ class GameController extends OpenController
|
||||
* 获取彩金池(中奖配置表)
|
||||
* GET /api/game/lotteryPool
|
||||
* header: token
|
||||
* 返回 DiceRewardConfig 列表(彩金池/中奖配置)
|
||||
* 返回 DiceRewardConfig 列表(彩金池/中奖配置),不包含 tier=BIGWIN
|
||||
*/
|
||||
public function lotteryPool(Request $request): Response
|
||||
{
|
||||
$list = DiceRewardConfig::getCachedList();
|
||||
$list = array_values(array_filter($list, function ($row) {
|
||||
return (string) ($row['tier'] ?? '') !== 'BIGWIN';
|
||||
}));
|
||||
|
||||
$lang = $request->header('lang', 'zh');
|
||||
if (!is_string($lang) || $lang === '') {
|
||||
$lang = 'zh';
|
||||
}
|
||||
$langLower = strtolower($lang);
|
||||
$isEn = $langLower === 'en' || str_starts_with($langLower, 'en-');
|
||||
|
||||
if ($isEn) {
|
||||
foreach ($list as $index => $row) {
|
||||
$uiEn = '';
|
||||
if (is_array($row) && array_key_exists('ui_text_en', $row) && $row['ui_text_en'] !== null) {
|
||||
$uiEn = (string) $row['ui_text_en'];
|
||||
}
|
||||
if ($uiEn !== '') {
|
||||
$row['ui_text'] = $uiEn;
|
||||
}
|
||||
$list[$index] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
@@ -101,23 +148,60 @@ class GameController extends OpenController
|
||||
$direction = (int) $direction;
|
||||
}
|
||||
if (!in_array($direction, [0, 1], true)) {
|
||||
return $this->fail('direction 必须为 0 或 1', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('direction must be 0 or 1', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::find($userId);
|
||||
if (!$player) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
$minEv = DiceRewardConfig::getCachedMinRealEv();
|
||||
$minCoin = abs($minEv + 100);
|
||||
$coin = (float) $player->coin;
|
||||
if ($coin < $minCoin) {
|
||||
return $this->success([], '当前玩家余额'.$coin.'小于'.$minCoin.'无法继续游戏');
|
||||
$msg = ApiLang::translateParams('Balance %s is less than %s, cannot continue', [$coin, $minCoin], $request);
|
||||
return $this->success([], $msg);
|
||||
}
|
||||
|
||||
$lockName = 'play_start_' . $userId;
|
||||
$lockResult = Db::query('SELECT GET_LOCK(?, 30) as l', [$lockName]);
|
||||
if (empty($lockResult) || (int) ($lockResult[0]['l'] ?? 0) !== 1) {
|
||||
return $this->fail('too many requests, please try again later', ReturnCode::BUSINESS_ERROR);
|
||||
}
|
||||
try {
|
||||
$logic = new PlayStartLogic();
|
||||
$data = $logic->run($userId, (int)$direction);
|
||||
|
||||
$lang = $request->header('lang', 'zh');
|
||||
if (!is_string($lang) || $lang === '') {
|
||||
$lang = 'zh';
|
||||
}
|
||||
$langLower = strtolower($lang);
|
||||
$isEn = $langLower === 'en' || str_starts_with($langLower, 'en-');
|
||||
|
||||
if (is_array($data) && array_key_exists('reward_config_id', $data)) {
|
||||
$rewardConfigId = (int) $data['reward_config_id'];
|
||||
if ($rewardConfigId > 0) {
|
||||
$configRow = DiceRewardConfig::getCachedById($rewardConfigId);
|
||||
if ($configRow !== null) {
|
||||
$uiText = '';
|
||||
$uiTextEn = '';
|
||||
if (array_key_exists('ui_text', $configRow) && $configRow['ui_text'] !== null) {
|
||||
$uiText = (string) $configRow['ui_text'];
|
||||
}
|
||||
if (array_key_exists('ui_text_en', $configRow) && $configRow['ui_text_en'] !== null) {
|
||||
$uiTextEn = (string) $configRow['ui_text_en'];
|
||||
}
|
||||
if ($isEn && $uiTextEn !== '') {
|
||||
$data['ui_text'] = $uiTextEn;
|
||||
} else {
|
||||
$data['ui_text'] = $uiText;
|
||||
}
|
||||
$data['ui_text_en'] = $uiTextEn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
} catch (ApiException $e) {
|
||||
return $this->fail($e->getMessage(), ReturnCode::BUSINESS_ERROR);
|
||||
@@ -132,18 +216,29 @@ class GameController extends OpenController
|
||||
]);
|
||||
$timeoutRecord = null;
|
||||
$timeout_message = '';
|
||||
$adminId = null;
|
||||
try {
|
||||
$timeoutPlayer = DicePlayer::find($userId);
|
||||
$adminId = ($timeoutPlayer && ($timeoutPlayer->admin_id ?? null)) ? (int) $timeoutPlayer->admin_id : null;
|
||||
} catch (\Throwable $_) {
|
||||
}
|
||||
try {
|
||||
$timeoutRecord = DicePlayRecord::create([
|
||||
'player_id' => $userId,
|
||||
'admin_id' => $adminId,
|
||||
'lottery_config_id' => 0,
|
||||
'lottery_type' => 0,
|
||||
'is_win' => 0,
|
||||
'win_coin' => 0,
|
||||
'super_win_coin' => 0,
|
||||
'reward_win_coin' => 0,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => 0,
|
||||
'start_index' => 0,
|
||||
'target_index' => 0,
|
||||
'roll_array' => '[]',
|
||||
'roll_number' => 0,
|
||||
'status' => PlayStartLogic::RECORD_STATUS_TIMEOUT,
|
||||
]);
|
||||
} catch (\Exception $inner) {
|
||||
@@ -155,7 +250,9 @@ class GameController extends OpenController
|
||||
if ($msg === '') {
|
||||
$msg = '没有原因';
|
||||
}
|
||||
return $this->fail('服务超时,' . $msg);
|
||||
return $this->fail('Service timeout: ' . $msg);
|
||||
} finally {
|
||||
Db::execute('SELECT RELEASE_LOCK(?)', [$lockName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ use app\api\logic\UserLogic;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use plugin\saiadmin\basic\OpenController;
|
||||
use app\api\controller\BaseController;
|
||||
|
||||
/**
|
||||
* API 用户登录等
|
||||
* 登录接口 /api/user/Login 无需 token;其余接口需在请求头携带 token(base64(username.-.time)),由 TokenMiddleware 鉴权并注入 request->player_id / request->player
|
||||
*/
|
||||
class UserController extends OpenController
|
||||
class UserController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 登录(form-data 参数)
|
||||
@@ -34,7 +34,7 @@ class UserController extends OpenController
|
||||
$time = $request->post('time');
|
||||
$time = $time !== null && $time !== '' ? (string) $time : (string) time();
|
||||
if ($username === '' || $password === '') {
|
||||
return $this->fail('username、password 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('USERNAME_PASSWORD_REQUIRED', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -68,15 +68,15 @@ class UserController extends OpenController
|
||||
}
|
||||
$token = $token !== null ? trim((string) $token) : '';
|
||||
if ($token === '') {
|
||||
return $this->fail('请携带 token', ReturnCode::UNAUTHORIZED);
|
||||
return $this->fail('Please provide token', ReturnCode::UNAUTHORIZED);
|
||||
}
|
||||
$username = UserLogic::getUsernameFromJwtPayload($token);
|
||||
if ($username === null || $username === '') {
|
||||
return $this->fail('token 无效', ReturnCode::TOKEN_INVALID);
|
||||
return $this->fail('Invalid or expired token', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
UserCache::deleteSessionByUsername($username);
|
||||
UserCache::deletePlayerByUsername($username);
|
||||
return $this->success('已退出登录');
|
||||
return $this->success('Logged out successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ class UserController extends OpenController
|
||||
$userId = (int) ($request->player_id ?? 0);
|
||||
$user = UserLogic::getCachedUser($userId);
|
||||
if (empty($user)) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
$fields = ['id', 'username', 'phone', 'uid', 'name', 'coin', 'total_ticket_count'];
|
||||
$info = [];
|
||||
@@ -111,7 +111,7 @@ class UserController extends OpenController
|
||||
$userId = (int) ($request->player_id ?? 0);
|
||||
$user = UserLogic::getCachedUser($userId);
|
||||
if (empty($user)) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
$coin = $user['coin'] ?? 0;
|
||||
if (is_string($coin) && is_numeric($coin)) {
|
||||
|
||||
73
server/app/api/controller/v1/AuthTokenController.php
Normal file
73
server/app/api/controller/v1/AuthTokenController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\api\cache\AuthTokenCache;
|
||||
use app\api\controller\BaseController;
|
||||
use app\api\util\ReturnCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
|
||||
/**
|
||||
* 平台鉴权接口
|
||||
* 鉴权接口:/api/v1/authtoken
|
||||
* GET 参数:signature, secret, time, agent_id
|
||||
* 签名:signature = md5(agent_id.secret.time)
|
||||
*/
|
||||
class AuthTokenController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取 auth-token
|
||||
* GET 参数:signature, secret, time, agent_id
|
||||
* 返回 authtoken,后续 /api/v1/* 接口需在请求头携带 auth-token
|
||||
*/
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$agentId = trim((string) ($request->get('agent_id', '')));
|
||||
$secret = trim((string) ($request->get('secret', '')));
|
||||
$time = trim((string) ($request->get('time', '')));
|
||||
$signature = trim((string) ($request->get('signature', '')));
|
||||
|
||||
if ($agentId === '' || $secret === '' || $time === '' || $signature === '') {
|
||||
return $this->fail('Missing parameters: agent_id, secret, time, signature are required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$expectedSecret = config('api.auth_token_secret', '');
|
||||
if ($expectedSecret === '') {
|
||||
return $this->fail('API_AUTH_TOKEN_SECRET is not configured', ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
if ($secret !== $expectedSecret) {
|
||||
return $this->fail('Invalid secret', ReturnCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
$timeVal = (int) $time;
|
||||
$tolerance = (int) config('api.auth_token_time_tolerance', 300);
|
||||
$now = time();
|
||||
if ($timeVal < $now - $tolerance || $timeVal > $now + $tolerance) {
|
||||
return $this->fail('Timestamp expired or invalid, please sync time', ReturnCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
$expectedSignature = md5($agentId . $secret . $time);
|
||||
if ($signature !== $expectedSignature) {
|
||||
return $this->fail('Signature verification failed', ReturnCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
$exp = (int) config('api.auth_token_exp', 86400);
|
||||
$tokenResult = JwtToken::generateToken([
|
||||
'id' => 0,
|
||||
'agent_id' => $agentId,
|
||||
'plat' => 'api_auth_token',
|
||||
'access_exp' => $exp,
|
||||
]);
|
||||
$token = $tokenResult['access_token'];
|
||||
if (!AuthTokenCache::setToken($agentId, $token)) {
|
||||
return $this->fail('Failed to generate token', ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
'authtoken' => $token,
|
||||
]);
|
||||
}
|
||||
}
|
||||
313
server/app/api/controller/v1/GameController.php
Normal file
313
server/app/api/controller/v1/GameController.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\api\logic\UserLogic;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
|
||||
use support\think\Db;
|
||||
use app\api\controller\BaseController;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\api\cache\UserCache;
|
||||
|
||||
/**
|
||||
* 平台 v1 游戏接口
|
||||
* 请求头:auth-token
|
||||
*/
|
||||
class GameController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取游戏地址
|
||||
* 根据 username 创建登录 token(JWT),拼接游戏地址返回
|
||||
*/
|
||||
public function getGameUrl(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
$password = trim((string) ($request->post('password', '123456')));
|
||||
$time = trim((string) ($request->post('time', '')));
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
if ($password === '') {
|
||||
$password = '123456';
|
||||
}
|
||||
if ($time === '') {
|
||||
$time = (string) time();
|
||||
}
|
||||
|
||||
$adminId = null;
|
||||
$adminIdsInTopDept = null;
|
||||
$agentId = trim((string) ($request->agent_id ?? ''));
|
||||
if ($agentId !== '') {
|
||||
$systemUser = SystemUser::where('agent_id', $agentId)->find();
|
||||
if ($systemUser) {
|
||||
$adminId = (int) $systemUser->id;
|
||||
$adminIdsInTopDept = UserLogic::getAdminIdsByAgentIdTopDept($agentId);
|
||||
}
|
||||
}
|
||||
|
||||
$lang = trim((string) ($request->post('lang', 'zh')));
|
||||
$lang = in_array($lang, ['en', 'zh'], true) ? $lang : 'zh';
|
||||
|
||||
try {
|
||||
$logic = new UserLogic();
|
||||
$result = $logic->loginByUsername($username, $password, $lang === 'en' ? 'en' : 'chs', 0.0, $time, $adminId, $adminIdsInTopDept);
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage(), ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$gameUrlBase = rtrim(config('api.game_url', 'dice-game.yuliao666.top'), '/');
|
||||
$tokenInUrl = str_replace('%3D', '=', urlencode($result['token']));
|
||||
$url = $gameUrlBase . '/?token=' . $tokenInUrl . '&lang=' . $lang;
|
||||
|
||||
return $this->success([
|
||||
'url' => $url,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* POST 参数:username
|
||||
* 返回 DicePlayer 中非敏感信息
|
||||
*/
|
||||
public function getPlayerInfo(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
$hidden = ['password', 'lottery_config_id', 't1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight', 'delete_time'];
|
||||
$info = $player->hidden($hidden)->toArray();
|
||||
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏记录
|
||||
* POST 参数:username(非必填,没填则不按用户筛选), start_create_time, end_create_time(非必填,没填则不筛选时间)
|
||||
* 返回 DicePlayRecord 中非敏感信息
|
||||
*/
|
||||
public function getPlayerGameRecord(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
$startCreateTime = trim((string) ($request->post('start_create_time', '')));
|
||||
$endCreateTime = trim((string) ($request->post('end_create_time', '')));
|
||||
$page = (int) $request->post('page', 1);
|
||||
$limit = (int) $request->post('limit', 20);
|
||||
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
}
|
||||
if ($limit < 1 || $limit > 100) {
|
||||
$limit = 20;
|
||||
}
|
||||
|
||||
$query = DicePlayRecord::order('id', 'desc');
|
||||
|
||||
if ($username !== '') {
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->success([]);
|
||||
}
|
||||
$query->where('player_id', (int) $player->id);
|
||||
}
|
||||
|
||||
if ($startCreateTime !== '') {
|
||||
$query->where('create_time', '>=', $startCreateTime);
|
||||
}
|
||||
if ($endCreateTime !== '') {
|
||||
$query->where('create_time', '<=', $endCreateTime);
|
||||
}
|
||||
|
||||
$list = $query->page($page, $limit)->select()->toArray();
|
||||
$playerIds = array_unique(array_column($list, 'player_id'));
|
||||
if (!empty($playerIds)) {
|
||||
$players = DicePlayer::whereIn('id', $playerIds)->field('id,username,phone')->select()->toArray();
|
||||
$playerMap = [];
|
||||
foreach ($players as $p) {
|
||||
$playerMap[(int) ($p['id'] ?? 0)] = $p;
|
||||
}
|
||||
foreach ($list as &$item) {
|
||||
$item['dice_player'] = $playerMap[(int) ($item['player_id'] ?? 0)] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取钱包流水
|
||||
* POST 参数:username(非必填,没填则不按用户筛选), start_create_time, end_create_time(非必填,没填则不筛选时间)
|
||||
* 返回 DicePlayerWalletRecord 中非敏感信息
|
||||
*/
|
||||
public function getPlayerWalletRecord(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
$startCreateTime = trim((string) ($request->post('start_create_time', '')));
|
||||
$endCreateTime = trim((string) ($request->post('end_create_time', '')));
|
||||
$page = (int) $request->post('page', 1);
|
||||
$limit = (int) $request->post('limit', 20);
|
||||
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
}
|
||||
if ($limit < 1 || $limit > 100) {
|
||||
$limit = 20;
|
||||
}
|
||||
|
||||
$query = DicePlayerWalletRecord::order('id', 'desc');
|
||||
|
||||
if ($username !== '') {
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->success([]);
|
||||
}
|
||||
$query->where('player_id', (int) $player->id);
|
||||
}
|
||||
|
||||
if ($startCreateTime !== '') {
|
||||
$query->where('create_time', '>=', $startCreateTime);
|
||||
}
|
||||
if ($endCreateTime !== '') {
|
||||
$query->where('create_time', '<=', $endCreateTime);
|
||||
}
|
||||
|
||||
$list = $query->with(['dicePlayer' => function ($q) {
|
||||
$q->field('id,username,phone');
|
||||
}])->page($page, $limit)->select()->toArray();
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户中奖券获取记录
|
||||
* POST 参数:username(非必填,没填则不按用户筛选), start_create_time, end_create_time(非必填,没填则不筛选时间)
|
||||
* 返回 DicePlayerTicketRecord 中非敏感信息
|
||||
*/
|
||||
public function getPlayerTicketRecord(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
$startCreateTime = trim((string) ($request->post('start_create_time', '')));
|
||||
$endCreateTime = trim((string) ($request->post('end_create_time', '')));
|
||||
$page = (int) $request->post('page', 1);
|
||||
$limit = (int) $request->post('limit', 20);
|
||||
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
}
|
||||
if ($limit < 1 || $limit > 100) {
|
||||
$limit = 20;
|
||||
}
|
||||
|
||||
$query = DicePlayerTicketRecord::order('id', 'desc');
|
||||
|
||||
if ($username !== '') {
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->success([]);
|
||||
}
|
||||
$query->where('player_id', (int) $player->id);
|
||||
}
|
||||
|
||||
if ($startCreateTime !== '') {
|
||||
$query->where('create_time', '>=', $startCreateTime);
|
||||
}
|
||||
if ($endCreateTime !== '') {
|
||||
$query->where('create_time', '<=', $endCreateTime);
|
||||
}
|
||||
|
||||
$list = $query->with(['dicePlayer' => function ($q) {
|
||||
$q->field('id,username,phone');
|
||||
}])->page($page, $limit)->select()->toArray();
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包转入转出
|
||||
* POST 参数:username(必填), coin(转入>0 或 转出<0)
|
||||
* 创建 DicePlayerWalletRecord,type: 0=充值(coin>0), 1=提现(coin<0)
|
||||
* 返回创建的记录
|
||||
*/
|
||||
public function setPlayerWallet(Request $request): Response
|
||||
{
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
$coin = $request->post('coin');
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
if ($coin === null || $coin === '') {
|
||||
return $this->fail('coin is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$coinVal = (float) $coin;
|
||||
if ($coinVal === 0.0) {
|
||||
return $this->fail('coin cannot be 0', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
$walletBefore = (float) ($player->coin ?? 0);
|
||||
$walletAfter = $walletBefore + $coinVal;
|
||||
|
||||
if ($coinVal < 0 && $walletBefore < -$coinVal) {
|
||||
return $this->fail('Insufficient balance to transfer', ReturnCode::BUSINESS_ERROR);
|
||||
}
|
||||
|
||||
$type = $coinVal > 0 ? 0 : 1;
|
||||
$remark = $coinVal > 0 ? '充值' : '提现';
|
||||
|
||||
try {
|
||||
Db::startTrans();
|
||||
$player->coin = $walletAfter;
|
||||
$player->save();
|
||||
|
||||
$adminId = ($player->admin_id ?? null) ? (int) $player->admin_id : null;
|
||||
$record = DicePlayerWalletRecord::create([
|
||||
'player_id' => (int) $player->id,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => $coinVal,
|
||||
'type' => $type,
|
||||
'wallet_before' => $walletBefore,
|
||||
'wallet_after' => $walletAfter,
|
||||
'total_ticket_count' => 0,
|
||||
'paid_ticket_count' => 0,
|
||||
'free_ticket_count' => 0,
|
||||
'remark' => $remark,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return $this->fail('Operation failed: ' . $e->getMessage(), ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 出于安全:删除该玩家相关缓存,后续 API 调用按需重建
|
||||
UserCache::deleteUser($player->id);
|
||||
if ($player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
|
||||
$recordArr = $record->toArray();
|
||||
$recordArr['dice_player'] = ['id' => (int) $player->id, 'username' => $player->username ?? '', 'phone' => $player->phone ?? ''];
|
||||
return $this->success($recordArr);
|
||||
}
|
||||
}
|
||||
39
server/app/api/lang/en.php
Normal file
39
server/app/api/lang/en.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* API 英文文案(对外接口推荐:英文 key)
|
||||
* 请求头 lang=en 时使用,key 为英文错误码,value 为英文展示文案
|
||||
*/
|
||||
return [
|
||||
'SUCCESS' => 'Success',
|
||||
'FAIL' => 'Fail',
|
||||
'TOKEN_REQUIRED' => 'Please provide token',
|
||||
'TOKEN_INVALID' => 'Invalid or expired token',
|
||||
'TOKEN_EXPIRED_RELOGIN' => 'Token expired, please login again',
|
||||
'TOKEN_FORMAT_INVALID' => 'Token format invalid',
|
||||
'AUTH_TOKEN_REQUIRED' => 'Please provide auth-token',
|
||||
'AUTH_TOKEN_EXPIRED' => 'auth-token expired',
|
||||
'AUTH_TOKEN_INVALID' => 'auth-token invalid',
|
||||
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token format invalid',
|
||||
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token invalid or expired',
|
||||
'USER_NOT_FOUND' => 'User not found',
|
||||
'USERNAME_REQUIRED' => 'username is required',
|
||||
'USERNAME_PASSWORD_REQUIRED' => 'username and password are required',
|
||||
'PASSWORD_WRONG' => 'Wrong password',
|
||||
'ACCOUNT_DISABLED' => 'Account is disabled and cannot log in',
|
||||
'BUY_TICKET_ERROR' => 'Invalid lottery ticket purchase',
|
||||
'INSUFFICIENT_BALANCE' => 'Insufficient balance',
|
||||
'INSUFFICIENT_TICKETS' => 'Insufficient lottery tickets',
|
||||
'DIRECTION_INVALID' => 'direction must be 0 or 1',
|
||||
'BALANCE_LESS_THAN_MIN' => 'Balance %s is less than %s, cannot continue',
|
||||
'LOTTERY_CONFIG_NOT_FOUND' => 'Lottery config not found',
|
||||
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => 'Lottery pool config not found (name=default required)',
|
||||
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => 'No name=default pool config found, please create one first',
|
||||
'NO_AVAILABLE_REWARD_CONFIG' => 'No available reward config',
|
||||
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => 'Config ID %s not found or tier is empty',
|
||||
'DATA_NOT_FOUND' => 'Data not found',
|
||||
'BATCH_DELETE_FORBIDDEN' => 'Batch delete is not allowed',
|
||||
'SUPER_ADMIN_CANNOT_DELETE' => 'Super admin cannot be deleted',
|
||||
'OLD_PASSWORD_WRONG' => 'Old password is incorrect',
|
||||
];
|
||||
150
server/app/api/lang/legacy_en.php
Normal file
150
server/app/api/lang/legacy_en.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 旧版兼容:中文 => 英文 映射表
|
||||
* 历史代码中大量直接抛中文/返回中文 message,lang=en 时用于兼容翻译。
|
||||
* 新版推荐使用英文错误码(key)+ resource/translations/api/{zh,en}.php。
|
||||
*/
|
||||
return [
|
||||
'success' => 'Success',
|
||||
'fail' => 'Fail',
|
||||
'username、password 不能为空' => 'username and password are required',
|
||||
'请携带 token' => 'Please provide token',
|
||||
'token 无效' => 'Invalid or expired token',
|
||||
'已退出登录' => 'Logged out successfully',
|
||||
'用户不存在' => 'User not found',
|
||||
'username 不能为空' => 'username is required',
|
||||
'密码错误' => 'Wrong password',
|
||||
'账号已被禁用,无法登录' => 'Account is disabled and cannot log in',
|
||||
'购买抽奖券错误' => 'Invalid lottery ticket purchase',
|
||||
'平台币不足' => 'Insufficient balance',
|
||||
'direction 必须为 0 或 1' => 'direction must be 0 or 1',
|
||||
'当前玩家余额%s小于%s无法继续游戏' => 'Balance %s is less than %s, cannot continue',
|
||||
'服务超时,' => 'Service timeout: ',
|
||||
'没有原因' => 'Unknown reason',
|
||||
'缺少参数:agent_id、secret、time、signature 不能为空' => 'Missing parameters: agent_id, secret, time, signature are required',
|
||||
'服务端未配置 API_AUTH_TOKEN_SECRET' => 'API_AUTH_TOKEN_SECRET is not configured',
|
||||
'密钥错误' => 'Invalid secret',
|
||||
'时间戳已过期或无效,请同步时间' => 'Timestamp expired or invalid, please sync time',
|
||||
'签名验证失败' => 'Signature verification failed',
|
||||
'生成 token 失败' => 'Failed to generate token',
|
||||
'coin 不能为空' => 'coin is required',
|
||||
'coin 不能为 0' => 'coin cannot be 0',
|
||||
'余额不足,无法转出' => 'Insufficient balance to transfer',
|
||||
'操作失败:' => 'Operation failed: ',
|
||||
'服务超时,没有原因' => 'Service timeout: Unknown reason',
|
||||
// PlayStartLogic / GameLogic
|
||||
'抽奖券不足' => 'Insufficient lottery tickets',
|
||||
'奖池配置不存在' => 'Lottery config not found',
|
||||
'配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty',
|
||||
'该方向下暂无可用路径配置' => 'No path config available for this direction',
|
||||
// Dice / pool config
|
||||
'奖池配置不存在(需 name=default)' => 'Lottery pool config not found (name=default required)',
|
||||
'暂无可用奖励配置' => 'No available reward config',
|
||||
'未找到 name=default 的奖池配置,请先创建' => 'No name=default pool config found, please create one first',
|
||||
// Dice / wallet & tickets
|
||||
'参数错误:需要有效的 player_id 和 type(3=加点,4=扣点)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
|
||||
'平台币变动必须大于 0' => 'Coin change must be greater than 0',
|
||||
'玩家不存在' => 'Player not found',
|
||||
'扣点数量不能大于当前余额' => 'Deduct amount cannot exceed current balance',
|
||||
// Dice / reward config record
|
||||
'测试记录不存在' => 'Test record not found',
|
||||
'付费奖池配置不存在' => 'Paid pool config not found',
|
||||
'免费奖池配置不存在' => 'Free pool config not found',
|
||||
'各抽奖次数仅支持 0、100、500、1000、5000' => 'Counts only support 0, 100, 500, 1000, 5000',
|
||||
'付费或免费至少一种方向次数之和大于 0' => 'Sum of paid/free direction counts must be greater than 0',
|
||||
'付费未选择奖池配置时,请填写付费自定义档位概率(T1~T5)' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)',
|
||||
'付费档位概率每档只能 0-100%' => 'Paid tier probability must be between 0 and 100%',
|
||||
'付费档位概率 T1~T5 之和不能超过 100%' => 'Paid tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
'免费未选择奖池配置时,请填写免费自定义档位概率(T1~T5)' => 'When free pool is not selected, please fill free custom tier probabilities (T1–T5)',
|
||||
'免费档位概率每档只能 0-100%' => 'Free tier probability must be between 0 and 100%',
|
||||
'免费档位概率 T1~T5 之和不能超过 100%' => 'Free tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
// Dice / reward
|
||||
'存在无效的配置ID' => 'Invalid config ID exists',
|
||||
'存在无效的 DiceReward id' => 'Invalid DiceReward id exists',
|
||||
'奖励配置为空,请先维护 dice_reward_config' => 'Reward config is empty, please maintain dice_reward_config first',
|
||||
// Dice / reward_config
|
||||
'测试次数仅支持 100、500、1000、5000、10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
|
||||
// SaiAdmin permissions & auth
|
||||
'没有权限操作该部门数据' => 'No permission to operate department data',
|
||||
'没有权限操作该角色数据' => 'No permission to operate role data',
|
||||
'没有权限操作该数据' => 'No permission to operate this data',
|
||||
'禁止批量删除操作' => 'Batch delete is not allowed',
|
||||
'超级管理员禁止删除' => 'Super admin cannot be deleted',
|
||||
'原密码错误' => 'Old password is incorrect',
|
||||
'上级部门和当前部门不能相同' => 'Parent department cannot be the same as current department',
|
||||
'不能将上级部门设置为当前部门的子部门' => 'Cannot set parent department to a child of current department',
|
||||
'该部门下存在子部门,请先删除子部门' => 'This department has sub-departments, please delete them first',
|
||||
'该部门下存在用户,请先删除或者转移用户' => 'This department has users, please delete or transfer them first',
|
||||
'您的登录凭证错误或者已过期,请重新登录' => 'Your login credential is invalid or expired, please login again',
|
||||
'登录凭证校验失败' => 'Login credential verification failed',
|
||||
// Saipackage install
|
||||
'插件的基础配置信息错误' => 'Plugin base config is invalid',
|
||||
'插件已经存在' => 'Plugin already exists',
|
||||
'该插件的安装目录已经被占用' => 'Plugin install directory is already occupied',
|
||||
'文件不存在' => 'File not found',
|
||||
// UserLogic
|
||||
'手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789)' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
|
||||
// TokenMiddleware / Auth (api/user/*, api/game/*)
|
||||
'请携带 auth-token' => 'Please provide auth-token',
|
||||
'auth-token 已过期' => 'auth-token expired',
|
||||
'auth-token 无效' => 'auth-token invalid',
|
||||
'auth-token 格式无效' => 'auth-token format invalid',
|
||||
'auth-token 无效或已失效' => 'auth-token invalid or expired',
|
||||
'token 已过期,请重新登录' => 'Token expired, please login again',
|
||||
'token 格式无效' => 'Token format invalid',
|
||||
'请注册' => 'Please register',
|
||||
'请重新登录' => 'Please login again',
|
||||
'请重新登录(当前账号已在其他处登录)' => 'Please login again (account logged in elsewhere)',
|
||||
// DiceRewardLogic 动态文案(占位符)
|
||||
'奖励配置需覆盖 26 个格位(id 0-25 或 1-26),当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
|
||||
// 通用
|
||||
'数据不存在' => 'Data not found',
|
||||
'不能设置父级为自身' => 'Cannot set parent to self',
|
||||
'该菜单下存在子菜单,请先删除子菜单' => 'This menu has sub-menus, please delete them first',
|
||||
'导入文件错误,请上传正确的文件格式xlsx' => 'Import file error, please upload correct xlsx file',
|
||||
'不能操作比当前账户职级高的角色' => 'Cannot operate roles with higher level than current account',
|
||||
'该字典标识已存在' => 'This dict code already exists',
|
||||
'修改数据异常,请检查' => 'Update data error, please check',
|
||||
'删除数据异常,请检查' => 'Delete data error, please check',
|
||||
'字典类型不存在' => 'Dict type not found',
|
||||
'配置数据未找到' => 'Config data not found',
|
||||
'系统默认分组,无法删除' => 'System default group cannot be deleted',
|
||||
'配置组未找到' => 'Config group not found',
|
||||
'上级分类和当前分类不能相同' => 'Parent category cannot be the same as current',
|
||||
'不能将上级分类设置为当前分类的子分类' => 'Cannot set parent category as child of current',
|
||||
'该部门下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
|
||||
'目标分类不存在' => 'Target category not found',
|
||||
'获取文件资源失败' => 'Failed to get file resource',
|
||||
'创建图片资源失败' => 'Failed to create image resource',
|
||||
'文件格式错误' => 'Invalid file format',
|
||||
'文件保存失败' => 'Failed to save file',
|
||||
'当前表不支持回收站功能' => 'Current table does not support recycle bin',
|
||||
'模板不存在' => 'Template not found',
|
||||
'任务类型异常' => 'Invalid task type',
|
||||
'数据库配置读取失败' => 'Failed to read database config',
|
||||
'应用类型必须为plugin或者app' => 'App type must be plugin or app',
|
||||
'请先设置应用名称' => 'Please set app name first',
|
||||
'请选择要生成的表' => 'Please select tables to generate',
|
||||
'非调试模式下,不允许生成文件' => 'File generation not allowed in non-debug mode',
|
||||
'登录凭获取失败,请检查' => 'Failed to get login credential, please check',
|
||||
'文件大小超过限制' => 'File size exceeds limit',
|
||||
'不支持该格式的文件上传' => 'File format not supported for upload',
|
||||
'该上传模式不存在' => 'Upload mode not found',
|
||||
'切片上传服务必须在 HTTP 请求环境下调用' => 'Chunk upload must be called in HTTP request context',
|
||||
'切片文件查找失败,请重新上传' => 'Chunk file not found, please upload again',
|
||||
'未设置邮件配置' => 'Mail config not set',
|
||||
'请执行 composer require phpmailer/phpmailer 并重启' => 'Please run composer require phpmailer/phpmailer and restart',
|
||||
'仅超级管理员能够操作' => 'Only super admin can perform this action',
|
||||
'等待依赖安装' => 'Waiting for dependencies to be installed',
|
||||
'插件目录不存在' => 'Plugin directory not found',
|
||||
'该插件的基础配置信息不完善' => 'Plugin base config is incomplete',
|
||||
'参数错误' => 'Invalid parameters',
|
||||
'该分类下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
|
||||
'无法打开文件,或者文件创建失败' => 'Cannot open file or create file failed',
|
||||
'系统生成文件错误' => 'System file generation error',
|
||||
'模板目录不存在!' => 'Template directory not found',
|
||||
'文件类型异常,无法生成指定文件!' => 'Invalid file type, cannot generate file',
|
||||
'前端目录查找失败,必须与后端目录为同级目录!' => 'Frontend directory not found, must be same level as backend',
|
||||
];
|
||||
40
server/app/api/lang/zh.php
Normal file
40
server/app/api/lang/zh.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* API 中文文案(对外接口推荐:英文 key)
|
||||
* 请求头 lang=zh 时使用,key 为英文错误码,value 为中文展示文案
|
||||
*/
|
||||
return [
|
||||
'SUCCESS' => '成功',
|
||||
'FAIL' => '失败',
|
||||
'TOKEN_REQUIRED' => '请携带 token',
|
||||
'TOKEN_INVALID' => 'token 无效',
|
||||
'TOKEN_EXPIRED_RELOGIN' => 'token 已过期,请重新登录',
|
||||
'TOKEN_FORMAT_INVALID' => 'token 格式无效',
|
||||
'AUTH_TOKEN_REQUIRED' => '请携带 auth-token',
|
||||
'AUTH_TOKEN_EXPIRED' => 'auth-token 已过期',
|
||||
'AUTH_TOKEN_INVALID' => 'auth-token 无效',
|
||||
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token 格式无效',
|
||||
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token 无效或已失效',
|
||||
'USER_NOT_FOUND' => '用户不存在',
|
||||
'USERNAME_REQUIRED' => 'username 不能为空',
|
||||
'USERNAME_PASSWORD_REQUIRED' => 'username、password 不能为空',
|
||||
'PASSWORD_WRONG' => '密码错误',
|
||||
'ACCOUNT_DISABLED' => '账号已被禁用,无法登录',
|
||||
'BUY_TICKET_ERROR' => '购买抽奖券错误',
|
||||
'INSUFFICIENT_BALANCE' => '平台币不足',
|
||||
'INSUFFICIENT_TICKETS' => '抽奖券不足',
|
||||
'DIRECTION_INVALID' => 'direction 必须为 0 或 1',
|
||||
'BALANCE_LESS_THAN_MIN' => '当前玩家余额%s小于%s无法继续游戏',
|
||||
'LOTTERY_CONFIG_NOT_FOUND' => '奖池配置不存在',
|
||||
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => '奖池配置不存在(需 name=default)',
|
||||
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => '未找到 name=default 的奖池配置,请先创建',
|
||||
'NO_AVAILABLE_REWARD_CONFIG' => '暂无可用奖励配置',
|
||||
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => '配置ID %s 不存在或档位为空',
|
||||
'DATA_NOT_FOUND' => '数据不存在',
|
||||
'BATCH_DELETE_FORBIDDEN' => '禁止批量删除操作',
|
||||
'SUPER_ADMIN_CANNOT_DELETE' => '超级管理员禁止删除',
|
||||
'OLD_PASSWORD_WRONG' => '原密码错误',
|
||||
];
|
||||
|
||||
@@ -35,7 +35,7 @@ class GameLogic
|
||||
public function buyLotteryTickets(int $playerId, int $count): array
|
||||
{
|
||||
if (!isset(self::PACKAGES[$count])) {
|
||||
throw new ApiException('购买抽奖券错误');
|
||||
throw new ApiException('Invalid lottery ticket purchase');
|
||||
}
|
||||
$pack = self::PACKAGES[$count];
|
||||
$cost = $pack['coin'];
|
||||
@@ -45,11 +45,11 @@ class GameLogic
|
||||
|
||||
$player = DicePlayer::find($playerId);
|
||||
if (!$player) {
|
||||
throw new ApiException('用户不存在');
|
||||
throw new ApiException('User not found');
|
||||
}
|
||||
$coinBefore = (float) $player->coin;
|
||||
if ($coinBefore < $cost) {
|
||||
throw new ApiException('平台币不足');
|
||||
throw new ApiException('Insufficient balance');
|
||||
}
|
||||
|
||||
$coinAfter = $coinBefore - $cost;
|
||||
@@ -69,10 +69,12 @@ class GameLogic
|
||||
|
||||
UserCache::setUser($playerId, $updatedUserArr);
|
||||
|
||||
$adminId = ($player->admin_id ?? null) ? (int) $player->admin_id : null;
|
||||
try {
|
||||
Db::transaction(function () use (
|
||||
$player,
|
||||
$playerId,
|
||||
$adminId,
|
||||
$cost,
|
||||
$coinBefore,
|
||||
$coinAfter,
|
||||
@@ -91,6 +93,7 @@ class GameLogic
|
||||
|
||||
DicePlayerWalletRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => -$cost,
|
||||
'type' => self::WALLET_TYPE_BUY_DRAW,
|
||||
'wallet_before' => $coinBefore,
|
||||
@@ -103,6 +106,7 @@ class GameLogic
|
||||
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'use_coins' => $cost,
|
||||
'total_ticket_count' => $addTotal,
|
||||
'paid_ticket_count' => $addPaid,
|
||||
|
||||
@@ -4,13 +4,15 @@ declare(strict_types=1);
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\api\cache\UserCache;
|
||||
use app\api\util\ApiLang;
|
||||
use app\api\service\LotteryService;
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use support\Log;
|
||||
use support\think\Cache;
|
||||
@@ -34,6 +36,12 @@ class PlayStartLogic
|
||||
|
||||
/** 开启对局最低余额 = |DiceRewardConfig 最小 real_ev + 100| */
|
||||
private const MIN_COIN_EXTRA = 100;
|
||||
/** 豹子号中大奖额外平台币(无 BIGWIN 配置时兜底) */
|
||||
private const SUPER_WIN_BONUS = 500;
|
||||
/** 可触发超级大奖的 grid_number(5=全1 10=全2 15=全3 20=全4 25=全5 30=全6) */
|
||||
private const SUPER_WIN_GRID_NUMBERS = [5, 10, 15, 20, 25, 30];
|
||||
/** 5 和 30 抽到即豹子,不参与 BIGWIN 权重判定;10/15/20/25 按 BIGWIN weight 判定是否豹子 */
|
||||
private const SUPER_WIN_ALWAYS_GRID_NUMBERS = [5, 30];
|
||||
|
||||
/**
|
||||
* 执行一局游戏
|
||||
@@ -45,72 +53,131 @@ class PlayStartLogic
|
||||
{
|
||||
$player = DicePlayer::find($playerId);
|
||||
if (!$player) {
|
||||
throw new ApiException('用户不存在');
|
||||
throw new ApiException('User not found');
|
||||
}
|
||||
|
||||
$minEv = DiceRewardConfig::getCachedMinRealEv();
|
||||
$minCoin = abs($minEv + self::MIN_COIN_EXTRA);
|
||||
$coin = (float) $player->coin;
|
||||
if ($coin < $minCoin) {
|
||||
throw new ApiException('当前玩家余额'.$coin.'小于'.$minCoin.'无法继续游戏');
|
||||
throw new ApiException(ApiLang::translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin]));
|
||||
}
|
||||
|
||||
$paid = (int) ($player->paid_ticket_count ?? 0);
|
||||
$free = (int) ($player->free_ticket_count ?? 0);
|
||||
if ($paid + $free <= 0) {
|
||||
throw new ApiException('抽奖券不足');
|
||||
throw new ApiException('Insufficient lottery tickets');
|
||||
}
|
||||
|
||||
$lotteryService = LotteryService::getOrCreate($playerId);
|
||||
$ticketType = LotteryService::drawTicketType($paid, $free);
|
||||
$config = $ticketType === self::LOTTERY_TYPE_PAID
|
||||
? ($lotteryService->getConfigType0Id() ? DiceLotteryConfig::find($lotteryService->getConfigType0Id()) : null)
|
||||
: ($lotteryService->getConfigType1Id() ? DiceLotteryConfig::find($lotteryService->getConfigType1Id()) : null);
|
||||
if (!$config) {
|
||||
throw new ApiException('奖池配置不存在');
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('Lottery pool config not found (name=default required)');
|
||||
}
|
||||
|
||||
// 按玩家权重抽取档位;若该档位无奖励或该方向下均无可用路径则重新摇取档位
|
||||
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||
// 该值来自 dice_lottery_pool_config.profit_amount
|
||||
$poolProfitTotal = $configType0->profit_amount ?? 0;
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||
// 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default)
|
||||
// 记录 lottery_config_id:用池权重时记对应池,付费用玩家权重时记 default
|
||||
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null)
|
||||
|| ($ticketType === self::LOTTERY_TYPE_FREE);
|
||||
$config = $usePoolWeights
|
||||
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
|
||||
: $configType0;
|
||||
|
||||
// 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $rewardInstance['by_tier_direction'] ?? [];
|
||||
$maxTierRetry = 10;
|
||||
$chosen = null;
|
||||
$startCandidates = [];
|
||||
$tier = null;
|
||||
for ($tierAttempt = 0; $tierAttempt < $maxTierRetry; $tierAttempt++) {
|
||||
$tier = LotteryService::drawTierByPlayerWeights($player);
|
||||
$tierRewards = DiceRewardConfig::getCachedByTier($tier);
|
||||
$tier = $usePoolWeights
|
||||
? LotteryService::drawTierByWeights($config)
|
||||
: LotteryService::drawTierByPlayerWeights($player);
|
||||
$tierRewards = $byTierDirection[$tier][$direction] ?? [];
|
||||
if (empty($tierRewards)) {
|
||||
Log::warning("档位 {$tier} 无任何奖励配置,重新摇取档位");
|
||||
Log::warning("档位 {$tier} 方向 {$direction} 无任何 DiceReward,重新摇取档位");
|
||||
continue;
|
||||
}
|
||||
$maxRewardRetry = count($tierRewards);
|
||||
for ($attempt = 0; $attempt < $maxRewardRetry; $attempt++) {
|
||||
$chosen = $tierRewards[array_rand($tierRewards)];
|
||||
$chosenId = (int) ($chosen['id'] ?? 0);
|
||||
if ($direction === 0) {
|
||||
$startCandidates = DiceRewardConfig::getCachedBySEndIndex($chosenId);
|
||||
} else {
|
||||
$startCandidates = DiceRewardConfig::getCachedByNEndIndex($chosenId);
|
||||
if ($usePoolWeights) {
|
||||
$tierRewards = self::filterOutSuperWinOnlyGrids($tierRewards);
|
||||
if (empty($tierRewards)) {
|
||||
Log::warning("档位 {$tier} 方向 {$direction} 杀分档位下排除 5/30 后无可用奖励,重新摇取档位");
|
||||
continue;
|
||||
}
|
||||
if (!empty($startCandidates)) {
|
||||
break 2;
|
||||
}
|
||||
Log::warning("方向 {$direction} 下无 s_end_index/n_end_index={$chosenId} 的配置,重新摇取");
|
||||
}
|
||||
Log::warning("方向 {$direction} 下档位 {$tier} 所有奖励均无可用路径配置,重新摇取档位");
|
||||
try {
|
||||
$chosen = self::drawRewardByWeight($tierRewards);
|
||||
} catch (\RuntimeException $e) {
|
||||
if ($e->getMessage() === self::EXCEPTION_WEIGHT_ALL_ZERO) {
|
||||
Log::warning("档位 {$tier} 下所有奖励权重均为 0,重新摇取档位");
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (empty($startCandidates)) {
|
||||
Log::error("方向 {$direction} 下多次摇取档位后仍无可用路径配置");
|
||||
throw new ApiException('该方向下暂无可用路径配置');
|
||||
if ($chosen === null) {
|
||||
Log::error("多次摇取档位后仍无有效 DiceReward");
|
||||
throw new ApiException('No available reward config');
|
||||
}
|
||||
$chosenId = (int) ($chosen['id'] ?? 0);
|
||||
$startRecord = $startCandidates[array_rand($startCandidates)];
|
||||
|
||||
$startIndex = (int) ($startRecord['id'] ?? 0);
|
||||
$targetIndex = $direction === 0
|
||||
? (int) ($startRecord['s_end_index'] ?? 0)
|
||||
: (int) ($startRecord['n_end_index'] ?? 0);
|
||||
$rollNumber = (int) ($startRecord['grid_number'] ?? 0);
|
||||
$rollArray = $this->generateRollArrayFromSum($rollNumber);
|
||||
$startIndex = (int) ($chosen['start_index'] ?? 0);
|
||||
$targetIndex = (int) ($chosen['end_index'] ?? 0);
|
||||
$rollNumber = (int) ($chosen['grid_number'] ?? 0);
|
||||
$realEv = (float) ($chosen['real_ev'] ?? 0);
|
||||
$isTierT5 = (string) ($chosen['tier'] ?? '') === 'T5';
|
||||
$rewardWinCoin = $isTierT5 ? $realEv : (100 + $realEv);
|
||||
|
||||
// 豹子判定:5/30 必豹子;10/15/20/25 按 DiceRewardConfig 中 BIGWIN 该点数的 weight 判定(0-10000,10000=100%)
|
||||
// 杀分档位:不触发豹子,5/30 已在上方抽取时排除,10/15/20/25 仅生成非豹子组合
|
||||
$superWinCoin = 0;
|
||||
$isWin = 0;
|
||||
$bigWinRealEv = 0.0;
|
||||
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
|
||||
if ($usePoolWeights) {
|
||||
// 杀分档位:绝不触发豹子,仅生成非豹子组合,不发放豹子奖金
|
||||
$isWin = 0;
|
||||
$superWinCoin = 0.0;
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
} else {
|
||||
$bigWinConfig = DiceRewardConfig::getCachedByTierAndGridNumber('BIGWIN', $rollNumber);
|
||||
$alwaysSuperWin = in_array($rollNumber, self::SUPER_WIN_ALWAYS_GRID_NUMBERS, true);
|
||||
$doSuperWin = $alwaysSuperWin;
|
||||
if (!$doSuperWin) {
|
||||
$bigWinWeight = 10000;
|
||||
if ($bigWinConfig !== null && isset($bigWinConfig['weight'])) {
|
||||
$bigWinWeight = min(10000, max(0, (int) $bigWinConfig['weight']));
|
||||
$bigWinRealEv = (float) ($bigWinConfig['real_ev'] ?? 0);
|
||||
}
|
||||
$roll = (random_int(0, PHP_INT_MAX - 1) / (float) PHP_INT_MAX);
|
||||
$doSuperWin = $bigWinWeight > 0 && $roll < ($bigWinWeight / 10000.0);
|
||||
} else {
|
||||
if ($bigWinConfig !== null) {
|
||||
$bigWinRealEv = (float) ($bigWinConfig['real_ev'] ?? 0);
|
||||
}
|
||||
}
|
||||
if ($doSuperWin) {
|
||||
$rollArray = $this->getSuperWinRollArray($rollNumber);
|
||||
$isWin = 1;
|
||||
$superWinCoin = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
|
||||
// 中 BIGWIN 豹子:不走原奖励流程,不记录原奖励,不触发 T5 再来一次,仅发放豹子奖金
|
||||
$rewardWinCoin = 0;
|
||||
$realEv = 0;
|
||||
$isTierT5 = false;
|
||||
} else {
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rollArray = $this->generateRollArrayFromSum($rollNumber);
|
||||
}
|
||||
|
||||
Log::info(sprintf(
|
||||
'摇取点数 roll_number=%d, 方向=%d, start_index=%d, target_index=%d',
|
||||
@@ -119,23 +186,29 @@ class PlayStartLogic
|
||||
$startIndex,
|
||||
$targetIndex
|
||||
));
|
||||
$realEv = (float) ($chosen['real_ev'] ?? 0);
|
||||
$winCoin = 100 + $realEv; // 赢取平台币 = 100 + DiceRewardConfig.real_ev
|
||||
$winCoin = $superWinCoin + $rewardWinCoin; // 赢取平台币 = 中大奖 + 摇色子中奖(豹子时 rewardWinCoin 已为 0)
|
||||
|
||||
$record = null;
|
||||
$configId = (int) $config->id;
|
||||
$rewardId = $chosenId;
|
||||
$type0ConfigId = (int) $configType0->id;
|
||||
$rewardId = ($isWin === 1 && $superWinCoin > 0) ? 0 : $targetIndex; // 中豹子不记录原奖励配置 id
|
||||
$configName = (string) ($config->name ?? '');
|
||||
$isTierT5 = (string) ($chosen['tier'] ?? '') === 'T5';
|
||||
$adminId = ($player->admin_id ?? null) ? (int) $player->admin_id : null;
|
||||
try {
|
||||
Db::transaction(function () use (
|
||||
$playerId,
|
||||
$adminId,
|
||||
$configId,
|
||||
$type0ConfigId,
|
||||
$rewardId,
|
||||
$configName,
|
||||
$ticketType,
|
||||
$winCoin,
|
||||
$superWinCoin,
|
||||
$rewardWinCoin,
|
||||
$isWin,
|
||||
$realEv,
|
||||
$bigWinRealEv,
|
||||
$direction,
|
||||
$startIndex,
|
||||
$targetIndex,
|
||||
@@ -145,15 +218,20 @@ class PlayStartLogic
|
||||
) {
|
||||
$record = DicePlayRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'lottery_config_id' => $configId,
|
||||
'lottery_type' => $ticketType,
|
||||
'is_win' => $isWin,
|
||||
'win_coin' => $winCoin,
|
||||
'super_win_coin' => $superWinCoin,
|
||||
'reward_win_coin' => $rewardWinCoin,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => $rewardId,
|
||||
'start_index' => $startIndex,
|
||||
'target_index' => $targetIndex,
|
||||
'roll_array' => is_array($rollArray) ? json_encode($rollArray) : $rollArray,
|
||||
'roll_number' => is_array($rollArray) ? array_sum($rollArray) : 0,
|
||||
'lottery_name' => $configName,
|
||||
'status' => self::RECORD_STATUS_SUCCESS,
|
||||
]);
|
||||
@@ -178,24 +256,35 @@ class PlayStartLogic
|
||||
$p->total_ticket_count = (int) $p->total_ticket_count + 1;
|
||||
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'free_ticket_count' => 1,
|
||||
'remark' => '中奖结果为T5',
|
||||
'remark' => '中奖结果为T5',
|
||||
]);
|
||||
}
|
||||
|
||||
$p->save();
|
||||
|
||||
// 累加彩金池盈利额度(累加值为 -real_ev)。若 dice_lottery_config 表有 ev 字段则执行
|
||||
// 彩金池累计盈利累加在 name=default 彩金池上:
|
||||
// 付费券:每局按“当前中奖金额(含 BIGWIN) - 抽奖券费用 100”
|
||||
// 免费券:取消票价成本 100,只计入中奖金额
|
||||
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - 100.0) : $winCoin;
|
||||
$addProfit = $perPlayProfit;
|
||||
try {
|
||||
DiceLotteryConfig::where('id', $configId)->update([
|
||||
'ev' => Db::raw('IFNULL(ev,0) - ' . (float) $realEv),
|
||||
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([
|
||||
'profit_amount' => Db::raw('IFNULL(profit_amount,0) + ' . (float) $addProfit),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('彩金池盈利累加失败', [
|
||||
'config_id' => $type0ConfigId,
|
||||
'add_profit' => $addProfit,
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
} catch (\Throwable $_) {
|
||||
}
|
||||
|
||||
DicePlayerWalletRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => $winCoin,
|
||||
'type' => self::WALLET_TYPE_DRAW,
|
||||
'wallet_before' => $coinBefore,
|
||||
@@ -208,15 +297,20 @@ class PlayStartLogic
|
||||
try {
|
||||
$record = DicePlayRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId ?? null,
|
||||
'lottery_config_id' => $configId ?? 0,
|
||||
'lottery_type' => $ticketType,
|
||||
'is_win' => 0,
|
||||
'win_coin' => 0,
|
||||
'super_win_coin' => 0,
|
||||
'reward_win_coin' => 0,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => 0,
|
||||
'start_index' => $startIndex,
|
||||
'target_index' => 0,
|
||||
'roll_array' => '[]',
|
||||
'roll_number' => 0,
|
||||
'status' => self::RECORD_STATUS_TIMEOUT,
|
||||
]);
|
||||
} catch (\Throwable $_) {
|
||||
@@ -239,9 +333,63 @@ class PlayStartLogic
|
||||
$arr['roll_array'] = json_decode($arr['roll_array'], true) ?? [];
|
||||
}
|
||||
$arr['roll_number'] = is_array($arr['roll_array'] ?? null) ? array_sum($arr['roll_array']) : 0;
|
||||
$arr['tier'] = $tier ?? '';
|
||||
// 记录完数据后返回当前玩家余额与抽奖次数
|
||||
$arr['coin'] = $updated ? (float) $updated->coin : 0;
|
||||
$arr['total_ticket_count'] = $updated ? (int) $updated->total_ticket_count : 0;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/** 该组配置权重均为 0 时抛出,供调用方重试 */
|
||||
private const EXCEPTION_WEIGHT_ALL_ZERO = 'REWARD_WEIGHT_ALL_ZERO';
|
||||
|
||||
/** 杀分档位需排除的豹子号:5 和 30 只能组成豹子,无法生成非豹子组合 */
|
||||
private const KILL_MODE_EXCLUDE_GRIDS = [5, 30];
|
||||
|
||||
/**
|
||||
* 杀分档位下排除 grid_number=5/30 的奖励(5/30 只能豹子,无法剔除)
|
||||
* @return array 排除后的奖励列表,保持索引连续
|
||||
*/
|
||||
private static function filterOutSuperWinOnlyGrids(array $rewards): array
|
||||
{
|
||||
return array_values(array_filter($rewards, function ($r) {
|
||||
$g = (int) ($r['grid_number'] ?? 0);
|
||||
return !in_array($g, self::KILL_MODE_EXCLUDE_GRIDS, true);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按权重抽取一条配置:仅 weight>0 参与抽取(weight=0 不会被摇到)
|
||||
* 使用 [0, total) 浮点随机,支持最小权重 0.1%(如 weight=0.1),避免整数随机导致小权重失真
|
||||
* 全部 weight 为 0 时抛出 RuntimeException(EXCEPTION_WEIGHT_ALL_ZERO)
|
||||
*/
|
||||
private static function drawRewardByWeight(array $rewards): array
|
||||
{
|
||||
if (empty($rewards)) {
|
||||
throw new \InvalidArgumentException('rewards 不能为空');
|
||||
}
|
||||
$candidateWeights = [];
|
||||
foreach ($rewards as $i => $row) {
|
||||
$w = isset($row['weight']) ? (float) $row['weight'] : 0.0;
|
||||
if ($w > 0) {
|
||||
$candidateWeights[$i] = $w;
|
||||
}
|
||||
}
|
||||
$total = (float) array_sum($candidateWeights);
|
||||
if ($total > 0) {
|
||||
$r = (random_int(0, PHP_INT_MAX - 1) / (float) PHP_INT_MAX) * $total;
|
||||
$acc = 0.0;
|
||||
foreach ($candidateWeights as $i => $w) {
|
||||
$acc += $w;
|
||||
if ($r < $acc) {
|
||||
return $rewards[$i];
|
||||
}
|
||||
}
|
||||
return $rewards[array_key_last($candidateWeights)];
|
||||
}
|
||||
throw new \RuntimeException(self::EXCEPTION_WEIGHT_ALL_ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据摇取点数(5-30)生成 5 个色子数组,每个 1-6,总和为 $sum
|
||||
* @return int[] 如 [1,2,3,4,5]
|
||||
@@ -258,10 +406,186 @@ class PlayStartLogic
|
||||
if (empty($candidates)) {
|
||||
break;
|
||||
}
|
||||
$idx = $candidates[array_rand($candidates)];
|
||||
$idx = $candidates[random_int(0, count($candidates) - 1)];
|
||||
$arr[$idx]++;
|
||||
}
|
||||
shuffle($arr);
|
||||
return array_values($arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 豹子组合:5->[1,1,1,1,1],10->[2,2,2,2,2],15->[3,3,3,3,3],20->[4,4,4,4,4],25->[5,5,5,5,5],30->[6,6,6,6,6]
|
||||
* @return int[]
|
||||
*/
|
||||
private function getSuperWinRollArray(int $gridNumber): array
|
||||
{
|
||||
if ($gridNumber === 30) {
|
||||
return array_fill(0, 5, 6);
|
||||
}
|
||||
$n = (int) ($gridNumber / 5);
|
||||
$n = max(1, min(5, $n));
|
||||
return array_fill(0, 5, $n);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成总和为 $sum 且非豹子的 5 个色子(1-6);sum=5 时仅 [1,1,1,1,1] 可能,仍返回该组合
|
||||
* @return int[]
|
||||
*/
|
||||
private function generateNonSuperWinRollArrayWithSum(int $sum): array
|
||||
{
|
||||
$sum = max(5, min(30, $sum));
|
||||
$super = $this->getSuperWinRollArray($sum);
|
||||
if ($sum === 5) {
|
||||
return $super;
|
||||
}
|
||||
$arr = $super;
|
||||
$maxAttempts = 20;
|
||||
for ($a = 0; $a < $maxAttempts; $a++) {
|
||||
$idx = random_int(0, count($arr) - 1);
|
||||
$j = random_int(0, count($arr) - 1);
|
||||
if ($idx === $j) {
|
||||
$j = ($j + 1) % 5;
|
||||
}
|
||||
$i = $idx;
|
||||
if ($arr[$i] >= 2 && $arr[$j] <= 5) {
|
||||
$arr[$i]--;
|
||||
$arr[$j]++;
|
||||
shuffle($arr);
|
||||
return array_values($arr);
|
||||
}
|
||||
if ($arr[$i] <= 5 && $arr[$j] >= 2) {
|
||||
$arr[$i]++;
|
||||
$arr[$j]--;
|
||||
shuffle($arr);
|
||||
return array_values($arr);
|
||||
}
|
||||
}
|
||||
return $this->generateRollArrayFromSum($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟一局抽奖(不写库、不扣玩家),用于权重测试写入 dice_play_record_test
|
||||
* @param \app\dice\model\lottery_pool_config\DiceLotteryPoolConfig|null $config 奖池配置,自定义档位时可为 null
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
* @param int $lotteryType 0=付费 1=免费
|
||||
* @param array|null $customTierWeights 自定义档位权重 ['T1'=>x, 'T2'=>x, ...],非空时忽略 config 的档位权重
|
||||
* @return array 可直接用于 DicePlayRecordTest::create 的字段 + tier(用于统计档位概率)
|
||||
*/
|
||||
public function simulateOnePlay($config, int $direction, int $lotteryType = 0, ?array $customTierWeights = null): array
|
||||
{
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $rewardInstance['by_tier_direction'] ?? [];
|
||||
$maxTierRetry = 10;
|
||||
$chosen = null;
|
||||
$tier = null;
|
||||
for ($tierAttempt = 0; $tierAttempt < $maxTierRetry; $tierAttempt++) {
|
||||
if ($customTierWeights !== null && $customTierWeights !== []) {
|
||||
$tier = LotteryService::drawTierByWeightsFromArray($customTierWeights);
|
||||
} else {
|
||||
if ($config === null) {
|
||||
throw new \RuntimeException('模拟抽奖:未提供奖池配置或自定义档位权重');
|
||||
}
|
||||
$tier = LotteryService::drawTierByWeights($config);
|
||||
}
|
||||
$tierRewards = $byTierDirection[$tier][$direction] ?? [];
|
||||
if (empty($tierRewards)) {
|
||||
continue;
|
||||
}
|
||||
// 免费券或 killScore 池:与实际流程一致,排除 5/30 且不触发豹子
|
||||
$useKillMode = ($lotteryType === 1) || ($config !== null && (string) ($config->name ?? '') === 'killScore');
|
||||
if ($useKillMode) {
|
||||
$tierRewards = self::filterOutSuperWinOnlyGrids($tierRewards);
|
||||
if (empty($tierRewards)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$chosen = self::drawRewardByWeight($tierRewards);
|
||||
} catch (\RuntimeException $e) {
|
||||
if ($e->getMessage() === self::EXCEPTION_WEIGHT_ALL_ZERO) {
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($chosen === null) {
|
||||
throw new \RuntimeException('模拟抽奖:无可用奖励配置');
|
||||
}
|
||||
|
||||
$startIndex = (int) ($chosen['start_index'] ?? 0);
|
||||
$targetIndex = (int) ($chosen['end_index'] ?? 0);
|
||||
$rollNumber = (int) ($chosen['grid_number'] ?? 0);
|
||||
$realEv = (float) ($chosen['real_ev'] ?? 0);
|
||||
$isTierT5 = (string) ($chosen['tier'] ?? '') === 'T5';
|
||||
$rewardWinCoin = $isTierT5 ? $realEv : (100 + $realEv);
|
||||
|
||||
$superWinCoin = 0;
|
||||
$isWin = 0;
|
||||
$bigWinRealEv = 0.0;
|
||||
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
|
||||
if ($useKillMode) {
|
||||
// 杀分档位:绝不触发豹子,仅生成非豹子组合,不发放豹子奖金
|
||||
$isWin = 0;
|
||||
$superWinCoin = 0.0;
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
} else {
|
||||
$bigWinConfig = DiceRewardConfig::getCachedByTierAndGridNumber('BIGWIN', $rollNumber);
|
||||
$alwaysSuperWin = in_array($rollNumber, self::SUPER_WIN_ALWAYS_GRID_NUMBERS, true);
|
||||
$doSuperWin = $alwaysSuperWin;
|
||||
if (!$doSuperWin) {
|
||||
$bigWinWeight = 10000;
|
||||
if ($bigWinConfig !== null && isset($bigWinConfig['weight'])) {
|
||||
$bigWinWeight = min(10000, max(0, (int) $bigWinConfig['weight']));
|
||||
}
|
||||
$roll = (random_int(0, PHP_INT_MAX - 1) / (float) PHP_INT_MAX);
|
||||
$doSuperWin = $bigWinWeight > 0 && $roll < ($bigWinWeight / 10000.0);
|
||||
}
|
||||
if ($bigWinConfig !== null && isset($bigWinConfig['real_ev'])) {
|
||||
$bigWinRealEv = (float) $bigWinConfig['real_ev'];
|
||||
}
|
||||
if ($doSuperWin) {
|
||||
$rollArray = $this->getSuperWinRollArray($rollNumber);
|
||||
$isWin = 1;
|
||||
$superWinCoin = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
|
||||
$rewardWinCoin = 0;
|
||||
} else {
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rollArray = $this->generateRollArrayFromSum($rollNumber);
|
||||
}
|
||||
|
||||
$winCoin = $superWinCoin + $rewardWinCoin;
|
||||
$configId = $config !== null ? (int) $config->id : 0;
|
||||
$rewardId = ($isWin === 1 && $superWinCoin > 0) ? 0 : $targetIndex;
|
||||
$configName = $config !== null ? (string) ($config->name ?? '') : '自定义';
|
||||
$costRealEv = $realEv + ($isWin === 1 ? $bigWinRealEv : 0.0);
|
||||
|
||||
return [
|
||||
'player_id' => 0,
|
||||
'admin_id' => 0,
|
||||
'lottery_config_id' => $configId,
|
||||
'lottery_type' => $lotteryType,
|
||||
'is_win' => $isWin,
|
||||
'win_coin' => $winCoin,
|
||||
'super_win_coin' => $superWinCoin,
|
||||
'reward_win_coin' => $rewardWinCoin,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => $rewardId,
|
||||
'start_index' => $startIndex,
|
||||
'target_index' => $targetIndex,
|
||||
'roll_array' => json_encode($rollArray),
|
||||
'roll_number' => array_sum($rollArray),
|
||||
'lottery_name' => $configName,
|
||||
'status' => self::RECORD_STATUS_SUCCESS,
|
||||
'tier' => $tier,
|
||||
'roll_number_for_count' => $rollNumber,
|
||||
'real_ev' => $realEv,
|
||||
'bigwin_real_ev' => $isWin === 1 ? $bigWinRealEv : 0.0,
|
||||
'cost_ev' => $costRealEv,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace app\api\logic;
|
||||
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\api\cache\UserCache;
|
||||
use plugin\saiadmin\app\model\system\SystemDept;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
|
||||
@@ -29,7 +31,7 @@ class UserLogic
|
||||
public static function validatePhone(string $phone): void
|
||||
{
|
||||
if (!preg_match(self::PHONE_REGEX, $phone)) {
|
||||
throw new ApiException('手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789)');
|
||||
throw new ApiException('Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,23 +43,105 @@ class UserLogic
|
||||
return md5(self::PASSWORD_SALT . $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 parent_id 向上遍历找到顶级部门(parent_id=0)
|
||||
*/
|
||||
private static function getTopDeptIdByParentId(int $deptId): ?int
|
||||
{
|
||||
$currentId = $deptId;
|
||||
$visited = [];
|
||||
while ($currentId > 0 && !isset($visited[$currentId])) {
|
||||
$visited[$currentId] = true;
|
||||
$dept = SystemDept::find($currentId);
|
||||
if (!$dept) {
|
||||
return null;
|
||||
}
|
||||
$parentId = (int) ($dept->parent_id ?? 0);
|
||||
if ($parentId === 0) {
|
||||
return $currentId;
|
||||
}
|
||||
$currentId = $parentId;
|
||||
}
|
||||
return $currentId > 0 ? $currentId : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据顶级部门 id,递归获取其下所有部门 id(含自身),仅用 id 和 parent_id
|
||||
*/
|
||||
private static function getAllDeptIdsUnderTop(int $topId): array
|
||||
{
|
||||
$deptIds = [$topId];
|
||||
$prevCount = 0;
|
||||
while (count($deptIds) > $prevCount) {
|
||||
$prevCount = count($deptIds);
|
||||
$children = SystemDept::whereIn('parent_id', $deptIds)->column('id');
|
||||
$deptIds = array_unique(array_merge($deptIds, array_map('intval', $children)));
|
||||
}
|
||||
return array_values($deptIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 agent_id 获取当前管理员所在顶级部门下的所有管理员 ID 列表
|
||||
* 使用 SystemDept 的 id 和 parent_id 字段遍历:先向上找顶级部门(parent_id=0),再向下收集所有子部门
|
||||
* 用于 getGameUrl 接口判断 DicePlayer 是否属于该部门,同顶级部门下不重复创建玩家
|
||||
*
|
||||
* @param string $agentId 代理标识(sa_system_user.agent_id)
|
||||
* @return int[] 管理员 ID 列表,空数组表示未找到或无法解析
|
||||
*/
|
||||
public static function getAdminIdsByAgentIdTopDept(string $agentId): array
|
||||
{
|
||||
$agentId = trim($agentId);
|
||||
if ($agentId === '') {
|
||||
return [];
|
||||
}
|
||||
$admin = SystemUser::where('agent_id', $agentId)->find();
|
||||
if (!$admin) {
|
||||
return [];
|
||||
}
|
||||
$deptId = $admin->dept_id ?? null;
|
||||
if ($deptId === null || $deptId === '') {
|
||||
return [(int) $admin->id];
|
||||
}
|
||||
$deptId = (int) $deptId;
|
||||
$topId = self::getTopDeptIdByParentId($deptId);
|
||||
if ($topId === null) {
|
||||
return [(int) $admin->id];
|
||||
}
|
||||
$deptIds = self::getAllDeptIdsUnderTop($topId);
|
||||
if (empty($deptIds)) {
|
||||
$deptIds = [$deptId];
|
||||
}
|
||||
$adminIds = SystemUser::whereIn('dept_id', $deptIds)->column('id');
|
||||
return array_map('intval', $adminIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录(JSON:username, password, lang, coin, time)
|
||||
* 存在则校验密码并更新 coin(累加);不存在则创建用户并写入 coin。
|
||||
* 将会话写入 Redis,返回 token 与前端连接地址。
|
||||
*
|
||||
* @param int|null $adminId 创建新用户时关联的后台管理员ID(sa_system_user.id),可选
|
||||
* @param int[]|null $adminIdsInTopDept 当前管理员顶级部门下的所有管理员ID,用于按部门范围查找玩家;为空时退化为仅按 username 查找
|
||||
*/
|
||||
public function loginByUsername(string $username, string $password, string $lang, float $coin, string $time): array
|
||||
public function loginByUsername(string $username, string $password, string $lang, float $coin, string $time, ?int $adminId = null, ?array $adminIdsInTopDept = null): array
|
||||
{
|
||||
$username = trim($username);
|
||||
if ($username === '') {
|
||||
throw new ApiException('username 不能为空');
|
||||
throw new ApiException('username is required');
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
$query = DicePlayer::where('username', $username);
|
||||
if ($adminIdsInTopDept !== null && !empty($adminIdsInTopDept)) {
|
||||
$query->whereIn('admin_id', $adminIdsInTopDept);
|
||||
}
|
||||
$player = $query->find();
|
||||
if ($player) {
|
||||
if ((int) ($player->status ?? 1) === 0) {
|
||||
throw new ApiException('Account is disabled and cannot log in');
|
||||
}
|
||||
$hashed = $this->hashPassword($password);
|
||||
if ($player->password !== $hashed) {
|
||||
throw new ApiException('密码错误');
|
||||
throw new ApiException('Wrong password');
|
||||
}
|
||||
$currentCoin = (float) $player->coin;
|
||||
$player->coin = $currentCoin + $coin;
|
||||
@@ -69,6 +153,9 @@ class UserLogic
|
||||
$player->password = $this->hashPassword($password);
|
||||
$player->status = self::STATUS_NORMAL;
|
||||
$player->coin = $coin;
|
||||
if ($adminId !== null && $adminId > 0) {
|
||||
$player->admin_id = $adminId;
|
||||
}
|
||||
$player->save();
|
||||
}
|
||||
|
||||
@@ -82,7 +169,7 @@ class UserLogic
|
||||
$token = $tokenResult['access_token'];
|
||||
UserCache::setSessionByUsername($username, $token);
|
||||
|
||||
$userArr = $player->hidden(['password'])->toArray();
|
||||
$userArr = $player->hidden(['password', 'lottery_config_id', 't1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'])->toArray();
|
||||
UserCache::setUser((int) $player->id, $userArr);
|
||||
UserCache::setPlayerByUsername($username, $userArr);
|
||||
|
||||
|
||||
58
server/app/api/middleware/AuthTokenMiddleware.php
Normal file
58
server/app/api/middleware/AuthTokenMiddleware.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\middleware;
|
||||
|
||||
use app\api\cache\AuthTokenCache;
|
||||
use app\api\util\ReturnCode;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
use Tinywan\Jwt\Exception\JwtTokenException;
|
||||
use Tinywan\Jwt\Exception\JwtTokenExpiredException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 校验 auth-token 请求头(JWT)
|
||||
* 用于 /api/v1/* 接口(除 /api/v1/authtoken 外)
|
||||
* 请求头需携带 auth-token,通过后注入 request->agent_id
|
||||
*/
|
||||
class AuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
$token = $request->header('auth-token');
|
||||
$token = $token !== null ? trim((string) $token) : '';
|
||||
if ($token === '') {
|
||||
throw new ApiException('Please provide auth-token', ReturnCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
try {
|
||||
$decoded = JwtToken::verify(1, $token);
|
||||
} catch (JwtTokenExpiredException $e) {
|
||||
throw new ApiException('auth-token expired', ReturnCode::TOKEN_INVALID);
|
||||
} catch (JwtTokenException $e) {
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException('auth-token format invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$extend = $decoded['extend'] ?? [];
|
||||
if ((string) ($extend['plat'] ?? '') !== 'api_auth_token') {
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
$agentId = trim((string) ($extend['agent_id'] ?? ''));
|
||||
if ($agentId === '') {
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$currentToken = AuthTokenCache::getTokenByAgentId($agentId);
|
||||
if ($currentToken === null || $currentToken !== $token) {
|
||||
throw new ApiException('auth-token invalid or expired', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$request->agent_id = $agentId;
|
||||
return $handler($request);
|
||||
}
|
||||
}
|
||||
@@ -32,38 +32,38 @@ class TokenMiddleware implements MiddlewareInterface
|
||||
}
|
||||
$token = $token !== null ? trim((string) $token) : '';
|
||||
if ($token === '') {
|
||||
throw new ApiException('请携带 token', ReturnCode::UNAUTHORIZED);
|
||||
throw new ApiException('Please provide token', ReturnCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
try {
|
||||
$decoded = JwtToken::verify(1, $token);
|
||||
} catch (JwtTokenExpiredException $e) {
|
||||
throw new ApiException('token 已过期,请重新登录', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Token expired, please login again', ReturnCode::TOKEN_INVALID);
|
||||
} catch (JwtTokenException $e) {
|
||||
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException('token 格式无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Token format invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$extend = $decoded['extend'] ?? [];
|
||||
if ((string) ($extend['plat'] ?? '') !== 'api_login') {
|
||||
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
$username = trim((string) ($extend['username'] ?? ''));
|
||||
if ($username === '') {
|
||||
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$currentToken = UserCache::getSessionTokenByUsername($username);
|
||||
if ($currentToken === null || $currentToken === '') {
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
throw new ApiException('请注册', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Please register', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
throw new ApiException('请重新登录', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Please login again', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
if ($currentToken !== $token) {
|
||||
throw new ApiException('请重新登录(当前账号已在其他处登录)', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Please login again (account logged in elsewhere)', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
// 优先从 Redis 缓存取玩家,避免每次请求都查库
|
||||
@@ -76,7 +76,7 @@ class TokenMiddleware implements MiddlewareInterface
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
UserCache::deleteSessionByUsername($username);
|
||||
throw new ApiException('请重新登录', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('Please login again', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
UserCache::setPlayerByUsername($username, $player->hidden(['password'])->toArray());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use support\think\Cache;
|
||||
|
||||
@@ -19,7 +19,7 @@ class LotteryService
|
||||
private int $playerId;
|
||||
private ?int $configType0Id = null;
|
||||
private ?int $configType1Id = null;
|
||||
/** @var array{t1_wight?:int,t2_wight?:int,t3_wight?:int,t4_wight?:int,t5_wight?:int} */
|
||||
/** @var array{t1_weight?:int,t2_weight?:int,t3_weight?:int,t4_weight?:int,t5_weight?:int} */
|
||||
private array $playerWeights = [];
|
||||
|
||||
public function __construct(int $playerId)
|
||||
@@ -37,7 +37,7 @@ class LotteryService
|
||||
return self::REDIS_KEY_START_INDEX . $playerId;
|
||||
}
|
||||
|
||||
/** 从 Redis 加载或根据玩家与 DiceLotteryConfig 创建并保存 */
|
||||
/** 从 Redis 加载或根据玩家与 DiceLotteryPoolConfig 创建并保存 */
|
||||
public static function getOrCreate(int $playerId): self
|
||||
{
|
||||
$key = self::getRedisKey($playerId);
|
||||
@@ -56,17 +56,17 @@ class LotteryService
|
||||
if (!$player) {
|
||||
throw new \RuntimeException('玩家不存在');
|
||||
}
|
||||
$config0 = DiceLotteryConfig::where('type', 0)->find();
|
||||
$config1 = DiceLotteryConfig::where('type', 1)->find();
|
||||
$config0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$config1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
$s = new self($playerId);
|
||||
$s->configType0Id = $config0 ? (int) $config0->id : null;
|
||||
$s->configType1Id = $config1 ? (int) $config1->id : null;
|
||||
$s->playerWeights = [
|
||||
't1_wight' => (int) ($player->t1_wight ?? 0),
|
||||
't2_wight' => (int) ($player->t2_wight ?? 0),
|
||||
't3_wight' => (int) ($player->t3_wight ?? 0),
|
||||
't4_wight' => (int) ($player->t4_wight ?? 0),
|
||||
't5_wight' => (int) ($player->t5_wight ?? 0),
|
||||
't1_weight' => (int) ($player->t1_weight ?? 0),
|
||||
't2_weight' => (int) ($player->t2_weight ?? 0),
|
||||
't3_weight' => (int) ($player->t3_weight ?? 0),
|
||||
't4_weight' => (int) ($player->t4_weight ?? 0),
|
||||
't5_weight' => (int) ($player->t5_weight ?? 0),
|
||||
];
|
||||
$s->save();
|
||||
return $s;
|
||||
@@ -83,45 +83,59 @@ class LotteryService
|
||||
Cache::set($key, json_encode($data), self::EXPIRE);
|
||||
}
|
||||
|
||||
/** 根据奖池配置的 t1_wight..t5_wight 权重随机抽取档位 T1-T5 */
|
||||
public static function drawTierByWeights(DiceLotteryConfig $config): string
|
||||
/** 根据奖池配置的 t1_weight..t5_weight 权重随机抽取档位 T1-T5 */
|
||||
public static function drawTierByWeights(DiceLotteryPoolConfig $config): string
|
||||
{
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$weights = [
|
||||
(int) ($config->t1_wight ?? 0),
|
||||
(int) ($config->t2_wight ?? 0),
|
||||
(int) ($config->t3_wight ?? 0),
|
||||
(int) ($config->t4_wight ?? 0),
|
||||
(int) ($config->t5_wight ?? 0),
|
||||
(int) ($config->t1_weight ?? 0),
|
||||
(int) ($config->t2_weight ?? 0),
|
||||
(int) ($config->t3_weight ?? 0),
|
||||
(int) ($config->t4_weight ?? 0),
|
||||
(int) ($config->t5_weight ?? 0),
|
||||
];
|
||||
return self::drawTierByWeightArray($tiers, $weights);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据玩家 t1_wight~t5_wight 权重随机抽取中奖档位 T1-T5
|
||||
* t1_wight=T1, t2_wight=T2, t3_wight=T3, t4_wight=T4, t5_wight=T5
|
||||
* 根据玩家 t1_weight~t5_weight 权重随机抽取中奖档位 T1-T5
|
||||
* t1_weight=T1, t2_weight=T2, t3_weight=T3, t4_weight=T4, t5_weight=T5
|
||||
*/
|
||||
public static function drawTierByPlayerWeights(DicePlayer $player): string
|
||||
{
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$weights = [
|
||||
(int) ($player->t1_wight ?? 0),
|
||||
(int) ($player->t2_wight ?? 0),
|
||||
(int) ($player->t3_wight ?? 0),
|
||||
(int) ($player->t4_wight ?? 0),
|
||||
(int) ($player->t5_wight ?? 0),
|
||||
(int) ($player->t1_weight ?? 0),
|
||||
(int) ($player->t2_weight ?? 0),
|
||||
(int) ($player->t3_weight ?? 0),
|
||||
(int) ($player->t4_weight ?? 0),
|
||||
(int) ($player->t5_weight ?? 0),
|
||||
];
|
||||
return self::drawTierByWeightArray($tiers, $weights);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 T1-T5 权重数组抽取档位(用于测试自定义档位概率)
|
||||
* @param array $tierWeights 如 ['T1'=>100, 'T2'=>200, ...] 或 [100,200,300,400,500]
|
||||
*/
|
||||
public static function drawTierByWeightsFromArray(array $tierWeights): string
|
||||
{
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$weights = [];
|
||||
foreach ($tiers as $i => $t) {
|
||||
$weights[] = (int) ($tierWeights[$t] ?? $tierWeights[$i] ?? 0);
|
||||
}
|
||||
return self::drawTierByWeightArray($tiers, $weights);
|
||||
}
|
||||
|
||||
/** 按档位权重数组抽取 T1-T5 */
|
||||
private static function drawTierByWeightArray(array $tiers, array $weights): string
|
||||
{
|
||||
$total = array_sum($weights);
|
||||
if ($total <= 0) {
|
||||
return $tiers[array_rand($tiers)];
|
||||
return $tiers[random_int(0, count($tiers) - 1)];
|
||||
}
|
||||
$r = mt_rand(1, $total);
|
||||
$r = random_int(1, $total);
|
||||
$acc = 0;
|
||||
foreach ($weights as $i => $w) {
|
||||
$acc += $w;
|
||||
@@ -145,7 +159,7 @@ class LotteryService
|
||||
return 0;
|
||||
}
|
||||
$total = $paid + $free;
|
||||
$r = mt_rand(1, $total);
|
||||
$r = random_int(1, $total);
|
||||
return $r <= $paid ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
123
server/app/api/util/ApiLang.php
Normal file
123
server/app/api/util/ApiLang.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\util;
|
||||
|
||||
use support\Request;
|
||||
|
||||
/**
|
||||
* API 多语言(兼容 Webman 多语言配置)
|
||||
* 根据请求头 lang(zh=中文,en=英文)返回对应文案;
|
||||
* 无 lang 请求头时使用 config('translation.locale') 推断(zh_CN/zh→中文,en→英文)
|
||||
*/
|
||||
class ApiLang
|
||||
{
|
||||
private const LANG_HEADER = 'lang';
|
||||
private const LANG_EN = 'en';
|
||||
private const LANG_ZH = 'zh';
|
||||
|
||||
/** @var array<string, array<string, string>> lang => [ key => message ] */
|
||||
private static array $messages = [];
|
||||
|
||||
/**
|
||||
* 从请求中获取语言:优先读 header lang,否则按 Webman config('translation.locale') 推断
|
||||
*/
|
||||
public static function getLang(?Request $request = null): string
|
||||
{
|
||||
$request = $request ?? (function_exists('request') ? request() : null);
|
||||
if ($request !== null) {
|
||||
$lang = $request->header(self::LANG_HEADER);
|
||||
if ($lang !== null && $lang !== '') {
|
||||
$lang = strtolower(trim((string) $lang));
|
||||
if ($lang === self::LANG_EN) {
|
||||
return self::LANG_EN;
|
||||
}
|
||||
if ($lang === self::LANG_ZH || $lang === 'chs') {
|
||||
return self::LANG_ZH;
|
||||
}
|
||||
}
|
||||
}
|
||||
$locale = (string) (function_exists('config') ? config('translation.locale', 'zh_CN') : 'zh_CN');
|
||||
return stripos($locale, 'en') !== false ? self::LANG_EN : self::LANG_ZH;
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译文案(对外接口 message):
|
||||
* - 推荐:抛英文 key(如 USER_NOT_FOUND),根据 lang 返回对应语言
|
||||
* - 兼容:仍抛中文原文时,lang=en 按旧映射翻译,否则原样返回
|
||||
*
|
||||
* 语言文件优先从 Webman config('translation.path')/api/{lang}.php 加载
|
||||
*/
|
||||
public static function translate(string $message, ?Request $request = null): string
|
||||
{
|
||||
$lang = self::getLang($request);
|
||||
$map = self::loadMessages($lang);
|
||||
if (isset($map[$message])) {
|
||||
return (string) $map[$message];
|
||||
}
|
||||
|
||||
// 若传入的是中文/原文,则按固定规则生成英文 key(MSG_XXXXXXXX)再翻译
|
||||
$key = self::toMsgKey($message);
|
||||
if ($key !== null && isset($map[$key])) {
|
||||
return (string) $map[$key];
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载某语言的 API 文案(推荐:key=英文,value=对应语言文案)
|
||||
*/
|
||||
private static function loadMessages(string $locale): array
|
||||
{
|
||||
if (isset(self::$messages[$locale])) {
|
||||
return self::$messages[$locale];
|
||||
}
|
||||
$path = null;
|
||||
if (function_exists('config')) {
|
||||
$base = rtrim((string) config('translation.path', ''), DIRECTORY_SEPARATOR);
|
||||
if ($base !== '') {
|
||||
$path = $base . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . $locale . '.php';
|
||||
}
|
||||
}
|
||||
if ($path !== null && is_file($path)) {
|
||||
self::$messages[$locale] = require $path;
|
||||
return self::$messages[$locale];
|
||||
}
|
||||
|
||||
// 回退到 app/api/lang/{lang}.php(同样使用英文 key)
|
||||
$fallback = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $locale . '.php';
|
||||
self::$messages[$locale] = is_file($fallback) ? (require $fallback) : [];
|
||||
return self::$messages[$locale];
|
||||
}
|
||||
|
||||
/**
|
||||
* 将原文转换为英文 key(只包含英文字符/数字/下划线):MSG_XXXXXXXX(crc32)
|
||||
* 若入参已经是英文 key,则返回 null(表示无需转换)
|
||||
*/
|
||||
private static function toMsgKey(string $message): ?string
|
||||
{
|
||||
$trim = trim($message);
|
||||
if ($trim === '') {
|
||||
return null;
|
||||
}
|
||||
// 已经是英文错误码 key(只允许 A-Z/0-9/_,且至少 3 位)
|
||||
if (preg_match('/^[A-Z0-9_]{3,}$/', $trim) === 1) {
|
||||
return null;
|
||||
}
|
||||
return 'MSG_' . strtoupper(sprintf('%08X', crc32($trim)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 带占位符的翻译,如 translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin])
|
||||
* 先翻译再替换(en 文案使用 %s 占位)
|
||||
*/
|
||||
public static function translateParams(string $message, array $params = [], ?Request $request = null): string
|
||||
{
|
||||
$translated = self::translate($message, $request);
|
||||
if ($params !== []) {
|
||||
$translated = sprintf($translated, ...$params);
|
||||
}
|
||||
return $translated;
|
||||
}
|
||||
}
|
||||
237
server/app/dice/controller/DiceDashboardController.php
Normal file
237
server/app/dice/controller/DiceDashboardController.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\dice\controller;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
|
||||
/**
|
||||
* 大富翁工作台数据统计
|
||||
*/
|
||||
class DiceDashboardController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 工作台卡片统计:玩家注册、充值、提现、游玩次数(含较上周对比)
|
||||
*/
|
||||
#[Permission('工作台数据统计', 'core:console:list')]
|
||||
public function statistics(): Response
|
||||
{
|
||||
$thisWeekStart = date('Y-m-d 00:00:00', strtotime('monday this week'));
|
||||
$thisWeekEnd = date('Y-m-d 23:59:59', strtotime('sunday this week'));
|
||||
$lastWeekStart = date('Y-m-d 00:00:00', strtotime('monday last week'));
|
||||
$lastWeekEnd = date('Y-m-d 23:59:59', strtotime('sunday last week'));
|
||||
|
||||
$adminInfo = $this->adminInfo ?? null;
|
||||
|
||||
$playerQueryThis = DicePlayer::whereBetween('create_time', [$thisWeekStart, $thisWeekEnd]);
|
||||
$playerQueryLast = DicePlayer::whereBetween('create_time', [$lastWeekStart, $lastWeekEnd]);
|
||||
AdminScopeHelper::applyAdminScope($playerQueryThis, $adminInfo);
|
||||
AdminScopeHelper::applyAdminScope($playerQueryLast, $adminInfo);
|
||||
$playerThis = $playerQueryThis->count();
|
||||
$playerLast = $playerQueryLast->count();
|
||||
|
||||
$chargeQueryThis = DicePlayerWalletRecord::where('type', 0)
|
||||
->where('coin', '>', 0)
|
||||
->whereBetween('create_time', [$thisWeekStart, $thisWeekEnd]);
|
||||
$chargeQueryLast = DicePlayerWalletRecord::where('type', 0)
|
||||
->where('coin', '>', 0)
|
||||
->whereBetween('create_time', [$lastWeekStart, $lastWeekEnd]);
|
||||
AdminScopeHelper::applyAdminScope($chargeQueryThis, $adminInfo);
|
||||
AdminScopeHelper::applyAdminScope($chargeQueryLast, $adminInfo);
|
||||
$chargeThis = $chargeQueryThis->sum('coin');
|
||||
$chargeLast = $chargeQueryLast->sum('coin');
|
||||
|
||||
$withdrawQueryThis = DicePlayerWalletRecord::where('type', 1)
|
||||
->whereBetween('create_time', [$thisWeekStart, $thisWeekEnd]);
|
||||
$withdrawQueryLast = DicePlayerWalletRecord::where('type', 1)
|
||||
->whereBetween('create_time', [$lastWeekStart, $lastWeekEnd]);
|
||||
AdminScopeHelper::applyAdminScope($withdrawQueryThis, $adminInfo);
|
||||
AdminScopeHelper::applyAdminScope($withdrawQueryLast, $adminInfo);
|
||||
$withdrawThis = $withdrawQueryThis->sum(Db::raw('ABS(coin)'));
|
||||
$withdrawLast = $withdrawQueryLast->sum(Db::raw('ABS(coin)'));
|
||||
|
||||
$playQueryThis = DicePlayRecord::whereBetween('create_time', [$thisWeekStart, $thisWeekEnd]);
|
||||
$playQueryLast = DicePlayRecord::whereBetween('create_time', [$lastWeekStart, $lastWeekEnd]);
|
||||
AdminScopeHelper::applyAdminScope($playQueryThis, $adminInfo);
|
||||
AdminScopeHelper::applyAdminScope($playQueryLast, $adminInfo);
|
||||
$playThis = $playQueryThis->count();
|
||||
$playLast = $playQueryLast->count();
|
||||
|
||||
$playerChange = $this->calcWeekChange($playerThis, $playerLast);
|
||||
$chargeChange = $this->calcWeekChange((float) $chargeThis, (float) $chargeLast);
|
||||
$withdrawChange = $this->calcWeekChange((float) $withdrawThis, (float) $withdrawLast);
|
||||
$playChange = $this->calcWeekChange($playThis, $playLast);
|
||||
|
||||
return $this->success([
|
||||
'player_count' => $playerThis,
|
||||
'player_count_change' => $playerChange,
|
||||
'charge_amount' => (float) $chargeThis,
|
||||
'charge_amount_change' => $chargeChange,
|
||||
'withdraw_amount' => (float) $withdrawThis,
|
||||
'withdraw_amount_change' => $withdrawChange,
|
||||
'play_count' => $playThis,
|
||||
'play_count_change' => $playChange,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 近期玩家充值统计(近10天每日充值金额)
|
||||
*/
|
||||
#[Permission('工作台数据统计', 'core:console:list')]
|
||||
public function rechargeChart(): Response
|
||||
{
|
||||
$adminInfo = $this->adminInfo ?? null;
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($adminInfo);
|
||||
$adminCondition = '';
|
||||
if ($allowedIds !== null) {
|
||||
if (empty($allowedIds)) {
|
||||
$data = [];
|
||||
foreach (range(0, 9) as $n) {
|
||||
$data[] = ['recharge_date' => date('Y-m-d', strtotime("-{$n} days")), 'recharge_amount' => 0];
|
||||
}
|
||||
$data = array_reverse($data);
|
||||
return $this->success([
|
||||
'recharge_amount' => array_map('floatval', array_column($data, 'recharge_amount')),
|
||||
'recharge_date' => array_column($data, 'recharge_date'),
|
||||
]);
|
||||
}
|
||||
$idsStr = implode(',', array_map('intval', $allowedIds));
|
||||
$adminCondition = " AND w.admin_id IN ({$idsStr})";
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
d.date AS recharge_date,
|
||||
IFNULL(SUM(w.coin), 0) AS recharge_amount
|
||||
FROM
|
||||
(SELECT CURDATE() - INTERVAL (a.N) DAY AS date
|
||||
FROM (SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
|
||||
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
|
||||
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a
|
||||
) d
|
||||
LEFT JOIN dice_player_wallet_record w
|
||||
ON DATE(w.create_time) = d.date AND w.type = 0 AND w.coin > 0 {$adminCondition}
|
||||
GROUP BY d.date
|
||||
ORDER BY d.date ASC
|
||||
";
|
||||
$data = Db::query($sql);
|
||||
return $this->success([
|
||||
'recharge_amount' => array_map('floatval', array_column($data, 'recharge_amount')),
|
||||
'recharge_date' => array_column($data, 'recharge_date'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 月度玩家充值汇总(当年1-12月每月充值金额)
|
||||
*/
|
||||
#[Permission('工作台数据统计', 'core:console:list')]
|
||||
public function rechargeBarChart(): Response
|
||||
{
|
||||
$adminInfo = $this->adminInfo ?? null;
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($adminInfo);
|
||||
$adminCondition = '';
|
||||
if ($allowedIds !== null) {
|
||||
if (empty($allowedIds)) {
|
||||
$data = [];
|
||||
for ($m = 1; $m <= 12; $m++) {
|
||||
$data[] = ['recharge_month' => sprintf('%02d月', $m), 'recharge_amount' => 0];
|
||||
}
|
||||
return $this->success([
|
||||
'recharge_amount' => array_map('floatval', array_column($data, 'recharge_amount')),
|
||||
'recharge_month' => array_column($data, 'recharge_month'),
|
||||
]);
|
||||
}
|
||||
$idsStr = implode(',', array_map('intval', $allowedIds));
|
||||
$adminCondition = " AND w.admin_id IN ({$idsStr})";
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
CONCAT(LPAD(m.month_num, 2, '0'), '月') AS recharge_month,
|
||||
IFNULL(SUM(w.coin), 0) AS recharge_amount
|
||||
FROM
|
||||
(SELECT 1 AS month_num UNION ALL SELECT 2 UNION ALL SELECT 3
|
||||
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
|
||||
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
|
||||
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12) m
|
||||
LEFT JOIN dice_player_wallet_record w
|
||||
ON YEAR(w.create_time) = YEAR(CURDATE())
|
||||
AND MONTH(w.create_time) = m.month_num
|
||||
AND w.type = 0 AND w.coin > 0 {$adminCondition}
|
||||
GROUP BY m.month_num
|
||||
ORDER BY m.month_num ASC
|
||||
";
|
||||
$data = Db::query($sql);
|
||||
return $this->success([
|
||||
'recharge_amount' => array_map('floatval', array_column($data, 'recharge_amount')),
|
||||
'recharge_month' => array_column($data, 'recharge_month'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作台-玩家充值记录:最新50条(admin_id=当前管理员及子管理员,type=0)
|
||||
* 返回:玩家账号(DicePlayer.username)、充值金额(coin)、充值时间(create_time)
|
||||
*/
|
||||
#[Permission('工作台数据统计', 'core:console:list')]
|
||||
public function walletRecordList(): Response
|
||||
{
|
||||
$adminInfo = $this->adminInfo ?? null;
|
||||
$query = DicePlayerWalletRecord::with([
|
||||
'dicePlayer' => function ($q) {
|
||||
$q->field('id,username');
|
||||
},
|
||||
])
|
||||
->where('type', 0)
|
||||
->order('create_time', 'desc')
|
||||
->limit(50);
|
||||
AdminScopeHelper::applyAdminScope($query, $adminInfo);
|
||||
$list = $query->select();
|
||||
$rows = [];
|
||||
foreach ($list as $row) {
|
||||
$player = $row->dicePlayer;
|
||||
$rows[] = [
|
||||
'player_name' => $player ? $player->getAttr('username') : '',
|
||||
'coin' => $row->getAttr('coin'),
|
||||
'create_time' => $row->getAttr('create_time'),
|
||||
];
|
||||
}
|
||||
return $this->success($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作台-新增玩家记录:最新50条(admin_id=当前管理员及子管理员)
|
||||
* 返回:玩家账号(username)、余额(coin)、抽奖券(total_ticket_count)
|
||||
*/
|
||||
#[Permission('工作台数据统计', 'core:console:list')]
|
||||
public function newPlayerList(): Response
|
||||
{
|
||||
$adminInfo = $this->adminInfo ?? null;
|
||||
$query = DicePlayer::field('username,coin,total_ticket_count,create_time')
|
||||
->order('create_time', 'desc')
|
||||
->limit(50);
|
||||
AdminScopeHelper::applyAdminScope($query, $adminInfo);
|
||||
$list = $query->select();
|
||||
$rows = [];
|
||||
foreach ($list as $row) {
|
||||
$rows[] = [
|
||||
'name' => $row->getAttr('username'),
|
||||
'coin' => $row->getAttr('coin'),
|
||||
'total_ticket_count' => $row->getAttr('total_ticket_count'),
|
||||
];
|
||||
}
|
||||
return $this->success($rows);
|
||||
}
|
||||
|
||||
private function calcWeekChange($current, $last): float
|
||||
{
|
||||
if ($last == 0) {
|
||||
return $current > 0 ? 100.0 : 0.0;
|
||||
}
|
||||
return round((($current - $last) / $last) * 100, 1);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class DiceConfigController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ class DiceConfigController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ class DiceConfigController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ class DiceConfigController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\lottery_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\lottery_config\DiceLotteryConfigLogic;
|
||||
use app\dice\validate\lottery_config\DiceLotteryConfigValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 色子奖池配置控制器
|
||||
*/
|
||||
class DiceLotteryConfigController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceLotteryConfigLogic();
|
||||
$this->validate = new DiceLotteryConfigValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_config:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['name', ''],
|
||||
['type', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置读取', 'dice:lottery_config:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置添加', 'dice:lottery_config:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_config:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置删除', 'dice:lottery_config:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\lottery_pool_config;
|
||||
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\lottery_pool_config\DiceLotteryPoolConfigLogic;
|
||||
use app\dice\validate\lottery_pool_config\DiceLotteryPoolConfigValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 色子奖池配置控制器
|
||||
*/
|
||||
class DiceLotteryPoolConfigController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceLotteryPoolConfigLogic();
|
||||
$this->validate = new DiceLotteryPoolConfigValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,用于 lottery_config_id 下拉(值为 id,显示为 name),并附带 T1-T5 档位权重
|
||||
* @param Request $request
|
||||
* @return Response 返回 [ ['id' => int, 'name' => string, 't1_weight' => int, ... 't5_weight' => int], ... ]
|
||||
*/
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:index')]
|
||||
public function getOptions(Request $request): Response
|
||||
{
|
||||
$list = DiceLotteryPoolConfig::field('id,name,t1_weight,t2_weight,t3_weight,t4_weight,t5_weight')
|
||||
->order('id', 'asc')
|
||||
->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return [
|
||||
'id' => (int) $item['id'],
|
||||
'name' => (string) ($item['name'] ?? ''),
|
||||
't1_weight' => (int) ($item['t1_weight'] ?? 0),
|
||||
't2_weight' => (int) ($item['t2_weight'] ?? 0),
|
||||
't3_weight' => (int) ($item['t3_weight'] ?? 0),
|
||||
't4_weight' => (int) ($item['t4_weight'] ?? 0),
|
||||
't5_weight' => (int) ($item['t5_weight'] ?? 0),
|
||||
];
|
||||
})->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['name', ''],
|
||||
['type', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置读取', 'dice:lottery_pool_config:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置添加', 'dice:lottery_pool_config:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('色子奖池配置删除', 'dice:lottery_pool_config:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前彩金池(Redis 实例化,无则按 type=0 创建)
|
||||
* 返回含玩家累计盈利 profit_amount 实时值,供前端轮询展示
|
||||
*/
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:getCurrentPool')]
|
||||
public function getCurrentPool(Request $request): Response
|
||||
{
|
||||
$data = $this->logic->getCurrentPool();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前彩金池:仅可修改 safety_line、t1_weight~t5_weight,不可修改 profit_amount
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:updateCurrentPool')]
|
||||
public function updateCurrentPool(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->logic->updateCurrentPool($data);
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置当前彩金池的玩家累计盈利:将 profit_amount 置为 0
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:resetProfitAmount')]
|
||||
public function resetProfitAmount(Request $request): Response
|
||||
{
|
||||
$this->logic->resetProfitAmount();
|
||||
return $this->success('reset success');
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\play_record;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\play_record\DicePlayRecordLogic;
|
||||
use app\dice\validate\play_record\DicePlayRecordValidate;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@@ -46,17 +47,29 @@ class DicePlayRecordController extends BaseController
|
||||
['is_win', ''],
|
||||
['win_coin_min', ''],
|
||||
['win_coin_max', ''],
|
||||
['roll_number_min', ''],
|
||||
['roll_number_max', ''],
|
||||
['reward_ui_text', ''],
|
||||
['reward_tier', ''],
|
||||
['direction', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
'diceRewardConfig',
|
||||
'diceLotteryConfig',
|
||||
'diceLotteryPoolConfig',
|
||||
]);
|
||||
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费抽奖(lottery_type=0)次数×100 - 玩家总收益(win_coin 求和)
|
||||
$sumQuery = clone $query;
|
||||
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||
$paidCountQuery = clone $query;
|
||||
$paidCount = (int) $paidCountQuery->where('lottery_type', 0)->count();
|
||||
$totalWinCoin = $paidCount * 100 - $playerTotalWin;
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
@@ -66,7 +79,9 @@ class DicePlayRecordController extends BaseController
|
||||
#[Permission('玩家抽奖记录列表', 'dice:play_record:index:index')]
|
||||
public function getPlayerOptions(Request $request): Response
|
||||
{
|
||||
$list = DicePlayer::field('id,username')->select();
|
||||
$query = DicePlayer::field('id,username');
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'username' => $item['username'] ?? ''];
|
||||
})->toArray();
|
||||
@@ -79,7 +94,7 @@ class DicePlayRecordController extends BaseController
|
||||
#[Permission('玩家抽奖记录列表', 'dice:play_record:index:index')]
|
||||
public function getLotteryConfigOptions(Request $request): Response
|
||||
{
|
||||
$list = DiceLotteryConfig::field('id,name')->select();
|
||||
$list = DiceLotteryPoolConfig::field('id,name')->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'name' => $item['name'] ?? ''];
|
||||
})->toArray();
|
||||
@@ -113,12 +128,15 @@ class DicePlayRecordController extends BaseController
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,9 +151,9 @@ class DicePlayRecordController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,9 +169,9 @@ class DicePlayRecordController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,13 +185,13 @@ class DicePlayRecordController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\play_record_test;
|
||||
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\play_record_test\DicePlayRecordTestLogic;
|
||||
use app\dice\validate\play_record_test\DicePlayRecordTestValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use support\think\Db;
|
||||
|
||||
/**
|
||||
* 玩家抽奖记录(测试数据)控制器
|
||||
*/
|
||||
class DicePlayRecordTestController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DicePlayRecordTestLogic();
|
||||
$this->validate = new DicePlayRecordTestValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表,并在结果中附带当前筛选条件下测试数据的平台总盈利 total_win_coin(付费抽奖次数×100 - 玩家总收益)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)列表', 'dice:play_record_test:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['lottery_type', ''],
|
||||
['direction', ''],
|
||||
['is_win', ''],
|
||||
['win_coin_min', ''],
|
||||
['win_coin_max', ''],
|
||||
['reward_tier', ''],
|
||||
['roll_number', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$query->with(['diceLotteryPoolConfig', 'diceRewardConfig']);
|
||||
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费抽奖(lottery_type=0)次数×100 - 玩家总收益(win_coin 求和)
|
||||
$sumQuery = clone $query;
|
||||
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||
$paidCountQuery = clone $query;
|
||||
$paidCount = (int) $paidCountQuery->where('lottery_type', 0)->count();
|
||||
$totalWinCoin = $paidCount * 100 - $playerTotalWin;
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)读取', 'dice:play_record_test:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)添加', 'dice:play_record_test:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)修改', 'dice:play_record_test:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键删除所有测试数据:清空 dice_play_record_test 表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:clearAll')]
|
||||
public function clearAll(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$table = (new \app\dice\model\play_record_test\DicePlayRecordTest())->getTable();
|
||||
Db::execute('TRUNCATE TABLE `' . $table . '`');
|
||||
return $this->success('all test data cleared');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail('clear failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,20 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\player;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\player\DicePlayerLogic;
|
||||
use app\dice\validate\player\DicePlayerValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\api\cache\UserCache;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
|
||||
/**
|
||||
* 大富翁-玩家控制器
|
||||
* 玩家控制器
|
||||
*/
|
||||
class DicePlayerController extends BaseController
|
||||
{
|
||||
@@ -28,12 +33,55 @@ class DicePlayerController extends BaseController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取彩金池配置选项(id、name)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家列表', 'dice:player:index:index')]
|
||||
public function getLotteryConfigOptions(Request $request): Response
|
||||
{
|
||||
$list = DiceLotteryPoolConfig::field('id,name')->order('id', 'asc')->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => (int) $item['id'], 'name' => (string) ($item['name'] ?? '')];
|
||||
})->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台管理员选项(id、username、realname)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家列表', 'dice:player:index:index')]
|
||||
public function getSystemUserOptions(Request $request): Response
|
||||
{
|
||||
$query = SystemUser::field('id,username,realname')->where('status', 1)->order('id', 'asc');
|
||||
if (isset($this->adminInfo['id']) && (int) $this->adminInfo['id'] > 1) {
|
||||
$deptList = $this->adminInfo['deptList'] ?? [];
|
||||
if (!empty($deptList)) {
|
||||
$query->auth($deptList);
|
||||
}
|
||||
}
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
$label = trim((string) ($item['realname'] ?? '')) ?: (string) ($item['username'] ?? '');
|
||||
return [
|
||||
'id' => (int) $item['id'],
|
||||
'username' => (string) ($item['username'] ?? ''),
|
||||
'realname' => (string) ($item['realname'] ?? ''),
|
||||
'label' => $label ?: (string) $item['id'],
|
||||
];
|
||||
})->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家列表', 'dice:player:index:index')]
|
||||
#[Permission('玩家列表', 'dice:player:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
@@ -42,9 +90,11 @@ class DicePlayerController extends BaseController
|
||||
['phone', ''],
|
||||
['status', ''],
|
||||
['coin', ''],
|
||||
['is_up', ''],
|
||||
['lottery_config_id', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$query->with(['diceLotteryPoolConfig']);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
@@ -54,17 +104,20 @@ class DicePlayerController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家读取', 'dice:player:index:read')]
|
||||
#[Permission('玩家读取', 'dice:player:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,17 +125,26 @@ class DicePlayerController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家添加', 'dice:player:index:save')]
|
||||
#[Permission('玩家添加', 'dice:player:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
// 类型转化
|
||||
if (empty($data['admin_id']) && isset($this->adminInfo['id']) && (int) $this->adminInfo['id'] > 0) {
|
||||
$data['admin_id'] = (int) $this->adminInfo['id'];
|
||||
}
|
||||
$result = $this->logic->add($data);
|
||||
if ($result && isset($result['id'])) {
|
||||
// 出于安全:删除该玩家缓存,后续 API 按需重建
|
||||
UserCache::deleteUser($result['id']);
|
||||
$player = DicePlayer::find($result['id']);
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('add success');
|
||||
}
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,37 +152,62 @@ class DicePlayerController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家修改', 'dice:player:index:update')]
|
||||
#[Permission('玩家修改', 'dice:player:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$model = $this->logic->read($data['id'] ?? 0);
|
||||
if ($model) {
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to update this record');
|
||||
}
|
||||
}
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
// 出于安全:删除该玩家缓存,后续 API 按需重建
|
||||
UserCache::deleteUser($data['id']);
|
||||
$player = DicePlayer::find($data['id']);
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('update success');
|
||||
}
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅更新状态(列表内开关用)
|
||||
* 更新状态
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家修改', 'dice:player:index:update')]
|
||||
#[Permission('玩家状态修改', 'dice:player:index:update')]
|
||||
public function updateStatus(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$status = $request->input('status');
|
||||
if ($id === null || $id === '') {
|
||||
return $this->fail('缺少 id');
|
||||
return $this->fail('missing parameter id');
|
||||
}
|
||||
if ($status === null || $status === '') {
|
||||
return $this->fail('缺少 status');
|
||||
return $this->fail('missing parameter status');
|
||||
}
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to update this record');
|
||||
}
|
||||
}
|
||||
$this->logic->edit($id, ['status' => (int) $status]);
|
||||
return $this->success('修改成功');
|
||||
// 出于安全:删除该玩家缓存,后续 API 按需重建
|
||||
UserCache::deleteUser($id);
|
||||
$player = DicePlayer::find($id);
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('update success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,19 +215,42 @@ class DicePlayerController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大富翁-玩家删除', 'dice:player:index:destroy')]
|
||||
#[Permission('玩家删除', 'dice:player:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$ids = is_array($ids) ? $ids : explode(',', (string) $ids);
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null) {
|
||||
$models = $this->logic->model->whereIn('id', $ids)->column('admin_id', 'id');
|
||||
$validIds = [];
|
||||
foreach ($ids as $id) {
|
||||
$adminId = (int) ($models[$id] ?? 0);
|
||||
if (in_array($adminId, $allowedIds, true)) {
|
||||
$validIds[] = $id;
|
||||
}
|
||||
}
|
||||
$ids = $validIds;
|
||||
if (empty($ids)) {
|
||||
return $this->fail('no permission to delete selected data');
|
||||
}
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
// 出于安全:删除相关玩家缓存,后续 API 按需重建
|
||||
foreach ($ids as $id) {
|
||||
UserCache::deleteUser($id);
|
||||
$player = DicePlayer::find($id);
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
}
|
||||
return $this->success('delete success');
|
||||
}
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\player_ticket_record;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\player_ticket_record\DicePlayerTicketRecordLogic;
|
||||
use app\dice\validate\player_ticket_record\DicePlayerTicketRecordValidate;
|
||||
@@ -51,6 +52,7 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
['create_time_max', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
]);
|
||||
@@ -66,7 +68,9 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
#[Permission('抽奖券获取记录列表', 'dice:player_ticket_record:index:index')]
|
||||
public function getPlayerOptions(Request $request): Response
|
||||
{
|
||||
$list = DicePlayer::field('id,username')->select();
|
||||
$query = DicePlayer::field('id,username');
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'username' => $item['username'] ?? ''];
|
||||
})->toArray();
|
||||
@@ -83,12 +87,15 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,9 +110,9 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +128,9 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +144,13 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\player_wallet_record;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\player_wallet_record\DicePlayerWalletRecordLogic;
|
||||
use app\dice\validate\player_wallet_record\DicePlayerWalletRecordValidate;
|
||||
@@ -47,6 +48,7 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
['create_time_max', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
'operator',
|
||||
@@ -63,7 +65,9 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
#[Permission('玩家钱包流水列表', 'dice:player_wallet_record:index:index')]
|
||||
public function getPlayerOptions(Request $request): Response
|
||||
{
|
||||
$list = DicePlayer::field('id,username')->select();
|
||||
$query = DicePlayer::field('id,username');
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'username' => $item['username'] ?? ''];
|
||||
})->toArray();
|
||||
@@ -81,11 +85,15 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
{
|
||||
$playerId = $request->input('player_id');
|
||||
if ($playerId === null || $playerId === '') {
|
||||
return $this->fail('缺少 player_id');
|
||||
return $this->fail('missing player_id');
|
||||
}
|
||||
$player = DicePlayer::field('coin')->where('id', $playerId)->find();
|
||||
$player = DicePlayer::field('coin,admin_id')->where('id', $playerId)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('玩家不存在');
|
||||
return $this->fail('Player not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($player->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to operate this player');
|
||||
}
|
||||
return $this->success(['wallet_before' => (float) $player['coin']]);
|
||||
}
|
||||
@@ -100,12 +108,15 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +124,7 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:save')]
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:adminOperate')]
|
||||
public function adminOperate(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
@@ -122,13 +133,13 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
$coin = isset($data['coin']) ? (float) $data['coin'] : null;
|
||||
|
||||
if ($playerId === null || $playerId === '') {
|
||||
return $this->fail('请选择玩家');
|
||||
return $this->fail('please select player');
|
||||
}
|
||||
if (!in_array($type, [3, 4], true)) {
|
||||
return $this->fail('操作类型必须为 3=加点 或 4=扣点');
|
||||
return $this->fail('operation type must be 3 (add) or 4 (deduct)');
|
||||
}
|
||||
if ($coin === null || $coin <= 0) {
|
||||
return $this->fail('平台币变动必须大于 0');
|
||||
return $this->fail('Coin change must be greater than 0');
|
||||
}
|
||||
|
||||
$data['player_id'] = $playerId;
|
||||
@@ -152,35 +163,25 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
}
|
||||
}
|
||||
if ($adminId === null || $adminId <= 0) {
|
||||
return $this->fail('请先登录');
|
||||
return $this->fail('please login first');
|
||||
}
|
||||
|
||||
$player = DicePlayer::field('admin_id')->where('id', $playerId)->find();
|
||||
if ($player) {
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($player->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('no permission to operate this player');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->logic->adminOperate($data, $adminId);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
@@ -193,30 +194,9 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水删除', 'dice:player_wallet_record:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
199
server/app/dice/controller/reward/DiceRewardController.php
Normal file
199
server/app/dice/controller/reward/DiceRewardController.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\reward;
|
||||
|
||||
use app\dice\logic\reward\DiceRewardLogic;
|
||||
use app\dice\logic\reward_config_record\DiceRewardConfigRecordLogic;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use support\think\Db;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 奖励对照控制器(dice_reward,按方向分页列表 + 权重编辑)
|
||||
*/
|
||||
class DiceRewardController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 分页列表,按 direction 区分顺时针(0)/逆时针(1)
|
||||
* 参数:direction(必), tier(选), page, limit, orderField, orderType
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$direction = $request->input('direction', null);
|
||||
if ($direction === null || $direction === '') {
|
||||
return $this->fail('please provide direction (0=clockwise, 1=counterclockwise)');
|
||||
}
|
||||
$direction = (int) $direction;
|
||||
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
|
||||
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
|
||||
}
|
||||
$tier = $request->input('tier', '');
|
||||
$page = (int) $request->input('page', 1);
|
||||
$limit = (int) $request->input('limit', 10);
|
||||
$orderField = $request->input('orderField', 'r.tier');
|
||||
$orderType = $request->input('orderType', 'asc');
|
||||
|
||||
$logic = new DiceRewardLogic();
|
||||
$data = $logic->getListWithConfig($direction, [
|
||||
'tier' => $tier,
|
||||
'orderField' => $orderField,
|
||||
'orderType' => $orderType,
|
||||
], $page, $limit);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按档位分组获取当前方向的配置+权重(单方向,用于兼容)
|
||||
* 参数:direction 0=顺时针 1=逆时针
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
public function weightRatioList(Request $request): Response
|
||||
{
|
||||
$direction = (int) $request->input('direction', 0);
|
||||
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
|
||||
$direction = DiceReward::DIRECTION_CLOCKWISE;
|
||||
}
|
||||
$logic = new DiceRewardLogic();
|
||||
$data = $logic->getListGroupedByTierForDirection($direction);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按档位分组获取配置+顺时针/逆时针权重(dice_reward 双方向)
|
||||
* 返回与 reward_config 权重配比一致结构,供奖励对照页弹窗同时编辑 direction=0/1
|
||||
* 拉取前先刷新缓存,保证与列表页(直查 DB)数据一致,避免表格与弹窗权重不一致
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
public function weightRatioListWithDirection(Request $request): Response
|
||||
{
|
||||
DiceReward::refreshCache();
|
||||
$logic = new DiceRewardLogic();
|
||||
$data = $logic->getListGroupedByTierWithDirection();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键测试权重:创建测试记录并启动单进程后台执行,按付费/免费、顺逆方向交替写入 dice_play_record_test
|
||||
* 参数:lottery_config_id 可选,不选则传 paid_tier_weights / free_tier_weights 自定义档位;
|
||||
* paid_s_count, paid_n_count, free_s_count, free_n_count;或兼容旧版 s_count, n_count
|
||||
*/
|
||||
#[Permission('一键测试权重', 'dice:reward:index:startWeightTest')]
|
||||
public function startWeightTest(Request $request): Response
|
||||
{
|
||||
$post = is_array($request->post()) ? $request->post() : [];
|
||||
$params = [
|
||||
'lottery_config_id' => $post['lottery_config_id'] ?? null,
|
||||
'paid_lottery_config_id' => $post['paid_lottery_config_id'] ?? null,
|
||||
'free_lottery_config_id' => $post['free_lottery_config_id'] ?? null,
|
||||
's_count' => $post['s_count'] ?? null,
|
||||
'n_count' => $post['n_count'] ?? null,
|
||||
'paid_s_count' => $post['paid_s_count'] ?? null,
|
||||
'paid_n_count' => $post['paid_n_count'] ?? null,
|
||||
'free_s_count' => $post['free_s_count'] ?? null,
|
||||
'free_n_count' => $post['free_n_count'] ?? null,
|
||||
'paid_tier_weights' => $post['paid_tier_weights'] ?? null,
|
||||
'free_tier_weights' => $post['free_tier_weights'] ?? null,
|
||||
];
|
||||
$adminId = isset($this->adminInfo['id']) ? (int) $this->adminInfo['id'] : null;
|
||||
try {
|
||||
$logic = new DiceRewardConfigRecordLogic();
|
||||
$recordId = $logic->createWeightTestRecord($params, $adminId);
|
||||
return $this->success(['record_id' => $recordId]);
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一键测试进度:total_play_count、over_play_count、status、remark
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
public function getTestProgress(Request $request): Response
|
||||
{
|
||||
$recordId = (int) $request->input('record_id', 0);
|
||||
if ($recordId <= 0) {
|
||||
return $this->fail('please provide record_id');
|
||||
}
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if (!$record) {
|
||||
return $this->fail('record not found');
|
||||
}
|
||||
$arr = $record->toArray();
|
||||
$data = [
|
||||
'total_play_count' => (int) ($arr['total_play_count'] ?? 0),
|
||||
'over_play_count' => (int) ($arr['over_play_count'] ?? 0),
|
||||
'status' => (int) ($arr['status'] ?? 0),
|
||||
'remark' => $arr['remark'] ?? null,
|
||||
'result_counts' => $arr['result_counts'] ?? null,
|
||||
'tier_counts' => $arr['tier_counts'] ?? null,
|
||||
];
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键清空测试数据:清空 dice_play_record_test 表
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
public function clearPlayRecordTest(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$table = (new DicePlayRecordTest())->getTable();
|
||||
Db::execute('TRUNCATE TABLE `' . $table . '`');
|
||||
return $this->success('test data cleared');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail('clear failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:按方向+点数批量更新权重(写入 dice_reward)
|
||||
* 参数:items: [{ grid_number, weight_clockwise, weight_counterclockwise }, ...]
|
||||
*/
|
||||
#[Permission('权重配比', 'dice:reward:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$logic = new DiceRewardLogic();
|
||||
$logic->batchUpdateWeights($items);
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权重编辑弹窗:批量更新当前方向的权重(单方向,用于兼容)
|
||||
* 参数:direction(必), items: [{ id, weight }, ...]
|
||||
*/
|
||||
#[Permission('奖励对照修改', 'dice:reward:index:update')]
|
||||
public function batchUpdateWeightsByDirection(Request $request): Response
|
||||
{
|
||||
$direction = (int) $request->post('direction', 0);
|
||||
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
|
||||
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
|
||||
}
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$logic = new DiceRewardLogic();
|
||||
$logic->batchUpdateWeightsByDirection($direction, $items);
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace app\dice\controller\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\reward_config\DiceRewardConfigLogic;
|
||||
use app\dice\logic\reward\DiceRewardLogic;
|
||||
use app\dice\validate\reward_config\DiceRewardConfigValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
@@ -63,7 +64,7 @@ class DiceRewardConfigController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +80,9 @@ class DiceRewardConfigController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +98,35 @@ class DiceRewardConfigController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新奖励索引配置(第一页:id、grid_number、ui_text、real_ev、tier、remark)
|
||||
* @param Request $request items: [{ id, grid_number?, ui_text?, real_ev?, tier?, remark? }, ...]
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('修改奖励索引', 'dice:reward_config:index:batchUpdate')]
|
||||
public function batchUpdate(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (! is_array($items)) {
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
$err = $this->logic->validateBatchUpdateItems($items);
|
||||
if ($err !== null) {
|
||||
return $this->fail($err);
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
$this->validate('batch_update', array_merge($item, ['id' => $item['id']]));
|
||||
}
|
||||
$this->logic->batchUpdate($items);
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
@@ -113,14 +137,112 @@ class DiceRewardConfigController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* T1-T5、BIGWIN 权重配比:按档位分组返回配置列表(含顺时针/逆时针权重,来自 dice_reward)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置列表', 'dice:reward_config:index:index')]
|
||||
public function weightRatioList(Request $request): Response
|
||||
{
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
$data = $rewardLogic->getListGroupedByTierWithDirection();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* T1-T5、BIGWIN 权重配比:按 DiceReward 主键 id 批量更新 weight(写入 dice_reward,修改后刷新缓存)
|
||||
* items: [ { id: DiceReward.id, weight: 1-10000 }, ... ]
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('修改色子点数权重', 'dice:reward_config:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
$rewardLogic->batchUpdateWeights($items);
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大奖权重:按 grid_number 批量保存 BIGWIN 权重(仅更新 dice_reward_config 表,不操作 dice_reward)
|
||||
* items: [ { grid_number: 5-30, weight: 0-10000 }, ... ]
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('大奖权重修改', 'dice:reward_config:index:saveBigwinWeightsByGrid')]
|
||||
public function saveBigwinWeightsByGrid(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (! is_array($items)) {
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
$err = $this->logic->validateBigwinWeightItems($items);
|
||||
if ($err !== null) {
|
||||
return $this->fail($err);
|
||||
}
|
||||
$this->logic->batchUpdateBigwinWeight($items);
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建奖励对照:按当前 dice_reward_config 为两种方向(顺时针0、逆时针1)生成所有色子可能对应的 dice_reward 记录
|
||||
* 权重默认 1,可在「奖励对照」页的权重编辑弹窗中调整
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('创建奖励对照', 'dice:reward_config:index:createRewardReference')]
|
||||
public function createRewardReference(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
$result = $rewardLogic->createRewardReferenceFromConfig();
|
||||
return $this->success($result, 'create reward mapping success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 权重配比测试:仅模拟落点统计,不创建游玩记录。按当前配置在内存中模拟 N 次抽奖,返回各 grid_number 落点次数,可选保存到 dice_reward_config_record。
|
||||
* @param Request $request test_count: 100|500|1000, save_record: bool, lottery_config_id: int|null 奖池配置ID,用于设定 T1-T5 概率
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置列表', 'dice:reward_config:index:index')]
|
||||
public function runWeightTest(Request $request): Response
|
||||
{
|
||||
$testCount = (int) $request->post('test_count', 100);
|
||||
$saveRecord = (bool) $request->post('save_record', true);
|
||||
$adminId = isset($this->adminInfo['id']) ? (int) $this->adminInfo['id'] : null;
|
||||
$lotteryConfigId = $request->post('lottery_config_id', null);
|
||||
if ($lotteryConfigId !== null && $lotteryConfigId !== '') {
|
||||
$lotteryConfigId = (int) $lotteryConfigId;
|
||||
} else {
|
||||
$lotteryConfigId = null;
|
||||
}
|
||||
try {
|
||||
$result = $this->logic->runWeightTest($testCount, $saveRecord, $adminId, $lotteryConfigId);
|
||||
return $this->success($result);
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\reward_config_record;
|
||||
|
||||
use app\dice\logic\reward_config_record\DiceRewardConfigRecordLogic;
|
||||
use app\dice\validate\reward_config_record\DiceRewardConfigRecordValidate;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录控制器
|
||||
*/
|
||||
class DiceRewardConfigRecordController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceRewardConfigRecordLogic();
|
||||
$this->validate = new DiceRewardConfigRecordValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录列表', 'dice:reward_config_record:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录读取', 'dice:reward_config_record:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
$data['admin_name'] = $this->getAdminName((int) ($data['admin_id'] ?? 0));
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据管理员 ID 获取姓名(realname 优先,否则 username)
|
||||
*/
|
||||
private function getAdminName(int $adminId): string
|
||||
{
|
||||
if ($adminId <= 0) {
|
||||
return '—';
|
||||
}
|
||||
$user = SystemUser::where('id', $adminId)->field('id,realname,username')->find();
|
||||
if (!$user) {
|
||||
return '';
|
||||
}
|
||||
$user = is_array($user) ? $user : $user->toArray();
|
||||
$name = trim((string) ($user['realname'] ?? ''));
|
||||
if ($name !== '') {
|
||||
return $name;
|
||||
}
|
||||
$name = trim((string) ($user['username'] ?? ''));
|
||||
return $name !== '' ? $name : (string) $adminId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录添加', 'dice:reward_config_record:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录修改', 'dice:reward_config_record:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录删除', 'dice:reward_config_record:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入:测试记录 → DiceReward、DiceRewardConfig(BIGWIN)、DiceLotteryPoolConfig(付费/免费 T1-T5)
|
||||
* @param Request $request record_id, paid_lottery_config_id(可选), free_lottery_config_id(可选), lottery_config_id(兼容旧版)
|
||||
*/
|
||||
#[Permission('导入权重配置', 'dice:reward_config_record:index:importFromRecord')]
|
||||
public function importFromRecord(Request $request): Response
|
||||
{
|
||||
$recordId = (int) $request->post('record_id', 0);
|
||||
if ($recordId <= 0) {
|
||||
return $this->fail('please specify test record');
|
||||
}
|
||||
$paidId = $request->post('paid_lottery_config_id', null);
|
||||
$freeId = $request->post('free_lottery_config_id', null);
|
||||
$legacyId = $request->post('lottery_config_id', null);
|
||||
$paidLotteryConfigId = $paidId !== null && $paidId !== '' ? (int) $paidId : null;
|
||||
$freeLotteryConfigId = $freeId !== null && $freeId !== '' ? (int) $freeId : null;
|
||||
$lotteryConfigId = $legacyId !== null && $legacyId !== '' ? (int) $legacyId : null;
|
||||
try {
|
||||
$this->logic->importFromRecord($recordId, $paidLotteryConfigId, $freeLotteryConfigId, $lotteryConfigId);
|
||||
return $this->success('import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
60
server/app/dice/helper/AdminScopeHelper.php
Normal file
60
server/app/dice/helper/AdminScopeHelper.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\dice\helper;
|
||||
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
|
||||
/**
|
||||
* 管理员数据范围辅助类
|
||||
* 用于获取当前管理员及其部门下属管理员可访问的数据范围
|
||||
*/
|
||||
class AdminScopeHelper
|
||||
{
|
||||
/**
|
||||
* 获取当前管理员可访问的 admin_id 列表
|
||||
* 超级管理员(id=1) 返回 null 表示不限制
|
||||
* 普通管理员返回其本人及部门下属管理员的 id 列表
|
||||
*
|
||||
* @param array|null $adminInfo 当前登录管理员信息(含 id、deptList)
|
||||
* @return int[]|null null=不限制(超级管理员),否则为可访问的 admin_id 数组
|
||||
*/
|
||||
public static function getAllowedAdminIds(?array $adminInfo): ?array
|
||||
{
|
||||
if (empty($adminInfo) || !isset($adminInfo['id'])) {
|
||||
return [];
|
||||
}
|
||||
$adminId = (int) $adminInfo['id'];
|
||||
if ($adminId <= 1) {
|
||||
return null;
|
||||
}
|
||||
$deptList = $adminInfo['deptList'] ?? [];
|
||||
if (empty($deptList) || !isset($deptList['id'])) {
|
||||
return [$adminId];
|
||||
}
|
||||
$query = SystemUser::field('id');
|
||||
$query->auth($deptList);
|
||||
$ids = $query->column('id');
|
||||
return array_map('intval', $ids ?: []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对查询应用 admin_id 范围过滤
|
||||
*
|
||||
* @param object $query ThinkORM 查询对象
|
||||
* @param array|null $adminInfo 当前登录管理员信息
|
||||
* @return void
|
||||
*/
|
||||
public static function applyAdminScope($query, ?array $adminInfo): void
|
||||
{
|
||||
$allowedIds = self::getAllowedAdminIds($adminInfo);
|
||||
if ($allowedIds === null) {
|
||||
return;
|
||||
}
|
||||
if (empty($allowedIds)) {
|
||||
$query->whereRaw('1=0');
|
||||
return;
|
||||
}
|
||||
$query->whereIn('admin_id', $allowedIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\lottery_pool_config;
|
||||
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\utils\Helper;
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
* 色子奖池配置逻辑层
|
||||
*/
|
||||
class DiceLotteryPoolConfigLogic extends BaseLogic
|
||||
{
|
||||
/** Redis 当前彩金池(type=0 实例)key,无则按 type=0 创建 */
|
||||
private const REDIS_KEY_CURRENT_POOL = 'api:game:lottery_pool:default';
|
||||
|
||||
private const EXPIRE = 86400 * 7;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceLotteryPoolConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前彩金池(type=0)+ 杀分权重为 type=1 的只读展示
|
||||
* profit_amount 每次从 DB 实时读取;t1_weight~t5_weight 来自 type=1(杀分权重,不可在弹窗内修改)
|
||||
*
|
||||
* @return array{id:int,name:string,safety_line:int,kill_enabled:int,t1_weight:int,...,t5_weight:int,profit_amount:float}
|
||||
*/
|
||||
public function getCurrentPool(): array
|
||||
{
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('No name=default pool config found, please create one first');
|
||||
}
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
$row0 = $configType0->toArray();
|
||||
$profitAmount = isset($row0['profit_amount']) ? (float) $row0['profit_amount'] : (isset($row0['ev']) ? (float) $row0['ev'] : 0.0);
|
||||
$pool = [
|
||||
'id' => (int) $row0['id'],
|
||||
'name' => (string) ($row0['name'] ?? ''),
|
||||
'safety_line' => (int) ($row0['safety_line'] ?? 0),
|
||||
'kill_enabled' => (int) ($row0['kill_enabled'] ?? 1),
|
||||
'profit_amount' => $profitAmount,
|
||||
];
|
||||
$row1 = $configType1 ? $configType1->toArray() : [];
|
||||
$pool['t1_weight'] = (int) ($row1['t1_weight'] ?? 0);
|
||||
$pool['t2_weight'] = (int) ($row1['t2_weight'] ?? 0);
|
||||
$pool['t3_weight'] = (int) ($row1['t3_weight'] ?? 0);
|
||||
$pool['t4_weight'] = (int) ($row1['t4_weight'] ?? 0);
|
||||
$pool['t5_weight'] = (int) ($row1['t5_weight'] ?? 0);
|
||||
return $pool;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前彩金池:仅允许修改 type=0 的 safety_line、kill_enabled(杀分权重来自 type=1,不可在此接口修改)
|
||||
*
|
||||
* @param array{safety_line?:int,kill_enabled?:int} $data
|
||||
*/
|
||||
public function updateCurrentPool(array $data): void
|
||||
{
|
||||
$pool = $this->getCurrentPool();
|
||||
$id = (int) $pool['id'];
|
||||
if (!array_key_exists('safety_line', $data) && !array_key_exists('kill_enabled', $data)) {
|
||||
return;
|
||||
}
|
||||
$update = [];
|
||||
if (array_key_exists('safety_line', $data)) {
|
||||
$update['safety_line'] = (int) $data['safety_line'];
|
||||
}
|
||||
if (array_key_exists('kill_enabled', $data)) {
|
||||
$update['kill_enabled'] = ((int) $data['kill_enabled']) === 1 ? 1 : 0;
|
||||
}
|
||||
if ($update === []) {
|
||||
return;
|
||||
}
|
||||
DiceLotteryPoolConfig::where('id', $id)->update($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置当前彩金池的玩家累计盈利:将 profit_amount 置为 0,并刷新 Redis 缓存
|
||||
*/
|
||||
public function resetProfitAmount(): void
|
||||
{
|
||||
$pool = $this->getCurrentPool();
|
||||
$id = (int) $pool['id'];
|
||||
DiceLotteryPoolConfig::where('id', $id)->update(['profit_amount' => 0]);
|
||||
$pool['profit_amount'] = 0.0;
|
||||
Cache::set(self::REDIS_KEY_CURRENT_POOL, json_encode($pool), self::EXPIRE);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ class DicePlayRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,16 +45,18 @@ class DicePlayRecordLogic extends BaseLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 roll_array 从数组转为 JSON 字符串
|
||||
* 将 roll_array 转为 JSON 字符串,并确保 roll_number 与摇取点数一致
|
||||
*/
|
||||
private function normalizeRollArray(array $data): array
|
||||
{
|
||||
if (!array_key_exists('roll_array', $data)) {
|
||||
return $data;
|
||||
}
|
||||
$val = $data['roll_array'];
|
||||
if (is_array($val)) {
|
||||
$data['roll_array'] = json_encode($val, JSON_UNESCAPED_UNICODE);
|
||||
if (array_key_exists('roll_array', $data)) {
|
||||
$val = $data['roll_array'];
|
||||
if (is_array($val)) {
|
||||
$data['roll_array'] = json_encode($val, JSON_UNESCAPED_UNICODE);
|
||||
if (!isset($data['roll_number'])) {
|
||||
$data['roll_number'] = array_sum($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\lottery_config;
|
||||
namespace app\dice\logic\play_record_test;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\utils\Helper;
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
|
||||
/**
|
||||
* 色子奖池配置逻辑层
|
||||
* 玩家抽奖记录(测试数据)逻辑层
|
||||
*/
|
||||
class DiceLotteryConfigLogic extends BaseLogic
|
||||
class DicePlayRecordTestLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceLotteryConfig();
|
||||
$this->model = new DicePlayRecordTest();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,8 @@ class DicePlayerTicketRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayerTicketRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@ use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\api\cache\UserCache;
|
||||
|
||||
/**
|
||||
* 玩家钱包流水逻辑层
|
||||
@@ -22,6 +23,8 @@ class DicePlayerWalletRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayerWalletRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,20 +52,20 @@ class DicePlayerWalletRecordLogic extends BaseLogic
|
||||
$coin = (float) ($data['coin'] ?? 0);
|
||||
|
||||
if ($playerId <= 0 || !in_array($type, [3, 4], true)) {
|
||||
throw new ApiException('参数错误:需要有效的 player_id 和 type(3=加点,4=扣点)');
|
||||
throw new ApiException('Invalid params: player_id and type are required (3=add, 4=deduct)');
|
||||
}
|
||||
if ($coin <= 0) {
|
||||
throw new ApiException('平台币变动必须大于 0');
|
||||
throw new ApiException('Coin change must be greater than 0');
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('id', $playerId)->find();
|
||||
if (!$player) {
|
||||
throw new ApiException('玩家不存在');
|
||||
throw new ApiException('Player not found');
|
||||
}
|
||||
|
||||
$walletBefore = (float) ($player['coin'] ?? 0);
|
||||
if ($type === 4 && $walletBefore < $coin) {
|
||||
throw new ApiException('扣点数量不能大于当前余额');
|
||||
throw new ApiException('Deduct amount cannot exceed current balance');
|
||||
}
|
||||
|
||||
$walletAfter = $type === 3 ? $walletBefore + $coin : $walletBefore - $coin;
|
||||
@@ -73,8 +76,16 @@ class DicePlayerWalletRecordLogic extends BaseLogic
|
||||
|
||||
DicePlayer::where('id', $playerId)->update(['coin' => $walletAfter]);
|
||||
|
||||
// 出于安全:删除该玩家相关缓存,后续 API 按需重建
|
||||
UserCache::deleteUser($playerId);
|
||||
if (isset($player->username) && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
|
||||
$playerAdminId = ($player->admin_id ?? null) ? (int) $player->admin_id : null;
|
||||
$record = [
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $playerAdminId,
|
||||
'coin' => $type === 3 ? $coin : -$coin,
|
||||
'type' => $type,
|
||||
'wallet_before' => $walletBefore,
|
||||
|
||||
454
server/app/dice/logic/reward/DiceRewardLogic.php
Normal file
454
server/app/dice/logic/reward/DiceRewardLogic.php
Normal file
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\reward;
|
||||
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use support\think\Db;
|
||||
|
||||
/**
|
||||
* 奖励对照逻辑层(DiceReward)
|
||||
* 权重 1-10000,区分顺时针/逆时针,修改后刷新 DiceReward 缓存
|
||||
*/
|
||||
class DiceRewardLogic
|
||||
{
|
||||
private const WEIGHT_MIN = 1;
|
||||
private const WEIGHT_MAX = 10000;
|
||||
|
||||
/** 档位键 */
|
||||
private const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5', 'BIGWIN'];
|
||||
|
||||
/**
|
||||
* 分页列表(按方向筛选,关联 dice_reward_config 展示 grid_number、ui_text、real_ev、remark)
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
* @param array{tier?: string, orderField?: string, orderType?: string} $where tier 档位筛选
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array{total: int, per_page: int, current_page: int, data: array}
|
||||
*/
|
||||
public function getListWithConfig(int $direction, array $where, int $page = 1, int $limit = 10): array
|
||||
{
|
||||
$tier = isset($where['tier']) ? trim((string) $where['tier']) : '';
|
||||
$orderField = isset($where['orderField']) && $where['orderField'] !== '' ? (string) $where['orderField'] : 'r.tier';
|
||||
$orderType = isset($where['orderType']) && strtoupper((string) $where['orderType']) === 'DESC' ? 'desc' : 'asc';
|
||||
|
||||
$query = DiceReward::alias('r')
|
||||
->where('r.direction', $direction)
|
||||
->field('r.id,r.tier,r.direction,r.end_index,r.weight,r.grid_number,r.start_index,r.ui_text,r.real_ev,r.remark,r.type,r.create_time,r.update_time')
|
||||
->order($orderField, $orderType)
|
||||
->order('r.end_index', 'asc');
|
||||
|
||||
if ($tier !== '') {
|
||||
$query->where('r.tier', $tier);
|
||||
}
|
||||
|
||||
$paginator = $query->paginate($limit, false, ['page' => $page]);
|
||||
$arr = $paginator->toArray();
|
||||
$data = isset($arr['data']) ? $arr['data'] : $arr['records'] ?? [];
|
||||
$total = (int) ($arr['total'] ?? 0);
|
||||
$perPage = (int) ($arr['per_page'] ?? $limit);
|
||||
$currentPage = (int) ($arr['current_page'] ?? $page);
|
||||
foreach ($data as $i => $row) {
|
||||
if (isset($row['id']) && $row['id'] !== '' && $row['id'] !== null) {
|
||||
$data[$i]['id'] = (int) $row['id'];
|
||||
} else {
|
||||
$data[$i]['id'] = isset($row['end_index']) ? (int) $row['end_index'] : 0;
|
||||
}
|
||||
$data[$i]['start_index'] = isset($row['start_index']) && $row['start_index'] !== '' && $row['start_index'] !== null
|
||||
? (int) $row['start_index']
|
||||
: 0;
|
||||
}
|
||||
return [
|
||||
'total' => $total,
|
||||
'per_page' => $perPage,
|
||||
'current_page' => $currentPage,
|
||||
'data' => $data,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 按单方向批量更新权重(仅更新当前方向的 weight,并刷新缓存)
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
* @param array<int, array{id: int, weight: int}> $items id 为 end_index(DiceRewardConfig.id)
|
||||
*/
|
||||
public function batchUpdateWeightsByDirection(int $direction, array $items): void
|
||||
{
|
||||
if (empty($items)) {
|
||||
return;
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$id = isset($item['id']) ? (int) $item['id'] : 0;
|
||||
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
|
||||
if ($id <= 0) {
|
||||
throw new ApiException('Invalid config ID exists');
|
||||
}
|
||||
$weight = max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, $weight));
|
||||
|
||||
$tier = DiceRewardConfig::where('id', $id)->value('tier');
|
||||
if ($tier === null || $tier === '') {
|
||||
throw new ApiException(\app\api\util\ApiLang::translateParams('配置ID %s 不存在或档位为空', [$id]));
|
||||
}
|
||||
$tier = (string) $tier;
|
||||
|
||||
$affected = DiceReward::where('tier', $tier)->where('direction', $direction)->where('end_index', $id)->update(['weight' => $weight]);
|
||||
if ($affected === 0) {
|
||||
$m = new DiceReward();
|
||||
$m->tier = $tier;
|
||||
$m->direction = $direction;
|
||||
$m->end_index = $id;
|
||||
$m->weight = $weight;
|
||||
$m->save();
|
||||
}
|
||||
}
|
||||
DiceReward::refreshCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按档位+单方向返回列表(用于权重编辑弹窗:当前方向下按档位分组的配置+权重)
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
* @return array<string, array> 键 T1|T2|...|BIGWIN,值为该档位下带 weight 的行数组
|
||||
*/
|
||||
public function getListGroupedByTierForDirection(int $direction): array
|
||||
{
|
||||
$configInstance = DiceRewardConfig::getCachedInstance();
|
||||
$byTier = $configInstance['by_tier'] ?? [];
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $rewardInstance['by_tier_direction'] ?? [];
|
||||
|
||||
$result = [];
|
||||
foreach (self::TIER_KEYS as $tier) {
|
||||
$result[$tier] = [];
|
||||
$rows = $byTier[$tier] ?? [];
|
||||
$dirRows = $byTierDirection[$tier][$direction] ?? [];
|
||||
$weightMap = [];
|
||||
foreach ($dirRows as $r) {
|
||||
$eid = isset($r['end_index']) ? (int) $r['end_index'] : 0;
|
||||
$weightMap[$eid] = isset($r['weight']) ? max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, (int) $r['weight'])) : 1;
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
$id = isset($row['id']) ? (int) $row['id'] : 0;
|
||||
$result[$tier][] = [
|
||||
'id' => $id,
|
||||
'grid_number' => $row['grid_number'] ?? 0,
|
||||
'ui_text' => $row['ui_text'] ?? '',
|
||||
'real_ev' => $row['real_ev'] ?? 0,
|
||||
'remark' => $row['remark'] ?? '',
|
||||
'tier' => $tier,
|
||||
'weight' => $weightMap[$id] ?? 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按档位+方向返回 DiceReward 列表(用于权重配比弹窗),直接读 dice_reward 表,不依赖 config
|
||||
* 每行含 reward_id(DiceReward 主键,用于按 id 更新权重)、id(end_index 展示用)、grid_number、ui_text、real_ev、remark、weight
|
||||
*
|
||||
* @return array<string, array{0: array, 1: array}>
|
||||
*/
|
||||
public function getListGroupedByTierWithDirection(): array
|
||||
{
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $rewardInstance['by_tier_direction'] ?? [];
|
||||
|
||||
$result = [];
|
||||
foreach (self::TIER_KEYS as $tier) {
|
||||
$result[$tier] = [0 => [], 1 => []];
|
||||
foreach ([0, 1] as $direction) {
|
||||
$rows = $byTierDirection[$tier][$direction] ?? [];
|
||||
foreach ($rows as $r) {
|
||||
$result[$tier][$direction][] = [
|
||||
'reward_id' => isset($r['id']) ? (int) $r['id'] : 0,
|
||||
'id' => isset($r['end_index']) ? (int) $r['end_index'] : 0,
|
||||
'grid_number' => isset($r['grid_number']) ? (int) $r['grid_number'] : 0,
|
||||
'ui_text' => (string) ($r['ui_text'] ?? ''),
|
||||
'real_ev' => $r['real_ev'] ?? 0,
|
||||
'remark' => (string) ($r['remark'] ?? ''),
|
||||
'weight' => isset($r['weight']) ? max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, (int) $r['weight'])) : self::WEIGHT_MIN,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新权重:直接按 DiceReward 主键 id 更新 weight,不依赖 direction/grid_number
|
||||
*
|
||||
* @param array<int, array{id: int, weight: int}> $items 每项 id 为 dice_reward 表主键,weight 为 1-10000
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function batchUpdateWeights(array $items): void
|
||||
{
|
||||
if (empty($items)) {
|
||||
return;
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$id = isset($item['id']) ? (int) $item['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
$id = isset($item['reward_id']) ? (int) $item['reward_id'] : 0;
|
||||
}
|
||||
if ($id <= 0) {
|
||||
throw new ApiException('Invalid DiceReward id exists');
|
||||
}
|
||||
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
|
||||
$weight = max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, $weight));
|
||||
$model = DiceReward::find($id);
|
||||
if ($model !== null) {
|
||||
$model->weight = $weight;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
DiceReward::refreshCache();
|
||||
}
|
||||
|
||||
/** BIGWIN 权重范围:0=0% 中奖,10000=100% 中奖;grid_number=5/30 固定 100% 不可改 */
|
||||
private const BIGWIN_WEIGHT_MAX = 10000;
|
||||
|
||||
/**
|
||||
* 按 grid_number 获取 BIGWIN 档位权重(取顺时针方向,用于编辑展示)
|
||||
* 若 DiceReward 无该点数则 5/30 返回 10000,其余返回 0
|
||||
*/
|
||||
public function getBigwinWeightByGridNumber(int $gridNumber): int
|
||||
{
|
||||
$inst = DiceReward::getCachedInstance();
|
||||
$rows = $inst['by_tier_direction']['BIGWIN'][DiceReward::DIRECTION_CLOCKWISE] ?? [];
|
||||
foreach ($rows as $row) {
|
||||
if ((int) ($row['grid_number'] ?? 0) === $gridNumber) {
|
||||
return min(self::BIGWIN_WEIGHT_MAX, (int) ($row['weight'] ?? self::BIGWIN_WEIGHT_MAX));
|
||||
}
|
||||
}
|
||||
return in_array($gridNumber, [5, 30], true) ? self::BIGWIN_WEIGHT_MAX : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 BIGWIN 档位某点数的权重(顺/逆时针同时更新);0=0% 中奖,10000=100% 中奖
|
||||
* 表 dice_reward 唯一键为 (direction, grid_number),同一点数同一方向仅一条记录,故先按该键查找再更新,避免重复插入
|
||||
*/
|
||||
public function updateBigwinWeight(int $gridNumber, int $weight): void
|
||||
{
|
||||
$weight = min(self::BIGWIN_WEIGHT_MAX, max(0, $weight));
|
||||
$config = DiceRewardConfig::where('tier', 'BIGWIN')
|
||||
->where('grid_number', $gridNumber)
|
||||
->find();
|
||||
if (! $config) {
|
||||
return;
|
||||
}
|
||||
$configArr = $config->toArray();
|
||||
foreach ([DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE] as $direction) {
|
||||
// 按唯一键 (direction, grid_number) 查找,存在则更新,不存在则插入
|
||||
$row = DiceReward::where('direction', $direction)
|
||||
->where('grid_number', $gridNumber)
|
||||
->find();
|
||||
if ($row) {
|
||||
$row->tier = 'BIGWIN';
|
||||
$row->weight = $weight > 0 ? $weight : self::WEIGHT_MIN;
|
||||
$row->start_index = (int) ($configArr['id'] ?? $row->start_index);
|
||||
$row->end_index = (int) ($configArr['id'] ?? $row->end_index);
|
||||
$row->ui_text = (string) ($configArr['ui_text'] ?? $row->ui_text);
|
||||
$row->real_ev = (float) ($configArr['real_ev'] ?? $row->real_ev);
|
||||
$row->remark = (string) ($configArr['remark'] ?? $row->remark);
|
||||
$row->type = $configArr['type'] ?? $row->type;
|
||||
$row->save();
|
||||
} else {
|
||||
$m = new DiceReward();
|
||||
$m->tier = 'BIGWIN';
|
||||
$m->direction = $direction;
|
||||
$m->grid_number = (int) $gridNumber;
|
||||
$m->start_index = (int) ($configArr['id'] ?? 0);
|
||||
$m->end_index = (int) ($configArr['id'] ?? 0);
|
||||
$m->ui_text = (string) ($configArr['ui_text'] ?? '');
|
||||
$m->real_ev = (float) ($configArr['real_ev'] ?? 0);
|
||||
$m->remark = (string) ($configArr['remark'] ?? '');
|
||||
$m->type = $configArr['type'] ?? null;
|
||||
$m->weight = $weight > 0 ? $weight : self::WEIGHT_MIN;
|
||||
$m->save();
|
||||
}
|
||||
}
|
||||
DiceReward::refreshCache();
|
||||
}
|
||||
|
||||
/** 盘面格数(用于顺时针/逆时针计算 end_index) */
|
||||
private const BOARD_SIZE = 26;
|
||||
|
||||
/** 点数摇取范围:5-30,顺时针与逆时针均需创建 */
|
||||
private const GRID_NUMBER_MIN = 5;
|
||||
private const GRID_NUMBER_MAX = 30;
|
||||
|
||||
/**
|
||||
* 创建奖励对照:先清空 dice_reward 表,再按两种方向为点数 5-30 生成记录。
|
||||
*
|
||||
* DiceReward 记录数据规则(与 config 通过 end_index 关联):
|
||||
* - 方向:direction = 0(顺时针)/ 1(逆时针)
|
||||
* - 摇取点数:grid_number
|
||||
* - 起始索引:start_index = DiceRewardConfig::where('grid_number', $grid_number)->first()->id
|
||||
* - 结束索引(顺时针):end_index = ($start_index + $grid_number) % 26(对 26 取余)
|
||||
* - 结束索引(逆时针):end_index = ($start_index - $grid_number >= 0) ? ($start_index - $grid_number) : (26 + $start_index - $grid_number)
|
||||
* - 奖励档位:tier = DiceRewardConfig::where('id', $end_index)->first()->tier
|
||||
* - 显示ui:ui_text = DiceRewardConfig::where('id', $end_index)->first()->ui_text
|
||||
* - 实际中奖:real_ev = DiceRewardConfig::where('id', $end_index)->first()->real_ev
|
||||
* - 备注:remark = DiceRewardConfig::where('id', $end_index)->first()->remark
|
||||
* - 类型:type = DiceRewardConfig::where('id', $end_index)->first()->type(-2=唯一惩罚,-1=抽水,0=回本,1=再来一次,2=小赚,3=大奖格)
|
||||
* - weight 默认 1,后续在权重编辑弹窗设置
|
||||
*
|
||||
* 例如顺时针摇取点数为 5 时:start_index = 配置中 grid_number=5 对应格位的 id,
|
||||
* 结束位置 = (起始位置 + grid_number) % 26,再取该位置的 config 的 id 作为 end_index。
|
||||
* 使用「按 id 排序后的盘面位置 0-25」做环形计算,避免 config.id 非连续时取模结果找不到;
|
||||
* 唯一键为 (direction, grid_number),保证每个点数、每个方向各一条记录,不因 end_index 相同而覆盖。
|
||||
*
|
||||
* @return array{created_clockwise: int, created_counterclockwise: int, updated_clockwise: int, updated_counterclockwise: int, skipped: int}
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function createRewardReferenceFromConfig(): array
|
||||
{
|
||||
$list = DiceRewardConfig::order('id', 'asc')->select()->toArray();
|
||||
if (empty($list)) {
|
||||
throw new ApiException('Reward config is empty, please maintain dice_reward_config first');
|
||||
}
|
||||
$configCount = count($list);
|
||||
if ($configCount < self::BOARD_SIZE) {
|
||||
throw new ApiException(
|
||||
\app\api\util\ApiLang::translateParams(
|
||||
'奖励配置需覆盖 26 个格位(id 0-25 或 1-26),当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照',
|
||||
[$configCount]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$table = (new DiceReward())->getTable();
|
||||
Db::execute('DELETE FROM `' . $table . '`');
|
||||
DiceReward::refreshCache();
|
||||
|
||||
// 按 id 排序后,盘面位置 0..25 对应 $list[$pos],避免 config.id 非 0-25/1-26 时取模结果找不到
|
||||
$gridToPosition = [];
|
||||
foreach ($list as $pos => $row) {
|
||||
$gn = isset($row['grid_number']) ? (int) $row['grid_number'] : 0;
|
||||
if ($gn >= self::GRID_NUMBER_MIN && $gn <= self::GRID_NUMBER_MAX && !isset($gridToPosition[$gn])) {
|
||||
$gridToPosition[$gn] = $pos;
|
||||
}
|
||||
}
|
||||
|
||||
$createdCw = 0;
|
||||
$createdCcw = 0;
|
||||
$updatedCw = 0;
|
||||
$updatedCcw = 0;
|
||||
$skipped = 0;
|
||||
|
||||
for ($gridNumber = self::GRID_NUMBER_MIN; $gridNumber <= self::GRID_NUMBER_MAX; $gridNumber++) {
|
||||
if (!isset($gridToPosition[$gridNumber])) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
$startPos = $gridToPosition[$gridNumber];
|
||||
$startRow = $list[$startPos];
|
||||
$startId = isset($startRow['id']) ? (int) $startRow['id'] : 0;
|
||||
|
||||
$endPosCw = ($startPos + $gridNumber) % self::BOARD_SIZE;
|
||||
$endPosCcw = $startPos - $gridNumber >= 0 ? $startPos - $gridNumber : self::BOARD_SIZE + $startPos - $gridNumber;
|
||||
|
||||
$configCw = $list[$endPosCw] ?? null;
|
||||
$configCcw = $list[$endPosCcw] ?? null;
|
||||
$endIdCw = $configCw !== null && isset($configCw['id']) ? (int) $configCw['id'] : 0;
|
||||
$endIdCcw = $configCcw !== null && isset($configCcw['id']) ? (int) $configCcw['id'] : 0;
|
||||
|
||||
if ($configCw !== null) {
|
||||
$tier = isset($configCw['tier']) ? trim((string) $configCw['tier']) : '';
|
||||
if ($tier !== '') {
|
||||
// 使用对应奖励配置的 weight 作为格子权重(若未配置则退回最小权重)
|
||||
$weightCw = isset($configCw['weight']) && $configCw['weight'] !== null
|
||||
? $configCw['weight']
|
||||
: self::WEIGHT_MIN;
|
||||
$payloadCw = [
|
||||
'tier' => $tier,
|
||||
'weight' => $weightCw,
|
||||
'grid_number' => $gridNumber,
|
||||
'start_index' => $startId,
|
||||
'end_index' => $endIdCw,
|
||||
'ui_text' => $configCw['ui_text'] ?? '',
|
||||
'real_ev' => $configCw['real_ev'] ?? null,
|
||||
'remark' => $configCw['remark'] ?? '',
|
||||
'type' => isset($configCw['type']) ? (int) $configCw['type'] : 0,
|
||||
];
|
||||
$existing = DiceReward::where('direction', DiceReward::DIRECTION_CLOCKWISE)->where('grid_number', $gridNumber)->find();
|
||||
if ($existing) {
|
||||
DiceReward::where('id', $existing->id)->update($payloadCw);
|
||||
$updatedCw++;
|
||||
} else {
|
||||
$m = new DiceReward();
|
||||
$m->tier = $tier;
|
||||
$m->direction = DiceReward::DIRECTION_CLOCKWISE;
|
||||
$m->end_index = $endIdCw;
|
||||
$m->weight = $weightCw;
|
||||
$m->grid_number = $gridNumber;
|
||||
$m->start_index = $startId;
|
||||
$m->ui_text = $configCw['ui_text'] ?? '';
|
||||
$m->real_ev = $configCw['real_ev'] ?? null;
|
||||
$m->remark = $configCw['remark'] ?? '';
|
||||
$m->type = isset($configCw['type']) ? (int) $configCw['type'] : 0;
|
||||
$m->save();
|
||||
$createdCw++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($configCcw !== null) {
|
||||
$tier = isset($configCcw['tier']) ? trim((string) $configCcw['tier']) : '';
|
||||
if ($tier !== '') {
|
||||
// 使用对应奖励配置的 weight 作为格子权重(若未配置则退回最小权重)
|
||||
$weightCcw = isset($configCcw['weight']) && $configCcw['weight'] !== null
|
||||
? $configCcw['weight']
|
||||
: self::WEIGHT_MIN;
|
||||
$payloadCcw = [
|
||||
'tier' => $tier,
|
||||
'weight' => $weightCcw,
|
||||
'grid_number' => $gridNumber,
|
||||
'start_index' => $startId,
|
||||
'end_index' => $endIdCcw,
|
||||
'ui_text' => $configCcw['ui_text'] ?? '',
|
||||
'real_ev' => $configCcw['real_ev'] ?? null,
|
||||
'remark' => $configCcw['remark'] ?? '',
|
||||
'type' => isset($configCcw['type']) ? (int) $configCcw['type'] : 0,
|
||||
];
|
||||
$existing = DiceReward::where('direction', DiceReward::DIRECTION_COUNTERCLOCKWISE)->where('grid_number', $gridNumber)->find();
|
||||
if ($existing) {
|
||||
DiceReward::where('id', $existing->id)->update($payloadCcw);
|
||||
$updatedCcw++;
|
||||
} else {
|
||||
$m = new DiceReward();
|
||||
$m->tier = $tier;
|
||||
$m->direction = DiceReward::DIRECTION_COUNTERCLOCKWISE;
|
||||
$m->end_index = $endIdCcw;
|
||||
$m->weight = $weightCcw;
|
||||
$m->grid_number = $gridNumber;
|
||||
$m->start_index = $startId;
|
||||
$m->ui_text = $configCcw['ui_text'] ?? '';
|
||||
$m->real_ev = $configCcw['real_ev'] ?? null;
|
||||
$m->remark = $configCcw['remark'] ?? '';
|
||||
$m->type = isset($configCcw['type']) ? (int) $configCcw['type'] : 0;
|
||||
$m->save();
|
||||
$createdCcw++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DiceReward::refreshCache();
|
||||
return [
|
||||
'created_clockwise' => $createdCw,
|
||||
'created_counterclockwise' => $createdCcw,
|
||||
'updated_clockwise' => $updatedCw,
|
||||
'updated_counterclockwise' => $updatedCcw,
|
||||
'skipped' => $skipped,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,22 +6,408 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\reward_config;
|
||||
|
||||
use app\dice\logic\reward\DiceRewardLogic;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\utils\Helper;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use support\Log;
|
||||
|
||||
/**
|
||||
* 奖励配置逻辑层
|
||||
* 奖励配置逻辑层(DiceRewardConfig)
|
||||
* weight 1-10000,各档位权重和不限制
|
||||
*/
|
||||
class DiceRewardConfigLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
/** weight 取值范围 */
|
||||
private const WEIGHT_MIN = 1;
|
||||
private const WEIGHT_MAX = 10000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceRewardConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增:保存后刷新缓存(权重已迁移至 dice_reward 表)
|
||||
*/
|
||||
public function add(array $data): mixed
|
||||
{
|
||||
$result = parent::add($data);
|
||||
DiceRewardConfig::refreshCache();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改:保存后刷新缓存;BIGWIN 的 weight 直接写入 dice_reward_config 表,抽奖时从 Config 读取
|
||||
*/
|
||||
public function edit($id, array $data): mixed
|
||||
{
|
||||
$result = parent::edit($id, $data);
|
||||
DiceRewardConfig::refreshCache();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为列表/分页数据中的 BIGWIN 行附加 weight(来自 DiceReward 缓存)
|
||||
*/
|
||||
public function enrichBigwinWeight(array $listResult): array
|
||||
{
|
||||
$key = isset($listResult['data']) ? 'data' : (isset($listResult['records']) ? 'records' : null);
|
||||
if ($key === null || empty($listResult[$key])) {
|
||||
return $listResult;
|
||||
}
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
foreach ($listResult[$key] as $i => $row) {
|
||||
if (isset($row['tier']) && $row['tier'] === 'BIGWIN' && isset($row['grid_number'])) {
|
||||
$listResult[$key][$i]['weight'] = $rewardLogic->getBigwinWeightByGridNumber((int) $row['grid_number']);
|
||||
}
|
||||
}
|
||||
return $listResult;
|
||||
}
|
||||
|
||||
/** 奖励索引必须为 26 条,id 为 0~25,点数 5~30 各出现一次 */
|
||||
private const BATCH_INDEX_COUNT = 26;
|
||||
private const INDEX_ID_MIN = 0;
|
||||
private const INDEX_ID_MAX = 25;
|
||||
private const GRID_NUMBER_MIN = 5;
|
||||
private const GRID_NUMBER_MAX = 30;
|
||||
|
||||
/**
|
||||
* 校验批量更新项(奖励索引表单独立提交,可能只含非 BIGWIN 的若干条)
|
||||
* - 每项必须包含 id、grid_number;grid_number 须在 5~30,提交项内 grid_number 不能重复
|
||||
* - 若为 26 条则额外校验:id 为 0~25 各一、grid_number 为 5~30 各一
|
||||
* @return string|null 校验失败返回错误信息,通过返回 null
|
||||
*/
|
||||
public function validateBatchUpdateItems(array $items): ?string
|
||||
{
|
||||
if (count($items) === 0) {
|
||||
return '提交数据不能为空';
|
||||
}
|
||||
$ids = [];
|
||||
$gridNumbers = [];
|
||||
foreach ($items as $item) {
|
||||
if (! array_key_exists('id', $item) || $item['id'] === null || $item['id'] === '') {
|
||||
return '每项必须包含 id';
|
||||
}
|
||||
$id = (int) $item['id'];
|
||||
$ids[] = $id;
|
||||
if (! array_key_exists('grid_number', $item)) {
|
||||
return '每项必须包含 grid_number';
|
||||
}
|
||||
$gn = (int) $item['grid_number'];
|
||||
if ($gn < self::GRID_NUMBER_MIN || $gn > self::GRID_NUMBER_MAX) {
|
||||
return '色子点数 grid_number 只能为 ' . self::GRID_NUMBER_MIN . '~' . self::GRID_NUMBER_MAX . ',当前存在 ' . $gn;
|
||||
}
|
||||
$gridNumbers[] = $gn;
|
||||
}
|
||||
$gridDuplicates = $this->findDuplicateValues($gridNumbers);
|
||||
if ($gridDuplicates !== []) {
|
||||
sort($gridDuplicates);
|
||||
return '色子点数在本批内不能重复,重复的点数为:' . implode('、', $gridDuplicates);
|
||||
}
|
||||
$cnt = count($items);
|
||||
if ($cnt === self::BATCH_INDEX_COUNT) {
|
||||
foreach ($ids as $id) {
|
||||
if ($id < self::INDEX_ID_MIN || $id > self::INDEX_ID_MAX) {
|
||||
return '索引 id 只能为 ' . self::INDEX_ID_MIN . '~' . self::INDEX_ID_MAX . ',当前存在 id=' . $id;
|
||||
}
|
||||
}
|
||||
$idDuplicates = $this->findDuplicateValues($ids);
|
||||
if ($idDuplicates !== []) {
|
||||
sort($idDuplicates);
|
||||
return '索引 id 必须为 0~25 各出现一次不能重复,重复的 id 为:' . implode('、', $idDuplicates);
|
||||
}
|
||||
$requiredIds = range(self::INDEX_ID_MIN, self::INDEX_ID_MAX);
|
||||
if (array_diff($requiredIds, $ids) !== [] || array_diff($ids, $requiredIds) !== []) {
|
||||
return '索引 id 必须且只能为 0~25 各一个';
|
||||
}
|
||||
$requiredGrid = range(self::GRID_NUMBER_MIN, self::GRID_NUMBER_MAX);
|
||||
if (array_diff($requiredGrid, $gridNumbers) !== [] || array_diff($gridNumbers, $requiredGrid) !== []) {
|
||||
return '色子点数必须且只能为 5~30 各一个';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出数组中出现多于一次的值
|
||||
* @param array $arr
|
||||
* @return array 重复出现的值(去重)
|
||||
*/
|
||||
private function findDuplicateValues(array $arr): array
|
||||
{
|
||||
$counts = array_count_values($arr);
|
||||
$duplicates = [];
|
||||
foreach ($counts as $value => $count) {
|
||||
if ($count > 1) {
|
||||
$duplicates[] = $value;
|
||||
}
|
||||
}
|
||||
return $duplicates;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新奖励索引配置:grid_number、ui_text、real_ev、tier、remark(不含 weight,BIGWIN 权重单独接口)
|
||||
* @param array $items 每项 [id, grid_number?, ui_text?, real_ev?, tier?, remark?]
|
||||
*/
|
||||
public function batchUpdate(array $items): void
|
||||
{
|
||||
foreach ($items as $row) {
|
||||
if (! array_key_exists('id', $row) || $row['id'] === null || $row['id'] === '') {
|
||||
continue;
|
||||
}
|
||||
$id = (int) $row['id'];
|
||||
$data = [];
|
||||
foreach (['grid_number', 'ui_text', 'ui_text_en', 'real_ev', 'tier', 'remark'] as $field) {
|
||||
if (array_key_exists($field, $row)) {
|
||||
$data[$field] = $row[$field];
|
||||
}
|
||||
}
|
||||
if (! empty($data)) {
|
||||
parent::edit($id, $data);
|
||||
}
|
||||
}
|
||||
DiceRewardConfig::refreshCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验大奖权重提交项:点数 5~30,本批内 grid_number 不能重复
|
||||
* @return string|null 校验失败返回错误信息(含重复的点数),通过返回 null
|
||||
*/
|
||||
public function validateBigwinWeightItems(array $items): ?string
|
||||
{
|
||||
if (count($items) === 0) {
|
||||
return '提交数据不能为空';
|
||||
}
|
||||
$gridNumbers = [];
|
||||
foreach ($items as $row) {
|
||||
$gn = isset($row['grid_number']) ? (int) $row['grid_number'] : 0;
|
||||
if ($gn < self::GRID_NUMBER_MIN || $gn > self::GRID_NUMBER_MAX) {
|
||||
return '色子点数 grid_number 只能为 ' . self::GRID_NUMBER_MIN . '~' . self::GRID_NUMBER_MAX . ',当前存在 ' . $gn;
|
||||
}
|
||||
$gridNumbers[] = $gn;
|
||||
}
|
||||
$duplicates = $this->findDuplicateValues($gridNumbers);
|
||||
if ($duplicates !== []) {
|
||||
sort($duplicates);
|
||||
return '大奖权重本批内点数不能重复,重复的点数为:' . implode('、', $duplicates);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新 BIGWIN 档位权重(仅写 dice_reward_config 表,不操作 dice_reward)
|
||||
* @param array $items 每项 [grid_number => 5-30, weight => 0-10000]
|
||||
*/
|
||||
public function batchUpdateBigwinWeight(array $items): void
|
||||
{
|
||||
$weightMin = 0;
|
||||
$weightMax = 10000;
|
||||
foreach ($items as $row) {
|
||||
$gridNumber = isset($row['grid_number']) ? (int) $row['grid_number'] : 0;
|
||||
$weight = isset($row['weight']) ? (int) $row['weight'] : 0;
|
||||
if ($gridNumber < 5 || $gridNumber > 30) {
|
||||
continue;
|
||||
}
|
||||
$weight = max($weightMin, min($weightMax, $weight));
|
||||
$this->model->where('tier', 'BIGWIN')
|
||||
->where('grid_number', $gridNumber)
|
||||
->update(['weight' => $weight]);
|
||||
}
|
||||
DiceRewardConfig::refreshCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除后刷新缓存
|
||||
*/
|
||||
public function destroy($ids): bool
|
||||
{
|
||||
$result = parent::destroy($ids);
|
||||
if ($result) {
|
||||
DiceRewardConfig::refreshCache();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按档位分组返回奖励配置列表(仅配置,权重在 dice_reward 表;权重配比请用 DiceRewardLogic::getListGroupedByTierWithDirection)
|
||||
*/
|
||||
public function getListGroupedByTier(): array
|
||||
{
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5', 'BIGWIN'];
|
||||
$list = $this->model->whereIn('tier', $tiers)->order('tier')->order('id')->select()->toArray();
|
||||
$grouped = [];
|
||||
foreach ($tiers as $t) {
|
||||
$grouped[$t] = [];
|
||||
}
|
||||
foreach ($list as $row) {
|
||||
$tier = isset($row['tier']) ? (string) $row['tier'] : '';
|
||||
if ($tier !== '' && isset($grouped[$tier])) {
|
||||
$grouped[$tier][] = $row;
|
||||
}
|
||||
}
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/** 测试时档位权重均为 0 的异常标识 */
|
||||
private const EXCEPTION_WEIGHT_ALL_ZERO = 'REWARD_WEIGHT_ALL_ZERO';
|
||||
|
||||
/**
|
||||
* 按权重抽取一条配置(与 PlayStartLogic 抽奖逻辑一致,仅 weight>0 参与)
|
||||
*/
|
||||
private static function drawRewardByWeight(array $rewards): array
|
||||
{
|
||||
if (empty($rewards)) {
|
||||
throw new \InvalidArgumentException('rewards 不能为空');
|
||||
}
|
||||
$candidateWeights = [];
|
||||
foreach ($rewards as $i => $row) {
|
||||
$w = isset($row['weight']) ? (float) $row['weight'] : 0.0;
|
||||
if ($w > 0) {
|
||||
$candidateWeights[$i] = $w;
|
||||
}
|
||||
}
|
||||
$total = (float) array_sum($candidateWeights);
|
||||
if ($total > 0) {
|
||||
$r = (random_int(0, PHP_INT_MAX - 1) / (float) PHP_INT_MAX) * $total;
|
||||
$acc = 0.0;
|
||||
foreach ($candidateWeights as $i => $w) {
|
||||
$acc += $w;
|
||||
if ($r < $acc) {
|
||||
return $rewards[$i];
|
||||
}
|
||||
}
|
||||
return $rewards[array_key_last($candidateWeights)];
|
||||
}
|
||||
throw new \RuntimeException(self::EXCEPTION_WEIGHT_ALL_ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按档位权重数组抽取 T1-T5
|
||||
*/
|
||||
private static function drawTierByWeightArray(array $tiers, array $weights): string
|
||||
{
|
||||
$total = array_sum($weights);
|
||||
if ($total <= 0) {
|
||||
return $tiers[random_int(0, count($tiers) - 1)];
|
||||
}
|
||||
$r = random_int(1, (int) $total);
|
||||
$acc = 0;
|
||||
foreach ($weights as $i => $w) {
|
||||
$acc += (int) $w;
|
||||
if ($r <= $acc) {
|
||||
return $tiers[$i];
|
||||
}
|
||||
}
|
||||
return $tiers[count($tiers) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行权重配比测试:仅按当前配置在内存中模拟 N 次抽奖,统计各 grid_number 落点数量。
|
||||
* 不创建任何游玩记录(DicePlayRecord)、不扣券、不写钱包,仅用于验证权重配比效果。
|
||||
*
|
||||
* @param int $testCount 测试次数 100/500/1000/5000/10000
|
||||
* @param bool $saveRecord 是否保存到 dice_reward_config_record(测试记录表,非游玩记录)
|
||||
* @param int|null $adminId 执行人管理员ID
|
||||
* @param int|null $lotteryConfigId 奖池配置ID(DiceLotteryPoolConfig),用于设定 T1-T5 档位概率;不传则使用 type=0 的配置或均等
|
||||
* @return array{counts: array<int,int>, record_id: int|null} counts 为 grid_number=>出现次数
|
||||
*/
|
||||
public function runWeightTest(int $testCount, bool $saveRecord = true, ?int $adminId = null, ?int $lotteryConfigId = null): array
|
||||
{
|
||||
$allowedCounts = [100, 500, 1000, 5000, 10000];
|
||||
if (!in_array($testCount, $allowedCounts, true)) {
|
||||
throw new ApiException('Test count only supports 100, 500, 1000, 5000, 10000');
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
foreach (['T1', 'T2', 'T3', 'T4', 'T5', 'BIGWIN'] as $t) {
|
||||
$grouped[$t] = $this->model::getCachedByTierForDirection($t, 0);
|
||||
}
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$tierWeights = [1, 1, 1, 1, 1];
|
||||
$config = null;
|
||||
if ($lotteryConfigId !== null && $lotteryConfigId > 0) {
|
||||
$config = DiceLotteryPoolConfig::find($lotteryConfigId);
|
||||
}
|
||||
if (!$config) {
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
}
|
||||
if ($config) {
|
||||
$tierWeights = [
|
||||
(int) ($config->t1_weight ?? 0),
|
||||
(int) ($config->t2_weight ?? 0),
|
||||
(int) ($config->t3_weight ?? 0),
|
||||
(int) ($config->t4_weight ?? 0),
|
||||
(int) ($config->t5_weight ?? 0),
|
||||
];
|
||||
if (array_sum($tierWeights) <= 0) {
|
||||
$tierWeights = [1, 1, 1, 1, 1];
|
||||
}
|
||||
}
|
||||
|
||||
$counts = [];
|
||||
$maxRetry = 20;
|
||||
for ($i = 0; $i < $testCount; $i++) {
|
||||
$tier = self::drawTierByWeightArray($tiers, $tierWeights);
|
||||
$rewards = $grouped[$tier] ?? [];
|
||||
if (empty($rewards)) {
|
||||
continue;
|
||||
}
|
||||
$attempt = 0;
|
||||
while ($attempt < $maxRetry) {
|
||||
try {
|
||||
$chosen = self::drawRewardByWeight($rewards);
|
||||
$gridNumber = isset($chosen['grid_number']) ? (int) $chosen['grid_number'] : 0;
|
||||
if ($gridNumber >= 5 && $gridNumber <= 30) {
|
||||
$counts[$gridNumber] = ($counts[$gridNumber] ?? 0) + 1;
|
||||
}
|
||||
break;
|
||||
} catch (\RuntimeException $e) {
|
||||
if ($e->getMessage() === self::EXCEPTION_WEIGHT_ALL_ZERO) {
|
||||
$attempt++;
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$snapshot = [];
|
||||
foreach ($grouped as $tierKey => $rows) {
|
||||
foreach ($rows as $row) {
|
||||
$snapshot[] = [
|
||||
'id' => (int) ($row['id'] ?? 0),
|
||||
'grid_number' => (int) ($row['grid_number'] ?? 0),
|
||||
'tier' => (string) ($row['tier'] ?? ''),
|
||||
'weight' => (int) ($row['weight'] ?? 0),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tierWeightsSnapshot = [
|
||||
'T1' => $tierWeights[0] ?? 0,
|
||||
'T2' => $tierWeights[1] ?? 0,
|
||||
'T3' => $tierWeights[2] ?? 0,
|
||||
'T4' => $tierWeights[3] ?? 0,
|
||||
'T5' => $tierWeights[4] ?? 0,
|
||||
];
|
||||
$recordId = null;
|
||||
if ($saveRecord) {
|
||||
$record = new DiceRewardConfigRecord();
|
||||
$record->test_count = $testCount;
|
||||
$record->weight_config_snapshot = $snapshot;
|
||||
$record->tier_weights_snapshot = $tierWeightsSnapshot;
|
||||
$record->lottery_config_id = $config ? (int) $config->id : null;
|
||||
$record->result_counts = $counts;
|
||||
$record->admin_id = $adminId;
|
||||
$record->create_time = date('Y-m-d H:i:s');
|
||||
$record->save();
|
||||
$recordId = (int) $record->id;
|
||||
}
|
||||
|
||||
return ['counts' => $counts, 'record_id' => $recordId];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\reward_config_record;
|
||||
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录逻辑层
|
||||
*/
|
||||
class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceRewardConfigRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表,并为每条记录附加 admin_name(管理员姓名:realname 或 username)
|
||||
*/
|
||||
public function getList($query): mixed
|
||||
{
|
||||
$result = parent::getList($query);
|
||||
if (!is_array($result)) {
|
||||
return $result;
|
||||
}
|
||||
$rows = $result['data'] ?? $result['records'] ?? null;
|
||||
if (!is_array($rows) || empty($rows)) {
|
||||
return $result;
|
||||
}
|
||||
$adminIds = array_unique(array_filter(array_column($rows, 'admin_id')));
|
||||
$nameMap = $this->getAdminNameMap($adminIds);
|
||||
$key = isset($result['data']) ? 'data' : 'records';
|
||||
foreach ($result[$key] as &$row) {
|
||||
$aid = isset($row['admin_id']) ? (int) $row['admin_id'] : 0;
|
||||
$row['admin_name'] = $nameMap[$aid] ?? ($aid > 0 ? '' : '—');
|
||||
}
|
||||
unset($row);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据管理员 ID 列表获取 id => 姓名(realname 优先,否则 username)
|
||||
* @param array $adminIds
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function getAdminNameMap(array $adminIds): array
|
||||
{
|
||||
if (empty($adminIds)) {
|
||||
return [];
|
||||
}
|
||||
$list = SystemUser::whereIn('id', $adminIds)->field('id,realname,username')->select()->toArray();
|
||||
$map = [];
|
||||
foreach ($list as $user) {
|
||||
$user = is_array($user) ? $user : (array) $user;
|
||||
$id = (int) ($user['id'] ?? 0);
|
||||
$name = trim((string) ($user['realname'] ?? ''));
|
||||
if ($name === '') {
|
||||
$name = trim((string) ($user['username'] ?? ''));
|
||||
}
|
||||
$map[$id] = $name !== '' ? $name : (string) $id;
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将测试记录导入:DiceReward(权重快照)、DiceRewardConfig(BIGWIN weight)、DiceLotteryPoolConfig(付费/免费 T1-T5)
|
||||
* @param int $recordId 测试记录 ID
|
||||
* @param int|null $paidLotteryConfigId 导入付费档位概率到的奖池(type=0),不传则用记录 paid_lottery_config_id
|
||||
* @param int|null $freeLotteryConfigId 导入免费档位概率到的奖池(type=1),不传则用记录 free_lottery_config_id
|
||||
* @param int|null $lotteryConfigId 兼容旧版:不传 paid/free 时用作统一奖池
|
||||
*/
|
||||
public function importFromRecord(int $recordId, ?int $paidLotteryConfigId = null, ?int $freeLotteryConfigId = null, ?int $lotteryConfigId = null): void
|
||||
{
|
||||
$record = $this->model->find($recordId);
|
||||
if (!$record) {
|
||||
throw new ApiException('Test record not found');
|
||||
}
|
||||
$record = is_array($record) ? $record : $record->toArray();
|
||||
|
||||
$snapshot = $record['weight_config_snapshot'] ?? null;
|
||||
if (is_string($snapshot)) {
|
||||
$snapshot = json_decode($snapshot, true);
|
||||
}
|
||||
if (is_array($snapshot) && !empty($snapshot)) {
|
||||
foreach ($snapshot as $item) {
|
||||
$direction = isset($item['direction']) ? (int) $item['direction'] : null;
|
||||
$gridNumber = isset($item['grid_number']) ? (int) $item['grid_number'] : 0;
|
||||
$weight = isset($item['weight']) ? (int) $item['weight'] : 1;
|
||||
$weight = max(1, min(10000, $weight));
|
||||
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
|
||||
continue;
|
||||
}
|
||||
if ($gridNumber <= 0) {
|
||||
continue;
|
||||
}
|
||||
$tier = isset($item['tier']) ? (string) $item['tier'] : '';
|
||||
if ($tier === '') {
|
||||
// 若快照中未带 tier,则尝试按方向+点数从现有配置中取
|
||||
$tierFromDb = DiceReward::where('direction', $direction)->where('grid_number', $gridNumber)->value('tier');
|
||||
$tier = $tierFromDb !== null ? (string) $tierFromDb : '';
|
||||
}
|
||||
// 仅按方向 + 点数更新 DiceReward(若存在则更新,不存在才插入,避免唯一键冲突)
|
||||
$reward = DiceReward::where('direction', $direction)
|
||||
->where('grid_number', $gridNumber)
|
||||
->find();
|
||||
if ($reward) {
|
||||
$reward->weight = $weight;
|
||||
// 若快照中有 tier,补齐 tier 信息
|
||||
if ($tier !== '' && (string) $reward->tier !== $tier) {
|
||||
$reward->tier = $tier;
|
||||
}
|
||||
$reward->save();
|
||||
} else {
|
||||
$m = new DiceReward();
|
||||
if ($tier !== '') {
|
||||
$m->tier = $tier;
|
||||
}
|
||||
$m->direction = $direction;
|
||||
$m->grid_number = $gridNumber;
|
||||
$m->weight = $weight;
|
||||
$m->save();
|
||||
}
|
||||
}
|
||||
DiceReward::refreshCache();
|
||||
}
|
||||
|
||||
// 使用记录中的 bigwin_weight JSON 将 BIGWIN 概率导入到 DiceRewardConfig
|
||||
$recordBigwinWeight = $record['bigwin_weight'] ?? null;
|
||||
if (is_string($recordBigwinWeight)) {
|
||||
$decoded = json_decode($recordBigwinWeight, true);
|
||||
$recordBigwinWeight = is_array($decoded) ? $decoded : null;
|
||||
}
|
||||
if (is_array($recordBigwinWeight) && !empty($recordBigwinWeight)) {
|
||||
foreach ($recordBigwinWeight as $grid => $w) {
|
||||
$gridNumber = (int) $grid;
|
||||
$weight = (int) $w;
|
||||
if ($gridNumber <= 0) {
|
||||
continue;
|
||||
}
|
||||
if ($weight < 0) {
|
||||
$weight = 0;
|
||||
}
|
||||
DiceRewardConfig::where('tier', 'BIGWIN')
|
||||
->where('grid_number', $gridNumber)
|
||||
->update(['weight' => $weight]);
|
||||
}
|
||||
DiceRewardConfig::refreshCache();
|
||||
}
|
||||
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$tierSnapshot = $record['tier_weights_snapshot'] ?? null;
|
||||
if (is_string($tierSnapshot)) {
|
||||
$tierSnapshot = json_decode($tierSnapshot, true);
|
||||
}
|
||||
$paidWeights = $record['paid_tier_weights'] ?? null;
|
||||
if (is_string($paidWeights)) {
|
||||
$paidWeights = json_decode($paidWeights, true);
|
||||
}
|
||||
$freeWeights = $record['free_tier_weights'] ?? null;
|
||||
if (is_string($freeWeights)) {
|
||||
$freeWeights = json_decode($freeWeights, true);
|
||||
}
|
||||
$fallbackLotteryId = $lotteryConfigId > 0 ? $lotteryConfigId : (isset($record['lottery_config_id']) && (int) $record['lottery_config_id'] > 0 ? (int) $record['lottery_config_id'] : null);
|
||||
$paidTargetId = $paidLotteryConfigId > 0 ? $paidLotteryConfigId : ($fallbackLotteryId ?? (isset($record['paid_lottery_config_id']) && (int) $record['paid_lottery_config_id'] > 0 ? (int) $record['paid_lottery_config_id'] : null));
|
||||
$freeTargetId = $freeLotteryConfigId > 0 ? $freeLotteryConfigId : (isset($record['free_lottery_config_id']) && (int) $record['free_lottery_config_id'] > 0 ? (int) $record['free_lottery_config_id'] : null);
|
||||
|
||||
// tier_weights_snapshot 新结构:['paid' => [...], 'free' => [...]]
|
||||
$snapshotPaid = null;
|
||||
$snapshotFree = null;
|
||||
if (is_array($tierSnapshot) && !empty($tierSnapshot)) {
|
||||
if (array_key_exists('paid', $tierSnapshot) || array_key_exists('free', $tierSnapshot)) {
|
||||
if (isset($tierSnapshot['paid']) && is_array($tierSnapshot['paid'])) {
|
||||
$snapshotPaid = $tierSnapshot['paid'];
|
||||
}
|
||||
if (isset($tierSnapshot['free']) && is_array($tierSnapshot['free'])) {
|
||||
$snapshotFree = $tierSnapshot['free'];
|
||||
}
|
||||
} else {
|
||||
// 兼容旧结构:直接就是一个 T1-T5 的数组,视为付费
|
||||
$snapshotPaid = $tierSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
$paidData = is_array($paidWeights) && !empty($paidWeights) ? $paidWeights : $snapshotPaid;
|
||||
$freeData = is_array($freeWeights) && !empty($freeWeights) ? $freeWeights : $snapshotFree;
|
||||
|
||||
if (is_array($paidData) && $paidTargetId > 0) {
|
||||
$pool = DiceLotteryPoolConfig::find($paidTargetId);
|
||||
if (!$pool) {
|
||||
throw new ApiException('Paid pool config not found');
|
||||
}
|
||||
$update = [
|
||||
't1_weight' => (int) ($paidData['T1'] ?? $paidData['t1'] ?? 0),
|
||||
't2_weight' => (int) ($paidData['T2'] ?? $paidData['t2'] ?? 0),
|
||||
't3_weight' => (int) ($paidData['T3'] ?? $paidData['t3'] ?? 0),
|
||||
't4_weight' => (int) ($paidData['T4'] ?? $paidData['t4'] ?? 0),
|
||||
't5_weight' => (int) ($paidData['T5'] ?? $paidData['t5'] ?? 0),
|
||||
];
|
||||
DiceLotteryPoolConfig::where('id', $paidTargetId)->update($update);
|
||||
}
|
||||
if (is_array($freeData) && $freeTargetId > 0) {
|
||||
$pool = DiceLotteryPoolConfig::find($freeTargetId);
|
||||
if (!$pool) {
|
||||
throw new ApiException('Free pool config not found');
|
||||
}
|
||||
$update = [
|
||||
't1_weight' => (int) ($freeData['T1'] ?? $freeData['t1'] ?? 0),
|
||||
't2_weight' => (int) ($freeData['T2'] ?? $freeData['t2'] ?? 0),
|
||||
't3_weight' => (int) ($freeData['T3'] ?? $freeData['t3'] ?? 0),
|
||||
't4_weight' => (int) ($freeData['T4'] ?? $freeData['t4'] ?? 0),
|
||||
't5_weight' => (int) ($freeData['T5'] ?? $freeData['t5'] ?? 0),
|
||||
];
|
||||
DiceLotteryPoolConfig::where('id', $freeTargetId)->update($update);
|
||||
}
|
||||
|
||||
DiceRewardConfig::refreshCache();
|
||||
DiceRewardConfig::clearRequestInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一键测试权重记录并返回 ID,供后台执行器按付费/免费、顺逆方向交替写入 dice_play_record_test
|
||||
* 支持两种模式:1)选择奖池配置 lottery_config_id,档位概率取自配置;2)不选配置,使用自定义 paid_tier_weights / free_tier_weights
|
||||
* @param array|int $params 数组:lottery_config_id(可选), paid_s_count, paid_n_count, free_s_count, free_n_count;或兼容旧版传 4 个 int 时视为 (paid_s_count, paid_n_count, free_s_count, free_n_count)
|
||||
* @param int|null $adminId 执行人(旧版 4 参调用时第二参为 paid_n_count,此处不传 adminId)
|
||||
* @return int 记录 ID
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function createWeightTestRecord(array|int $params, mixed $adminIdOrFreeS = null, mixed $freeSOrFreeN = null, mixed $freeN = null): int
|
||||
{
|
||||
$adminId = null;
|
||||
if (!is_array($params)) {
|
||||
// 兼容旧版调用:createWeightTestRecord(paid_s_count, paid_n_count, free_s_count, free_n_count)
|
||||
$params = [
|
||||
'paid_s_count' => (int) $params,
|
||||
'paid_n_count' => (int) $adminIdOrFreeS,
|
||||
'free_s_count' => (int) $freeSOrFreeN,
|
||||
'free_n_count' => (int) $freeN,
|
||||
];
|
||||
} else {
|
||||
$adminId = $adminIdOrFreeS !== null && $adminIdOrFreeS !== '' ? (int) $adminIdOrFreeS : null;
|
||||
}
|
||||
$allowed = [100, 500, 1000, 5000];
|
||||
$lotteryConfigId = isset($params['lottery_config_id']) ? (int) $params['lottery_config_id'] : 0;
|
||||
$paidConfigId = isset($params['paid_lottery_config_id']) ? (int) $params['paid_lottery_config_id'] : 0;
|
||||
$freeConfigId = isset($params['free_lottery_config_id']) ? (int) $params['free_lottery_config_id'] : 0;
|
||||
if ($paidConfigId <= 0 && $lotteryConfigId > 0) {
|
||||
$paidConfigId = $lotteryConfigId;
|
||||
}
|
||||
if ($freeConfigId <= 0 && $lotteryConfigId > 0) {
|
||||
$freeConfigId = $lotteryConfigId;
|
||||
}
|
||||
$paidS = isset($params['paid_s_count']) ? (int) $params['paid_s_count'] : (int) ($params['s_count'] ?? 0);
|
||||
$paidN = isset($params['paid_n_count']) ? (int) $params['paid_n_count'] : (int) ($params['n_count'] ?? 0);
|
||||
$freeS = (int) ($params['free_s_count'] ?? 0);
|
||||
$freeN = (int) ($params['free_n_count'] ?? 0);
|
||||
|
||||
foreach ([$paidS, $paidN, $freeS, $freeN] as $c) {
|
||||
if ($c !== 0 && !in_array($c, $allowed, true)) {
|
||||
throw new ApiException('Counts only support 0, 100, 500, 1000, 5000');
|
||||
}
|
||||
}
|
||||
$total = $paidS + $paidN + $freeS + $freeN;
|
||||
if ($total <= 0) {
|
||||
throw new ApiException('Sum of paid/free direction counts must be greater than 0');
|
||||
}
|
||||
|
||||
$snapshot = [];
|
||||
// 档位权重快照:区分付费/免费,结构为 ['paid' => [...], 'free' => [...]]
|
||||
$tierWeightsSnapshot = [
|
||||
'paid' => null,
|
||||
'free' => null,
|
||||
];
|
||||
$paidTierWeights = null;
|
||||
$freeTierWeights = null;
|
||||
|
||||
// 来自 DiceReward 的当前权重快照(按方向+点数),用于权重测试模拟
|
||||
$instance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $instance['by_tier_direction'] ?? [];
|
||||
foreach ($byTierDirection as $tier => $byDir) {
|
||||
foreach ($byDir as $dir => $rows) {
|
||||
foreach ($rows as $row) {
|
||||
$snapshot[] = [
|
||||
// 不再记录 DiceReward.id,只记录方向、点数和、档位与权重
|
||||
'direction' => (int) $dir,
|
||||
'grid_number' => (int) ($row['grid_number'] ?? 0),
|
||||
'tier' => (string) ($tier ?? ''),
|
||||
'weight' => (int) ($row['weight'] ?? 0),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BIGWIN 概率快照从 DiceRewardConfig 读取(例如豹子号配置)
|
||||
// JSON 结构 {"grid_number": weight, ...}
|
||||
$bigwinWeights = [];
|
||||
$bigwinConfigs = DiceRewardConfig::getCachedByTier('BIGWIN');
|
||||
foreach ($bigwinConfigs as $cfg) {
|
||||
$grid = isset($cfg['grid_number']) ? (int) $cfg['grid_number'] : 0;
|
||||
if ($grid <= 0) {
|
||||
continue;
|
||||
}
|
||||
$w = isset($cfg['weight']) ? (int) $cfg['weight'] : 0;
|
||||
$bigwinWeights[$grid] = $w;
|
||||
}
|
||||
|
||||
if ($paidConfigId > 0) {
|
||||
$config = DiceLotteryPoolConfig::find($paidConfigId);
|
||||
if (!$config) {
|
||||
throw new ApiException('Paid pool config not found');
|
||||
}
|
||||
$tierWeightsSnapshot['paid'] = [
|
||||
'T1' => (int) ($config->t1_weight ?? 0),
|
||||
'T2' => (int) ($config->t2_weight ?? 0),
|
||||
'T3' => (int) ($config->t3_weight ?? 0),
|
||||
'T4' => (int) ($config->t4_weight ?? 0),
|
||||
'T5' => (int) ($config->t5_weight ?? 0),
|
||||
];
|
||||
} else {
|
||||
$paidTierWeights = $params['paid_tier_weights'] ?? null;
|
||||
if (!is_array($paidTierWeights)) {
|
||||
throw new ApiException('When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)');
|
||||
}
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
foreach ($tiers as $t) {
|
||||
$v = (int) ($paidTierWeights[$t] ?? 0);
|
||||
if ($v < 0 || $v > 100) {
|
||||
throw new ApiException('Paid tier probability must be between 0 and 100%');
|
||||
}
|
||||
$paidTierWeights[$t] = $v;
|
||||
}
|
||||
$paidSum = array_sum(array_intersect_key($paidTierWeights, array_flip($tiers)));
|
||||
if ($paidSum > 100) {
|
||||
throw new ApiException('Paid tier probabilities (T1–T5) sum cannot exceed 100%');
|
||||
}
|
||||
$tierWeightsSnapshot['paid'] = $paidTierWeights;
|
||||
}
|
||||
|
||||
if ($freeConfigId > 0) {
|
||||
$config = DiceLotteryPoolConfig::find($freeConfigId);
|
||||
if (!$config) {
|
||||
throw new ApiException('Free pool config not found');
|
||||
}
|
||||
$tierWeightsSnapshot['free'] = [
|
||||
'T1' => (int) ($config->t1_weight ?? 0),
|
||||
'T2' => (int) ($config->t2_weight ?? 0),
|
||||
'T3' => (int) ($config->t3_weight ?? 0),
|
||||
'T4' => (int) ($config->t4_weight ?? 0),
|
||||
'T5' => (int) ($config->t5_weight ?? 0),
|
||||
];
|
||||
} else {
|
||||
$freeTierWeights = $params['free_tier_weights'] ?? null;
|
||||
if (!is_array($freeTierWeights)) {
|
||||
throw new ApiException('When free pool is not selected, please fill free custom tier probabilities (T1–T5)');
|
||||
}
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
foreach ($tiers as $t) {
|
||||
$v = (int) ($freeTierWeights[$t] ?? 0);
|
||||
if ($v < 0 || $v > 100) {
|
||||
throw new ApiException('Free tier probability must be between 0 and 100%');
|
||||
}
|
||||
$freeTierWeights[$t] = $v;
|
||||
}
|
||||
$freeSum = array_sum(array_intersect_key($freeTierWeights, array_flip($tiers)));
|
||||
if ($freeSum > 100) {
|
||||
throw new ApiException('Free tier probabilities (T1–T5) sum cannot exceed 100%');
|
||||
}
|
||||
$tierWeightsSnapshot['free'] = $freeTierWeights;
|
||||
}
|
||||
|
||||
// 兼容:若某一侧未配置,则保存为空数组,方便前端直接解构
|
||||
if (!is_array($tierWeightsSnapshot['paid'])) {
|
||||
$tierWeightsSnapshot['paid'] = [];
|
||||
}
|
||||
if (!is_array($tierWeightsSnapshot['free'])) {
|
||||
$tierWeightsSnapshot['free'] = [];
|
||||
}
|
||||
|
||||
$record = new DiceRewardConfigRecord();
|
||||
$record->test_count = $total;
|
||||
$record->weight_config_snapshot = $snapshot;
|
||||
$record->tier_weights_snapshot = $tierWeightsSnapshot;
|
||||
$record->lottery_config_id = $lotteryConfigId > 0 ? $lotteryConfigId : null;
|
||||
$record->paid_lottery_config_id = $paidConfigId > 0 ? $paidConfigId : null;
|
||||
$record->free_lottery_config_id = $freeConfigId > 0 ? $freeConfigId : null;
|
||||
$record->total_play_count = $total;
|
||||
$record->over_play_count = 0;
|
||||
$record->status = DiceRewardConfigRecord::STATUS_RUNNING;
|
||||
$record->remark = null;
|
||||
$record->s_count = $paidS + $paidN;
|
||||
$record->n_count = $freeS + $freeN;
|
||||
$record->paid_s_count = $paidS;
|
||||
$record->paid_n_count = $paidN;
|
||||
$record->free_s_count = $freeS;
|
||||
$record->free_n_count = $freeN;
|
||||
$record->paid_tier_weights = $paidTierWeights;
|
||||
$record->free_tier_weights = $freeTierWeights;
|
||||
$record->result_counts = [];
|
||||
$record->tier_counts = null;
|
||||
$record->bigwin_weight = $bigwinWeights ?: null;
|
||||
$record->admin_id = $adminId;
|
||||
$record->create_time = date('Y-m-d H:i:s');
|
||||
$record->save();
|
||||
|
||||
return (int) $record->id;
|
||||
}
|
||||
}
|
||||
250
server/app/dice/logic/reward_config_record/WeightTestRunner.php
Normal file
250
server/app/dice/logic/reward_config_record/WeightTestRunner.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\dice\logic\reward_config_record;
|
||||
|
||||
use app\api\logic\PlayStartLogic;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use support\Log;
|
||||
use support\think\Db;
|
||||
|
||||
/**
|
||||
* 一键测试权重:单进程后台执行模拟摇色子,写入 dice_play_record_test 并更新 dice_reward_config_record 进度
|
||||
* 抽奖逻辑与 PlayStartLogic 一致:使用 name=default 的安全线、杀分开关;盈利<安全线时付费用玩家权重、免费用 killScore;盈利>=安全线且杀分开启时付费/免费均用 killScore
|
||||
*/
|
||||
class WeightTestRunner
|
||||
{
|
||||
private const BATCH_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 执行指定测试记录:按付费/免费、顺/逆方向交替模拟(付费顺→付费逆→免费顺→免费逆),每 10 条写入一次测试表并更新进度
|
||||
* 使用与 playStart 相同的彩金池逻辑:name=default 的安全线/kill_enabled;付费用 paid_tier_weights(玩家权重)或 killScore;免费用 killScore
|
||||
* @param int $recordId dice_reward_config_record.id
|
||||
*/
|
||||
public function run(int $recordId): void
|
||||
{
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if (!$record) {
|
||||
Log::error("WeightTestRunner: 记录不存在 record_id={$recordId}");
|
||||
return;
|
||||
}
|
||||
|
||||
$paidS = (int) ($record->paid_s_count ?? 0);
|
||||
$paidN = (int) ($record->paid_n_count ?? 0);
|
||||
$freeS = (int) ($record->free_s_count ?? 0);
|
||||
$freeN = (int) ($record->free_n_count ?? 0);
|
||||
if ($paidS + $paidN + $freeS + $freeN <= 0) {
|
||||
$sCount = (int) ($record->s_count ?? 0);
|
||||
$nCount = (int) ($record->n_count ?? 0);
|
||||
$total = $sCount + $nCount;
|
||||
if ($total <= 0) {
|
||||
$this->markFailed($recordId, '抽奖次数必须大于 0');
|
||||
return;
|
||||
}
|
||||
$paidS = $sCount;
|
||||
$paidN = $nCount;
|
||||
} else {
|
||||
$total = $paidS + $paidN + $freeS + $freeN;
|
||||
}
|
||||
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
$this->markFailed($recordId, '彩金池配置 name=default 不存在');
|
||||
return;
|
||||
}
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||
|
||||
$paidTierWeights = (is_array($record->paid_tier_weights ?? null) && $record->paid_tier_weights !== [])
|
||||
? $record->paid_tier_weights
|
||||
: [
|
||||
'T1' => (int) ($configType0->t1_weight ?? 0),
|
||||
'T2' => (int) ($configType0->t2_weight ?? 0),
|
||||
'T3' => (int) ($configType0->t3_weight ?? 0),
|
||||
'T4' => (int) ($configType0->t4_weight ?? 0),
|
||||
'T5' => (int) ($configType0->t5_weight ?? 0),
|
||||
];
|
||||
if (array_sum($paidTierWeights) <= 0) {
|
||||
$this->markFailed($recordId, '需提供 paid_tier_weights(玩家权重,盈利未达安全线时付费抽奖使用)或选择 default 奖池');
|
||||
return;
|
||||
}
|
||||
|
||||
$freeConfig = $configType1 !== null ? $configType1 : $configType0;
|
||||
|
||||
// 每次测试开始前清空进程内静态缓存,强制从共享缓存读取最新 BIGWIN/奖励配置,与数据库一致
|
||||
DiceRewardConfig::clearRequestInstance();
|
||||
DiceReward::clearRequestInstance();
|
||||
|
||||
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||
$poolProfitTotal = $configType0->profit_amount ?? 0;
|
||||
|
||||
$playLogic = new PlayStartLogic();
|
||||
$resultCounts = [];
|
||||
$tierCounts = [];
|
||||
$buffer = [];
|
||||
$done = 0;
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < $paidS; $i++) {
|
||||
$usePoolWeights = $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
|
||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $poolProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $paidN; $i++) {
|
||||
$usePoolWeights = $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
|
||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $poolProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $freeS; $i++) {
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
|
||||
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $poolProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $freeN; $i++) {
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
|
||||
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $poolProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
if (!empty($buffer)) {
|
||||
$this->insertBuffer($buffer);
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts);
|
||||
}
|
||||
// 平台赚取金额:通过关联 DicePlayRecordTest(reward_config_record_id)统计
|
||||
$this->markSuccess($recordId, $resultCounts, $tierCounts);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('WeightTestRunner exception: ' . $e->getMessage(), ['record_id' => $recordId, 'trace' => $e->getTraceAsString()]);
|
||||
$this->markFailed($recordId, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 累加彩金池累计盈利,用于触发杀分,与 PlayStartLogic 一致
|
||||
* @param int $lotteryType 0=付费券,1=免费券
|
||||
* @param object $usedConfig 本次使用的奖池配置(仅用于校验非空)
|
||||
* @param object $configType0 name=default 的彩金池
|
||||
* @param float $playerProfitTotal 实际为“彩金池累计盈利”滚动值
|
||||
*/
|
||||
private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void
|
||||
{
|
||||
if (($lotteryType !== 0 && $lotteryType !== 1) || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) {
|
||||
return;
|
||||
}
|
||||
$winCoin = (float) $row['win_coin'];
|
||||
$playerProfitTotal += $lotteryType === 0 ? ($winCoin - 100.0) : $winCoin;
|
||||
}
|
||||
|
||||
private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void
|
||||
{
|
||||
$grid = (int) ($row['roll_number_for_count'] ?? $row['roll_number'] ?? 0);
|
||||
if ($grid >= 5 && $grid <= 30) {
|
||||
$resultCounts[$grid] = ($resultCounts[$grid] ?? 0) + 1;
|
||||
}
|
||||
$tier = (string) ($row['tier'] ?? '');
|
||||
if ($tier !== '') {
|
||||
$tierCounts[$tier] = ($tierCounts[$tier] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private function rowForInsert(array $row, int $rewardConfigRecordId): array
|
||||
{
|
||||
$out = [
|
||||
'reward_config_record_id' => $rewardConfigRecordId,
|
||||
];
|
||||
$keys = [
|
||||
'player_id', 'admin_id', 'lottery_config_id', 'lottery_type', 'is_win', 'win_coin',
|
||||
'super_win_coin', 'reward_win_coin', 'use_coins', 'direction', 'reward_config_id',
|
||||
'start_index', 'target_index', 'roll_array', 'roll_number', 'lottery_name', 'status',
|
||||
];
|
||||
foreach ($keys as $k) {
|
||||
if (array_key_exists($k, $row)) {
|
||||
$out[$k] = $row[$k];
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function flushIfNeeded(array &$buffer, int $recordId, int $done, int $total, array $resultCounts, array $tierCounts): void
|
||||
{
|
||||
if (count($buffer) < self::BATCH_SIZE) {
|
||||
return;
|
||||
}
|
||||
$this->insertBuffer($buffer);
|
||||
$buffer = [];
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts);
|
||||
}
|
||||
|
||||
private function insertBuffer(array $rows): void
|
||||
{
|
||||
if (empty($rows)) {
|
||||
return;
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
DicePlayRecordTest::create($row);
|
||||
}
|
||||
}
|
||||
|
||||
private function updateProgress(int $recordId, int $overPlayCount, array $resultCounts, array $tierCounts): void
|
||||
{
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if ($record) {
|
||||
$record->over_play_count = $overPlayCount;
|
||||
$record->result_counts = $resultCounts;
|
||||
$record->tier_counts = $tierCounts;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记测试成功并记录平台总盈利 platform_profit
|
||||
* 通过关联 DicePlayRecordTest(reward_config_record_id)统计:付费(lottery_type=0)次数×100 - win_coin 求和
|
||||
*/
|
||||
private function markSuccess(int $recordId, array $resultCounts, array $tierCounts): void
|
||||
{
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if ($record) {
|
||||
// 平台盈利通过关联测试记录统计
|
||||
$platformProfit = DiceRewardConfigRecord::computePlatformProfitFromRelated($recordId);
|
||||
// 落点统计也通过关联测试记录重新统计,避免模拟过程异常导致为空
|
||||
$dbResultCounts = DiceRewardConfigRecord::computeResultCountsFromRelated($recordId);
|
||||
|
||||
$record->status = DiceRewardConfigRecord::STATUS_SUCCESS;
|
||||
$record->result_counts = !empty($dbResultCounts) ? $dbResultCounts : $resultCounts;
|
||||
$record->tier_counts = $tierCounts;
|
||||
$record->remark = null;
|
||||
$record->platform_profit = $platformProfit;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function markFailed(int $recordId, string $message): void
|
||||
{
|
||||
DiceRewardConfigRecord::where('id', $recordId)->update([
|
||||
'status' => DiceRewardConfigRecord::STATUS_FAIL,
|
||||
'remark' => mb_substr($message, 0, 500),
|
||||
'platform_profit' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,9 @@ use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
* @property $name 配置名称
|
||||
* @property $group 分组
|
||||
* @property $title 标题
|
||||
* @property $title_en 标题(英文)
|
||||
* @property $value 值
|
||||
* @property $value_en 值(英文)
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
@@ -35,6 +37,12 @@ class DiceConfig extends BaseModel
|
||||
*/
|
||||
protected $table = 'dice_config';
|
||||
|
||||
/**
|
||||
* 是否自动维护 create_time / update_time(继承基类 CREATED_AT / UPDATED_AT)
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 属性转换
|
||||
*/
|
||||
|
||||
@@ -4,29 +4,30 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\lottery_config;
|
||||
namespace app\dice\model\lottery_pool_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
|
||||
/**
|
||||
* 色子奖池配置模型
|
||||
*
|
||||
* dice_lottery_config 色子奖池配置
|
||||
* dice_lottery_pool_config 色子奖池配置
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $name 名称
|
||||
* @property $remark 备注
|
||||
* @property $type 奖池类型
|
||||
* @property $safety_line 安全线
|
||||
* @property $kill_enabled 是否启用杀分:0=关闭 1=开启
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
* @property $t1_wight T1池权重
|
||||
* @property $t2_wight T2池权重
|
||||
* @property $t3_wight T3池权重
|
||||
* @property $t4_wight T4池权重
|
||||
* @property $t5_wight T5池权重
|
||||
* @property $t1_weight T1池权重
|
||||
* @property $t2_weight T2池权重
|
||||
* @property $t3_weight T3池权重
|
||||
* @property $t4_weight T4池权重
|
||||
* @property $t5_weight T5池权重
|
||||
* @property $profit_amount 池子累计盈利(每局抽奖累加 100-real_ev,仅展示不可编辑)
|
||||
*/
|
||||
class DiceLotteryConfig extends BaseModel
|
||||
class DiceLotteryPoolConfig extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
@@ -38,7 +39,7 @@ class DiceLotteryConfig extends BaseModel
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_lottery_config';
|
||||
protected $table = 'dice_lottery_pool_config';
|
||||
|
||||
/**
|
||||
* 名称 搜索
|
||||
@@ -6,9 +6,9 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\play_record;
|
||||
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
@@ -19,16 +19,20 @@ use think\model\relation\BelongsTo;
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $player_id 玩家id
|
||||
* @property $admin_id 关联玩家所属管理员ID(DicePlayer.admin_id)
|
||||
* @property $lottery_config_id 彩金池配置
|
||||
* @property $lottery_type 抽奖类型
|
||||
* @property $is_win 中奖
|
||||
* @property $win_coin 赢取平台币
|
||||
* @property $is_win 是否中大奖:豹子号[1,1,1,1,1]~[6,6,6,6,6]为1,否则0
|
||||
* @property $win_coin 赢取平台币(= super_win_coin + reward_win_coin)
|
||||
* @property $super_win_coin 中大奖平台币(豹子时发放)
|
||||
* @property $reward_win_coin 摇色子中奖平台币
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $reward_config_id 奖励配置id
|
||||
* @property $lottery_id 奖池
|
||||
* @property $start_index 起始索引
|
||||
* @property $target_index 结束索引
|
||||
* @property $roll_array 摇取点数,格式:[1,2,3,4,5](5个点数)
|
||||
* @property $roll_number 摇取点数和(5个色子点数之和,5-30)
|
||||
* @property $lottery_name 奖池名
|
||||
* @property $status 状态:0=超时/失败 1=成功
|
||||
* @property $create_time 创建时间
|
||||
@@ -67,12 +71,12 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 彩金配置
|
||||
* 关联模型 diceLotteryConfig
|
||||
* 彩金池配置
|
||||
* 关联模型 diceLotteryPoolConfig
|
||||
*/
|
||||
public function diceLotteryConfig(): BelongsTo
|
||||
public function diceLotteryPoolConfig(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DiceLotteryConfig::class, 'lottery_config_id', 'id');
|
||||
return $this->belongsTo(DiceLotteryPoolConfig::class, 'lottery_config_id', 'id');
|
||||
}
|
||||
|
||||
/** 按玩家用户名模糊(dicePlayer.username) */
|
||||
@@ -89,13 +93,13 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 按彩金池配置名称模糊(diceLotteryConfig.name) */
|
||||
/** 按彩金池配置名称模糊(diceLotteryPoolConfig.name) */
|
||||
public function searchLotteryConfigNameAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DiceLotteryConfig::where('name', 'like', '%' . $value . '%')->column('id');
|
||||
$ids = DiceLotteryPoolConfig::where('name', 'like', '%' . $value . '%')->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('lottery_config_id', $ids);
|
||||
} else {
|
||||
@@ -103,6 +107,58 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取 roll_array 时:若为空且 roll_number 在 5~30,则按点数和生成默认 5 个色子数组,避免“点数和有值但五个点数空”的展示问题
|
||||
* @param mixed $value 库中原始值(JSON 字符串或 null)
|
||||
* @param array $data 当前记录数据
|
||||
* @return array 5 个元素的数组,每项 1~6
|
||||
*/
|
||||
public function getRollArrayAttr($value, $data = []): array
|
||||
{
|
||||
$arr = [];
|
||||
if (is_string($value) && $value !== '') {
|
||||
$decoded = json_decode($value, true);
|
||||
$arr = is_array($decoded) ? $decoded : [];
|
||||
} elseif (is_array($value)) {
|
||||
$arr = $value;
|
||||
}
|
||||
$sum = isset($data['roll_number']) ? (int) $data['roll_number'] : 0;
|
||||
if (count($arr) === 5 && array_sum($arr) === $sum) {
|
||||
$valid = true;
|
||||
foreach ($arr as $v) {
|
||||
if (!is_numeric($v) || (int) $v < 1 || (int) $v > 6) {
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($valid) {
|
||||
return array_map('intval', array_slice($arr, 0, 5));
|
||||
}
|
||||
}
|
||||
if ($sum >= 5 && $sum <= 30) {
|
||||
return self::defaultRollArrayForSum($sum);
|
||||
}
|
||||
return array_slice(array_map('intval', $arr), 0, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据点数和生成默认 5 个色子数组(每项 1~6),用于补全缺失的 roll_array
|
||||
*/
|
||||
public static function defaultRollArrayForSum(int $sum): array
|
||||
{
|
||||
$sum = max(5, min(30, $sum));
|
||||
$base = (int) floor($sum / 5);
|
||||
$rem = $sum - 5 * $base;
|
||||
$arr = array_fill(0, 5, $base);
|
||||
for ($i = 0; $i < $rem; $i++) {
|
||||
$arr[$i]++;
|
||||
}
|
||||
$arr = array_map(function ($v) {
|
||||
return max(1, min(6, (int) $v));
|
||||
}, $arr);
|
||||
return array_values($arr);
|
||||
}
|
||||
|
||||
/** 抽奖类型 */
|
||||
public function searchLotteryTypeAttr($query, $value)
|
||||
{
|
||||
@@ -111,7 +167,25 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 中奖 */
|
||||
/**
|
||||
* 是否豹子号(中大奖):5 个点数相同且为 1~6 之一(含 [6,6,6,6,6])
|
||||
* @param int[] $rollArray 摇取点数数组,如 [1,1,1,1,1] 或 [6,6,6,6,6]
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSuperWin(array $rollArray): bool
|
||||
{
|
||||
if (count($rollArray) !== 5) {
|
||||
return false;
|
||||
}
|
||||
$unique = array_unique($rollArray);
|
||||
if (count($unique) !== 1) {
|
||||
return false;
|
||||
}
|
||||
$value = reset($unique);
|
||||
return in_array($value, [1, 2, 3, 4, 5, 6], true);
|
||||
}
|
||||
|
||||
/** 是否中大奖 */
|
||||
public function searchIsWinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -135,6 +209,38 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 中大奖平台币下限 */
|
||||
public function searchSuperWinCoinMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('super_win_coin', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 中大奖平台币上限 */
|
||||
public function searchSuperWinCoinMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('super_win_coin', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 摇色子中奖平台币下限 */
|
||||
public function searchRewardWinCoinMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('reward_win_coin', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 摇色子中奖平台币上限 */
|
||||
public function searchRewardWinCoinMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('reward_win_coin', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 按奖励配置前端显示文本模糊(diceRewardConfig.ui_text) */
|
||||
public function searchRewardUiTextAttr($query, $value)
|
||||
{
|
||||
@@ -170,4 +276,20 @@ class DicePlayRecord extends BaseModel
|
||||
$query->where('direction', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 摇取点数和下限 */
|
||||
public function searchRollNumberMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('roll_number', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 摇取点数和上限 */
|
||||
public function searchRollNumberMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('roll_number', '<=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
141
server/app/dice/model/play_record_test/DicePlayRecordTest.php
Normal file
141
server/app/dice/model/play_record_test/DicePlayRecordTest.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\play_record_test;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
/**
|
||||
* 玩家抽奖记录(测试数据)模型
|
||||
*
|
||||
* dice_play_record_test 玩家抽奖记录(测试数据)
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $lottery_config_id 彩金池配置id
|
||||
* @property $lottery_type 抽奖类型:0=付费,1=赠送
|
||||
* @property $is_win 中大奖:0=无,1=中奖
|
||||
* @property $win_coin 赢取平台币
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $reward_config_id 奖励配置id
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
* @property $start_index 起始索引
|
||||
* @property $target_index 结束索引
|
||||
* @property $roll_number 摇取点数和
|
||||
* @property $roll_array 摇取点数:[1,2,3,4,5,6]
|
||||
* @property $status 状态:0=失败,1=成功
|
||||
* @property $super_win_coin 中大奖平台币
|
||||
* @property $reward_win_coin 摇色子中奖平台币
|
||||
* @property $admin_id 所属管理员
|
||||
* @property int|null $reward_config_record_id 关联 DiceRewardConfigRecord.id(权重测试记录)
|
||||
*/
|
||||
class DicePlayRecordTest extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_play_record_test';
|
||||
|
||||
/**
|
||||
* 彩金池配置
|
||||
* 关联 lottery_config_id -> DiceLotteryPoolConfig.id
|
||||
*/
|
||||
public function diceLotteryPoolConfig(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DiceLotteryPoolConfig::class, 'lottery_config_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖励配置(终点格 = target_index 对应 DiceRewardConfig.id,表中为 reward_config_id)
|
||||
* 关联 reward_config_id -> DiceRewardConfig.id
|
||||
*/
|
||||
public function diceRewardConfig(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DiceRewardConfig::class, 'reward_config_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联的权重测试记录
|
||||
* reward_config_record_id -> DiceRewardConfigRecord.id
|
||||
*/
|
||||
public function diceRewardConfigRecord(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DiceRewardConfigRecord::class, 'reward_config_record_id', 'id');
|
||||
}
|
||||
|
||||
/** 抽奖类型 0=付费 1=赠送 */
|
||||
public function searchLotteryTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('lottery_type', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 方向 0=顺时针 1=逆时针 */
|
||||
public function searchDirectionAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('direction', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 是否中大奖 0=无 1=中大奖 */
|
||||
public function searchIsWinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('is_win', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 赢取平台币下限 */
|
||||
public function searchWinCoinMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('win_coin', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 赢取平台币上限 */
|
||||
public function searchWinCoinMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('win_coin', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 中奖档位(按 reward_config_id 对应 DiceRewardConfig.tier) */
|
||||
public function searchRewardTierAttr($query, $value)
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$ids = DiceRewardConfig::where('tier', '=', $value)->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('reward_config_id', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
|
||||
/** 点数和 roll_number(摇取点数和 5-30) */
|
||||
public function searchRollNumberAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('roll_number', '=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace app\dice\model\player;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
|
||||
/**
|
||||
* 大富翁-玩家模型
|
||||
@@ -22,18 +22,19 @@ use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
* @property $password 密码
|
||||
* @property $status 状态
|
||||
* @property $coin 平台币
|
||||
* @property $is_up 倍率
|
||||
* @property $t1_wight T1池权重
|
||||
* @property $t2_wight T2池权重
|
||||
* @property $t3_wight T3池权重
|
||||
* @property $t4_wight T4池权重
|
||||
* @property $t5_wight T5池权重
|
||||
* @property $admin_id 创建该玩家的后台管理员ID,关联 sa_system_user.id
|
||||
* @property $lottery_config_id 彩金池配置ID(0或null时使用自定义权重*_weight)
|
||||
* @property $t1_weight T1池权重
|
||||
* @property $t2_weight T2池权重
|
||||
* @property $t3_weight T3池权重
|
||||
* @property $t4_weight T4池权重
|
||||
* @property $t5_weight T5池权重
|
||||
* @property $total_ticket_count 总抽奖次数
|
||||
* @property $paid_ticket_count 购买抽奖次数
|
||||
* @property $free_ticket_count 赠送抽奖次数
|
||||
* @property $created_at 创建时间
|
||||
* @property $updated_at 更新时间
|
||||
* @property $deleted_at 删除时间
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 更新时间
|
||||
* @property $delete_time 删除时间
|
||||
*/
|
||||
class DicePlayer extends BaseModel
|
||||
{
|
||||
@@ -49,10 +50,9 @@ class DicePlayer extends BaseModel
|
||||
*/
|
||||
protected $table = 'dice_player';
|
||||
|
||||
/** 创建时间字段(dice_player 表为 created_at) */
|
||||
protected $createTime = 'created_at';
|
||||
/** 更新时间字段(dice_player 表为 updated_at) */
|
||||
protected $updateTime = 'updated_at';
|
||||
protected $createTime = 'create_time';
|
||||
|
||||
protected $updateTime = 'update_time';
|
||||
|
||||
/**
|
||||
* 新增前:生成唯一 uid,昵称 name 默认使用 uid
|
||||
@@ -78,20 +78,30 @@ class DicePlayer extends BaseModel
|
||||
if ($name === null || $name === '') {
|
||||
$model->setAttr('name', $uid);
|
||||
}
|
||||
// 彩金池权重默认取 type=0 的奖池配置
|
||||
// 创建玩家时:未指定则自动保存 lottery_config_id 为 DiceLotteryPoolConfig name=default 的 id,没有则为 0
|
||||
try {
|
||||
$lotteryConfigId = $model->getAttr('lottery_config_id');
|
||||
} catch (\Throwable $e) {
|
||||
$lotteryConfigId = null;
|
||||
}
|
||||
if ($lotteryConfigId === null || $lotteryConfigId === '' || (int) $lotteryConfigId === 0) {
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$model->setAttr('lottery_config_id', $config ? (int) $config->id : 0);
|
||||
}
|
||||
// 彩金池权重默认取 name=default 的奖池配置
|
||||
self::setDefaultWeightsFromLotteryConfig($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 DiceLotteryConfig type=0 取 t1_wight~t5_wight 作为玩家未设置时的默认值
|
||||
* 从 DiceLotteryPoolConfig name=default 取 t1_weight~t5_weight 作为玩家未设置时的默认值
|
||||
*/
|
||||
protected static function setDefaultWeightsFromLotteryConfig(DicePlayer $model): void
|
||||
{
|
||||
$config = DiceLotteryConfig::where('type', 0)->find();
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
if (!$config) {
|
||||
return;
|
||||
}
|
||||
$fields = ['t1_wight', 't2_wight', 't3_wight', 't4_wight', 't5_wight'];
|
||||
$fields = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'];
|
||||
foreach ($fields as $field) {
|
||||
try {
|
||||
$val = $model->getAttr($field);
|
||||
@@ -163,13 +173,20 @@ class DicePlayer extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 倍率 搜索
|
||||
* 彩金池配置ID 搜索
|
||||
*/
|
||||
public function searchIs_upAttr($query, $value)
|
||||
public function searchLottery_config_idAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('is_up', '=', $value);
|
||||
$query->where('lottery_config_id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联彩金池配置
|
||||
*/
|
||||
public function diceLotteryPoolConfig()
|
||||
{
|
||||
return $this->belongsTo(DiceLotteryPoolConfig::class, 'lottery_config_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use think\model\relation\BelongsTo;
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $player_id 玩家id
|
||||
* @property $admin_id 关联玩家所属管理员ID(DicePlayer.admin_id)
|
||||
* @property $use_coins 消耗硬币
|
||||
* @property $total_ticket_count 总抽奖次数
|
||||
* @property $paid_ticket_count 购买抽奖次数
|
||||
|
||||
@@ -18,6 +18,7 @@ use think\model\relation\BelongsTo;
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $player_id 用户id
|
||||
* @property $admin_id 关联玩家所属管理员ID(DicePlayer.admin_id)
|
||||
* @property $coin 平台币变化
|
||||
* @property $type 类型:0=充值 1=提现 2=购买抽奖次数
|
||||
* @property $wallet_before 钱包操作前
|
||||
|
||||
140
server/app/dice/model/reward/DiceReward.php
Normal file
140
server/app/dice/model/reward/DiceReward.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
* 奖励对照模型
|
||||
*
|
||||
* dice_reward 奖励对照表(主键 id 自增)
|
||||
* 唯一约束 (direction, grid_number),保证每个点数、每个方向各一条;end_index 关联 DiceRewardConfig.id
|
||||
*
|
||||
* @property $id 主键
|
||||
* @property $tier 档位 T1-T5/BIGWIN
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $end_index 结束索引(DiceRewardConfig.id)
|
||||
* @property $weight 权重 1-10000,档位内按权重比抽取
|
||||
* @property $grid_number 色子点数(摇取值)
|
||||
* @property $start_index 起始索引(DiceRewardConfig.id)
|
||||
* @property $ui_text 显示文本(来自config)
|
||||
* @property $real_ev 实际中奖金额(来自config)
|
||||
* @property $remark 备注(来自config)
|
||||
* @property $type 奖励类型(来自config)
|
||||
*/
|
||||
class DiceReward extends BaseModel
|
||||
{
|
||||
/** 方向:顺时针 */
|
||||
public const DIRECTION_CLOCKWISE = 0;
|
||||
/** 方向:逆时针 */
|
||||
public const DIRECTION_COUNTERCLOCKWISE = 1;
|
||||
|
||||
/** 缓存键:奖励对照实例 */
|
||||
private const CACHE_KEY_INSTANCE = 'dice:reward:instance';
|
||||
|
||||
private const CACHE_TTL = 86400 * 30;
|
||||
|
||||
private static ?array $instance = null;
|
||||
|
||||
protected $table = 'dice_reward';
|
||||
|
||||
/** 主键 id 自增,唯一约束 (direction, grid_number) */
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 获取奖励对照实例(按档位+方向索引,用于抽奖与权重配比)
|
||||
* 优先从共享缓存读取,保证多进程(如一键测试 worker)与数据库一致
|
||||
* @return array{list: array, by_tier_direction: array}
|
||||
*/
|
||||
public static function getCachedInstance(): array
|
||||
{
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
if ($instance !== null && is_array($instance)) {
|
||||
self::$instance = $instance;
|
||||
return $instance;
|
||||
}
|
||||
if (self::$instance !== null) {
|
||||
return self::$instance;
|
||||
}
|
||||
self::refreshCache();
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
self::$instance = is_array($instance) ? $instance : self::buildEmptyInstance();
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按档位+方向取权重列表(用于抽奖:该档位该方向下 end_index => weight)
|
||||
* @return array<int, int> end_index => weight
|
||||
*/
|
||||
public static function getCachedByTierAndDirection(string $tier, int $direction): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$byTierDirection = $inst['by_tier_direction'] ?? [];
|
||||
$list = $byTierDirection[$tier][$direction] ?? [];
|
||||
$result = [];
|
||||
foreach ($list as $row) {
|
||||
$endIndex = isset($row['end_index']) ? (int) $row['end_index'] : 0;
|
||||
$weight = isset($row['weight']) ? (int) $row['weight'] : 1;
|
||||
$result[$endIndex] = $weight;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新从数据库加载并写入缓存;修改/新增/删除后需调用以实例化
|
||||
*/
|
||||
public static function refreshCache(): void
|
||||
{
|
||||
$list = (new self())->order('tier')->order('direction')->order('end_index')->select()->toArray();
|
||||
$byTierDirection = [];
|
||||
foreach ($list as $row) {
|
||||
$tier = isset($row['tier']) ? (string) $row['tier'] : '';
|
||||
$direction = isset($row['direction']) ? (int) $row['direction'] : 0;
|
||||
if ($tier !== '') {
|
||||
if (!isset($byTierDirection[$tier])) {
|
||||
$byTierDirection[$tier] = [0 => [], 1 => []];
|
||||
}
|
||||
if (!isset($byTierDirection[$tier][$direction])) {
|
||||
$byTierDirection[$tier][$direction] = [];
|
||||
}
|
||||
$byTierDirection[$tier][$direction][] = $row;
|
||||
}
|
||||
}
|
||||
self::$instance = [
|
||||
'list' => $list,
|
||||
'by_tier_direction' => $byTierDirection,
|
||||
];
|
||||
Cache::set(self::CACHE_KEY_INSTANCE, self::$instance, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
private static function buildEmptyInstance(): array
|
||||
{
|
||||
return [
|
||||
'list' => [],
|
||||
'by_tier_direction' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public static function clearRequestInstance(): void
|
||||
{
|
||||
self::$instance = null;
|
||||
}
|
||||
|
||||
public static function onAfterInsert($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
|
||||
public static function onAfterUpdate($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
|
||||
public static function onAfterDelete($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
}
|
||||
9
server/app/dice/model/reward/DiceRewardConfig.php
Normal file
9
server/app/dice/model/reward/DiceRewardConfig.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 别名:reward 命名空间下引用 reward_config\DiceRewardConfig
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward;
|
||||
|
||||
class DiceRewardConfig extends \app\dice\model\reward_config\DiceRewardConfig
|
||||
{
|
||||
}
|
||||
@@ -6,88 +6,86 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config;
|
||||
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
* 奖励配置模型
|
||||
*
|
||||
* dice_reward_config 奖励配置
|
||||
* 奖励列表为全玩家通用,保存时刷新缓存,游戏时优先读缓存。
|
||||
* dice_reward_config 奖励配置;BIGWIN 档位使用本表 weight(0-10000,10000=100% 中大奖)
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $grid_number 色子点数
|
||||
* @property $ui_text 前端显示文本
|
||||
* @property $ui_text_en 前端显示文本(英文)
|
||||
* @property $real_ev 真实资金结算
|
||||
* @property $tier 所属档位
|
||||
* @property $s_end_index 顺时针结束索引
|
||||
* @property $n_end_index 逆时针结束索引
|
||||
* @property $weight 权重(仅 BIGWIN 使用,0-10000)
|
||||
* @property $remark 备注
|
||||
* @property $type 奖励类型 -2=唯一惩罚,-1=抽水,0=回本,1=再来一次,2=小赚,3=大奖格
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DiceRewardConfig extends BaseModel
|
||||
{
|
||||
/** 缓存键:彩金池奖励列表实例(含列表与索引) */
|
||||
/** 缓存键:彩金池奖励列表实例 */
|
||||
private const CACHE_KEY_INSTANCE = 'dice:reward_config:instance';
|
||||
|
||||
/** 缓存过期时间(秒),保存时会主动刷新故设较长 */
|
||||
private const CACHE_TTL = 86400 * 30;
|
||||
|
||||
/** 当前请求内已加载的实例,避免同请求多次读缓存 */
|
||||
private static ?array $instance = null;
|
||||
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_reward_config';
|
||||
|
||||
/**
|
||||
* 获取彩金池实例(含 list / 索引),无则从库加载并写入缓存;同请求内复用
|
||||
* @return array{list: array, by_tier: array, by_s_end_index: array, by_n_end_index: array, min_real_ev: float}
|
||||
* 获取彩金池实例(含 list / by_tier / by_tier_grid),无则从库加载并写入缓存
|
||||
* 优先从共享缓存读取,保证多进程(如一键测试 worker)能拿到最新配置,与数据库一致
|
||||
* @return array{list: array, by_tier: array, by_tier_grid: array, min_real_ev: float}
|
||||
*/
|
||||
public static function getCachedInstance(): array
|
||||
{
|
||||
if (self::$instance !== null) {
|
||||
return self::$instance;
|
||||
}
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
if ($instance !== null && is_array($instance)) {
|
||||
self::$instance = $instance;
|
||||
return $instance;
|
||||
}
|
||||
if (self::$instance !== null) {
|
||||
return self::$instance;
|
||||
}
|
||||
self::refreshCache();
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
self::$instance = is_array($instance) ? $instance : self::buildEmptyInstance();
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存的奖励列表(无则从库加载并写入缓存)
|
||||
* @return array<int, array>
|
||||
*/
|
||||
public static function getCachedList(): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
return $inst['list'] ?? [];
|
||||
}
|
||||
|
||||
public static function getCachedById(int $id): ?array
|
||||
{
|
||||
$list = self::getCachedList();
|
||||
foreach ($list as $row) {
|
||||
if (isset($row['id']) && (int) $row['id'] === $id) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新从数据库加载并写入缓存(保存时调用),构建列表与索引
|
||||
* 重新从数据库加载并写入缓存(按档位+权重抽 grid_number,含 by_tier、by_tier_grid)
|
||||
*/
|
||||
public static function refreshCache(): void
|
||||
{
|
||||
$list = (new self())->order('id', 'asc')->select()->toArray();
|
||||
$byTier = [];
|
||||
$bySEndIndex = [];
|
||||
$byNEndIndex = [];
|
||||
$byTierGrid = [];
|
||||
foreach ($list as $row) {
|
||||
$tier = isset($row['tier']) ? (string) $row['tier'] : '';
|
||||
if ($tier !== '') {
|
||||
@@ -95,48 +93,47 @@ class DiceRewardConfig extends BaseModel
|
||||
$byTier[$tier] = [];
|
||||
}
|
||||
$byTier[$tier][] = $row;
|
||||
}
|
||||
$sEnd = isset($row['s_end_index']) ? (int) $row['s_end_index'] : 0;
|
||||
if ($sEnd !== 0) {
|
||||
if (!isset($bySEndIndex[$sEnd])) {
|
||||
$bySEndIndex[$sEnd] = [];
|
||||
$gridNum = isset($row['grid_number']) ? (int) $row['grid_number'] : 0;
|
||||
if (!isset($byTierGrid[$tier])) {
|
||||
$byTierGrid[$tier] = [];
|
||||
}
|
||||
$bySEndIndex[$sEnd][] = $row;
|
||||
}
|
||||
$nEnd = isset($row['n_end_index']) ? (int) $row['n_end_index'] : 0;
|
||||
if ($nEnd !== 0) {
|
||||
if (!isset($byNEndIndex[$nEnd])) {
|
||||
$byNEndIndex[$nEnd] = [];
|
||||
if (!isset($byTierGrid[$tier][$gridNum])) {
|
||||
$byTierGrid[$tier][$gridNum] = $row;
|
||||
}
|
||||
$byNEndIndex[$nEnd][] = $row;
|
||||
}
|
||||
}
|
||||
$minRealEv = empty($list) ? 0.0 : (float) min(array_column($list, 'real_ev'));
|
||||
self::$instance = [
|
||||
'list' => $list,
|
||||
'by_tier' => $byTier,
|
||||
'by_s_end_index' => $bySEndIndex,
|
||||
'by_n_end_index' => $byNEndIndex,
|
||||
'min_real_ev' => $minRealEv,
|
||||
'list' => $list,
|
||||
'by_tier' => $byTier,
|
||||
'by_tier_grid' => $byTierGrid,
|
||||
'min_real_ev' => $minRealEv,
|
||||
];
|
||||
Cache::set(self::CACHE_KEY_INSTANCE, self::$instance, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
/** 空实例结构 */
|
||||
private static function buildEmptyInstance(): array
|
||||
{
|
||||
return [
|
||||
'list' => [],
|
||||
'by_tier' => [],
|
||||
'by_s_end_index' => [],
|
||||
'by_n_end_index' => [],
|
||||
'min_real_ev' => 0.0,
|
||||
'list' => [],
|
||||
'by_tier' => [],
|
||||
'by_tier_grid' => [],
|
||||
'min_real_ev' => 0.0,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存取最小 real_ev
|
||||
* 按档位+色子点数取一条(用于 BIGWIN)
|
||||
*/
|
||||
public static function getCachedByTierAndGridNumber(string $tier, int $gridNumber): ?array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$byTierGrid = $inst['by_tier_grid'] ?? [];
|
||||
$tierData = $byTierGrid[$tier] ?? [];
|
||||
$row = $tierData[$gridNumber] ?? null;
|
||||
return is_array($row) ? $row : null;
|
||||
}
|
||||
|
||||
public static function getCachedMinRealEv(): float
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
@@ -144,8 +141,7 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存按档位取奖励列表
|
||||
* @return array<int, array>
|
||||
* 从缓存按档位取奖励列表(不含权重,仅配置)
|
||||
*/
|
||||
public static function getCachedByTier(string $tier): array
|
||||
{
|
||||
@@ -155,54 +151,41 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存按顺时针结束索引取列表(s_end_index = id 的配置)
|
||||
* @return array<int, array>
|
||||
* 按档位+方向取奖励列表(合并 dice_reward 权重,用于抽奖)
|
||||
* @param int $direction 0=顺时针, 1=逆时针
|
||||
* @return array 每行含 id, grid_number, real_ev, tier, weight 等
|
||||
*/
|
||||
public static function getCachedBySEndIndex(int $id): array
|
||||
public static function getCachedByTierForDirection(string $tier, int $direction): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$by = $inst['by_s_end_index'] ?? [];
|
||||
return $by[$id] ?? [];
|
||||
$list = self::getCachedByTier($tier);
|
||||
$weightMap = DiceReward::getCachedByTierAndDirection($tier, $direction);
|
||||
foreach ($list as $i => $row) {
|
||||
$id = isset($row['id']) ? (int) $row['id'] : 0;
|
||||
$list[$i]['weight'] = $weightMap[$id] ?? 1;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存按逆时针结束索引取列表(n_end_index = id 的配置)
|
||||
* @return array<int, array>
|
||||
*/
|
||||
public static function getCachedByNEndIndex(int $id): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$by = $inst['by_n_end_index'] ?? [];
|
||||
return $by[$id] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除当前请求内实例(如测试或需强制下次读缓存时调用)
|
||||
*/
|
||||
public static function clearRequestInstance(): void
|
||||
{
|
||||
self::$instance = null;
|
||||
}
|
||||
|
||||
/** 保存后刷新缓存 */
|
||||
public static function onAfterInsert($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
|
||||
/** 更新后刷新缓存 */
|
||||
public static function onAfterUpdate($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
|
||||
/** 删除后刷新缓存 */
|
||||
public static function onAfterDelete($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
}
|
||||
|
||||
/** 色子点数下限 */
|
||||
public function searchGridNumberMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -210,7 +193,6 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 色子点数上限 */
|
||||
public function searchGridNumberMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -218,7 +200,6 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 前端显示文本模糊 */
|
||||
public function searchUiTextAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -226,7 +207,6 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 真实资金结算下限 */
|
||||
public function searchRealEvMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -234,7 +214,6 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 真实资金结算上限 */
|
||||
public function searchRealEvMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -242,7 +221,6 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 所属档位 */
|
||||
public function searchTierAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
|
||||
/**
|
||||
* 权重配比测试记录模型
|
||||
*
|
||||
* dice_reward_config_record 保存测试时的权重快照与落点统计
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $test_count 测试次数 100/500/1000/5000/10000
|
||||
* @property array $weight_config_snapshot 测试时权重配比快照
|
||||
* @property array $tier_weights_snapshot 测试时 T1-T5 档位权重快照(来自奖池配置)
|
||||
* @property int|null $lottery_config_id 测试时使用的奖池配置 ID
|
||||
* @property array $result_counts 落点统计 grid_number=>出现次数
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
*/
|
||||
class DiceRewardConfigRecord extends BaseModel
|
||||
{
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $table = 'dice_reward_config_record';
|
||||
|
||||
protected $json = ['weight_config_snapshot', 'tier_weights_snapshot', 'result_counts'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config_record;
|
||||
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use think\model\relation\HasMany;
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录模型
|
||||
*
|
||||
* dice_reward_config_record 奖励配置权重测试记录
|
||||
*
|
||||
* @property int $id 主键
|
||||
* @property int $test_count 测试次数 100/500/1000/5000/10000
|
||||
* @property array $weight_config_snapshot 测试时权重配比快照:按档位 id,grid_number,tier,weight
|
||||
* @property array $tier_weights_snapshot 测试时 T1-T5 档位权重快照(来自奖池配置)
|
||||
* @property int|null $lottery_config_id 测试时使用的奖池配置 ID(兼容旧:付费+免费共用)
|
||||
* @property int|null $paid_lottery_config_id 付费抽奖奖池配置 ID,默认 type=0
|
||||
* @property int|null $free_lottery_config_id 免费抽奖奖池配置 ID,默认 type=1
|
||||
* @property int $total_play_count 总模拟次数(s_count+n_count)
|
||||
* @property int $over_play_count 已完成次数
|
||||
* @property int $status 状态 -1失败 0进行中 1成功
|
||||
* @property string|null $remark 失败时记录原因
|
||||
* @property int $s_count 顺时针模拟次数(兼容旧数据)
|
||||
* @property int $n_count 逆时针模拟次数(兼容旧数据)
|
||||
* @property int $paid_s_count 付费抽奖顺时针次数
|
||||
* @property int $paid_n_count 付费抽奖逆时针次数
|
||||
* @property int $free_s_count 免费抽奖顺时针次数
|
||||
* @property int $free_n_count 免费抽奖逆时针次数
|
||||
* @property array|null $paid_tier_weights 付费自定义档位权重 T1-T5
|
||||
* @property array|null $free_tier_weights 免费自定义档位权重 T1-T5
|
||||
* @property array $result_counts 落点统计 grid_number=>出现次数
|
||||
* @property array|null $tier_counts 档位出现次数 T1=>count
|
||||
* @property float|null $platform_profit 平台赚取金额(付费抽取次数×100-玩家总收益)
|
||||
* @property array|null $bigwin_weight 测试时 BIGWIN 档位权重快照(JSON:grid_number=>weight)
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
*/
|
||||
class DiceRewardConfigRecord extends BaseModel
|
||||
{
|
||||
/** 状态:失败 */
|
||||
public const STATUS_FAIL = -1;
|
||||
/** 状态:待执行(队列中) */
|
||||
public const STATUS_RUNNING = 0;
|
||||
/** 状态:执行中(已被某进程领取,防止定时器重入重复执行) */
|
||||
public const STATUS_EXECUTING = 2;
|
||||
/** 状态:成功 */
|
||||
public const STATUS_SUCCESS = 1;
|
||||
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $table = 'dice_reward_config_record';
|
||||
|
||||
protected $json = ['weight_config_snapshot', 'tier_weights_snapshot', 'result_counts', 'tier_counts', 'paid_tier_weights', 'free_tier_weights', 'bigwin_weight'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
/**
|
||||
* 关联的测试抽奖记录(通过 reward_config_record_id)
|
||||
*/
|
||||
public function playRecordTests(): HasMany
|
||||
{
|
||||
return $this->hasMany(DicePlayRecordTest::class, 'reward_config_record_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关联的 DicePlayRecordTest 统计平台赚取平台币
|
||||
* platform_profit = 关联的付费(lottery_type=0)抽取次数 × 100 - 关联的 win_coin 求和
|
||||
* @param int $recordId dice_reward_config_record.id
|
||||
* @return float
|
||||
*/
|
||||
public static function computePlatformProfitFromRelated(int $recordId): float
|
||||
{
|
||||
$paidCount = DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->where('lottery_type', 0)
|
||||
->count();
|
||||
$sumWinCoin = (float) DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->sum('win_coin');
|
||||
return round($paidCount * 100 - $sumWinCoin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关联的 DicePlayRecordTest 统计落点次数
|
||||
* result_counts = [grid_number => 出现次数],只统计 roll_number 在 5-30 之间的记录
|
||||
* @param int $recordId
|
||||
* @return array<int,int>
|
||||
*/
|
||||
public static function computeResultCountsFromRelated(int $recordId): array
|
||||
{
|
||||
$rows = DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->where('roll_number', '>=', 5)
|
||||
->where('roll_number', '<=', 30)
|
||||
->field('roll_number, COUNT(*) AS c')
|
||||
->group('roll_number')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$result = [];
|
||||
foreach ($rows as $row) {
|
||||
$grid = (int) ($row['roll_number'] ?? 0);
|
||||
$cnt = (int) ($row['c'] ?? 0);
|
||||
if ($grid > 0 && $cnt > 0) {
|
||||
$result[$grid] = $cnt;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ class DiceConfigValidate extends BaseValidate
|
||||
'group' => 'require',
|
||||
'title' => 'require',
|
||||
'value' => 'require',
|
||||
'title_en' => 'max:100',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,7 @@ class DiceConfigValidate extends BaseValidate
|
||||
'group' => '分组必须填写',
|
||||
'title' => '标题必须填写',
|
||||
'value' => '值必须填写',
|
||||
'title_en' => '英文标题长度需小于 100 字符',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -42,12 +44,14 @@ class DiceConfigValidate extends BaseValidate
|
||||
'group',
|
||||
'title',
|
||||
'value',
|
||||
'title_en',
|
||||
],
|
||||
'update' => [
|
||||
'name',
|
||||
'group',
|
||||
'title',
|
||||
'value',
|
||||
'title_en',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\lottery_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 色子奖池配置验证器
|
||||
*/
|
||||
class DiceLotteryConfigValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
'type' => 'require',
|
||||
't1_wight' => 'require',
|
||||
't2_wight' => 'require',
|
||||
't3_wight' => 'require',
|
||||
't4_wight' => 'require',
|
||||
't5_wight' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'name' => '名称必须填写',
|
||||
'type' => '奖池类型必须填写',
|
||||
't1_wight' => 'T1池权重必须填写',
|
||||
't2_wight' => 'T2池权重必须填写',
|
||||
't3_wight' => 'T3池权重必须填写',
|
||||
't4_wight' => 'T4池权重必须填写',
|
||||
't5_wight' => 'T5池权重必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'name',
|
||||
'type',
|
||||
't1_wight',
|
||||
't2_wight',
|
||||
't3_wight',
|
||||
't4_wight',
|
||||
't5_wight',
|
||||
],
|
||||
'update' => [
|
||||
'name',
|
||||
'type',
|
||||
't1_wight',
|
||||
't2_wight',
|
||||
't3_wight',
|
||||
't4_wight',
|
||||
't5_wight',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\lottery_pool_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 色子奖池配置验证器
|
||||
*/
|
||||
class DiceLotteryPoolConfigValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
't1_weight' => 'require',
|
||||
't2_weight' => 'require',
|
||||
't3_weight' => 'require',
|
||||
't4_weight' => 'require',
|
||||
't5_weight' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'name' => '名称必须填写',
|
||||
't1_weight' => 'T1池权重必须填写',
|
||||
't2_weight' => 'T2池权重必须填写',
|
||||
't3_weight' => 'T3池权重必须填写',
|
||||
't4_weight' => 'T4池权重必须填写',
|
||||
't5_weight' => 'T5池权重必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'name',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
't4_weight',
|
||||
't5_weight',
|
||||
],
|
||||
'update' => [
|
||||
'name',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
't4_weight',
|
||||
't5_weight',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\play_record_test;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 玩家抽奖记录(测试数据)验证器
|
||||
*/
|
||||
class DicePlayRecordTestValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'lottery_config_id' => 'require',
|
||||
'lottery_type' => 'require',
|
||||
'is_win' => 'require',
|
||||
'direction' => 'require',
|
||||
'reward_config_id' => 'require',
|
||||
'status' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'lottery_config_id' => '彩金池配置id必须填写',
|
||||
'lottery_type' => '抽奖类型:0=付费,1=赠送必须填写',
|
||||
'is_win' => '中大奖:0=无,1=中奖必须填写',
|
||||
'direction' => '方向:0=顺时针,1=逆时针必须填写',
|
||||
'reward_config_id' => '奖励配置id必须填写',
|
||||
'status' => '状态:0=失败,1=成功必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'lottery_config_id',
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'direction',
|
||||
'reward_config_id',
|
||||
'status',
|
||||
],
|
||||
'update' => [
|
||||
'lottery_config_id',
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'direction',
|
||||
'reward_config_id',
|
||||
'status',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -9,46 +9,36 @@ namespace app\dice\validate\reward_config;
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 奖励配置验证器
|
||||
* 奖励配置验证器(DiceRewardConfig;BIGWIN 的 weight 存本表,0-10000)
|
||||
*/
|
||||
class DiceRewardConfigValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'grid_number' => 'require',
|
||||
'ui_text' => 'require',
|
||||
'real_ev' => 'require',
|
||||
'tier' => 'require',
|
||||
/** 色子点数范围:5~30 共 26 个点数 */
|
||||
public const GRID_NUMBER_MIN = 5;
|
||||
public const GRID_NUMBER_MAX = 30;
|
||||
|
||||
protected $rule = [
|
||||
'grid_number' => 'require|integer|between:5,30',
|
||||
'ui_text' => 'require',
|
||||
'ui_text_en' => 'max:255',
|
||||
'real_ev' => 'require',
|
||||
'tier' => 'require',
|
||||
'type' => 'number',
|
||||
'weight' => 'number|between:0,10000', // BIGWIN 大奖权重,仅档位为 BIGWIN 时使用
|
||||
'remark' => 'max:500',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'grid_number' => '色子点数必须填写',
|
||||
'ui_text' => '前端显示文本必须填写',
|
||||
'real_ev' => '真实资金结算必须填写',
|
||||
'tier' => '所属档位必须填写',
|
||||
protected $message = [
|
||||
'grid_number' => '色子点数必须为 5~30 之间的整数(共26个点数)',
|
||||
'ui_text' => '前端显示文本必须填写',
|
||||
'real_ev' => '真实资金结算必须填写',
|
||||
'tier' => '所属档位必须填写',
|
||||
'type' => '奖励类型须为数字',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'grid_number',
|
||||
'ui_text',
|
||||
'real_ev',
|
||||
'tier',
|
||||
],
|
||||
'update' => [
|
||||
'grid_number',
|
||||
'ui_text',
|
||||
'real_ev',
|
||||
'tier',
|
||||
],
|
||||
'save' => ['grid_number', 'ui_text', 'ui_text_en', 'real_ev', 'tier', 'type'],
|
||||
'update' => ['grid_number', 'ui_text', 'ui_text_en', 'real_ev', 'tier', 'type', 'weight', 'remark'],
|
||||
'batch_update' => ['grid_number', 'ui_text', 'ui_text_en', 'real_ev', 'tier', 'remark'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\reward_config_record;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录验证器
|
||||
*/
|
||||
class DiceRewardConfigRecordValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'test_count' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'test_count' => '测试次数:100/500/1000必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'test_count',
|
||||
],
|
||||
'update' => [
|
||||
'test_count',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
51
server/app/process/WeightTestProcess.php
Normal file
51
server/app/process/WeightTestProcess.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\process;
|
||||
|
||||
use app\dice\logic\reward_config_record\WeightTestRunner;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use Workerman\Timer;
|
||||
use Workerman\Worker;
|
||||
|
||||
/**
|
||||
* 一键测试权重定时任务进程:每隔一定时间检查 status=0 的测试记录并执行一条,不占用 HTTP worker 资源
|
||||
*/
|
||||
class WeightTestProcess
|
||||
{
|
||||
/** 轮询间隔(秒) */
|
||||
private const INTERVAL = 15;
|
||||
|
||||
public function onWorkerStart(Worker $worker): void
|
||||
{
|
||||
Timer::add(self::INTERVAL, function () {
|
||||
$this->runOnePending();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行一条待完成的测试记录(status=0)
|
||||
* 先原子更新为 STATUS_EXECUTING,避免定时器 15 秒重入时同一条记录被重复执行(导致顺/逆时针各跑两倍次数)
|
||||
*/
|
||||
private function runOnePending(): void
|
||||
{
|
||||
$record = DiceRewardConfigRecord::where('status', DiceRewardConfigRecord::STATUS_RUNNING)
|
||||
->order('id')
|
||||
->find();
|
||||
if (!$record) {
|
||||
return;
|
||||
}
|
||||
$recordId = (int) $record->id;
|
||||
$affected = DiceRewardConfigRecord::where('id', $recordId)
|
||||
->where('status', DiceRewardConfigRecord::STATUS_RUNNING)
|
||||
->update(['status' => DiceRewardConfigRecord::STATUS_EXECUTING]);
|
||||
if ($affected !== 1) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
(new WeightTestRunner())->run($recordId);
|
||||
} catch (\Throwable $e) {
|
||||
// WeightTestRunner 内部会更新 status=-1 和 remark
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
return [
|
||||
// 登录成功返回的连接地址前缀,如 https://127.0.0.1:6777
|
||||
'login_url_base' => env('API_LOGIN_URL_BASE', 'https://127.0.0.1:6777'),
|
||||
// 游戏地址,用于 /api/v1/getGameUrl 返回拼接 token
|
||||
'game_url' => env('GAME_URL', 'dice-game.yuliao666.top'),
|
||||
// 按 username 存储的登录会话 Redis key 前缀,用于 token 中间件校验
|
||||
'session_username_prefix' => env('API_SESSION_USERNAME_PREFIX', 'api:user:session:'),
|
||||
// 登录会话过期时间(秒),默认 7 天
|
||||
@@ -17,6 +19,8 @@ return [
|
||||
'auth_token_exp' => (int) env('API_AUTH_TOKEN_EXP', 86400),
|
||||
// auth-token 按设备存储的 Redis key 前缀(同一设备只保留最新一个 auth-token)
|
||||
'auth_token_device_prefix' => env('API_AUTH_TOKEN_DEVICE_PREFIX', 'api:auth_token:'),
|
||||
// auth-token 按 token 存储的 Redis key 前缀(用于校验 auth-token 请求头)
|
||||
'auth_token_prefix' => env('API_AUTH_TOKEN_PREFIX', 'api:auth_token:t:'),
|
||||
// user-token 有效期(秒),默认 7 天
|
||||
'user_token_exp' => (int) env('API_USER_TOKEN_EXP', 604800),
|
||||
// 按用户存储当前有效 user-token 的 Redis key 前缀(同一用户仅保留最新一次登录的 token)
|
||||
|
||||
@@ -35,6 +35,11 @@ return [
|
||||
'publicPath' => public_path()
|
||||
]
|
||||
],
|
||||
// 一键测试权重:定时轮询 status=0 的测试记录并执行,不占用 HTTP 资源
|
||||
'weight_test' => [
|
||||
'handler' => app\process\WeightTestProcess::class,
|
||||
'count' => 1,
|
||||
],
|
||||
// File update detection and automatic reload
|
||||
'monitor' => [
|
||||
'handler' => app\process\Monitor::class,
|
||||
|
||||
@@ -14,6 +14,24 @@
|
||||
|
||||
use Webman\Route;
|
||||
use app\api\middleware\TokenMiddleware;
|
||||
use app\api\middleware\AuthTokenMiddleware;
|
||||
|
||||
// 平台鉴权接口:/api/v1/authToken,请求头 signature/secret/time/agent_id,返回 authtToken
|
||||
Route::group('/api/v1', function () {
|
||||
Route::any('/authToken', [app\api\controller\v1\AuthTokenController::class, 'index']);
|
||||
})->middleware([]);
|
||||
|
||||
// 平台 v1 接口:需在请求头携带 auth-token
|
||||
Route::group('/api/v1', function () {
|
||||
Route::any('/getGameUrl', [app\api\controller\v1\GameController::class, 'getGameUrl']);
|
||||
Route::any('/getPlayerInfo', [app\api\controller\v1\GameController::class, 'getPlayerInfo']);
|
||||
Route::any('/getPlayerGameRecord', [app\api\controller\v1\GameController::class, 'getPlayerGameRecord']);
|
||||
Route::any('/getPlayerWalletRecord', [app\api\controller\v1\GameController::class, 'getPlayerWalletRecord']);
|
||||
Route::any('/getPlayerTicketRecord', [app\api\controller\v1\GameController::class, 'getPlayerTicketRecord']);
|
||||
Route::any('/setPlayerWallet', [app\api\controller\v1\GameController::class, 'setPlayerWallet']);
|
||||
})->middleware([
|
||||
AuthTokenMiddleware::class,
|
||||
]);
|
||||
|
||||
// 登录接口:无需 token,提交 JSON 获取带 token 的连接地址
|
||||
Route::group('/api', function () {
|
||||
|
||||
21
server/docs/DICE_REWARD_CONFIG_START_INDEX_IMPACT.md
Normal file
21
server/docs/DICE_REWARD_CONFIG_START_INDEX_IMPACT.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# 移除 DiceRewardConfig 表 s_start_index / n_start_index 的说明(已处理)
|
||||
|
||||
**`s_start_index`**(顺时针起始索引)、**`n_start_index`**(逆时针起始索引)已从业务与表单中移除,起始索引统一使用 **dice_reward.start_index**。
|
||||
|
||||
## 1. 当前状态(移除后无影响)
|
||||
|
||||
| 位置 | 处理情况 |
|
||||
|------|----------|
|
||||
| **PlayStartLogic** | 已使用 **DiceReward** 的 `start_index`,不读 config,无影响 |
|
||||
| **DiceRewardLogic::getListWithConfig** | 已去掉对 config 的 join 与回填,仅使用 `r.start_index` |
|
||||
| **DiceRewardConfigValidate** | 已从规则与 save/update 场景中删除这两项 |
|
||||
| **奖励配置编辑弹窗** | 已移除「顺时针/逆时针起始索引」表单项及提交字段 |
|
||||
| **DiceRewardConfig 模型** | 已从属性注释中删除 |
|
||||
|
||||
## 2. 数据库表结构
|
||||
|
||||
若表中仍有这两列,可执行:
|
||||
|
||||
- `server/db/dice_reward_config_drop_start_index.sql`:删除 `s_start_index`、`n_start_index` 列。
|
||||
|
||||
执行前请确认已通过「创建奖励对照」生成 dice_reward 数据,且 `dice_reward.start_index` 已正确写入。
|
||||
286
server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md
Normal file
286
server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md
Normal file
@@ -0,0 +1,286 @@
|
||||
# Game Performance & QPS Analysis (Dice Project)
|
||||
|
||||
> This document describes the current dice game backend architecture, key endpoints, approximate QPS capacity, and concrete optimization suggestions.
|
||||
> It is written in plain ASCII to avoid any encoding or garbled-text issues.
|
||||
|
||||
---
|
||||
|
||||
## 1. Runtime Environment Overview
|
||||
|
||||
| Item | Description |
|
||||
|-----------------|-----------------------------------------------------------------------------|
|
||||
| Framework | Webman (on top of Workerman, long-running PHP workers) |
|
||||
| Business module | `app/dice` (players, play records, rewards, lottery pool, dashboard, etc.) |
|
||||
| HTTP endpoint | Typically `http://0.0.0.0:6688` |
|
||||
| Worker count | Recommended: `cpu_count() * 4` (for example, 8 cores -> 32 workers) |
|
||||
| Database | MySQL + ThinkORM, with connection pool (for example, max=20 / min=2) |
|
||||
| Cache | Redis + think-cache, with connection pool (for example, max=20 / min=2) |
|
||||
|
||||
Recommended production configuration:
|
||||
|
||||
- Use Redis as default cache: in `.env`, set `CACHE_MODE=redis`.
|
||||
- Align `DB_POOL_MAX` / `REDIS_POOL_MAX` with worker count and MySQL `max_connections`.
|
||||
|
||||
---
|
||||
|
||||
## 2. Key Endpoints and Load Characteristics
|
||||
|
||||
From the codebase, main game-related endpoints can be roughly grouped into:
|
||||
|
||||
- High-load: multiple DB writes plus Redis and non-trivial business logic.
|
||||
- Medium-load: some DB writes or heavier DB reads.
|
||||
- Light: mostly cache reads or simple DB queries.
|
||||
|
||||
### 2.1 Main endpoints (current project)
|
||||
|
||||
Below is a simplified view; exact routes live in the dice module and API controllers:
|
||||
|
||||
| Endpoint | Purpose | Load level | Notes / risks |
|
||||
|-------------------------------------|--------------------------|------------|----------------------------------------------------------|
|
||||
| `POST /api/game/playStart` | Start a play / roll | High | Multiple DB + Redis ops, main QPS bottleneck |
|
||||
| `POST /api/game/buyLotteryTickets` | Buy tickets / chances | Med-High | Multiple table writes, wallet and ticket records |
|
||||
| `GET /api/game/config` | Game config for frontend | Medium | Depends on `DiceConfig` and cache |
|
||||
| `GET /api/game/lotteryPool` | Lottery / reward config | Medium | Depends on `DiceLotteryPoolConfig` / `DiceRewardConfig` |
|
||||
| `POST /api/v1/getGameUrl` | Get game URL / entry | Medium | JWT + Redis auth; light DB usage |
|
||||
| `POST /api/v1/getPlayerInfo` | Get player info | Medium | Needs index on `dice_player.username` |
|
||||
| `POST /api/v1/getPlayerGameRecord` | Player history records | Med-High | Risk of N+1 if not using batch/with |
|
||||
| `POST /api/v1/setPlayerWallet` | Adjust wallet balance | Medium | Wallet + records, must be concurrency-safe |
|
||||
|
||||
For QPS capacity analysis, focus on:
|
||||
|
||||
- `playStart` (core hot path).
|
||||
- Ticket, wallet, record-related endpoints.
|
||||
|
||||
---
|
||||
|
||||
## 3. `playStart` Call Flow and Resource Usage
|
||||
|
||||
The exact implementation is in the dice game logic layer and related services. A typical call flow looks like the following.
|
||||
|
||||
### 3.1 DB access (typical)
|
||||
|
||||
1. Load player:
|
||||
- `DicePlayer::find($playerId)`
|
||||
- Should be done once per request and reused.
|
||||
|
||||
2. Load reward EV / minimum real EV:
|
||||
- `DiceRewardConfig::getCachedMinRealEv()`
|
||||
- First call hits DB and writes Redis; later calls hit Redis only.
|
||||
|
||||
3. Get or create lottery pool:
|
||||
- `LotteryService::getOrCreate()`
|
||||
- Reads from Redis; if missing, reads from DB (for example, `DiceLotteryPoolConfig::where('name','default/killScore')->find()`).
|
||||
|
||||
4. Load concrete pool config for this play:
|
||||
- `DiceLotteryPoolConfig::find($configId)`
|
||||
|
||||
5. Persist this play and its side effects (within one or several transactions):
|
||||
- `DicePlayRecord::create()` (play record)
|
||||
- `DicePlayer::save()` (balance and state)
|
||||
- `DicePlayerTicketRecord::create()` (ticket usage)
|
||||
- `DiceLotteryPoolConfig::where('id')->update(['ev' => Db::raw(...)]` (EV statistics)
|
||||
- `DicePlayerWalletRecord::create()` (wallet history)
|
||||
|
||||
6. Refresh player cache:
|
||||
- Reuse or reload player and call `UserCache::setUser($player)`.
|
||||
|
||||
Rough DB count (assuming good caching and no redundant `find` calls):
|
||||
|
||||
- About 3-6 DB queries/updates per `playStart`.
|
||||
- About 3-6 Redis operations per `playStart`.
|
||||
|
||||
If the code calls `DicePlayer::find($playerId)` multiple times in one request, DB usage and latency will increase accordingly.
|
||||
|
||||
### 3.2 Redis access
|
||||
|
||||
Typical Redis usages in the current design:
|
||||
|
||||
- Reward / pool configs: `DiceRewardConfig::getCachedInstance()`, `getCachedByTier()`, `LotteryService::getOrCreate()`.
|
||||
- Player cache: `UserCache::getUser()`, `UserCache::setUser()`.
|
||||
- Optional counters: EV / statistics counters can be done via Redis `INCRBY`, etc.
|
||||
|
||||
Goal: hot paths should hit Redis most of the time, and DB should primarily be for persistence and cold reads.
|
||||
|
||||
---
|
||||
|
||||
## 4. Main Bottlenecks and Optimizations
|
||||
|
||||
### 4.1 DB connections and slow SQL
|
||||
|
||||
1. Connection pool sizing:
|
||||
- With 32 workers and `DB_POOL_MAX=20`, connection exhaustion and waiting are likely at higher QPS.
|
||||
- Recommendation: set `DB_POOL_MAX` to something like 32-64 (depending on CPU and MySQL `max_connections`), and check that MySQL allows enough connections.
|
||||
|
||||
2. Avoid redundant queries:
|
||||
- In `playStart`, ensure player is loaded once and reused (do not call `DicePlayer::find` multiple times per request).
|
||||
|
||||
3. EV update strategy:
|
||||
- Repeated `UPDATE dice_lottery_pool_config SET ev = ev - ?` on a hot row causes lock contention.
|
||||
- Better:
|
||||
- Accumulate EV deltas in Redis (per pool or per shard).
|
||||
- Periodic cron job to aggregate Redis deltas back into MySQL in batches.
|
||||
|
||||
4. Index coverage:
|
||||
- Ensure all high-frequency queries (`username`, `player_id`, `create_time`, status fields) use proper indexes (see section 6).
|
||||
|
||||
### 4.2 Cache and serialization overhead
|
||||
|
||||
1. Use Redis cache driver:
|
||||
- In `.env`, set `CACHE_MODE=redis`.
|
||||
- In `config/cache.php`, the default store should be Redis in production.
|
||||
|
||||
2. Player cache encryption:
|
||||
- If `UserCache` encrypts/decrypts data (for example, AES), CPU cost can be high at large QPS.
|
||||
- Possible mitigations:
|
||||
- Keep cached value small (only necessary fields).
|
||||
- Limit how often `setUser` is called (only on actual state changes).
|
||||
- Avoid double-encryption or repeated heavy serialization in hot paths.
|
||||
|
||||
### 4.3 N+1 queries
|
||||
|
||||
Endpoints like "get player game record" or wallet histories can easily trigger N+1 patterns:
|
||||
|
||||
- Use `whereIn('player_id', $playerIds)` instead of one query per player.
|
||||
- Use eager loading (`with(['dicePlayer'])`) for related player info.
|
||||
- Keep page size (`limit`) moderate (for example, 100 rows or less per page).
|
||||
|
||||
### 4.4 Redis vs DB coordination
|
||||
|
||||
- Ensure worker count, DB pool and Redis pool are balanced:
|
||||
- If CPU is not saturated but DB or Redis is fully blocked, it is a typical sign of misconfiguration.
|
||||
- Monitor Redis:
|
||||
- Use slowlog for heavy commands.
|
||||
- Watch for large keys or hot keys; consider hash or sharding if needed.
|
||||
|
||||
---
|
||||
|
||||
## 5. Approximate QPS Capacity (Single Node)
|
||||
|
||||
These are ballpark figures for a single node with something like 8 cores and 32 workers, with MySQL and Redis in the same LAN and the optimizations above applied. Real numbers must come from your own load tests.
|
||||
|
||||
### 5.1 Per-endpoint estimates
|
||||
|
||||
- `playStart`:
|
||||
- Typical latency: about 50-150 ms.
|
||||
- Expected QPS: about 200-300 per node.
|
||||
|
||||
- `buyLotteryTickets`:
|
||||
- Typical latency: about 20-60 ms.
|
||||
- Expected QPS: about 500-1000+ per node.
|
||||
|
||||
- `getGameUrl` / login-style endpoints:
|
||||
- Typical latency: about 30-80 ms.
|
||||
- Expected QPS: about 400-800 per node.
|
||||
|
||||
### 5.2 Mixed traffic scenario
|
||||
|
||||
Example traffic mix:
|
||||
|
||||
- 70% `playStart`
|
||||
- 30% lighter endpoints (`getGameUrl`, `getPlayerInfo`, and similar)
|
||||
|
||||
Under such a mix, with reasonable indexing and caching:
|
||||
|
||||
- A single 8-core node can typically sustain about 250-400 QPS overall.
|
||||
- To go significantly beyond that, you will normally use horizontal scaling (multiple app nodes) plus DB/Redis scaling (read replicas, sharding, and so on).
|
||||
|
||||
---
|
||||
|
||||
## 6. Index and Table Design Recommendations
|
||||
|
||||
### 6.1 Must-have indexes
|
||||
|
||||
| Table | Index | Purpose |
|
||||
|-----------------------------|-----------------------------------|------------------------------------------|
|
||||
| `dice_player` | unique(`username`) | Fast lookup by username (login, API) |
|
||||
| `dice_play_record` | index(`player_id`, `create_time`) | Player record listing plus time sorting |
|
||||
| `dice_player_wallet_record` | index(`player_id`, `create_time`) | Wallet history listing |
|
||||
| `dice_player_ticket_record` | index(`player_id`, `create_time`) | Ticket history listing |
|
||||
|
||||
Example SQL:
|
||||
|
||||
```sql
|
||||
ALTER TABLE dice_player ADD UNIQUE INDEX uk_username (username);
|
||||
ALTER TABLE dice_play_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
ALTER TABLE dice_player_wallet_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
ALTER TABLE dice_player_ticket_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
```
|
||||
|
||||
### 6.2 Large-table strategy
|
||||
|
||||
For very large history tables (play records, wallet logs, ticket logs), plan ahead:
|
||||
|
||||
- Partitioning or sharding (by time or by player ID).
|
||||
- Archival strategy (move very old data to cold storage or delete).
|
||||
|
||||
---
|
||||
|
||||
## 7. Load Testing and Metrics
|
||||
|
||||
### 7.1 Load testing `playStart`
|
||||
|
||||
1. Prepare:
|
||||
- Seed enough test players and balances.
|
||||
- Obtain valid JWT tokens.
|
||||
|
||||
2. `ab` example:
|
||||
|
||||
```bash
|
||||
ab -n 2000 -c 32 \
|
||||
-p post_body.json \
|
||||
-T application/json \
|
||||
-H "token: YOUR_JWT" \
|
||||
http://127.0.0.1:6688/api/game/playStart
|
||||
```
|
||||
|
||||
3. `wrk` example:
|
||||
|
||||
```bash
|
||||
wrk -t4 -c32 -d60s -s play_start.lua http://127.0.0.1:6688/api/game/playStart
|
||||
```
|
||||
|
||||
4. Focus on:
|
||||
- QPS (Requests per second)
|
||||
- P95 / P99 latency
|
||||
- Error rates (HTTP 5xx, timeouts, business failures)
|
||||
- MySQL / Redis CPU and connection usage
|
||||
|
||||
### 7.2 Typical troubleshooting
|
||||
|
||||
- Low QPS but low CPU:
|
||||
- Likely DB or Redis connection pool exhaustion or slow queries.
|
||||
- High P99 spikes:
|
||||
- Check for large transactions, schema changes, backup jobs, GC, or disk I/O hiccups.
|
||||
- Redis issues:
|
||||
- Look for big keys, blocking commands (for example, `KEYS`), or high single-key contention.
|
||||
|
||||
---
|
||||
|
||||
## 8. Configuration and Code Checklist
|
||||
|
||||
Use this list before load tests or production deployments.
|
||||
|
||||
### 8.1 Configuration
|
||||
|
||||
- `.env`:
|
||||
- [ ] `CACHE_MODE=redis`
|
||||
- [ ] `DB_POOL_MAX` / `DB_POOL_MIN` tuned for CPU and MySQL `max_connections`
|
||||
- [ ] `REDIS_POOL_MAX` large enough for concurrent traffic
|
||||
- MySQL:
|
||||
- [ ] `max_connections` greater than or equal to the sum of all app DB pools
|
||||
- [ ] Slow query log enabled with a reasonable threshold
|
||||
|
||||
### 8.2 Code
|
||||
|
||||
- [ ] `playStart` loads player once and reuses it everywhere.
|
||||
- [ ] Reward and pool configuration is always accessed via cache; after changes, cache is refreshed.
|
||||
- [ ] History and wallet endpoints avoid N+1; use batch queries and eager loading.
|
||||
- [ ] EV and other hot counters use Redis aggregation instead of per-request `UPDATE` on hot rows.
|
||||
|
||||
---
|
||||
|
||||
## 9. Summary
|
||||
|
||||
- For the current dice project, `playStart` and related lottery, wallet, and ticket flows define the backend QPS ceiling.
|
||||
- With proper connection pool tuning, Redis caching, indexing, and fewer redundant DB operations, a single 8-core node can typically handle a few hundred QPS of mixed traffic.
|
||||
- Real capacity must be validated via `ab`, `wrk`, or `k6` load tests against your environment; this document serves as a practical guide for identifying and fixing performance bottlenecks.
|
||||
293
server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md
Normal file
293
server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md
Normal file
@@ -0,0 +1,293 @@
|
||||
# 游戏性能与 QPS 分析(Dice 项目)
|
||||
|
||||
> 本文基于当前骰子游戏(dice)项目的实际代码结构,对后端接口的性能瓶颈、QPS 能力和优化方向做说明,便于后续压测、扩容和排查问题。
|
||||
|
||||
---
|
||||
|
||||
## 1. 运行环境与架构概览
|
||||
|
||||
| 项目 | 说明 |
|
||||
|----------------|----------------------------------------------------------------------|
|
||||
| 应用框架 | Webman(基于 Workerman 的常驻内存 PHP 框架) |
|
||||
| 业务模块 | `app/dice`(玩家、抽奖记录、奖励配置、奖池配置、看板等) |
|
||||
| HTTP 监听地址 | 通常为 `http://0.0.0.0:6688` |
|
||||
| Worker 数量 | 推荐:`cpu_count() * 4`(例如 8 核 CPU → 32 个 Worker 进程) |
|
||||
| 数据库 | MySQL + ThinkORM,使用连接池(例如 max=20 / min=2) |
|
||||
| 缓存 | Redis + think-cache,使用连接池(例如 max=20 / min=2) |
|
||||
|
||||
**生产环境配置建议:**
|
||||
|
||||
- 在 `.env` 中统一使用 Redis 作为默认缓存:`CACHE_MODE=redis`
|
||||
- 调整 `DB_POOL_MAX` / `REDIS_POOL_MAX`,使其与 Worker 数量和 MySQL `max_connections` 匹配
|
||||
|
||||
---
|
||||
|
||||
## 2. 核心接口与负载特征
|
||||
|
||||
从当前项目代码来看,游戏相关接口大致可以分为三类:
|
||||
|
||||
- **高负载型**:强依赖 DB + Redis,多次写入或复杂逻辑(QPS 瓶颈主要在这里)
|
||||
- **中负载型**:部分写 DB 或复杂读 DB
|
||||
- **轻量型**:读缓存或简单 DB 查询
|
||||
|
||||
### 2.1 主要接口梳理
|
||||
|
||||
| 接口 | 用途 | 负载级别 | 说明 / 风险点 |
|
||||
|-------------------------------------|--------------------|----------|--------------------------------------------------------|
|
||||
| `POST /api/game/playStart` | 开始一局游戏 / 抽奖 | 高 | 多次 DB + Redis 操作,是整体 QPS 的核心瓶颈 |
|
||||
| `POST /api/game/buyLotteryTickets` | 购买门票 / 次数 | 中-高 | 多表写入:门票记录、钱包记录等 |
|
||||
| `GET /api/game/config` | 获取游戏配置 | 中 | 依赖 `DiceConfig`,若无缓存会有全表扫描风险 |
|
||||
| `GET /api/game/lotteryPool` | 获取奖池 / 奖励配置 | 中 | 依赖 `DiceLotteryPoolConfig` / `DiceRewardConfig` |
|
||||
| `POST /api/v1/getGameUrl` | 获取游戏 URL | 中 | JWT + Redis 鉴权,DB 较少,Redis 压力较大 |
|
||||
| `POST /api/v1/getPlayerInfo` | 获取玩家信息 | 中 | 需要 `dice_player.username` 索引,否则易产生慢查询 |
|
||||
| `POST /api/v1/getPlayerGameRecord` | 获取玩家历史记录 | 中-高 | 若未优化,容易出现 N+1 查询问题 |
|
||||
| `POST /api/v1/setPlayerWallet` | 调整玩家钱包余额 | 中 | 涉及余额变更与流水写入,需处理好并发与幂等 |
|
||||
|
||||
在进行 QPS 能力评估或性能优化时,优先关注:
|
||||
|
||||
- `playStart` 接口;
|
||||
- 门票 / 钱包 / 流水相关接口。
|
||||
|
||||
---
|
||||
|
||||
## 3. `playStart` 调用链与资源消耗
|
||||
|
||||
以下是典型的一次 `playStart` 请求在后端的大致流程(抽象描述):
|
||||
|
||||
### 3.1 数据库访问路径(典型情况)
|
||||
|
||||
1. **加载玩家信息**
|
||||
- 调用 `DicePlayer::find($playerId)`
|
||||
- 建议:每个请求只查询一次,并在后续逻辑中复用该对象。
|
||||
|
||||
2. **加载奖励 EV / 最小实际 EV**
|
||||
- 调用 `DiceRewardConfig::getCachedMinRealEv()`
|
||||
- 首次会访问 DB 并写入 Redis;后续命中 Redis 即可。
|
||||
|
||||
3. **获取或创建奖池(LotteryService)**
|
||||
- 调用 `LotteryService::getOrCreate()`:
|
||||
- 优先从 Redis 中读取奖池信息;
|
||||
- 若缓存不存在,则从 DB 中加载:如 `DiceLotteryPoolConfig::where('name','default/killScore')->find()`。
|
||||
|
||||
4. **根据本次玩法加载奖池配置**
|
||||
- 调用 `DiceLotteryPoolConfig::find($configId)`。
|
||||
|
||||
5. **核心业务落库(可能在事务中执行)**
|
||||
- `DicePlayRecord::create()`:写入本次抽奖记录;
|
||||
- `DicePlayer::save()`:更新玩家余额、状态等;
|
||||
- `DicePlayerTicketRecord::create()`:写入门票/次数流水;
|
||||
- `DiceLotteryPoolConfig::where('id')->update(['ev' => Db::raw(...)]`:更新 EV 统计;
|
||||
- `DicePlayerWalletRecord::create()`:写入钱包流水。
|
||||
|
||||
6. **刷新玩家缓存**
|
||||
- 再次使用(或重新加载)玩家信息,调用 `UserCache::setUser($player)` 同步到 Redis。
|
||||
|
||||
**DB / Redis 调用次数粗略估算:**
|
||||
|
||||
- 在写法合理、缓存命中良好的情况下,每次 `playStart` 大致会产生:
|
||||
- 3 ~ 6 次 DB 访问(读 + 写);
|
||||
- 3 ~ 6 次 Redis 操作。
|
||||
- 若在同一请求中多次重复调用 `DicePlayer::find($playerId)`,DB 调用次数和耗时都会显著上升。
|
||||
|
||||
### 3.2 Redis 使用路径
|
||||
|
||||
在当前设计中,Redis 主要用于:
|
||||
|
||||
- 奖励 / 奖池配置缓存:`DiceRewardConfig::getCachedInstance()`、`getCachedByTier()`、`LotteryService::getOrCreate()` 等;
|
||||
- 玩家缓存:`UserCache::getUser()`、`UserCache::setUser()`;
|
||||
- 统计计数:可以使用 Redis `INCRBY` 等命令维护 EV 或其他统计数据。
|
||||
|
||||
**目标:** 热路径尽量命中 Redis,DB 主要负责落库和冷数据读取。
|
||||
|
||||
---
|
||||
|
||||
## 4. 性能瓶颈与优化方向
|
||||
|
||||
### 4.1 数据库连接与 SQL
|
||||
|
||||
1. **连接池大小**
|
||||
- 在 32 个 Worker 且 `DB_POOL_MAX=20` 的情况下,高并发时容易出现连接耗尽和等待。
|
||||
- 建议:根据 CPU 核心数和目标 QPS,将 `DB_POOL_MAX` 调整到 **32 ~ 64** 左右,并保证 MySQL `max_connections` 足够大。
|
||||
|
||||
2. **避免重复查询**
|
||||
- 在 `playStart` 中,玩家信息应只查询一次:`$player = DicePlayer::find($playerId)`,后续逻辑统一使用 `$player`,避免重复 `find`。
|
||||
|
||||
3. **EV 更新策略**
|
||||
- 频繁在在线请求中执行 `UPDATE dice_lottery_pool_config SET ev = ev - ?`,会造成该行热点锁竞争;
|
||||
- 建议:
|
||||
- 在线请求仅将 EV 变动累加到 Redis 计数器;
|
||||
- 通过定时任务批量同步 Redis 中的统计数据回 MySQL。
|
||||
|
||||
4. **索引覆盖**
|
||||
- 高频查询条件(如 `username`、`player_id`、`create_time`、`status` 等)必须有合适索引(见第 6 节)。
|
||||
|
||||
### 4.2 缓存与序列化开销
|
||||
|
||||
1. **统一使用 Redis 缓存驱动**
|
||||
- `.env` 中设置:`CACHE_MODE=redis`;
|
||||
- `config/cache.php` 中,生产环境默认缓存驱动应为 Redis。
|
||||
|
||||
2. **UserCache 加解密成本**
|
||||
- 若 `UserCache` 中对玩家信息做 AES 加解密,在高 QPS 场景下会占用较多 CPU;
|
||||
- 可以:
|
||||
- 精简缓存字段,只缓存必要信息;
|
||||
- 控制 `setUser` 调用频率,避免无意义重复写入;
|
||||
- 评估哪些字段确实需要加密,非敏感字段可不加密。
|
||||
|
||||
### 4.3 N+1 查询问题
|
||||
|
||||
历史记录、钱包流水等接口非常容易出现 N+1 查询,例如:
|
||||
|
||||
- 循环按玩家逐条查询记录;
|
||||
- 循环对每条记录再单独查询玩家信息。
|
||||
|
||||
建议:
|
||||
|
||||
- 使用 `whereIn('player_id', $playerIds)` 做批量查询;
|
||||
- 使用 `with(['dicePlayer'])` 或 join 预加载关联的玩家信息;
|
||||
- 控制单页 `limit`,例如不超过 100 条。
|
||||
|
||||
### 4.4 Redis 与 DB 的整体协同
|
||||
|
||||
- Worker 数、DB 连接池、Redis 连接池三者要相互匹配:
|
||||
- 出现 CPU 未打满但 DB/Redis 已经“顶满”的情况,多半是配置不平衡。
|
||||
- 对 Redis 的监控要关注:
|
||||
- 慢日志(慢命令);
|
||||
- 大 Key 或热点 Key(必要时做拆分或分桶)。
|
||||
|
||||
---
|
||||
|
||||
## 5. 单机 QPS 能力(估算)
|
||||
|
||||
> 以下为在常见生产环境(如 8C32G 单机、MySQL/Redis 与应用在同一内网)且做好上述优化后的大致量级,仅用于评估和对比,实际仍需通过压测确认。
|
||||
|
||||
### 5.1 单接口预估
|
||||
|
||||
- `playStart`
|
||||
- 单次耗时:约 50 ~ 150 ms(受 DB/Redis 延迟和业务分支影响);
|
||||
- 单机 QPS:约 **200 ~ 300**。
|
||||
|
||||
- `buyLotteryTickets`
|
||||
- 单次耗时:约 20 ~ 60 ms;
|
||||
- 单机 QPS:约 **500 ~ 1000+**。
|
||||
|
||||
- `getGameUrl` / 登录类接口
|
||||
- 单次耗时:约 30 ~ 80 ms;
|
||||
- 单机 QPS:约 **400 ~ 800**。
|
||||
|
||||
### 5.2 混合业务场景
|
||||
|
||||
假设:
|
||||
|
||||
- 70% 请求是 `playStart`;
|
||||
- 30% 请求为 `getGameUrl`、`getPlayerInfo` 等轻 / 中量接口;
|
||||
|
||||
在 8 核 32 Worker、索引和缓存配置合理的前提下:
|
||||
|
||||
- 单机综合 QPS 约可达到 **250 ~ 400 QPS**;
|
||||
- 若需要显著更高的整体 QPS,应采用多节点水平扩展 + DB/Redis 扩容(读写分离、分库分表等)。
|
||||
|
||||
---
|
||||
|
||||
## 6. 索引与表结构建议
|
||||
|
||||
### 6.1 必备索引
|
||||
|
||||
| 表名 | 索引 | 用途说明 |
|
||||
|------------------------------|-----------------------------------|--------------------------------|
|
||||
| `dice_player` | 唯一索引 `unique(username)` | 通过用户名快速定位玩家 |
|
||||
| `dice_play_record` | 普通索引 `(player_id, create_time)` | 玩家历史记录分页 + 时间排序 |
|
||||
| `dice_player_wallet_record` | 普通索引 `(player_id, create_time)` | 钱包流水查询 |
|
||||
| `dice_player_ticket_record` | 普通索引 `(player_id, create_time)` | 门票流水查询 |
|
||||
|
||||
示例 SQL:
|
||||
|
||||
```sql
|
||||
ALTER TABLE dice_player ADD UNIQUE INDEX uk_username (username);
|
||||
ALTER TABLE dice_play_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
ALTER TABLE dice_player_wallet_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
ALTER TABLE dice_player_ticket_record ADD INDEX idx_player_create (player_id, create_time);
|
||||
```
|
||||
|
||||
### 6.2 大表策略
|
||||
|
||||
对于体量较大的历史表(抽奖记录、钱包流水、门票流水等),建议提前规划:
|
||||
|
||||
- 分区或分表策略(按时间或按玩家 ID);
|
||||
- 归档 / 删除过旧数据,例如只保留最近 N 个月的在线查询。
|
||||
|
||||
---
|
||||
|
||||
## 7. 压测步骤与指标观测
|
||||
|
||||
### 7.1 压测 `playStart`
|
||||
|
||||
1. 准备数据:
|
||||
- 预先创建足够多的测试玩家及初始余额;
|
||||
- 获取一批可用的 JWT token。
|
||||
|
||||
2. 使用 `ab` 压测示例:
|
||||
|
||||
```bash
|
||||
ab -n 2000 -c 32 \
|
||||
-p post_body.json \
|
||||
-T application/json \
|
||||
-H "token: YOUR_JWT" \
|
||||
http://127.0.0.1:6688/api/game/playStart
|
||||
```
|
||||
|
||||
3. 使用 `wrk` 压测示例:
|
||||
|
||||
```bash
|
||||
wrk -t4 -c32 -d60s -s play_start.lua http://127.0.0.1:6688/api/game/playStart
|
||||
```
|
||||
|
||||
4. 重点关注指标:
|
||||
- QPS(Requests per second);
|
||||
- P95 / P99 延迟;
|
||||
- 错误率(HTTP 5xx、超时、业务失败);
|
||||
- MySQL / Redis 的 CPU 使用率与连接数。
|
||||
|
||||
### 7.2 常见问题排查思路
|
||||
|
||||
1. **QPS 上不去,CPU 却不高**
|
||||
- 检查 DB / Redis 连接池是否经常“打满”;
|
||||
- 是否存在慢 SQL(全表扫描、缺索引);
|
||||
- 是否有外部依赖(如第三方接口)拖慢整体。
|
||||
|
||||
2. **P99 延迟偶尔飙高**
|
||||
- 查看是否有大事务 / 大批量更新与压测同时进行;
|
||||
- 观察磁盘 I/O 和 GC 情况;
|
||||
- 检查 Redis 是否有大 Key 或阻塞命令(如 `KEYS`)。
|
||||
|
||||
---
|
||||
|
||||
## 8. 配置与代码自查清单
|
||||
|
||||
> 建议在压测前和上线前都按此清单进行一次自查。
|
||||
|
||||
### 8.1 配置层面
|
||||
|
||||
- `.env`:
|
||||
- [ ] `CACHE_MODE=redis` 已开启;
|
||||
- [ ] `DB_POOL_MAX` / `DB_POOL_MIN` 已根据 CPU 与 MySQL `max_connections` 调整;
|
||||
- [ ] `REDIS_POOL_MAX` 能够支撑预期并发量。
|
||||
- MySQL:
|
||||
- [ ] `max_connections` 不小于所有应用实例 DB 连接池上限之和;
|
||||
- [ ] 已开启慢查询日志,并设置了合理阈值。
|
||||
|
||||
### 8.2 代码层面
|
||||
|
||||
- [ ] `playStart` 在一次请求中只加载一次玩家信息并全程复用;
|
||||
- [ ] 奖励/奖池配置统一通过缓存访问,修改后有刷新缓存逻辑(如 `refreshCache()`);
|
||||
- [ ] 历史记录、钱包流水接口避免 N+1 查询,使用批量查询或预加载;
|
||||
- [ ] EV 等高频统计字段不直接在在线请求中频繁 `UPDATE`,而是通过 Redis 聚合后批量回写。
|
||||
|
||||
---
|
||||
|
||||
## 9. 总结
|
||||
|
||||
1. 对于当前 dice 项目,`playStart` 以及与之相关的奖池、钱包、门票逻辑,是后端 QPS 能力的关键瓶颈所在。
|
||||
2. 通过合理配置 DB/Redis 连接池、充分利用缓存、补齐必要索引、减少重复查询和热点 UPDATE,可以大幅提升单机可承载的 QPS,并降低 P99 延迟。
|
||||
3. 真正的容量边界必须通过 `ab` / `wrk` / `k6` 等工具在接近真实数据和流量模型的情况下进行压测验证,本文档主要为定位瓶颈和指导优化提供一个工程实践层面的参考。
|
||||
|
||||
49
server/docs/PLAY_START_FLOW_COMPARISON.md
Normal file
49
server/docs/PLAY_START_FLOW_COMPARISON.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# 抽奖流程对比:当前实现 vs 预期流程
|
||||
|
||||
## 你描述的预期流程
|
||||
|
||||
1. **先判断中的是 T1–T5 中的哪个奖**
|
||||
→ 按彩金池/玩家权重抽档位 T1–T5。
|
||||
|
||||
2. **根据 (1) 中奖类型从 DiceRewardConfig 读取数据,再根据权重 weight 抽取点数 grid_number**
|
||||
→ 该档位下多条配置,按每条配置的 **weight** 抽一条,得到这条配置的 **grid_number**(以及 real_ev 等)。
|
||||
|
||||
3. **根据抽取的 grid_number 查找有无对应的 s_end_index(n_end_index)**
|
||||
→ 用上一步得到的 grid_number(及方向)去查「带该 grid_number 且带 s_end_index/n_end_index 的配置」是否存在。
|
||||
|
||||
4. **若有则输出 s_end_index(n_end_index)对应的点数和起始点数;中奖数据仍用步骤 2 抽到的 grid_number 对应配置**
|
||||
→ 输出:起始点、终点(s_end_index 或 n_end_index)、点数和 roll_number;中奖金额等用步骤 2 抽到的那条配置。
|
||||
|
||||
5. **判断是否中大奖**
|
||||
→ 若点数和为豹子组合 (5,10,15,20,25,30),其中 5 和 30 必中大奖,其余按 BIGWIN 的 weight 再判一次;中大奖则返回 BIGWIN 的 roll_array。
|
||||
|
||||
---
|
||||
|
||||
## 当前实现
|
||||
|
||||
| 步骤 | 预期 | 当前实现 | 是否一致 |
|
||||
|------|------|----------|----------|
|
||||
| 1 | 先抽 T1–T5 档位 | 按彩金池/玩家权重抽 T1–T5 | ✅ 一致 |
|
||||
| 2 | 按该档位配置的 **weight** 抽取 **grid_number**(即抽一条配置) | 该档位配置**等权随机**选一条 `chosen`,**没有用 weight**;且当前用的 **grid_number 来自后面的「路径」配置**,不是来自这条 chosen | ❌ 不一致:未按 weight 抽,grid_number 来源也不对 |
|
||||
| 3 | 根据 grid_number 查 s_end_index / n_end_index | 根据 **chosen.id** 查「s_end_index = chosen.id 或 n_end_index = chosen.id」的配置,得到若干 **startCandidates**(路径列表) | ❌ 不一致:是按「终点 id」查路径,不是按 grid_number 查 |
|
||||
| 4 | 若有则输出终点、点数和、起始点;中奖数据用步骤 2 的配置 | 从 startCandidates 里再**等权随机**一条 `startRecord`,用 **startRecord.id** 作起始、**startRecord.grid_number** 作点数和、**startRecord.s_end_index/n_end_index** 作终点;中奖数据(real_ev 等)用的是 **chosen** | ⚠️ 部分一致:终点、起始、点数和都有,但 grid_number 来自路径而不是「按 weight 抽出的那条配置」 |
|
||||
| 5 | 豹子点数 5,10,15,20,25,30;5/30 必中大奖;其余按 BIGWIN.weight 判 | 逻辑一致:5/30 必中大奖,其余用 BIGWIN 的 weight 判定 | ✅ 一致 |
|
||||
|
||||
### weight 是否实例化(入缓存)
|
||||
|
||||
- **BIGWIN**:缓存里有完整行,含 **weight**,`getCachedByTierAndGridNumber('BIGWIN', rollNumber)` 返回的配置里带 weight,已用于步骤 5。✅ 已实例化。
|
||||
- **T1–T5**:`getCachedByTier(tier)` 返回的每条配置也是完整行(含 weight),但当前代码**没有用这些 weight**,只用 `array_rand` 等权选一条。即:weight 已在缓存里,但**未参与抽奖**。⚠️ 已实例化但未使用。
|
||||
|
||||
---
|
||||
|
||||
## 结论与建议
|
||||
|
||||
- **不一致点**:
|
||||
- 步骤 2:应用「该档位下按 **weight** 抽一条配置」,用这条配置的 **grid_number**(和 real_ev 等);当前是等权抽一条且 grid_number 实际来自路径。
|
||||
- 步骤 3:应用「用步骤 2 得到的 **grid_number**(及方向)查是否有 s_end_index/n_end_index」;当前是用 chosen.id 查「以该 id 为终点的路径」。
|
||||
|
||||
- **建议**:
|
||||
- 改为「先按档位内 weight 抽一条配置」,以该条为**唯一**来源得到 grid_number、real_ev、以及 s_end_index/n_end_index(若表结构是一条配置同时带 grid_number 与 s_end_index/n_end_index)。
|
||||
- 若表结构是「奖励配置」与「路径配置」分离,则需在步骤 2 按 weight 抽到 grid_number 后,再按 **grid_number + 方向** 查路径表得到 s_end_index/n_end_index 与起始点;并保证只对「在该方向下有有效 s_end_index/n_end_index 的配置」做 weight 抽取。
|
||||
|
||||
若你确认表结构(是否同一张表、是否一条既有 grid_number 又有 s_end_index/n_end_index),我可以按上述思路给出具体修改方案(含要改的类/方法名和伪代码)。
|
||||
39
server/docs/README_WEIGHT_TEST.md
Normal file
39
server/docs/README_WEIGHT_TEST.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# 一键测试权重 - 数据库 SQL 操作说明
|
||||
|
||||
## 1. 新建表 dice_play_record_test
|
||||
|
||||
测试用游玩记录表,结构与 `dice_play_record` 完全一致,不关联真实玩家(`player_id` 填 0),用于写入模拟数据并可一键清空。
|
||||
|
||||
**执行脚本:** `dice_play_record_test.sql`
|
||||
|
||||
```sql
|
||||
-- 若表已存在可跳过;执行前请确认 dice_play_record 表已存在
|
||||
CREATE TABLE IF NOT EXISTS `dice_play_record_test` LIKE `dice_play_record`;
|
||||
```
|
||||
|
||||
## 2. 扩展表 dice_reward_config_record
|
||||
|
||||
为一键测试权重增加进度与结果字段:总次数、已完成次数、状态、备注、顺/逆时针次数、档位出现次数(档位概率)。
|
||||
|
||||
**执行脚本:** `dice_reward_config_record_add_test_progress.sql`
|
||||
|
||||
若某列已存在会报错,可跳过该条继续执行下一条。
|
||||
|
||||
- `total_play_count`:总模拟次数(s_count + n_count)
|
||||
- `over_play_count`:已完成次数,每完成 10 条写入 `dice_play_record_test` 后更新
|
||||
- `status`:-1 失败,0 进行中,1 成功
|
||||
- `remark`:失败时记录原因
|
||||
- `s_count`:顺时针模拟次数
|
||||
- `n_count`:逆时针模拟次数
|
||||
- `tier_counts`:档位出现次数 JSON(T1=>count),用于档位概率
|
||||
|
||||
原有字段 `result_counts` 已存在,用于点数出现次数(点数概率)。
|
||||
|
||||
## 3. 导入操作
|
||||
|
||||
`dice_reward_config_record` 的**导入**功能保持不变:可将测试记录的权重快照导入到 `DiceReward` 与 `DiceLotteryPoolConfig`,并刷新缓存。无需额外 SQL。
|
||||
|
||||
## 执行顺序建议
|
||||
|
||||
1. 先执行 `dice_play_record_test.sql` 创建测试表。
|
||||
2. 再执行 `dice_reward_config_record_add_test_progress.sql` 为测试记录表增加字段(逐条执行,已存在的列可忽略)。
|
||||
78
server/docs/ROLL_NUMBER_ANALYSIS.md
Normal file
78
server/docs/ROLL_NUMBER_ANALYSIS.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# 色子点数(5–30)抽中概率分析
|
||||
|
||||
## 一、当前流程(为何 5 和 30 容易出、部分点数可能摇不到)
|
||||
|
||||
点数 `rollNumber`(5–30)由**两步**决定,而不是在 5–30 里直接按权重抽一次:
|
||||
|
||||
1. **先抽档位**
|
||||
按池子/玩家权重抽 T1–T5 之一。
|
||||
|
||||
2. **再在该档位内按权重抽一条“奖励配置”**
|
||||
`$chosen = drawRewardByWeight(tierRewards)`,得到一条配置,记其主键为 `chosenId`。
|
||||
|
||||
3. **按 chosenId 取“路径候选”**
|
||||
- 顺时针:`startCandidates = getCachedBySEndIndex(chosenId)` → 所有 **s_end_index = chosenId** 的配置。
|
||||
- 逆时针:`startCandidates = getCachedByNEndIndex(chosenId)` → 所有 **n_end_index = chosenId** 的配置。
|
||||
|
||||
4. **在路径候选中再按权重抽一条**
|
||||
`$startRecord = drawRewardByWeight(startCandidates)`,最终 **rollNumber = $startRecord['grid_number']**。
|
||||
|
||||
因此:
|
||||
|
||||
- **本局能出现哪些点数,完全由“当前 chosenId 对应的路径组”决定。**
|
||||
- 只有**在 startCandidates 里出现的 grid_number** 才会被摇到;**不在该组里的点数本局根本不会参与抽取**,相当于被“跳过”。
|
||||
|
||||
## 二、为何 5 和 30 摇到的概率会很大
|
||||
|
||||
可能原因:
|
||||
|
||||
1. **路径数据里 5、30 占比高**
|
||||
对很多 `chosenId`,其 `s_end_index=chosenId`(或 n_end_index)的配置里,grid_number=5 和 30 的条数多、或 weight 设得大,其它点数少/权重小,所以在这组里一抽就经常是 5 或 30。
|
||||
|
||||
2. **被抽中的 chosenId 偏集中在“含 5、30 的路径组”**
|
||||
档位内按权重抽到的 `$chosen` 的 id,如果经常落在某几类 id 上,而这些 id 对应的路径组里又以 5、30 为主,整体就会表现为 5、30 出现很多。
|
||||
|
||||
3. **5、30 出现在很多路径组里**
|
||||
若 5、30 对应的配置的 `s_end_index`/`n_end_index` 覆盖了很多不同的 id(即出现在很多“路径组”里),而其它点数只出现在少数几个 id 的路径组里,那么 5、30 被抽到的机会自然更多。
|
||||
|
||||
## 三、为何有些点数“摇不到、像被跳过”
|
||||
|
||||
- 某点数 **grid_number = G** 本局能出,**仅当**:
|
||||
当前 `chosenId` 对应的路径组里,**存在至少一条配置的 grid_number = G**(且 weight>0 会参与权重抽)。
|
||||
- 若在**所有** `s_end_index = 某 id`(或 n_end_index)的路径组里,**都没有** grid_number=12 的配置,那么 12 就**永远不会**被摇到,即被“跳过”。
|
||||
- 若 12 只出现在“很少被选中的 chosenId”对应的路径组里(例如这些 id 在档位内权重很低),那 12 就会**很少**出现。
|
||||
|
||||
所以:**不是代码故意跳过某些点数,而是这些点数在当前数据下,没有进入“本局实际参与抽奖的那组路径”里。**
|
||||
5、30 摇得多 = 它们在这组路径里权重大或出现次数多;某些点数摇不到 = 它们没进这组路径或权重为 0。
|
||||
|
||||
## 四、建议的数据检查(在库里直接查)
|
||||
|
||||
在 `dice_reward_config` 表里可以做两类检查:
|
||||
|
||||
**1)每个点数是否至少能出现在某个路径组里(避免永远摇不到)**
|
||||
|
||||
- 顺时针:对每个 grid_number(5–30),是否存在至少一行 **s_end_index = 某个在 T1–T5 里出现过的 id**,且该行 weight > 0。
|
||||
(“在 T1–T5 里出现过的 id” = 作为某条 T1–T5 配置的主键 id。)
|
||||
- 逆时针:同上,把 `s_end_index` 换成 `n_end_index`。
|
||||
|
||||
若某点数在顺时针(或逆时针)下没有任何一条这样的行,则该点数在该方向下**永远不会**被摇到。
|
||||
|
||||
**2)各点数在“路径组内”的权重是否过于悬殊**
|
||||
|
||||
- 对常见的 chosenId(例如在 T1 里权重高的几条配置的 id),查:
|
||||
`SELECT grid_number, SUM(weight) FROM dice_reward_config WHERE s_end_index = ? AND tier IN ('T1','T2',...) GROUP BY grid_number`
|
||||
看 5、30 的权重和是否明显高于 6–29,导致在该路径组内一抽就经常是 5 或 30。
|
||||
|
||||
## 五、可选:打开调试日志看“本局路径组里有哪些点数”
|
||||
|
||||
在 `PlayStartLogic` 里,在 `$startRecord = drawRewardByWeight(...)` 之后可加一段**仅调试时启用**的日志,例如:
|
||||
|
||||
- 打出:`chosenId`、`direction`、本局路径组里出现的 **grid_number 列表**及每个 grid_number 的**权重和**(或条数)。
|
||||
这样可以看到:每次抽奖时“实际参与抽奖的点数集合”是哪些,5、30 在该组里的权重是否偏大,以及哪些点数从未出现在日志里(即被跳过)。
|
||||
|
||||
---
|
||||
|
||||
**结论**:
|
||||
- 5 和 30 摇到的概率大,是因为在“当前 chosenId 对应的路径组”里,它们权重高或出现次数多。
|
||||
- 某些点数摇不到,是因为它们没有出现在任何“本局会用到”的路径组里,或只出现在极少被选中的路径组里。
|
||||
要平衡概率,需要从**路径数据**入手:保证每个点数 5–30 至少出现在若干路径组中且 weight>0,并调低 5、30 在路径组内的权重或条数占比。
|
||||
@@ -63,7 +63,7 @@ class InstallController extends OpenController
|
||||
|
||||
clearstatcache();
|
||||
if (is_file($env)) {
|
||||
return $this->fail('管理后台已经安装!如需重新安装,请删除根目录env配置文件并重启');
|
||||
return $this->fail('admin already installed, to reinstall please delete env file and restart');
|
||||
}
|
||||
|
||||
$user = $request->post('username');
|
||||
@@ -82,13 +82,13 @@ class InstallController extends OpenController
|
||||
} catch (\Throwable $e) {
|
||||
$message = $e->getMessage();
|
||||
if (stripos($message, 'Access denied for user')) {
|
||||
return $this->fail('数据库用户名或密码错误');
|
||||
return $this->fail('database username or password is incorrect');
|
||||
}
|
||||
if (stripos($message, 'Connection refused')) {
|
||||
return $this->fail('Connection refused. 请确认数据库IP端口是否正确,数据库已经启动');
|
||||
return $this->fail('connection refused, please check database ip/port and ensure database is running');
|
||||
}
|
||||
if (stripos($message, 'timed out')) {
|
||||
return $this->fail('数据库连接超时,请确认数据库IP端口是否正确,安全组及防火墙已经放行端口');
|
||||
return $this->fail('database connection timeout, please check ip/port and firewall/security group rules');
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class InstallController extends OpenController
|
||||
$smt = $db->query("show tables like 'sa_system_menu';");
|
||||
$tables = $smt->fetchAll();
|
||||
if (count($tables) > 0) {
|
||||
return $this->fail('数据库已经安装,请勿重复安装');
|
||||
return $this->fail('database already installed, please do not install again');
|
||||
}
|
||||
|
||||
if ($dataType == 'demo') {
|
||||
@@ -108,7 +108,7 @@ class InstallController extends OpenController
|
||||
}
|
||||
|
||||
if (!is_file($sql_file)) {
|
||||
return $this->fail('数据库SQL文件不存在');
|
||||
return $this->fail('database SQL file not found');
|
||||
}
|
||||
|
||||
$sql_query = file_get_contents($sql_file);
|
||||
@@ -151,7 +151,7 @@ EOF;
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
return $this->success('安装成功');
|
||||
return $this->success('install success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ class LoginController extends BaseController
|
||||
if ($captchaEnabled) {
|
||||
$captcha = new Captcha();
|
||||
if (!$captcha->checkCaptcha($uuid, $code)) {
|
||||
return $this->fail('验证码错误');
|
||||
return $this->fail('captcha error');
|
||||
}
|
||||
}
|
||||
$logic = new SystemUserLogic();
|
||||
|
||||
@@ -37,14 +37,14 @@ class SystemController extends BaseController
|
||||
if ($adminInfo === null || !is_array($adminInfo) || !isset($adminInfo['id'])) {
|
||||
$token = getCurrentInfo();
|
||||
if (!is_array($token) || empty($token['id'])) {
|
||||
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
|
||||
return $this->fail('login expired or invalid, please login again', 401);
|
||||
}
|
||||
$adminInfo = UserInfoCache::getUserInfo($token['id']);
|
||||
if (empty($adminInfo) || !isset($adminInfo['id'])) {
|
||||
$adminInfo = UserInfoCache::setUserInfo($token['id']);
|
||||
}
|
||||
if (empty($adminInfo) || !isset($adminInfo['id'])) {
|
||||
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
|
||||
return $this->fail('login expired or invalid, please login again', 401);
|
||||
}
|
||||
$this->adminInfo = $adminInfo;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class SystemController extends BaseController
|
||||
public function menu(): Response
|
||||
{
|
||||
if (!$this->ensureAdminInfo()) {
|
||||
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
|
||||
return $this->fail('login expired or invalid, please login again', 401);
|
||||
}
|
||||
$data = UserMenuCache::getUserMenu($this->adminInfo['id']);
|
||||
return $this->success($data);
|
||||
@@ -151,7 +151,7 @@ class SystemController extends BaseController
|
||||
$config = Storage::getConfig('local');
|
||||
$logic = new SystemAttachmentLogic();
|
||||
$data = $logic->saveNetworkImage($url, $config);
|
||||
return $this->success($data, '操作成功');
|
||||
return $this->success($data, 'operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +228,7 @@ class SystemController extends BaseController
|
||||
UserInfoCache::clearUserInfo($this->adminId);
|
||||
UserAuthCache::clearUserAuth($this->adminId);
|
||||
UserMenuCache::clearUserMenu($this->adminId);
|
||||
return $this->success([], '清除缓存成功!');
|
||||
return $this->success([], 'clear cache success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,11 +78,11 @@ class DataBaseController extends BaseController
|
||||
if (!empty($ids)) {
|
||||
$result = $this->logic->delete($table, $ids);
|
||||
if (!$result) {
|
||||
return $this->fail('操作失败');
|
||||
return $this->fail('operation failed');
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ class DataBaseController extends BaseController
|
||||
if (!empty($ids)) {
|
||||
$result = $this->logic->recovery($table, $ids);
|
||||
if (!$result) {
|
||||
return $this->fail('操作失败');
|
||||
return $this->fail('operation failed');
|
||||
}
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class DataBaseController extends BaseController
|
||||
{
|
||||
$tables = $request->input('tables', []);
|
||||
$this->logic->optimizeTable($tables);
|
||||
return $this->success('优化成功');
|
||||
return $this->success('optimize success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +141,7 @@ class DataBaseController extends BaseController
|
||||
{
|
||||
$tables = $request->input('tables', []);
|
||||
$this->logic->fragmentTable($tables);
|
||||
return $this->success('清理成功');
|
||||
return $this->success('clean success');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,9 +57,9 @@ class SystemAttachmentController extends BaseController
|
||||
$data = $request->post();
|
||||
$result = $this->logic->edit($data['id'], ['origin_name' => $data['origin_name']]);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ class SystemAttachmentController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +94,13 @@ class SystemAttachmentController extends BaseController
|
||||
$category_id = $request->post('category_id', '');
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids) || empty($category_id)) {
|
||||
return $this->fail('参数错误,请检查参数');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
$result = $this->logic->move($category_id, $ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class SystemCategoryController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ class SystemCategoryController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ class SystemCategoryController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ class SystemCategoryController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ class SystemConfigController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ class SystemConfigController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ class SystemConfigController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +117,10 @@ class SystemConfigController extends BaseController
|
||||
$group_id = $request->post('group_id');
|
||||
$config = $request->post('config');
|
||||
if (empty($group_id) || empty($config)) {
|
||||
return $this->fail('参数错误');
|
||||
return $this->fail('Invalid parameters');
|
||||
}
|
||||
$this->logic->batchUpdate($group_id, $config);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ class SystemConfigGroupController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ class SystemConfigGroupController extends BaseController
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
ConfigCache::clearConfig($data['code']);
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ class SystemConfigGroupController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class SystemConfigGroupController extends BaseController
|
||||
{
|
||||
$email = $request->input('email', '');
|
||||
if (empty($email)) {
|
||||
return $this->fail('请输入邮箱');
|
||||
return $this->fail('please input email');
|
||||
}
|
||||
$subject = "测试邮件";
|
||||
$code = "9527";
|
||||
@@ -137,11 +137,11 @@ class SystemConfigGroupController extends BaseController
|
||||
$model->status = 'failure';
|
||||
$model->response = $result;
|
||||
$model->save();
|
||||
return $this->fail('发送失败,请查看日志');
|
||||
return $this->fail('send failed, please check logs');
|
||||
} else {
|
||||
$model->status = 'success';
|
||||
$model->save();
|
||||
return $this->success([], '发送成功');
|
||||
return $this->success([], 'send success');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$model->status = 'failure';
|
||||
|
||||
@@ -59,7 +59,7 @@ class SystemDeptController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ class SystemDeptController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +93,9 @@ class SystemDeptController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,13 +109,13 @@ class SystemDeptController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ class SystemDictDataController extends BaseController
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ class SystemDictDataController extends BaseController
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ class SystemDictDataController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ class SystemDictTypeController extends BaseController
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ class SystemDictTypeController extends BaseController
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@ class SystemDictTypeController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
DictCache::clear();
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ class SystemLogController extends BaseController
|
||||
$logic = new SystemLoginLogLogic();
|
||||
if (!empty($ids)) {
|
||||
$logic->destroy($ids);
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ class SystemLogController extends BaseController
|
||||
$logic = new SystemOperLogLogic();
|
||||
if (!empty($ids)) {
|
||||
$logic->destroy($ids);
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,13 @@ class SystemMailController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class SystemMenuController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ class SystemMenuController extends BaseController
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
UserMenuCache::clearMenuCache();
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ class SystemMenuController extends BaseController
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
UserMenuCache::clearMenuCache();
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +113,14 @@ class SystemMenuController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
UserMenuCache::clearMenuCache();
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class SystemPostController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ class SystemPostController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ class SystemPostController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ class SystemPostController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,10 +130,10 @@ class SystemPostController extends BaseController
|
||||
{
|
||||
$file = current($request->file());
|
||||
if (!$file || !$file->isValid()) {
|
||||
return $this->fail('未找到上传文件');
|
||||
return $this->fail('uploaded file not found');
|
||||
}
|
||||
$this->logic->import($file);
|
||||
return $this->success('导入成功');
|
||||
return $this->success('import success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,7 +66,7 @@ class SystemRoleController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ class SystemRoleController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ class SystemRoleController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ class SystemRoleController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class SystemRoleController extends BaseController
|
||||
$id = $request->post('id');
|
||||
$menu_ids = $request->post('menu_ids');
|
||||
$this->logic->saveMenuPermission($id, $menu_ids);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,11 +75,11 @@ class SystemServerController extends BaseController
|
||||
{
|
||||
$tag = $request->input('tag', '');
|
||||
if (empty($tag)) {
|
||||
return $this->fail('请选择要删除的缓存');
|
||||
return $this->fail('please select cache to delete');
|
||||
}
|
||||
Cache::tag($tag)->clear();
|
||||
Cache::delete($tag);
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class SystemUserController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,9 @@ class SystemUserController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ class SystemUserController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ class SystemUserController extends BaseController
|
||||
$ids = $request->input('ids', '');
|
||||
if (!empty($ids)) {
|
||||
$this->logic->destroy($ids);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class SystemUserController extends BaseController
|
||||
UserInfoCache::clearUserInfo($id);
|
||||
UserAuthCache::clearUserAuth($id);
|
||||
UserMenuCache::clearUserMenu($id);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,12 +148,12 @@ class SystemUserController extends BaseController
|
||||
$id = $request->post('id', '');
|
||||
$password = $request->post('password', '');
|
||||
if ($id == 1) {
|
||||
return $this->fail('超级管理员不允许重置密码');
|
||||
return $this->fail('super admin cannot reset password');
|
||||
}
|
||||
$data = ['password' => password_hash($password, PASSWORD_DEFAULT)];
|
||||
$this->logic->authEdit($id, $data);
|
||||
UserInfoCache::clearUserInfo($id);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ class SystemUserController extends BaseController
|
||||
$data = ['dashboard' => $dashboard];
|
||||
$this->logic->authEdit($id, $data);
|
||||
UserInfoCache::clearUserInfo($id);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,9 +187,9 @@ class SystemUserController extends BaseController
|
||||
$result = $this->logic->updateInfo($this->adminId, $data);
|
||||
if ($result) {
|
||||
UserInfoCache::clearUserInfo($this->adminId);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('操作失败');
|
||||
return $this->fail('operation failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +205,6 @@ class SystemUserController extends BaseController
|
||||
$newPassword = $request->input('newPassword');
|
||||
$this->logic->modifyPassword($this->adminId, $oldPassword, $newPassword);
|
||||
UserInfoCache::clearUserInfo($this->adminId);
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ class CrontabController extends BaseController
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ class CrontabController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,13 +95,13 @@ class CrontabController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ class CrontabController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$status = $request->input('status', 1);
|
||||
if (empty($id)) {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
$result = $this->logic->changeStatus($id, $status);
|
||||
if ($result) {
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('操作失败');
|
||||
return $this->fail('operation failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +137,9 @@ class CrontabController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$result = $this->logic->run($id);
|
||||
if ($result) {
|
||||
return $this->success('执行成功');
|
||||
return $this->success('execute success');
|
||||
} else {
|
||||
return $this->fail('执行失败');
|
||||
return $this->fail('execution failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +173,9 @@ class CrontabController extends BaseController
|
||||
if (!empty($ids)) {
|
||||
$logic = new CrontabLogLogic();
|
||||
$logic->destroy($ids);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
} else {
|
||||
return $this->fail('参数错误,请检查');
|
||||
return $this->fail('invalid parameters, please check');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class GenerateTablesController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ class GenerateTablesController extends BaseController
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ class GenerateTablesController extends BaseController
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class GenerateTablesController extends BaseController
|
||||
$names = $request->input('names', []);
|
||||
$source = $request->input('source', '');
|
||||
$this->logic->loadTable($names, $source);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ class GenerateTablesController extends BaseController
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$this->logic->sync($id);
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ class GenerateTablesController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$this->logic->generateFile($id);
|
||||
UserMenuCache::clearMenuCache();
|
||||
return $this->success('操作成功');
|
||||
return $this->success('operation success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ if (!function_exists('downloadFile')) {
|
||||
if (file_exists($base_dir . DIRECTORY_SEPARATOR . $file_name)) {
|
||||
return response()->download($base_dir . DIRECTORY_SEPARATOR . $file_name, urlencode($file_name));
|
||||
} else {
|
||||
throw new ApiException('模板不存在');
|
||||
throw new ApiException('Template not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ class DatabaseLogic extends BaseLogic
|
||||
$isDeleteTime = true;
|
||||
}
|
||||
if (!$isDeleteTime) {
|
||||
throw new ApiException('当前表不支持回收站功能');
|
||||
throw new ApiException('Current table does not support recycle bin');
|
||||
}
|
||||
// 查询软删除数据
|
||||
$request = request();
|
||||
|
||||
@@ -38,7 +38,7 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
{
|
||||
$category = SystemCategory::where('id', $category_id)->findOrEmpty();
|
||||
if ($category->isEmpty()) {
|
||||
throw new ApiException('目标分类不存在');
|
||||
throw new ApiException('Target category not found');
|
||||
}
|
||||
return $this->model->whereIn('id', $ids)->update(['category_id' => $category_id]);
|
||||
}
|
||||
@@ -54,11 +54,11 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
{
|
||||
$image_data = file_get_contents($url);
|
||||
if ($image_data === false) {
|
||||
throw new ApiException('获取文件资源失败');
|
||||
throw new ApiException('Failed to get file resource');
|
||||
}
|
||||
$image_resource = imagecreatefromstring($image_data);
|
||||
if (!$image_resource) {
|
||||
throw new ApiException('创建图片资源失败');
|
||||
throw new ApiException('Failed to create image resource');
|
||||
}
|
||||
$filename = basename($url);
|
||||
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
@@ -84,11 +84,11 @@ class SystemAttachmentLogic extends BaseLogic
|
||||
break;
|
||||
default:
|
||||
imagedestroy($image_resource);
|
||||
throw new ApiException('文件格式错误');
|
||||
throw new ApiException('Invalid file format');
|
||||
}
|
||||
imagedestroy($image_resource);
|
||||
if (!$result) {
|
||||
throw new ApiException('文件保存失败');
|
||||
throw new ApiException('Failed to save file');
|
||||
}
|
||||
|
||||
$hash = md5_file($save_path);
|
||||
|
||||
@@ -41,14 +41,14 @@ class SystemCategoryLogic extends BaseLogic
|
||||
{
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('上级分类和当前分类不能相同');
|
||||
throw new ApiException('Parent category cannot be the same as current');
|
||||
}
|
||||
if (in_array($id, explode(',', $data['level']))) {
|
||||
throw new ApiException('不能将上级分类设置为当前分类的子分类');
|
||||
throw new ApiException('Cannot set parent category as child of current');
|
||||
}
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model->save($data);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class SystemCategoryLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该部门下存在子分类,请先删除子分类');
|
||||
throw new ApiException('This category has sub-categories, please delete them first');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ class SystemConfigGroupLogic extends BaseLogic
|
||||
$id = $ids[0];
|
||||
$model = $this->model->where('id', $id)->findOrEmpty();
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('配置数据未找到');
|
||||
throw new ApiException('Config data not found');
|
||||
}
|
||||
if (in_array(intval($id), [1, 2, 3])) {
|
||||
throw new ApiException('系统默认分组,无法删除');
|
||||
throw new ApiException('System default group cannot be deleted');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
@@ -51,7 +51,7 @@ class SystemConfigGroupLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('删除数据异常,请检查');
|
||||
throw new ApiException('Delete data error, please check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class SystemConfigLogic extends BaseLogic
|
||||
{
|
||||
$group = SystemConfigGroup::find($group_id);
|
||||
if (!$group) {
|
||||
throw new ApiException('配置组未找到');
|
||||
throw new ApiException('Config group not found');
|
||||
}
|
||||
$saveData = [];
|
||||
foreach ($config as $key => $value) {
|
||||
|
||||
@@ -44,10 +44,10 @@ class SystemDeptLogic extends BaseLogic
|
||||
$oldLevel = $data['level'] . $id . ',';
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('上级部门和当前部门不能相同');
|
||||
throw new ApiException('Parent department cannot be the same as current department');
|
||||
}
|
||||
if (in_array($id, explode(',', $data['level']))) {
|
||||
throw new ApiException('不能将上级部门设置为当前部门的子部门');
|
||||
throw new ApiException('Cannot set parent department to a child of current department');
|
||||
}
|
||||
$newLevel = $data['level'] . $id . ',';
|
||||
$deptIds = $this->model->where('level', 'like', $oldLevel . '%')->column('id');
|
||||
@@ -65,11 +65,11 @@ class SystemDeptLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该部门下存在子部门,请先删除子部门');
|
||||
throw new ApiException('This department has sub-departments, please delete them first');
|
||||
} else {
|
||||
$count = SystemUser::where('dept_id', 'in', $ids)->count();
|
||||
if ($count > 0) {
|
||||
throw new ApiException('该部门下存在用户,请先删除或者转移用户');
|
||||
throw new ApiException('This department has users, please delete or transfer them first');
|
||||
}
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
@@ -117,7 +117,10 @@ class SystemDeptLogic extends BaseLogic
|
||||
public function accessDept(array $where = []): array
|
||||
{
|
||||
$query = $this->search($where);
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
// 超级管理员(id=1)可查看全部部门,普通管理员按部门权限过滤
|
||||
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
|
||||
$query->auth($this->adminInfo['deptList'] ?? []);
|
||||
}
|
||||
$query->field('id, id as value, name as label, parent_id');
|
||||
$query->order('sort', 'desc');
|
||||
$data = $this->getAll($query);
|
||||
|
||||
@@ -35,7 +35,7 @@ class SystemDictDataLogic extends BaseLogic
|
||||
{
|
||||
$type = SystemDictType::where('id', $data['type_id'])->findOrEmpty();
|
||||
if ($type->isEmpty()) {
|
||||
throw new ApiException('字典类型不存在');
|
||||
throw new ApiException('Dict type not found');
|
||||
}
|
||||
$data['code'] = $type->code;
|
||||
$model = $this->model->create($data);
|
||||
|
||||
@@ -32,7 +32,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->where('code', $data['code'])->findOrEmpty();
|
||||
if (!$model->isEmpty()) {
|
||||
throw new ApiException('该字典标识已存在');
|
||||
throw new ApiException('This dict code already exists');
|
||||
}
|
||||
return $this->model->save($data);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('修改数据异常,请检查');
|
||||
throw new ApiException('Update data error, please check');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class SystemDictTypeLogic extends BaseLogic
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ApiException('删除数据异常,请检查');
|
||||
throw new ApiException('Delete data error, please check');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SystemMenuLogic extends BaseLogic
|
||||
{
|
||||
$data = $this->handleData($data);
|
||||
if ($data['parent_id'] == $id) {
|
||||
throw new ApiException('不能设置父级为自身');
|
||||
throw new ApiException('Cannot set parent to self');
|
||||
}
|
||||
return $this->model->update($data, ['id' => $id]);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class SystemMenuLogic extends BaseLogic
|
||||
{
|
||||
$num = $this->model->where('parent_id', 'in', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('该菜单下存在子菜单,请先删除子菜单');
|
||||
throw new ApiException('This menu has sub-menus, please delete them first');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class SystemPostLogic extends BaseLogic
|
||||
}
|
||||
$this->saveAll($data);
|
||||
} catch (\Exception $e) {
|
||||
throw new ApiException('导入文件错误,请上传正确的文件格式xlsx');
|
||||
throw new ApiException('Import file error, please upload correct xlsx file');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
$data = $this->handleData($data);
|
||||
return $model->save($data);
|
||||
@@ -60,7 +60,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
|
||||
$num = SystemRole::where('level', '>=', $maxLevel)->whereIn('id', $ids)->count();
|
||||
if ($num > 0) {
|
||||
throw new ApiException('不能操作比当前账户职级高的角色');
|
||||
throw new ApiException('Cannot operate roles with higher level than current account');
|
||||
} else {
|
||||
return $this->model->destroy($ids);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class SystemRoleLogic extends BaseLogic
|
||||
$levelArr = array_column($this->adminInfo['roleList'], 'level');
|
||||
$maxLevel = max($levelArr);
|
||||
if ($data['level'] >= $maxLevel) {
|
||||
throw new ApiException('不能操作比当前账户职级高的角色');
|
||||
throw new ApiException('Cannot operate roles with higher level than current account');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,10 @@ class SystemUserLogic extends BaseLogic
|
||||
{
|
||||
$query = $this->search($where);
|
||||
$query->with(['depts']);
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
// 超级管理员(id=1)可查看全部用户,普通管理员按部门权限过滤
|
||||
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
|
||||
$query->auth($this->adminInfo['deptList'] ?? []);
|
||||
}
|
||||
return $this->getList($query);
|
||||
}
|
||||
|
||||
@@ -82,7 +85,7 @@ class SystemUserLogic extends BaseLogic
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
@@ -102,11 +105,11 @@ class SystemUserLogic extends BaseLogic
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
$user = SystemUser::create($data);
|
||||
@@ -132,21 +135,23 @@ class SystemUserLogic extends BaseLogic
|
||||
return $this->transaction(function () use ($data, $id) {
|
||||
$role_ids = $data['role_ids'] ?? [];
|
||||
$post_ids = $data['post_ids'] ?? [];
|
||||
// 仅可修改当前部门和子部门的用户
|
||||
// 超级管理员可修改任意用户,普通管理员仅可修改当前部门和子部门的用户
|
||||
$query = $this->model->where('id', $id);
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
|
||||
$query->auth($this->adminInfo['deptList'] ?? []);
|
||||
}
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
// 部门保护
|
||||
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
|
||||
throw new ApiException('没有权限操作该部门数据');
|
||||
throw new ApiException('No permission to operate department data');
|
||||
}
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
$result = parent::edit($id, $data);
|
||||
@@ -174,25 +179,28 @@ class SystemUserLogic extends BaseLogic
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
if (count($ids) > 1) {
|
||||
throw new ApiException('禁止批量删除操作');
|
||||
throw new ApiException('Batch delete is not allowed');
|
||||
}
|
||||
$ids = $ids[0];
|
||||
}
|
||||
if ($ids == 1) {
|
||||
throw new ApiException('超级管理员禁止删除');
|
||||
throw new ApiException('Super admin cannot be deleted');
|
||||
}
|
||||
$query = $this->model->where('id', $ids);
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
// 超级管理员可删除任意用户,普通管理员仅可删除当前部门和子部门的用户
|
||||
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
|
||||
$query->auth($this->adminInfo['deptList'] ?? []);
|
||||
}
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
if ($this->adminInfo['id'] > 1) {
|
||||
$role_ids = $user->roles->toArray() ?: [];
|
||||
if (!empty($role_ids)) {
|
||||
// 越权保护
|
||||
if (!$this->roleProtect($this->adminInfo['roleList'], array_column($role_ids, 'id'))) {
|
||||
throw new ApiException('没有权限操作该角色数据');
|
||||
throw new ApiException('No permission to operate role data');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +283,7 @@ class SystemUserLogic extends BaseLogic
|
||||
$model->password = password_hash($newPassword, PASSWORD_DEFAULT);
|
||||
return $model->save();
|
||||
} else {
|
||||
throw new ApiException('原密码错误');
|
||||
throw new ApiException('Old password is incorrect');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +298,7 @@ class SystemUserLogic extends BaseLogic
|
||||
$query->auth($this->adminInfo['deptList']);
|
||||
$user = $query->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new ApiException('没有权限操作该数据');
|
||||
throw new ApiException('No permission to operate this data');
|
||||
}
|
||||
}
|
||||
parent::edit($id, $data);
|
||||
|
||||
@@ -50,7 +50,7 @@ class CrontabLogic extends BaseLogic
|
||||
6 => "0 {$minute} {$hour} * * {$week}",
|
||||
7 => "0 {$minute} {$hour} {$day} * *",
|
||||
8 => "0 {$minute} {$hour} {$day} {$month} *",
|
||||
default => throw new ApiException("任务类型异常"),
|
||||
default => throw new ApiException('Invalid task type'),
|
||||
};
|
||||
|
||||
// 定时任务模型新增
|
||||
@@ -95,13 +95,13 @@ class CrontabLogic extends BaseLogic
|
||||
6 => "0 {$minute} {$hour} * * {$week}",
|
||||
7 => "0 {$minute} {$hour} {$day} * *",
|
||||
8 => "0 {$minute} {$hour} {$day} {$month} *",
|
||||
default => throw new ApiException("任务类型异常"),
|
||||
default => throw new ApiException('Invalid task type'),
|
||||
};
|
||||
|
||||
// 查询任务数据
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
|
||||
$result = $model->save([
|
||||
@@ -134,7 +134,7 @@ class CrontabLogic extends BaseLogic
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
if (count($ids) > 1) {
|
||||
throw new ApiException('禁止批量删除操作');
|
||||
throw new ApiException('Batch delete is not allowed');
|
||||
}
|
||||
$ids = $ids[0];
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class CrontabLogic extends BaseLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
$result = $model->save(['status' => $status]);
|
||||
if ($result) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class GenerateTablesLogic extends BaseLogic
|
||||
$data = config('think-orm.connections');
|
||||
$config = $data[$source];
|
||||
if (!$config) {
|
||||
throw new ApiException('数据库配置读取失败');
|
||||
throw new ApiException('Failed to read database config');
|
||||
}
|
||||
|
||||
$prefix = $config['prefix'] ?? '';
|
||||
@@ -262,10 +262,10 @@ class GenerateTablesLogic extends BaseLogic
|
||||
{
|
||||
$table = $this->model->findOrEmpty($id);
|
||||
if (!in_array($table['template'], ["plugin", "app"])) {
|
||||
throw new ApiException('应用类型必须为plugin或者app');
|
||||
throw new ApiException('App type must be plugin or app');
|
||||
}
|
||||
if (empty($table['namespace'])) {
|
||||
throw new ApiException('请先设置应用名称');
|
||||
throw new ApiException('Please set app name first');
|
||||
}
|
||||
|
||||
$columns = $this->columnLogic->where('table_id', $id)
|
||||
@@ -320,11 +320,11 @@ class GenerateTablesLogic extends BaseLogic
|
||||
{
|
||||
$table = $this->model->where('id', $id)->findOrEmpty();
|
||||
if ($table->isEmpty()) {
|
||||
throw new ApiException('请选择要生成的表');
|
||||
throw new ApiException('Please select tables to generate');
|
||||
}
|
||||
$debug = config('app.debug', true);
|
||||
if (!$debug) {
|
||||
throw new ApiException('非调试模式下,不允许生成文件');
|
||||
throw new ApiException('File generation not allowed in non-debug mode');
|
||||
}
|
||||
$this->updateMenu($table);
|
||||
$this->genModule($id);
|
||||
|
||||
@@ -27,10 +27,10 @@ class CheckLogin implements MiddlewareInterface
|
||||
try {
|
||||
$token = JwtToken::getExtend();
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException('您的登录凭证错误或者已过期,请重新登录', 401);
|
||||
throw new ApiException('Your login credential is invalid or expired, please login again', 401);
|
||||
}
|
||||
if ($token['plat'] !== 'saiadmin') {
|
||||
throw new ApiException('登录凭证校验失败');
|
||||
throw new ApiException('Login credential verification failed');
|
||||
}
|
||||
// 一次合并设置,避免 setHeader 覆盖导致只保留最后一个
|
||||
$request->setHeader(array_merge($request->header() ?: [], [
|
||||
|
||||
@@ -30,7 +30,7 @@ class SystemLog implements MiddlewareInterface
|
||||
// 记录日志
|
||||
Event::emit('user.operateLog', true);
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException('登录凭获取失败,请检查');
|
||||
throw new ApiException('Failed to get login credential, please check');
|
||||
}
|
||||
}
|
||||
return $handler($request);
|
||||
|
||||
@@ -42,11 +42,14 @@ class SystemDept extends BaseModel
|
||||
*/
|
||||
public function scopeAuth($query, $value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
if (!empty($value) && isset($value['id'])) {
|
||||
$deptIds = [$value['id']];
|
||||
$deptLevel = $value['level'] . $value['id'] . ',';
|
||||
$ids = static::whereLike('level', $deptLevel . '%')->column('id');
|
||||
$deptIds = array_merge($deptIds, $ids);
|
||||
$level = $value['level'] ?? '';
|
||||
if ($level !== '' && $level !== null) {
|
||||
$deptLevel = $level . $value['id'] . ',';
|
||||
$ids = static::whereLike('level', $deptLevel . '%')->column('id');
|
||||
$deptIds = array_merge($deptIds, $ids);
|
||||
}
|
||||
$query->whereIn('id', $deptIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use plugin\saiadmin\basic\think\BaseModel;
|
||||
* sa_system_user 用户表
|
||||
*
|
||||
* @property $id
|
||||
* @property $agent_id 代理标识,md5(id)唯一
|
||||
* @property $username 登录账号
|
||||
* @property $password 加密密码
|
||||
* @property $realname 真实姓名
|
||||
@@ -49,6 +50,30 @@ class SystemUser extends BaseModel
|
||||
*/
|
||||
protected $table = 'sa_system_user';
|
||||
|
||||
/**
|
||||
* 插入后:自动填充 agent_id = md5(id),保证唯一
|
||||
*/
|
||||
public static function onAfterInsert($model): void
|
||||
{
|
||||
$id = $model->getAttr('id');
|
||||
if ($id !== null && $id !== '') {
|
||||
$agentId = md5((string) $id);
|
||||
(new static())->where('id', $id)->update(['agent_id' => $agentId]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 agent_id:若未存储则返回 md5(id)
|
||||
*/
|
||||
public function getAgentIdAttr($value, $data)
|
||||
{
|
||||
if ($value !== null && $value !== '') {
|
||||
return $value;
|
||||
}
|
||||
$id = $data['id'] ?? null;
|
||||
return $id !== null ? md5((string) $id) : '';
|
||||
}
|
||||
|
||||
public function searchKeywordAttr($query, $value)
|
||||
{
|
||||
if ($value) {
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class AbstractLogic implements LogicInterface
|
||||
* 模型注入
|
||||
* @var object
|
||||
*/
|
||||
protected $model;
|
||||
public $model;
|
||||
|
||||
/**
|
||||
* 管理员信息
|
||||
|
||||
@@ -47,7 +47,7 @@ class BaseLogic extends AbstractLogic
|
||||
{
|
||||
$model = $this->model->find($id);
|
||||
if (!$model) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model->update($data);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class BaseLogic extends AbstractLogic
|
||||
{
|
||||
$model = $this->model->find($id);
|
||||
if (!$model) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class BaseLogic extends AbstractLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model->save($data);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class BaseLogic extends AbstractLogic
|
||||
{
|
||||
$model = $this->model->findOrEmpty($id);
|
||||
if ($model->isEmpty()) {
|
||||
throw new ApiException('数据不存在');
|
||||
throw new ApiException('Data not found');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@ Route::group('/core', function () {
|
||||
Route::get('/system/statistics', [plugin\saiadmin\app\controller\SystemController::class, 'statistics']);
|
||||
Route::get('/system/loginChart', [plugin\saiadmin\app\controller\SystemController::class, 'loginChart']);
|
||||
Route::get('/system/loginBarChart', [plugin\saiadmin\app\controller\SystemController::class, 'loginBarChart']);
|
||||
// 大富翁工作台统计(覆盖默认统计)
|
||||
Route::get('/dice/dashboard/statistics', [\app\dice\controller\DiceDashboardController::class, 'statistics']);
|
||||
Route::get('/dice/dashboard/rechargeChart', [\app\dice\controller\DiceDashboardController::class, 'rechargeChart']);
|
||||
Route::get('/dice/dashboard/rechargeBarChart', [\app\dice\controller\DiceDashboardController::class, 'rechargeBarChart']);
|
||||
Route::get('/dice/dashboard/walletRecordList', [\app\dice\controller\DiceDashboardController::class, 'walletRecordList']);
|
||||
Route::get('/dice/dashboard/newPlayerList', [\app\dice\controller\DiceDashboardController::class, 'newPlayerList']);
|
||||
Route::get('/system/clearAllCache', [plugin\saiadmin\app\controller\SystemController::class, 'clearAllCache']);
|
||||
|
||||
Route::get("/system/getResourceCategory", [plugin\saiadmin\app\controller\SystemController::class, 'getResourceCategory']);
|
||||
@@ -82,6 +88,46 @@ Route::group('/core', function () {
|
||||
Route::get("/server/cache", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'cache']);
|
||||
Route::post("/server/clear", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'clear']);
|
||||
|
||||
// 大富翁 Dice 模块
|
||||
fastRoute('dice/config/DiceConfig', \app\dice\controller\config\DiceConfigController::class);
|
||||
fastRoute('dice/player/DicePlayer', \app\dice\controller\player\DicePlayerController::class);
|
||||
Route::put('/dice/player/DicePlayer/updateStatus', [\app\dice\controller\player\DicePlayerController::class, 'updateStatus']);
|
||||
Route::get('/dice/player/DicePlayer/getLotteryConfigOptions', [\app\dice\controller\player\DicePlayerController::class, 'getLotteryConfigOptions']);
|
||||
Route::get('/dice/player/DicePlayer/getSystemUserOptions', [\app\dice\controller\player\DicePlayerController::class, 'getSystemUserOptions']);
|
||||
fastRoute('dice/play_record/DicePlayRecord', \app\dice\controller\play_record\DicePlayRecordController::class);
|
||||
Route::get('/dice/play_record/DicePlayRecord/getPlayerOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getPlayerOptions']);
|
||||
Route::get('/dice/play_record/DicePlayRecord/getLotteryConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getLotteryConfigOptions']);
|
||||
Route::get('/dice/play_record/DicePlayRecord/getRewardConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getRewardConfigOptions']);
|
||||
fastRoute('dice/player_wallet_record/DicePlayerWalletRecord', \app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class);
|
||||
Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerOptions']);
|
||||
Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerWalletBefore']);
|
||||
Route::post('/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'adminOperate']);
|
||||
fastRoute('dice/player_ticket_record/DicePlayerTicketRecord', \app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class);
|
||||
Route::get('/dice/player_ticket_record/DicePlayerTicketRecord/getPlayerOptions', [\app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class, 'getPlayerOptions']);
|
||||
fastRoute('dice/reward/DiceReward', \app\dice\controller\reward\DiceRewardController::class);
|
||||
Route::get('/dice/reward/DiceReward/weightRatioList', [\app\dice\controller\reward\DiceRewardController::class, 'weightRatioList']);
|
||||
Route::get('/dice/reward/DiceReward/weightRatioListWithDirection', [\app\dice\controller\reward\DiceRewardController::class, 'weightRatioListWithDirection']);
|
||||
Route::post('/dice/reward/DiceReward/batchUpdateWeights', [\app\dice\controller\reward\DiceRewardController::class, 'batchUpdateWeights']);
|
||||
Route::post('/dice/reward/DiceReward/batchUpdateWeightsByDirection', [\app\dice\controller\reward\DiceRewardController::class, 'batchUpdateWeightsByDirection']);
|
||||
Route::post('/dice/reward/DiceReward/startWeightTest', [\app\dice\controller\reward\DiceRewardController::class, 'startWeightTest']);
|
||||
Route::get('/dice/reward/DiceReward/getTestProgress', [\app\dice\controller\reward\DiceRewardController::class, 'getTestProgress']);
|
||||
fastRoute('dice/reward_config/DiceRewardConfig', \app\dice\controller\reward_config\DiceRewardConfigController::class);
|
||||
Route::get('/dice/reward_config/DiceRewardConfig/weightRatioList', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'weightRatioList']);
|
||||
Route::post('/dice/reward_config/DiceRewardConfig/batchUpdateWeights', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'batchUpdateWeights']);
|
||||
Route::post('/dice/reward_config/DiceRewardConfig/saveBigwinWeightsByGrid', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'saveBigwinWeightsByGrid']);
|
||||
Route::post('/dice/reward_config/DiceRewardConfig/batchUpdate', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'batchUpdate']);
|
||||
Route::post('/dice/reward_config/DiceRewardConfig/createRewardReference', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'createRewardReference']);
|
||||
Route::post('/dice/reward_config/DiceRewardConfig/runWeightTest', [\app\dice\controller\reward_config\DiceRewardConfigController::class, 'runWeightTest']);
|
||||
fastRoute('dice/lottery_pool_config/DiceLotteryPoolConfig', \app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class);
|
||||
Route::get('/dice/lottery_pool_config/DiceLotteryPoolConfig/getOptions', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'getOptions']);
|
||||
Route::get('/dice/lottery_pool_config/DiceLotteryPoolConfig/getCurrentPool', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'getCurrentPool']);
|
||||
Route::post('/dice/lottery_pool_config/DiceLotteryPoolConfig/updateCurrentPool', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'updateCurrentPool']);
|
||||
Route::post('/dice/lottery_pool_config/DiceLotteryPoolConfig/resetProfitAmount', [\app\dice\controller\lottery_pool_config\DiceLotteryPoolConfigController::class, 'resetProfitAmount']);
|
||||
fastRoute('dice/reward_config_record/DiceRewardConfigRecord', \app\dice\controller\reward_config_record\DiceRewardConfigRecordController::class);
|
||||
Route::post('/dice/reward_config_record/DiceRewardConfigRecord/importFromRecord', [\app\dice\controller\reward_config_record\DiceRewardConfigRecordController::class, 'importFromRecord']);
|
||||
fastRoute('dice/play_record_test/DicePlayRecordTest', \app\dice\controller\play_record_test\DicePlayRecordTestController::class);
|
||||
Route::post('/dice/play_record_test/DicePlayRecordTest/clearAll', [\app\dice\controller\play_record_test\DicePlayRecordTestController::class, 'clearAll']);
|
||||
|
||||
// 数据表维护
|
||||
Route::get("/database/index", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'index']);
|
||||
Route::get("/database/recycle", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'recycle']);
|
||||
|
||||
@@ -17,6 +17,8 @@ class ApiException extends BusinessException
|
||||
{
|
||||
public function render(Request $request): ?Response
|
||||
{
|
||||
return json(['code' => $this->getCode() ?: 500, 'message' => $this->getMessage()]);
|
||||
$message = $this->getMessage();
|
||||
$message = \app\api\util\ApiLang::translate($message, $request);
|
||||
return json(['code' => $this->getCode() ?: 500, 'message' => $message]);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class EmailService
|
||||
$logic = new SystemConfigLogic();
|
||||
$config = $logic->getGroup('email_config');
|
||||
if (!$config) {
|
||||
throw new ApiException('未设置邮件配置');
|
||||
throw new ApiException('Mail config not set');
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class EmailService
|
||||
public static function getMailer(): PHPMailer
|
||||
{
|
||||
if (!class_exists(PHPMailer::class)) {
|
||||
throw new ApiException('请执行 composer require phpmailer/phpmailer 并重启');
|
||||
throw new ApiException('Please run composer require phpmailer/phpmailer and restart');
|
||||
}
|
||||
$config = static::getConfig();
|
||||
$mailer = new PHPMailer();
|
||||
|
||||
@@ -54,7 +54,7 @@ class ChunkUploadService
|
||||
{
|
||||
$allow_file = Arr::getConfigValue($this->config, 'upload_allow_file');
|
||||
if (!in_array($data['ext'], explode(',', $allow_file))) {
|
||||
throw new ApiException('不支持该格式的文件上传');
|
||||
throw new ApiException('File format not supported for upload');
|
||||
}
|
||||
// 检查已经上传的分片文件
|
||||
for ($i = 0; $i < $data['total']; ++$i) {
|
||||
@@ -80,11 +80,11 @@ class ChunkUploadService
|
||||
{
|
||||
$allow_file = Arr::getConfigValue($this->config, 'upload_allow_file');
|
||||
if (!in_array($data['ext'], explode(',', $allow_file))) {
|
||||
throw new ApiException('不支持该格式的文件上传');
|
||||
throw new ApiException('File format not supported for upload');
|
||||
}
|
||||
$request = request();
|
||||
if (!$request) {
|
||||
throw new ApiException('切片上传服务必须在 HTTP 请求环境下调用');
|
||||
throw new ApiException('Chunk upload must be called in HTTP request context');
|
||||
}
|
||||
$uploadFile = current($request->file());
|
||||
$chunkName = $this->path . "{$data['hash']}_{$data['total']}_{$data['index']}.chunk";
|
||||
@@ -107,7 +107,7 @@ class ChunkUploadService
|
||||
for ($i = 0; $i < $data['total']; ++$i) {
|
||||
$chunkFile = $this->path . "{$data['hash']}_{$data['total']}_{$i}.chunk";
|
||||
if (!file_exists($chunkFile)) {
|
||||
throw new ApiException('切片文件查找失败,请重新上传');
|
||||
throw new ApiException('Chunk file not found, please upload again');
|
||||
}
|
||||
fwrite($fileHandle, file_get_contents($chunkFile));
|
||||
unlink($chunkFile);
|
||||
|
||||
@@ -34,17 +34,17 @@ class UploadService
|
||||
$ext = $file->getUploadExtension() ?: null;
|
||||
$file_size = $file->getSize();
|
||||
if ($file_size > Arr::getConfigValue($uploadConfig, 'upload_size')) {
|
||||
throw new ApiException('文件大小超过限制');
|
||||
throw new ApiException('File size exceeds limit');
|
||||
}
|
||||
$allow_file = Arr::getConfigValue($uploadConfig, 'upload_allow_file');
|
||||
$allow_image = Arr::getConfigValue($uploadConfig, 'upload_allow_image');
|
||||
if ($upload == 'image') {
|
||||
if (!in_array($ext, explode(',', $allow_image))) {
|
||||
throw new ApiException('不支持该格式的文件上传');
|
||||
throw new ApiException('File format not supported for upload');
|
||||
}
|
||||
} else {
|
||||
if (!in_array($ext, explode(',', $allow_file))) {
|
||||
throw new ApiException('不支持该格式的文件上传');
|
||||
throw new ApiException('File format not supported for upload');
|
||||
}
|
||||
}
|
||||
switch ($type) {
|
||||
@@ -115,7 +115,7 @@ class UploadService
|
||||
];
|
||||
break;
|
||||
default:
|
||||
throw new ApiException('该上传模式不存在');
|
||||
throw new ApiException('Upload mode not found');
|
||||
}
|
||||
return new $config['adapter'](array_merge(
|
||||
$config,
|
||||
|
||||
@@ -53,7 +53,7 @@ class CodeEngine
|
||||
|
||||
// 判断模板是否存在
|
||||
if (!is_dir($config['template_path'])) {
|
||||
throw new ApiException('模板目录不存在!');
|
||||
throw new ApiException('Template directory not found');
|
||||
}
|
||||
// 判断文件生成目录是否存在
|
||||
if (!is_dir($config['generate_path'])) {
|
||||
@@ -160,7 +160,7 @@ class CodeEngine
|
||||
}
|
||||
|
||||
if (empty($outPath)) {
|
||||
throw new ApiException('文件类型异常,无法生成指定文件!');
|
||||
throw new ApiException('Invalid file type, cannot generate file');
|
||||
}
|
||||
if (!is_dir(dirname($outPath))) {
|
||||
mkdir(dirname($outPath), 0777, true);
|
||||
@@ -176,7 +176,7 @@ class CodeEngine
|
||||
{
|
||||
$rootPath = dirname(base_path()) . DS . $this->value['generate_path'];
|
||||
if (!is_dir($rootPath)) {
|
||||
throw new ApiException('前端目录查找失败,必须与后端目录为同级目录!');
|
||||
throw new ApiException('Frontend directory not found, must be same level as backend');
|
||||
}
|
||||
|
||||
$rootPath = $rootPath . DS . 'src' . DS . 'views' . DS . 'plugin' . DS . $this->value['namespace'];
|
||||
@@ -199,7 +199,7 @@ class CodeEngine
|
||||
}
|
||||
|
||||
if (empty($outPath)) {
|
||||
throw new ApiException('文件类型异常,无法生成指定文件!');
|
||||
throw new ApiException('Invalid file type, cannot generate file');
|
||||
}
|
||||
if (!is_dir(dirname($outPath))) {
|
||||
mkdir(dirname($outPath), 0777, true);
|
||||
|
||||
@@ -57,7 +57,7 @@ class CodeZip
|
||||
$zipName = $config['generate_path'].'.zip';
|
||||
$dirPath = $config['generate_path'];
|
||||
if ($zipArc->open($zipName, \ZipArchive::OVERWRITE | \ZipArchive::CREATE) !== true) {
|
||||
throw new ApiException('无法打开文件,或者文件创建失败');
|
||||
throw new ApiException('Cannot open file or create file failed');
|
||||
}
|
||||
$this->addFileToZip($dirPath, $zipArc);
|
||||
$zipArc->close();
|
||||
@@ -158,7 +158,7 @@ class CodeZip
|
||||
@readfile($fileName);
|
||||
@unlink($fileName);
|
||||
} catch (\Throwable $th) {
|
||||
throw new ApiException('系统生成文件错误');
|
||||
throw new ApiException('System file generation error');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class InstallController extends BaseController
|
||||
{
|
||||
parent::__construct();
|
||||
if ($this->adminId > 1) {
|
||||
throw new ApiException('仅超级管理员能够操作');
|
||||
throw new ApiException('Only super admin can perform this action');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,17 +105,17 @@ class InstallController extends BaseController
|
||||
{
|
||||
$spl_file = current($request->file());
|
||||
if (!$spl_file->isValid()) {
|
||||
return $this->fail('上传文件校验失败');
|
||||
return $this->fail('upload file validation failed');
|
||||
}
|
||||
$config = config('plugin.saipackage.upload', [
|
||||
'size' => 1024 * 1024 * 5,
|
||||
'type' => ['zip']
|
||||
]);
|
||||
if (!in_array($spl_file->getUploadExtension(), $config['type'])) {
|
||||
return $this->fail('文件格式上传失败,请选择zip格式文件上传');
|
||||
return $this->fail('upload failed, please upload zip file');
|
||||
}
|
||||
if ($spl_file->getSize() > $config['size']) {
|
||||
return $this->fail('文件大小不能超过5M');
|
||||
return $this->fail('file size cannot exceed 5M');
|
||||
}
|
||||
$install = new InstallLogic();
|
||||
$info = $install->upload($spl_file);
|
||||
@@ -132,7 +132,7 @@ class InstallController extends BaseController
|
||||
{
|
||||
$appName = $request->post("appName", '');
|
||||
if (empty($appName)) {
|
||||
return $this->fail('参数错误');
|
||||
return $this->fail('Invalid parameters');
|
||||
}
|
||||
$install = new InstallLogic($appName);
|
||||
$info = $install->install();
|
||||
@@ -150,12 +150,12 @@ class InstallController extends BaseController
|
||||
{
|
||||
$appName = $request->post("appName", '');
|
||||
if (empty($appName)) {
|
||||
return $this->fail('参数错误');
|
||||
return $this->fail('Invalid parameters');
|
||||
}
|
||||
$install = new InstallLogic($appName);
|
||||
$install->uninstall();
|
||||
UserMenuCache::clearMenuCache();
|
||||
return $this->success('卸载插件成功');
|
||||
return $this->success('uninstall plugin success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ class InstallController extends BaseController
|
||||
{
|
||||
Server::restart();
|
||||
|
||||
return $this->success('重载成功');
|
||||
return $this->success('reload success');
|
||||
}
|
||||
|
||||
// ========== 商店代理接口 ==========
|
||||
@@ -278,7 +278,7 @@ class InstallController extends BaseController
|
||||
{
|
||||
$token = $request->input('token');
|
||||
if (empty($token)) {
|
||||
return $this->fail('未登录');
|
||||
return $this->fail('not logged in');
|
||||
}
|
||||
|
||||
$result = $this->proxyRequest(
|
||||
@@ -299,7 +299,7 @@ class InstallController extends BaseController
|
||||
{
|
||||
$token = $request->input('token');
|
||||
if (empty($token)) {
|
||||
return $this->fail('未登录');
|
||||
return $this->fail('not logged in');
|
||||
}
|
||||
|
||||
$result = $this->proxyRequest(
|
||||
@@ -322,7 +322,7 @@ class InstallController extends BaseController
|
||||
$appId = $request->input('app_id');
|
||||
|
||||
if (empty($token)) {
|
||||
return $this->fail('未登录');
|
||||
return $this->fail('not logged in');
|
||||
}
|
||||
|
||||
$result = $this->proxyRequest(
|
||||
@@ -345,11 +345,11 @@ class InstallController extends BaseController
|
||||
$versionId = $request->input('id');
|
||||
|
||||
if (empty($token)) {
|
||||
return $this->fail('未登录');
|
||||
return $this->fail('not logged in');
|
||||
}
|
||||
|
||||
if (empty($versionId)) {
|
||||
return $this->fail('版本ID不能为空');
|
||||
return $this->fail('version id is required');
|
||||
}
|
||||
|
||||
$result = $this->proxyRequest(
|
||||
@@ -365,7 +365,7 @@ class InstallController extends BaseController
|
||||
}
|
||||
|
||||
if (!isset($result['raw'])) {
|
||||
return $this->fail('下载失败');
|
||||
return $this->fail('download failed');
|
||||
}
|
||||
|
||||
// 保存临时 zip 文件
|
||||
@@ -380,7 +380,7 @@ class InstallController extends BaseController
|
||||
$install = new InstallLogic();
|
||||
$info = $install->uploadFromPath($tempZip);
|
||||
|
||||
return $this->success($info, '下载成功,请在插件列表中安装');
|
||||
return $this->success($info, 'download success, please install in plugin list');
|
||||
} catch (Throwable $e) {
|
||||
@unlink($tempZip);
|
||||
return $this->fail($e->getMessage());
|
||||
|
||||
@@ -108,7 +108,7 @@ class InstallLogic
|
||||
if (empty($info['app'])) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
// 基本配置不完整
|
||||
throw new ApiException('插件的基础配置信息错误');
|
||||
throw new ApiException('Plugin base config is invalid');
|
||||
}
|
||||
|
||||
|
||||
@@ -127,14 +127,14 @@ class InstallLogic
|
||||
$upgrade = Version::compare($nextVersion, $info['version']);
|
||||
if (!$upgrade) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
throw new ApiException('插件已经存在');
|
||||
throw new ApiException('Plugin already exists');
|
||||
}
|
||||
}
|
||||
|
||||
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
// 模块目录被占
|
||||
throw new ApiException('该插件的安装目录已经被占用');
|
||||
throw new ApiException('Plugin install directory is already occupied');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class InstallLogic
|
||||
public function uploadFromPath(string $zipPath): array
|
||||
{
|
||||
if (!is_file($zipPath)) {
|
||||
throw new ApiException('文件不存在');
|
||||
throw new ApiException('File not found');
|
||||
}
|
||||
|
||||
// 解压
|
||||
@@ -181,7 +181,7 @@ class InstallLogic
|
||||
$info = Server::getIni($copyToDir);
|
||||
if (empty($info['app'])) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
throw new ApiException('插件的基础配置信息错误');
|
||||
throw new ApiException('Plugin base config is invalid');
|
||||
}
|
||||
|
||||
$this->appName = $info['app'];
|
||||
@@ -199,13 +199,13 @@ class InstallLogic
|
||||
$upgrade = Version::compare($nextVersion, $info['version']);
|
||||
if (!$upgrade) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
throw new ApiException('插件已经存在');
|
||||
throw new ApiException('Plugin already exists');
|
||||
}
|
||||
}
|
||||
|
||||
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
|
||||
Filesystem::delDir($copyToDir);
|
||||
throw new ApiException('该插件的安装目录已经被占用');
|
||||
throw new ApiException('Plugin install directory is already occupied');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +237,11 @@ class InstallLogic
|
||||
{
|
||||
$state = $this->getInstallState();
|
||||
if ($state == self::INSTALLED || $state == self::DIRECTORY_OCCUPIED) {
|
||||
throw new ApiException('插件已经存在');
|
||||
throw new ApiException('Plugin already exists');
|
||||
}
|
||||
|
||||
if ($state == self::DEPENDENT_WAIT_INSTALL) {
|
||||
throw new ApiException('等待依赖安装');
|
||||
throw new ApiException('Waiting for dependencies to be installed');
|
||||
}
|
||||
|
||||
echo '开始安装[' . $this->appName . ']' . PHP_EOL;
|
||||
@@ -351,14 +351,14 @@ class InstallLogic
|
||||
public function checkPackage(): bool
|
||||
{
|
||||
if (!is_dir($this->appDir)) {
|
||||
throw new ApiException('插件目录不存在');
|
||||
throw new ApiException('Plugin directory not found');
|
||||
}
|
||||
$info = $this->getInfo();
|
||||
$infoKeys = ['app', 'title', 'about', 'author', 'version', 'state'];
|
||||
foreach ($infoKeys as $value) {
|
||||
if (!array_key_exists($value, $info)) {
|
||||
Filesystem::delDir($this->appDir);
|
||||
throw new ApiException('该插件的基础配置信息不完善');
|
||||
throw new ApiException('Plugin base config is incomplete');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -527,6 +527,6 @@ class InstallLogic
|
||||
} elseif ($arr) {
|
||||
return Server::setIni($this->appDir, $arr);
|
||||
}
|
||||
throw new ApiException('参数错误');
|
||||
throw new ApiException('Invalid parameters');
|
||||
}
|
||||
}
|
||||
|
||||
346
server/resource/translations/api/en.php
Normal file
346
server/resource/translations/api/en.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'ACCOUNT_DISABLED' => 'Account is disabled and cannot log in',
|
||||
'API_AUTH_TOKEN_SECRET is not configured' => 'API_AUTH_TOKEN_SECRET is not configured',
|
||||
'AUTH_TOKEN_EXPIRED' => 'auth-token expired',
|
||||
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token format invalid',
|
||||
'AUTH_TOKEN_INVALID' => 'auth-token invalid',
|
||||
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token invalid or expired',
|
||||
'AUTH_TOKEN_REQUIRED' => 'Please provide auth-token',
|
||||
'Account is disabled and cannot log in' => 'Account is disabled and cannot log in',
|
||||
'App type must be plugin or app' => 'App type must be plugin or app',
|
||||
'BALANCE_LESS_THAN_MIN' => 'Balance %s is less than %s, cannot continue',
|
||||
'BATCH_DELETE_FORBIDDEN' => 'Batch delete is not allowed',
|
||||
'BUY_TICKET_ERROR' => 'Invalid lottery ticket purchase',
|
||||
'Balance %s is less than %s, cannot continue' => 'Balance %s is less than %s, cannot continue',
|
||||
'Batch delete is not allowed' => 'Batch delete is not allowed',
|
||||
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => 'Config ID %s not found or tier is empty',
|
||||
'Cannot open file or create file failed' => 'Cannot open file or create file failed',
|
||||
'Cannot operate roles with higher level than current account' => 'Cannot operate roles with higher level than current account',
|
||||
'Cannot set parent category as child of current' => 'Cannot set parent category as child of current',
|
||||
'Cannot set parent department to a child of current department' => 'Cannot set parent department to a child of current department',
|
||||
'Cannot set parent to self' => 'Cannot set parent to self',
|
||||
'Chunk file not found, please upload again' => 'Chunk file not found, please upload again',
|
||||
'Chunk upload must be called in HTTP request context' => 'Chunk upload must be called in HTTP request context',
|
||||
'Coin change must be greater than 0' => 'Coin change must be greater than 0',
|
||||
'Config data not found' => 'Config data not found',
|
||||
'Config group not found' => 'Config group not found',
|
||||
'Counts only support 0, 100, 500, 1000, 5000' => 'Counts only support 0, 100, 500, 1000, 5000',
|
||||
'Current table does not support recycle bin' => 'Current table does not support recycle bin',
|
||||
'DATA_NOT_FOUND' => 'Data not found',
|
||||
'DIRECTION_INVALID' => 'direction must be 0 or 1',
|
||||
'Data not found' => 'Data not found',
|
||||
'Deduct amount cannot exceed current balance' => 'Deduct amount cannot exceed current balance',
|
||||
'Delete data error, please check' => 'Delete data error, please check',
|
||||
'Dict type not found' => 'Dict type not found',
|
||||
'FAIL' => 'Fail',
|
||||
'Failed to create image resource' => 'Failed to create image resource',
|
||||
'Failed to generate token' => 'Failed to generate token',
|
||||
'Failed to get file resource' => 'Failed to get file resource',
|
||||
'Failed to get login credential, please check' => 'Failed to get login credential, please check',
|
||||
'Failed to read database config' => 'Failed to read database config',
|
||||
'Failed to save file' => 'Failed to save file',
|
||||
'File format not supported for upload' => 'File format not supported for upload',
|
||||
'File generation not allowed in non-debug mode' => 'File generation not allowed in non-debug mode',
|
||||
'File not found' => 'File not found',
|
||||
'File size exceeds limit' => 'File size exceeds limit',
|
||||
'Free pool config not found' => 'Free pool config not found',
|
||||
'Free tier probabilities (T1–T5) sum cannot exceed 100%' => 'Free tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
'Free tier probability must be between 0 and 100%' => 'Free tier probability must be between 0 and 100%',
|
||||
'Frontend directory not found, must be same level as backend' => 'Frontend directory not found, must be same level as backend',
|
||||
'INSUFFICIENT_BALANCE' => 'Insufficient balance',
|
||||
'INSUFFICIENT_TICKETS' => 'Insufficient lottery tickets',
|
||||
'Import file error, please upload correct xlsx file' => 'Import file error, please upload correct xlsx file',
|
||||
'Insufficient balance' => 'Insufficient balance',
|
||||
'Insufficient balance to transfer' => 'Insufficient balance to transfer',
|
||||
'Insufficient lottery tickets' => 'Insufficient lottery tickets',
|
||||
'Invalid DiceReward id exists' => 'Invalid DiceReward id exists',
|
||||
'Invalid config ID exists' => 'Invalid config ID exists',
|
||||
'Invalid file format' => 'Invalid file format',
|
||||
'Invalid file type, cannot generate file' => 'Invalid file type, cannot generate file',
|
||||
'Invalid lottery ticket purchase' => 'Invalid lottery ticket purchase',
|
||||
'Invalid or expired token' => 'Invalid or expired token',
|
||||
'Invalid parameters' => 'Invalid parameters',
|
||||
'Invalid params: player_id and type are required (3=add, 4=deduct)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
|
||||
'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
|
||||
'Invalid secret' => 'Invalid secret',
|
||||
'Invalid task type' => 'Invalid task type',
|
||||
'LOTTERY_CONFIG_NOT_FOUND' => 'Lottery config not found',
|
||||
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => 'No name=default pool config found, please create one first',
|
||||
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => 'Lottery pool config not found (name=default required)',
|
||||
'Logged out successfully' => 'Logged out successfully',
|
||||
'Login credential verification failed' => 'Login credential verification failed',
|
||||
'Lottery pool config not found (name=default required)' => 'Lottery pool config not found (name=default required)',
|
||||
'MSG_022FA411' => 'App type must be plugin or app',
|
||||
'MSG_04BF8179' => 'Data not found',
|
||||
'MSG_06F06DA6' => 'Invalid or expired token',
|
||||
'MSG_0A17D195' => 'Paid tier probability must be between 0 and 100%',
|
||||
'MSG_0A9A3E28' => 'Batch delete is not allowed',
|
||||
'MSG_0BCF9CBC' => 'Test count only supports 100, 500, 1000, 5000, 10000',
|
||||
'MSG_0CBB8FF6' => 'Service timeout: ',
|
||||
'MSG_0D49B785' => 'Old password is incorrect',
|
||||
'MSG_0FE75E2C' => 'Chunk upload must be called in HTTP request context',
|
||||
'MSG_146A3F0D' => 'Dict type not found',
|
||||
'MSG_17740DB3' => 'Token format invalid',
|
||||
'MSG_1798E4D4' => 'Template not found',
|
||||
'MSG_19E651B8' => 'coin is required',
|
||||
'MSG_1A499109' => 'File not found',
|
||||
'MSG_1BB27051' => 'auth-token expired',
|
||||
'MSG_1C1718A6' => 'Plugin already exists',
|
||||
'MSG_2240AD6D' => 'auth-token invalid',
|
||||
'MSG_2273437E' => 'Balance %s is less than %s, cannot continue',
|
||||
'MSG_22C6787F' => 'Chunk file not found, please upload again',
|
||||
'MSG_25BF8A8D' => 'Deduct amount cannot exceed current balance',
|
||||
'MSG_2830AE01' => 'Service timeout: Unknown reason',
|
||||
'MSG_2ED0C7A8' => 'Plugin base config is invalid',
|
||||
'MSG_2EE75A5E' => 'System file generation error',
|
||||
'MSG_2EFE74EE' => 'File generation not allowed in non-debug mode',
|
||||
'MSG_2F100DB4' => 'Cannot operate roles with higher level than current account',
|
||||
'MSG_334CE26A' => 'No permission to operate this data',
|
||||
'MSG_35FB9BA0' => 'File format not supported for upload',
|
||||
'MSG_381A19AE' => 'Upload mode not found',
|
||||
'MSG_3A4A6DE6' => 'username is required',
|
||||
'MSG_3A4FF81F' => 'No permission to operate department data',
|
||||
'MSG_3C99F7F7' => 'Reward config is empty, please maintain dice_reward_config first',
|
||||
'MSG_3DBFEA33' => 'Invalid file format',
|
||||
'MSG_43C4D703' => 'This department has users, please delete or transfer them first',
|
||||
'MSG_47FDBDD0' => 'Config group not found',
|
||||
'MSG_4CA58C61' => 'Update data error, please check',
|
||||
'MSG_4F1D271A' => 'Invalid DiceReward id exists',
|
||||
'MSG_521593FB' => 'Please set app name first',
|
||||
'MSG_557E5109' => 'Failed to get file resource',
|
||||
'MSG_559AAE0E' => 'No permission to operate role data',
|
||||
'MSG_560E6D91' => 'No path config available for this direction',
|
||||
'MSG_5643EE10' => 'Failed to generate token',
|
||||
'MSG_569EC863' => 'Current table does not support recycle bin',
|
||||
'MSG_56B44907' => 'Target category not found',
|
||||
'MSG_5CE17D6B' => 'auth-token invalid or expired',
|
||||
'MSG_5FF3A2BE' => 'Failed to read database config',
|
||||
'MSG_609A300B' => 'Insufficient balance',
|
||||
'MSG_60B9FC38' => 'Failed to get login credential, please check',
|
||||
'MSG_64A3C830' => 'User not found',
|
||||
'MSG_67C66962' => 'No name=default pool config found, please create one first',
|
||||
'MSG_6C16260B' => 'When free pool is not selected, please fill free custom tier probabilities (T1–T5)',
|
||||
'MSG_6CA924A1' => 'Lottery pool config not found (name=default required)',
|
||||
'MSG_6F00DFB2' => 'Success',
|
||||
'MSG_7310FDB8' => 'Frontend directory not found, must be same level as backend',
|
||||
'MSG_74E3CB84' => 'No available reward config',
|
||||
'MSG_75C6A69F' => 'Please provide auth-token',
|
||||
'MSG_7845F2E9' => 'Delete data error, please check',
|
||||
'MSG_86272B49' => 'Fail',
|
||||
'MSG_8865D363' => 'coin cannot be 0',
|
||||
'MSG_8B6AA32A' => 'Cannot set parent category as child of current',
|
||||
'MSG_8C2E3CE6' => 'Please login again (account logged in elsewhere)',
|
||||
'MSG_8FDBA3F1' => 'This dict code already exists',
|
||||
'MSG_91272513' => 'Invalid lottery ticket purchase',
|
||||
'MSG_94EE6593' => 'Plugin install directory is already occupied',
|
||||
'MSG_9501E2EF' => 'Insufficient balance to transfer',
|
||||
'MSG_950B6072' => 'Config data not found',
|
||||
'MSG_9A01DFBF' => 'Plugin base config is incomplete',
|
||||
'MSG_9D195F25' => 'Account is disabled and cannot log in',
|
||||
'MSG_9EE0801C' => 'Cannot open file or create file failed',
|
||||
'MSG_9F6B51C8' => 'Invalid file type, cannot generate file',
|
||||
'MSG_A049A679' => 'This category has sub-categories, please delete them first',
|
||||
'MSG_A3165463' => 'Only super admin can perform this action',
|
||||
'MSG_A4FB6212' => 'Failed to save file',
|
||||
'MSG_A6A8EA8F' => 'Plugin directory not found',
|
||||
'MSG_A72A7DC6' => 'This department has sub-departments, please delete them first',
|
||||
'MSG_A778ABB9' => 'auth-token format invalid',
|
||||
'MSG_ADA80442' => 'Please login again',
|
||||
'MSG_AE73E6F3' => 'API_AUTH_TOKEN_SECRET is not configured',
|
||||
'MSG_B387239D' => 'Paid tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
'MSG_B5C2F2F6' => 'Counts only support 0, 100, 500, 1000, 5000',
|
||||
'MSG_B5CD5C51' => 'Test record not found',
|
||||
'MSG_B720629D' => 'username and password are required',
|
||||
'MSG_BA173F12' => 'Sum of paid/free direction counts must be greater than 0',
|
||||
'MSG_BAC2EFB0' => 'Parent department cannot be the same as current department',
|
||||
'MSG_BB3C5A3F' => 'direction must be 0 or 1',
|
||||
'MSG_BBD3198A' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
|
||||
'MSG_BD8AD1D3' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
|
||||
'MSG_BEB15D55' => 'Invalid parameters',
|
||||
'MSG_C2E4B3DC' => 'Invalid task type',
|
||||
'MSG_C2F02095' => 'Insufficient lottery tickets',
|
||||
'MSG_C3CB20DC' => 'Free tier probability must be between 0 and 100%',
|
||||
'MSG_C43809BC' => 'Operation failed: ',
|
||||
'MSG_C548E557' => 'Missing parameters: agent_id, secret, time, signature are required',
|
||||
'MSG_C5D5D5E1' => 'Cannot set parent department to a child of current department',
|
||||
'MSG_C803EA6F' => 'Please register',
|
||||
'MSG_C80C5EF5' => 'Failed to create image resource',
|
||||
'MSG_C9BFC7E9' => 'Lottery config not found',
|
||||
'MSG_CDEA9DD8' => 'Your login credential is invalid or expired, please login again',
|
||||
'MSG_D15C0759' => 'Invalid secret',
|
||||
'MSG_D1D1C0A0' => 'Template directory not found',
|
||||
'MSG_D1E7769C' => 'Parent category cannot be the same as current',
|
||||
'MSG_D224020F' => 'Free pool config not found',
|
||||
'MSG_D75845B2' => 'Free tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
'MSG_DB560C68' => 'Please run composer require phpmailer/phpmailer and restart',
|
||||
'MSG_DEE31D19' => 'Timestamp expired or invalid, please sync time',
|
||||
'MSG_DF93D5F9' => 'Token expired, please login again',
|
||||
'MSG_E12FF883' => 'File size exceeds limit',
|
||||
'MSG_E15B47C6' => 'Super admin cannot be deleted',
|
||||
'MSG_E1BFE655' => 'Mail config not set',
|
||||
'MSG_E5849544' => 'Wrong password',
|
||||
'MSG_E66BC216' => 'This menu has sub-menus, please delete them first',
|
||||
'MSG_E6E6288B' => 'System default group cannot be deleted',
|
||||
'MSG_E84B2B0A' => 'Logged out successfully',
|
||||
'MSG_E8C8EC80' => 'Invalid config ID exists',
|
||||
'MSG_E96B26B9' => 'Coin change must be greater than 0',
|
||||
'MSG_EEDAAC44' => 'Waiting for dependencies to be installed',
|
||||
'MSG_F0F5F561' => 'Config ID %s not found or tier is empty',
|
||||
'MSG_F12E5DBA' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
|
||||
'MSG_F2643E83' => 'Login credential verification failed',
|
||||
'MSG_F58CB5C8' => 'This category has sub-categories, please delete them first',
|
||||
'MSG_F5F9FF11' => 'Paid pool config not found',
|
||||
'MSG_F7BBA776' => 'Unknown reason',
|
||||
'MSG_F8EB5084' => 'Signature verification failed',
|
||||
'MSG_FA5FF202' => 'Cannot set parent to self',
|
||||
'MSG_FB4C0ADF' => 'Please select tables to generate',
|
||||
'MSG_FBC50B18' => 'Player not found',
|
||||
'MSG_FC1E3345' => 'Import file error, please upload correct xlsx file',
|
||||
'MSG_FDADA275' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)',
|
||||
'MSG_FE1B67CA' => 'Please provide token',
|
||||
'Mail config not set' => 'Mail config not set',
|
||||
'Missing parameters: agent_id, secret, time, signature are required' => 'Missing parameters: agent_id, secret, time, signature are required',
|
||||
'NO_AVAILABLE_REWARD_CONFIG' => 'No available reward config',
|
||||
'No available reward config' => 'No available reward config',
|
||||
'No name=default pool config found, please create one first' => 'No name=default pool config found, please create one first',
|
||||
'No permission to operate department data' => 'No permission to operate department data',
|
||||
'No permission to operate role data' => 'No permission to operate role data',
|
||||
'No permission to operate this data' => 'No permission to operate this data',
|
||||
'OLD_PASSWORD_WRONG' => 'Old password is incorrect',
|
||||
'Old password is incorrect' => 'Old password is incorrect',
|
||||
'Only super admin can perform this action' => 'Only super admin can perform this action',
|
||||
'Operation failed: ' => 'Operation failed: ',
|
||||
'PASSWORD_WRONG' => 'Wrong password',
|
||||
'Paid pool config not found' => 'Paid pool config not found',
|
||||
'Paid tier probabilities (T1–T5) sum cannot exceed 100%' => 'Paid tier probabilities (T1–T5) sum cannot exceed 100%',
|
||||
'Paid tier probability must be between 0 and 100%' => 'Paid tier probability must be between 0 and 100%',
|
||||
'Parent category cannot be the same as current' => 'Parent category cannot be the same as current',
|
||||
'Parent department cannot be the same as current department' => 'Parent department cannot be the same as current department',
|
||||
'Player not found' => 'Player not found',
|
||||
'Please login again' => 'Please login again',
|
||||
'Please login again (account logged in elsewhere)' => 'Please login again (account logged in elsewhere)',
|
||||
'Please provide auth-token' => 'Please provide auth-token',
|
||||
'Please provide token' => 'Please provide token',
|
||||
'Please register' => 'Please register',
|
||||
'Please run composer require phpmailer/phpmailer and restart' => 'Please run composer require phpmailer/phpmailer and restart',
|
||||
'Please select tables to generate' => 'Please select tables to generate',
|
||||
'Please set app name first' => 'Please set app name first',
|
||||
'Plugin already exists' => 'Plugin already exists',
|
||||
'Plugin base config is incomplete' => 'Plugin base config is incomplete',
|
||||
'Plugin base config is invalid' => 'Plugin base config is invalid',
|
||||
'Plugin directory not found' => 'Plugin directory not found',
|
||||
'Plugin install directory is already occupied' => 'Plugin install directory is already occupied',
|
||||
'Reward config is empty, please maintain dice_reward_config first' => 'Reward config is empty, please maintain dice_reward_config first',
|
||||
'SUCCESS' => 'Success',
|
||||
'SUPER_ADMIN_CANNOT_DELETE' => 'Super admin cannot be deleted',
|
||||
'Service timeout: ' => 'Service timeout: ',
|
||||
'Signature verification failed' => 'Signature verification failed',
|
||||
'Sum of paid/free direction counts must be greater than 0' => 'Sum of paid/free direction counts must be greater than 0',
|
||||
'Super admin cannot be deleted' => 'Super admin cannot be deleted',
|
||||
'System default group cannot be deleted' => 'System default group cannot be deleted',
|
||||
'System file generation error' => 'System file generation error',
|
||||
'TOKEN_EXPIRED_RELOGIN' => 'Token expired, please login again',
|
||||
'TOKEN_FORMAT_INVALID' => 'Token format invalid',
|
||||
'TOKEN_INVALID' => 'Invalid or expired token',
|
||||
'TOKEN_REQUIRED' => 'Please provide token',
|
||||
'Target category not found' => 'Target category not found',
|
||||
'Template directory not found' => 'Template directory not found',
|
||||
'Template not found' => 'Template not found',
|
||||
'Test count only supports 100, 500, 1000, 5000, 10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
|
||||
'Test record not found' => 'Test record not found',
|
||||
'This category has sub-categories, please delete them first' => 'This category has sub-categories, please delete them first',
|
||||
'This department has sub-departments, please delete them first' => 'This department has sub-departments, please delete them first',
|
||||
'This department has users, please delete or transfer them first' => 'This department has users, please delete or transfer them first',
|
||||
'This dict code already exists' => 'This dict code already exists',
|
||||
'This menu has sub-menus, please delete them first' => 'This menu has sub-menus, please delete them first',
|
||||
'Timestamp expired or invalid, please sync time' => 'Timestamp expired or invalid, please sync time',
|
||||
'Token expired, please login again' => 'Token expired, please login again',
|
||||
'Token format invalid' => 'Token format invalid',
|
||||
'USERNAME_PASSWORD_REQUIRED' => 'username and password are required',
|
||||
'USERNAME_REQUIRED' => 'username is required',
|
||||
'USER_NOT_FOUND' => 'User not found',
|
||||
'Update data error, please check' => 'Update data error, please check',
|
||||
'Upload mode not found' => 'Upload mode not found',
|
||||
'User not found' => 'User not found',
|
||||
'Waiting for dependencies to be installed' => 'Waiting for dependencies to be installed',
|
||||
'When free pool is not selected, please fill free custom tier probabilities (T1–T5)' => 'When free pool is not selected, please fill free custom tier probabilities (T1–T5)',
|
||||
'When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)',
|
||||
'Wrong password' => 'Wrong password',
|
||||
'Your login credential is invalid or expired, please login again' => 'Your login credential is invalid or expired, please login again',
|
||||
'add failed' => 'add failed',
|
||||
'add success' => 'add success',
|
||||
'admin already installed, to reinstall please delete env file and restart' => 'admin already installed, to reinstall please delete env file and restart',
|
||||
'all test data cleared' => 'all test data cleared',
|
||||
'auth-token expired' => 'auth-token expired',
|
||||
'auth-token format invalid' => 'auth-token format invalid',
|
||||
'auth-token invalid' => 'auth-token invalid',
|
||||
'auth-token invalid or expired' => 'auth-token invalid or expired',
|
||||
'captcha error' => 'captcha error',
|
||||
'clean success' => 'clean success',
|
||||
'clear cache success' => 'clear cache success',
|
||||
'clear failed: ' => 'clear failed: ',
|
||||
'coin cannot be 0' => 'coin cannot be 0',
|
||||
'coin is required' => 'coin is required',
|
||||
'connection refused, please check database ip/port and ensure database is running' => 'connection refused, please check database ip/port and ensure database is running',
|
||||
'create reward mapping success' => 'create reward mapping success',
|
||||
'database SQL file not found' => 'database SQL file not found',
|
||||
'database already installed, please do not install again' => 'database already installed, please do not install again',
|
||||
'database connection timeout, please check ip/port and firewall/security group rules' => 'database connection timeout, please check ip/port and firewall/security group rules',
|
||||
'database username or password is incorrect' => 'database username or password is incorrect',
|
||||
'delete failed' => 'delete failed',
|
||||
'delete success' => 'delete success',
|
||||
'direction must be 0 (clockwise) or 1 (counterclockwise)' => 'direction must be 0 (clockwise) or 1 (counterclockwise)',
|
||||
'direction must be 0 or 1' => 'direction must be 0 or 1',
|
||||
'download failed' => 'download failed',
|
||||
'download success, please install in plugin list' => 'download success, please install in plugin list',
|
||||
'execute success' => 'execute success',
|
||||
'execution failed' => 'execution failed',
|
||||
'file size cannot exceed 5M' => 'file size cannot exceed 5M',
|
||||
'import success' => 'import success',
|
||||
'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config' => 'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config',
|
||||
'install success' => 'install success',
|
||||
'invalid parameters, please check' => 'invalid parameters, please check',
|
||||
'login expired or invalid, please login again' => 'login expired or invalid, please login again',
|
||||
'missing parameter id' => 'missing parameter id',
|
||||
'missing parameter status' => 'missing parameter status',
|
||||
'missing player_id' => 'missing player_id',
|
||||
'no permission to delete selected data' => 'no permission to delete selected data',
|
||||
'no permission to operate this player' => 'no permission to operate this player',
|
||||
'no permission to update this record' => 'no permission to update this record',
|
||||
'no permission to view this record' => 'no permission to view this record',
|
||||
'not found' => 'not found',
|
||||
'not logged in' => 'not logged in',
|
||||
'operation failed' => 'operation failed',
|
||||
'operation success' => 'operation success',
|
||||
'operation type must be 3 (add) or 4 (deduct)' => 'operation type must be 3 (add) or 4 (deduct)',
|
||||
'optimize success' => 'optimize success',
|
||||
'parameter items must be an array' => 'parameter items must be an array',
|
||||
'please input email' => 'please input email',
|
||||
'please login first' => 'please login first',
|
||||
'please provide direction (0=clockwise, 1=counterclockwise)' => 'please provide direction (0=clockwise, 1=counterclockwise)',
|
||||
'please provide record_id' => 'please provide record_id',
|
||||
'please select cache to delete' => 'please select cache to delete',
|
||||
'please select data to delete' => 'please select data to delete',
|
||||
'please select player' => 'please select player',
|
||||
'please specify test record' => 'please specify test record',
|
||||
'record not found' => 'record not found',
|
||||
'reload success' => 'reload success',
|
||||
'reset success' => 'reset success',
|
||||
'save success' => 'save success',
|
||||
'send failed, please check logs' => 'send failed, please check logs',
|
||||
'send success' => 'send success',
|
||||
'super admin cannot reset password' => 'super admin cannot reset password',
|
||||
'test data cleared' => 'test data cleared',
|
||||
'too many requests, please try again later' => 'too many requests, please try again later',
|
||||
'uninstall plugin success' => 'uninstall plugin success',
|
||||
'update failed' => 'update failed',
|
||||
'update success' => 'update success',
|
||||
'upload failed, please upload zip file' => 'upload failed, please upload zip file',
|
||||
'upload file validation failed' => 'upload file validation failed',
|
||||
'uploaded file not found' => 'uploaded file not found',
|
||||
'username is required' => 'username is required',
|
||||
'version id is required' => 'version id is required',
|
||||
];
|
||||
346
server/resource/translations/api/zh.php
Normal file
346
server/resource/translations/api/zh.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'ACCOUNT_DISABLED' => '账号已被禁用,无法登录',
|
||||
'API_AUTH_TOKEN_SECRET is not configured' => '服务端未配置 API_AUTH_TOKEN_SECRET',
|
||||
'AUTH_TOKEN_EXPIRED' => 'auth-token 已过期',
|
||||
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token 格式无效',
|
||||
'AUTH_TOKEN_INVALID' => 'auth-token 无效',
|
||||
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token 无效或已失效',
|
||||
'AUTH_TOKEN_REQUIRED' => '请携带 auth-token',
|
||||
'Account is disabled and cannot log in' => '账号已被禁用,无法登录',
|
||||
'App type must be plugin or app' => '应用类型必须为plugin或者app',
|
||||
'BALANCE_LESS_THAN_MIN' => '当前玩家余额%s小于%s无法继续游戏',
|
||||
'BATCH_DELETE_FORBIDDEN' => '禁止批量删除操作',
|
||||
'BUY_TICKET_ERROR' => '购买抽奖券错误',
|
||||
'Balance %s is less than %s, cannot continue' => '当前玩家余额%s小于%s无法继续游戏',
|
||||
'Batch delete is not allowed' => '禁止批量删除操作',
|
||||
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => '配置ID %s 不存在或档位为空',
|
||||
'Cannot open file or create file failed' => '无法打开文件,或者文件创建失败',
|
||||
'Cannot operate roles with higher level than current account' => '不能操作比当前账户职级高的角色',
|
||||
'Cannot set parent category as child of current' => '不能将上级分类设置为当前分类的子分类',
|
||||
'Cannot set parent department to a child of current department' => '不能将上级部门设置为当前部门的子部门',
|
||||
'Cannot set parent to self' => '不能设置父级为自身',
|
||||
'Chunk file not found, please upload again' => '切片文件查找失败,请重新上传',
|
||||
'Chunk upload must be called in HTTP request context' => '切片上传服务必须在 HTTP 请求环境下调用',
|
||||
'Coin change must be greater than 0' => '平台币变动必须大于 0',
|
||||
'Config data not found' => '配置数据未找到',
|
||||
'Config group not found' => '配置组未找到',
|
||||
'Counts only support 0, 100, 500, 1000, 5000' => '各抽奖次数仅支持 0、100、500、1000、5000',
|
||||
'Current table does not support recycle bin' => '当前表不支持回收站功能',
|
||||
'DATA_NOT_FOUND' => '数据不存在',
|
||||
'DIRECTION_INVALID' => 'direction 必须为 0 或 1',
|
||||
'Data not found' => '数据不存在',
|
||||
'Deduct amount cannot exceed current balance' => '扣点数量不能大于当前余额',
|
||||
'Delete data error, please check' => '删除数据异常,请检查',
|
||||
'Dict type not found' => '字典类型不存在',
|
||||
'FAIL' => '失败',
|
||||
'Failed to create image resource' => '创建图片资源失败',
|
||||
'Failed to generate token' => '生成 token 失败',
|
||||
'Failed to get file resource' => '获取文件资源失败',
|
||||
'Failed to get login credential, please check' => '登录凭获取失败,请检查',
|
||||
'Failed to read database config' => '数据库配置读取失败',
|
||||
'Failed to save file' => '文件保存失败',
|
||||
'File format not supported for upload' => '不支持该格式的文件上传',
|
||||
'File generation not allowed in non-debug mode' => '非调试模式下,不允许生成文件',
|
||||
'File not found' => '文件不存在',
|
||||
'File size exceeds limit' => '文件大小超过限制',
|
||||
'Free pool config not found' => '免费奖池配置不存在',
|
||||
'Free tier probabilities (T1–T5) sum cannot exceed 100%' => '免费档位概率 T1~T5 之和不能超过 100%',
|
||||
'Free tier probability must be between 0 and 100%' => '免费档位概率每档只能 0-100%',
|
||||
'Frontend directory not found, must be same level as backend' => '前端目录查找失败,必须与后端目录为同级目录!',
|
||||
'INSUFFICIENT_BALANCE' => '平台币不足',
|
||||
'INSUFFICIENT_TICKETS' => '抽奖券不足',
|
||||
'Import file error, please upload correct xlsx file' => '导入文件错误,请上传正确的文件格式xlsx',
|
||||
'Insufficient balance' => '平台币不足',
|
||||
'Insufficient balance to transfer' => '余额不足,无法转出',
|
||||
'Insufficient lottery tickets' => '抽奖券不足',
|
||||
'Invalid DiceReward id exists' => '存在无效的 DiceReward id',
|
||||
'Invalid config ID exists' => '存在无效的配置ID',
|
||||
'Invalid file format' => '文件格式错误',
|
||||
'Invalid file type, cannot generate file' => '文件类型异常,无法生成指定文件!',
|
||||
'Invalid lottery ticket purchase' => '购买抽奖券错误',
|
||||
'Invalid or expired token' => 'token 无效',
|
||||
'Invalid parameters' => '参数错误',
|
||||
'Invalid params: player_id and type are required (3=add, 4=deduct)' => '参数错误:需要有效的 player_id 和 type(3=加点,4=扣点)',
|
||||
'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)' => '手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789)',
|
||||
'Invalid secret' => '密钥错误',
|
||||
'Invalid task type' => '任务类型异常',
|
||||
'LOTTERY_CONFIG_NOT_FOUND' => '奖池配置不存在',
|
||||
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => '未找到 name=default 的奖池配置,请先创建',
|
||||
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => '奖池配置不存在(需 name=default)',
|
||||
'Logged out successfully' => '已退出登录',
|
||||
'Login credential verification failed' => '登录凭证校验失败',
|
||||
'Lottery pool config not found (name=default required)' => '奖池配置不存在(需 name=default)',
|
||||
'MSG_022FA411' => '应用类型必须为plugin或者app',
|
||||
'MSG_04BF8179' => '数据不存在',
|
||||
'MSG_06F06DA6' => 'token 无效',
|
||||
'MSG_0A17D195' => '付费档位概率每档只能 0-100%',
|
||||
'MSG_0A9A3E28' => '禁止批量删除操作',
|
||||
'MSG_0BCF9CBC' => '测试次数仅支持 100、500、1000、5000、10000',
|
||||
'MSG_0CBB8FF6' => '服务超时,',
|
||||
'MSG_0D49B785' => '原密码错误',
|
||||
'MSG_0FE75E2C' => '切片上传服务必须在 HTTP 请求环境下调用',
|
||||
'MSG_146A3F0D' => '字典类型不存在',
|
||||
'MSG_17740DB3' => 'token 格式无效',
|
||||
'MSG_1798E4D4' => '模板不存在',
|
||||
'MSG_19E651B8' => 'coin 不能为空',
|
||||
'MSG_1A499109' => '文件不存在',
|
||||
'MSG_1BB27051' => 'auth-token 已过期',
|
||||
'MSG_1C1718A6' => '插件已经存在',
|
||||
'MSG_2240AD6D' => 'auth-token 无效',
|
||||
'MSG_2273437E' => '当前玩家余额%s小于%s无法继续游戏',
|
||||
'MSG_22C6787F' => '切片文件查找失败,请重新上传',
|
||||
'MSG_25BF8A8D' => '扣点数量不能大于当前余额',
|
||||
'MSG_2830AE01' => '服务超时,没有原因',
|
||||
'MSG_2ED0C7A8' => '插件的基础配置信息错误',
|
||||
'MSG_2EE75A5E' => '系统生成文件错误',
|
||||
'MSG_2EFE74EE' => '非调试模式下,不允许生成文件',
|
||||
'MSG_2F100DB4' => '不能操作比当前账户职级高的角色',
|
||||
'MSG_334CE26A' => '没有权限操作该数据',
|
||||
'MSG_35FB9BA0' => '不支持该格式的文件上传',
|
||||
'MSG_381A19AE' => '该上传模式不存在',
|
||||
'MSG_3A4A6DE6' => 'username 不能为空',
|
||||
'MSG_3A4FF81F' => '没有权限操作该部门数据',
|
||||
'MSG_3C99F7F7' => '奖励配置为空,请先维护 dice_reward_config',
|
||||
'MSG_3DBFEA33' => '文件格式错误',
|
||||
'MSG_43C4D703' => '该部门下存在用户,请先删除或者转移用户',
|
||||
'MSG_47FDBDD0' => '配置组未找到',
|
||||
'MSG_4CA58C61' => '修改数据异常,请检查',
|
||||
'MSG_4F1D271A' => '存在无效的 DiceReward id',
|
||||
'MSG_521593FB' => '请先设置应用名称',
|
||||
'MSG_557E5109' => '获取文件资源失败',
|
||||
'MSG_559AAE0E' => '没有权限操作该角色数据',
|
||||
'MSG_560E6D91' => '该方向下暂无可用路径配置',
|
||||
'MSG_5643EE10' => '生成 token 失败',
|
||||
'MSG_569EC863' => '当前表不支持回收站功能',
|
||||
'MSG_56B44907' => '目标分类不存在',
|
||||
'MSG_5CE17D6B' => 'auth-token 无效或已失效',
|
||||
'MSG_5FF3A2BE' => '数据库配置读取失败',
|
||||
'MSG_609A300B' => '平台币不足',
|
||||
'MSG_60B9FC38' => '登录凭获取失败,请检查',
|
||||
'MSG_64A3C830' => '用户不存在',
|
||||
'MSG_67C66962' => '未找到 name=default 的奖池配置,请先创建',
|
||||
'MSG_6C16260B' => '免费未选择奖池配置时,请填写免费自定义档位概率(T1~T5)',
|
||||
'MSG_6CA924A1' => '奖池配置不存在(需 name=default)',
|
||||
'MSG_6F00DFB2' => 'success',
|
||||
'MSG_7310FDB8' => '前端目录查找失败,必须与后端目录为同级目录!',
|
||||
'MSG_74E3CB84' => '暂无可用奖励配置',
|
||||
'MSG_75C6A69F' => '请携带 auth-token',
|
||||
'MSG_7845F2E9' => '删除数据异常,请检查',
|
||||
'MSG_86272B49' => 'fail',
|
||||
'MSG_8865D363' => 'coin 不能为 0',
|
||||
'MSG_8B6AA32A' => '不能将上级分类设置为当前分类的子分类',
|
||||
'MSG_8C2E3CE6' => '请重新登录(当前账号已在其他处登录)',
|
||||
'MSG_8FDBA3F1' => '该字典标识已存在',
|
||||
'MSG_91272513' => '购买抽奖券错误',
|
||||
'MSG_94EE6593' => '该插件的安装目录已经被占用',
|
||||
'MSG_9501E2EF' => '余额不足,无法转出',
|
||||
'MSG_950B6072' => '配置数据未找到',
|
||||
'MSG_9A01DFBF' => '该插件的基础配置信息不完善',
|
||||
'MSG_9D195F25' => '账号已被禁用,无法登录',
|
||||
'MSG_9EE0801C' => '无法打开文件,或者文件创建失败',
|
||||
'MSG_9F6B51C8' => '文件类型异常,无法生成指定文件!',
|
||||
'MSG_A049A679' => '该分类下存在子分类,请先删除子分类',
|
||||
'MSG_A3165463' => '仅超级管理员能够操作',
|
||||
'MSG_A4FB6212' => '文件保存失败',
|
||||
'MSG_A6A8EA8F' => '插件目录不存在',
|
||||
'MSG_A72A7DC6' => '该部门下存在子部门,请先删除子部门',
|
||||
'MSG_A778ABB9' => 'auth-token 格式无效',
|
||||
'MSG_ADA80442' => '请重新登录',
|
||||
'MSG_AE73E6F3' => '服务端未配置 API_AUTH_TOKEN_SECRET',
|
||||
'MSG_B387239D' => '付费档位概率 T1~T5 之和不能超过 100%',
|
||||
'MSG_B5C2F2F6' => '各抽奖次数仅支持 0、100、500、1000、5000',
|
||||
'MSG_B5CD5C51' => '测试记录不存在',
|
||||
'MSG_B720629D' => 'username、password 不能为空',
|
||||
'MSG_BA173F12' => '付费或免费至少一种方向次数之和大于 0',
|
||||
'MSG_BAC2EFB0' => '上级部门和当前部门不能相同',
|
||||
'MSG_BB3C5A3F' => 'direction 必须为 0 或 1',
|
||||
'MSG_BBD3198A' => '参数错误:需要有效的 player_id 和 type(3=加点,4=扣点)',
|
||||
'MSG_BD8AD1D3' => '手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789)',
|
||||
'MSG_BEB15D55' => '参数错误',
|
||||
'MSG_C2E4B3DC' => '任务类型异常',
|
||||
'MSG_C2F02095' => '抽奖券不足',
|
||||
'MSG_C3CB20DC' => '免费档位概率每档只能 0-100%',
|
||||
'MSG_C43809BC' => '操作失败:',
|
||||
'MSG_C548E557' => '缺少参数:agent_id、secret、time、signature 不能为空',
|
||||
'MSG_C5D5D5E1' => '不能将上级部门设置为当前部门的子部门',
|
||||
'MSG_C803EA6F' => '请注册',
|
||||
'MSG_C80C5EF5' => '创建图片资源失败',
|
||||
'MSG_C9BFC7E9' => '奖池配置不存在',
|
||||
'MSG_CDEA9DD8' => '您的登录凭证错误或者已过期,请重新登录',
|
||||
'MSG_D15C0759' => '密钥错误',
|
||||
'MSG_D1D1C0A0' => '模板目录不存在!',
|
||||
'MSG_D1E7769C' => '上级分类和当前分类不能相同',
|
||||
'MSG_D224020F' => '免费奖池配置不存在',
|
||||
'MSG_D75845B2' => '免费档位概率 T1~T5 之和不能超过 100%',
|
||||
'MSG_DB560C68' => '请执行 composer require phpmailer/phpmailer 并重启',
|
||||
'MSG_DEE31D19' => '时间戳已过期或无效,请同步时间',
|
||||
'MSG_DF93D5F9' => 'token 已过期,请重新登录',
|
||||
'MSG_E12FF883' => '文件大小超过限制',
|
||||
'MSG_E15B47C6' => '超级管理员禁止删除',
|
||||
'MSG_E1BFE655' => '未设置邮件配置',
|
||||
'MSG_E5849544' => '密码错误',
|
||||
'MSG_E66BC216' => '该菜单下存在子菜单,请先删除子菜单',
|
||||
'MSG_E6E6288B' => '系统默认分组,无法删除',
|
||||
'MSG_E84B2B0A' => '已退出登录',
|
||||
'MSG_E8C8EC80' => '存在无效的配置ID',
|
||||
'MSG_E96B26B9' => '平台币变动必须大于 0',
|
||||
'MSG_EEDAAC44' => '等待依赖安装',
|
||||
'MSG_F0F5F561' => '配置ID %s 不存在或档位为空',
|
||||
'MSG_F12E5DBA' => '奖励配置需覆盖 26 个格位(id 0-25 或 1-26),当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照',
|
||||
'MSG_F2643E83' => '登录凭证校验失败',
|
||||
'MSG_F58CB5C8' => '该部门下存在子分类,请先删除子分类',
|
||||
'MSG_F5F9FF11' => '付费奖池配置不存在',
|
||||
'MSG_F7BBA776' => '没有原因',
|
||||
'MSG_F8EB5084' => '签名验证失败',
|
||||
'MSG_FA5FF202' => '不能设置父级为自身',
|
||||
'MSG_FB4C0ADF' => '请选择要生成的表',
|
||||
'MSG_FBC50B18' => '玩家不存在',
|
||||
'MSG_FC1E3345' => '导入文件错误,请上传正确的文件格式xlsx',
|
||||
'MSG_FDADA275' => '付费未选择奖池配置时,请填写付费自定义档位概率(T1~T5)',
|
||||
'MSG_FE1B67CA' => '请携带 token',
|
||||
'Mail config not set' => '未设置邮件配置',
|
||||
'Missing parameters: agent_id, secret, time, signature are required' => '缺少参数:agent_id、secret、time、signature 不能为空',
|
||||
'NO_AVAILABLE_REWARD_CONFIG' => '暂无可用奖励配置',
|
||||
'No available reward config' => '暂无可用奖励配置',
|
||||
'No name=default pool config found, please create one first' => '未找到 name=default 的奖池配置,请先创建',
|
||||
'No permission to operate department data' => '没有权限操作该部门数据',
|
||||
'No permission to operate role data' => '没有权限操作该角色数据',
|
||||
'No permission to operate this data' => '没有权限操作该数据',
|
||||
'OLD_PASSWORD_WRONG' => '原密码错误',
|
||||
'Old password is incorrect' => '原密码错误',
|
||||
'Only super admin can perform this action' => '仅超级管理员能够操作',
|
||||
'Operation failed: ' => '操作失败:',
|
||||
'PASSWORD_WRONG' => '密码错误',
|
||||
'Paid pool config not found' => '付费奖池配置不存在',
|
||||
'Paid tier probabilities (T1–T5) sum cannot exceed 100%' => '付费档位概率 T1~T5 之和不能超过 100%',
|
||||
'Paid tier probability must be between 0 and 100%' => '付费档位概率每档只能 0-100%',
|
||||
'Parent category cannot be the same as current' => '上级分类和当前分类不能相同',
|
||||
'Parent department cannot be the same as current department' => '上级部门和当前部门不能相同',
|
||||
'Player not found' => '玩家不存在',
|
||||
'Please login again' => '请重新登录',
|
||||
'Please login again (account logged in elsewhere)' => '请重新登录(当前账号已在其他处登录)',
|
||||
'Please provide auth-token' => '请携带 auth-token',
|
||||
'Please provide token' => '请携带 token',
|
||||
'Please register' => '请注册',
|
||||
'Please run composer require phpmailer/phpmailer and restart' => '请执行 composer require phpmailer/phpmailer 并重启',
|
||||
'Please select tables to generate' => '请选择要生成的表',
|
||||
'Please set app name first' => '请先设置应用名称',
|
||||
'Plugin already exists' => '插件已经存在',
|
||||
'Plugin base config is incomplete' => '该插件的基础配置信息不完善',
|
||||
'Plugin base config is invalid' => '插件的基础配置信息错误',
|
||||
'Plugin directory not found' => '插件目录不存在',
|
||||
'Plugin install directory is already occupied' => '该插件的安装目录已经被占用',
|
||||
'Reward config is empty, please maintain dice_reward_config first' => '奖励配置为空,请先维护 dice_reward_config',
|
||||
'SUCCESS' => '成功',
|
||||
'SUPER_ADMIN_CANNOT_DELETE' => '超级管理员禁止删除',
|
||||
'Service timeout: ' => '服务超时,',
|
||||
'Signature verification failed' => '签名验证失败',
|
||||
'Sum of paid/free direction counts must be greater than 0' => '付费或免费至少一种方向次数之和大于 0',
|
||||
'Super admin cannot be deleted' => '超级管理员禁止删除',
|
||||
'System default group cannot be deleted' => '系统默认分组,无法删除',
|
||||
'System file generation error' => '系统生成文件错误',
|
||||
'TOKEN_EXPIRED_RELOGIN' => 'token 已过期,请重新登录',
|
||||
'TOKEN_FORMAT_INVALID' => 'token 格式无效',
|
||||
'TOKEN_INVALID' => 'token 无效',
|
||||
'TOKEN_REQUIRED' => '请携带 token',
|
||||
'Target category not found' => '目标分类不存在',
|
||||
'Template directory not found' => '模板目录不存在!',
|
||||
'Template not found' => '模板不存在',
|
||||
'Test count only supports 100, 500, 1000, 5000, 10000' => '测试次数仅支持 100、500、1000、5000、10000',
|
||||
'Test record not found' => '测试记录不存在',
|
||||
'This category has sub-categories, please delete them first' => '该部门下存在子分类,请先删除子分类',
|
||||
'This department has sub-departments, please delete them first' => '该部门下存在子部门,请先删除子部门',
|
||||
'This department has users, please delete or transfer them first' => '该部门下存在用户,请先删除或者转移用户',
|
||||
'This dict code already exists' => '该字典标识已存在',
|
||||
'This menu has sub-menus, please delete them first' => '该菜单下存在子菜单,请先删除子菜单',
|
||||
'Timestamp expired or invalid, please sync time' => '时间戳已过期或无效,请同步时间',
|
||||
'Token expired, please login again' => 'token 已过期,请重新登录',
|
||||
'Token format invalid' => 'token 格式无效',
|
||||
'USERNAME_PASSWORD_REQUIRED' => 'username、password 不能为空',
|
||||
'USERNAME_REQUIRED' => 'username 不能为空',
|
||||
'USER_NOT_FOUND' => '用户不存在',
|
||||
'Update data error, please check' => '修改数据异常,请检查',
|
||||
'Upload mode not found' => '该上传模式不存在',
|
||||
'User not found' => '用户不存在',
|
||||
'Waiting for dependencies to be installed' => '等待依赖安装',
|
||||
'When free pool is not selected, please fill free custom tier probabilities (T1–T5)' => '免费未选择奖池配置时,请填写免费自定义档位概率(T1~T5)',
|
||||
'When paid pool is not selected, please fill paid custom tier probabilities (T1–T5)' => '付费未选择奖池配置时,请填写付费自定义档位概率(T1~T5)',
|
||||
'Wrong password' => '密码错误',
|
||||
'Your login credential is invalid or expired, please login again' => '您的登录凭证错误或者已过期,请重新登录',
|
||||
'add failed' => '添加失败',
|
||||
'add success' => '添加成功',
|
||||
'admin already installed, to reinstall please delete env file and restart' => '管理后台已经安装!如需重新安装,请删除根目录env配置文件并重启',
|
||||
'all test data cleared' => '已清空所有测试数据',
|
||||
'auth-token expired' => 'auth-token 已过期',
|
||||
'auth-token format invalid' => 'auth-token 格式无效',
|
||||
'auth-token invalid' => 'auth-token 无效',
|
||||
'auth-token invalid or expired' => 'auth-token 无效或已失效',
|
||||
'captcha error' => '验证码错误',
|
||||
'clean success' => '清理成功',
|
||||
'clear cache success' => '清除缓存成功!',
|
||||
'clear failed: ' => '清空失败:',
|
||||
'coin cannot be 0' => 'coin 不能为 0',
|
||||
'coin is required' => 'coin 不能为空',
|
||||
'connection refused, please check database ip/port and ensure database is running' => 'Connection refused. 请确认数据库IP端口是否正确,数据库已经启动',
|
||||
'create reward mapping success' => '创建奖励对照成功',
|
||||
'database SQL file not found' => '数据库SQL文件不存在',
|
||||
'database already installed, please do not install again' => '数据库已经安装,请勿重复安装',
|
||||
'database connection timeout, please check ip/port and firewall/security group rules' => '数据库连接超时,请确认数据库IP端口是否正确,安全组及防火墙已经放行端口',
|
||||
'database username or password is incorrect' => '数据库用户名或密码错误',
|
||||
'delete failed' => '删除失败',
|
||||
'delete success' => '删除成功',
|
||||
'direction must be 0 (clockwise) or 1 (counterclockwise)' => 'direction 必须为 0(顺时针)或 1(逆时针)',
|
||||
'direction must be 0 or 1' => 'direction 必须为 0 或 1',
|
||||
'download failed' => '下载失败',
|
||||
'download success, please install in plugin list' => '下载成功,请在插件列表中安装',
|
||||
'execute success' => '执行成功',
|
||||
'execution failed' => '执行失败',
|
||||
'file size cannot exceed 5M' => '文件大小不能超过5M',
|
||||
'import success' => '导入成功',
|
||||
'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config' => '导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置',
|
||||
'install success' => '安装成功',
|
||||
'invalid parameters, please check' => '参数错误,请检查',
|
||||
'login expired or invalid, please login again' => '登录已过期或用户信息无效,请重新登录',
|
||||
'missing parameter id' => '缺少参数 id',
|
||||
'missing parameter status' => '缺少参数 status',
|
||||
'missing player_id' => '缺少 player_id',
|
||||
'no permission to delete selected data' => '无权限删除所选数据',
|
||||
'no permission to operate this player' => '无权限操作该玩家',
|
||||
'no permission to update this record' => '无权限修改该记录',
|
||||
'no permission to view this record' => '无权限查看该记录',
|
||||
'not found' => '未查找到信息',
|
||||
'not logged in' => '未登录',
|
||||
'operation failed' => '操作失败',
|
||||
'operation success' => '操作成功',
|
||||
'operation type must be 3 (add) or 4 (deduct)' => '操作类型必须为 3=加点 或 4=扣点',
|
||||
'optimize success' => '优化成功',
|
||||
'parameter items must be an array' => '参数 items 必须为数组',
|
||||
'please input email' => '请输入邮箱',
|
||||
'please login first' => '请先登录',
|
||||
'please provide direction (0=clockwise, 1=counterclockwise)' => '请传入 direction(0=顺时针 1=逆时针)',
|
||||
'please provide record_id' => '请传入 record_id',
|
||||
'please select cache to delete' => '请选择要删除的缓存',
|
||||
'please select data to delete' => '请选择要删除的数据',
|
||||
'please select player' => '请选择玩家',
|
||||
'please specify test record' => '请指定测试记录',
|
||||
'record not found' => '记录不存在',
|
||||
'reload success' => '重载成功',
|
||||
'reset success' => '重置成功',
|
||||
'save success' => '保存成功',
|
||||
'send failed, please check logs' => '发送失败,请查看日志',
|
||||
'send success' => '发送成功',
|
||||
'super admin cannot reset password' => '超级管理员不允许重置密码',
|
||||
'test data cleared' => '已清空测试数据',
|
||||
'too many requests, please try again later' => '请求过于频繁,请稍后再试',
|
||||
'uninstall plugin success' => '卸载插件成功',
|
||||
'update failed' => '修改失败',
|
||||
'update success' => '修改成功',
|
||||
'upload failed, please upload zip file' => '文件格式上传失败,请选择zip格式文件上传',
|
||||
'upload file validation failed' => '上传文件校验失败',
|
||||
'uploaded file not found' => '未找到上传文件',
|
||||
'username is required' => 'username 不能为空',
|
||||
'version id is required' => '版本ID不能为空',
|
||||
];
|
||||
50
server/scripts/gen_api_msg_keys.php
Normal file
50
server/scripts/gen_api_msg_keys.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 将 “中文=>英文” 的历史映射(可临时放在 $legacy 变量里)转换为英文 key 映射:
|
||||
* - resource/translations/api/en.php: key=MSG_XXXXXXXX, value=英文
|
||||
* - resource/translations/api/zh.php: key=MSG_XXXXXXXX, value=中文
|
||||
*
|
||||
* 同时保留 resource/translations/api/{zh,en}.php 中已存在的显式英文错误码。
|
||||
*/
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
|
||||
$enPath = $root . '/resource/translations/api/en.php';
|
||||
$zhPath = $root . '/resource/translations/api/zh.php';
|
||||
|
||||
$legacy = [];
|
||||
$en = is_file($enPath) ? (require $enPath) : [];
|
||||
$zh = is_file($zhPath) ? (require $zhPath) : [];
|
||||
|
||||
foreach ($legacy as $cn => $enVal) {
|
||||
if (!is_string($cn) || $cn === '' || !is_string($enVal)) {
|
||||
continue;
|
||||
}
|
||||
$key = 'MSG_' . strtoupper(sprintf('%08X', crc32($cn)));
|
||||
if (!isset($en[$key])) {
|
||||
$en[$key] = $enVal;
|
||||
}
|
||||
if (!isset($zh[$key])) {
|
||||
$zh[$key] = $cn;
|
||||
}
|
||||
}
|
||||
|
||||
$dump = static function (array $arr): string {
|
||||
ksort($arr);
|
||||
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
|
||||
foreach ($arr as $k => $v) {
|
||||
$k = str_replace("'", "\\'", (string) $k);
|
||||
$v = str_replace("'", "\\'", (string) $v);
|
||||
$out .= " '{$k}' => '{$v}',\n";
|
||||
}
|
||||
$out .= "];\n";
|
||||
return $out;
|
||||
};
|
||||
|
||||
file_put_contents($enPath, $dump($en));
|
||||
file_put_contents($zhPath, $dump($zh));
|
||||
|
||||
echo "done\n";
|
||||
|
||||
184
server/scripts/replace_cn_messages_with_en.php
Normal file
184
server/scripts/replace_cn_messages_with_en.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 批量把代码中的中文 message 替换为英文短句(显式英文,不是错误码):
|
||||
* - return $this->success('中文...')
|
||||
* - return $this->fail('中文...', ...)
|
||||
* - throw new ApiException('中文...', ...)
|
||||
*
|
||||
* 英文短句来源:resource/translations/api/en.php 与 zh.php 中的 MSG_ 对照(crc32 中文生成 key)。
|
||||
* 同时自动把“英文短句 => 英文/中文”写入 resource/translations/api/{en,zh}.php(Webman 标准路径)。
|
||||
*
|
||||
* 用法:
|
||||
* php server/scripts/replace_cn_messages_with_en.php
|
||||
*/
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$serverDir = $root;
|
||||
|
||||
$enPath = $root . '/resource/translations/api/en.php';
|
||||
$zhPath = $root . '/resource/translations/api/zh.php';
|
||||
|
||||
$enMap = is_file($enPath) ? (require $enPath) : [];
|
||||
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
|
||||
|
||||
/** @var array<string, string> $cnToEn */
|
||||
$cnToEn = [];
|
||||
foreach ($zhMap as $k => $cn) {
|
||||
if (!is_string($k) || !is_string($cn)) {
|
||||
continue;
|
||||
}
|
||||
if (strncmp($k, 'MSG_', 4) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$en = $enMap[$k] ?? null;
|
||||
if (is_string($en) && $en !== '') {
|
||||
$cnToEn[$cn] = $en;
|
||||
}
|
||||
}
|
||||
|
||||
$fallbackCn = [
|
||||
'添加成功' => 'add success',
|
||||
'修改成功' => 'update success',
|
||||
'删除成功' => 'delete success',
|
||||
'操作成功' => 'operation success',
|
||||
'保存成功' => 'save success',
|
||||
'执行成功' => 'execute success',
|
||||
'安装成功' => 'install success',
|
||||
'导入成功' => 'import success',
|
||||
'发送成功' => 'send success',
|
||||
'重载成功' => 'reload success',
|
||||
'重置成功' => 'reset success',
|
||||
'卸载插件成功' => 'uninstall plugin success',
|
||||
'优化成功' => 'optimize success',
|
||||
'清理成功' => 'clean success',
|
||||
'清除缓存成功!' => 'clear cache success',
|
||||
'已清空测试数据' => 'test data cleared',
|
||||
'已清空所有测试数据' => 'all test data cleared',
|
||||
'创建奖励对照成功' => 'create reward mapping success',
|
||||
'导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置' => 'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config',
|
||||
'下载成功,请在插件列表中安装' => 'download success, please install in plugin list',
|
||||
];
|
||||
|
||||
$containsCn = static function (string $s): bool {
|
||||
return preg_match('/[\x{4e00}-\x{9fff}]/u', $s) === 1;
|
||||
};
|
||||
|
||||
$quote = static function (string $s): string {
|
||||
return "'" . str_replace("'", "\\'", $s) . "'";
|
||||
};
|
||||
|
||||
$dump = static function (array $arr): string {
|
||||
ksort($arr);
|
||||
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
|
||||
foreach ($arr as $k => $v) {
|
||||
$k = str_replace("'", "\\'", (string) $k);
|
||||
$v = str_replace("'", "\\'", (string) $v);
|
||||
$out .= " '{$k}' => '{$v}',\n";
|
||||
}
|
||||
$out .= "];\n";
|
||||
return $out;
|
||||
};
|
||||
|
||||
$files = [];
|
||||
$it = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
foreach ($it as $file) {
|
||||
/** @var SplFileInfo $file */
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
$path = $file->getPathname();
|
||||
if (substr($path, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
// 跳过 translations 目录与 scripts 自己,避免自我替换
|
||||
$norm = str_replace('\\', '/', $path);
|
||||
if (str_contains($norm, '/resource/translations/')) {
|
||||
continue;
|
||||
}
|
||||
if (str_contains($norm, '/scripts/replace_cn_messages_with_en.php')) {
|
||||
continue;
|
||||
}
|
||||
$files[] = $path;
|
||||
}
|
||||
|
||||
$totalReplaced = 0;
|
||||
$touchedFiles = 0;
|
||||
$addedKeys = 0;
|
||||
|
||||
foreach ($files as $path) {
|
||||
$content = file_get_contents($path);
|
||||
if (!is_string($content) || $content === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$replacedInFile = 0;
|
||||
$newContent = $content;
|
||||
|
||||
// 只处理单引号字符串:'...'
|
||||
$patterns = [
|
||||
// return $this->success('中文')
|
||||
'/(\$this->success\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'success',
|
||||
// return $this->success($data, '中文')
|
||||
'/(\$this->success\([^\\)]*?,\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'success_msg',
|
||||
// return $this->fail('中文', ...)
|
||||
'/(\$this->fail\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'fail',
|
||||
// throw new ApiException('中文', ...)
|
||||
'/(throw\s+new\s+ApiException\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'exception',
|
||||
];
|
||||
|
||||
foreach ($patterns as $regex => $type) {
|
||||
$newContent = preg_replace_callback($regex, function (array $m) use (
|
||||
$containsCn,
|
||||
$quote,
|
||||
&$cnToEn,
|
||||
$fallbackCn,
|
||||
&$enMap,
|
||||
&$zhMap,
|
||||
&$replacedInFile,
|
||||
&$addedKeys,
|
||||
$type
|
||||
) {
|
||||
$prefix = $m[1];
|
||||
$raw = $m[2];
|
||||
$cn = stripcslashes($raw);
|
||||
if (!$containsCn($cn)) {
|
||||
return $m[0];
|
||||
}
|
||||
$en = $cnToEn[$cn] ?? ($fallbackCn[$cn] ?? null);
|
||||
if (!is_string($en) || $en === '') {
|
||||
return $m[0];
|
||||
}
|
||||
|
||||
// 写入翻译表:英文短句作为 key
|
||||
if (!isset($enMap[$en])) {
|
||||
$enMap[$en] = $en;
|
||||
$addedKeys++;
|
||||
}
|
||||
if (!isset($zhMap[$en])) {
|
||||
$zhMap[$en] = $cn;
|
||||
$addedKeys++;
|
||||
}
|
||||
|
||||
$replacedInFile++;
|
||||
return $prefix . $quote($en);
|
||||
}, $newContent) ?? $newContent;
|
||||
}
|
||||
|
||||
if ($replacedInFile > 0 && $newContent !== $content) {
|
||||
file_put_contents($path, $newContent);
|
||||
$totalReplaced += $replacedInFile;
|
||||
$touchedFiles++;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($enPath, $dump($enMap));
|
||||
file_put_contents($zhPath, $dump($zhMap));
|
||||
|
||||
echo "touched_files={$touchedFiles}\n";
|
||||
echo "replaced={$totalReplaced}\n";
|
||||
echo "added_translation_pairs={$addedKeys}\n";
|
||||
|
||||
108
server/scripts/replace_e_crc_with_en_phrase.php
Normal file
108
server/scripts/replace_e_crc_with_en_phrase.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 修复替换结果:把代码里的 'E_XXXXXXXX'(crc32 的十六进制)替换为真正英文短句。
|
||||
* 英文短句来源:resource/translations/api/en.php 的 MSG_XXXXXXXX。
|
||||
*
|
||||
* 同时确保 translations/api/{en,zh}.php 中包含:
|
||||
* - key=英文短句, en=英文短句
|
||||
* - key=英文短句, zh=对应中文
|
||||
*/
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$serverDir = $root;
|
||||
|
||||
$enPath = $root . '/resource/translations/api/en.php';
|
||||
$zhPath = $root . '/resource/translations/api/zh.php';
|
||||
|
||||
$enMap = is_file($enPath) ? (require $enPath) : [];
|
||||
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
|
||||
|
||||
$dump = static function (array $arr): string {
|
||||
ksort($arr);
|
||||
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
|
||||
foreach ($arr as $k => $v) {
|
||||
$k = str_replace("'", "\\'", (string) $k);
|
||||
$v = str_replace("'", "\\'", (string) $v);
|
||||
$out .= " '{$k}' => '{$v}',\n";
|
||||
}
|
||||
$out .= "];\n";
|
||||
return $out;
|
||||
};
|
||||
|
||||
$files = [];
|
||||
$it = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
foreach ($it as $file) {
|
||||
/** @var SplFileInfo $file */
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
$path = $file->getPathname();
|
||||
if (substr($path, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
$norm = str_replace('\\', '/', $path);
|
||||
if (str_contains($norm, '/resource/translations/')) {
|
||||
continue;
|
||||
}
|
||||
if (str_contains($norm, '/scripts/')) {
|
||||
continue;
|
||||
}
|
||||
$files[] = $path;
|
||||
}
|
||||
|
||||
$touchedFiles = 0;
|
||||
$replaced = 0;
|
||||
$added = 0;
|
||||
|
||||
foreach ($files as $path) {
|
||||
$content = file_get_contents($path);
|
||||
if (!is_string($content) || $content === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newContent = preg_replace_callback(
|
||||
"/(['\"])E_([0-9A-Fa-f]{8})\\1/",
|
||||
function (array $m) use (&$enMap, &$zhMap, &$replaced, &$added) {
|
||||
$hex = strtoupper($m[2]);
|
||||
$msgKey = 'MSG_' . $hex;
|
||||
$en = $enMap[$msgKey] ?? null;
|
||||
$zh = $zhMap[$msgKey] ?? null;
|
||||
if (!is_string($en) || $en === '') {
|
||||
return $m[0];
|
||||
}
|
||||
if (!is_string($zh) || $zh === '') {
|
||||
$zh = $msgKey;
|
||||
}
|
||||
|
||||
if (!isset($enMap[$en])) {
|
||||
$enMap[$en] = $en;
|
||||
$added++;
|
||||
}
|
||||
if (!isset($zhMap[$en])) {
|
||||
$zhMap[$en] = $zh;
|
||||
$added++;
|
||||
}
|
||||
|
||||
$replaced++;
|
||||
return "'" . str_replace("'", "\\'", $en) . "'";
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
if (is_string($newContent) && $newContent !== $content) {
|
||||
file_put_contents($path, $newContent);
|
||||
$touchedFiles++;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($enPath, $dump($enMap));
|
||||
file_put_contents($zhPath, $dump($zhMap));
|
||||
|
||||
echo "touched_files={$touchedFiles}\n";
|
||||
echo "replaced={$replaced}\n";
|
||||
echo "added_translation_pairs={$added}\n";
|
||||
|
||||
215
server/scripts/replace_e_keys_using_git_diff.php
Normal file
215
server/scripts/replace_e_keys_using_git_diff.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 通过 git diff 恢复 E_XXXXXXXX 对应的原中文,并替换为英文短句:
|
||||
* - 在 server 下查找 "'E_XXXXXXXX'" 并替换为 "'<english phrase>'"
|
||||
* - 同时写入 resource/translations/api/{en,zh}.php:english=>english / english=>中文
|
||||
*
|
||||
* 英文短句来源优先级:
|
||||
* 1) resource/translations/api/en.php 与 zh.php 中的 MSG_ 对照(中文=>英文)
|
||||
* 2) 内置常用中文短语翻译表
|
||||
*/
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$repoRoot = dirname($root);
|
||||
|
||||
$enPath = $root . '/resource/translations/api/en.php';
|
||||
$zhPath = $root . '/resource/translations/api/zh.php';
|
||||
|
||||
$enMap = is_file($enPath) ? (require $enPath) : [];
|
||||
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
|
||||
|
||||
/** @var array<string, string> $cnToEn 基于 MSG_ 的中文=>英文 */
|
||||
$cnToEn = [];
|
||||
foreach ($zhMap as $k => $cn) {
|
||||
if (!is_string($k) || !is_string($cn)) {
|
||||
continue;
|
||||
}
|
||||
if (strncmp($k, 'MSG_', 4) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$en = $enMap[$k] ?? null;
|
||||
if (is_string($en) && $en !== '') {
|
||||
$cnToEn[$cn] = $en;
|
||||
}
|
||||
}
|
||||
|
||||
/** 常用中文短语翻译(兜底) */
|
||||
$fallbackCn = [
|
||||
'未查找到信息' => 'not found',
|
||||
'记录不存在' => 'record not found',
|
||||
'数据不存在' => 'data not found',
|
||||
'添加失败' => 'add failed',
|
||||
'修改失败' => 'update failed',
|
||||
'删除失败' => 'delete failed',
|
||||
'请选择要删除的数据' => 'please select data to delete',
|
||||
'参数错误,请检查' => 'invalid parameters, please check',
|
||||
'参数错误,请检查参数' => 'invalid parameters, please check',
|
||||
'操作失败' => 'operation failed',
|
||||
'执行失败' => 'execution failed',
|
||||
'请先登录' => 'please login first',
|
||||
'未登录' => 'not logged in',
|
||||
'下载失败' => 'download failed',
|
||||
'请求过于频繁,请稍后再试' => 'too many requests, please try again later',
|
||||
'验证码错误' => 'captcha error',
|
||||
'请选择要删除的缓存' => 'please select cache to delete',
|
||||
'请选择要删除的数据' => 'please select data to delete',
|
||||
'请选择要生成的表' => 'please select tables to generate',
|
||||
'发送失败,请查看日志' => 'send failed, please check logs',
|
||||
'请输入邮箱' => 'please input email',
|
||||
'版本ID不能为空' => 'version id is required',
|
||||
'上传文件校验失败' => 'upload file validation failed',
|
||||
'文件大小不能超过5M' => 'file size cannot exceed 5M',
|
||||
'文件格式上传失败,请选择zip格式文件上传' => 'upload failed, please upload zip file',
|
||||
'登录已过期或用户信息无效,请重新登录' => 'login expired or invalid, please login again',
|
||||
'超级管理员不允许重置密码' => 'super admin cannot reset password',
|
||||
'未找到上传文件' => 'uploaded file not found',
|
||||
'参数 items 必须为数组' => 'parameter items must be an array',
|
||||
'缺少参数 id' => 'missing parameter id',
|
||||
'缺少参数 status' => 'missing parameter status',
|
||||
'缺少 player_id' => 'missing player_id',
|
||||
'缺少参数:agent_id、secret、time、signature 不能为空' => 'missing parameters: agent_id, secret, time, signature are required',
|
||||
'无权限查看该记录' => 'no permission to view this record',
|
||||
'无权限修改该记录' => 'no permission to update this record',
|
||||
'无权限删除所选数据' => 'no permission to delete selected data',
|
||||
'无权限操作该玩家' => 'no permission to operate this player',
|
||||
'请选择玩家' => 'please select player',
|
||||
'操作类型必须为 3=加点 或 4=扣点' => 'operation type must be 3 (add) or 4 (deduct)',
|
||||
'请指定测试记录' => 'please specify test record',
|
||||
'请传入 record_id' => 'please provide record_id',
|
||||
'请传入 direction(0=顺时针 1=逆时针)' => 'please provide direction (0=clockwise, 1=counterclockwise)',
|
||||
'direction 必须为 0(顺时针)或 1(逆时针)' => 'direction must be 0 (clockwise) or 1 (counterclockwise)',
|
||||
'清空失败:' => 'clear failed: ',
|
||||
'管理后台已经安装!如需重新安装,请删除根目录env配置文件并重启' => 'admin already installed, to reinstall please delete env file and restart',
|
||||
'数据库用户名或密码错误' => 'database username or password is incorrect',
|
||||
'Connection refused. 请确认数据库IP端口是否正确,数据库已经启动' => 'connection refused, please check database ip/port and ensure database is running',
|
||||
'数据库连接超时,请确认数据库IP端口是否正确,安全组及防火墙已经放行端口' => 'database connection timeout, please check ip/port and firewall/security group rules',
|
||||
'数据库已经安装,请勿重复安装' => 'database already installed, please do not install again',
|
||||
'数据库SQL文件不存在' => 'database SQL file not found',
|
||||
];
|
||||
|
||||
$dump = static function (array $arr): string {
|
||||
ksort($arr);
|
||||
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
|
||||
foreach ($arr as $k => $v) {
|
||||
$k = str_replace("'", "\\'", (string) $k);
|
||||
$v = str_replace("'", "\\'", (string) $v);
|
||||
$out .= " '{$k}' => '{$v}',\n";
|
||||
}
|
||||
$out .= "];\n";
|
||||
return $out;
|
||||
};
|
||||
|
||||
$diff = shell_exec('git -C ' . escapeshellarg($repoRoot) . ' diff -U0 -- server');
|
||||
if (!is_string($diff) || $diff === '') {
|
||||
echo "no diff\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/** @var array<string, string> $hexToCn */
|
||||
$hexToCn = [];
|
||||
$lines = preg_split("/\r\n|\n|\r/", $diff) ?: [];
|
||||
$prevCn = null;
|
||||
foreach ($lines as $line) {
|
||||
// - return $this->fail('未查找到信息');
|
||||
if (preg_match("/^\\-.*'([^']*?)'.*$/u", $line, $m) === 1) {
|
||||
$maybeCn = $m[1];
|
||||
if (preg_match('/[\x{4e00}-\x{9fff}]/u', $maybeCn) === 1) {
|
||||
$prevCn = $maybeCn;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// + return $this->fail('E_FC6490F8');
|
||||
if ($prevCn !== null && preg_match("/^\\+.*'E_([0-9A-Fa-f]{8})'.*$/", $line, $m) === 1) {
|
||||
$hexToCn[strtoupper($m[1])] = $prevCn;
|
||||
$prevCn = null;
|
||||
continue;
|
||||
}
|
||||
// reset when encountering unrelated added/removed line
|
||||
if (strlen($line) > 0 && ($line[0] === '+' || $line[0] === '-')) {
|
||||
$prevCn = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hexToCn === []) {
|
||||
echo "no E_ mappings found in diff\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// 替换代码中的 E_XXXXXXXX
|
||||
$serverDir = $root;
|
||||
$files = [];
|
||||
$it = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
foreach ($it as $file) {
|
||||
/** @var SplFileInfo $file */
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
$path = $file->getPathname();
|
||||
if (substr($path, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
$norm = str_replace('\\', '/', $path);
|
||||
if (str_contains($norm, '/resource/translations/')) {
|
||||
continue;
|
||||
}
|
||||
if (str_contains($norm, '/scripts/')) {
|
||||
continue;
|
||||
}
|
||||
$files[] = $path;
|
||||
}
|
||||
|
||||
$touched = 0;
|
||||
$replaced = 0;
|
||||
$addedPairs = 0;
|
||||
|
||||
foreach ($files as $path) {
|
||||
$content = file_get_contents($path);
|
||||
if (!is_string($content) || $content === '') {
|
||||
continue;
|
||||
}
|
||||
$new = preg_replace_callback(
|
||||
"/(['\"])E_([0-9A-Fa-f]{8})\\1/",
|
||||
function (array $m) use (&$enMap, &$zhMap, &$replaced, &$addedPairs, $hexToCn, $cnToEn, $fallbackCn) {
|
||||
$hex = strtoupper($m[2]);
|
||||
$cn = $hexToCn[$hex] ?? null;
|
||||
if (!is_string($cn) || $cn === '') {
|
||||
return $m[0];
|
||||
}
|
||||
|
||||
$en = $cnToEn[$cn] ?? ($fallbackCn[$cn] ?? null);
|
||||
if (!is_string($en) || $en === '') {
|
||||
return $m[0];
|
||||
}
|
||||
|
||||
if (!isset($enMap[$en])) {
|
||||
$enMap[$en] = $en;
|
||||
$addedPairs++;
|
||||
}
|
||||
if (!isset($zhMap[$en])) {
|
||||
$zhMap[$en] = $cn;
|
||||
$addedPairs++;
|
||||
}
|
||||
|
||||
$replaced++;
|
||||
return "'" . str_replace("'", "\\'", $en) . "'";
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
if (is_string($new) && $new !== $content) {
|
||||
file_put_contents($path, $new);
|
||||
$touched++;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($enPath, $dump($enMap));
|
||||
file_put_contents($zhPath, $dump($zhMap));
|
||||
|
||||
echo "touched_files={$touched}\n";
|
||||
echo "replaced={$replaced}\n";
|
||||
echo "added_translation_pairs={$addedPairs}\n";
|
||||
|
||||
Reference in New Issue
Block a user