Compare commits
53 Commits
f6b4fb99f0
...
master-v3
| Author | SHA1 | Date | |
|---|---|---|---|
| ef684a1c55 | |||
| a8973d4e47 | |||
| 9f42cffd18 | |||
| edd870457f | |||
| 7493c4e400 | |||
| b0e5a3f5c0 | |||
| 6ed34b97df | |||
| d54a9c9281 | |||
| afd6113927 | |||
| 2f05ac0cd9 | |||
| ded5e82e16 | |||
| e2273ef41c | |||
| 0bdab95ab7 | |||
| cfc6537f97 | |||
| e32f3890f1 | |||
| 77ec0dcade | |||
| d72a8487a8 | |||
| 7596007a5a | |||
| 1b448833c6 | |||
| 748ee12a52 | |||
| d793a511ee | |||
| f8cf85dd01 | |||
| 6c6971c4bf | |||
| 60833aa6ff | |||
| d0d82399dc | |||
| 5b209da678 | |||
| d10dc81fc7 | |||
| 6b9fb0c26e | |||
| 9b4104fc0e | |||
| ce9062e186 | |||
| 1027612cc0 | |||
| 5ef8ee8bc5 | |||
| bd402aa97d | |||
| 68092759d3 | |||
| 8702cb0571 | |||
| ca620eb536 | |||
| 8684fdc9f0 | |||
| d72868eb76 | |||
| 6ff65afcb5 | |||
| b689a40595 | |||
| f9f8a1e169 | |||
| 3dbd68829a | |||
| 333e85f7d9 | |||
| db0e420a8f | |||
| f63616e735 | |||
| bdf50e61f5 | |||
| e7b8f4cae9 | |||
| d4cf708bc1 | |||
| eb8123c7b3 | |||
| 683bd5d97a | |||
| 150d31eac5 | |||
| 1892c7bcb7 | |||
| 5b5e923a0b |
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`。
|
||||
|
||||
199
README.md
199
README.md
@@ -1,99 +1,146 @@
|
||||
<p align="center">
|
||||
<img src="https://saithink.top/images/logo.png" width="120" />
|
||||
</p>
|
||||
<p align="center">
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=License&value=MIT" />
|
||||
<img src="https://svg.hamm.cn/badge.svg?key=Version&value=6.x" />
|
||||
</p>
|
||||
# 大富翁 · 摇色子 — 项目文档
|
||||
|
||||
<div style="padding:18px;max-width: 1024px;margin:0 auto;">
|
||||
<h1>SaiAdmin 6.x</h1>
|
||||
|
||||
## 项目简介
|
||||
|
||||
SaiAdmin 是一个基于 [Webman](https://www.workerman.net/webman) 的高性能后台管理系统插件。它提供了完整的权限管理、系统配置、代码生成等功能,帮助开发者快速构建企业级应用。
|
||||
本文描述**业务玩法**与**服务端抽奖/结算机制**,便于产品、运营与二次开发对齐实现。接口路径、鉴权与联调细节见根目录 [`API对接文档.md`](API对接文档.md)。
|
||||
|
||||
---
|
||||
|
||||
## ✨ 核心特性
|
||||
## 1. 项目概述
|
||||
|
||||
- **🚀 高性能** - 基于 Webman 常驻内存框架,性能优异
|
||||
- **🔐 完整权限系统** - RBAC 权限模型,支持用户、角色、部门、岗位管理
|
||||
- **📝 代码生成器** - 一键生成 CRUD 代码,提升开发效率
|
||||
- **⚡ 双 ORM 支持** - 同时支持 ThinkORM 和 Eloquent ORM
|
||||
- **🔧 插件化架构** - 支持插件扩展,便于功能模块化
|
||||
- **📊 系统监控** - 内置服务器监控、缓存管理功能
|
||||
- **📋 日志系统** - 完整的登录日志和操作日志记录
|
||||
- **形态**:平台玩家使用「平台币」参与摇五颗标准六面骰(点数各 1–6),结果对应棋盘/奖励配置;后台可配置档位权重、奖池、杀分策略与展示文案(含中英文)。
|
||||
- **服务端**:PHP [Webman](https://www.workerman.net/webman)(`server/`),玩家与平台接口在 `app/api`;骰子业务模型在 `app/dice`。
|
||||
- **管理端**:前端工程 `saiadmin-artd/`(与 SaiAdmin 插件体系配套)。
|
||||
|
||||
## 🛠️ 功能模块
|
||||
---
|
||||
|
||||
### 系统管理
|
||||
## 2. 核心概念
|
||||
|
||||
| 模块 | 说明 |
|
||||
| ---------- | -------------------------------- |
|
||||
| 用户管理 | 用户增删改查、密码管理、缓存清理 |
|
||||
| 角色管理 | 角色 CRUD、菜单权限分配 |
|
||||
| 部门管理 | 组织架构管理、树形结构 |
|
||||
| 岗位管理 | 岗位信息维护、Excel 模板导入导出 |
|
||||
| 菜单管理 | 菜单配置、按钮权限 |
|
||||
| 字典管理 | 字典类型与字典数据维护 |
|
||||
| 附件管理 | 文件上传、分类管理、资源移动 |
|
||||
| 系统配置 | 分组配置、邮件设置、动态参数 |
|
||||
| 日志管理 | 登录日志、操作日志查询与清理 |
|
||||
| 服务监控 | 服务器状态、缓存信息、一键清理 |
|
||||
| 数据表维护 | 数据表结构、表优化、碎片整理 |
|
||||
| 概念 | 说明 |
|
||||
| --- | --- |
|
||||
| **平台币 `coin`** | 玩家钱包余额;付费开局、购买套餐、中奖结算均围绕该字段。 |
|
||||
| **注数 `ante`** | 倍数因子,须存在于表 `dice_ante_config` 的 `mult` 中;接口 `/api/game/anteConfig` 返回可选注数。 |
|
||||
| **单注费用** | 付费抽奖时,开局前扣除 **`ante × 1`** 平台币(代码常量 `UNIT_COST = 1`,即「单注 1 币」口径)。 |
|
||||
| **方向 `direction`** | 开局参数:`0` 与 `1` 对应两套奖励数据(顺时针/逆时针或「无 / 中奖」分支,由前端与配置表共同约定);服务端在 **档位确定后**,按当前方向从 `DiceReward` 缓存结构中取该档位下的条目再按权重抽取。 |
|
||||
| **档位 T1–T5** | 中奖层级;先抽档位,再在该档位 + 当前方向下按 `weight` 抽一条奖励配置。 |
|
||||
| **`grid_number`(5–30)** | 与「五颗骰子点数之和」一致:最小 5(全 1),最大 30(全 6);用于关联奖励行与后续生成 `roll_array`。 |
|
||||
| **`real_ev`** | 奖励配置中的期望调节项;**普通中奖**结算为 **`real_ev × ante`**(付费局在开局已扣 `ante×1`,净效果依 `real_ev` 而定)。 |
|
||||
|
||||
### 开发工具
|
||||
---
|
||||
|
||||
| 模块 | 说明 |
|
||||
| -------- | ---------------------------- |
|
||||
| 代码生成 | 根据数据表自动生成 CRUD 代码 |
|
||||
| 定时任务 | Crontab 任务管理、执行日志 |
|
||||
## 3. 玩法流程(玩家视角)
|
||||
|
||||
<h1>学习</h1>
|
||||
1. **登录 / 进游戏**
|
||||
平台侧通过 `/api/v1/getGameUrl` 或玩家侧 `/api/user/Login` 换取 token,打开前端页面。
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://saithink.top" target="_blank">主页 / Home page</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://saithink.top/documents/v6/" target="_blank">文档 / Document</a>
|
||||
</li>
|
||||
</ul>
|
||||
2. **(可选)购买「抽奖券」套餐**
|
||||
`POST /api/game/buyLotteryTickets`,`count` 仅支持 `1`、`5`、`10`:
|
||||
- 1:1 币 → 1 次付费计数 + 0 次赠送
|
||||
- 5:5 币 → 5 次付费 + **1 次赠送**(共 6 次计入总次数)
|
||||
- 10:10 币 → 10 次付费 + **3 次赠送**(共 13 次)
|
||||
|
||||
会更新玩家身上的 `total_ticket_count` / `paid_ticket_count` / `free_ticket_count`,并记钱包与券流水。
|
||||
|
||||
<h1>演示地址</h1>
|
||||
<p>演示地址: <a href="http://v6.saithink.top" target="_blank">http://v6.saithink.top</a></p>
|
||||
<p>演示账号:admin</p>
|
||||
<p>演示密码:123456</p>
|
||||
3. **开局抽奖**
|
||||
`POST /api/game/playStart`,需传 **`direction`(0 或 1)** 与 **`ante`(正整数,且须在底注配置中)**。
|
||||
|
||||
<h1>共同交流</h1>
|
||||
4. **付费 vs 免费**
|
||||
- **免费抽奖**:当 `free_ticket_count > 0` 时,本局视为免费类型:不扣 `ante×1`,但会消耗 **1 次** `free_ticket_count`。
|
||||
- **付费抽奖**:不依赖「券张数是否大于 0」;只要非免费局,开局前扣 **`ante × 1`**。
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center" valign="middle">
|
||||
<img src="https://saithink.top/images/me.png" class="no-zoom" width="180px">
|
||||
<p>saiadmin交流群(添加我微信备注"saiadmin")</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
> **重要**:当前实现已**不再用「抽奖券张数」作为能否开局的条件**;`buyLotteryTickets` 更新的是统计与赠送次数,**真正开局仍看余额、注数、免费次数等规则**(见下节)。
|
||||
|
||||
<h1>支持项目</h1>
|
||||
5. **免费注数锁定**
|
||||
若上一局因命中 **T5** 赠送了免费次数,服务端会缓存「免费局须与触发时相同的 `ante`」,不一致则拒绝并提示修改注数。
|
||||
|
||||
如果您正在使用这个项目并感觉良好,或者是想支持我继续开发,您可以通过如下`任意`方式支持我:
|
||||
---
|
||||
|
||||
谢谢! ❤️
|
||||
## 4. 抽奖与结算机制(服务端逻辑)
|
||||
|
||||
以下对应 `PlayStartLogic` 与 `LotteryService`,便于理解「先抽什么、再算什么钱」。
|
||||
|
||||
| 微信 | 支付宝 |
|
||||
| :------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
|
||||
| <img src="https://saithink.top/images/wechat.png" alt="Wechat QRcode" width=180> | <img src="https://saithink.top/images/alipay.png" alt="Alipay QRcode" width=180> |
|
||||
### 4.1 前置校验
|
||||
|
||||
<div style="clear: both">
|
||||
<h1>LICENSE</h1>
|
||||
This project is open-sourced software licensed under the MIT.
|
||||
</div>
|
||||
- 用户存在;`ante` 合法。
|
||||
- **最低余额**:`coin ≥ abs(min_real_ev) × ante`(`min_real_ev` 来自全表 `DiceRewardConfig` 缓存),防止极端负 EV 下余额不足以覆盖风险口径。
|
||||
- 付费局:`coin ≥ ante × 1`。
|
||||
|
||||
</div>
|
||||
### 4.2 使用哪套「档位权重」:默认奖池 vs 杀分奖池
|
||||
|
||||
配置表 `dice_lottery_pool_config` 至少要有 **`name = default`**;可选 **`name = killScore`**。
|
||||
|
||||
- **`default` 彩金池**维护累计盈利字段 **`profit_amount`**(见 4.5)。
|
||||
- 记:`safety_line` = 安全线,`kill_enabled` = 是否开启杀分。
|
||||
|
||||
**是否按「奖池档位权重」抽档位(`usePoolWeights`)**:
|
||||
|
||||
| 情形 | 档位权重来源 |
|
||||
| --- | --- |
|
||||
| **免费局** | 使用 **killScore** 奖池的 T1–T5 权重;若无 `killScore` 则退回 `default`。 |
|
||||
| **付费局** 且 **杀分开启** 且 **`profit_amount ≥ safety_line`** 且 **存在 killScore** | 使用 **killScore** 的档位权重(杀分模式)。 |
|
||||
| **其他付费局** | 使用 **玩家**身上的 `t1_weight`~`t5_weight`(`DicePlayer` 字段,与 `LotteryService::drawTierByPlayerWeights` 一致)。 |
|
||||
|
||||
档位抽出 **T1–T5** 后,从 `DiceReward` 缓存中取出 **`[该档位][direction]`** 下的所有奖励行,再按行 **`weight`** 做加权随机(仅 `weight > 0` 参与;全为 0 会重试档位,最多约 10 次)。
|
||||
|
||||
### 4.3 杀分模式下的特殊处理
|
||||
|
||||
当使用 **killScore / 免费局** 等与杀分一致的权重路径时:
|
||||
|
||||
- 在奖励抽取阶段会 **排除 `grid_number` 为 5 和 30 的配置**(这两点数和只能对应「全 1」「全 6」豹子,无法做成非豹子展示)。
|
||||
- **不会触发豹子大奖**(见 4.4):若摇到豹子点数组,只生成 **非豹子** 的五骰组合,不发放豹子附加奖金。
|
||||
|
||||
### 4.4 普通奖与「豹子 / BIGWIN」
|
||||
|
||||
- 若本次抽中的 `grid_number` **不是**「豹子集合」`{5,10,15,20,25,30}`:按点数和生成 5 个 1–6 的骰子(和为 `grid_number`),**普通奖金** = **`real_ev × ante`**(付费局已预先扣除 `ante×1`)。
|
||||
|
||||
- 若点数和落在豹子集合:
|
||||
- **`grid_number` 为 5 或 30**:若**非**杀分路径,**必定**按豹子结算(五颗相同点数)。
|
||||
- **10 / 15 / 20 / 25**:读取 `DiceRewardConfig` 中 **`tier = BIGWIN`** 且对应该 `grid_number` 的配置,用其 **`weight`(0–10000,10000=100%)** 随机决定是否视为真豹子;否则生成**非豹子**但点数和不变的骰子组合。
|
||||
- **真豹子**时:奖金按 **`big_win_real_ev × ante`** 发放(`big_win_real_ev` 来自 BIGWIN 配置;若未配则用代码兜底常量);并**不计入**当次普通 `reward_win` 那条配置(与「中豹子不走普通奖」逻辑一致,详见代码注释)。
|
||||
|
||||
杀分路径下:**不触发**豹子奖,仅展示非豹子组合。
|
||||
|
||||
### 4.5 T5「再来一次」
|
||||
|
||||
若命中奖励属于 **T5** 档位(且未走「仅豹子清掉普通奖」的特殊分支):在事务内为玩家 **`free_ticket_count + 1`**,并写入券流水备注;同时写入 Redis:**下一局免费抽奖必须使用本局相同 `ante`**。
|
||||
|
||||
### 4.6 彩金池盈利累计
|
||||
|
||||
在 **`default`** 那条池子上更新 **`profit_amount`**:
|
||||
|
||||
- **付费局**:本局贡献 `+= (本局总中奖 win_coin) - (本局付费 paid_amount)`,其中 `paid_amount = ante × 1`。
|
||||
- **免费局**:`+= win_coin`(无票价成本,`paid_amount = 0`)。
|
||||
|
||||
该累计值与 **`safety_line`、 `kill_enabled`** 共同决定下一局付费是否进入 **killScore** 档位权重(见 4.2)。
|
||||
|
||||
> 注意:仓库中部分数据库迁移脚本对 `profit_amount` 的注释可能仍沿用旧口径。当前行为应以 `PlayStartLogic` 中对 `profit_amount` 的实际累加逻辑为准。
|
||||
|
||||
---
|
||||
|
||||
## 5. 数据与配置要点(实现侧)
|
||||
|
||||
- **`DiceReward`**:按档位、方向组织好的多语言/展示与 `grid_number`、`weight`、`real_ev` 等,供开局加权抽取。
|
||||
- **`DiceRewardConfig`**:含 **BIGWIN** 档及普通档;`getCachedMinRealEv()` 等用于全局限定。
|
||||
- **`dice_lottery_pool_config`**:`default` / `killScore` 的 T1–T5 权重及杀分相关开关、安全线、累计盈利。
|
||||
- **对局表 `DicePlayRecord`**:记录 `lottery_config_id`、`lottery_type`(付费/免费)、`ante`、`paid_amount`、`roll_array`、`reward_tier`、各类中奖拆分字段等,供后台与平台对账。
|
||||
|
||||
---
|
||||
|
||||
## 6. 接口与文档索引
|
||||
|
||||
| 文档 | 内容 |
|
||||
| --- | --- |
|
||||
| [`API对接文档.md`](API对接文档.md) | 平台 `/api/v1/*`(`auth-token`)、玩家 `/api/*`(`token`)、统一返回码、联调建议。 |
|
||||
| `server/docs/` | 性能、权重测试、出点分析等专项说明(按需阅读)。 |
|
||||
|
||||
**与玩法直接相关的玩家接口示例**:
|
||||
|
||||
- `GET /api/game/config` — 前端文案与分组配置
|
||||
- `GET /api/game/anteConfig` — 可选注数
|
||||
- `GET /api/game/lotteryPool` — 彩金池展示列表(不含 BIGWIN 档)
|
||||
- `POST /api/game/buyLotteryTickets` — 购买套餐(更新次数统计)
|
||||
- `POST /api/game/playStart` — 开局一局(`direction`、`ante`)
|
||||
|
||||
---
|
||||
|
||||
## 7. 修订说明
|
||||
|
||||
- 本文档依据 `server/app/api/logic/PlayStartLogic.php`、`GameLogic.php`、`LotteryService.php` 及 `GameController` 当前实现整理;若业务规则变更,请以代码与数据库迁移为准并同步更新本节与 [`API对接文档.md`](API对接文档.md)。
|
||||
|
||||
@@ -7,7 +7,7 @@ VITE_BASE_URL = /
|
||||
VITE_API_URL = /api
|
||||
|
||||
# 代理目标地址(开发环境通过 Vite 代理转发请求到此地址,解决跨域问题)
|
||||
VITE_API_PROXY_URL = http://127.0.0.1:6688
|
||||
VITE_API_PROXY_URL = http://127.0.0.1:8989
|
||||
|
||||
# Delete console
|
||||
VITE_DROP_CONSOLE = false
|
||||
@@ -5,7 +5,7 @@
|
||||
VITE_BASE_URL = ./
|
||||
|
||||
# API 根地址(后端路由为 /core、/tool、/dice 等,无 /prod 前缀,不要加 /prod)
|
||||
VITE_API_URL = https://dice-api.yuliao666.top
|
||||
VITE_API_URL = https://dice-v3-api.yuliao666.top
|
||||
|
||||
# 登录页是否显示验证码,设为 false 可关闭(需与后端 LOGIN_CAPTCHA_ENABLE 一致)
|
||||
VITE_LOGIN_CAPTCHA_ENABLED = false
|
||||
|
||||
53
saiadmin-artd/scripts/generate-dice-reward-index.ts
Normal file
53
saiadmin-artd/scripts/generate-dice-reward-index.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 命令行:按「当前盘面 grid_number 排布」与 T1/T2/T4/T5 约束生成 DiceRewardConfig 表 JSON(不含保存)。
|
||||
* 用法:pnpm tsx scripts/generate-dice-reward-index.ts [t1Fixed] [t2Min] [t4Fixed] [t5Fixed]
|
||||
* 默认:3 5 1 1(T4/T5 为顺、逆加权条数固定值)
|
||||
*
|
||||
* 生成逻辑见 src/views/plugin/dice/reward_config/utils/generateIndexByRules.ts
|
||||
*/
|
||||
|
||||
import {
|
||||
buildRowsFromTiers,
|
||||
computeBoardFrequencies,
|
||||
DEFAULT_TIER_REAL_EV_STANDARDS,
|
||||
generateTiers,
|
||||
summarizeCounts
|
||||
} from '../src/views/plugin/dice/reward_config/utils/generateIndexByRules'
|
||||
|
||||
const grids = [
|
||||
20, 27, 24, 10, 5, 15, 8, 22, 30, 23, 16, 12, 13, 7, 17, 9, 21, 26, 6, 29, 19, 11, 25, 14, 28, 18
|
||||
]
|
||||
|
||||
const args = process.argv.slice(2).map((x) => parseInt(x, 10))
|
||||
const t1 = Number.isFinite(args[0]) ? args[0] : 3
|
||||
const t2 = Number.isFinite(args[1]) ? args[1] : 5
|
||||
const x4 = Number.isFinite(args[2]) ? args[2] : 1
|
||||
const x5 = Number.isFinite(args[3]) ? args[3] : 1
|
||||
|
||||
const constraints = {
|
||||
t1FixedCw: t1,
|
||||
t2MinCw: t2,
|
||||
t4FixedCw: x4,
|
||||
t5FixedCw: x5,
|
||||
t1FixedCcw: t1,
|
||||
t2MinCcw: t2,
|
||||
t4FixedCcw: x4,
|
||||
t5FixedCcw: x5
|
||||
}
|
||||
|
||||
const gen = generateTiers({ grids, constraints })
|
||||
if (gen.ok === false) {
|
||||
console.error(gen.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const board = computeBoardFrequencies(grids)
|
||||
if (board === null) {
|
||||
console.error('computeBoardFrequencies failed')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const rows = buildRowsFromTiers(grids, gen.tiers, DEFAULT_TIER_REAL_EV_STANDARDS)
|
||||
const sc = summarizeCounts(board, gen.tiers)
|
||||
|
||||
console.log(JSON.stringify({ weighted: { cw: sc.cw, ccw: sc.ccw }, rows }, null, 2))
|
||||
@@ -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', {
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
import AppConfig from '@/config'
|
||||
import { languageOptions } from '@/locales'
|
||||
import { invalidatePageLocaleCache } from '@/locales/pageLocaleLoader'
|
||||
import { invalidatePageLocaleCache, loadPageLocale } from '@/locales/pageLocaleLoader'
|
||||
import { mittBus } from '@/utils/sys'
|
||||
import { themeAnimation } from '@/utils/ui/animation'
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
@@ -285,12 +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)
|
||||
invalidatePageLocaleCache()
|
||||
reload(50)
|
||||
await loadPageLocale(router.currentRoute.value.path)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
*/
|
||||
const clearCache = (): void => {
|
||||
userStore.clearCache()
|
||||
ElMessage.success('清理缓存成功')
|
||||
ElMessage.success(t('uiMsg.clearCacheSuccess'))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 字段
|
||||
|
||||
@@ -311,9 +311,12 @@
|
||||
/** 表头 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.')) && i18n.global.te(label)) {
|
||||
if (label && typeof label === 'string' && (label.startsWith('table.') || label.startsWith('page.'))) {
|
||||
return { ...col, label: $t(label) }
|
||||
}
|
||||
return 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) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import axios from 'axios'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { $t } from '@/locales'
|
||||
|
||||
defineOptions({ name: 'SaExport' })
|
||||
|
||||
@@ -42,18 +43,18 @@
|
||||
const handleExport = async () => {
|
||||
if (loading.value) return
|
||||
if (!props.url) {
|
||||
ElMessage.error('未配置导出接口')
|
||||
ElMessage.error($t('uiMsg.exportNotConfigured'))
|
||||
return
|
||||
}
|
||||
|
||||
let finalFileName = props.fileName
|
||||
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt('请输入导出文件名称', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
const { value } = await ElMessageBox.prompt($t('uiMsg.exportPromptFileName'), $t('uiMsg.titlePrompt'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
inputValue: props.fileName,
|
||||
inputValidator: (val) => !!val.trim() || '文件名不能为空'
|
||||
inputValidator: (val) => !!val.trim() || $t('uiMsg.exportFileNameRequired')
|
||||
})
|
||||
finalFileName = value
|
||||
} catch {
|
||||
@@ -87,10 +88,10 @@
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const result = JSON.parse(reader.result as string)
|
||||
ElMessage.error(result.msg || '导出失败')
|
||||
ElMessage.error(result.msg || $t('uiMsg.exportFail'))
|
||||
emit('error', result)
|
||||
} catch (e) {
|
||||
ElMessage.error('导出失败')
|
||||
ElMessage.error($t('uiMsg.exportFail'))
|
||||
emit('error', e)
|
||||
}
|
||||
}
|
||||
@@ -108,11 +109,11 @@
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('导出成功')
|
||||
ElMessage.success($t('uiMsg.exportSuccess'))
|
||||
emit('success')
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
ElMessage.error(error.message || '导出失败')
|
||||
ElMessage.error(error.message || $t('uiMsg.exportFail'))
|
||||
emit('error', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
@@ -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
|
||||
})()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ref, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
|
||||
/**
|
||||
* SaiAdmin Composable
|
||||
@@ -39,13 +40,13 @@ export function useSaiAdmin() {
|
||||
apiFn: (params: any) => Promise<any>,
|
||||
callback?: () => void
|
||||
): void => {
|
||||
ElMessageBox.confirm(`确定要删除该数据吗?`, '删除数据', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('uiMsg.deleteConfirmSingle'), $t('uiMsg.titleDelete'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
apiFn({ ids: [row.id] }).then(() => {
|
||||
ElMessage.success('删除成功')
|
||||
ElMessage.success($t('uiMsg.deleteSuccess'))
|
||||
if (callback) callback()
|
||||
})
|
||||
})
|
||||
@@ -57,20 +58,20 @@ export function useSaiAdmin() {
|
||||
callback?: () => void
|
||||
): void => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要删除的行')
|
||||
ElMessage.warning($t('uiMsg.selectRowsToDelete'))
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
`确定要删除选中的 ${selectedRows.value.length} 条数据吗?`,
|
||||
'删除选中数据',
|
||||
$t('uiMsg.deleteConfirmSelected', { n: selectedRows.value.length }),
|
||||
$t('uiMsg.titleDeleteSelected'),
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}
|
||||
).then(() => {
|
||||
apiFn({ ids: selectedRows.value.map((row) => row.id) }).then(() => {
|
||||
ElMessage.success('删除成功')
|
||||
ElMessage.success($t('uiMsg.deleteSuccess'))
|
||||
if (callback) callback()
|
||||
selectedRows.value = []
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ const i18n: I18n = createI18n(i18nOptions)
|
||||
* 翻译函数类型
|
||||
*/
|
||||
interface Translation {
|
||||
(key: string): string
|
||||
(key: string, named?: Record<string, unknown>): string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,46 @@
|
||||
"confirm": "Confirm",
|
||||
"logOutTips": "Do you want to log out?"
|
||||
},
|
||||
"uiMsg": {
|
||||
"titlePrompt": "Prompt",
|
||||
"titleDelete": "Delete",
|
||||
"titleDeleteSelected": "Delete selected",
|
||||
"btnOk": "Confirm",
|
||||
"btnCancel": "Cancel",
|
||||
"deleteConfirmSingle": "Are you sure you want to delete this item?",
|
||||
"deleteConfirmSelected": "Are you sure you want to delete the selected {n} items?",
|
||||
"deleteSuccess": "Deleted",
|
||||
"operationSuccess": "Success",
|
||||
"selectRowsToDelete": "Please select rows to delete",
|
||||
"selectAtLeastOne": "Please select at least one item",
|
||||
"clearCacheSuccess": "Cache cleared",
|
||||
"copySuccess": "Copied",
|
||||
"copyFail": "Copy failed, please copy manually",
|
||||
"uploadSuccess": "Uploaded",
|
||||
"uploadFail": "Upload failed",
|
||||
"downloadTemplateFail": "Failed to download template",
|
||||
"importSuccess": "Imported",
|
||||
"importFail": "Import failed",
|
||||
"exportFail": "Export failed",
|
||||
"exportSuccess": "Exported"
|
||||
,
|
||||
"exportNotConfigured": "Export API is not configured",
|
||||
"exportPromptFileName": "Please enter export file name",
|
||||
"exportFileNameRequired": "File name is required",
|
||||
"clearCacheSelect": "Please select a cache to clear",
|
||||
"clearCacheTitle": "Clear selected cache",
|
||||
"clearCacheConfirmByTag": "Are you sure you want to clear cache for tag: {tag}?"
|
||||
,
|
||||
"saipackageWebBuildTitle": "Frontend build & publish",
|
||||
"saipackageWebBuildConfirm": "Rebuild frontend and publish the project?",
|
||||
"saipackageWebBuildSuccess": "Frontend built and published",
|
||||
"saipackageFrontendDepsTitle": "Frontend dependencies",
|
||||
"saipackageFrontendDepsConfirm": "Update frontend Node dependencies?",
|
||||
"saipackageFrontendDepsSuccess": "Frontend dependencies updated",
|
||||
"saipackageComposerTitle": "Composer dependencies",
|
||||
"saipackageComposerConfirm": "Update backend Composer packages?",
|
||||
"saipackageComposerSuccess": "Composer packages updated"
|
||||
},
|
||||
"form": {
|
||||
"placeholderInput": "Please enter",
|
||||
"placeholderSelect": "Please select",
|
||||
@@ -47,6 +87,17 @@
|
||||
"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",
|
||||
@@ -350,6 +401,7 @@
|
||||
"dice": {
|
||||
"title": "Dice Game",
|
||||
"lotteryPoolConfig": "Lottery Tier Weight Config",
|
||||
"anteConfig": "Ante Config",
|
||||
"player": "Player Management",
|
||||
"playerWalletRecord": "Player Wallet Records",
|
||||
"playRecord": "Player Draw Records",
|
||||
|
||||
37
saiadmin-artd/src/locales/langs/en/dice/ante_config.json
Normal file
37
saiadmin-artd/src/locales/langs/en/dice/ante_config.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"search": {
|
||||
"name": "Name",
|
||||
"title": "Title",
|
||||
"isDefault": "Default",
|
||||
"placeholderName": "Please enter name",
|
||||
"placeholderTitle": "Please enter title",
|
||||
"placeholderIsDefault": "Please select default status"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"name": "Name",
|
||||
"title": "Title",
|
||||
"mult": "Ante Multiplier",
|
||||
"isDefault": "Default Ante",
|
||||
"defaultYes": "Yes",
|
||||
"defaultNo": "No",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "Add Ante Config",
|
||||
"titleEdit": "Edit Ante Config",
|
||||
"labelName": "Name",
|
||||
"labelTitle": "Title",
|
||||
"labelMult": "Ante Multiplier",
|
||||
"labelIsDefault": "Default Ante",
|
||||
"placeholderName": "Please enter name",
|
||||
"placeholderTitle": "Please enter title",
|
||||
"ruleNameRequired": "Please enter name",
|
||||
"ruleTitleRequired": "Please enter title",
|
||||
"ruleMultRequired": "Please enter ante multiplier",
|
||||
"ruleDefaultRequired": "Please select default status",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
}
|
||||
}
|
||||
@@ -18,22 +18,21 @@
|
||||
"t5Weight": "T5 Pool Weight (%)",
|
||||
"weightsSumHint": "Total pool weights: ",
|
||||
"weightsSumUnit": "% / 100% (must equal 100%)",
|
||||
"weightsSumUnitCurrent": "% / 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.",
|
||||
"profitCalcHint": "Profit per round: paid = win_coin (incl. BIGWIN) - paid_amount (= ante×1); free = win_coin. 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 (type=1 read-only)",
|
||||
"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": "Saved",
|
||||
"msgSaveSuccess": "Save Success",
|
||||
"msgResetProfitSuccess": "Player total profit reset to 0",
|
||||
"msgResetFailed": "Reset failed",
|
||||
"ruleNameRequired": "Name is required",
|
||||
|
||||
@@ -30,8 +30,14 @@
|
||||
"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)"
|
||||
"rewardTier": "Reward Tier",
|
||||
"placeholderRewardTier": "Select reward tier",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully",
|
||||
"validateFailed": "Validation failed, please check required fields and format"
|
||||
},
|
||||
"toolbar": {
|
||||
"platformTotalProfit": "Platform Total Profit"
|
||||
},
|
||||
"search": {
|
||||
"player": "Player",
|
||||
@@ -41,8 +47,8 @@
|
||||
"direction": "Direction",
|
||||
"winCoin": "Win Coin",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"rewardTier": "Reward Tier",
|
||||
"rewardConfig": "Reward Config",
|
||||
"usernameFuzzy": "Username (fuzzy)",
|
||||
"nameFuzzy": "Name (fuzzy)",
|
||||
"uiTextFuzzy": "UI Text (fuzzy)",
|
||||
@@ -58,6 +64,8 @@
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"ante": "Ante",
|
||||
"paidAmount": "Paid Amount",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
@@ -67,7 +75,7 @@
|
||||
"targetIndex": "Target Index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"rewardTier": "Reward Tier",
|
||||
"createTime": "Create Time",
|
||||
"updateTime": "Update Time"
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
"platformTotalProfit": "Platform Total Profit"
|
||||
},
|
||||
"search": {
|
||||
"rewardConfigRecordId": "Weight Test Record ID",
|
||||
"drawType": "Draw Type",
|
||||
"direction": "Direction",
|
||||
"isBigWin": "Is Big Win",
|
||||
"winCoin": "Win Coin",
|
||||
"paidAmount": "Paid Amount",
|
||||
"ante": "Ante",
|
||||
"rewardTier": "Reward Tier",
|
||||
"rollNumber": "Roll Number",
|
||||
"paid": "Paid",
|
||||
@@ -19,10 +22,13 @@
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"rewardConfigRecordId": "Weight Test Record ID",
|
||||
"player": "Player",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"drawType": "Draw Type",
|
||||
"isBigWin": "Is Big Win",
|
||||
"paidAmount": "Paid Amount",
|
||||
"ante": "Ante",
|
||||
"winCoin": "Win Coin",
|
||||
"superWinCoin": "Super Win Coin",
|
||||
"rewardWinCoin": "Reward Win Coin",
|
||||
@@ -31,7 +37,40 @@
|
||||
"targetIndex": "Target Index",
|
||||
"rollArray": "Roll Array",
|
||||
"rollNumber": "Roll Number",
|
||||
"rewardConfig": "Reward Config",
|
||||
"rewardTier": "Reward Tier",
|
||||
"status": "Status",
|
||||
"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 reward tier",
|
||||
"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",
|
||||
"ruleRewardTierRequired": "Reward tier is required",
|
||||
"ruleStatusRequired": "Status is required",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"ui": {
|
||||
"clearAllConfirm": "Are you sure you want to clear all player draw test data?",
|
||||
"clearAllSuccess": "All test data cleared",
|
||||
"clearAllFail": "Clear failed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"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",
|
||||
@@ -65,6 +66,7 @@
|
||||
"status": "Status",
|
||||
"coin": "Coin",
|
||||
"lotteryPoolConfig": "Lottery Pool Config",
|
||||
"customConfig": "Custom",
|
||||
"t1Weight": "T1 Weight",
|
||||
"t2Weight": "T2 Weight",
|
||||
"t3Weight": "T3 Weight",
|
||||
|
||||
@@ -12,11 +12,14 @@
|
||||
"placeholderFreeDrawCount": "Please enter free draw count",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"placeholderTotalDrawCount": "Auto sum",
|
||||
"placeholderRemark": "Remark (required)"
|
||||
"placeholderRemark": "Remark (required)",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"search": {
|
||||
"player": "Player",
|
||||
"useCoins": "Use Coins",
|
||||
"ante": "Ante",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
@@ -27,6 +30,7 @@
|
||||
"id": "ID",
|
||||
"playerUsername": "Player Username",
|
||||
"useCoins": "Use Coins",
|
||||
"ante": "Ante",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"paidDrawCount": "Paid Draw Count",
|
||||
"freeDrawCount": "Free Draw Count",
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
"placeholderWalletBefore": "Auto from selected user",
|
||||
"walletAfter": "After",
|
||||
"placeholderWalletAfter": "Auto calculated",
|
||||
"placeholderRemark": "Optional"
|
||||
"placeholderRemark": "Optional",
|
||||
"addSuccess": "Added successfully",
|
||||
"editSuccess": "Updated successfully"
|
||||
},
|
||||
"search": {
|
||||
"type": "Type",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"weightRatio": "Weight Ratio",
|
||||
"weightTest": "Test Weight"
|
||||
"weightTest": "Test Weights"
|
||||
},
|
||||
"search": {
|
||||
"tier": "Tier",
|
||||
"clockwise": "Clockwise",
|
||||
"anticlockwise": "Anticlockwise"
|
||||
"anticlockwise": "Counter-clockwise",
|
||||
"optionBigwin": "BIGWIN"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "Start Index",
|
||||
@@ -17,5 +18,78 @@
|
||||
"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": "Test mode is non-kill by default. You can enable kill mode below with switch + safety line: once simulated player cumulative profit reaches the line, paid draws switch to killScore.",
|
||||
"chainModeHint": "Simulation: set paid spin counts only (CW/CCW). If a paid draw hits “play again” (or T5), the next draw is free with the same ante, lottery type free, paid amount 0. Free-draw tier odds are configured below (including chained free plays).",
|
||||
"killModeHint": "When test kill mode is enabled: use simulated player cumulative profit as trigger; once cumulative profit >= safety line, subsequent paid draws use killScore. Free draws still follow the configured free settings.",
|
||||
"labelKillModeEnabled": "Enable test kill mode",
|
||||
"labelTestSafetyLine": "Test safety line",
|
||||
"sectionPaid": "Paid draws",
|
||||
"sectionFreeAfterPlayAgain": "Free draw tier odds (after play-again)",
|
||||
"tierProbHintFreeChain": "When using custom tier odds: T1–T5 below apply when a free draw runs (tier roll; combined with dice_reward row weights).",
|
||||
"stepPaid": "Paid ticket",
|
||||
"stepFree": "Free ticket",
|
||||
"labelLotteryTypePaid": "Test pool type",
|
||||
"labelLotteryTypeFree": "Test pool type",
|
||||
"labelAnte": "Ante",
|
||||
"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",
|
||||
"warnAnte": "Ante must be greater than 0",
|
||||
"warnPaidSpins": "Paid clockwise + counter-clockwise spin counts must be greater than 0",
|
||||
"warnTestSafetyLine": "Test safety line must be greater than or equal to 0",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,118 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"gameRewardConfig": "Game Reward Config",
|
||||
"createRewardRef": "Create Reward Reference"
|
||||
"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",
|
||||
"colRealReward": "Player Real Reward",
|
||||
"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.",
|
||||
"btnRuleGenerate": "Generate by rules",
|
||||
"ruleGenerateTitle": "Generate reward index by rules",
|
||||
"ruleGenerateRules": "[Generation logic (same as Create Reward Reference)]\n• 26 cells ordered by id ascending are positions 0–25; each row’s grid_number is 5–30 and unique.\n• Roll D (5–30): start at the cell whose grid_number equals D (start_index); clockwise landing = (start position + D) mod 26; counter-clockwise = start − D (if negative, +26).\n• Each reference row’s “dice points” column is the roll D; tier / real_ev / display text come from the config at the landing id.\n\n[Leopard rolls]\nFor rolls 5, 10, 15, 20, 25, 30, clockwise and counter-clockwise landing tiers must NOT be T4 or T5 (avoid leopard roll + penalty / once again).\n\n[Settlement amount vs tier]\nSettlement < 0 → T4; 0 < Settlement < 100 → T3; 100 < Settlement < 200 → T2; Settlement > 200 → T1; T5 “once again” settlement = 0. You can set a unified settlement standard for each tier below; generated rows write those values into the config, and details can be edited later in the table.\n\n[Inputs in this dialog]\nCount: T1/T4/T5 are fixed; T2 is minimum. Clockwise and counter-clockwise weighted counts (each roll result counts once) must each satisfy the entered values; T1, T4, and T5 are entered separately.\nSettlement standard: all cells in the same tier use the same value. On generation, T1–T4 use ui_text / ui_text_en = settlement real_ev; T5 is fixed to \"再来一次\" / \"Once again\". Remarks still distinguish break-even / small win, etc.",
|
||||
"ruleGenT1Row": "T1 (big prize)",
|
||||
"ruleGenT2Row": "T2 (small win / break-even)",
|
||||
"ruleGenT3RealEvOnly": "T3 (rake)",
|
||||
"ruleGenT4Row": "T4 (penalty)",
|
||||
"ruleGenT5Row": "T5 (try again)",
|
||||
"ruleGenMinCount": "Min count",
|
||||
"ruleGenFixedCount": "Fixed count (CW & CCW)",
|
||||
"ruleGenRealEvStd": "real_ev standard",
|
||||
"ruleGenRealEvEditHint": "After saving, you can still edit display text, EN, real_ev and remarks per row in the table above.",
|
||||
"ruleGenInvalidT1RealEv": "T1 settlement amount must satisfy: value > 200",
|
||||
"ruleGenInvalidT2RealEv": "T2 settlement amount must satisfy: 100 < value < 200",
|
||||
"ruleGenInvalidT3RealEv": "T3 settlement amount must satisfy: 0 < value < 100",
|
||||
"ruleGenInvalidT4RealEv": "T4 settlement amount must satisfy: value < 0",
|
||||
"ruleGenInvalidT5RealEv": "T5 “try again” real_ev must be 0",
|
||||
"ruleGenT1Min": "T1 fixed count (CW & CCW)",
|
||||
"ruleGenT2Min": "T2 min (CW & CCW)",
|
||||
"ruleGenT4Max": "T4 fixed count (CW & CCW)",
|
||||
"ruleGenT5Max": "T5 fixed count (CW & CCW)",
|
||||
"ruleGenScopeHint": "T1/T4/T5 are exact; T2 is minimum: clockwise and counter-clockwise weighted counts must satisfy each constraint.",
|
||||
"ruleGenApply": "Generate and save",
|
||||
"ruleGenNeedFullGrid": "Missing id 0–25 rows or incomplete grid_number; cannot generate",
|
||||
"ruleGenFreqFail": "Cannot compute board frequencies; check grid_number",
|
||||
"ruleGenUnknownId": "Unknown reward index id: {id}",
|
||||
"ruleGenSuccess": "Generated and saved. Clockwise weighted: T1={cwT1} T2={cwT2} T4={cwT4} T5={cwT5}; counter-clockwise: T1={ccT1} T2={ccT2} T4={ccT4} T5={ccT5}",
|
||||
"btnJsonImport": "JSON import",
|
||||
"jsonImportTitle": "Reward index JSON import",
|
||||
"jsonImportHint": "Current Reward Index rows (excluding BIGWIN) are filled below. Edit and submit; id must be 0–25, grid_number must be 5–30. Submit applies to the table and saves.",
|
||||
"jsonImportParseFail": "Invalid JSON",
|
||||
"jsonImportNotArray": "Root must be a JSON array",
|
||||
"jsonImportItemInvalid": "Item {n} is not a valid object",
|
||||
"jsonImportMissingField": "Item {n} is missing field: {field}",
|
||||
"jsonImportIdRange": "id must be 0–25; item {n} has {v}",
|
||||
"jsonImportGridRange": "grid_number must be 5–30; item {n} has {v}",
|
||||
"jsonImportDupId": "Duplicate id in JSON: {list}",
|
||||
"jsonImportDupGrid": "Duplicate grid_number in JSON: {list}",
|
||||
"jsonImportFullIdSet": "For 26 rows, id must be exactly 0–25 once each",
|
||||
"jsonImportFullGridSet": "For 26 rows, grid_number must be exactly 5–30 once each",
|
||||
"jsonImportUnknownId": "Unknown id: {id} (export from the current list first)",
|
||||
"jsonImportTierInvalid": "Invalid tier at item {n}",
|
||||
"jsonImportEmpty": "Nothing to submit"
|
||||
},
|
||||
"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",
|
||||
@@ -19,5 +130,34 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,94 @@
|
||||
"toolbar": {
|
||||
"viewDetail": "View Detail"
|
||||
},
|
||||
"search": {
|
||||
"paidPlannedSpins": "Planned paid spins",
|
||||
"ante": "Ante"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"clockwiseAbbr": "CW",
|
||||
"counterclockwiseAbbr": "CCW",
|
||||
"status": "Status",
|
||||
"paidDraw": "Paid Draw",
|
||||
"freeDraw": "Free Draw",
|
||||
"chainMode": "Chain play-again",
|
||||
"chainModeYes": "Yes",
|
||||
"chainModeNo": "No",
|
||||
"paidPlannedSpins": "Planned paid spins",
|
||||
"ante": "Ante",
|
||||
"playAgainCount": "Play-again count",
|
||||
"progressDraws": "{over} done",
|
||||
"progressFailed": "{over} before fail",
|
||||
"platformProfit": "Platform Profit",
|
||||
"totalDrawCount": "Total Draw Count",
|
||||
"totalDrawCount": "Total draws",
|
||||
"createdBy": "Created By",
|
||||
"remark": "Remark",
|
||||
"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",
|
||||
"testCountProgress": "In progress: {over} done",
|
||||
"testCountFailed": "{over} before failure",
|
||||
"chainModeLabel": "Chain play-again",
|
||||
"paidPlannedSpins": "Planned paid spins",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,13 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"search": {
|
||||
"deptName": "Dept Name",
|
||||
"deptName": "channel(Department) Name",
|
||||
"deptCode": "Dept Code",
|
||||
"status": "Status",
|
||||
"placeholderDeptName": "Please enter dept name",
|
||||
@@ -8,11 +8,32 @@
|
||||
"searchSelectPlaceholder": "Please select"
|
||||
},
|
||||
"table": {
|
||||
"deptName": "Dept Name",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,49 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,22 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,25 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,41 @@
|
||||
"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"
|
||||
},
|
||||
"ui": {
|
||||
"promptNewPassword": "Please enter a new password",
|
||||
"passwordLengthError": "Password length must be between 6 and 16",
|
||||
"passwordChanged": "Password updated",
|
||||
"clearCacheConfirm": "Are you sure you want to clear cache?"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,16 @@
|
||||
"tplCategory": "Gen Type",
|
||||
"updateTime": "Update Time",
|
||||
"createTime": "Create Time"
|
||||
},
|
||||
"ui": {
|
||||
"generating": "Generating code package, please wait...",
|
||||
"generateSuccess": "Code generated, downloading...",
|
||||
"downloadFail": "Download failed",
|
||||
"syncConfirm": "Sync will overwrite the configured table structure. Continue?",
|
||||
"syncSuccess": "Synced",
|
||||
"generateToProjectConfirm": "Generate-to-project will overwrite existing files. Continue?",
|
||||
"generateToProjectSuccess": "Generated to project",
|
||||
"loadSuccess": "Loaded",
|
||||
"copyToClipboard": "Code copied to clipboard"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,52 @@
|
||||
"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"
|
||||
},
|
||||
"ui": {
|
||||
"runTitle": "Run Task",
|
||||
"runConfirm": "Are you sure you want to run task [{name}]?",
|
||||
"runSuccess": "Task started",
|
||||
"selectTaskFirst": "Please select a task first"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,46 @@
|
||||
"confirm": "确定",
|
||||
"logOutTips": "您是否要退出登录?"
|
||||
},
|
||||
"uiMsg": {
|
||||
"titlePrompt": "提示",
|
||||
"titleDelete": "删除数据",
|
||||
"titleDeleteSelected": "删除选中数据",
|
||||
"btnOk": "确定",
|
||||
"btnCancel": "取消",
|
||||
"deleteConfirmSingle": "确定要删除该数据吗?",
|
||||
"deleteConfirmSelected": "确定要删除选中的 {n} 条数据吗?",
|
||||
"deleteSuccess": "删除成功",
|
||||
"operationSuccess": "操作成功",
|
||||
"selectRowsToDelete": "请选择要删除的行",
|
||||
"selectAtLeastOne": "至少要选择一条数据",
|
||||
"clearCacheSuccess": "清理缓存成功",
|
||||
"copySuccess": "复制成功",
|
||||
"copyFail": "复制失败,请手动复制",
|
||||
"uploadSuccess": "上传成功",
|
||||
"uploadFail": "上传失败",
|
||||
"downloadTemplateFail": "下载模板失败",
|
||||
"importSuccess": "导入成功",
|
||||
"importFail": "导入失败",
|
||||
"exportFail": "导出失败",
|
||||
"exportSuccess": "导出成功"
|
||||
,
|
||||
"exportNotConfigured": "未配置导出接口",
|
||||
"exportPromptFileName": "请输入导出文件名称",
|
||||
"exportFileNameRequired": "文件名不能为空",
|
||||
"clearCacheSelect": "请选择要清理的缓存",
|
||||
"clearCacheTitle": "清理选中缓存",
|
||||
"clearCacheConfirmByTag": "确定要清理标签:【{tag}】的缓存吗?"
|
||||
,
|
||||
"saipackageWebBuildTitle": "前端打包发布",
|
||||
"saipackageWebBuildConfirm": "确认重新打包前端并发布项目吗?",
|
||||
"saipackageWebBuildSuccess": "前端打包发布成功",
|
||||
"saipackageFrontendDepsTitle": "前端依赖更新",
|
||||
"saipackageFrontendDepsConfirm": "确认更新前端Node依赖吗?",
|
||||
"saipackageFrontendDepsSuccess": "前端依赖更新成功",
|
||||
"saipackageComposerTitle": "composer包更新",
|
||||
"saipackageComposerConfirm": "确认更新后端composer包吗?",
|
||||
"saipackageComposerSuccess": "composer包更新成功"
|
||||
},
|
||||
"form": {
|
||||
"placeholderInput": "请输入",
|
||||
"placeholderSelect": "请选择",
|
||||
@@ -47,6 +87,17 @@
|
||||
"labelName": "名称",
|
||||
"close": "关闭"
|
||||
},
|
||||
"dict": {
|
||||
"data_status": {
|
||||
"1": "正常",
|
||||
"2": "停用"
|
||||
},
|
||||
"gender": {
|
||||
"1": "男",
|
||||
"2": "女",
|
||||
"3": "未知"
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "搜索页面",
|
||||
"historyTitle": "搜索历史",
|
||||
@@ -323,7 +374,7 @@
|
||||
"role": "角色管理",
|
||||
"userCenter": "个人中心",
|
||||
"menu": "菜单管理",
|
||||
"dept": "部门管理",
|
||||
"dept": "渠道(部门)管理",
|
||||
"post": "岗位管理",
|
||||
"config": "系统配置"
|
||||
},
|
||||
@@ -346,6 +397,7 @@
|
||||
"dice": {
|
||||
"title": "大富翁-色子游戏",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"anteConfig": "底注配置",
|
||||
"player": "玩家管理",
|
||||
"playerWalletRecord": "玩家钱包记录",
|
||||
"playRecord": "玩家抽奖记录",
|
||||
|
||||
37
saiadmin-artd/src/locales/langs/zh/dice/ante_config.json
Normal file
37
saiadmin-artd/src/locales/langs/zh/dice/ante_config.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"search": {
|
||||
"name": "名称",
|
||||
"title": "标题",
|
||||
"isDefault": "是否默认",
|
||||
"placeholderName": "请输入名称",
|
||||
"placeholderTitle": "请输入标题",
|
||||
"placeholderIsDefault": "请选择是否默认"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"name": "名称",
|
||||
"title": "标题",
|
||||
"mult": "底注倍率",
|
||||
"isDefault": "默认底注",
|
||||
"defaultYes": "是",
|
||||
"defaultNo": "否",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增底注配置",
|
||||
"titleEdit": "编辑底注配置",
|
||||
"labelName": "名称",
|
||||
"labelTitle": "标题",
|
||||
"labelMult": "底注倍率",
|
||||
"labelIsDefault": "默认底注",
|
||||
"placeholderName": "请输入名称",
|
||||
"placeholderTitle": "请输入标题",
|
||||
"ruleNameRequired": "请输入名称",
|
||||
"ruleTitleRequired": "请输入标题",
|
||||
"ruleMultRequired": "请输入底注倍率",
|
||||
"ruleDefaultRequired": "请选择是否默认底注",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,16 @@
|
||||
"t5Weight": "T5池权重(%)",
|
||||
"weightsSumHint": "五个池权重总和:",
|
||||
"weightsSumUnit": "% / 100%(必须为100%)",
|
||||
"weightsSumUnitCurrent": "% / 100%(须为100%)",
|
||||
"currentPoolTitle": "当前彩金池",
|
||||
"loading": "加载中...",
|
||||
"poolName": "池子名称",
|
||||
"playerProfit": "玩家累计盈利(profit_amount):",
|
||||
"realtime": "实时",
|
||||
"profitCalcHint": "计算方式:每局按“当前中奖金额(含超级大奖 BIGWIN)减去抽奖券费用 100”累加,弹窗打开期间每 2 秒自动刷新",
|
||||
"profitCalcHint": "计算方式:付费每局按“赢取平台币 win_coin(含 BIGWIN)减去付费金额 压注金额paid_amount(= 压注倍数ante×1)”累加;免费每局按“玩家赢得平台币win_coin”累加。弹窗打开期间每 2 秒自动刷新",
|
||||
"tierRuleTitle": "抽奖档位规则",
|
||||
"tierRuleContent": "当玩家在当前彩金池的累计盈利 低于安全线 时,按 玩家 的 T*_weight 权重抽取档位;当累计盈利 高于或等于安全线 时,按 当前彩金池 的 T*_weight 权重抽取档位(杀分)。",
|
||||
"killScoreWeights": "杀分权重(type=1 只读)",
|
||||
"killWeightNote": "(杀分权重来自奖池配置 type=1,请在列表中编辑对应记录)",
|
||||
"killScoreWeights": "杀分权重",
|
||||
"killWeightNote": "(杀分权重来自奖池配置,请在列表中编辑对应记录)",
|
||||
"btnResetProfit": "重置玩家累计盈利",
|
||||
"btnSaveSafetyLine": "保存安全线",
|
||||
"ruleSafetyLineRequired": "请输入安全线",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"placeholderLotteryPool": "请选择彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"free": "免费",
|
||||
"isBigWin": "是否中大奖",
|
||||
"noBigWin": "无",
|
||||
"bigWin": "中大奖",
|
||||
@@ -30,8 +30,14 @@
|
||||
"rollArrayHint": "固定 5 个数,每个 1~6",
|
||||
"rollNumber": "摇取点数和",
|
||||
"placeholderRollNumber": "5 个色子点数之和(5~30)",
|
||||
"rewardConfig": "奖励配置",
|
||||
"placeholderRewardConfig": "请选择奖励配置(显示前端文本)"
|
||||
"rewardTier": "中奖档位",
|
||||
"placeholderRewardTier": "请选择中奖档位",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功",
|
||||
"validateFailed": "表单验证失败,请检查必填项与格式"
|
||||
},
|
||||
"toolbar": {
|
||||
"platformTotalProfit": "平台总盈利"
|
||||
},
|
||||
"search": {
|
||||
"player": "玩家",
|
||||
@@ -41,13 +47,13 @@
|
||||
"direction": "方向",
|
||||
"winCoin": "赢取平台币",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardTier": "中奖档位",
|
||||
"rewardConfig": "奖励配置",
|
||||
"rewardTier": "奖励档位",
|
||||
"usernameFuzzy": "用户名模糊",
|
||||
"nameFuzzy": "名称模糊",
|
||||
"uiTextFuzzy": "前端显示文本模糊",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"free": "免费",
|
||||
"noBigWin": "无",
|
||||
"bigWin": "中大奖",
|
||||
"clockwise": "顺时针",
|
||||
@@ -58,6 +64,8 @@
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"ante": "注数",
|
||||
"paidAmount": "付费金额",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
@@ -67,7 +75,7 @@
|
||||
"targetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"rewardTier": "中奖档位",
|
||||
"createTime": "创建时间",
|
||||
"updateTime": "更新时间"
|
||||
}
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
"platformTotalProfit": "平台总盈利"
|
||||
},
|
||||
"search": {
|
||||
"rewardConfigRecordId": "测试记录ID",
|
||||
"drawType": "抽奖类型",
|
||||
"direction": "方向",
|
||||
"isBigWin": "是否中大奖",
|
||||
"winCoin": "赢取平台币",
|
||||
"rewardTier": "奖励档位",
|
||||
"paidAmount": "付费金额",
|
||||
"ante": "底注",
|
||||
"rewardTier": "中奖档位",
|
||||
"rollNumber": "摇取点数和",
|
||||
"paid": "付费",
|
||||
"free": "赠送",
|
||||
"free": "免费",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针",
|
||||
"noBigWin": "无",
|
||||
@@ -19,10 +22,13 @@
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"rewardConfigRecordId": "测试记录ID",
|
||||
"player": "玩家",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"drawType": "抽奖类型",
|
||||
"isBigWin": "是否中大奖",
|
||||
"paidAmount": "付费金额",
|
||||
"ante": "底注",
|
||||
"winCoin": "赢取平台币",
|
||||
"superWinCoin": "中大奖平台币",
|
||||
"rewardWinCoin": "摇色子中奖平台币",
|
||||
@@ -31,7 +37,40 @@
|
||||
"targetIndex": "终点索引",
|
||||
"rollArray": "摇取点数",
|
||||
"rollNumber": "摇取点数和",
|
||||
"rewardConfig": "奖励配置",
|
||||
"rewardTier": "中奖档位",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增玩家抽奖记录(测试数据)",
|
||||
"titleEdit": "编辑玩家抽奖记录(测试数据)",
|
||||
"labelLotteryConfigId": "彩金池配置id",
|
||||
"placeholderLotteryConfigId": "请输入彩金池配置id",
|
||||
"placeholderWinCoin": "赢取平台币",
|
||||
"placeholderRewardTier": "请选择中奖档位",
|
||||
"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": "方向必需填写",
|
||||
"ruleRewardTierRequired": "中奖档位必需填写",
|
||||
"ruleStatusRequired": "状态必需填写",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"ui": {
|
||||
"clearAllConfirm": "确定清空所有玩家抽奖测试数据?",
|
||||
"clearAllSuccess": "已清空所有测试数据",
|
||||
"clearAllFail": "清空失败"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"t5Weight": "T5池权重(%)",
|
||||
"weightsSumHint": "五个池权重总和:",
|
||||
"weightsSumUnit": "% / 100%(必须为100%)",
|
||||
"ruleWeightsSumMustBe100": "五个池权重总和必须为100%",
|
||||
"walletTitle": "玩家钱包操作",
|
||||
"walletPlayer": "玩家",
|
||||
"walletBalance": "钱包余额",
|
||||
@@ -65,6 +66,7 @@
|
||||
"status": "状态",
|
||||
"coin": "平台币",
|
||||
"lotteryPoolConfig": "彩金池配置",
|
||||
"customConfig": "自定义",
|
||||
"t1Weight": "T1权重",
|
||||
"t2Weight": "T2权重",
|
||||
"t3Weight": "T3权重",
|
||||
|
||||
@@ -12,11 +12,14 @@
|
||||
"placeholderFreeDrawCount": "请输入赠送抽奖次数",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"placeholderTotalDrawCount": "自动求和",
|
||||
"placeholderRemark": "请输入备注(必填)"
|
||||
"placeholderRemark": "请输入备注(必填)",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"search": {
|
||||
"player": "玩家",
|
||||
"useCoins": "消耗硬币",
|
||||
"ante": "底注",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
@@ -27,6 +30,7 @@
|
||||
"id": "ID",
|
||||
"playerUsername": "玩家用户名",
|
||||
"useCoins": "消耗硬币",
|
||||
"ante": "底注",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"paidDrawCount": "购买抽奖次数",
|
||||
"freeDrawCount": "赠送抽奖次数",
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
"placeholderWalletBefore": "选择用户后自动带出当前平台币",
|
||||
"walletAfter": "钱包操作后",
|
||||
"placeholderWalletAfter": "根据平台币变化自动计算",
|
||||
"placeholderRemark": "选填"
|
||||
"placeholderRemark": "选填",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
},
|
||||
"search": {
|
||||
"type": "类型",
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"search": {
|
||||
"tier": "档位",
|
||||
"clockwise": "顺时针",
|
||||
"anticlockwise": "逆时针"
|
||||
"anticlockwise": "逆时针",
|
||||
"optionBigwin": "BIGWIN"
|
||||
},
|
||||
"table": {
|
||||
"startIndex": "起始索引",
|
||||
@@ -17,5 +18,78 @@
|
||||
"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": "测试模式默认不启用杀分切换;可通过下方“杀分开关 + 安全线”在测试内启用:当模拟玩家累计盈利达到安全线后,付费抽奖切换到 killScore。",
|
||||
"chainModeHint": "模拟方式:只配置付费抽奖次数(顺/逆时针)。付费抽到「再来一次」或 T5 时,下一局自动为免费抽奖,底注与触发局相同,抽奖类型记为免费、付费金额记为 0。免费抽奖的档位概率由下方「免费抽奖」配置决定(含通过再来一次触发的后续免费局)。",
|
||||
"killModeHint": "杀分开关开启后:以“模拟玩家累计盈利”作为判定值;当累计盈利 >= 安全线时,后续付费抽奖按 killScore 配置抽取;免费抽奖仍按“免费抽奖配置”执行。",
|
||||
"labelKillModeEnabled": "开启测试内杀分",
|
||||
"labelTestSafetyLine": "测试安全线",
|
||||
"sectionPaid": "付费抽奖",
|
||||
"sectionFreeAfterPlayAgain": "免费抽奖(再来一次后的档位概率)",
|
||||
"tierProbHintFreeChain": "当使用自定义档位时:以下为「免费抽奖」时 T1~T5 的档位概率(仅在有免费局时参与摇档,与 dice_reward 格子权重共同决定结果)。",
|
||||
"stepPaid": "付费抽奖券",
|
||||
"stepFree": "免费抽奖券",
|
||||
"labelLotteryTypePaid": "测试数据档位类型",
|
||||
"labelLotteryTypeFree": "测试数据档位类型",
|
||||
"labelAnte": "底注 ante",
|
||||
"placeholderPaidPool": "不选则下方自定义档位概率(默认 default)",
|
||||
"placeholderFreePool": "不选则下方自定义档位概率(默认 killScore)",
|
||||
"tierProbHint": "自定义档位概率(T1~T5),每档 0-100%,五档之和不能超过 100%",
|
||||
"tierFieldLabel": "档位 {tier}(%)",
|
||||
"tierSumError": "当前五档之和为 {sum}%,不能超过 100%",
|
||||
"labelCwCount": "顺时针次数",
|
||||
"labelCcwCount": "逆时针次数",
|
||||
"placeholderSelect": "请选择",
|
||||
"btnPrev": "上一步",
|
||||
"btnNext": "下一步",
|
||||
"btnStart": "开始测试",
|
||||
"btnCancel": "取消",
|
||||
"warnAnte": "底注 ante 必须大于 0",
|
||||
"warnPaidSpins": "付费抽奖顺时针与逆时针次数之和须大于 0",
|
||||
"warnTestSafetyLine": "测试安全线必须大于或等于 0",
|
||||
"warnTotalSpins": "付费或免费至少一种方向次数之和大于 0",
|
||||
"warnPaidTierSumPositive": "付费未选奖池时,T1~T5 档位概率之和需大于 0",
|
||||
"warnPaidTierSumMax": "付费档位概率 T1~T5 之和不能超过 100%",
|
||||
"warnFreeTierSumPositive": "免费未选奖池时,T1~T5 档位概率之和需大于 0",
|
||||
"warnFreeTierSumMax": "免费档位概率 T1~T5 之和不能超过 100%",
|
||||
"successCreated": "测试任务已创建,后台将自动执行。请在【玩家抽奖记录(测试数据)】中查看生成的测试数据",
|
||||
"failCreate": "创建测试任务失败"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,118 @@
|
||||
{
|
||||
"toolbar": {
|
||||
"gameRewardConfig": "游戏奖励配置",
|
||||
"createRewardRef": "创建奖励对照"
|
||||
"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": "结算金额",
|
||||
"colRealReward": "玩家实际中奖",
|
||||
"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",
|
||||
"btnRuleGenerate": "按规则生成",
|
||||
"ruleGenerateTitle": "按规则生成奖励索引",
|
||||
"ruleGenerateRules": "【生成逻辑(与创建奖励对照一致)】\n• 盘面 26 格按 id 升序为位置 0~25;每条配置的 grid_number 为 5~30 且不重复。\n• 摇取点数 D(5~30):起点为「grid_number=D」所在格位的 id(即 start_index),顺时针落点位置 = (起点位置 + D) mod 26,逆时针落点 = 起点位置 − D(若小于 0 则 +26)。\n• 对照表每条记录的「色子点数」列为摇取点数 D;档位、真实结算、显示文案取自落点格位对应 id 的配置。\n\n【豹子摇取点数】\n摇取点数为 5、10、15、20、25、30 时,其顺/逆时针落点档位不能为 T4、T5(避免对照表上出现豹子点数 + 惩罚/再来一次)。\n\n【结算金额 与 档位】\n结算金额 < 0 → T4;0 < 结算金额 < 100 → T3;100 < 结算金额 < 200 → T2;200 < 结算金额 → T1;T5「再来一次」结算金额=0。下方可为各档位填写统一的 结算金额 标准,生成时写入配置;细则可稍后在表格中再改。\n\n【本弹窗输入】\n条数:T1/T4/T5「固定」;T2「不少于」——顺时针与逆时针的加权条数(每条摇取结果计一次)须分别满足所填数值;T1、T4 与 T5 分开填写。\n结算金额 标准:同档位各格使用同一数值。生成时 T1~T4 的 显示文本 / 显示文本(英文) = 结算金额;T5 固定为「再来一次」/「Once again」。备注仍区分完美回本/小赚等。",
|
||||
"ruleGenT1Row": "T1 大奖",
|
||||
"ruleGenT2Row": "T2 小赚/回本",
|
||||
"ruleGenT3RealEvOnly": "T3 抽水",
|
||||
"ruleGenT4Row": "T4 惩罚",
|
||||
"ruleGenT5Row": "T5 再来一次",
|
||||
"ruleGenMinCount": "最少条数",
|
||||
"ruleGenFixedCount": "固定条数(顺/逆)",
|
||||
"ruleGenRealEvStd": "结算金额",
|
||||
"ruleGenRealEvEditHint": "生成并保存后,仍可在本页表格中逐条修改显示文案、英文、真实结算与备注。",
|
||||
"ruleGenInvalidT1RealEv": "T1 的 结算金额 满足:200 < 值",
|
||||
"ruleGenInvalidT2RealEv": "T2 的 结算金额 满足:100 < 值 < 200",
|
||||
"ruleGenInvalidT3RealEv": "T3 的 结算金额 满足:0 < 值 < 100",
|
||||
"ruleGenInvalidT4RealEv": "T4 的 结算金额 满足:值 < 0",
|
||||
"ruleGenInvalidT5RealEv": "T5「再来一次」的 结算金额 须为 0",
|
||||
"ruleGenT1Min": "T1 固定条数(顺/逆)",
|
||||
"ruleGenT2Min": "T2 最少条数(顺/逆)",
|
||||
"ruleGenT4Max": "T4 固定条数(顺/逆)",
|
||||
"ruleGenT5Max": "T5 固定条数(顺/逆)",
|
||||
"ruleGenScopeHint": "T1/T4/T5 为「恰好」;T2 为「不少于」:顺时针与逆时针加权条数须分别满足对应约束。",
|
||||
"ruleGenApply": "生成并保存",
|
||||
"ruleGenNeedFullGrid": "当前列表缺少 id 0~25 的奖励索引行或色子点数不完整,无法生成",
|
||||
"ruleGenFreqFail": "无法计算盘面频率,请检查 grid_number",
|
||||
"ruleGenUnknownId": "不存在奖励索引 id:{id}",
|
||||
"ruleGenSuccess": "已按规则生成并保存。顺时针加权:T1={cwT1} T2={cwT2} T4={cwT4} T5={cwT5};逆时针加权:T1={ccT1} T2={ccT2} T4={ccT4} T5={ccT5}",
|
||||
"btnJsonImport": "JSON 导入",
|
||||
"jsonImportTitle": "奖励索引 JSON 导入",
|
||||
"jsonImportHint": "当前「奖励索引」表数据(不含 BIGWIN)已填入下方,可编辑后提交;奖励索引 id 须为 0~25,色子点数 grid_number 须为 5~30。提交后将写入表格并保存。",
|
||||
"jsonImportParseFail": "JSON 解析失败,请检查格式",
|
||||
"jsonImportNotArray": "JSON 根节点必须为数组",
|
||||
"jsonImportItemInvalid": "第 {n} 项不是有效对象",
|
||||
"jsonImportMissingField": "第 {n} 项缺少字段:{field}",
|
||||
"jsonImportIdRange": "奖励索引 id 须为 0~25,第 {n} 项为 {v}",
|
||||
"jsonImportGridRange": "色子点数 grid_number 须为 5~30,第 {n} 项为 {v}",
|
||||
"jsonImportDupId": "JSON 内奖励索引 id 重复:{list}",
|
||||
"jsonImportDupGrid": "JSON 内色子点数重复:{list}",
|
||||
"jsonImportFullIdSet": "共 26 条时,奖励索引 id 必须且仅能各出现一次(0~25)",
|
||||
"jsonImportFullGridSet": "共 26 条时,色子点数必须且仅能各出现一次(5~30)",
|
||||
"jsonImportUnknownId": "不存在奖励索引 id:{id}(请从当前列表导出后编辑)",
|
||||
"jsonImportTierInvalid": "第 {n} 项所属档位 tier 无效",
|
||||
"jsonImportEmpty": "没有可提交的条目"
|
||||
},
|
||||
"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)",
|
||||
@@ -19,5 +130,34 @@
|
||||
"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": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,94 @@
|
||||
"toolbar": {
|
||||
"viewDetail": "查看详情"
|
||||
},
|
||||
"search": {
|
||||
"paidPlannedSpins": "计划付费次数",
|
||||
"ante": "底注"
|
||||
},
|
||||
"table": {
|
||||
"id": "ID",
|
||||
"clockwiseAbbr": "顺",
|
||||
"counterclockwiseAbbr": "逆",
|
||||
"status": "状态",
|
||||
"paidDraw": "付费抽取",
|
||||
"freeDraw": "免费抽取",
|
||||
"chainMode": "链式再来一次",
|
||||
"chainModeYes": "是",
|
||||
"chainModeNo": "否",
|
||||
"paidPlannedSpins": "计划付费次数",
|
||||
"ante": "底注",
|
||||
"playAgainCount": "再来一次次数",
|
||||
"progressDraws": "已完成 {over} 次",
|
||||
"progressFailed": "失败前 {over} 次",
|
||||
"platformProfit": "平台赚取金额",
|
||||
"totalDrawCount": "总抽奖次数",
|
||||
"createdBy": "创建管理员",
|
||||
"remark": "备注",
|
||||
"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": "次",
|
||||
"testCountProgress": "进行中:已完成 {over} 次",
|
||||
"testCountFailed": "失败前 {over} 次",
|
||||
"chainModeLabel": "链式再来一次",
|
||||
"paidPlannedSpins": "计划付费次数",
|
||||
"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": "逆时针"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,13 @@
|
||||
"fileType": "文件类型",
|
||||
"fileSize": "文件大小",
|
||||
"uploadTime": "上传时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增文件",
|
||||
"titleEdit": "编辑文件",
|
||||
"labelFileName": "文件名称",
|
||||
"placeholderFileName": "请输入文件名称",
|
||||
"ruleFileNameRequired": "请输入文件名称",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"search": {
|
||||
"deptName": "部门名称",
|
||||
"deptName": "渠道(部门)名称",
|
||||
"deptCode": "部门编码",
|
||||
"status": "状态",
|
||||
"placeholderDeptName": "请输入部门名称",
|
||||
@@ -8,11 +8,32 @@
|
||||
"searchSelectPlaceholder": "请选择"
|
||||
},
|
||||
"table": {
|
||||
"deptName": "部门名称",
|
||||
"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": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,49 @@
|
||||
"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": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,22 @@
|
||||
"sort": "排序",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增岗位",
|
||||
"titleEdit": "编辑岗位",
|
||||
"labelName": "岗位名称",
|
||||
"labelCode": "岗位编码",
|
||||
"labelRemark": "描述",
|
||||
"labelSort": "排序",
|
||||
"labelStatus": "启用",
|
||||
"placeholderName": "请输入岗位名称",
|
||||
"placeholderCode": "请输入岗位编码",
|
||||
"placeholderRemark": "请输入岗位描述",
|
||||
"placeholderSort": "请输入排序",
|
||||
"ruleNameRequired": "请输入岗位名称",
|
||||
"ruleCodeRequired": "请输入岗位编码",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,25 @@
|
||||
"roleRemark": "角色描述",
|
||||
"status": "状态",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"form": {
|
||||
"titleAdd": "新增角色",
|
||||
"titleEdit": "编辑角色",
|
||||
"labelName": "角色名称",
|
||||
"labelCode": "角色标识",
|
||||
"labelLevel": "角色级别",
|
||||
"levelTip": "控制角色的权限层级, 不能操作职级高于自己的角色",
|
||||
"labelRemark": "描述",
|
||||
"labelSort": "排序",
|
||||
"labelStatus": "启用",
|
||||
"placeholderName": "请输入角色名称",
|
||||
"placeholderCode": "请输入角色编码",
|
||||
"placeholderRemark": "请输入角色描述",
|
||||
"placeholderSort": "请输入排序",
|
||||
"ruleNameRequired": "请输入角色名称",
|
||||
"ruleCodeRequired": "请输入角色编码",
|
||||
"ruleLevelRequired": "请输入角色级别",
|
||||
"addSuccess": "新增成功",
|
||||
"editSuccess": "修改成功"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,41 @@
|
||||
"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": "修改成功"
|
||||
},
|
||||
"ui": {
|
||||
"promptNewPassword": "请输入新密码",
|
||||
"passwordLengthError": "密码长度在6到16之间",
|
||||
"passwordChanged": "修改密码成功",
|
||||
"clearCacheConfirm": "确定要清理缓存吗?"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,16 @@
|
||||
"tplCategory": "生成类型",
|
||||
"updateTime": "更新时间",
|
||||
"createTime": "创建时间"
|
||||
},
|
||||
"ui": {
|
||||
"generating": "代码生成下载中,请稍后",
|
||||
"generateSuccess": "代码生成成功,开始下载",
|
||||
"downloadFail": "文件下载失败",
|
||||
"syncConfirm": "执行同步操作将会覆盖已经设置的表结构,确定要同步吗?",
|
||||
"syncSuccess": "同步成功",
|
||||
"generateToProjectConfirm": "生成到项目将会覆盖原有文件,确定要生成吗?",
|
||||
"generateToProjectSuccess": "生成到项目成功",
|
||||
"loadSuccess": "装载成功",
|
||||
"copyToClipboard": "代码已复制到剪贴板"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,52 @@
|
||||
"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": "修改成功"
|
||||
},
|
||||
"ui": {
|
||||
"runTitle": "运行任务",
|
||||
"runConfirm": "确定要运行任务【{name}】吗?",
|
||||
"runSuccess": "任务运行成功",
|
||||
"selectTaskFirst": "请先选择一个任务"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,12 @@ function getModuleKey(locale: string, path: string): string {
|
||||
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 命名空间
|
||||
*/
|
||||
@@ -36,15 +42,34 @@ export async function loadPageLocale(routePath: string): Promise<void> {
|
||||
clearPageLocale()
|
||||
return
|
||||
}
|
||||
const locale = i18n.global.locale.value
|
||||
const key = getModuleKey(locale, path)
|
||||
const locale = getCurrentLocale()
|
||||
const modules = locale === LanguageEnum.EN ? enModules : zhModules
|
||||
const loader = modules[key]
|
||||
|
||||
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 === path && lastLoadedLocale === locale) {
|
||||
if (lastLoadedPath === matchedPath && lastLoadedLocale === locale) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -52,7 +77,7 @@ export async function loadPageLocale(routePath: string): Promise<void> {
|
||||
const message = mod?.default
|
||||
if (message && typeof message === 'object') {
|
||||
i18n.global.mergeLocaleMessage(locale, { page: message })
|
||||
lastLoadedPath = path
|
||||
lastLoadedPath = matchedPath
|
||||
lastLoadedLocale = locale
|
||||
}
|
||||
} catch {
|
||||
@@ -64,7 +89,7 @@ export async function loadPageLocale(routePath: string): Promise<void> {
|
||||
* 清除 page 命名空间(进入无页面翻译的路由时调用)
|
||||
*/
|
||||
export function clearPageLocale(): void {
|
||||
const locale = i18n.global.locale.value
|
||||
const locale = getCurrentLocale()
|
||||
const messages = i18n.global.getLocaleMessage(locale) as Record<string, unknown>
|
||||
if (messages && 'page' in messages) {
|
||||
const next = { ...messages }
|
||||
|
||||
@@ -209,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
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,19 @@
|
||||
|
||||
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'
|
||||
|
||||
/** 当前语言(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
|
||||
@@ -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')
|
||||
|
||||
@@ -42,6 +42,8 @@ export const MAP_PATH_TO_MENU_I18N_KEY: Record<string, string> = {
|
||||
'/dice': 'menus.dice.title',
|
||||
'/dice/lottery_pool_config': 'menus.dice.lotteryPoolConfig',
|
||||
'/dice/lottery_pool_config/index': 'menus.dice.lotteryPoolConfig',
|
||||
'/dice/ante_config': 'menus.dice.anteConfig',
|
||||
'/dice/ante_config/index': 'menus.dice.anteConfig',
|
||||
'/dice/player': 'menus.dice.player',
|
||||
'/dice/player/index': 'menus.dice.player',
|
||||
'/dice/player_wallet_record': 'menus.dice.playerWalletRecord',
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
{{ formatCoin(scope.row.coin) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('console.newPlayer.ticket')" prop="total_ticket_count" min-width="100" align="center" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
</div>
|
||||
|
||||
149
saiadmin-artd/src/views/plugin/dice/ante_config/index/index.vue
Normal file
149
saiadmin-artd/src/views/plugin/dice/ante_config/index/index.vue
Normal file
@@ -0,0 +1,149 @@
|
||||
<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:ante_config:index:save'"
|
||||
@click="showDialog('add')"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
{{ $t('table.actions.add') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:ante_config: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"
|
||||
>
|
||||
<template #is_default="{ row }">
|
||||
<ElTag :type="row.is_default === 1 ? 'primary' : 'warning'" size="small">
|
||||
{{ row.is_default === 1 ? $t('page.table.defaultYes') : $t('page.table.defaultNo') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:ante_config:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:ante_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/ante_config/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
const searchForm = ref({
|
||||
name: undefined,
|
||||
title: undefined,
|
||||
is_default: undefined
|
||||
})
|
||||
|
||||
const handleSearch = (params: Record<string, unknown>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||
{ prop: 'name', label: 'page.table.name', align: 'center' },
|
||||
{ prop: 'title', label: 'page.table.title', align: 'center' },
|
||||
{ prop: 'mult', label: 'page.table.mult', align: 'center' },
|
||||
{
|
||||
prop: 'is_default',
|
||||
label: 'page.table.isDefault',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170, align: 'center' },
|
||||
{ prop: 'update_time', label: 'page.table.updateTime', width: 170, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? $t('page.form.titleAdd') : $t('page.form.titleEdit')"
|
||||
width="560px"
|
||||
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.labelName')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.form.placeholderName')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelTitle')" prop="title">
|
||||
<el-input v-model="formData.title" :placeholder="$t('page.form.placeholderTitle')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelMult')" prop="mult">
|
||||
<el-input-number v-model="formData.mult" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.labelIsDefault')" prop="is_default">
|
||||
<el-radio-group v-model="formData.is_default">
|
||||
<el-radio :value="1">{{ $t('page.table.defaultYes') }}</el-radio>
|
||||
<el-radio :value="0">{{ $t('page.table.defaultNo') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</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/ante_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
|
||||
dialogType: string
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
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 formRef = ref<FormInstance>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
title: [{ required: true, message: t('page.form.ruleTitleRequired'), trigger: 'blur' }],
|
||||
mult: [{ required: true, message: t('page.form.ruleMultRequired'), trigger: 'blur' }],
|
||||
is_default: [{ required: true, message: t('page.form.ruleDefaultRequired'), trigger: 'change' }]
|
||||
}))
|
||||
|
||||
interface AnteFormData {
|
||||
id: number | null
|
||||
name: string
|
||||
title: string
|
||||
mult: number
|
||||
is_default: number
|
||||
}
|
||||
|
||||
const initialFormData: AnteFormData = {
|
||||
id: null,
|
||||
name: '',
|
||||
title: '',
|
||||
mult: 1,
|
||||
is_default: 0
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
async (newVal) => {
|
||||
if (!newVal) return
|
||||
Object.assign(formData, initialFormData)
|
||||
if (!props.data) return
|
||||
await nextTick()
|
||||
if (typeof props.data.id === 'number') formData.id = props.data.id
|
||||
if (typeof props.data.name === 'string') formData.name = props.data.name
|
||||
if (typeof props.data.title === 'string') formData.title = props.data.title
|
||||
formData.mult = Number(props.data.mult ?? 1) || 1
|
||||
formData.is_default = Number(props.data.is_default ?? 0) === 1 ? 1 : 0
|
||||
}
|
||||
)
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
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,76 @@
|
||||
<template>
|
||||
<sa-search-bar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
label-width="100px"
|
||||
:showExpand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.name')" prop="name">
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<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="$t('page.search.isDefault')" prop="is_default">
|
||||
<el-select v-model="formData.is_default" :placeholder="$t('page.search.placeholderIsDefault')" clearable>
|
||||
<el-option :label="$t('page.table.defaultYes')" :value="1" />
|
||||
<el-option :label="$t('page.table.defaultNo')" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type AnteConfigSearchForm = {
|
||||
name?: string
|
||||
title?: string
|
||||
/** 1=是 0=否 */
|
||||
is_default?: 0 | 1 | null
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: AnteConfigSearchForm
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: AnteConfigSearchForm): void
|
||||
(e: 'search', params: AnteConfigSearchForm): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed<AnteConfigSearchForm>({
|
||||
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) => {
|
||||
return {
|
||||
span,
|
||||
xs: 24,
|
||||
sm: span >= 12 ? span : 12,
|
||||
md: span >= 8 ? span : 8,
|
||||
lg: span,
|
||||
xl: span
|
||||
}
|
||||
}
|
||||
</script>
|
||||
40
saiadmin-artd/src/views/plugin/dice/api/ante_config/index.ts
Normal file
40
saiadmin-artd/src/views/plugin/dice/api/ante_config/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 底注配置 API
|
||||
*/
|
||||
export default {
|
||||
list(params: Record<string, unknown>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/core/dice/ante_config/DiceAnteConfig/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/ante_config/DiceAnteConfig/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
save(params: Record<string, unknown>) {
|
||||
return request.post({
|
||||
url: '/core/dice/ante_config/DiceAnteConfig/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
update(params: Record<string, unknown>) {
|
||||
return request.put({
|
||||
url: '/core/dice/ante_config/DiceAnteConfig/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
delete(params: Record<string, unknown>) {
|
||||
return request.del({
|
||||
url: '/core/dice/ante_config/DiceAnteConfig/destroy',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/config/DiceConfig/index',
|
||||
url: '/core/dice/config/DiceConfig/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/config/DiceConfig/read?id=' + id
|
||||
url: '/core/dice/config/DiceConfig/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/config/DiceConfig/save',
|
||||
url: '/core/dice/config/DiceConfig/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/config/DiceConfig/update',
|
||||
url: '/core/dice/config/DiceConfig/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/config/DiceConfig/destroy',
|
||||
url: '/core/dice/config/DiceConfig/destroy',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,14 +17,13 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,含 id、name、type、t1_weight~t5_weight,用于一键测试权重档位类型下拉
|
||||
* type:0=付费抽奖券,1=免费抽奖券;付费默认选 type=0,免费默认选 type=1
|
||||
* 获取 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
|
||||
type: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
@@ -40,7 +39,6 @@ export default {
|
||||
return rows.map((r: any) => ({
|
||||
id: Number(r.id),
|
||||
name: String(r.name ?? r.id ?? ''),
|
||||
type: Number(r.type ?? 0),
|
||||
t1_weight: Number(r.t1_weight ?? 0),
|
||||
t2_weight: Number(r.t2_weight ?? 0),
|
||||
t3_weight: Number(r.t3_weight ?? 0),
|
||||
@@ -104,6 +102,7 @@ export default {
|
||||
id: number
|
||||
name: string
|
||||
safety_line: number
|
||||
kill_enabled: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
@@ -118,14 +117,7 @@ export default {
|
||||
/**
|
||||
* 更新当前彩金池:仅 safety_line、t1_weight~t5_weight,不可改 profit_amount
|
||||
*/
|
||||
updateCurrentPool(params: {
|
||||
safety_line?: number
|
||||
t1_weight?: number
|
||||
t2_weight?: number
|
||||
t3_weight?: number
|
||||
t4_weight?: number
|
||||
t5_weight?: number
|
||||
}) {
|
||||
updateCurrentPool(params: { safety_line?: number; kill_enabled?: number }) {
|
||||
return request.post<any>({
|
||||
url: '/core/dice/lottery_pool_config/DiceLotteryPoolConfig/updateCurrentPool',
|
||||
data: params
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/play_record/DicePlayRecord/index',
|
||||
url: '/core/dice/play_record/DicePlayRecord/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/play_record/DicePlayRecord/read?id=' + id
|
||||
url: '/core/dice/play_record/DicePlayRecord/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/play_record/DicePlayRecord/save',
|
||||
url: '/core/dice/play_record/DicePlayRecord/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/play_record/DicePlayRecord/update',
|
||||
url: '/core/dice/play_record/DicePlayRecord/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/play_record/DicePlayRecord/destroy',
|
||||
url: '/core/dice/play_record/DicePlayRecord/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -66,21 +66,14 @@ export default {
|
||||
/** 获取玩家选项(id、username) */
|
||||
getPlayerOptions() {
|
||||
return request.get<{ id: number; username: string }[]>({
|
||||
url: '/dice/play_record/DicePlayRecord/getPlayerOptions'
|
||||
url: '/core/dice/play_record/DicePlayRecord/getPlayerOptions'
|
||||
})
|
||||
},
|
||||
|
||||
/** 获取彩金池配置选项(id、name) */
|
||||
getLotteryConfigOptions() {
|
||||
return request.get<{ id: number; name: string }[]>({
|
||||
url: '/dice/play_record/DicePlayRecord/getLotteryConfigOptions'
|
||||
})
|
||||
},
|
||||
|
||||
/** 获取奖励配置选项(id、ui_text、tier) */
|
||||
getRewardConfigOptions() {
|
||||
return request.get<{ id: number; ui_text: string; tier: string }[]>({
|
||||
url: '/dice/play_record/DicePlayRecord/getRewardConfigOptions'
|
||||
url: '/core/dice/play_record/DicePlayRecord/getLotteryConfigOptions'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
* @returns 数据列表
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
return request.get<Api.Common.ApiPage & { total_win_coin?: number }>({
|
||||
url: '/core/dice/play_record_test/DicePlayRecordTest/index',
|
||||
params
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/player/DicePlayer/index',
|
||||
url: '/core/dice/player/DicePlayer/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/player/DicePlayer/read?id=' + id
|
||||
url: '/core/dice/player/DicePlayer/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/player/DicePlayer/save',
|
||||
url: '/core/dice/player/DicePlayer/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/player/DicePlayer/update',
|
||||
url: '/core/dice/player/DicePlayer/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/player/DicePlayer/destroy',
|
||||
url: '/core/dice/player/DicePlayer/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -68,7 +68,7 @@ export default {
|
||||
*/
|
||||
updateStatus(params: { id: number | string; status: number }) {
|
||||
return request.put<any>({
|
||||
url: '/dice/player/DicePlayer/updateStatus',
|
||||
url: '/core/dice/player/DicePlayer/updateStatus',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -79,7 +79,7 @@ export default {
|
||||
*/
|
||||
async getLotteryConfigOptions(): Promise<Array<{ id: number; name: string }>> {
|
||||
const res = await request.get<any>({
|
||||
url: '/dice/player/DicePlayer/getLotteryConfigOptions'
|
||||
url: '/core/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 ?? '') }))
|
||||
@@ -93,7 +93,7 @@ export default {
|
||||
Array<{ id: number; username: string; realname: string; label: string }>
|
||||
> {
|
||||
const res = await request.get<any>({
|
||||
url: '/dice/player/DicePlayer/getSystemUserOptions'
|
||||
url: '/core/dice/player/DicePlayer/getSystemUserOptions'
|
||||
})
|
||||
const rows = (Array.isArray(res) ? res : (res?.data ?? [])) as Array<{
|
||||
id: number
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/index',
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/read?id=' + id
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/save',
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/update',
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/destroy',
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -68,7 +68,7 @@ export default {
|
||||
*/
|
||||
getPlayerOptions() {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/player_ticket_record/DicePlayerTicketRecord/getPlayerOptions'
|
||||
url: '/core/dice/player_ticket_record/DicePlayerTicketRecord/getPlayerOptions'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,17 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* 一键测试权重:创建测试记录并启动后台执行,按付费/免费、顺逆方向交替抽奖
|
||||
* 可选 lottery_config_id;不选则传 paid_tier_weights / free_tier_weights(T1-T5)
|
||||
* 一键测试权重:创建测试记录并启动后台执行
|
||||
* chain_free_mode=true:仅模拟付费次数;付费抽到再来一次则插入免费抽奖(同底注、付费金额 0)
|
||||
*/
|
||||
startWeightTest(params: {
|
||||
ante?: number
|
||||
lottery_config_id?: number
|
||||
paid_lottery_config_id?: number
|
||||
free_lottery_config_id?: number
|
||||
chain_free_mode?: boolean
|
||||
kill_mode_enabled?: boolean
|
||||
test_safety_line?: number
|
||||
s_count?: number
|
||||
n_count?: number
|
||||
paid_s_count?: number
|
||||
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
*/
|
||||
list(params: Record<string, any>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/index',
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
*/
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/read?id=' + id
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
*/
|
||||
save(params: Record<string, any>) {
|
||||
return request.post<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/save',
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
*/
|
||||
update(params: Record<string, any>) {
|
||||
return request.put<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/update',
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
*/
|
||||
delete(params: Record<string, any>) {
|
||||
return request.del<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/destroy',
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/destroy',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
lottery_config_id?: number | null
|
||||
}) {
|
||||
return request.post<any>({
|
||||
url: '/dice/reward_config_record/DiceRewardConfigRecord/importFromRecord',
|
||||
url: '/core/dice/reward_config_record/DiceRewardConfigRecord/importFromRecord',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: undefined,
|
||||
type: undefined
|
||||
// type 字段已移除,改用 name 区分:default/killScore/up
|
||||
})
|
||||
|
||||
// 搜索处理
|
||||
@@ -82,9 +82,14 @@
|
||||
getData()
|
||||
}
|
||||
|
||||
// 奖池类型展示:0=正常 1=强制杀猪 2=T1高倍率
|
||||
const typeFormatter = (row: Record<string, unknown>) =>
|
||||
row.type === 0 ? t('page.search.poolTypeNormal') : row.type === 1 ? t('page.search.poolTypeKill') : row.type === 2 ? t('page.search.poolTypeT1') : '-'
|
||||
// 奖池类型展示:按 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>) => {
|
||||
@@ -111,7 +116,7 @@
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'name', label: 'page.table.name', align: 'center' },
|
||||
{ prop: 'type', label: 'page.table.poolType', width: 100, align: 'center', formatter: typeFormatter },
|
||||
{ prop: 'name', label: 'page.table.poolType', width: 100, align: 'center', formatter: typeFormatter },
|
||||
{ prop: 'safety_line', label: 'page.table.safetyLine', align: 'center' },
|
||||
{
|
||||
prop: 't1_weight',
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
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 }}%
|
||||
@@ -49,20 +52,28 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="text-gray-500 text-sm">
|
||||
{{ $t('page.form.weightsSumHint') }}<span :class="weightsSum !== 100 ? 'text-red-500' : ''">{{
|
||||
weightsSum
|
||||
}}</span
|
||||
>{{ $t('page.form.weightsSumUnitCurrent') }} {{ $t('page.form.killWeightNote') }}
|
||||
{{ $t('page.form.killWeightNote') }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">{{ $t('form.close') }}</el-button>
|
||||
<el-button :loading="resetting" :disabled="!pool" @click="handleResetProfit">
|
||||
<el-button
|
||||
v-permission="'dice:lottery_pool_config:index:resetProfitAmount'"
|
||||
:loading="resetting"
|
||||
:disabled="!pool"
|
||||
@click="handleResetProfit"
|
||||
>
|
||||
{{ $t('page.form.btnResetProfit') }}
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="saving" :disabled="!pool" @click="handleSubmit">
|
||||
<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>
|
||||
@@ -81,6 +92,7 @@
|
||||
id: number
|
||||
name: string
|
||||
safety_line: number
|
||||
kill_enabled: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
@@ -104,7 +116,8 @@
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const formData = reactive({
|
||||
safety_line: 0
|
||||
safety_line: 0,
|
||||
kill_enabled: 1
|
||||
})
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
@@ -143,6 +156,7 @@
|
||||
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'))
|
||||
@@ -180,7 +194,8 @@
|
||||
await formRef.value?.validate?.()
|
||||
saving.value = true
|
||||
await api.updateCurrentPool({
|
||||
safety_line: formData.safety_line
|
||||
safety_line: formData.safety_line,
|
||||
kill_enabled: formData.kill_enabled
|
||||
})
|
||||
ElMessage.success(t('page.form.msgSaveSuccess'))
|
||||
await loadPool()
|
||||
|
||||
@@ -25,19 +25,7 @@
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.poolType')" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:placeholder="$t('page.form.placeholderPoolType')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option :label="$t('page.form.poolTypeNormal')" :value="0" />
|
||||
<el-option :label="$t('page.form.poolTypeKill')" :value="1" />
|
||||
<el-option :label="$t('page.form.poolTypeT1')" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 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"
|
||||
@@ -127,7 +115,6 @@
|
||||
*/
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
type: [{ required: true, message: t('page.form.rulePoolTypeRequired'), trigger: 'change' }],
|
||||
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' }],
|
||||
@@ -142,7 +129,6 @@
|
||||
id: null as number | null,
|
||||
name: '',
|
||||
remark: '',
|
||||
type: null as number | null,
|
||||
safety_line: 0 as number,
|
||||
t1_weight: 0 as number,
|
||||
t2_weight: 0 as number,
|
||||
@@ -188,7 +174,6 @@
|
||||
if (!props.data) return
|
||||
const numKeys = [
|
||||
'id',
|
||||
'type',
|
||||
'safety_line',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
|
||||
@@ -13,16 +13,7 @@
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.poolType')" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:options="typeOptions"
|
||||
:placeholder="$t('page.search.placeholderPoolType')"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- dice_lottery_pool_config 已移除 type 字段,按 name 区分 default/killScore/up -->
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
@@ -42,11 +33,7 @@
|
||||
const isExpanded = ref<boolean>(false)
|
||||
|
||||
const { t } = useI18n()
|
||||
const typeOptions = computed(() => [
|
||||
{ name: '0', value: t('page.search.poolTypeNormal') },
|
||||
{ name: '1', value: t('page.search.poolTypeKill') },
|
||||
{ name: '2', value: t('page.search.poolTypeT1') }
|
||||
])
|
||||
// type 字段已移除
|
||||
// 表单数据双向绑定
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<!-- 表格头部 -->
|
||||
<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>-->
|
||||
<!-- <ElButton-->
|
||||
<!-- v-permission="'dice:play_record:index:save'"-->
|
||||
@@ -53,21 +56,52 @@
|
||||
<!-- 抽奖类型 tag -->
|
||||
<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') : '-' }}
|
||||
{{
|
||||
row.lottery_type === 0
|
||||
? t('page.search.paid')
|
||||
: row.lottery_type === 1
|
||||
? t('page.search.free')
|
||||
: '-'
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 是否中大奖 tag -->
|
||||
<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') : '-' }}
|
||||
{{
|
||||
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 ? t('page.search.clockwise') : row.direction === 1 ? t('page.search.anticlockwise') : '-' }}
|
||||
{{
|
||||
row.direction === 0
|
||||
? t('page.search.clockwise')
|
||||
: row.direction === 1
|
||||
? t('page.search.anticlockwise')
|
||||
: '-'
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 平台币相关:统一整数显示 -->
|
||||
<template #win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.win_coin) }}</span>
|
||||
</template>
|
||||
<template #super_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.super_win_coin) }}</span>
|
||||
</template>
|
||||
<template #reward_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.reward_win_coin) }}</span>
|
||||
</template>
|
||||
<template #paid_amount="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.paid_amount) }}</span>
|
||||
</template>
|
||||
<!-- 摇取点数 tag -->
|
||||
<template #roll_array="{ row }">
|
||||
<ElTag size="small">
|
||||
@@ -126,6 +160,15 @@
|
||||
direction: undefined
|
||||
})
|
||||
|
||||
/** 当前筛选下平台总盈利(付费金额 paid_amount 求和 - 玩家总收益) */
|
||||
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)
|
||||
@@ -136,8 +179,7 @@
|
||||
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
||||
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 ?? '-'
|
||||
const rewardTierFormatter = (row: Record<string, any>) => row?.reward_tier ?? '-'
|
||||
|
||||
/** 摇取点数格式化为 1,3,4,5,6,6 */
|
||||
function formatRollArray(val: unknown): string {
|
||||
@@ -154,6 +196,13 @@
|
||||
return String(val)
|
||||
}
|
||||
|
||||
function formatPlatformCoin(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
@@ -170,7 +219,8 @@
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiFn: listApi,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
// { type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80 },
|
||||
@@ -186,23 +236,32 @@
|
||||
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: 'ante', label: 'page.table.ante', width: 80, align: 'center' },
|
||||
{ prop: 'paid_amount', label: 'page.table.paidAmount', width: 110, align: 'center', useSlot: true },
|
||||
{ prop: 'is_win', label: 'page.table.isBigWin', width: 100, useSlot: true },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110, useSlot: true },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120, useSlot: true },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140, 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',
|
||||
prop: 'reward_tier',
|
||||
label: 'page.table.rewardTier',
|
||||
width: 100,
|
||||
formatter: (row: Record<string, any>) => rewardTierFormatter(row)
|
||||
},
|
||||
{ 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 }
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -219,3 +278,15 @@
|
||||
// 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>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin"
|
||||
:placeholder="$t('page.form.placeholderWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
@@ -79,7 +79,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.super_win_coin"
|
||||
:placeholder="$t('page.form.placeholderSuperWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
@@ -89,7 +89,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.reward_win_coin"
|
||||
:placeholder="$t('page.form.placeholderRewardWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
@@ -153,25 +153,21 @@
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.rewardConfig')" prop="reward_config_id">
|
||||
<el-form-item :label="$t('page.form.rewardTier')" prop="reward_tier">
|
||||
<el-select
|
||||
v-model="formData.reward_config_id"
|
||||
:placeholder="$t('page.form.placeholderRewardConfig')"
|
||||
v-model="formData.reward_tier"
|
||||
:placeholder="$t('page.form.placeholderRewardTier')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
:disabled="true"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in rewardConfigOptions"
|
||||
:key="item.id"
|
||||
:label="
|
||||
item.ui_text
|
||||
? `${item.ui_text}${item.tier ? ' (' + item.tier + ')' : ''}`
|
||||
: String(item.id)
|
||||
"
|
||||
:value="item.id"
|
||||
/>
|
||||
<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="BIGWIN" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -184,9 +180,12 @@
|
||||
|
||||
<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
|
||||
@@ -236,12 +235,11 @@
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
reward_config_id: [{ required: true, message: '请选择奖励配置', trigger: 'change' }]
|
||||
reward_tier: [{ required: true, message: '请选择中奖档位', trigger: 'change' }]
|
||||
})
|
||||
|
||||
const playerOptions = ref<Array<{ id: number; username: string }>>([])
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
const rewardConfigOptions = ref<Array<{ id: number; ui_text: string; tier: string }>>([])
|
||||
|
||||
const initialFormData = {
|
||||
id: null as number | null,
|
||||
@@ -257,7 +255,7 @@
|
||||
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
|
||||
reward_tier: '' as string
|
||||
}
|
||||
|
||||
/** 摇取点数固定 5 位 [n0..n4],每项 1~6 */
|
||||
@@ -274,22 +272,17 @@
|
||||
if (open) {
|
||||
initPage()
|
||||
try {
|
||||
const [players, lotteryConfigs, rewardConfigs] = await Promise.all([
|
||||
const [players, lotteryConfigs] = await Promise.all([
|
||||
api.getPlayerOptions(),
|
||||
api.getLotteryConfigOptions(),
|
||||
api.getRewardConfigOptions()
|
||||
api.getLotteryConfigOptions()
|
||||
])
|
||||
playerOptions.value = Array.isArray(players) ? players : ((players as any)?.data ?? [])
|
||||
lotteryConfigOptions.value = Array.isArray(lotteryConfigs)
|
||||
? lotteryConfigs
|
||||
: ((lotteryConfigs as any)?.data ?? [])
|
||||
rewardConfigOptions.value = Array.isArray(rewardConfigs)
|
||||
? rewardConfigs
|
||||
: ((rewardConfigs as any)?.data ?? [])
|
||||
} catch {
|
||||
playerOptions.value = []
|
||||
lotteryConfigOptions.value = []
|
||||
rewardConfigOptions.value = []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,7 +312,7 @@
|
||||
'target_index',
|
||||
'roll_array',
|
||||
'roll_number',
|
||||
'reward_config_id'
|
||||
'reward_tier'
|
||||
]
|
||||
keys.forEach((key) => {
|
||||
const val = props.data![key]
|
||||
@@ -399,15 +392,15 @@
|
||||
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') {
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_min"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -56,7 +56,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_max"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -101,6 +101,7 @@
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option label="BIGWIN" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
<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>
|
||||
{{ $t('page.toolbar.platformTotalProfit') }}:<strong>{{
|
||||
formatPlatformCoin(totalWinCoin)
|
||||
}}</strong>
|
||||
</span>
|
||||
<ElSpace wrap class="table-toolbar-buttons">
|
||||
<ElButton
|
||||
@@ -23,7 +25,7 @@
|
||||
{{ $t('table.actions.delete') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:play_record_test:index:destroy'"
|
||||
v-permission="'dice:play_record_test:index:clearAll'"
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleClearAll"
|
||||
@@ -58,19 +60,37 @@
|
||||
<!-- 抽奖类型 -->
|
||||
<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') : '-' }}
|
||||
{{
|
||||
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') : '-' }}
|
||||
{{
|
||||
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') : '-' }}
|
||||
{{
|
||||
row.direction === 0
|
||||
? t('page.search.clockwise')
|
||||
: row.direction === 1
|
||||
? t('page.search.anticlockwise')
|
||||
: '-'
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 摇取点数 -->
|
||||
@@ -79,10 +99,20 @@
|
||||
{{ formatRollArray(row.roll_array) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 奖励档位:显示 DiceRewardConfig.tier -->
|
||||
<template #reward_config_id="{ row }">
|
||||
<!-- 奖励档位:优先显示记录自带 reward_tier -->
|
||||
<template #reward_tier="{ row }">
|
||||
<ElTag size="small">{{ rewardTierFormatter(row) }}</ElTag>
|
||||
</template>
|
||||
<!-- 平台币相关:统一整数显示 -->
|
||||
<template #win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.win_coin) }}</span>
|
||||
</template>
|
||||
<template #super_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.super_win_coin) }}</span>
|
||||
</template>
|
||||
<template #reward_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.reward_win_coin) }}</span>
|
||||
</template>
|
||||
<!-- 状态 -->
|
||||
<template #status="{ row }">
|
||||
<ElTag size="small" :type="row.status === 1 ? 'success' : 'info'">
|
||||
@@ -129,28 +159,30 @@
|
||||
|
||||
// 搜索表单(与 play_record 对齐:方向、赢取平台币范围、是否中大奖、中奖档位、点数和)
|
||||
const searchForm = ref<Record<string, unknown>>({
|
||||
reward_config_record_id: undefined,
|
||||
lottery_type: undefined,
|
||||
direction: undefined,
|
||||
is_win: undefined,
|
||||
paid_amount: undefined,
|
||||
ante: undefined,
|
||||
win_coin_min: undefined,
|
||||
win_coin_max: undefined,
|
||||
reward_tier: undefined,
|
||||
roll_number: undefined
|
||||
})
|
||||
|
||||
// 当前筛选下平台总盈利(付费抽奖次数×100 - 玩家总收益)
|
||||
// 当前筛选下平台总盈利(付费金额 paid_amount 求和 - 玩家总收益)
|
||||
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
|
||||
totalWinCoin.value = res?.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 ?? '-'
|
||||
const rewardTierFormatter = (row: Record<string, any>) => row?.reward_tier ?? '-'
|
||||
|
||||
/** 摇取点数格式化为 1,3,4,5,6 */
|
||||
function formatRollArray(val: unknown): string {
|
||||
@@ -167,17 +199,24 @@
|
||||
return String(val)
|
||||
}
|
||||
|
||||
function formatPlatformCoin(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
const handleClearAll = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定清空所有玩家抽奖测试数据?', '提示', {
|
||||
await ElMessageBox.confirm(t('page.ui.clearAllConfirm'), t('uiMsg.titlePrompt'), {
|
||||
type: 'warning'
|
||||
})
|
||||
await api.clearAll()
|
||||
ElMessage.success('已清空所有测试数据')
|
||||
ElMessage.success(t('page.ui.clearAllSuccess'))
|
||||
getData()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
ElMessage.error(e?.message || '清空失败')
|
||||
ElMessage.error(e?.message || t('page.ui.clearAllFail'))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,21 +247,39 @@
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80 },
|
||||
{ prop: 'lottery_config_id', label: 'page.table.lotteryPoolConfig', width: 120, useSlot: true },
|
||||
{
|
||||
prop: 'reward_config_record_id',
|
||||
label: 'page.table.rewardConfigRecordId',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
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: 'ante', label: 'page.table.ante', width: 90 },
|
||||
{ prop: 'is_win', label: 'page.table.isBigWin', width: 100, useSlot: true },
|
||||
{ prop: 'paid_amount', label: 'page.table.paidAmount', width: 130 },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110, useSlot: true },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120, useSlot: true },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140, 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: 'reward_tier', label: 'page.table.rewardTier', 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 }
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,106 +1,130 @@
|
||||
<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="彩金池配置id" prop="lottery_config_id">
|
||||
<el-input v-model="formData.lottery_config_id" placeholder="请输入彩金池配置id" />
|
||||
<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="抽奖类型" 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%"
|
||||
>
|
||||
<el-option label="付费" :value="0" />
|
||||
<el-option label="赠送" :value="1" />
|
||||
<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="方向" 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('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="是否中大奖" 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-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="赢取平台币" prop="win_coin">
|
||||
<el-form-item :label="$t('page.search.ante')" prop="ante">
|
||||
<el-input-number
|
||||
v-model="formData.win_coin"
|
||||
placeholder="赢取平台币"
|
||||
:precision="2"
|
||||
v-model="formData.ante"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="中奖档位" prop="reward_tier">
|
||||
<el-form-item :label="$t('page.search.paidAmount')" prop="paid_amount">
|
||||
<el-input-number
|
||||
v-model="formData.paid_amount"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</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="0"
|
||||
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="请选择档位(选后自动带出奖励配置ID)"
|
||||
: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-option label="BIGWIN" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖励配置id" prop="reward_config_id">
|
||||
<el-input
|
||||
v-model="formData.reward_config_id"
|
||||
placeholder="可选中奖档位自动带出或手动输入"
|
||||
/>
|
||||
<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="起始索引" prop="start_index">
|
||||
<el-input v-model="formData.start_index" placeholder="请输入起始索引" />
|
||||
<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="结束索引" prop="target_index">
|
||||
<el-input v-model="formData.target_index" placeholder="请输入结束索引" />
|
||||
<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="摇取点数和" prop="roll_number">
|
||||
<el-input v-model="formData.roll_number" placeholder="请输入摇取点数和" />
|
||||
<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="摇取点数:[1,2,3,4,5,6]" prop="roll_array">
|
||||
<el-input v-model="formData.roll_array" placeholder="请输入摇取点数:[1,2,3,4,5,6]" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态:0=失败,1=成功" 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="super_win_coin">
|
||||
<el-input v-model="formData.super_win_coin" placeholder="请输入中大奖平台币" />
|
||||
<el-form-item :label="$t('page.table.superWinCoin')" prop="super_win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.super_win_coin"
|
||||
:placeholder="$t('page.form.placeholderSuperWinCoin')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="摇色子中奖平台币" prop="reward_win_coin">
|
||||
<el-input v-model="formData.reward_win_coin" placeholder="请输入摇色子中奖平台币" />
|
||||
<el-form-item :label="$t('page.table.rewardWinCoin')" prop="reward_win_coin">
|
||||
<el-input-number
|
||||
v-model="formData.reward_win_coin"
|
||||
:placeholder="$t('page.form.placeholderRewardWinCoin')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属管理员" prop="admin_id">
|
||||
<el-input v-model="formData.admin_id" placeholder="请输入所属管理员" />
|
||||
<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">取消</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/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
|
||||
@@ -120,6 +144,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -134,14 +159,14 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
lottery_config_id: [{ required: true, message: '彩金池配置id必需填写', trigger: 'blur' }],
|
||||
lottery_type: [{ required: true, message: '抽奖类型:0=付费,1=赠送必需填写', trigger: 'blur' }],
|
||||
is_win: [{ required: true, message: '中大奖:0=无,1=中奖必需填写', trigger: 'blur' }],
|
||||
direction: [{ required: true, message: '方向:0=顺时针,1=逆时针必需填写', trigger: 'blur' }],
|
||||
reward_config_id: [{ required: true, message: '奖励配置id必需填写', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态:0=失败,1=成功必需填写', trigger: 'blur' }]
|
||||
})
|
||||
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_tier: [{ required: true, message: t('page.form.ruleRewardTierRequired'), trigger: 'blur' }],
|
||||
status: [{ required: true, message: t('page.form.ruleStatusRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -151,17 +176,18 @@
|
||||
lottery_config_id: null,
|
||||
lottery_type: null,
|
||||
is_win: null,
|
||||
ante: 1,
|
||||
paid_amount: 0,
|
||||
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',
|
||||
super_win_coin: 0,
|
||||
reward_win_coin: 0,
|
||||
admin_id: null
|
||||
}
|
||||
|
||||
@@ -198,44 +224,26 @@
|
||||
/**
|
||||
* 初始化表单数据
|
||||
*/
|
||||
function normalizePlatformCoin(val: unknown): number {
|
||||
if (val === '' || val === null || val === undefined) return 0
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return 0
|
||||
return Math.trunc(n)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
formData.win_coin = normalizePlatformCoin(formData.win_coin)
|
||||
formData.super_win_coin = normalizePlatformCoin(formData.super_win_coin)
|
||||
formData.reward_win_coin = normalizePlatformCoin(formData.reward_win_coin)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖档位变更:按档位拉取奖励配置并取第一条的 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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并重置表单
|
||||
@@ -253,13 +261,12 @@
|
||||
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('新增成功')
|
||||
ElMessage.success(t('page.form.addSuccess'))
|
||||
} else {
|
||||
await api.update(payload)
|
||||
ElMessage.success('修改成功')
|
||||
ElMessage.success(t('page.form.editSuccess'))
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
@search="handleSearch"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.rewardConfigRecordId')" prop="reward_config_record_id">
|
||||
<el-input-number
|
||||
v-model="formData.reward_config_record_id"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:precision="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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%">
|
||||
@@ -32,13 +44,35 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.paidAmount')" prop="paid_amount">
|
||||
<el-input-number
|
||||
v-model="formData.paid_amount"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.ante')" prop="ante">
|
||||
<el-input-number
|
||||
v-model="formData.ante"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</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"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -46,7 +80,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_max"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -61,6 +95,7 @@
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option label="BIGWIN" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -98,6 +98,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/index'
|
||||
@@ -105,6 +106,8 @@
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
import WalletOperateDialog from './modules/WalletOperateDialog.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
username: undefined,
|
||||
@@ -129,7 +132,8 @@
|
||||
|
||||
// 根据 lottery_config_id 显示彩金池配置名称
|
||||
const lotteryConfigNameFormatter = (row: any) =>
|
||||
row?.diceLotteryPoolConfig?.name ?? (row?.lottery_config_id ? `#${row.lottery_config_id}` : '未知')
|
||||
row?.diceLotteryPoolConfig?.name ??
|
||||
(row?.lottery_config_id ? `#${row.lottery_config_id}` : t('page.table.customConfig'))
|
||||
|
||||
// 表格
|
||||
const {
|
||||
@@ -163,7 +167,7 @@
|
||||
{
|
||||
prop: 'coin',
|
||||
label: 'page.table.coin',
|
||||
width: 100,
|
||||
width: 110,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelType') }}:</span>
|
||||
<span>{{ lotteryConfigTypeText(currentLotteryConfig.type) }}</span>
|
||||
<span>{{ lotteryConfigTypeText(currentLotteryConfig.name) }}</span>
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelWeights') }}:</span>
|
||||
@@ -171,9 +171,11 @@
|
||||
<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 {
|
||||
@@ -265,11 +267,12 @@
|
||||
/** 当前选中的 DiceLotteryConfig 完整数据(用于展示) */
|
||||
const currentLotteryConfig = ref<Record<string, any> | null>(null)
|
||||
|
||||
function lotteryConfigTypeText(type: unknown): string {
|
||||
const t = Number(type)
|
||||
if (t === 0) return '付费'
|
||||
if (t === 1) return '赠送'
|
||||
return t ? `类型${t}` : '-'
|
||||
function lotteryConfigTypeText(name: unknown): string {
|
||||
const n = String(name ?? '')
|
||||
if (n === 'default') return '默认'
|
||||
if (n === 'killScore') return '杀分'
|
||||
if (n === 'up') return '上分'
|
||||
return n || '-'
|
||||
}
|
||||
|
||||
/** 是否为空/自定义权重(未选彩金池或选 0) */
|
||||
@@ -415,7 +418,7 @@
|
||||
await formRef.value.validate()
|
||||
const useCustomWeights = isLotteryConfigEmpty()
|
||||
if (useCustomWeights && Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
ElMessage.warning('五个池权重总和必须为100%')
|
||||
ElMessage.warning(t('page.form.ruleWeightsSumMustBe100'))
|
||||
return
|
||||
}
|
||||
const payload = { ...formData }
|
||||
@@ -427,10 +430,10 @@
|
||||
}
|
||||
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()
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
username: undefined,
|
||||
use_coins_min: undefined,
|
||||
use_coins_max: undefined,
|
||||
ante: undefined,
|
||||
total_ticket_count_min: undefined,
|
||||
total_ticket_count_max: undefined,
|
||||
paid_ticket_count_min: undefined,
|
||||
@@ -122,6 +123,7 @@
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => {
|
||||
const usernameFormatter = (row: Record<string, any>) =>
|
||||
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
||||
@@ -135,6 +137,7 @@
|
||||
formatter: (row: Record<string, any>) => usernameFormatter(row)
|
||||
},
|
||||
{ prop: 'use_coins', label: 'page.table.useCoins', align: 'center' },
|
||||
{ prop: 'ante', label: 'page.table.ante', 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' },
|
||||
|
||||
@@ -81,9 +81,12 @@
|
||||
|
||||
<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
|
||||
@@ -230,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()
|
||||
|
||||
@@ -34,6 +34,18 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.ante')" prop="ante">
|
||||
<el-input-number
|
||||
v-model="formData.ante"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.totalDrawCount')" prop="total_ticket_count_min">
|
||||
<div class="range-wrap">
|
||||
|
||||
@@ -146,6 +146,13 @@
|
||||
return player?.username ?? row.player_id ?? '-'
|
||||
}
|
||||
|
||||
function formatMoney2(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
@@ -163,6 +170,7 @@
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
apiParams: { limit: 100 },
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection', align: 'center' },
|
||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||
@@ -189,8 +197,20 @@
|
||||
align: 'center',
|
||||
formatter: operatorFormatter
|
||||
},
|
||||
{ prop: 'wallet_before', label: 'page.table.walletBefore', width: 110, align: 'center' },
|
||||
{ prop: 'wallet_after', label: 'page.table.walletAfter', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'wallet_before',
|
||||
label: 'page.table.walletBefore',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatMoney2(row?.wallet_before)
|
||||
},
|
||||
{
|
||||
prop: 'wallet_after',
|
||||
label: 'page.table.walletAfter',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatMoney2(row?.wallet_after)
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: 'page.table.remark',
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
v-model="formData.coin"
|
||||
:placeholder="$t('page.form.placeholderCoinChange')"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
style="width: 100%"
|
||||
@change="onCoinChange"
|
||||
:disabled="dialogType === 'edit'"
|
||||
@@ -90,9 +91,12 @@
|
||||
|
||||
<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
|
||||
@@ -128,14 +132,22 @@
|
||||
type: [{ required: true, message: '请选择类型', trigger: 'change' }]
|
||||
})
|
||||
|
||||
const initialFormData = {
|
||||
id: null as number | null,
|
||||
player_id: null as number | null,
|
||||
coin: 0 as number,
|
||||
type: null as number | null,
|
||||
wallet_before: 0 as number,
|
||||
wallet_after: 0 as number,
|
||||
remark: '' as string
|
||||
const initialFormData: {
|
||||
id: number | null
|
||||
player_id: number | null
|
||||
coin: number
|
||||
type: number | null
|
||||
wallet_before: number
|
||||
wallet_after: number
|
||||
remark: string
|
||||
} = {
|
||||
id: null,
|
||||
player_id: null,
|
||||
coin: 0,
|
||||
type: null,
|
||||
wallet_before: 0,
|
||||
wallet_after: 0,
|
||||
remark: ''
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
@@ -167,7 +179,7 @@
|
||||
function calcWalletAfter() {
|
||||
const before = Number(formData.wallet_before) || 0
|
||||
const coin = Number(formData.coin) || 0
|
||||
formData.wallet_after = Math.round((before + coin) * 100) / 100
|
||||
formData.wallet_after = Number((before + coin).toFixed(2))
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -193,23 +205,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
const numKeys = ['id', 'player_id', 'coin', 'type', 'wallet_before', 'wallet_after']
|
||||
function normalizeMoney2(val: unknown, fallback: number): number {
|
||||
if (val === '' || val === null || val === undefined) return fallback
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return fallback
|
||||
return Number(n.toFixed(2))
|
||||
}
|
||||
|
||||
const initForm = () => {
|
||||
if (!props.data) return
|
||||
for (const key of Object.keys(formData)) {
|
||||
if (!(key in props.data)) continue
|
||||
const val = props.data[key]
|
||||
if (numKeys.includes(key)) {
|
||||
if (key === 'id' || key === 'player_id' || key === 'type') {
|
||||
;(formData as any)[key] = val != null && val !== '' ? Number(val) : null
|
||||
} else {
|
||||
;(formData as any)[key] = val != null && val !== '' ? Number(val) : 0
|
||||
}
|
||||
} else {
|
||||
;(formData as any)[key] = val ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
formData.id = props.data.id != null && props.data.id !== '' ? Number(props.data.id) : null
|
||||
formData.player_id =
|
||||
props.data.player_id != null && props.data.player_id !== '' ? Number(props.data.player_id) : null
|
||||
formData.type = props.data.type != null && props.data.type !== '' ? Number(props.data.type) : null
|
||||
formData.coin = normalizeMoney2(props.data.coin, 0)
|
||||
formData.wallet_before = normalizeMoney2(props.data.wallet_before, 0)
|
||||
formData.wallet_after = normalizeMoney2(props.data.wallet_after, 0)
|
||||
formData.remark = props.data.remark ?? ''
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -225,10 +238,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()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-permission="'dice:reward:index:update'"
|
||||
v-permission="'dice:reward:index:batchUpdateWeights'"
|
||||
type="primary"
|
||||
@click="weightRatioVisible = true"
|
||||
v-ripple
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ $t('page.toolbar.weightRatio') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:reward:index:index'"
|
||||
v-permission="'dice:reward:index:startWeightTest'"
|
||||
@click="weightTestVisible = true"
|
||||
v-ripple
|
||||
>
|
||||
@@ -70,6 +70,13 @@
|
||||
return api.list({ ...params, direction: currentDirection.value })
|
||||
}
|
||||
|
||||
function formatMoney2(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, { ...params, direction: currentDirection.value })
|
||||
getData()
|
||||
@@ -117,7 +124,13 @@
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'real_ev', label: 'page.table.realEv', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'real_ev',
|
||||
label: 'page.table.realEv',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatMoney2(row?.real_ev)
|
||||
},
|
||||
{ prop: 'remark', label: 'page.table.remark', minWidth: 80, align: 'center', showOverflowTooltip: true },
|
||||
{ prop: 'weight', label: 'page.table.weight', width: 110, align: 'center' }
|
||||
]
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option label="BIGWIN" value="BIGWIN" />
|
||||
<el-option :label="$t('page.search.optionBigwin')" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="奖励对照表(dice_reward)权重配比"
|
||||
:title="$t('page.weightEdit.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
编辑的是<strong>奖励对照表(dice_reward / DiceReward 模型)</strong
|
||||
>的权重,按<strong>结束索引(end_index)</strong>区分
|
||||
<strong>顺时针</strong>与<strong>逆时针</strong>两套权重;抽奖时按当前方向取对应权重。
|
||||
{{ $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">该档位暂无配置数据</div>
|
||||
<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="结束索引"
|
||||
:x-axis-name="$t('page.weightShared.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'clockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
<ArtBarChart
|
||||
x-axis-name="结束索引"
|
||||
:x-axis-name="$t('page.weightShared.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'counterclockwise')"
|
||||
height="180px"
|
||||
@@ -34,42 +32,54 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
当前档位权重合计(顺时针):<strong>{{ getTierSum(t, 'clockwise') }}</strong>
|
||||
;逆时针:<strong>{{ getTierSum(t, 'counterclockwise') }}</strong>
|
||||
(各条 1-10000,和不限制)
|
||||
{{
|
||||
$t('page.weightShared.sumLineDual', {
|
||||
cw: getTierSum(t, 'clockwise'),
|
||||
ccw: getTierSum(t, 'counterclockwise')
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>T4、T5 仅单一结果,无需配置权重。</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="结束索引(id)"
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="色子点数" prop="grid_number" width="80" align="center" />
|
||||
<el-table-column
|
||||
label="实际中奖金额"
|
||||
: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
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatMoney2(row?.real_ev) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="显示文本"
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="备注"
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="顺时针权重(direction=0)" min-width="160" align="center">
|
||||
<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">
|
||||
@@ -146,7 +156,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="逆时针权重(direction=1)" min-width="160" align="center">
|
||||
<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">
|
||||
@@ -232,8 +242,10 @@
|
||||
</el-tabs>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交</el-button>
|
||||
<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>
|
||||
@@ -242,6 +254,16 @@
|
||||
import api from '../../../api/reward/index'
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
function formatMoney2(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
/** 供模板 v-for 使用 */
|
||||
@@ -430,7 +452,7 @@
|
||||
grouped.value = parsePayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('获取权重数据失败')
|
||||
ElMessage.error(t('page.weightShared.fetchFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
@@ -456,19 +478,19 @@
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info('没有可提交的配置')
|
||||
ElMessage.info(t('page.weightShared.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success('保存成功')
|
||||
ElMessage.success(t('page.weightShared.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? '保存失败')
|
||||
ElMessage.error(e?.message ?? t('page.weightShared.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
|
||||
@@ -1,78 +1,80 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="权重配比"
|
||||
:title="$t('page.weightRatio.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
配置<strong>奖励对照表(dice_reward)</strong>的权重,一级按<strong>方向</strong>(顺时针/逆时针),二级按<strong>档位</strong>(T1-T5);各条权重
|
||||
1-10000,档位内按权重比抽取。
|
||||
{{ $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="顺时针" name="0">
|
||||
<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">该档位暂无配置数据</div>
|
||||
<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="点数"
|
||||
: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'">
|
||||
当前档位权重合计:<strong>{{ getTierSumForCurrentDirection(t) }}</strong>
|
||||
(各条 1-10000,档位内按权重比抽取,和不限制)
|
||||
{{
|
||||
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else
|
||||
>T4、T5 仅单一结果,无需配置权重。</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="点数(grid_number)"
|
||||
:label="$t('page.weightShared.colGridNumber')"
|
||||
prop="grid_number"
|
||||
width="110"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="结束索引(id)"
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="实际中奖金额"
|
||||
:label="$t('page.weightShared.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatMoney2(row?.real_ev) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="显示文本"
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="备注"
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="currentDirectionLabel + ' 权重(1-10000)'"
|
||||
:label="currentWeightColumnLabel"
|
||||
min-width="200"
|
||||
align="center"
|
||||
>
|
||||
@@ -156,65 +158,64 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="逆时针" name="1">
|
||||
<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">该档位暂无配置数据</div>
|
||||
<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="点数"
|
||||
: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'">
|
||||
当前档位权重合计:<strong>{{ getTierSumForCurrentDirection(t) }}</strong>
|
||||
(各条 1-10000,档位内按权重比抽取,和不限制)
|
||||
{{
|
||||
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else
|
||||
>T4、T5 仅单一结果,无需配置权重。</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="点数(grid_number)"
|
||||
:label="$t('page.weightShared.colGridNumber')"
|
||||
prop="grid_number"
|
||||
width="110"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="结束索引(id)"
|
||||
:label="$t('page.weightShared.colEndIndexId')"
|
||||
prop="id"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="实际中奖金额"
|
||||
:label="$t('page.weightShared.colRealEv')"
|
||||
prop="real_ev"
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="显示文本"
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="备注"
|
||||
:label="$t('page.weightShared.colRemark')"
|
||||
prop="remark"
|
||||
min-width="70"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
:label="currentDirectionLabel + ' 权重(1-10000)'"
|
||||
:label="currentWeightColumnLabel"
|
||||
min-width="200"
|
||||
align="center"
|
||||
>
|
||||
@@ -301,8 +302,14 @@
|
||||
</el-tabs>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交</el-button>
|
||||
<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>
|
||||
@@ -311,6 +318,16 @@
|
||||
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'
|
||||
function formatMoney2(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
|
||||
type DirectionKey = 'clockwise' | 'counterclockwise'
|
||||
@@ -361,9 +378,14 @@
|
||||
T5: { '0': [], '1': [] }
|
||||
})
|
||||
|
||||
const currentDirectionLabel = computed(() =>
|
||||
activeDirection.value === '0' ? '顺时针' : '逆时针'
|
||||
)
|
||||
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
|
||||
|
||||
@@ -465,7 +487,7 @@
|
||||
grouped.value = parsePayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('获取权重数据失败')
|
||||
ElMessage.error(t('page.weightShared.fetchFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
@@ -494,19 +516,19 @@
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info('没有可提交的配置')
|
||||
ElMessage.info(t('page.weightShared.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success('保存成功')
|
||||
ElMessage.success(t('page.weightShared.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? '保存失败')
|
||||
ElMessage.error(e?.message ?? t('page.weightShared.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
|
||||
@@ -1,132 +1,159 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="一键测试权重"
|
||||
:title="$t('page.weightTest.title')"
|
||||
width="560px"
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@close="onClose"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" label-width="140px">
|
||||
<ElSteps :active="currentStep" finish-status="success" simple class="steps-wrap">
|
||||
<ElStep title="付费抽奖券" />
|
||||
<ElStep title="免费抽奖券" />
|
||||
</ElSteps>
|
||||
<ElAlert type="info" :closable="false" show-icon class="weight-test-tip">
|
||||
<template #title>{{ $t('page.weightTest.alertTitle') }}</template>
|
||||
{{ $t('page.weightTest.alertBody') }}
|
||||
</ElAlert>
|
||||
<ElAlert type="warning" :closable="false" show-icon class="weight-test-tip chain-tip">
|
||||
{{ $t('page.weightTest.chainModeHint') }}
|
||||
</ElAlert>
|
||||
<ElAlert type="info" :closable="false" show-icon class="weight-test-tip chain-tip">
|
||||
{{ $t('page.weightTest.killModeHint') }}
|
||||
</ElAlert>
|
||||
<ElForm :model="form" label-width="140px">
|
||||
<ElFormItem :label="$t('page.weightTest.labelAnte')" prop="ante" required>
|
||||
<ElInputNumber v-model="form.ante" :min="1" :step="1" style="width: 100%" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.weightTest.labelKillModeEnabled')" prop="kill_mode_enabled">
|
||||
<ElSwitch v-model="form.kill_mode_enabled" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.weightTest.labelTestSafetyLine')" prop="test_safety_line">
|
||||
<ElInputNumber
|
||||
v-model="form.test_safety_line"
|
||||
:min="0"
|
||||
:step="100"
|
||||
:disabled="!form.kill_mode_enabled"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<!-- 第一页:付费抽奖券 -->
|
||||
<div v-show="currentStep === 0" class="step-panel">
|
||||
<ElFormItem label="测试数据档位类型" prop="paid_lottery_config_id">
|
||||
<ElSelect
|
||||
v-model="form.paid_lottery_config_id"
|
||||
placeholder="不选则下方自定义档位概率(默认 type=0)"
|
||||
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">自定义档位概率(T1~T5),每档 0-100%,五档之和不能超过 100%</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 }}(%)</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"
|
||||
>当前五档之和为 {{ paidTierSum }}%,不能超过 100%</div
|
||||
>
|
||||
</template>
|
||||
<ElFormItem label="顺时针次数" prop="paid_s_count" required>
|
||||
<ElSelect v-model="form.paid_s_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="逆时针次数" prop="paid_n_count" required>
|
||||
<ElSelect v-model="form.paid_n_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="section-title">{{ $t('page.weightTest.sectionPaid') }}</div>
|
||||
<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 v-show="currentStep === 1" class="step-panel">
|
||||
<ElFormItem label="测试数据档位类型" prop="free_lottery_config_id">
|
||||
<ElSelect
|
||||
v-model="form.free_lottery_config_id"
|
||||
placeholder="不选则下方自定义档位概率(默认 type=1)"
|
||||
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">自定义档位概率(T1~T5),每档 0-100%,五档之和不能超过 100%</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 }}(%)</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"
|
||||
>当前五档之和为 {{ freeTierSum }}%,不能超过 100%</div
|
||||
>
|
||||
</template>
|
||||
<ElFormItem label="顺时针次数" prop="free_s_count" required>
|
||||
<ElSelect v-model="form.free_s_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="逆时针次数" prop="free_n_count" required>
|
||||
<ElSelect v-model="form.free_n_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="section-title">{{ $t('page.weightTest.sectionFreeAfterPlayAgain') }}</div>
|
||||
<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.tierProbHintFreeChain') }}</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>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton v-if="currentStep > 0" :disabled="running" @click="currentStep--">上一步</ElButton>
|
||||
<ElButton v-if="currentStep < 1" type="primary" :disabled="running" @click="currentStep++"
|
||||
>下一步</ElButton
|
||||
<ElButton
|
||||
v-permission="'dice:reward:index:startWeightTest'"
|
||||
type="primary"
|
||||
:loading="running"
|
||||
@click="handleStart"
|
||||
>{{ $t('page.weightTest.btnStart') }}</ElButton
|
||||
>
|
||||
<ElButton v-if="currentStep === 1" type="primary" :loading="running" @click="handleStart"
|
||||
>开始测试</ElButton
|
||||
>
|
||||
<ElButton :disabled="running" @click="visible = false">取消</ElButton>
|
||||
<ElButton :disabled="running" @click="visible = false">{{
|
||||
$t('page.weightTest.btnCancel')
|
||||
}}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -134,6 +161,10 @@
|
||||
<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
|
||||
@@ -141,40 +172,31 @@
|
||||
const visible = defineModel<boolean>({ default: false })
|
||||
const emit = defineEmits<{ (e: 'success'): void }>()
|
||||
|
||||
const formRef = ref()
|
||||
const currentStep = ref(0)
|
||||
const form = reactive({
|
||||
ante: 1,
|
||||
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
|
||||
kill_mode_enabled: false,
|
||||
test_safety_line: 5000
|
||||
})
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string; type: number }>>([])
|
||||
/** 将 type 转为数字(接口可能返回字符串 "0"/"1") */
|
||||
function tierTypeNum(r: { type?: number | string }): number {
|
||||
const t = r.type ?? 0
|
||||
return typeof t === 'number' ? t : Number(t) || 0
|
||||
}
|
||||
/** 付费抽奖券可选档位:type=0 */
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
/** 付费抽奖券可选档位:name=default */
|
||||
const paidLotteryOptions = computed(() =>
|
||||
lotteryOptions.value.filter((r) => tierTypeNum(r) === 0)
|
||||
lotteryOptions.value.filter((r) => r.name === 'default')
|
||||
)
|
||||
/**
|
||||
* 免费抽奖券可选档位:优先 type=1(DiceLotteryPoolConfig.type=1),若无则显示全部以便下拉有选项
|
||||
*/
|
||||
/** 免费抽奖券可选档位:优先 name=killScore,若无则显示全部以便下拉有选项 */
|
||||
const freeLotteryOptions = computed(() => {
|
||||
const type1List = lotteryOptions.value.filter((r) => tierTypeNum(r) === 1)
|
||||
return type1List.length > 0 ? type1List : lotteryOptions.value
|
||||
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 {
|
||||
@@ -211,36 +233,35 @@
|
||||
async function loadLotteryOptions() {
|
||||
try {
|
||||
const list = await lotteryPoolApi.getOptions()
|
||||
lotteryOptions.value = list.map(
|
||||
(r: { id: number; name: string; type?: number | string }) => ({
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
type: tierTypeNum(r)
|
||||
})
|
||||
)
|
||||
// 付费抽奖券默认使用 type=0 的档位类型
|
||||
const type0 = list.find((r: { type?: number | string }) => tierTypeNum(r) === 0)
|
||||
if (type0) {
|
||||
form.paid_lottery_config_id = type0.id
|
||||
lotteryOptions.value = list.map((r: { id: number; name: string }) => ({
|
||||
id: r.id,
|
||||
name: r.name
|
||||
}))
|
||||
const normal = list.find((r: { name?: string }) => r.name === 'default')
|
||||
if (normal) {
|
||||
form.paid_lottery_config_id = normal.id
|
||||
}
|
||||
// 免费抽奖券默认使用 type=1 的档位类型(DiceLotteryPoolConfig.type=1);若无 type=1 则默认选第一项
|
||||
const type1 = list.find((r: { type?: number | string }) => tierTypeNum(r) === 1)
|
||||
if (type1) {
|
||||
form.free_lottery_config_id = type1.id
|
||||
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 (_) {
|
||||
} catch {
|
||||
lotteryOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const payload: Record<string, unknown> = {
|
||||
ante: form.ante,
|
||||
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
|
||||
free_s_count: 0,
|
||||
free_n_count: 0,
|
||||
chain_free_mode: true,
|
||||
kill_mode_enabled: form.kill_mode_enabled,
|
||||
test_safety_line: form.test_safety_line
|
||||
}
|
||||
if (form.paid_lottery_config_id != null) {
|
||||
payload.paid_lottery_config_id = form.paid_lottery_config_id
|
||||
@@ -256,8 +277,16 @@
|
||||
}
|
||||
|
||||
function validateForm(): boolean {
|
||||
if (form.paid_s_count + form.paid_n_count + form.free_s_count + form.free_n_count <= 0) {
|
||||
ElMessage.warning('付费或免费至少一种方向次数之和大于 0')
|
||||
if (form.ante == null || form.ante <= 0) {
|
||||
ElMessage.warning(t('page.weightTest.warnAnte'))
|
||||
return false
|
||||
}
|
||||
if (form.paid_s_count + form.paid_n_count <= 0) {
|
||||
ElMessage.warning(t('page.weightTest.warnPaidSpins'))
|
||||
return false
|
||||
}
|
||||
if (form.kill_mode_enabled && (form.test_safety_line == null || form.test_safety_line < 0)) {
|
||||
ElMessage.warning(t('page.weightTest.warnTestSafetyLine'))
|
||||
return false
|
||||
}
|
||||
const needPaidTier = form.paid_lottery_config_id == null
|
||||
@@ -265,22 +294,22 @@
|
||||
if (needPaidTier) {
|
||||
const sum = paidTierSum.value
|
||||
if (sum <= 0) {
|
||||
ElMessage.warning('付费未选奖池时,T1~T5 档位概率之和需大于 0')
|
||||
ElMessage.warning(t('page.weightTest.warnPaidTierSumPositive'))
|
||||
return false
|
||||
}
|
||||
if (sum > 100) {
|
||||
ElMessage.warning('付费档位概率 T1~T5 之和不能超过 100%')
|
||||
ElMessage.warning(t('page.weightTest.warnPaidTierSumMax'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (needFreeTier) {
|
||||
const sum = freeTierSum.value
|
||||
if (sum <= 0) {
|
||||
ElMessage.warning('免费未选奖池时,T1~T5 档位概率之和需大于 0')
|
||||
ElMessage.warning(t('page.weightTest.warnFreeTierSumPositive'))
|
||||
return false
|
||||
}
|
||||
if (sum > 100) {
|
||||
ElMessage.warning('免费档位概率 T1~T5 之和不能超过 100%')
|
||||
ElMessage.warning(t('page.weightTest.warnFreeTierSumMax'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -292,13 +321,11 @@
|
||||
running.value = true
|
||||
try {
|
||||
await api.startWeightTest(buildPayload())
|
||||
ElMessage.success(
|
||||
'测试任务已创建,后台将自动执行。请在【玩家抽奖记录(测试数据)】中查看生成的测试数据'
|
||||
)
|
||||
ElMessage.success(t('page.weightTest.successCreated'))
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '创建测试任务失败')
|
||||
ElMessage.error(e?.message || t('page.weightTest.failCreate'))
|
||||
} finally {
|
||||
running.value = false
|
||||
}
|
||||
@@ -311,25 +338,22 @@
|
||||
onClose()
|
||||
}
|
||||
})
|
||||
|
||||
// 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 type=1 的选项,避免显示错误
|
||||
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>
|
||||
.steps-wrap {
|
||||
.weight-test-tip {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.step-panel {
|
||||
min-height: 200px;
|
||||
.chain-tip {
|
||||
margin-top: -8px;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
margin: 8px 0 12px;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.tier-label {
|
||||
font-size: 13px;
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
<div class="card-header">
|
||||
<span>{{ $t('page.toolbar.gameRewardConfig') }}</span>
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:update'"
|
||||
v-permission="'dice:reward_config:index:createRewardReference'"
|
||||
type="warning"
|
||||
:loading="createRewardLoading"
|
||||
@click="handleCreateRewardReference"
|
||||
v-ripple
|
||||
title="按规则: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"
|
||||
:title="$t('page.toolbar.createRewardRefTitle')"
|
||||
>
|
||||
{{ $t('page.toolbar.createRewardRef') }}
|
||||
</ElButton>
|
||||
@@ -18,9 +18,19 @@
|
||||
</template>
|
||||
|
||||
<ElTabs v-model="activeTab" type="card" class="top-tabs">
|
||||
<ElTabPane label="奖励索引" name="index">
|
||||
<ElTabPane :label="$t('page.configPage.tabIndex')" name="index">
|
||||
<div class="tab-panel">
|
||||
<div class="panel-tip">色子点数须在 5~30 之间且本表内不重复。</div>
|
||||
<div class="panel-tip">{{ $t('page.configPage.tipIndex') }}</div>
|
||||
<div class="index-toolbar">
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:batchUpdate'"
|
||||
type="default"
|
||||
@click="openRuleGenerateDialog"
|
||||
v-ripple
|
||||
>
|
||||
{{ $t('page.configPage.btnRuleGenerate') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="table-scroll-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
@@ -29,12 +39,21 @@
|
||||
size="default"
|
||||
class="config-table"
|
||||
>
|
||||
<ElTableColumn label="索引(id)" prop="id" width="60" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colId')"
|
||||
prop="id"
|
||||
width="60"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.id }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="色子点数" min-width="100" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colDicePoints')"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.grid_number"
|
||||
@@ -46,31 +65,62 @@
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="显示文本" min-width="100" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colDisplayText')"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.ui_text" size="small" placeholder="显示文本(中文)" />
|
||||
<ElInput
|
||||
v-model="row.ui_text"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayZh')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="显示文本(英文)" min-width="120" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colDisplayTextEn')"
|
||||
min-width="120"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.ui_text_en" size="small" placeholder="显示文本(英文)" />
|
||||
<ElInput
|
||||
v-model="row.ui_text_en"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayEn')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="真实结算" min-width="110" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colRealEv')"
|
||||
min-width="110"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.real_ev"
|
||||
@change="handleRealEvChange(row)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
:step="1"
|
||||
class="full-width"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="所属档位" width="100" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colRealReward')"
|
||||
min-width="130"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatMoney2(calcRealReward(row.real_ev)) }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="$t('page.configPage.colTier')" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElSelect
|
||||
v-model="row.tier"
|
||||
placeholder="档位"
|
||||
:placeholder="$t('page.configPage.placeholderTierSelect')"
|
||||
clearable
|
||||
size="small"
|
||||
class="full-width"
|
||||
@@ -83,27 +133,36 @@
|
||||
</ElSelect>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="备注" min-width="140" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colRemark')"
|
||||
min-width="140"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.remark" size="small" placeholder="备注" />
|
||||
<ElInput
|
||||
v-model="row.remark"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderRemark')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
<div class="tab-footer">
|
||||
<ElButton type="primary" :loading="savingIndex" @click="handleSaveIndex"
|
||||
>保存</ElButton
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:batchUpdate'"
|
||||
type="primary"
|
||||
:loading="savingIndex"
|
||||
@click="handleSaveIndex"
|
||||
>{{ $t('page.configPage.btnSave') }}</ElButton
|
||||
>
|
||||
<ElButton @click="handleResetIndex">重置</ElButton>
|
||||
<ElButton @click="handleResetIndex">{{ $t('page.configPage.btnReset') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElTabPane>
|
||||
<ElTabPane label="大奖权重" name="bigwin">
|
||||
<ElTabPane :label="$t('page.configPage.tabBigwin')" name="bigwin">
|
||||
<div class="tab-panel">
|
||||
<div class="panel-tip"
|
||||
>从左至右:中大奖点数(不可改)、显示信息、实际中奖、备注、权重(0~10000)。点数 5、30
|
||||
权重固定 100%。本表单独立提交,仅提交大奖权重。</div
|
||||
>
|
||||
<div class="panel-tip">{{ $t('page.configPage.tipBigwin') }}</div>
|
||||
<div class="table-scroll-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
@@ -112,37 +171,75 @@
|
||||
size="default"
|
||||
class="config-table bigwin-table"
|
||||
>
|
||||
<ElTableColumn label="中大奖点数" width="100" align="center">
|
||||
<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="显示信息" min-width="140" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colDisplayInfo')"
|
||||
min-width="140"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.ui_text" size="small" placeholder="显示信息(中文)" />
|
||||
<ElInput
|
||||
v-model="row.ui_text"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayInfoZh')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="显示信息(英文)" min-width="160" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colDisplayInfoEn')"
|
||||
min-width="160"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.ui_text_en" size="small" placeholder="显示信息(英文)" />
|
||||
<ElInput
|
||||
v-model="row.ui_text_en"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderDisplayInfoEn')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="实际中奖" min-width="120" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colRealPrize')"
|
||||
min-width="120"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.real_ev"
|
||||
@change="handleRealEvChange(row)"
|
||||
controls-position="right"
|
||||
size="small"
|
||||
:step="1"
|
||||
class="full-width"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="备注" min-width="140" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colRemark')"
|
||||
min-width="140"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElInput v-model="row.remark" size="small" placeholder="备注" />
|
||||
<ElInput
|
||||
v-model="row.remark"
|
||||
size="small"
|
||||
:placeholder="$t('page.configPage.placeholderRemark')"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="权重(0-10000)" min-width="220" align="center">
|
||||
<ElTableColumn
|
||||
:label="$t('page.configPage.colWeightRange')"
|
||||
min-width="220"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="weight-cell">
|
||||
<ElSlider
|
||||
@@ -163,32 +260,217 @@
|
||||
class="weight-input"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="isBigwinWeightDisabled(row)" class="weight-tip"
|
||||
>点数 5、30 固定 100%</span
|
||||
>
|
||||
<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">
|
||||
暂无 BIGWIN 档位配置,请在「奖励索引」中设置 tier 为 BIGWIN。
|
||||
{{ $t('page.configPage.emptyBigwin') }}
|
||||
</div>
|
||||
<div class="tab-footer">
|
||||
<ElButton type="primary" :loading="savingBigwin" @click="handleSaveBigwin"
|
||||
>保存</ElButton
|
||||
<ElButton
|
||||
v-permission="'dice:reward_config:index:saveBigwinWeightsByGrid'"
|
||||
type="primary"
|
||||
:loading="savingBigwin"
|
||||
@click="handleSaveBigwin"
|
||||
>{{ $t('page.configPage.btnSave') }}</ElButton
|
||||
>
|
||||
<ElButton @click="handleResetBigwin">重置</ElButton>
|
||||
<ElButton @click="handleResetBigwin">{{ $t('page.configPage.btnReset') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
</ElCard>
|
||||
|
||||
<ElDialog
|
||||
v-model="ruleGenerateDialogVisible"
|
||||
:title="$t('page.configPage.ruleGenerateTitle')"
|
||||
:width="ruleGenDialogWidth"
|
||||
:fullscreen="ruleGenFullscreen"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
class="rule-generate-dialog"
|
||||
>
|
||||
<div class="rule-generate-rules">{{ $t('page.configPage.ruleGenerateRules') }}</div>
|
||||
<ElForm
|
||||
:label-position="ruleGenFormLabelPosition"
|
||||
:label-width="ruleGenFormLabelWidth"
|
||||
class="rule-generate-form"
|
||||
@submit.prevent
|
||||
>
|
||||
<ElFormItem :label="$t('page.configPage.ruleGenT1Row')">
|
||||
<div class="rule-gen-row">
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenFixedCount') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT1Fixed"
|
||||
class="rule-gen-input-num"
|
||||
:min="0"
|
||||
:max="26"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenRealEvStd') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT1RealEv"
|
||||
class="rule-gen-input-num"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.configPage.ruleGenT2Row')">
|
||||
<div class="rule-gen-row">
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenMinCount') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT2Min"
|
||||
class="rule-gen-input-num"
|
||||
:min="0"
|
||||
:max="26"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenRealEvStd') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT2RealEv"
|
||||
class="rule-gen-input-num"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.configPage.ruleGenT3RealEvOnly')">
|
||||
<div class="rule-gen-row">
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenRealEvStd') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT3RealEv"
|
||||
class="rule-gen-input-num"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.configPage.ruleGenT4Row')">
|
||||
<div class="rule-gen-row">
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenFixedCount') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT4Fixed"
|
||||
class="rule-gen-input-num"
|
||||
:min="0"
|
||||
:max="26"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenRealEvStd') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT4RealEv"
|
||||
class="rule-gen-input-num"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('page.configPage.ruleGenT5Row')">
|
||||
<div class="rule-gen-row">
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenFixedCount') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT5Fixed"
|
||||
class="rule-gen-input-num"
|
||||
:min="0"
|
||||
:max="26"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
<div class="rule-gen-cell">
|
||||
<span class="rule-gen-hint">{{ $t('page.configPage.ruleGenRealEvStd') }}</span>
|
||||
<ElInputNumber
|
||||
v-model="ruleGenT5RealEv"
|
||||
class="rule-gen-input-num"
|
||||
:disabled="true"
|
||||
:step="1"
|
||||
:controls="ruleGenInputControls"
|
||||
:size="ruleGenInputSize"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<p class="rule-generate-scope">{{ $t('page.configPage.ruleGenScopeHint') }}</p>
|
||||
<p class="rule-generate-scope">{{ $t('page.configPage.ruleGenRealEvEditHint') }}</p>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="rule-gen-footer-btns">
|
||||
<ElButton @click="ruleGenerateDialogVisible = false">{{ $t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="ruleGenSubmitting" @click="handleRuleGenerateApply">
|
||||
{{ $t('page.configPage.ruleGenApply') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import api from '../../api/reward_config/index'
|
||||
import {
|
||||
buildRowsFromTiers,
|
||||
computeBoardFrequencies,
|
||||
DEFAULT_TIER_REAL_EV_STANDARDS,
|
||||
generateTiers,
|
||||
summarizeCounts,
|
||||
validateTierRealEvStandards
|
||||
} from '../utils/generateIndexByRules'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { width: viewportWidth } = useWindowSize()
|
||||
/** 窄屏:单列、标签置顶、全屏弹窗 */
|
||||
const isRuleGenMobile = computed(() => viewportWidth.value < 640)
|
||||
const ruleGenDialogWidth = computed(() => (isRuleGenMobile.value ? '100%' : 'min(880px, 92vw)'))
|
||||
const ruleGenFullscreen = computed(() => isRuleGenMobile.value)
|
||||
const ruleGenFormLabelPosition = computed(() => (isRuleGenMobile.value ? 'top' : 'right'))
|
||||
const ruleGenFormLabelWidth = computed(() => (isRuleGenMobile.value ? undefined : '168px'))
|
||||
/** 移动端隐藏步进按钮,避免误触;用系统数字键盘输入 */
|
||||
const ruleGenInputControls = computed(() => !isRuleGenMobile.value)
|
||||
const ruleGenInputSize = computed(() => (isRuleGenMobile.value ? 'large' : 'default'))
|
||||
|
||||
/** 第一页:奖励索引行(来自 DiceRewardConfig 表) */
|
||||
interface IndexRow {
|
||||
@@ -207,6 +489,31 @@
|
||||
const savingIndex = ref(false)
|
||||
const savingBigwin = ref(false)
|
||||
const createRewardLoading = ref(false)
|
||||
const ruleGenerateDialogVisible = ref(false)
|
||||
const ruleGenSubmitting = ref(false)
|
||||
const ruleGenT1Fixed = ref(3)
|
||||
const ruleGenT2Min = ref(5)
|
||||
const ruleGenT4Fixed = ref(1)
|
||||
const ruleGenT5Fixed = ref(1)
|
||||
const ruleGenT1RealEv = ref(DEFAULT_TIER_REAL_EV_STANDARDS.T1)
|
||||
const ruleGenT2RealEv = ref(DEFAULT_TIER_REAL_EV_STANDARDS.T2)
|
||||
const ruleGenT3RealEv = ref(DEFAULT_TIER_REAL_EV_STANDARDS.T3)
|
||||
const ruleGenT4RealEv = ref(DEFAULT_TIER_REAL_EV_STANDARDS.T4)
|
||||
const ruleGenT5RealEv = ref(DEFAULT_TIER_REAL_EV_STANDARDS.T5)
|
||||
|
||||
/** 奖励索引 id 与后端 DiceRewardConfigLogic 一致:0~25 */
|
||||
const REWARD_INDEX_MIN = 0
|
||||
const REWARD_INDEX_MAX = 25
|
||||
const ALLOWED_INDEX_TIERS = ['T1', 'T2', 'T3', 'T4', 'T5', 'BIGWIN'] as const
|
||||
|
||||
function isAllowedIndexTier(s: string): boolean {
|
||||
for (let i = 0; i < ALLOWED_INDEX_TIERS.length; i++) {
|
||||
if (ALLOWED_INDEX_TIERS[i] === s) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** 第一页数据(来自 api.list,即 DiceRewardConfig 表) */
|
||||
const indexRows = ref<IndexRow[]>([])
|
||||
@@ -236,14 +543,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
function calcRealReward(realEv: unknown): number {
|
||||
const n = typeof realEv === 'number' && !Number.isNaN(realEv) ? realEv : Number(realEv)
|
||||
if (Number.isNaN(n)) {
|
||||
return -1
|
||||
}
|
||||
return n - 1
|
||||
}
|
||||
|
||||
function handleRealEvChange(row: IndexRow) {
|
||||
const n =
|
||||
typeof row.real_ev === 'number' && !Number.isNaN(row.real_ev)
|
||||
? row.real_ev
|
||||
: Number(row.real_ev)
|
||||
const text = Number.isNaN(n) ? '' : Number(n).toFixed(2)
|
||||
row.ui_text = text
|
||||
row.ui_text_en = text
|
||||
}
|
||||
|
||||
function formatMoney2(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
async function handleCreateRewardReference() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'按规则创建奖励对照:起始索引 start_index=奖励配置中 grid_number 对应格位的 id;顺时针 end_index=(start_index+摇取点数)%26;逆时针 end_index=start_index-摇取点数≥0 则取该值,否则 26+start_index-摇取点数。先清空现有数据再为 5-30 共 26 个点数、顺/逆时针分别生成。是否继续?',
|
||||
'创建奖励对照',
|
||||
t('page.configPage.confirmCreateRefMsg'),
|
||||
t('page.configPage.confirmCreateRefTitle'),
|
||||
{
|
||||
confirmButtonText: '确定创建',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: t('page.configPage.confirmCreateRefOk'),
|
||||
cancelButtonText: t('page.configPage.confirmCreateRefCancel'),
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
@@ -254,14 +586,23 @@
|
||||
try {
|
||||
const res: any = await api.createRewardReference()
|
||||
const data = res?.data ?? res
|
||||
const msg =
|
||||
typeof data === 'object' && data !== null
|
||||
? `已按 5-30 共26个点数、顺时针+逆时针创建:顺时针新增 ${data.created_clockwise ?? 0} 条、逆时针新增 ${data.created_counterclockwise ?? 0} 条;顺时针更新 ${data.updated_clockwise ?? 0} 条、逆时针更新 ${data.updated_counterclockwise ?? 0} 条${(data.skipped ?? 0) > 0 ? `;${data.skipped} 个点数使用兜底起始索引` : ''}`
|
||||
: '创建成功'
|
||||
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 ?? '创建奖励对照失败')
|
||||
ElMessage.error(e?.message ?? t('page.configPage.createRefFail'))
|
||||
} finally {
|
||||
createRewardLoading.value = false
|
||||
}
|
||||
@@ -280,7 +621,7 @@
|
||||
indexRowsSnapshot = rows.map((r) => ({ ...r }))
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('获取奖励索引配置失败')
|
||||
ElMessage.error(t('page.configPage.loadIndexFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
@@ -308,25 +649,192 @@
|
||||
}
|
||||
|
||||
/** 奖励索引表单校验:仅对本表内的行(不含 BIGWIN)校验,点数 5~30 且本批内不重复 */
|
||||
function validateIndexFormForSave(): string | null {
|
||||
const toSave = indexRows.value.filter((r) => r.tier !== 'BIGWIN')
|
||||
function validateIndexFormForSaveRows(rows: IndexRow[]): string | null {
|
||||
const toSave = rows.filter((r) => r.tier !== 'BIGWIN')
|
||||
if (toSave.length === 0) {
|
||||
return '暂无奖励索引数据可保存'
|
||||
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 `色子点数必须在 ${GRID_NUMBER_MIN}~${GRID_NUMBER_MAX} 之间`
|
||||
return t('page.configPage.warnGridRange', { min: GRID_NUMBER_MIN, max: GRID_NUMBER_MAX })
|
||||
}
|
||||
const duplicates = findDuplicateValues(nums)
|
||||
if (duplicates.length > 0) {
|
||||
return `色子点数在本表内不能重复,重复的点数为:${duplicates.join('、')}`
|
||||
return t('page.configPage.warnDupGrid', {
|
||||
list: duplicates.join(t('page.configPage.dupJoiner'))
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function validateIndexFormForSave(): string | null {
|
||||
return validateIndexFormForSaveRows(indexRows.value)
|
||||
}
|
||||
|
||||
/** 从当前表提取 id 0~25 的色子点数(不含 BIGWIN),用于按规则生成 */
|
||||
function extractGrids26(): number[] | null {
|
||||
const map = new Map<number, number>()
|
||||
for (const r of indexRows.value) {
|
||||
if (r.tier === 'BIGWIN') {
|
||||
continue
|
||||
}
|
||||
if (r.id >= REWARD_INDEX_MIN && r.id <= REWARD_INDEX_MAX) {
|
||||
map.set(r.id, Number(r.grid_number))
|
||||
}
|
||||
}
|
||||
const out: number[] = []
|
||||
for (let id = REWARD_INDEX_MIN; id <= REWARD_INDEX_MAX; id++) {
|
||||
if (!map.has(id)) {
|
||||
return null
|
||||
}
|
||||
const gn = map.get(id)
|
||||
if (gn === undefined || Number.isNaN(gn)) {
|
||||
return null
|
||||
}
|
||||
out.push(gn)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function openRuleGenerateDialog() {
|
||||
ruleGenerateDialogVisible.value = true
|
||||
}
|
||||
|
||||
function applyGeneratedRowsToIndex(
|
||||
items: Array<{
|
||||
id: number
|
||||
grid_number: number
|
||||
ui_text: string
|
||||
ui_text_en: string
|
||||
real_ev: number
|
||||
tier: string
|
||||
remark: string
|
||||
}>
|
||||
): string | null {
|
||||
const next = indexRows.value.map((r) => ({ ...r }))
|
||||
for (const item of items) {
|
||||
const row = next.find((x) => x.id === item.id)
|
||||
if (row === undefined) {
|
||||
return t('page.configPage.ruleGenUnknownId', { id: item.id })
|
||||
}
|
||||
row.grid_number = item.grid_number
|
||||
row.ui_text = item.ui_text
|
||||
row.ui_text_en = item.ui_text_en
|
||||
row.real_ev = item.real_ev
|
||||
row.tier = item.tier
|
||||
row.remark = item.remark
|
||||
}
|
||||
const err = validateIndexFormForSaveRows(next)
|
||||
if (err) {
|
||||
return err
|
||||
}
|
||||
indexRows.value = next
|
||||
return null
|
||||
}
|
||||
|
||||
async function handleRuleGenerateApply() {
|
||||
const grids = extractGrids26()
|
||||
if (grids === null) {
|
||||
ElMessage.warning(t('page.configPage.ruleGenNeedFullGrid'))
|
||||
return
|
||||
}
|
||||
const t1 = Math.max(0, Math.min(26, Math.floor(Number(ruleGenT1Fixed.value))))
|
||||
const t2 = Math.max(0, Math.min(26, Math.floor(Number(ruleGenT2Min.value))))
|
||||
const x4 = Math.max(0, Math.min(26, Math.floor(Number(ruleGenT4Fixed.value))))
|
||||
const x5 = Math.max(0, Math.min(26, Math.floor(Number(ruleGenT5Fixed.value))))
|
||||
const standards = {
|
||||
T1: Number(ruleGenT1RealEv.value),
|
||||
T2: Number(ruleGenT2RealEv.value),
|
||||
T3: Number(ruleGenT3RealEv.value),
|
||||
T4: Number(ruleGenT4RealEv.value),
|
||||
T5: Number(ruleGenT5RealEv.value)
|
||||
}
|
||||
const invalidKey = validateTierRealEvStandards(standards)
|
||||
if (invalidKey !== null) {
|
||||
ElMessage.warning(t(`page.configPage.${invalidKey}`))
|
||||
return
|
||||
}
|
||||
const constraints = {
|
||||
t1FixedCw: t1,
|
||||
t2MinCw: t2,
|
||||
t4FixedCw: x4,
|
||||
t5FixedCw: x5,
|
||||
t1FixedCcw: t1,
|
||||
t2MinCcw: t2,
|
||||
t4FixedCcw: x4,
|
||||
t5FixedCcw: x5
|
||||
}
|
||||
const gen = generateTiers({ grids, constraints })
|
||||
if (!gen.ok) {
|
||||
ElMessage.warning(gen.message)
|
||||
return
|
||||
}
|
||||
const built = buildRowsFromTiers(grids, gen.tiers, standards)
|
||||
const mergeErr = applyGeneratedRowsToIndex(built)
|
||||
if (mergeErr) {
|
||||
ElMessage.warning(mergeErr)
|
||||
return
|
||||
}
|
||||
const board = computeBoardFrequencies(grids)
|
||||
if (board === null) {
|
||||
ElMessage.warning(t('page.configPage.ruleGenFreqFail'))
|
||||
return
|
||||
}
|
||||
const sc = summarizeCounts(board, gen.tiers)
|
||||
ruleGenSubmitting.value = true
|
||||
try {
|
||||
const indexPayload = built.map(
|
||||
(r: {
|
||||
id: number
|
||||
grid_number: number
|
||||
ui_text: string
|
||||
ui_text_en: string
|
||||
real_ev: number
|
||||
tier: string
|
||||
remark: string
|
||||
}) => ({
|
||||
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.ruleGenSuccess', {
|
||||
cwT1: sc.cw.T1,
|
||||
cwT2: sc.cw.T2,
|
||||
cwT4: sc.cw.T4,
|
||||
cwT5: sc.cw.T5,
|
||||
ccT1: sc.ccw.T1,
|
||||
ccT2: sc.ccw.T2,
|
||||
ccT4: sc.ccw.T4,
|
||||
ccT5: sc.ccw.T5
|
||||
})
|
||||
)
|
||||
indexRowsSnapshot = indexRows.value.map((r) => ({ ...r }))
|
||||
ruleGenerateDialogVisible.value = false
|
||||
} catch (e: unknown) {
|
||||
let msg = ''
|
||||
if (e !== null && typeof e === 'object' && 'message' in e) {
|
||||
const m = Reflect.get(e, 'message')
|
||||
if (typeof m === 'string') {
|
||||
msg = m
|
||||
}
|
||||
}
|
||||
ElMessage.error(msg || t('page.configPage.saveFail'))
|
||||
loadIndexList()
|
||||
} finally {
|
||||
ruleGenSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 奖励索引表单:仅提交本表数据(T1~T5),不包含大奖权重 */
|
||||
async function handleSaveIndex() {
|
||||
const err = validateIndexFormForSave()
|
||||
@@ -347,10 +855,10 @@
|
||||
remark: r.remark
|
||||
}))
|
||||
await api.batchUpdate(indexPayload)
|
||||
ElMessage.success('保存成功')
|
||||
ElMessage.success(t('page.configPage.saveSuccess'))
|
||||
indexRowsSnapshot = indexRows.value.map((r) => ({ ...r }))
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? '保存失败')
|
||||
ElMessage.error(e?.message ?? t('page.configPage.saveFail'))
|
||||
} finally {
|
||||
savingIndex.value = false
|
||||
}
|
||||
@@ -359,25 +867,27 @@
|
||||
/** 奖励索引页:重置为本页数据(重新拉取列表) */
|
||||
function handleResetIndex() {
|
||||
loadIndexList()
|
||||
ElMessage.info('已重新加载奖励索引,恢复为服务器最新数据')
|
||||
ElMessage.info(t('page.configPage.resetIndexReloaded'))
|
||||
}
|
||||
|
||||
/** 大奖权重表单校验:点数在本表内不重复 */
|
||||
function validateBigwinFormForSave(): string | null {
|
||||
const rows = bigwinRows.value
|
||||
if (rows.length === 0) {
|
||||
return '暂无 BIGWIN 档位配置可保存'
|
||||
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 `色子点数必须在 ${GRID_NUMBER_MIN}~${GRID_NUMBER_MAX} 之间`
|
||||
return t('page.configPage.warnGridRange', { min: GRID_NUMBER_MIN, max: GRID_NUMBER_MAX })
|
||||
}
|
||||
const duplicates = findDuplicateValues(nums)
|
||||
if (duplicates.length > 0) {
|
||||
return `大奖权重本表内点数不能重复,重复的点数为:${duplicates.join('、')}`
|
||||
return t('page.configPage.warnBigwinDupGrid', {
|
||||
list: duplicates.join(t('page.configPage.dupJoiner'))
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -386,7 +896,7 @@
|
||||
async function handleSaveBigwin() {
|
||||
const rows = bigwinRows.value
|
||||
if (rows.length === 0) {
|
||||
ElMessage.info('暂无 BIGWIN 档位配置,请先在「奖励索引」中设置 tier 为 BIGWIN')
|
||||
ElMessage.info(t('page.configPage.infoNoBigwin'))
|
||||
return
|
||||
}
|
||||
const err = validateBigwinFormForSave()
|
||||
@@ -413,10 +923,10 @@
|
||||
: Math.max(0, Math.min(10000, Math.floor(r.weight)))
|
||||
}))
|
||||
await api.saveBigwinWeightsByGrid(weightItems)
|
||||
ElMessage.success('保存成功')
|
||||
ElMessage.success(t('page.configPage.saveSuccess'))
|
||||
loadIndexList()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? '保存失败')
|
||||
ElMessage.error(e?.message ?? t('page.configPage.saveFail'))
|
||||
} finally {
|
||||
savingBigwin.value = false
|
||||
}
|
||||
@@ -425,7 +935,7 @@
|
||||
/** 大奖权重页:重置(重新拉取列表,BIGWIN 数据随之更新) */
|
||||
function handleResetBigwin() {
|
||||
loadIndexList()
|
||||
ElMessage.info('已重新加载,大奖权重恢复为服务器最新数据')
|
||||
ElMessage.info(t('page.configPage.resetBigwinReloaded'))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -506,6 +1016,141 @@
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.index-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.rule-generate-dialog {
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 12px 16px;
|
||||
margin-right: 0;
|
||||
}
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 12px 16px 8px;
|
||||
}
|
||||
:deep(.el-dialog__footer) {
|
||||
padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
.rule-generate-rules {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.65;
|
||||
white-space: pre-wrap;
|
||||
margin: 0 0 12px;
|
||||
padding: 12px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
max-height: min(260px, 38vh);
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.rule-generate-form {
|
||||
margin-top: 4px;
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
:deep(.el-form-item__label) {
|
||||
line-height: 1.4;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
.rule-generate-scope {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin: 8px 0 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.rule-gen-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 12px 20px;
|
||||
width: 100%;
|
||||
}
|
||||
.rule-gen-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1 1 200px;
|
||||
min-width: 0;
|
||||
}
|
||||
.rule-gen-hint {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.rule-gen-input-num {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.rule-gen-input-num :deep(.el-input__wrapper) {
|
||||
min-height: 36px;
|
||||
}
|
||||
.rule-gen-footer-btns {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 639px) {
|
||||
.rule-generate-dialog {
|
||||
:deep(.el-dialog) {
|
||||
margin: 0;
|
||||
max-height: 100%;
|
||||
}
|
||||
:deep(.el-dialog.is-fullscreen) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
:deep(.el-dialog.is-fullscreen .el-dialog__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.rule-generate-rules {
|
||||
max-height: min(200px, 32vh);
|
||||
font-size: 11px;
|
||||
}
|
||||
.rule-gen-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 12px;
|
||||
}
|
||||
.rule-gen-cell {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
flex: none;
|
||||
width: 100%;
|
||||
}
|
||||
.rule-gen-hint {
|
||||
white-space: normal;
|
||||
}
|
||||
.rule-gen-input-num {
|
||||
width: 100%;
|
||||
}
|
||||
.rule-gen-input-num :deep(.el-input__wrapper) {
|
||||
min-height: 40px;
|
||||
}
|
||||
.rule-gen-footer-btns {
|
||||
flex-direction: column-reverse;
|
||||
align-items: stretch;
|
||||
.el-button {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.config-table {
|
||||
width: 100%;
|
||||
.full-width {
|
||||
|
||||
@@ -1,33 +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="grid_number">
|
||||
<el-form-item :label="$t('page.form.labelDicePoints')" prop="grid_number">
|
||||
<el-input-number
|
||||
v-model="formData.grid_number"
|
||||
placeholder="请输入色子点数"
|
||||
: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="ui_text_en">
|
||||
<el-input v-model="formData.ui_text_en" 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="real_ev">
|
||||
<el-input-number v-model="formData.real_ev" placeholder="请输入真实资金结算" />
|
||||
<el-form-item :label="$t('page.form.labelRealEv')" prop="real_ev">
|
||||
<el-input-number
|
||||
v-model="formData.real_ev"
|
||||
:placeholder="$t('page.form.placeholderRealEv')"
|
||||
@change="handleRealEvChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属档位" prop="tier">
|
||||
<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'"
|
||||
@@ -37,39 +41,39 @@
|
||||
<el-option label="T3" value="T3" />
|
||||
<el-option label="T4" value="T4" />
|
||||
<el-option label="T5" value="T5" />
|
||||
<el-option label="BIGWIN(超级大奖)" value="BIGWIN" />
|
||||
<el-option :label="$t('page.form.tierBigWin')" value="BIGWIN" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- BIGWIN 时可编辑权重:10000=100% 中奖,0=0% 中奖;点数 5、30 固定 100% 不可改 -->
|
||||
<el-form-item v-if="formData.tier === 'BIGWIN'" label="大奖权重" prop="weight">
|
||||
<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="0~10000,10000=100%中奖"
|
||||
:placeholder="$t('page.form.placeholderBigWinWeight')"
|
||||
:disabled="isBigwinWeightDisabled"
|
||||
/>
|
||||
<div v-if="isBigwinWeightDisabled" class="form-tip">
|
||||
点数 5、30 摇到必中大奖,权重固定 10000
|
||||
{{ $t('page.form.bigWinWeightDisabledTip') }}
|
||||
</div>
|
||||
<div v-else class="form-tip">10000=100% 中奖,0=0% 中奖;仅对点数 10/15/20/25 生效</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="备注" 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')"
|
||||
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>
|
||||
@@ -78,6 +82,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
|
||||
@@ -97,6 +102,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -111,14 +117,16 @@
|
||||
/**
|
||||
* 表单验证规则(权重已迁移至权重配比弹窗)
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
grid_number: [{ required: true, message: '色子点数必需填写', trigger: 'blur' }],
|
||||
ui_text: [{ required: true, message: '前端显示文本必需填写', trigger: 'blur' }],
|
||||
ui_text_en: [{ max: 255, message: '前端显示文本(英文)长度需小于 255 字符', trigger: 'blur' }],
|
||||
real_ev: [{ required: true, message: '真实资金结算必需填写', trigger: 'blur' }],
|
||||
tier: [{ required: true, message: '所属档位必需填写', trigger: 'blur' }],
|
||||
weight: [{ type: 'number', min: 0, max: 10000, message: '大奖权重 0~10000', 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(
|
||||
@@ -222,10 +230,10 @@
|
||||
}
|
||||
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()
|
||||
@@ -233,6 +241,16 @@
|
||||
console.log('表单验证失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleRealEvChange = () => {
|
||||
const n =
|
||||
typeof formData.real_ev === 'number' && !Number.isNaN(formData.real_ev)
|
||||
? formData.real_ev
|
||||
: Number(formData.real_ev)
|
||||
const text = Number.isNaN(n) ? '' : String(n)
|
||||
formData.ui_text = text
|
||||
formData.ui_text_en = text
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="T1-T5 权重配比(顺时针/逆时针)"
|
||||
:title="$t('page.weightRatio.title')"
|
||||
width="900px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div class="global-tip">
|
||||
权重来自<strong>奖励对照表(dice_reward)</strong>,按<strong>结束索引(DiceRewardConfig.id)</strong>区分<strong>顺时针</strong>与<strong>逆时针</strong>两套权重;抽奖时按当前方向取对应权重。
|
||||
{{ $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"> 该档位暂无配置数据 </div>
|
||||
<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="结束索引"
|
||||
:x-axis-name="$t('page.weightRatio.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'clockwise')"
|
||||
height="180px"
|
||||
/>
|
||||
<ArtBarChart
|
||||
x-axis-name="结束索引"
|
||||
:x-axis-name="$t('page.weightRatio.xAxisEndIndex')"
|
||||
:x-axis-data="getTierChartLabels(t)"
|
||||
:data="getTierChartData(t, 'counterclockwise')"
|
||||
height="180px"
|
||||
@@ -31,20 +31,41 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
|
||||
当前档位权重合计(顺时针):<strong>{{ getTierSumForValidation(t, 'clockwise') }}</strong>
|
||||
;逆时针:<strong>{{ getTierSumForValidation(t, 'counterclockwise') }}</strong>
|
||||
(各条 1-10000,档位内按权重比抽取,和不限制)
|
||||
{{
|
||||
$t('page.weightRatio.sumLine', {
|
||||
cw: getTierSumForValidation(t, 'clockwise'),
|
||||
ccw: getTierSumForValidation(t, 'counterclockwise')
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
<div class="weight-sum weight-sum-t4t5" v-else>
|
||||
T4、T5 档位抽中时仅有一个结果,无需配置权重。
|
||||
{{ $t('page.weightRatio.t4t5Note') }}
|
||||
</div>
|
||||
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
|
||||
<el-table-column label="结束索引(id)" prop="id" width="90" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="色子点数" prop="grid_number" width="80" align="center" />
|
||||
<el-table-column label="实际中奖金额" prop="real_ev" width="90" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="显示文本" prop="ui_text" min-width="70" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="备注" prop="remark" min-width="70" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="顺时针权重(1-10000)" min-width="160" align="center">
|
||||
<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">
|
||||
@@ -87,7 +108,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="逆时针权重(1-10000)" min-width="160" align="center">
|
||||
<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">
|
||||
@@ -135,8 +156,14 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<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
|
||||
v-permission="'dice:reward_config:index:batchUpdateWeights'"
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
@click="handleSubmit"
|
||||
>{{ $t('table.form.submit') }}</el-button
|
||||
>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -145,6 +172,9 @@
|
||||
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'
|
||||
@@ -335,7 +365,7 @@
|
||||
grouped.value = parseWeightRatioPayload(res)
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('获取权重配比数据失败')
|
||||
ElMessage.error(t('page.weightRatio.fetchFail'))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -358,19 +388,19 @@
|
||||
function handleSubmit() {
|
||||
const items = collectItems()
|
||||
if (items.length === 0) {
|
||||
ElMessage.info('没有可提交的配置')
|
||||
ElMessage.info(t('page.weightRatio.nothingToSubmit'))
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
api
|
||||
.batchUpdateWeights(items)
|
||||
.then(() => {
|
||||
ElMessage.success('保存成功')
|
||||
ElMessage.success(t('page.weightRatio.saveSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
})
|
||||
.catch((e: { message?: string }) => {
|
||||
ElMessage.error(e?.message ?? '保存失败')
|
||||
ElMessage.error(e?.message ?? t('page.weightRatio.submitFail'))
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false
|
||||
|
||||
@@ -0,0 +1,426 @@
|
||||
/**
|
||||
* 按与后端 DiceRewardLogic 一致的环形规则,为盘面 26 格(id 0~25)求档位 tier,
|
||||
* 并生成 real_ev / ui 等字段。
|
||||
*
|
||||
* 摇取点数为 5~30:起点为 grid_number==摇取点数 的格位下标,顺时针落点 (start+摇取)%26,
|
||||
* 逆时针落点 start-摇取(<0 则 +26)。
|
||||
*/
|
||||
|
||||
export type IndexTier = 'T1' | 'T2' | 'T3' | 'T4' | 'T5'
|
||||
|
||||
/** 豹子摇取点数:这些摇取下落点不得为 T4/T5(与 dice_reward 表中「点数」列一致) */
|
||||
export const LEOPARD_ROLLS: readonly number[] = [5, 10, 15, 20, 25, 30]
|
||||
|
||||
const BOARD_SIZE = 26
|
||||
const GRID_MIN = 5
|
||||
const GRID_MAX = 30
|
||||
|
||||
const T_ALL: IndexTier[] = ['T1', 'T2', 'T3', 'T4', 'T5']
|
||||
const T_NO_LEOPARD: IndexTier[] = ['T1', 'T2', 'T3']
|
||||
export interface BoardFrequencies {
|
||||
grids: number[]
|
||||
freqCw: number[]
|
||||
freqCcw: number[]
|
||||
leopardLandCw: Set<number>
|
||||
leopardLandCcw: Set<number>
|
||||
leopardLandUnion: Set<number>
|
||||
}
|
||||
|
||||
/**
|
||||
* 条数约束:T1/T4/T5 为「恰好」;T2 为「不少于」(加权条数,与 dice_reward 中顺/逆各 26 条摇取结果一致)
|
||||
*/
|
||||
export interface TierCountConstraints {
|
||||
t1FixedCw: number
|
||||
t2MinCw: number
|
||||
/** 顺时针方向 T4 加权条数固定为该值 */
|
||||
t4FixedCw: number
|
||||
/** 顺时针方向 T5 加权条数固定为该值 */
|
||||
t5FixedCw: number
|
||||
t1FixedCcw: number
|
||||
t2MinCcw: number
|
||||
/** 逆时针方向 T4 加权条数固定为该值 */
|
||||
t4FixedCcw: number
|
||||
/** 逆时针方向 T5 加权条数固定为该值 */
|
||||
t5FixedCcw: number
|
||||
}
|
||||
|
||||
/** 各档位统一 real_ev 标准(生成 DiceRewardConfig 时使用;细则可再到表格里改) */
|
||||
export interface TierRealEvStandards {
|
||||
T1: number
|
||||
T2: number
|
||||
T3: number
|
||||
T4: number
|
||||
T5: number
|
||||
}
|
||||
|
||||
/** 默认标准(与规则弹窗说明一致) */
|
||||
export const DEFAULT_TIER_REAL_EV_STANDARDS: TierRealEvStandards = {
|
||||
T1: 3,
|
||||
T2: 1.5,
|
||||
T3: 0.5,
|
||||
T4: -0.4,
|
||||
T5: 0
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验档位与 real_ev 区间是否一致;通过返回 null,否则返回 i18n 键名(不含 page.configPage. 前缀)
|
||||
*/
|
||||
export function validateTierRealEvStandards(s: TierRealEvStandards): string | null {
|
||||
if (!Number.isFinite(s.T1) || !(s.T1 > 2)) {
|
||||
return 'ruleGenInvalidT1RealEv'
|
||||
}
|
||||
if (!Number.isFinite(s.T2) || !(s.T2 > 1 && s.T2 < 2)) {
|
||||
return 'ruleGenInvalidT2RealEv'
|
||||
}
|
||||
if (!Number.isFinite(s.T3) || !(s.T3 > 0 && s.T3 < 1)) {
|
||||
return 'ruleGenInvalidT3RealEv'
|
||||
}
|
||||
if (!Number.isFinite(s.T4) || !(s.T4 < 0)) {
|
||||
return 'ruleGenInvalidT4RealEv'
|
||||
}
|
||||
if (!Number.isFinite(s.T5) || s.T5 !== 0) {
|
||||
return 'ruleGenInvalidT5RealEv'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export interface GenerateTierInput {
|
||||
grids: number[]
|
||||
constraints: TierCountConstraints
|
||||
}
|
||||
|
||||
export interface GenerateTierResultOk {
|
||||
ok: true
|
||||
tiers: IndexTier[]
|
||||
}
|
||||
|
||||
export interface GenerateTierResultFail {
|
||||
ok: false
|
||||
message: string
|
||||
}
|
||||
|
||||
export type GenerateTierResult = GenerateTierResultOk | GenerateTierResultFail
|
||||
|
||||
export function computeBoardFrequencies(grids: number[]): BoardFrequencies | null {
|
||||
if (grids.length !== BOARD_SIZE) {
|
||||
return null
|
||||
}
|
||||
const gridToPos: Record<number, number> = {}
|
||||
for (let pos = 0; pos < BOARD_SIZE; pos++) {
|
||||
const g = grids[pos]
|
||||
if (g < GRID_MIN || g > GRID_MAX) {
|
||||
return null
|
||||
}
|
||||
if (gridToPos[g] !== undefined) {
|
||||
return null
|
||||
}
|
||||
gridToPos[g] = pos
|
||||
}
|
||||
const freqCw = new Array<number>(BOARD_SIZE).fill(0)
|
||||
const freqCcw = new Array<number>(BOARD_SIZE).fill(0)
|
||||
for (let roll = GRID_MIN; roll <= GRID_MAX; roll++) {
|
||||
const startPos = gridToPos[roll]
|
||||
const endCw = (startPos + roll) % BOARD_SIZE
|
||||
const endCcw = startPos - roll >= 0 ? startPos - roll : BOARD_SIZE + startPos - roll
|
||||
freqCw[endCw]++
|
||||
freqCcw[endCcw]++
|
||||
}
|
||||
const leopardLandCw = new Set<number>()
|
||||
const leopardLandCcw = new Set<number>()
|
||||
for (let di = 0; di < LEOPARD_ROLLS.length; di++) {
|
||||
const d = LEOPARD_ROLLS[di]
|
||||
const sp = gridToPos[d]
|
||||
leopardLandCw.add((sp + d) % BOARD_SIZE)
|
||||
const eccw = sp - d >= 0 ? sp - d : BOARD_SIZE + sp - d
|
||||
leopardLandCcw.add(eccw)
|
||||
}
|
||||
const leopardLandUnion = new Set<number>()
|
||||
leopardLandCw.forEach((x) => leopardLandUnion.add(x))
|
||||
leopardLandCcw.forEach((x) => leopardLandUnion.add(x))
|
||||
return {
|
||||
grids: [...grids],
|
||||
freqCw,
|
||||
freqCcw,
|
||||
leopardLandCw,
|
||||
leopardLandCcw,
|
||||
leopardLandUnion
|
||||
}
|
||||
}
|
||||
|
||||
function sumWeighted(freq: number[], tiers: IndexTier[], tier: IndexTier): number {
|
||||
let s = 0
|
||||
for (let i = 0; i < BOARD_SIZE; i++) {
|
||||
if (tiers[i] === tier) {
|
||||
s += freq[i]
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
function meetsConstraints(
|
||||
tiers: IndexTier[],
|
||||
freqCw: number[],
|
||||
freqCcw: number[],
|
||||
c: TierCountConstraints
|
||||
): boolean {
|
||||
const cw1 = sumWeighted(freqCw, tiers, 'T1')
|
||||
const cw2 = sumWeighted(freqCw, tiers, 'T2')
|
||||
const cw4 = sumWeighted(freqCw, tiers, 'T4')
|
||||
const cw5 = sumWeighted(freqCw, tiers, 'T5')
|
||||
const cc1 = sumWeighted(freqCcw, tiers, 'T1')
|
||||
const cc2 = sumWeighted(freqCcw, tiers, 'T2')
|
||||
const cc4 = sumWeighted(freqCcw, tiers, 'T4')
|
||||
const cc5 = sumWeighted(freqCcw, tiers, 'T5')
|
||||
return (
|
||||
cw1 === c.t1FixedCw &&
|
||||
cw2 >= c.t2MinCw &&
|
||||
cw4 === c.t4FixedCw &&
|
||||
cw5 === c.t5FixedCw &&
|
||||
cc1 === c.t1FixedCcw &&
|
||||
cc2 >= c.t2MinCcw &&
|
||||
cc4 === c.t4FixedCcw &&
|
||||
cc5 === c.t5FixedCcw
|
||||
)
|
||||
}
|
||||
|
||||
function nonLeopardTierChoices(c: TierCountConstraints): IndexTier[] {
|
||||
const out: IndexTier[] = ['T1', 'T2', 'T3']
|
||||
if (c.t4FixedCw > 0 || c.t4FixedCcw > 0) {
|
||||
out.push('T4')
|
||||
}
|
||||
if (c.t5FixedCw > 0 || c.t5FixedCcw > 0) {
|
||||
out.push('T5')
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function shuffleIndices(rand: () => number): number[] {
|
||||
const a: number[] = []
|
||||
for (let i = 0; i < BOARD_SIZE; i++) {
|
||||
a.push(i)
|
||||
}
|
||||
for (let i = BOARD_SIZE - 1; i > 0; i--) {
|
||||
const j = Math.floor(rand() * (i + 1))
|
||||
const t = a[i]
|
||||
a[i] = a[j]
|
||||
a[j] = t
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
function mulberry32(seed: number): () => number {
|
||||
return () => {
|
||||
let t = (seed += 0x6d2b79f5)
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1)
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机搜索可行档位:豹子落点禁 T4/T5;T4/T5 顺/逆加权条数分别等于约束中的固定值(可多条 T4/T5 格位)。
|
||||
*/
|
||||
export function generateTiers(input: GenerateTierInput): GenerateTierResult {
|
||||
const board = computeBoardFrequencies(input.grids)
|
||||
if (board === null) {
|
||||
return { ok: false, message: 'grid_number 须为 5~30 各出现一次且共 26 条' }
|
||||
}
|
||||
|
||||
const { freqCw, freqCcw, leopardLandUnion } = board
|
||||
const c = input.constraints
|
||||
|
||||
let seed = 0
|
||||
for (let i = 0; i < BOARD_SIZE; i++) {
|
||||
seed = (seed + input.grids[i] * 31 + i) | 0
|
||||
}
|
||||
const rand = mulberry32(seed === 0 ? 0x9e3779b9 : seed)
|
||||
|
||||
const needT5Cell = c.t5FixedCw > 0 || c.t5FixedCcw > 0
|
||||
if (needT5Cell) {
|
||||
let hasNonLeopard = false
|
||||
for (let i = 0; i < BOARD_SIZE; i++) {
|
||||
if (!leopardLandUnion.has(i)) {
|
||||
hasNonLeopard = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!hasNonLeopard) {
|
||||
return { ok: false, message: '无可用 T5 格位(豹子摇取落点占满全盘,请调整 grid_number 排布)' }
|
||||
}
|
||||
}
|
||||
|
||||
const nonLeopardChoices = nonLeopardTierChoices(c)
|
||||
const maxAttempts = 400000
|
||||
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
||||
const tiers: IndexTier[] = new Array(BOARD_SIZE).fill('T3')
|
||||
const order = shuffleIndices(rand)
|
||||
for (let oi = 0; oi < order.length; oi++) {
|
||||
const pos = order[oi]
|
||||
if (leopardLandUnion.has(pos)) {
|
||||
tiers[pos] = T_NO_LEOPARD[Math.floor(rand() * T_NO_LEOPARD.length)]
|
||||
} else {
|
||||
tiers[pos] = nonLeopardChoices[Math.floor(rand() * nonLeopardChoices.length)]
|
||||
}
|
||||
}
|
||||
|
||||
if (meetsConstraints(tiers, freqCw, freqCcw, c)) {
|
||||
return { ok: true, tiers }
|
||||
}
|
||||
}
|
||||
|
||||
return { ok: false, message: '在当前盘面与约束下未找到可行解,请调整 T1/T4/T5 固定条数或放宽 T2 下限后重试' }
|
||||
}
|
||||
|
||||
function uiTextByTierWhenStandards(
|
||||
tier: IndexTier,
|
||||
realEv: number
|
||||
): { ui_text: string; ui_text_en: string } {
|
||||
if (tier === 'T5') {
|
||||
return { ui_text: '再来一次', ui_text_en: 'Once again' }
|
||||
}
|
||||
const value = Number.isFinite(realEv) ? realEv.toFixed(2) : String(realEv)
|
||||
return { ui_text: value, ui_text_en: value }
|
||||
}
|
||||
|
||||
/** 展示文案:直接使用真实结算值(中英文相同) */
|
||||
function uiTextFromRealEv(realEv: number): { ui_text: string; ui_text_en: string } {
|
||||
const value = Number.isFinite(realEv) ? realEv.toFixed(2) : String(realEv)
|
||||
return { ui_text: value, ui_text_en: value }
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 tier 生成展示字段。
|
||||
* @param standards 若传入,则各档位统一使用对应 real_ev 标准;不传则使用内置随机占位(兼容脚本/旧逻辑)
|
||||
*/
|
||||
export function buildRowsFromTiers(
|
||||
grids: number[],
|
||||
tiers: IndexTier[],
|
||||
standards?: TierRealEvStandards
|
||||
): Array<{
|
||||
id: number
|
||||
grid_number: number
|
||||
ui_text: string
|
||||
ui_text_en: string
|
||||
real_ev: number
|
||||
tier: IndexTier
|
||||
remark: string
|
||||
}> {
|
||||
const rows: Array<{
|
||||
id: number
|
||||
grid_number: number
|
||||
ui_text: string
|
||||
ui_text_en: string
|
||||
real_ev: number
|
||||
tier: IndexTier
|
||||
remark: string
|
||||
}> = []
|
||||
let t4Seq = 0
|
||||
for (let id = 0; id < BOARD_SIZE; id++) {
|
||||
const tier = tiers[id]
|
||||
const grid_number = grids[id]
|
||||
let ui_text = ''
|
||||
let ui_text_en = ''
|
||||
let real_ev = 0
|
||||
let remark = ''
|
||||
|
||||
if (standards !== undefined) {
|
||||
if (tier === 'T1') {
|
||||
real_ev = standards.T1
|
||||
const f = uiTextByTierWhenStandards(tier, real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '大奖格'
|
||||
} else if (tier === 'T2') {
|
||||
real_ev = standards.T2
|
||||
const f = uiTextByTierWhenStandards(tier, real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = standards.T2 <= 1 ? '完美回本' : '小赚'
|
||||
} else if (tier === 'T3') {
|
||||
real_ev = standards.T3
|
||||
const f = uiTextByTierWhenStandards(tier, real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '抽水'
|
||||
} else if (tier === 'T4') {
|
||||
real_ev = standards.T4
|
||||
const f = uiTextByTierWhenStandards(tier, real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '惩罚'
|
||||
} else {
|
||||
real_ev = standards.T5
|
||||
const f = uiTextByTierWhenStandards(tier, real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '前端需要在播放一次动画(特殊)'
|
||||
}
|
||||
} else if (tier === 'T1') {
|
||||
real_ev = 101 + ((id * 17 + grid_number * 3) % 398)
|
||||
if (real_ev >= 500) {
|
||||
real_ev = 498
|
||||
}
|
||||
const f = uiTextFromRealEv(real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '大奖格'
|
||||
} else if (tier === 'T2') {
|
||||
if (id % 3 === 0) {
|
||||
real_ev = 1
|
||||
remark = '完美回本'
|
||||
} else {
|
||||
real_ev = 20 + ((id * 11) % 75)
|
||||
if (real_ev <= 0) {
|
||||
real_ev = 50
|
||||
}
|
||||
remark = '小赚'
|
||||
}
|
||||
const f = uiTextFromRealEv(real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
} else if (tier === 'T3') {
|
||||
real_ev = -72 - (id % 15)
|
||||
const f = uiTextFromRealEv(real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '抽水'
|
||||
} else if (tier === 'T4') {
|
||||
t4Seq++
|
||||
real_ev = -101 - t4Seq * 15
|
||||
const f = uiTextFromRealEv(real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '惩罚'
|
||||
} else {
|
||||
real_ev = 0
|
||||
const f = uiTextFromRealEv(real_ev)
|
||||
ui_text = f.ui_text
|
||||
ui_text_en = f.ui_text_en
|
||||
remark = '前端需要在播放一次动画(特殊)'
|
||||
}
|
||||
rows.push({
|
||||
id,
|
||||
grid_number,
|
||||
ui_text,
|
||||
ui_text_en,
|
||||
real_ev,
|
||||
tier,
|
||||
remark
|
||||
})
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
export function summarizeCounts(
|
||||
board: BoardFrequencies,
|
||||
tiers: IndexTier[]
|
||||
): { cw: Record<IndexTier, number>; ccw: Record<IndexTier, number> } {
|
||||
const cw: Record<IndexTier, number> = { T1: 0, T2: 0, T3: 0, T4: 0, T5: 0 }
|
||||
const ccw: Record<IndexTier, number> = { T1: 0, T2: 0, T3: 0, T4: 0, T5: 0 }
|
||||
for (let k = 0; k < T_ALL.length; k++) {
|
||||
const t = T_ALL[k]
|
||||
cw[t] = sumWeighted(board.freqCw, tiers, t)
|
||||
ccw[t] = sumWeighted(board.freqCcw, tiers, t)
|
||||
}
|
||||
return { cw, ccw }
|
||||
}
|
||||
@@ -40,13 +40,18 @@
|
||||
<template #status="{ row }">
|
||||
<span>{{ formatStatus(row.status) }}</span>
|
||||
</template>
|
||||
<!-- 付费抽取:顺时针、逆时针抽取次数(兼容旧数据用 s_count/n_count) -->
|
||||
<!-- 付费抽取:顺时针、逆时针抽取次数 -->
|
||||
<template #paid_draw="{ row }">
|
||||
<span>顺 {{ getPaidS(row) }} / 逆 {{ getPaidN(row) }}</span>
|
||||
<span
|
||||
>{{ $t('page.table.clockwiseAbbr') }} {{ getPaidS(row) }} /
|
||||
{{ $t('page.table.counterclockwiseAbbr') }} {{ getPaidN(row) }}</span
|
||||
>
|
||||
</template>
|
||||
<!-- 免费抽取:顺时针、逆时针抽取次数 -->
|
||||
<template #free_draw="{ row }">
|
||||
<span>顺 {{ row.free_s_count ?? 0 }} / 逆 {{ row.free_n_count ?? 0 }}</span>
|
||||
<template #chain_mode="{ row }">
|
||||
<span>{{ formatChainMode(row) }}</span>
|
||||
</template>
|
||||
<template #total_draw="{ row }">
|
||||
<span>{{ formatTotalDraw(row) }}</span>
|
||||
</template>
|
||||
<!-- 平台赚取金额 -->
|
||||
<template #platform_profit="{ row }">
|
||||
@@ -127,27 +132,49 @@
|
||||
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 '—'
|
||||
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)
|
||||
return Number(row.paid_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)
|
||||
return Number(row.paid_n_count ?? 0)
|
||||
}
|
||||
|
||||
// 平台赚取金额展示(未完成或空显示 —)
|
||||
function formatPlatformProfit(v: unknown): string {
|
||||
if (v === null || v === undefined || v === '') return '—'
|
||||
const dash = t('page.detail.dash')
|
||||
if (v === null || v === undefined || v === '') return dash
|
||||
const n = Number(v)
|
||||
if (Number.isNaN(n)) return '—'
|
||||
return String(n)
|
||||
if (Number.isNaN(n)) return dash
|
||||
return n.toFixed(2)
|
||||
}
|
||||
|
||||
/** 链式再来一次:1=是(新库字段),JSON 旧数据用 tier_weights_snapshot.chain_free_mode */
|
||||
function formatChainMode(row: Record<string, any>): string {
|
||||
const v = row.chain_free_mode
|
||||
if (v === 1 || v === '1' || v === true) return t('page.table.chainModeYes')
|
||||
const snap = row.tier_weights_snapshot
|
||||
if (snap && typeof snap === 'object' && (snap as { chain_free_mode?: boolean }).chain_free_mode) {
|
||||
return t('page.table.chainModeYes')
|
||||
}
|
||||
return t('page.table.chainModeNo')
|
||||
}
|
||||
|
||||
/** 总抽奖次数:仅完成态写最终值;测试中显示已完成次数 */
|
||||
function formatTotalDraw(row: Record<string, any>): string {
|
||||
const status = Number(row.status)
|
||||
const done = Number(row.total_play_count ?? 0)
|
||||
const over = Number(row.over_play_count ?? 0)
|
||||
if (status === 1) {
|
||||
return String(done)
|
||||
}
|
||||
if (status === -1) {
|
||||
return over > 0 ? t('page.table.progressFailed', { over }) : t('page.detail.dash')
|
||||
}
|
||||
return t('page.table.progressDraws', { over })
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
@@ -186,12 +213,30 @@
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'free_draw',
|
||||
label: 'page.table.freeDraw',
|
||||
width: 160,
|
||||
prop: 'chain_mode',
|
||||
label: 'page.table.chainMode',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'paid_planned_spins',
|
||||
label: 'page.table.paidPlannedSpins',
|
||||
width: 120,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'ante',
|
||||
label: 'page.table.ante',
|
||||
width: 90,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'play_again_count',
|
||||
label: 'page.table.playAgainCount',
|
||||
width: 120,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'platform_profit',
|
||||
label: 'page.table.platformProfit',
|
||||
@@ -199,7 +244,13 @@
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{ prop: 'total_play_count', label: 'page.table.totalDrawCount', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'total_draw',
|
||||
label: 'page.table.totalDrawCount',
|
||||
width: 140,
|
||||
align: 'center',
|
||||
useSlot: true
|
||||
},
|
||||
{
|
||||
prop: 'admin_name',
|
||||
label: 'page.table.createdBy',
|
||||
@@ -207,6 +258,13 @@
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: 'page.table.remark',
|
||||
width: 220,
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'create_time', label: 'page.table.createTime', width: 170, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
title="测试记录详情"
|
||||
:title="$t('page.detail.title')"
|
||||
:size="drawerSize"
|
||||
direction="rtl"
|
||||
destroy-on-close
|
||||
@@ -9,37 +9,45 @@
|
||||
>
|
||||
<template v-if="record">
|
||||
<div class="detail-section">
|
||||
<div class="section-title">基本信息</div>
|
||||
<div class="section-title">{{ $t('page.detail.sectionBasic') }}</div>
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="记录ID">
|
||||
<el-descriptions-item :label="$t('page.detail.recordId')">
|
||||
{{ record.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="测试次数">{{ record.test_count }} 次</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ record.create_time || '—' }}
|
||||
<el-descriptions-item :label="$t('page.detail.chainModeLabel')">
|
||||
{{ formatChainModeDetail(record) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="执行管理员">
|
||||
{{ record.admin_name ?? record.admin_id ?? '—' }}
|
||||
<el-descriptions-item :label="$t('page.detail.paidPlannedSpins')">
|
||||
{{ record.paid_planned_spins ?? $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="付费奖池配置ID">
|
||||
{{ record.paid_lottery_config_id ?? record.lottery_config_id ?? '—' }}
|
||||
<el-descriptions-item :label="$t('page.detail.testCount')">
|
||||
{{ formatTestCountDisplay(record) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="免费奖池配置ID">
|
||||
{{ record.free_lottery_config_id ?? '—' }}
|
||||
<el-descriptions-item :label="$t('page.detail.createTime')">
|
||||
{{ record.create_time || $t('page.detail.dash') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="BIGWIN 权重快照">
|
||||
<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>—</template>
|
||||
<template v-else>{{ $t('page.detail.dash') }}</template>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">付费抽奖档位概率(T1-T5,测试时使用)</div>
|
||||
<div class="section-title">{{ $t('page.detail.sectionPaidTier') }}</div>
|
||||
<el-table
|
||||
v-if="paidTierTableData.length"
|
||||
:data="paidTierTableData"
|
||||
@@ -48,17 +56,17 @@
|
||||
class="tier-weights-table"
|
||||
max-height="160"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="100" align="center" />
|
||||
<el-table-column prop="percent" label="占比" width="100" align="center" />
|
||||
<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">
|
||||
暂无付费档位数据(旧记录可能仅保存 tier_weights_snapshot)
|
||||
{{ $t('page.detail.emptyPaidTier') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">免费抽奖档位概率(T1-T5,测试时使用)</div>
|
||||
<div class="section-title">{{ $t('page.detail.sectionFreeTier') }}</div>
|
||||
<el-table
|
||||
v-if="freeTierTableData.length"
|
||||
:data="freeTierTableData"
|
||||
@@ -67,18 +75,18 @@
|
||||
class="tier-weights-table"
|
||||
max-height="160"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="100" align="center" />
|
||||
<el-table-column prop="percent" label="占比" width="100" align="center" />
|
||||
<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">暂无免费档位数据</div>
|
||||
<div v-else class="empty-tip">{{ $t('page.detail.emptyFreeTier') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">权重配比快照(测试时使用的 T1-T5/BIGWIN 配置)</div>
|
||||
<div class="section-title">{{ $t('page.detail.sectionSnapshot') }}</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">顺时针(非 BIGWIN)</div>
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subCw') }}</div>
|
||||
<el-table
|
||||
:data="snapshotClockwise"
|
||||
border
|
||||
@@ -86,15 +94,15 @@
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
<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">暂无顺时针数据</div>
|
||||
<div v-if="!snapshotClockwise.length" class="empty-tip">{{ $t('page.detail.emptyCw') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">逆时针(非 BIGWIN)</div>
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subCcw') }}</div>
|
||||
<el-table
|
||||
:data="snapshotCounterclockwise"
|
||||
border
|
||||
@@ -102,15 +110,15 @@
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
<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">暂无逆时针数据</div>
|
||||
<div v-if="!snapshotCounterclockwise.length" class="empty-tip">{{ $t('page.detail.emptyCcw') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">BIGWIN(按 DiceRewardConfig 配置快照)</div>
|
||||
<div class="snapshot-subtitle">{{ $t('page.detail.subBigwin') }}</div>
|
||||
<el-table
|
||||
:data="bigwinTableData"
|
||||
border
|
||||
@@ -118,30 +126,35 @@
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" 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="!bigwinTableData.length" class="empty-tip">暂无 BIGWIN 数据</div>
|
||||
<div v-if="!bigwinTableData.length" class="empty-tip">{{ $t('page.detail.emptyBigwinTable') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">落点统计(各 grid_number 出现次数)</div>
|
||||
<div class="section-title">{{ $t('page.detail.sectionResult') }}</div>
|
||||
<div class="chart-wrap">
|
||||
<ArtBarChart
|
||||
x-axis-name="色子点数 (grid_number)"
|
||||
:x-axis-name="$t('page.detail.chartXAxis')"
|
||||
:x-axis-data="chartLabels"
|
||||
:data="chartData"
|
||||
height="280px"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="resultTotal === 0" class="empty-tip">暂无落点数据</div>
|
||||
<div v-else class="result-summary">总落点次数:{{ resultTotal }}</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 type="primary" :loading="importing" @click="openImport">
|
||||
导入到当前配置
|
||||
<el-button
|
||||
v-permission="'dice:reward_config_record:index:importFromRecord'"
|
||||
type="primary"
|
||||
:loading="importing"
|
||||
@click="openImport"
|
||||
>
|
||||
{{ $t('page.detail.btnImport') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -149,21 +162,19 @@
|
||||
<!-- 导入弹窗 -->
|
||||
<el-dialog
|
||||
v-model="importVisible"
|
||||
title="导入到正式配置"
|
||||
:title="$t('page.detail.importTitle')"
|
||||
width="520px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="import-desc">
|
||||
将本测试记录导入:<strong>DiceReward</strong>(格子权重)、
|
||||
<strong>DiceRewardConfig</strong>(BIGWIN weight)、
|
||||
<strong>DiceLotteryPoolConfig</strong>(付费/免费 T1-T5 档位概率)。请选择要写入的奖池。
|
||||
{{ $t('page.detail.importDesc') }}
|
||||
</p>
|
||||
<el-form label-width="160px">
|
||||
<el-form-item label="导入付费档位概率到奖池">
|
||||
<el-form-item :label="$t('page.detail.importPaidLabel')">
|
||||
<el-select
|
||||
v-model="importPaidLotteryConfigId"
|
||||
placeholder="选择任意奖池(建议付费池)"
|
||||
:placeholder="$t('page.detail.importPaidPlaceholder')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -175,12 +186,12 @@
|
||||
:value="opt.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">不选则使用本记录保存时的付费奖池配置 ID</div>
|
||||
<div class="form-tip">{{ $t('page.detail.importPaidTip') }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="导入免费档位概率到奖池">
|
||||
<el-form-item :label="$t('page.detail.importFreeLabel')">
|
||||
<el-select
|
||||
v-model="importFreeLotteryConfigId"
|
||||
placeholder="选择任意奖池(建议免费池)"
|
||||
:placeholder="$t('page.detail.importFreePlaceholder')"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -192,12 +203,18 @@
|
||||
:value="opt.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-tip">不选则使用本记录保存时的免费奖池配置 ID</div>
|
||||
<div class="form-tip">{{ $t('page.detail.importFreeTip') }}</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="importVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="importing" @click="confirmImport">确认导入</el-button>
|
||||
<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>
|
||||
@@ -208,6 +225,9 @@
|
||||
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,
|
||||
@@ -217,6 +237,11 @@
|
||||
interface RecordRow {
|
||||
id?: number
|
||||
test_count?: number
|
||||
total_play_count?: number
|
||||
status?: number
|
||||
over_play_count?: number
|
||||
chain_free_mode?: number | boolean | string
|
||||
paid_planned_spins?: number
|
||||
create_time?: string
|
||||
admin_id?: number | null
|
||||
admin_name?: string
|
||||
@@ -224,7 +249,6 @@
|
||||
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>
|
||||
@@ -243,6 +267,32 @@
|
||||
result_counts?: Record<string, number>
|
||||
}
|
||||
|
||||
function formatChainModeDetail(record: RecordRow | null): string {
|
||||
if (!record) return t('page.detail.dash')
|
||||
const v = record.chain_free_mode
|
||||
if (v === 1 || v === '1' || v === true) return t('page.table.chainModeYes')
|
||||
const snap = record.tier_weights_snapshot
|
||||
if (snap && typeof snap === 'object' && (snap as { chain_free_mode?: boolean }).chain_free_mode) {
|
||||
return t('page.table.chainModeYes')
|
||||
}
|
||||
return t('page.table.chainModeNo')
|
||||
}
|
||||
|
||||
function formatTestCountDisplay(record: RecordRow | null): string {
|
||||
if (!record) return t('page.detail.dash')
|
||||
const status = Number(record.status)
|
||||
if (status === 1) {
|
||||
const n = record.test_count ?? record.total_play_count
|
||||
return `${n ?? 0}${t('page.detail.testCountSuffix')}`
|
||||
}
|
||||
if (status === -1) {
|
||||
const over = Number(record.over_play_count ?? 0)
|
||||
return over > 0 ? t('page.detail.testCountFailed', { over }) : t('page.detail.dash')
|
||||
}
|
||||
const over = Number(record.over_play_count ?? 0)
|
||||
return t('page.detail.testCountProgress', { over })
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
record: RecordRow | null
|
||||
@@ -266,24 +316,26 @@
|
||||
const importing = ref(false)
|
||||
const importPaidLotteryConfigId = ref<number | null>(null)
|
||||
const importFreeLotteryConfigId = ref<number | null>(null)
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string; type: number }>>([])
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
function tierWeightsToTableData(t: Record<string, number> | null | undefined) {
|
||||
if (!t || typeof t !== 'object') return []
|
||||
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 = t[tier] ?? t[tier.toLowerCase()] ?? 0
|
||||
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)}%` : '—'
|
||||
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
|
||||
@@ -305,6 +357,7 @@
|
||||
})
|
||||
|
||||
const freeTierTableData = computed(() => {
|
||||
locale.value
|
||||
const r = props.record
|
||||
const freeFromRecord = r?.free_tier_weights
|
||||
const snapshot = r?.tier_weights_snapshot
|
||||
@@ -352,6 +405,8 @@
|
||||
})
|
||||
|
||||
const snapshotTableData = computed(() => {
|
||||
locale.value
|
||||
const dash = t('page.detail.dash')
|
||||
const snapshot = props.record?.weight_config_snapshot as
|
||||
| Array<{
|
||||
tier?: string
|
||||
@@ -364,11 +419,12 @@
|
||||
return snapshot.map((item) => {
|
||||
const dir = item.direction
|
||||
return {
|
||||
tier: item.tier ?? '—',
|
||||
tier: item.tier ?? dash,
|
||||
direction: dir,
|
||||
direction_label: dir === 0 ? '顺时针' : dir === 1 ? '逆时针' : '—',
|
||||
grid_number: item.grid_number ?? '—',
|
||||
weight: item.weight ?? '—'
|
||||
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
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -458,11 +514,11 @@
|
||||
paid_lottery_config_id: importPaidLotteryConfigId.value ?? undefined,
|
||||
free_lottery_config_id: importFreeLotteryConfigId.value ?? undefined
|
||||
})
|
||||
ElMessage.success('导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置')
|
||||
ElMessage.success(t('page.detail.importSuccess'))
|
||||
importVisible.value = false
|
||||
emit('import-done')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message ?? '导入失败')
|
||||
ElMessage.error(e?.message ?? t('page.detail.importFail'))
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<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="测试次数:100/500/1000" prop="test_count">
|
||||
<el-input v-model="formData.test_count" placeholder="请输入测试次数:100/500/1000" />
|
||||
<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="测试时权重配比快照:按档位保存 id,grid_number,tier,weight" prop="weight_config_snapshot">
|
||||
<el-input v-model="formData.weight_config_snapshot" placeholder="请输入测试时权重配比快照:按档位保存 id,grid_number,tier,weight" />
|
||||
<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="落点统计:grid_number=>出现次数" prop="result_counts">
|
||||
<el-input v-model="formData.result_counts" placeholder="请输入落点统计:grid_number=>出现次数" />
|
||||
<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">取消</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>
|
||||
@@ -29,6 +29,7 @@
|
||||
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
|
||||
@@ -48,6 +49,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
@@ -62,9 +64,9 @@
|
||||
/**
|
||||
* 表单验证规则
|
||||
*/
|
||||
const rules = reactive<FormRules>({
|
||||
test_count: [{ required: true, message: '测试次数:100/500/1000必需填写', trigger: 'blur' }],
|
||||
})
|
||||
const rules = computed<FormRules>(() => ({
|
||||
test_count: [{ required: true, message: t('page.form.ruleTestCountRequired'), trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
/**
|
||||
* 初始数据
|
||||
@@ -136,10 +138,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()
|
||||
|
||||
@@ -8,6 +8,32 @@
|
||||
@search="handleSearch"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.paidPlannedSpins')" prop="paid_planned_spins">
|
||||
<el-input-number
|
||||
v-model="formData.paid_planned_spins"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.ante')" prop="ante">
|
||||
<el-input-number
|
||||
v-model="formData.ante"
|
||||
:placeholder="$t('table.searchBar.all')"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useTerminalStore, TaskStatus } from '../store/terminal'
|
||||
import { $t } from '@/locales'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'success'): void
|
||||
@@ -157,51 +158,51 @@
|
||||
}
|
||||
|
||||
const webBuild = () => {
|
||||
ElMessageBox.confirm('确认重新打包前端并发布项目吗?', '前端打包发布', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('uiMsg.saipackageWebBuildConfirm'), $t('uiMsg.saipackageWebBuildTitle'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
terminal.addNodeTask('web-build', '', () => {
|
||||
ElMessage.success('前端打包发布成功')
|
||||
ElMessage.success($t('uiMsg.saipackageWebBuildSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const handleFronted = () => {
|
||||
ElMessageBox.confirm('确认更新前端Node依赖吗?', '前端依赖更新', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('uiMsg.saipackageFrontendDepsConfirm'), $t('uiMsg.saipackageFrontendDepsTitle'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
terminal.addNodeTask('web-install', '', () => {
|
||||
ElMessage.success('前端依赖更新成功')
|
||||
ElMessage.success($t('uiMsg.saipackageFrontendDepsSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const handleBackend = () => {
|
||||
ElMessageBox.confirm('确认更新后端composer包吗?', 'composer包更新', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('uiMsg.saipackageComposerConfirm'), $t('uiMsg.saipackageComposerTitle'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
terminal.addTask('composer.update', '', () => {
|
||||
ElMessage.success('composer包更新成功')
|
||||
ElMessage.success($t('uiMsg.saipackageComposerSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const frontInstall = (extend = '') => {
|
||||
terminal.addNodeTask('web-install', extend, () => {
|
||||
ElMessage.success('前端依赖更新成功')
|
||||
ElMessage.success($t('uiMsg.saipackageFrontendDepsSuccess'))
|
||||
emit('success')
|
||||
})
|
||||
}
|
||||
|
||||
const backendInstall = (extend = '') => {
|
||||
terminal.addTask('composer.update', extend, () => {
|
||||
ElMessage.success('composer包更新成功')
|
||||
ElMessage.success($t('uiMsg.saipackageComposerSuccess'))
|
||||
setTimeout(() => {
|
||||
emit('success')
|
||||
}, 500)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -186,6 +186,7 @@
|
||||
import api from '@/api/safeguard/server'
|
||||
import { onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -219,16 +220,16 @@
|
||||
*/
|
||||
const handleClearCache = (tag: string): void => {
|
||||
if (!tag) {
|
||||
ElMessage.warning('请选择要清理的缓存')
|
||||
ElMessage.warning($t('uiMsg.clearCacheSelect'))
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(`确定要清理标签:【${tag}】的缓存吗?`, '清理选中缓存', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('uiMsg.clearCacheConfirmByTag', { tag }), $t('uiMsg.clearCacheTitle'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
api.clear({ tag }).then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
ElMessage.success($t('uiMsg.operationSuccess'))
|
||||
updateCacheInfo()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -84,7 +84,8 @@
|
||||
<script setup lang="ts">
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import api from '@/api/safeguard/database'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import TableDialog from './modules/table-dialog.vue'
|
||||
@@ -126,7 +127,12 @@
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection' },
|
||||
{ prop: 'name', label: 'page.table.tableName', minWidth: 200 },
|
||||
{ prop: 'comment', label: 'page.table.tableComment', minWidth: 150, showOverflowTooltip: true },
|
||||
{
|
||||
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 },
|
||||
@@ -134,7 +140,13 @@
|
||||
{ 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 }
|
||||
{
|
||||
prop: 'operation',
|
||||
label: 'table.actions.operation',
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -167,20 +179,20 @@
|
||||
*/
|
||||
const handleOptimizeRows = (): void => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要优化的行')
|
||||
ElMessage.warning($t('page.ui.selectRowsToOptimize'))
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
`确定要优化选中的 ${selectedRows.value.length} 条数据吗?`,
|
||||
'优化选中数据',
|
||||
$t('page.ui.optimizeConfirm', { n: selectedRows.value.length }),
|
||||
$t('page.ui.optimizeTitle'),
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}
|
||||
).then(() => {
|
||||
api.optimize({ tables: selectedRows.value.map((row) => row.name) }).then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
ElMessage.success($t('uiMsg.operationSuccess'))
|
||||
refreshData()
|
||||
selectedRows.value = []
|
||||
})
|
||||
@@ -192,20 +204,20 @@
|
||||
*/
|
||||
const handleFragmentRows = (): void => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要清理碎片的行')
|
||||
ElMessage.warning($t('page.ui.selectRowsToFragment'))
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
`确定要清理选中的 ${selectedRows.value.length} 条数据吗?`,
|
||||
'清理碎片操作',
|
||||
$t('page.ui.fragmentConfirm', { n: selectedRows.value.length }),
|
||||
$t('page.ui.fragmentTitle'),
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}
|
||||
).then(() => {
|
||||
api.fragment({ tables: selectedRows.value.map((row) => row.name) }).then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
ElMessage.success($t('uiMsg.operationSuccess'))
|
||||
refreshData()
|
||||
selectedRows.value = []
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -129,7 +129,8 @@
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
import WorkDialog from './modules/work-dialog.vue'
|
||||
@@ -252,15 +253,15 @@
|
||||
* @param row
|
||||
*/
|
||||
const handlePassword = (row: any) => {
|
||||
ElMessageBox.prompt('请输入新密码', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.prompt($t('page.ui.promptNewPassword'), $t('uiMsg.titlePrompt'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
inputPattern: /^.{6,16}$/,
|
||||
inputErrorMessage: '密码长度在6到16之间',
|
||||
inputErrorMessage: $t('page.ui.passwordLengthError'),
|
||||
type: 'warning'
|
||||
}).then(({ value }) => {
|
||||
api.changePassword({ id: row.id, password: value }).then(() => {
|
||||
ElMessage.success('修改密码成功')
|
||||
ElMessage.success($t('page.ui.passwordChanged'))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -270,13 +271,13 @@
|
||||
* @param row
|
||||
*/
|
||||
const handleCache = (row: any) => {
|
||||
ElMessageBox.confirm('确定要清理缓存吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('page.ui.clearCacheConfirm'), $t('uiMsg.titlePrompt'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
api.clearCache({ id: row.id }).then(() => {
|
||||
ElMessage.success('清理缓存成功')
|
||||
ElMessage.success($t('uiMsg.clearCacheSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import api from '@/api/safeguard/database'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import generate from '@/api/tool/generate'
|
||||
@@ -172,7 +173,7 @@
|
||||
// 确认选择装载数据表
|
||||
const handleLoadTable = async () => {
|
||||
if (selectedRows.value.length < 1) {
|
||||
ElMessage.info('至少要选择一条数据')
|
||||
ElMessage.info($t('uiMsg.selectAtLeastOne'))
|
||||
return
|
||||
}
|
||||
const names = selectedRows.value.map((item) => ({
|
||||
@@ -185,7 +186,7 @@
|
||||
source: searchForm.value.source,
|
||||
names
|
||||
})
|
||||
ElMessage.success('装载成功')
|
||||
ElMessage.success($t('page.ui.loadSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import generate from '@/api/tool/generate'
|
||||
|
||||
interface Props {
|
||||
@@ -94,9 +95,9 @@
|
||||
const handleCopy = async (code: string) => {
|
||||
try {
|
||||
await copy(code)
|
||||
ElMessage.success('代码已复制到剪贴板')
|
||||
ElMessage.success($t('page.ui.copyToClipboard'))
|
||||
} catch {
|
||||
ElMessage.error('复制失败,请手动复制')
|
||||
ElMessage.error($t('uiMsg.copyFail'))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import api from '@/api/tool/generate'
|
||||
import { downloadFile } from '@/utils/tool'
|
||||
|
||||
@@ -211,15 +212,15 @@
|
||||
* 生成代码下载
|
||||
*/
|
||||
const generateCode = async (ids: number | string) => {
|
||||
ElMessage.info('代码生成下载中,请稍后')
|
||||
ElMessage.info($t('page.ui.generating'))
|
||||
const response = await api.generateCode({
|
||||
ids: ids.toString().split(',')
|
||||
})
|
||||
if (response) {
|
||||
downloadFile(response, 'code.zip')
|
||||
ElMessage.success('代码生成成功,开始下载')
|
||||
ElMessage.success($t('page.ui.generateSuccess'))
|
||||
} else {
|
||||
ElMessage.error('文件下载失败')
|
||||
ElMessage.error($t('page.ui.downloadFail'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,13 +228,13 @@
|
||||
* 同步表结构
|
||||
*/
|
||||
const syncTable = async (id: number) => {
|
||||
ElMessageBox.confirm('执行同步操作将会覆盖已经设置的表结构,确定要同步吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('page.ui.syncConfirm'), $t('uiMsg.titlePrompt'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
api.async({ id }).then(() => {
|
||||
ElMessage.success('同步成功')
|
||||
ElMessage.success($t('page.ui.syncSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -242,13 +243,13 @@
|
||||
* 生成到项目
|
||||
*/
|
||||
const generateFile = async (id: number) => {
|
||||
ElMessageBox.confirm('生成到项目将会覆盖原有文件,确定要生成吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('page.ui.generateToProjectConfirm'), $t('uiMsg.titlePrompt'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
api.generateFile({ id }).then(() => {
|
||||
ElMessage.success('生成到项目成功')
|
||||
ElMessage.success($t('page.ui.generateToProjectSuccess'))
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -258,7 +259,7 @@
|
||||
*/
|
||||
const batchGenerate = () => {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.error('至少要选择一条数据')
|
||||
ElMessage.error($t('uiMsg.selectAtLeastOne'))
|
||||
return
|
||||
}
|
||||
generateCode(selectedRows.value.map((item: any) => item.id).join(','))
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import api from '@/api/tool/crontab'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
@@ -146,13 +147,13 @@
|
||||
|
||||
// 运行任务
|
||||
const handleRun = (row: any) => {
|
||||
ElMessageBox.confirm(`确定要运行任务【${row.name}】吗?`, '运行任务', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm($t('page.ui.runConfirm', { name: row.name }), $t('page.ui.runTitle'), {
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
api.run({ id: row.id }).then(() => {
|
||||
ElMessage.success('任务运行成功')
|
||||
ElMessage.success($t('page.ui.runSuccess'))
|
||||
refreshData()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { $t } from '@/locales'
|
||||
import api from '@/api/tool/crontab'
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
|
||||
@@ -128,7 +129,7 @@
|
||||
*/
|
||||
const initPage = async () => {
|
||||
if (!props.data?.id) {
|
||||
ElMessage.error('请先选择一个任务')
|
||||
ElMessage.error($t('page.ui.selectTaskFirst'))
|
||||
return
|
||||
}
|
||||
searchForm.value.crontab_id = props.data.id
|
||||
@@ -166,20 +167,20 @@
|
||||
// 确认选择装载数据表
|
||||
const handleLoadTable = async () => {
|
||||
if (selectedRows.value.length < 1) {
|
||||
ElMessage.info('至少要选择一条数据')
|
||||
ElMessage.info($t('uiMsg.selectAtLeastOne'))
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(
|
||||
`确定要删除选中的 ${selectedRows.value.length} 条数据吗?`,
|
||||
'删除选中数据',
|
||||
$t('uiMsg.deleteConfirmSelected', { n: selectedRows.value.length }),
|
||||
$t('uiMsg.titleDeleteSelected'),
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: $t('uiMsg.btnOk'),
|
||||
cancelButtonText: $t('uiMsg.btnCancel'),
|
||||
type: 'error'
|
||||
}
|
||||
).then(() => {
|
||||
api.deleteCrontabLog({ ids: selectedRows.value.map((row) => row.id) }).then(() => {
|
||||
ElMessage.success('删除成功')
|
||||
ElMessage.success($t('uiMsg.deleteSuccess'))
|
||||
refreshData()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
DB_TYPE=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_NAME=saiadmin
|
||||
DB_USER=root
|
||||
DB_PASSWORD=123456
|
||||
DB_NAME=dafuweng-v3
|
||||
DB_USER=dafuweng-v3
|
||||
DB_PASSWORD=tA6rciKLKxpFNGAm
|
||||
DB_PREFIX=
|
||||
DB_POOL_MAX=32
|
||||
DB_POOL_MIN=4
|
||||
@@ -17,10 +17,15 @@ REDIS_POOL_MAX=32
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=''
|
||||
REDIS_DB=0
|
||||
REDIS_DB=1
|
||||
|
||||
# webman channel(用于定时任务通信)
|
||||
WEBMAN_CHANNEL_HOST=127.0.0.1
|
||||
WEBMAN_CHANNEL_PORT=2207
|
||||
WEBMAN_CHANNEL_LISTEN_HOST=0.0.0.0
|
||||
|
||||
# 游戏地址,用于 /api/v1/getGameUrl 返回
|
||||
GAME_URL=dice-game.yuliao666.top
|
||||
GAME_URL=dice-v3-game.yuliao666.top
|
||||
|
||||
# API 鉴权与用户(可选,不填则用默认值)
|
||||
# authToken 签名密钥(必填,与客户端约定,用于 signature 校验)
|
||||
|
||||
@@ -11,6 +11,7 @@ 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\ante_config\DiceAnteConfig;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
@@ -73,30 +74,30 @@ class GameController extends BaseController
|
||||
* 购买抽奖券
|
||||
* POST /api/game/buyLotteryTickets
|
||||
* header: token(由 TokenMiddleware 注入 request->player_id)
|
||||
* body: count = 1 | 5 | 10(1次/100coin, 5次/500coin, 10次/1000coin)
|
||||
* body: count = 1 | 5 | 10(1次/1coin, 5次/5coin, 10次/10coin)
|
||||
*/
|
||||
public function buyLotteryTickets(Request $request): Response
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
try {
|
||||
$logic = new GameLogic();
|
||||
$data = $logic->buyLotteryTickets($userId, $count);
|
||||
return $this->success($data);
|
||||
} catch (ApiException $e) {
|
||||
$msg = $e->getMessage();
|
||||
if ($msg === '平台币不足') {
|
||||
$player = DicePlayer::find($userId);
|
||||
$coin = $player ? (float) $player->coin : 0;
|
||||
return $this->success(['coin' => $coin], $msg);
|
||||
}
|
||||
return $this->fail($msg, ReturnCode::BUSINESS_ERROR);
|
||||
}
|
||||
}
|
||||
// public function buyLotteryTickets(Request $request): Response
|
||||
// {
|
||||
// $userId = (int) ($request->player_id ?? 0);
|
||||
// $count = (int) $request->post('count', 0);
|
||||
// if (!in_array($count, [1, 5, 10], true)) {
|
||||
// return $this->fail('Invalid lottery ticket purchase', ReturnCode::PARAMS_ERROR);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// $logic = new GameLogic();
|
||||
// $data = $logic->buyLotteryTickets($userId, $count);
|
||||
// return $this->success($data);
|
||||
// } catch (ApiException $e) {
|
||||
// $msg = $e->getMessage();
|
||||
// if ($msg === '平台币不足') {
|
||||
// $player = DicePlayer::find($userId);
|
||||
// $coin = $player ? (float) $player->coin : 0;
|
||||
// return $this->success(['coin' => $coin], $msg);
|
||||
// }
|
||||
// return $this->fail($msg, ReturnCode::BUSINESS_ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取彩金池(中奖配置表)
|
||||
@@ -127,6 +128,8 @@ class GameController extends BaseController
|
||||
if ($uiEn !== '') {
|
||||
$row['ui_text'] = $uiEn;
|
||||
}
|
||||
//移除掉其中的s_start_index和n_start_index
|
||||
$row = array_diff_key($row, ['s_start_index'=>'', 's_end_index'=>'', 'weight'=>'', 'ui_text_en'=>'', 'create_time'=>'', 'update_time'=>'', 'type'=>'']);
|
||||
$list[$index] = $row;
|
||||
}
|
||||
}
|
||||
@@ -134,6 +137,20 @@ class GameController extends BaseController
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取底注配置(全部)
|
||||
* GET/any /api/game/anteConfig
|
||||
* header: token(TokenMiddleware 注入)
|
||||
* 返回:dice_ante_config 列表(包含 mult/is_default 等字段)
|
||||
*/
|
||||
public function anteConfig(Request $request): Response
|
||||
{
|
||||
// 用于后续抽奖校验:在接口中实例化 model,后续逻辑可复用相同的数据读取方式。
|
||||
$anteConfigModel = new DiceAnteConfig();
|
||||
$rows = $anteConfigModel->order('id', 'asc')->select()->toArray();
|
||||
return $this->success($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始游戏(抽奖一局)
|
||||
* POST /api/game/playStart
|
||||
@@ -147,30 +164,30 @@ class GameController extends BaseController
|
||||
if ($direction !== null) {
|
||||
$direction = (int) $direction;
|
||||
}
|
||||
$ante = $request->post('ante');
|
||||
if ($ante !== null) {
|
||||
$ante = (int) $ante;
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (!is_int($ante) || $ante <= 0) {
|
||||
return $this->fail('ante must be a positive integer', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::find($userId);
|
||||
if (!$player) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
$minEv = DiceRewardConfig::getCachedMinRealEv();
|
||||
$minCoin = abs($minEv + 100);
|
||||
$coin = (float) $player->coin;
|
||||
if ($coin < $minCoin) {
|
||||
$msg = ApiLang::translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin], $request);
|
||||
return $this->success([], $msg);
|
||||
return $this->fail('User not found', ReturnCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
$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('请求过于频繁,请稍后再试', ReturnCode::BUSINESS_ERROR);
|
||||
return $this->fail('too many requests, please try again later', ReturnCode::BUSINESS_ERROR);
|
||||
}
|
||||
try {
|
||||
$logic = new PlayStartLogic();
|
||||
$data = $logic->run($userId, (int)$direction);
|
||||
$data = $logic->run($userId, (int) $direction, $ante);
|
||||
|
||||
$lang = $request->header('lang', 'zh');
|
||||
if (!is_string($lang) || $lang === '') {
|
||||
@@ -179,10 +196,11 @@ class GameController extends BaseController
|
||||
$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 (is_array($data)) {
|
||||
$rewardTier = array_key_exists('reward_tier', $data) ? (string) ($data['reward_tier'] ?? '') : '';
|
||||
$targetIndex = array_key_exists('target_index', $data) ? (int) ($data['target_index'] ?? 0) : 0;
|
||||
if ($rewardTier !== 'BIGWIN' && $targetIndex > 0) {
|
||||
$configRow = DiceRewardConfig::getCachedById($targetIndex);
|
||||
if ($configRow !== null) {
|
||||
$uiText = '';
|
||||
$uiTextEn = '';
|
||||
@@ -201,6 +219,7 @@ class GameController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['tier'] = $data['reward_tier'] ?? '';
|
||||
|
||||
return $this->success($data);
|
||||
} catch (ApiException $e) {
|
||||
@@ -232,9 +251,8 @@ class GameController extends BaseController
|
||||
'win_coin' => 0,
|
||||
'super_win_coin' => 0,
|
||||
'reward_win_coin' => 0,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => 0,
|
||||
'reward_tier' => '',
|
||||
'start_index' => 0,
|
||||
'target_index' => 0,
|
||||
'roll_array' => '[]',
|
||||
@@ -250,7 +268,7 @@ class GameController extends BaseController
|
||||
if ($msg === '') {
|
||||
$msg = '没有原因';
|
||||
}
|
||||
return $this->fail('服务超时,' . $msg);
|
||||
return $this->fail('Service timeout: ' . $msg);
|
||||
} finally {
|
||||
Db::execute('SELECT RELEASE_LOCK(?)', [$lockName]);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class UserController extends BaseController
|
||||
$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 BaseController
|
||||
}
|
||||
$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,9 +89,9 @@ class UserController extends BaseController
|
||||
$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'];
|
||||
$fields = ['id', 'username', 'phone', 'uid', 'name', 'coin', 'total_ticket_count', 'free_ticket'];
|
||||
$info = [];
|
||||
foreach ($fields as $field) {
|
||||
if (array_key_exists($field, $user)) {
|
||||
@@ -111,7 +111,7 @@ class UserController extends BaseController
|
||||
$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)) {
|
||||
|
||||
@@ -31,27 +31,27 @@ class AuthTokenController extends BaseController
|
||||
$signature = trim((string) ($request->get('signature', '')));
|
||||
|
||||
if ($agentId === '' || $secret === '' || $time === '' || $signature === '') {
|
||||
return $this->fail('缺少参数:agent_id、secret、time、signature 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
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', ReturnCode::SERVER_ERROR);
|
||||
return $this->fail('API_AUTH_TOKEN_SECRET is not configured', ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
if ($secret !== $expectedSecret) {
|
||||
return $this->fail('密钥错误', ReturnCode::FORBIDDEN);
|
||||
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('时间戳已过期或无效,请同步时间', ReturnCode::FORBIDDEN);
|
||||
return $this->fail('Timestamp expired or invalid, please sync time', ReturnCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
$expectedSignature = md5($agentId . $secret . $time);
|
||||
if ($signature !== $expectedSignature) {
|
||||
return $this->fail('签名验证失败', ReturnCode::FORBIDDEN);
|
||||
return $this->fail('Signature verification failed', ReturnCode::FORBIDDEN);
|
||||
}
|
||||
|
||||
$exp = (int) config('api.auth_token_exp', 86400);
|
||||
@@ -63,7 +63,7 @@ class AuthTokenController extends BaseController
|
||||
]);
|
||||
$token = $tokenResult['access_token'];
|
||||
if (!AuthTokenCache::setToken($agentId, $token)) {
|
||||
return $this->fail('生成 token 失败', ReturnCode::SERVER_ERROR);
|
||||
return $this->fail('Failed to generate token', ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
|
||||
@@ -33,7 +33,7 @@ class GameController extends BaseController
|
||||
$time = trim((string) ($request->post('time', '')));
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
if ($password === '') {
|
||||
$password = '123456';
|
||||
@@ -43,11 +43,13 @@ class GameController extends BaseController
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ class GameController extends BaseController
|
||||
|
||||
try {
|
||||
$logic = new UserLogic();
|
||||
$result = $logic->loginByUsername($username, $password, $lang === 'en' ? 'en' : 'chs', 0.0, $time, $adminId);
|
||||
$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);
|
||||
}
|
||||
@@ -80,12 +82,12 @@ class GameController extends BaseController
|
||||
$username = trim((string) ($request->post('username', '')));
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
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'];
|
||||
@@ -247,27 +249,27 @@ class GameController extends BaseController
|
||||
$coin = $request->post('coin');
|
||||
|
||||
if ($username === '') {
|
||||
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
if ($coin === null || $coin === '') {
|
||||
return $this->fail('coin 不能为空', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('coin is required', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$coinVal = (float) $coin;
|
||||
if ($coinVal === 0.0) {
|
||||
return $this->fail('coin 不能为 0', ReturnCode::PARAMS_ERROR);
|
||||
return $this->fail('coin cannot be 0', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if (!$player) {
|
||||
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
|
||||
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('余额不足,无法转出', ReturnCode::BUSINESS_ERROR);
|
||||
return $this->fail('Insufficient balance to transfer', ReturnCode::BUSINESS_ERROR);
|
||||
}
|
||||
|
||||
$type = $coinVal > 0 ? 0 : 1;
|
||||
@@ -295,7 +297,7 @@ class GameController extends BaseController
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return $this->fail('操作失败:' . $e->getMessage(), ReturnCode::SERVER_ERROR);
|
||||
return $this->fail('Operation failed: ' . $e->getMessage(), ReturnCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 出于安全:删除该玩家相关缓存,后续 API 调用按需重建
|
||||
|
||||
@@ -2,52 +2,38 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* API 英文文案(请求头 lang=en 时使用)
|
||||
* key 为中文原文,value 为英文
|
||||
* API 英文文案(对外接口推荐:英文 key)
|
||||
* 请求头 lang=en 时使用,key 为英文错误码,value 为英文展示文案
|
||||
*/
|
||||
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',
|
||||
'该方向下暂无可用路径配置' => 'No path config available for this direction',
|
||||
// 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)',
|
||||
'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' => '原密码错误',
|
||||
];
|
||||
|
||||
@@ -17,9 +17,9 @@ use support\think\Db;
|
||||
class GameLogic
|
||||
{
|
||||
public const PACKAGES = [
|
||||
1 => ['coin' => 100, 'paid' => 1, 'free' => 0], // 1次/100coin
|
||||
5 => ['coin' => 500, 'paid' => 5, 'free' => 1], // 5张/500coin(5购买+1赠送,共6次)
|
||||
10 => ['coin' => 1000, 'paid' => 10, 'free' => 3], // 10张/1000coin(10购买+3赠送,共13次)
|
||||
1 => ['coin' => 1, 'paid' => 1, 'free' => 0], // 1次/1coin
|
||||
5 => ['coin' => 5, 'paid' => 5, 'free' => 1], // 5张/5coin(5购买+1赠送,共6次)
|
||||
10 => ['coin' => 10, 'paid' => 10, 'free' => 3], // 10张/10coin(10购买+3赠送,共13次)
|
||||
];
|
||||
|
||||
/** 钱包流水类型:购买抽奖次数 */
|
||||
@@ -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,14 +45,14 @@ 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;
|
||||
$coinAfter = round($coinBefore - $cost, 2);
|
||||
$totalBefore = (int) ($player->total_ticket_count ?? 0);
|
||||
$paidBefore = (int) ($player->paid_ticket_count ?? 0);
|
||||
$freeBefore = (int) ($player->free_ticket_count ?? 0);
|
||||
@@ -94,7 +94,7 @@ class GameLogic
|
||||
DicePlayerWalletRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => -$cost,
|
||||
'coin' => round(-$cost, 2),
|
||||
'type' => self::WALLET_TYPE_BUY_DRAW,
|
||||
'wallet_before' => $coinBefore,
|
||||
'wallet_after' => $coinAfter,
|
||||
@@ -107,7 +107,8 @@ class GameLogic
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'use_coins' => $cost,
|
||||
'use_coins' => round($cost, 2),
|
||||
'ante' => 1,
|
||||
'total_ticket_count' => $addTotal,
|
||||
'paid_ticket_count' => $addPaid,
|
||||
'free_ticket_count' => $addFree,
|
||||
@@ -120,7 +121,7 @@ class GameLogic
|
||||
}
|
||||
|
||||
return [
|
||||
'coin' => (float) $coinAfter,
|
||||
'coin' => round((float) $coinAfter, 2),
|
||||
'total_ticket_count' => (int) $totalAfter,
|
||||
'paid_ticket_count' => (int) $paidAfter,
|
||||
'free_ticket_count' => (int) $freeAfter,
|
||||
|
||||
@@ -4,9 +4,11 @@ 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_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\ante_config\DiceAnteConfig;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
@@ -22,6 +24,8 @@ use support\think\Db;
|
||||
*/
|
||||
class PlayStartLogic
|
||||
{
|
||||
/** 钱包流水类型:购买抽奖次数 */
|
||||
public const WALLET_TYPE_BUY_DRAW = 2;
|
||||
/** 抽奖类型:付费 */
|
||||
public const LOTTERY_TYPE_PAID = 0;
|
||||
/** 抽奖类型:免费 */
|
||||
@@ -33,8 +37,12 @@ class PlayStartLogic
|
||||
/** 对局状态:超时/失败 */
|
||||
public const RECORD_STATUS_TIMEOUT = 0;
|
||||
|
||||
/** 开启对局最低余额 = |DiceRewardConfig 最小 real_ev + 100| */
|
||||
private const MIN_COIN_EXTRA = 100;
|
||||
/** 单注费用(抽奖券基础费用) */
|
||||
private const UNIT_COST = 1.0;
|
||||
/** 免费抽奖注数缓存 key 前缀(用于强制下一局注数一致) */
|
||||
private const FREE_ANTE_KEY_PREFIX = 'api:game:free_ante:';
|
||||
/** 免费抽奖注数缓存过期(秒) */
|
||||
private const FREE_ANTE_TTL = 86400 * 7;
|
||||
/** 豹子号中大奖额外平台币(无 BIGWIN 配置时兜底) */
|
||||
private const SUPER_WIN_BONUS = 500;
|
||||
/** 可触发超级大奖的 grid_number(5=全1 10=全2 15=全3 20=全4 25=全5 30=全6) */
|
||||
@@ -46,56 +54,93 @@ class PlayStartLogic
|
||||
* 执行一局游戏
|
||||
* @param int $playerId 玩家ID
|
||||
* @param int $direction 方向 0=无/顺时针 1=中奖/逆时针(前端 direction)
|
||||
* @param int $ante 注数(必须在 DiceAnteConfig.mult 中存在)
|
||||
* @return array 成功返回 DicePlayRecord 数据;余额不足时抛 ApiException,message 为约定文案
|
||||
*/
|
||||
public function run(int $playerId, int $direction): array
|
||||
public function run(int $playerId, int $direction, int $ante): array
|
||||
{
|
||||
$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.'无法继续游戏');
|
||||
if ($ante <= 0) {
|
||||
throw new ApiException('ante must be a positive integer');
|
||||
}
|
||||
|
||||
$paid = (int) ($player->paid_ticket_count ?? 0);
|
||||
$free = (int) ($player->free_ticket_count ?? 0);
|
||||
if ($paid + $free <= 0) {
|
||||
throw new ApiException('抽奖券不足');
|
||||
// 注数合规校验:ante 必须存在于 dice_ante_config.mult
|
||||
$anteConfigModel = new DiceAnteConfig();
|
||||
$exists = $anteConfigModel->where('mult', $ante)->count();
|
||||
if ($exists <= 0) {
|
||||
throw new ApiException('当前注数不合规,请选择正确的注数');
|
||||
}
|
||||
|
||||
$lotteryService = LotteryService::getOrCreate($playerId);
|
||||
$ticketType = LotteryService::drawTicketType($paid, $free);
|
||||
$configType0 = DiceLotteryPoolConfig::where('type', 0)->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('type', 1)->find();
|
||||
// 免费抽奖:优先使用 free_ticket(带 ante 与 count);兼容旧字段 free_ticket_count
|
||||
$freeTicket = $player->free_ticket ?? null;
|
||||
$freeTicketAnte = null;
|
||||
$freeTicketCount = 0;
|
||||
if (is_array($freeTicket)) {
|
||||
$a = $freeTicket['ante'] ?? null;
|
||||
$c = $freeTicket['count'] ?? null;
|
||||
if ($a !== null && $a !== '' && is_numeric($a)) {
|
||||
$freeTicketAnte = (int) $a;
|
||||
}
|
||||
if ($c !== null && $c !== '' && is_numeric($c)) {
|
||||
$freeTicketCount = (int) $c;
|
||||
}
|
||||
}
|
||||
$legacyFreeCount = (int) ($player->free_ticket_count ?? 0);
|
||||
$isFree = ($freeTicketAnte !== null && $freeTicketCount > 0) || $legacyFreeCount > 0;
|
||||
$ticketType = $isFree ? self::LOTTERY_TYPE_FREE : self::LOTTERY_TYPE_PAID;
|
||||
|
||||
// 若为 free_ticket 免费抽奖:注数必须与券的 ante 一致
|
||||
if ($ticketType === self::LOTTERY_TYPE_FREE && $freeTicketAnte !== null && $freeTicketCount > 0) {
|
||||
if ($ante !== $freeTicketAnte) {
|
||||
throw new ApiException('您有一张底注为' . $freeTicketAnte . '的免费抽奖券');
|
||||
}
|
||||
}
|
||||
|
||||
// 若为免费抽奖(旧逻辑):注数必须与上一次触发免费抽奖时的注数一致
|
||||
if ($isFree) {
|
||||
$requiredAnte = Cache::get(self::FREE_ANTE_KEY_PREFIX . $playerId);
|
||||
if ($requiredAnte !== null && $requiredAnte !== '' && (int) $requiredAnte !== $ante) {
|
||||
throw new ApiException('免费抽奖注数必须与上一次一致,请修改注数后继续');
|
||||
}
|
||||
}
|
||||
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('奖池配置不存在(需 type=0)');
|
||||
throw new ApiException('Lottery pool config not found (name=default required)');
|
||||
}
|
||||
// 杀分时使用 type=1 配置的权重;未杀分时付费用 type=0、免费用 type=1(无 type=1 时回退 type=0)
|
||||
$configForWeights = $ticketType === self::LOTTERY_TYPE_PAID
|
||||
? $configType0
|
||||
: ($configType1 ?? $configType0);
|
||||
|
||||
// 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数)
|
||||
$playerQuery = DicePlayRecord::where('player_id', $playerId)
|
||||
->where('lottery_config_id', $configType0->id)
|
||||
->where('status', self::RECORD_STATUS_SUCCESS);
|
||||
$playerWinSum = (float) $playerQuery->sum('win_coin');
|
||||
$playerPlayCount = (int) $playerQuery->count();
|
||||
$playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount;
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
// 玩家累计盈利>=安全线时杀分:用 type=1 的 T*_weight,并记录 lottery_config_id=type=1 的 id;否则用玩家权重,记录对应配置 id
|
||||
$usePoolWeights = $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
if ($usePoolWeights) {
|
||||
$config = $configType1;
|
||||
} else {
|
||||
$config = $configForWeights;
|
||||
// 余额校验:统一校验 ante * min(real_ev)
|
||||
$minEv = DiceRewardConfig::getCachedMinRealEv();
|
||||
$needMinBalance = abs((float) $minEv) * $ante;
|
||||
if ($coin < $needMinBalance) {
|
||||
throw new ApiException('未达抽奖余额 ' . $needMinBalance . ',无法开始游戏');
|
||||
}
|
||||
|
||||
// 付费抽奖:开始前扣除费用 ante * UNIT_COST,不足则提示余额不足
|
||||
$paidAmount = $ticketType === self::LOTTERY_TYPE_PAID ? round($ante * self::UNIT_COST, 2) : 0.0;
|
||||
if ($ticketType === self::LOTTERY_TYPE_PAID && $coin < $paidAmount) {
|
||||
throw new ApiException('余额不足');
|
||||
}
|
||||
|
||||
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||
// 该值来自 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'] ?? [];
|
||||
@@ -111,6 +156,13 @@ class PlayStartLogic
|
||||
Log::warning("档位 {$tier} 方向 {$direction} 无任何 DiceReward,重新摇取档位");
|
||||
continue;
|
||||
}
|
||||
if ($usePoolWeights) {
|
||||
$tierRewards = self::filterOutSuperWinOnlyGrids($tierRewards);
|
||||
if (empty($tierRewards)) {
|
||||
Log::warning("档位 {$tier} 方向 {$direction} 杀分档位下排除 5/30 后无可用奖励,重新摇取档位");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$chosen = self::drawRewardByWeight($tierRewards);
|
||||
} catch (\RuntimeException $e) {
|
||||
@@ -124,47 +176,61 @@ class PlayStartLogic
|
||||
}
|
||||
if ($chosen === null) {
|
||||
Log::error("多次摇取档位后仍无有效 DiceReward");
|
||||
throw new ApiException('暂无可用奖励配置');
|
||||
throw new ApiException('No available reward config');
|
||||
}
|
||||
|
||||
$startIndex = (int) ($chosen['start_index'] ?? 0);
|
||||
$targetIndex = (int) ($chosen['end_index'] ?? 0);
|
||||
$rollNumber = (int) ($chosen['grid_number'] ?? 0);
|
||||
$realEv = (float) ($chosen['real_ev'] ?? 0);
|
||||
// T5/再来一次:以奖励行 tier 为准,并以摇奖档位 $tier 兜底(与 reward_tier 展示一致,避免 dice_reward 行缺 tier 时不发券)
|
||||
$isTierT5 = (string) ($chosen['tier'] ?? '') === 'T5';
|
||||
$rewardWinCoin = $isTierT5 ? $realEv : (100 + $realEv);
|
||||
if ($isTierT5 === false && (string) ($tier ?? '') === 'T5') {
|
||||
$isTierT5 = true;
|
||||
}
|
||||
// 摇色子中奖:按 dice_reward_config.real_ev 直接结算(已乘 ante)
|
||||
$rewardWinCoin = round($realEv * $ante, 2);
|
||||
|
||||
// 豹子判定:5/30 必豹子;10/15/20/25 按 DiceRewardConfig 中 BIGWIN 该点数的 weight 判定(0-10000,10000=100%)
|
||||
$superWinCoin = 0;
|
||||
// 杀分档位:不触发豹子,5/30 已在上方抽取时排除,10/15/20/25 仅生成非豹子组合
|
||||
$superWinCoin = 0.0;
|
||||
$isWin = 0;
|
||||
$bigWinRealEv = 0.0;
|
||||
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
|
||||
$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 {
|
||||
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;
|
||||
$bigWinEv = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
|
||||
$superWinCoin = round($bigWinEv * $ante, 2);
|
||||
// 中 BIGWIN 豹子:不走原奖励流程,不记录原奖励,不触发 T5 再来一次,仅发放豹子奖金
|
||||
$rewardWinCoin = 0.0;
|
||||
$realEv = 0.0;
|
||||
$isTierT5 = false;
|
||||
} else {
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rollArray = $this->generateRollArrayFromSum($rollNumber);
|
||||
@@ -177,7 +243,7 @@ class PlayStartLogic
|
||||
$startIndex,
|
||||
$targetIndex
|
||||
));
|
||||
$winCoin = $superWinCoin + $rewardWinCoin; // 赢取平台币 = 中大奖 + 摇色子中奖(豹子时 rewardWinCoin 已为 0)
|
||||
$winCoin = round($superWinCoin + $rewardWinCoin, 2); // 赢取平台币 = 中大奖 + 摇色子中奖(豹子时 rewardWinCoin 已为 0)
|
||||
|
||||
$record = null;
|
||||
$configId = (int) $config->id;
|
||||
@@ -191,9 +257,10 @@ class PlayStartLogic
|
||||
$adminId,
|
||||
$configId,
|
||||
$type0ConfigId,
|
||||
$rewardId,
|
||||
$configName,
|
||||
$ticketType,
|
||||
$ante,
|
||||
$paidAmount,
|
||||
$winCoin,
|
||||
$superWinCoin,
|
||||
$rewardWinCoin,
|
||||
@@ -205,25 +272,27 @@ class PlayStartLogic
|
||||
$targetIndex,
|
||||
$rollArray,
|
||||
$isTierT5,
|
||||
$tier,
|
||||
&$record
|
||||
) {
|
||||
$rewardTier = ($isWin === 1 && $superWinCoin > 0) ? 'BIGWIN' : (string) ($tier ?? '');
|
||||
$record = DicePlayRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'lottery_config_id' => $configId,
|
||||
'lottery_type' => $ticketType,
|
||||
'ante' => $ante,
|
||||
'paid_amount' => $paidAmount,
|
||||
'is_win' => $isWin,
|
||||
'win_coin' => $winCoin,
|
||||
'super_win_coin' => $superWinCoin,
|
||||
'reward_win_coin' => $rewardWinCoin,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => $rewardId,
|
||||
'reward_tier' => $rewardTier,
|
||||
'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,
|
||||
]);
|
||||
|
||||
@@ -232,36 +301,112 @@ class PlayStartLogic
|
||||
throw new \RuntimeException('玩家不存在');
|
||||
}
|
||||
$coinBefore = (float) $p->coin;
|
||||
$coinAfter = $coinBefore + $winCoin;
|
||||
// 开始前先扣付费金额,再加中奖金额(免费抽奖 paid_amount=0)
|
||||
$coinAfter = round($coinBefore - $paidAmount + $winCoin, 2);
|
||||
$p->coin = $coinAfter;
|
||||
$p->total_ticket_count = max(0, (int) $p->total_ticket_count - 1);
|
||||
if ($ticketType === self::LOTTERY_TYPE_PAID) {
|
||||
$p->paid_ticket_count = max(0, (int) $p->paid_ticket_count - 1);
|
||||
} else {
|
||||
$p->free_ticket_count = max(0, (int) $p->free_ticket_count - 1);
|
||||
// 免费抽奖消耗:优先消耗 free_ticket.count,耗尽则清空 free_ticket;否则兼容旧 free_ticket_count
|
||||
if ($ticketType === self::LOTTERY_TYPE_FREE) {
|
||||
$ft = $p->free_ticket ?? null;
|
||||
$ftAnte = null;
|
||||
$ftCount = 0;
|
||||
if (is_array($ft)) {
|
||||
$a = $ft['ante'] ?? null;
|
||||
$c = $ft['count'] ?? null;
|
||||
if ($a !== null && $a !== '' && is_numeric($a)) {
|
||||
$ftAnte = (int) $a;
|
||||
}
|
||||
if ($c !== null && $c !== '' && is_numeric($c)) {
|
||||
$ftCount = (int) $c;
|
||||
}
|
||||
}
|
||||
if ($ftAnte !== null && $ftCount > 0) {
|
||||
$next = $ftCount - 1;
|
||||
if ($next <= 0) {
|
||||
$p->free_ticket = null;
|
||||
} else {
|
||||
$p->free_ticket = ['ante' => $ftAnte, 'count' => $next];
|
||||
}
|
||||
} else {
|
||||
$p->free_ticket_count = max(0, (int) $p->free_ticket_count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 若本局中奖档位为 T5,则额外赠送 1 次免费抽奖次数(总次数也 +1),并记录抽奖券获取记录
|
||||
// 记录每次游玩:写入抽奖券记录(用于后台“抽奖券记录”追踪付费/免费游玩与消耗)
|
||||
$isPaidPlay = $ticketType === self::LOTTERY_TYPE_PAID;
|
||||
$paidCnt = $isPaidPlay ? 1 : 0;
|
||||
$freeCnt = $isPaidPlay ? 0 : 1;
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'use_coins' => $paidAmount,
|
||||
'ante' => $ante,
|
||||
'total_ticket_count' => $paidCnt + $freeCnt,
|
||||
'paid_ticket_count' => $paidCnt,
|
||||
'free_ticket_count' => $freeCnt,
|
||||
'remark' => ($isPaidPlay ? '付费游玩' : '免费游玩') . '|play_record_id=' . $record->id,
|
||||
]);
|
||||
|
||||
// 若本局中奖档位为 T5,则额外赠送 1 次免费抽奖次数:
|
||||
// - 新结构:写入 free_ticket(ante=本局注数,count+1)
|
||||
// - 兼容旧结构:free_ticket_count +1
|
||||
if ($isTierT5) {
|
||||
$p->free_ticket_count = (int) $p->free_ticket_count + 1;
|
||||
$p->total_ticket_count = (int) $p->total_ticket_count + 1;
|
||||
$ft = $p->free_ticket ?? null;
|
||||
$ftAnte = null;
|
||||
$ftCount = 0;
|
||||
if (is_array($ft)) {
|
||||
$a = $ft['ante'] ?? null;
|
||||
$c = $ft['count'] ?? null;
|
||||
if ($a !== null && $a !== '' && is_numeric($a)) {
|
||||
$ftAnte = (int) $a;
|
||||
}
|
||||
if ($c !== null && $c !== '' && is_numeric($c)) {
|
||||
$ftCount = (int) $c;
|
||||
}
|
||||
}
|
||||
if ($ftAnte === null) {
|
||||
$ftAnte = $ante;
|
||||
}
|
||||
if ($ftAnte === $ante) {
|
||||
$p->free_ticket = ['ante' => $ante, 'count' => $ftCount + 1];
|
||||
} else {
|
||||
// 若已有不同注数的免费券,则仍保留旧字段累加,避免覆盖玩家已有券
|
||||
$p->free_ticket_count = (int) $p->free_ticket_count + 1;
|
||||
}
|
||||
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'ante' => $ante,
|
||||
'free_ticket_count' => 1,
|
||||
'remark' => '中奖结果为T5',
|
||||
]);
|
||||
// 记录免费抽奖注数,用于强制下一局注数一致
|
||||
Cache::set(self::FREE_ANTE_KEY_PREFIX . $playerId, $ante, self::FREE_ANTE_TTL);
|
||||
} else {
|
||||
// 若本次消耗了最后一次免费抽奖,则清理注数锁
|
||||
$ft = $p->free_ticket ?? null;
|
||||
$ftCount = 0;
|
||||
if (is_array($ft)) {
|
||||
$c = $ft['count'] ?? null;
|
||||
if ($c !== null && $c !== '' && is_numeric($c)) {
|
||||
$ftCount = (int) $c;
|
||||
}
|
||||
}
|
||||
if ($ticketType === self::LOTTERY_TYPE_FREE && $ftCount <= 0 && (int) $p->free_ticket_count <= 0) {
|
||||
Cache::delete(self::FREE_ANTE_KEY_PREFIX . $playerId);
|
||||
}
|
||||
}
|
||||
|
||||
$p->save();
|
||||
|
||||
// 玩家累计盈利累加在 type=0 彩金池上:每局按“当前中奖金额(含 BIGWIN) - 抽奖券费用 100”
|
||||
$perPlayProfit = $winCoin - 100.0;
|
||||
$addProfit = $perPlayProfit;
|
||||
// 彩金池累计盈利累加在 name=default 彩金池上:
|
||||
// 付费:每局按「本局赢取平台币 win_coin - 抽奖费用 paid_amount(ante*UNIT_COST)」
|
||||
// 免费券:paid_amount=0,只计入 win_coin
|
||||
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - $paidAmount) : $winCoin;
|
||||
$addProfit = round($perPlayProfit, 2);
|
||||
try {
|
||||
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([
|
||||
'profit_amount' => Db::raw('IFNULL(profit_amount,0) + ' . (float) $addProfit),
|
||||
'profit_amount' => Db::raw('IFNULL(profit_amount,0) + ' . sprintf('%.2f', $addProfit)),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('彩金池盈利累加失败', [
|
||||
@@ -271,14 +416,30 @@ class PlayStartLogic
|
||||
]);
|
||||
}
|
||||
|
||||
// 钱包流水拆分:先记录购券扣费,再记录抽奖结果(中奖/惩罚)
|
||||
if ($paidAmount > 0) {
|
||||
$walletAfterBuy = round($coinBefore - $paidAmount, 2);
|
||||
DicePlayerWalletRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => round(-$paidAmount, 2),
|
||||
'type' => self::WALLET_TYPE_BUY_DRAW,
|
||||
'wallet_before' => $coinBefore,
|
||||
'wallet_after' => $walletAfterBuy,
|
||||
'remark' => '抽奖购券扣费|play_record_id=' . $record->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$walletBeforeDraw = $coinBefore - $paidAmount;
|
||||
$drawRemark = ($winCoin >= 0 ? '抽奖中奖' : '抽奖惩罚') . '|play_record_id=' . $record->id;
|
||||
DicePlayerWalletRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'admin_id' => $adminId,
|
||||
'coin' => $winCoin,
|
||||
'type' => self::WALLET_TYPE_DRAW,
|
||||
'wallet_before' => $coinBefore,
|
||||
'wallet_before' => round($walletBeforeDraw, 2),
|
||||
'wallet_after' => $coinAfter,
|
||||
'remark' => '抽奖|play_record_id=' . $record->id,
|
||||
'remark' => $drawRemark,
|
||||
]);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
@@ -293,9 +454,8 @@ class PlayStartLogic
|
||||
'win_coin' => 0,
|
||||
'super_win_coin' => 0,
|
||||
'reward_win_coin' => 0,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => 0,
|
||||
'reward_tier' => '',
|
||||
'start_index' => $startIndex,
|
||||
'target_index' => 0,
|
||||
'roll_array' => '[]',
|
||||
@@ -322,16 +482,32 @@ 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['reward_tier'] = ($isWin === 1 && $superWinCoin > 0) ? 'BIGWIN' : (string) ($tier ?? '');
|
||||
// 记录完数据后返回当前玩家余额与抽奖次数
|
||||
$arr['coin'] = $updated ? (float) $updated->coin : 0;
|
||||
$arr['total_ticket_count'] = $updated ? (int) $updated->total_ticket_count : 0;
|
||||
$arr['coin'] = $updated ? round((float) $updated->coin, 2) : 0.0;
|
||||
// 本局从玩家货币中扣除的金额:付费抽奖为 ante*UNIT_COST,免费抽奖为 0(与 paid_amount 一致)
|
||||
$arr['use_coin'] = round($paidAmount, 2);
|
||||
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),避免整数随机导致小权重失真
|
||||
@@ -442,10 +618,11 @@ class PlayStartLogic
|
||||
* @param \app\dice\model\lottery_pool_config\DiceLotteryPoolConfig|null $config 奖池配置,自定义档位时可为 null
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
* @param int $lotteryType 0=付费 1=免费
|
||||
* @param int $ante 底注/注数(dice_ante_config.mult)
|
||||
* @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
|
||||
public function simulateOnePlay($config, int $direction, int $lotteryType = 0, int $ante = 1, ?array $customTierWeights = null): array
|
||||
{
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
$byTierDirection = $rewardInstance['by_tier_direction'] ?? [];
|
||||
@@ -465,6 +642,14 @@ class PlayStartLogic
|
||||
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) {
|
||||
@@ -483,44 +668,57 @@ class PlayStartLogic
|
||||
$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);
|
||||
// 摇色子中奖:按 real_ev 直接结算(与正式抽奖 run() 一致)
|
||||
$rewardWinCoin = round($realEv * $ante, 2);
|
||||
|
||||
$superWinCoin = 0;
|
||||
$superWinCoin = 0.0;
|
||||
$isWin = 0;
|
||||
$bigWinRealEv = 0.0;
|
||||
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
|
||||
$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 {
|
||||
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;
|
||||
$bigWinEv = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
|
||||
$superWinCoin = round($bigWinEv * $ante, 2);
|
||||
$rewardWinCoin = 0.0;
|
||||
// 中豹子时不走原奖励流程
|
||||
$realEv = 0.0;
|
||||
} else {
|
||||
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rollArray = $this->generateRollArrayFromSum($rollNumber);
|
||||
}
|
||||
|
||||
$winCoin = $superWinCoin + $rewardWinCoin;
|
||||
$winCoin = round($superWinCoin + $rewardWinCoin, 2);
|
||||
$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);
|
||||
$paidAmount = $lotteryType === 0 ? round($ante * self::UNIT_COST, 2) : 0.0;
|
||||
$rewardTier = ($isWin === 1 && $superWinCoin > 0) ? 'BIGWIN' : (string) ($tier ?? '');
|
||||
// 与写入记录的 reward_tier 完全一致:仅当展示档位为 T5(非豹子大奖)时触发「再来一次」链式免费局
|
||||
$grantsFreeTicket = ($rewardTier === 'T5');
|
||||
|
||||
return [
|
||||
'player_id' => 0,
|
||||
@@ -529,22 +727,23 @@ class PlayStartLogic
|
||||
'lottery_type' => $lotteryType,
|
||||
'is_win' => $isWin,
|
||||
'win_coin' => $winCoin,
|
||||
'ante' => $ante,
|
||||
'paid_amount' => $paidAmount,
|
||||
'super_win_coin' => $superWinCoin,
|
||||
'reward_win_coin' => $rewardWinCoin,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => $rewardId,
|
||||
'reward_tier' => $rewardTier,
|
||||
'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,
|
||||
'grants_free_ticket' => $grantsFreeTicket,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,28 +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, ?int $adminId = null): 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('账号已被禁用,无法登录');
|
||||
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;
|
||||
|
||||
@@ -25,31 +25,31 @@ class AuthTokenMiddleware implements MiddlewareInterface
|
||||
$token = $request->header('auth-token');
|
||||
$token = $token !== null ? trim((string) $token) : '';
|
||||
if ($token === '') {
|
||||
throw new ApiException('请携带 auth-token', ReturnCode::UNAUTHORIZED);
|
||||
throw new ApiException('Please provide auth-token', ReturnCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
try {
|
||||
$decoded = JwtToken::verify(1, $token);
|
||||
} catch (JwtTokenExpiredException $e) {
|
||||
throw new ApiException('auth-token 已过期', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('auth-token expired', ReturnCode::TOKEN_INVALID);
|
||||
} catch (JwtTokenException $e) {
|
||||
throw new ApiException('auth-token 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
} catch (\Throwable $e) {
|
||||
throw new ApiException('auth-token 格式无效', ReturnCode::TOKEN_INVALID);
|
||||
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 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
$agentId = trim((string) ($extend['agent_id'] ?? ''));
|
||||
if ($agentId === '') {
|
||||
throw new ApiException('auth-token 无效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$currentToken = AuthTokenCache::getTokenByAgentId($agentId);
|
||||
if ($currentToken === null || $currentToken !== $token) {
|
||||
throw new ApiException('auth-token 无效或已失效', ReturnCode::TOKEN_INVALID);
|
||||
throw new ApiException('auth-token invalid or expired', ReturnCode::TOKEN_INVALID);
|
||||
}
|
||||
|
||||
$request->agent_id = $agentId;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ class LotteryService
|
||||
if (!$player) {
|
||||
throw new \RuntimeException('玩家不存在');
|
||||
}
|
||||
$config0 = DiceLotteryPoolConfig::where('type', 0)->find();
|
||||
$config1 = DiceLotteryPoolConfig::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;
|
||||
|
||||
@@ -6,7 +6,9 @@ namespace app\api\util;
|
||||
use support\Request;
|
||||
|
||||
/**
|
||||
* API 多语言:根据请求头 lang(en=英文,zh=中文)翻译返回文案
|
||||
* API 多语言(兼容 Webman 多语言配置)
|
||||
* 根据请求头 lang(zh=中文,en=英文)返回对应文案;
|
||||
* 无 lang 请求头时使用 config('translation.locale') 推断(zh_CN/zh→中文,en→英文)
|
||||
*/
|
||||
class ApiLang
|
||||
{
|
||||
@@ -14,47 +16,96 @@ class ApiLang
|
||||
private const LANG_EN = 'en';
|
||||
private const LANG_ZH = 'zh';
|
||||
|
||||
/** @var array<string, string>|null */
|
||||
private static ?array $enMap = null;
|
||||
/** @var array<string, array<string, string>> lang => [ key => message ] */
|
||||
private static array $messages = [];
|
||||
|
||||
/**
|
||||
* 从请求中获取语言:lang 请求头 en=英文,zh=中文,默认 zh
|
||||
* 从请求中获取语言:优先读 header lang,否则按 Webman config('translation.locale') 推断
|
||||
*/
|
||||
public static function getLang(?Request $request = null): string
|
||||
{
|
||||
$request = $request ?? (function_exists('request') ? request() : null);
|
||||
if ($request === null) {
|
||||
return self::LANG_ZH;
|
||||
}
|
||||
$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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译文案:当前请求语言为 en 时返回英文,否则返回原文(中文)
|
||||
* @param string $message 中文或原文
|
||||
* @param Request|null $request 当前请求,不传则自动取 request()
|
||||
* 翻译文案(对外接口 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);
|
||||
if ($lang !== self::LANG_EN) {
|
||||
return $message;
|
||||
$map = self::loadMessages($lang);
|
||||
if (isset($map[$message])) {
|
||||
return (string) $map[$message];
|
||||
}
|
||||
if (self::$enMap === null) {
|
||||
$path = dirname(__DIR__) . '/lang/en.php';
|
||||
self::$enMap = is_file($path) ? (require $path) : [];
|
||||
|
||||
// 若传入的是中文/原文,则按固定规则生成英文 key(MSG_XXXXXXXX)再翻译
|
||||
$key = self::toMsgKey($message);
|
||||
if ($key !== null && isset($map[$key])) {
|
||||
return (string) $map[$key];
|
||||
}
|
||||
return self::$enMap[$message] ?? $message;
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\ante_config;
|
||||
|
||||
use app\dice\logic\ante_config\DiceAnteConfigLogic;
|
||||
use app\dice\validate\ante_config\DiceAnteConfigValidate;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 底注配置控制器
|
||||
*/
|
||||
class DiceAnteConfigController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceAnteConfigLogic();
|
||||
$this->validate = new DiceAnteConfigValidate();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[Permission('底注配置列表', 'dice:ante_config:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['name', ''],
|
||||
['title', ''],
|
||||
['is_default', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('底注配置读取', 'dice:ante_config:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('底注配置添加', 'dice:ante_config:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
return $result ? $this->success('add success') : $this->fail('add failed');
|
||||
}
|
||||
|
||||
#[Permission('底注配置修改', 'dice:ante_config:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
return $result ? $this->success('update success') : $this->fail('update failed');
|
||||
}
|
||||
|
||||
#[Permission('底注配置删除', 'dice:ante_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);
|
||||
return $result ? $this->success('delete success') : $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,22 +30,20 @@ class DiceLotteryPoolConfigController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,用于 lottery_config_id 下拉(值为 id,显示为 name),并附带 type、T1-T5 档位权重
|
||||
* type:0=付费抽奖券,1=免费抽奖券;一键测试权重中付费默认选 type=0,免费默认选 type=1
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,用于 lottery_config_id 下拉(值为 id,显示为 name),并附带 T1-T5 档位权重
|
||||
* @param Request $request
|
||||
* @return Response 返回 [ ['id' => int, 'name' => string, 'type' => int, 't1_weight' => int, ... 't5_weight' => int], ... ]
|
||||
* @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,type,t1_weight,t2_weight,t3_weight,t4_weight,t5_weight')
|
||||
$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'] ?? ''),
|
||||
'type' => (int) ($item['type'] ?? 0),
|
||||
't1_weight' => (int) ($item['t1_weight'] ?? 0),
|
||||
't2_weight' => (int) ($item['t2_weight'] ?? 0),
|
||||
't3_weight' => (int) ($item['t3_weight'] ?? 0),
|
||||
@@ -87,7 +85,7 @@ class DiceLotteryPoolConfigController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +101,9 @@ class DiceLotteryPoolConfigController 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 +119,9 @@ class DiceLotteryPoolConfigController 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 +135,13 @@ class DiceLotteryPoolConfigController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +149,7 @@ class DiceLotteryPoolConfigController extends BaseController
|
||||
* 获取当前彩金池(Redis 实例化,无则按 type=0 创建)
|
||||
* 返回含玩家累计盈利 profit_amount 实时值,供前端轮询展示
|
||||
*/
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:index')]
|
||||
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:getCurrentPool')]
|
||||
public function getCurrentPool(Request $request): Response
|
||||
{
|
||||
$data = $this->logic->getCurrentPool();
|
||||
@@ -161,21 +159,21 @@ class DiceLotteryPoolConfigController extends BaseController
|
||||
/**
|
||||
* 更新当前彩金池:仅可修改 safety_line、t1_weight~t5_weight,不可修改 profit_amount
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:update')]
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:updateCurrentPool')]
|
||||
public function updateCurrentPool(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->logic->updateCurrentPool($data);
|
||||
return $this->success('保存成功');
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置当前彩金池的玩家累计盈利:将 profit_amount 置为 0
|
||||
*/
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:update')]
|
||||
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:resetProfitAmount')]
|
||||
public function resetProfitAmount(Request $request): Response
|
||||
{
|
||||
$this->logic->resetProfitAmount();
|
||||
return $this->success('重置成功');
|
||||
return $this->success('reset success');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ 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_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@@ -57,10 +56,18 @@ class DicePlayRecordController extends BaseController
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
'diceRewardConfig',
|
||||
'diceLotteryPoolConfig',
|
||||
]);
|
||||
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费金额(paid_amount 求和) - 玩家总收益(win_coin 求和)
|
||||
$sumQuery = clone $query;
|
||||
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||
$paidAmountQuery = clone $query;
|
||||
$paidAmount = (float) $paidAmountQuery->where('lottery_type', 0)->sum('paid_amount');
|
||||
$totalWinCoin = round($paidAmount - $playerTotalWin, 2);
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
@@ -92,23 +99,6 @@ class DicePlayRecordController extends BaseController
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取奖励配置选项(id、ui_text、tier)
|
||||
*/
|
||||
#[Permission('玩家抽奖记录列表', 'dice:play_record:index:index')]
|
||||
public function getRewardConfigOptions(Request $request): Response
|
||||
{
|
||||
$list = DiceRewardConfig::field('id,ui_text,tier')->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'ui_text' => $item['ui_text'] ?? '',
|
||||
'tier' => $item['tier'] ?? ''
|
||||
];
|
||||
})->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
@@ -120,11 +110,11 @@ class DicePlayRecordController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('未查找到信息');
|
||||
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('无权限查看该记录');
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
@@ -142,9 +132,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,9 +150,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,13 +166,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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class DicePlayRecordTestController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表,并在结果中附带当前筛选条件下测试数据的平台总盈利 total_win_coin(付费抽奖次数×100 - 玩家总收益)
|
||||
* 数据列表,并在结果中附带当前筛选条件下测试数据的平台总盈利 total_win_coin(付费金额 paid_amount 求和 - 玩家总收益)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
@@ -38,23 +38,26 @@ class DicePlayRecordTestController extends BaseController
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['reward_config_record_id', ''],
|
||||
['lottery_type', ''],
|
||||
['direction', ''],
|
||||
['is_win', ''],
|
||||
['win_coin_min', ''],
|
||||
['win_coin_max', ''],
|
||||
['paid_amount', ''],
|
||||
['ante', ''],
|
||||
['reward_tier', ''],
|
||||
['roll_number', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$query->with(['diceLotteryPoolConfig', 'diceRewardConfig']);
|
||||
$query->with(['diceLotteryPoolConfig']);
|
||||
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费抽奖(lottery_type=0)次数×100 - 玩家总收益(win_coin 求和)
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费金额(paid_amount 求和) - 玩家总收益(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;
|
||||
$paidAmountQuery = clone $query;
|
||||
$paidAmount = (float) $paidAmountQuery->where('lottery_type', 0)->sum('paid_amount');
|
||||
$totalWinCoin = round($paidAmount - $playerTotalWin, 2);
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
@@ -75,7 +78,7 @@ class DicePlayRecordTestController extends BaseController
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +94,9 @@ class DicePlayRecordTestController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,9 +112,9 @@ class DicePlayRecordTestController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +128,13 @@ class DicePlayRecordTestController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,15 +143,15 @@ class DicePlayRecordTestController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:destroy')]
|
||||
#[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('已清空所有测试数据');
|
||||
return $this->success('all test data cleared');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail('清空失败:' . $e->getMessage());
|
||||
return $this->fail('clear failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +110,11 @@ class DicePlayerController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('未查找到信息');
|
||||
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('无权限查看该记录');
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
@@ -142,9 +142,9 @@ class DicePlayerController extends BaseController
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('添加成功');
|
||||
return $this->success('add success');
|
||||
}
|
||||
return $this->fail('添加失败');
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ class DicePlayerController extends BaseController
|
||||
if ($model) {
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
return $this->fail('无权限修改该记录');
|
||||
return $this->fail('no permission to update this record');
|
||||
}
|
||||
}
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
@@ -172,9 +172,9 @@ class DicePlayerController extends BaseController
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
}
|
||||
return $this->fail('修改失败');
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,16 +188,16 @@ class DicePlayerController extends BaseController
|
||||
$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('无权限修改该记录');
|
||||
return $this->fail('no permission to update this record');
|
||||
}
|
||||
}
|
||||
$this->logic->edit($id, ['status' => (int) $status]);
|
||||
@@ -207,7 +207,7 @@ class DicePlayerController extends BaseController
|
||||
if ($player && $player->username !== '') {
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
return $this->success('修改成功');
|
||||
return $this->success('update success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ class DicePlayerController extends BaseController
|
||||
{
|
||||
$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);
|
||||
@@ -235,7 +235,7 @@ class DicePlayerController extends BaseController
|
||||
}
|
||||
$ids = $validIds;
|
||||
if (empty($ids)) {
|
||||
return $this->fail('无权限删除所选数据');
|
||||
return $this->fail('no permission to delete selected data');
|
||||
}
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
@@ -248,9 +248,9 @@ class DicePlayerController extends BaseController
|
||||
UserCache::deletePlayerByUsername($player->username);
|
||||
}
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
return $this->success('delete success');
|
||||
}
|
||||
return $this->fail('删除失败');
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
['username', ''],
|
||||
['use_coins_min', ''],
|
||||
['use_coins_max', ''],
|
||||
['ante', ''],
|
||||
['total_ticket_count_min', ''],
|
||||
['total_ticket_count_max', ''],
|
||||
['paid_ticket_count_min', ''],
|
||||
@@ -88,11 +89,11 @@ class DicePlayerTicketRecordController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('未查找到信息');
|
||||
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('无权限查看该记录');
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
@@ -110,9 +111,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +129,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,13 +145,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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,15 +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,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('无权限操作该玩家');
|
||||
return $this->fail('no permission to operate this player');
|
||||
}
|
||||
return $this->success(['wallet_before' => (float) $player['coin']]);
|
||||
}
|
||||
@@ -109,11 +109,11 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('未查找到信息');
|
||||
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('无权限查看该记录');
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
@@ -124,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();
|
||||
@@ -133,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;
|
||||
@@ -163,43 +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('无权限操作该玩家');
|
||||
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
|
||||
@@ -212,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('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ class DiceRewardController extends BaseController
|
||||
{
|
||||
$direction = $request->input('direction', null);
|
||||
if ($direction === null || $direction === '') {
|
||||
return $this->fail('请传入 direction(0=顺时针 1=逆时针)');
|
||||
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 必须为 0(顺时针)或 1(逆时针)');
|
||||
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
|
||||
}
|
||||
$tier = $request->input('tier', '');
|
||||
$page = (int) $request->input('page', 1);
|
||||
@@ -81,26 +81,28 @@ class DiceRewardController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键测试权重:创建测试记录并启动单进程后台执行,按付费/免费、顺逆方向交替写入 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
|
||||
* 一键测试权重:创建测试记录并启动单进程后台执行,写入 dice_play_record_test
|
||||
* 参数:lottery_config_id 可选;paid_tier_weights / free_tier_weights 自定义档位;
|
||||
* paid_s_count, paid_n_count
|
||||
* chain_free_mode=1:仅按付费次数模拟;付费抽到再来一次/T5 则在队列中插入免费局(同底注、lottery_type=免费、paid_amount=0)
|
||||
* kill_mode_enabled=1:测试内启用杀分;当模拟玩家累计盈利达到 test_safety_line 后,付费抽奖切到 killScore
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
#[Permission('一键测试权重', 'dice:reward:index:startWeightTest')]
|
||||
public function startWeightTest(Request $request): Response
|
||||
{
|
||||
$post = is_array($request->post()) ? $request->post() : [];
|
||||
$params = [
|
||||
'ante' => $post['ante'] ?? null,
|
||||
'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,
|
||||
'chain_free_mode' => $post['chain_free_mode'] ?? null,
|
||||
'kill_mode_enabled' => $post['kill_mode_enabled'] ?? null,
|
||||
'test_safety_line' => $post['test_safety_line'] ?? null,
|
||||
];
|
||||
$adminId = isset($this->adminInfo['id']) ? (int) $this->adminInfo['id'] : null;
|
||||
try {
|
||||
@@ -120,11 +122,11 @@ class DiceRewardController extends BaseController
|
||||
{
|
||||
$recordId = (int) $request->input('record_id', 0);
|
||||
if ($recordId <= 0) {
|
||||
return $this->fail('请传入 record_id');
|
||||
return $this->fail('please provide record_id');
|
||||
}
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if (!$record) {
|
||||
return $this->fail('记录不存在');
|
||||
return $this->fail('record not found');
|
||||
}
|
||||
$arr = $record->toArray();
|
||||
$data = [
|
||||
@@ -147,9 +149,9 @@ class DiceRewardController extends BaseController
|
||||
try {
|
||||
$table = (new DicePlayRecordTest())->getTable();
|
||||
Db::execute('TRUNCATE TABLE `' . $table . '`');
|
||||
return $this->success('已清空测试数据');
|
||||
return $this->success('test data cleared');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail('清空失败:' . $e->getMessage());
|
||||
return $this->fail('clear failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,17 +159,17 @@ class DiceRewardController extends BaseController
|
||||
* 权重编辑弹窗:按方向+点数批量更新权重(写入 dice_reward)
|
||||
* 参数:items: [{ grid_number, weight_clockwise, weight_counterclockwise }, ...]
|
||||
*/
|
||||
#[Permission('奖励对照修改', 'dice:reward:index:update')]
|
||||
#[Permission('权重配比', 'dice:reward:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('参数 items 必须为数组');
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$logic = new DiceRewardLogic();
|
||||
$logic->batchUpdateWeights($items);
|
||||
return $this->success('保存成功');
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
@@ -182,16 +184,16 @@ class DiceRewardController extends BaseController
|
||||
{
|
||||
$direction = (int) $request->post('direction', 0);
|
||||
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
|
||||
return $this->fail('direction 必须为 0(顺时针)或 1(逆时针)');
|
||||
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
|
||||
}
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('参数 items 必须为数组');
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$logic = new DiceRewardLogic();
|
||||
$logic->batchUpdateWeightsByDirection($direction, $items);
|
||||
return $this->success('保存成功');
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -64,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +109,12 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request items: [{ id, grid_number?, ui_text?, real_ev?, tier?, remark? }, ...]
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('修改奖励索引', 'dice:reward_config:index:batchUpdate')]
|
||||
public function batchUpdate(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (! is_array($items)) {
|
||||
return $this->fail('参数 items 必须为数组');
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
$err = $this->logic->validateBatchUpdateItems($items);
|
||||
if ($err !== null) {
|
||||
@@ -124,7 +124,7 @@ class DiceRewardConfigController extends BaseController
|
||||
$this->validate('batch_update', array_merge($item, ['id' => $item['id']]));
|
||||
}
|
||||
$this->logic->batchUpdate($items);
|
||||
return $this->success('保存成功');
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,13 +137,13 @@ 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,17 +166,17 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('修改色子点数权重', 'dice:reward_config:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (!is_array($items)) {
|
||||
return $this->fail('参数 items 必须为数组');
|
||||
return $this->fail('parameter items must be an array');
|
||||
}
|
||||
try {
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
$rewardLogic->batchUpdateWeights($items);
|
||||
return $this->success('保存成功');
|
||||
return $this->success('save success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
@@ -188,19 +188,19 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('大奖权重修改', 'dice:reward_config:index:saveBigwinWeightsByGrid')]
|
||||
public function saveBigwinWeightsByGrid(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
if (! is_array($items)) {
|
||||
return $this->fail('参数 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('保存成功');
|
||||
return $this->success('save success');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,13 +209,13 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('创建奖励对照', 'dice:reward_config:index:createRewardReference')]
|
||||
public function createRewardReference(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$rewardLogic = new DiceRewardLogic();
|
||||
$result = $rewardLogic->createRewardReferenceFromConfig();
|
||||
return $this->success($result, '创建奖励对照成功');
|
||||
return $this->success($result, 'create reward mapping success');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ class DiceRewardConfigRecordController extends BaseController
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['paid_planned_spins', ''],
|
||||
['ante', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
@@ -59,7 +61,7 @@ class DiceRewardConfigRecordController extends BaseController
|
||||
$data['admin_name'] = $this->getAdminName((int) ($data['admin_id'] ?? 0));
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
return $this->fail('not found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +98,9 @@ class DiceRewardConfigRecordController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +116,9 @@ class DiceRewardConfigRecordController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,13 +132,13 @@ class DiceRewardConfigRecordController 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +146,12 @@ class DiceRewardConfigRecordController extends BaseController
|
||||
* 导入:测试记录 → 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:index')]
|
||||
#[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('请指定测试记录');
|
||||
return $this->fail('please specify test record');
|
||||
}
|
||||
$paidId = $request->post('paid_lottery_config_id', null);
|
||||
$freeId = $request->post('free_lottery_config_id', null);
|
||||
@@ -159,7 +161,7 @@ class DiceRewardConfigRecordController extends BaseController
|
||||
$lotteryConfigId = $legacyId !== null && $legacyId !== '' ? (int) $legacyId : null;
|
||||
try {
|
||||
$this->logic->importFromRecord($recordId, $paidLotteryConfigId, $freeLotteryConfigId, $lotteryConfigId);
|
||||
return $this->success('导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置');
|
||||
return $this->success('import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config');
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
90
server/app/dice/logic/ante_config/DiceAnteConfigLogic.php
Normal file
90
server/app/dice/logic/ante_config/DiceAnteConfigLogic.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\ante_config;
|
||||
|
||||
use app\dice\model\ante_config\DiceAnteConfig;
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
|
||||
/**
|
||||
* 底注配置逻辑层
|
||||
*/
|
||||
class DiceAnteConfigLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceAnteConfig();
|
||||
}
|
||||
|
||||
public function add(array $data): mixed
|
||||
{
|
||||
return $this->transaction(function () use ($data) {
|
||||
$this->normalizeDefaultField($data);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
$this->clearOtherDefaults();
|
||||
}
|
||||
return parent::add($data);
|
||||
});
|
||||
}
|
||||
|
||||
public function edit($id, array $data): mixed
|
||||
{
|
||||
return $this->transaction(function () use ($id, $data) {
|
||||
$this->normalizeDefaultField($data);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
$this->clearOtherDefaults((int) $id);
|
||||
}
|
||||
return parent::edit($id, $data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 防止删除后全表无默认:若删除了默认项,自动把最小 id 设为默认。
|
||||
*/
|
||||
public function destroy($ids): bool
|
||||
{
|
||||
return $this->transaction(function () use ($ids) {
|
||||
$idList = is_array($ids) ? $ids : explode(',', (string) $ids);
|
||||
$intIds = [];
|
||||
foreach ($idList as $v) {
|
||||
$iv = (int) $v;
|
||||
if ($iv > 0) {
|
||||
$intIds[] = $iv;
|
||||
}
|
||||
}
|
||||
if ($intIds === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$deletedDefaultCount = $this->model->whereIn('id', $intIds)->where('is_default', 1)->count();
|
||||
$result = $this->model->destroy($intIds);
|
||||
if ($result && $deletedDefaultCount > 0) {
|
||||
$first = $this->model->order('id', 'asc')->find();
|
||||
if ($first) {
|
||||
$this->model->where('id', (int) $first['id'])->update(['is_default' => 1]);
|
||||
}
|
||||
}
|
||||
return (bool) $result;
|
||||
});
|
||||
}
|
||||
|
||||
private function normalizeDefaultField(array &$data): void
|
||||
{
|
||||
if (!array_key_exists('is_default', $data)) {
|
||||
return;
|
||||
}
|
||||
$data['is_default'] = ((int) $data['is_default']) === 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
private function clearOtherDefaults(?int $excludeId = null): void
|
||||
{
|
||||
$query = $this->model->where('is_default', 1);
|
||||
if ($excludeId !== null && $excludeId > 0) {
|
||||
$query->where('id', '<>', $excludeId);
|
||||
}
|
||||
$query->update(['is_default' => 0]);
|
||||
}
|
||||
}
|
||||
@@ -34,21 +34,22 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
|
||||
* 获取当前彩金池(type=0)+ 杀分权重为 type=1 的只读展示
|
||||
* profit_amount 每次从 DB 实时读取;t1_weight~t5_weight 来自 type=1(杀分权重,不可在弹窗内修改)
|
||||
*
|
||||
* @return array{id:int,name:string,safety_line:int,t1_weight:int,...,t5_weight:int,profit_amount:float}
|
||||
* @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('type', 0)->find();
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('未找到 type=0 的奖池配置,请先创建');
|
||||
throw new ApiException('No name=default pool config found, please create one first');
|
||||
}
|
||||
$configType1 = DiceLotteryPoolConfig::where('type', 1)->find();
|
||||
$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() : [];
|
||||
@@ -61,19 +62,28 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前彩金池:仅允许修改 type=0 的 safety_line(杀分权重来自 type=1,不可在此接口修改)
|
||||
* 更新当前彩金池:仅允许修改 type=0 的 safety_line、kill_enabled(杀分权重来自 type=1,不可在此接口修改)
|
||||
*
|
||||
* @param array{safety_line?:int} $data
|
||||
* @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)) {
|
||||
if (!array_key_exists('safety_line', $data) && !array_key_exists('kill_enabled', $data)) {
|
||||
return;
|
||||
}
|
||||
$safetyLine = (int) $data['safety_line'];
|
||||
DiceLotteryPoolConfig::where('id', $id)->update(['safety_line' => $safetyLine]);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,8 @@ class DicePlayRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,8 @@ class DicePlayRecordTestLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayRecordTest();
|
||||
// 默认按 id 倒序,保证列表默认显示最新记录
|
||||
$this->setOrderField('id')->setOrderType('DESC');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ class DicePlayerTicketRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayerTicketRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,8 @@ class DicePlayerWalletRecordLogic extends BaseLogic
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayerWalletRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,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;
|
||||
|
||||
@@ -86,13 +86,13 @@ class DiceRewardLogic
|
||||
$id = isset($item['id']) ? (int) $item['id'] : 0;
|
||||
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
|
||||
if ($id <= 0) {
|
||||
throw new ApiException('存在无效的配置ID');
|
||||
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('配置ID ' . $id . ' 不存在或档位为空');
|
||||
throw new ApiException(\app\api\util\ApiLang::translateParams('配置ID %s 不存在或档位为空', [$id]));
|
||||
}
|
||||
$tier = (string) $tier;
|
||||
|
||||
@@ -199,7 +199,7 @@ class DiceRewardLogic
|
||||
$id = isset($item['reward_id']) ? (int) $item['reward_id'] : 0;
|
||||
}
|
||||
if ($id <= 0) {
|
||||
throw new ApiException('存在无效的 DiceReward id');
|
||||
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));
|
||||
@@ -313,12 +313,15 @@ class DiceRewardLogic
|
||||
{
|
||||
$list = DiceRewardConfig::order('id', 'asc')->select()->toArray();
|
||||
if (empty($list)) {
|
||||
throw new ApiException('奖励配置为空,请先维护 dice_reward_config');
|
||||
throw new ApiException('Reward config is empty, please maintain dice_reward_config first');
|
||||
}
|
||||
$configCount = count($list);
|
||||
if ($configCount < self::BOARD_SIZE) {
|
||||
throw new ApiException(
|
||||
'奖励配置需覆盖 26 个格位(id 0-25 或 1-26),当前仅 ' . $configCount . ' 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照'
|
||||
\app\api\util\ApiLang::translateParams(
|
||||
'奖励配置需覆盖 26 个格位(id 0-25 或 1-26),当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照',
|
||||
[$configCount]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ class DiceRewardConfigLogic extends BaseLogic
|
||||
{
|
||||
$allowedCounts = [100, 500, 1000, 5000, 10000];
|
||||
if (!in_array($testCount, $allowedCounts, true)) {
|
||||
throw new ApiException('测试次数仅支持 100、500、1000、5000、10000');
|
||||
throw new ApiException('Test count only supports 100, 500, 1000, 5000, 10000');
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
@@ -333,7 +333,7 @@ class DiceRewardConfigLogic extends BaseLogic
|
||||
$config = DiceLotteryPoolConfig::find($lotteryConfigId);
|
||||
}
|
||||
if (!$config) {
|
||||
$config = DiceLotteryPoolConfig::where('type', 0)->find();
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
}
|
||||
if ($config) {
|
||||
$tierWeights = [
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace app\dice\logic\reward_config_record;
|
||||
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\ante_config\DiceAnteConfig;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
@@ -14,12 +15,15 @@ use plugin\saiadmin\app\model\system\SystemUser;
|
||||
|
||||
/**
|
||||
* 奖励配置权重测试记录逻辑层
|
||||
*
|
||||
*/
|
||||
class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceRewardConfigRecord();
|
||||
// 默认按主键倒序:最新数据优先展示
|
||||
$this->setOrderType('DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +85,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
{
|
||||
$record = $this->model->find($recordId);
|
||||
if (!$record) {
|
||||
throw new ApiException('测试记录不存在');
|
||||
throw new ApiException('Test record not found');
|
||||
}
|
||||
$record = is_array($record) ? $record : $record->toArray();
|
||||
|
||||
@@ -195,7 +199,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
if (is_array($paidData) && $paidTargetId > 0) {
|
||||
$pool = DiceLotteryPoolConfig::find($paidTargetId);
|
||||
if (!$pool) {
|
||||
throw new ApiException('付费奖池配置不存在');
|
||||
throw new ApiException('Paid pool config not found');
|
||||
}
|
||||
$update = [
|
||||
't1_weight' => (int) ($paidData['T1'] ?? $paidData['t1'] ?? 0),
|
||||
@@ -209,7 +213,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
if (is_array($freeData) && $freeTargetId > 0) {
|
||||
$pool = DiceLotteryPoolConfig::find($freeTargetId);
|
||||
if (!$pool) {
|
||||
throw new ApiException('免费奖池配置不存在');
|
||||
throw new ApiException('Free pool config not found');
|
||||
}
|
||||
$update = [
|
||||
't1_weight' => (int) ($freeData['T1'] ?? $freeData['t1'] ?? 0),
|
||||
@@ -226,10 +230,10 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一键测试权重记录并返回 ID,供后台执行器按付费/免费、顺逆方向交替写入 dice_play_record_test
|
||||
* 创建一键测试权重记录并返回 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)
|
||||
* @param array|int $params 数组:lottery_config_id(可选), paid_s_count, paid_n_count
|
||||
* @param int|null $adminId 执行人
|
||||
* @return int 记录 ID
|
||||
* @throws ApiException
|
||||
*/
|
||||
@@ -237,17 +241,24 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
{
|
||||
$adminId = null;
|
||||
if (!is_array($params)) {
|
||||
// 兼容旧版调用:createWeightTestRecord(paid_s_count, paid_n_count, free_s_count, free_n_count)
|
||||
// 兼容旧版调用:createWeightTestRecord(paid_s_count, paid_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];
|
||||
$ante = isset($params['ante']) ? intval($params['ante']) : 1;
|
||||
if ($ante <= 0) {
|
||||
throw new ApiException('ante must be greater than 0');
|
||||
}
|
||||
$anteExists = DiceAnteConfig::where('mult', $ante)->count();
|
||||
if ($anteExists <= 0) {
|
||||
throw new ApiException('ante not allowed: ' . $ante);
|
||||
}
|
||||
|
||||
$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;
|
||||
@@ -257,19 +268,23 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
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);
|
||||
$paidS = isset($params['paid_s_count']) ? (int) $params['paid_s_count'] : 0;
|
||||
$paidN = isset($params['paid_n_count']) ? (int) $params['paid_n_count'] : 0;
|
||||
$chainFreeMode = !empty($params['chain_free_mode']);
|
||||
$killModeEnabled = !empty($params['kill_mode_enabled']);
|
||||
$testSafetyLine = isset($params['test_safety_line']) ? (int) $params['test_safety_line'] : 5000;
|
||||
if ($testSafetyLine < 0) {
|
||||
throw new ApiException('test_safety_line must be greater than or equal to 0');
|
||||
}
|
||||
|
||||
foreach ([$paidS, $paidN, $freeS, $freeN] as $c) {
|
||||
foreach ([$paidS, $paidN] as $c) {
|
||||
if ($c !== 0 && !in_array($c, $allowed, true)) {
|
||||
throw new ApiException('各抽奖次数仅支持 0、100、500、1000、5000');
|
||||
throw new ApiException('Counts only support 0, 100, 500, 1000, 5000');
|
||||
}
|
||||
}
|
||||
$total = $paidS + $paidN + $freeS + $freeN;
|
||||
$total = $paidS + $paidN;
|
||||
if ($total <= 0) {
|
||||
throw new ApiException('付费或免费至少一种方向次数之和大于 0');
|
||||
throw new ApiException('Sum of paid direction counts must be greater than 0');
|
||||
}
|
||||
|
||||
$snapshot = [];
|
||||
@@ -314,7 +329,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
if ($paidConfigId > 0) {
|
||||
$config = DiceLotteryPoolConfig::find($paidConfigId);
|
||||
if (!$config) {
|
||||
throw new ApiException('付费奖池配置不存在');
|
||||
throw new ApiException('Paid pool config not found');
|
||||
}
|
||||
$tierWeightsSnapshot['paid'] = [
|
||||
'T1' => (int) ($config->t1_weight ?? 0),
|
||||
@@ -326,19 +341,19 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
} else {
|
||||
$paidTierWeights = $params['paid_tier_weights'] ?? null;
|
||||
if (!is_array($paidTierWeights)) {
|
||||
throw new ApiException('付费未选择奖池配置时,请填写付费自定义档位概率(T1~T5)');
|
||||
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('付费档位概率每档只能 0-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('付费档位概率 T1~T5 之和不能超过 100%');
|
||||
throw new ApiException('Paid tier probabilities (T1–T5) sum cannot exceed 100%');
|
||||
}
|
||||
$tierWeightsSnapshot['paid'] = $paidTierWeights;
|
||||
}
|
||||
@@ -346,7 +361,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
if ($freeConfigId > 0) {
|
||||
$config = DiceLotteryPoolConfig::find($freeConfigId);
|
||||
if (!$config) {
|
||||
throw new ApiException('免费奖池配置不存在');
|
||||
throw new ApiException('Free pool config not found');
|
||||
}
|
||||
$tierWeightsSnapshot['free'] = [
|
||||
'T1' => (int) ($config->t1_weight ?? 0),
|
||||
@@ -358,19 +373,19 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
} else {
|
||||
$freeTierWeights = $params['free_tier_weights'] ?? null;
|
||||
if (!is_array($freeTierWeights)) {
|
||||
throw new ApiException('免费未选择奖池配置时,请填写免费自定义档位概率(T1~T5)');
|
||||
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('免费档位概率每档只能 0-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('免费档位概率 T1~T5 之和不能超过 100%');
|
||||
throw new ApiException('Free tier probabilities (T1–T5) sum cannot exceed 100%');
|
||||
}
|
||||
$tierWeightsSnapshot['free'] = $freeTierWeights;
|
||||
}
|
||||
@@ -382,29 +397,36 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
||||
if (!is_array($tierWeightsSnapshot['free'])) {
|
||||
$tierWeightsSnapshot['free'] = [];
|
||||
}
|
||||
if ($chainFreeMode) {
|
||||
$tierWeightsSnapshot['chain_free_mode'] = true;
|
||||
}
|
||||
|
||||
$record = new DiceRewardConfigRecord();
|
||||
$record->test_count = $total;
|
||||
$plannedPaidSpins = $paidS + $paidN;
|
||||
$record->chain_free_mode = $chainFreeMode ? 1 : 0;
|
||||
$record->kill_mode_enabled = $killModeEnabled ? 1 : 0;
|
||||
$record->test_safety_line = $testSafetyLine;
|
||||
$record->paid_planned_spins = $plannedPaidSpins;
|
||||
// 总抽奖次数与 test_count 仅在任务成功结束时写入(见 WeightTestRunner::markSuccess)
|
||||
$record->test_count = 0;
|
||||
$record->total_play_count = 0;
|
||||
$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->play_again_count = 0;
|
||||
$record->paid_tier_weights = $paidTierWeights;
|
||||
$record->free_tier_weights = $freeTierWeights;
|
||||
$record->result_counts = [];
|
||||
$record->tier_counts = null;
|
||||
$record->bigwin_weight = $bigwinWeights ?: null;
|
||||
$record->ante = $ante;
|
||||
$record->admin_id = $adminId;
|
||||
$record->create_time = date('Y-m-d H:i:s');
|
||||
$record->save();
|
||||
|
||||
@@ -14,14 +14,34 @@ use support\think\Db;
|
||||
|
||||
/**
|
||||
* 一键测试权重:单进程后台执行模拟摇色子,写入 dice_play_record_test 并更新 dice_reward_config_record 进度
|
||||
* 支持测试内杀分:当模拟玩家累计盈利达到安全线后,付费抽奖切换到 killScore
|
||||
*/
|
||||
class WeightTestRunner
|
||||
{
|
||||
private const BATCH_SIZE = 10;
|
||||
/** 测试记录写库白名单字段 */
|
||||
private const PLAY_RECORD_TEST_COLUMNS = [
|
||||
'reward_config_record_id',
|
||||
'admin_id',
|
||||
'lottery_config_id',
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'super_win_coin',
|
||||
'reward_win_coin',
|
||||
'direction',
|
||||
'reward_tier',
|
||||
'ante',
|
||||
'paid_amount',
|
||||
'start_index',
|
||||
'target_index',
|
||||
'roll_array',
|
||||
'roll_number',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* 执行指定测试记录:按付费/免费、顺/逆方向交替模拟(付费顺→付费逆→免费顺→免费逆),每 10 条写入一次测试表并更新进度
|
||||
* 支持:1)lottery_config_id 有值时用奖池配置档位权重;2)无值时用记录中的 paid_tier_weights / free_tier_weights
|
||||
* 执行指定测试记录:按付费次数模拟,若命中 T5 则链式插入免费局(同方向同底注)
|
||||
* @param int $recordId dice_reward_config_record.id
|
||||
*/
|
||||
public function run(int $recordId): void
|
||||
@@ -32,54 +52,47 @@ class WeightTestRunner
|
||||
return;
|
||||
}
|
||||
|
||||
$ante = is_numeric($record->ante ?? null) ? intval($record->ante) : 1;
|
||||
$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;
|
||||
$total = $paidS + $paidN;
|
||||
if ($total <= 0) {
|
||||
$this->markFailed($recordId, '抽奖次数必须大于 0');
|
||||
return;
|
||||
}
|
||||
|
||||
$paidConfigId = (int) ($record->paid_lottery_config_id ?? 0);
|
||||
$freeConfigId = (int) ($record->free_lottery_config_id ?? 0);
|
||||
if ($paidConfigId <= 0) {
|
||||
$paidConfigId = (int) ($record->lottery_config_id ?? 0);
|
||||
}
|
||||
if ($freeConfigId <= 0) {
|
||||
$freeConfigId = (int) ($record->lottery_config_id ?? 0);
|
||||
}
|
||||
$paidConfig = $paidConfigId > 0 ? DiceLotteryPoolConfig::find($paidConfigId) : null;
|
||||
$freeConfig = $freeConfigId > 0 ? DiceLotteryPoolConfig::find($freeConfigId) : null;
|
||||
if ($paidConfigId > 0 && !$paidConfig) {
|
||||
$this->markFailed($recordId, '付费奖池配置不存在');
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
$this->markFailed($recordId, '彩金池配置 name=default 不存在');
|
||||
return;
|
||||
}
|
||||
if ($freeConfigId > 0 && !$freeConfig) {
|
||||
$this->markFailed($recordId, '免费奖池配置不存在');
|
||||
return;
|
||||
}
|
||||
$paidTierWeights = (is_array($record->paid_tier_weights ?? null) && $record->paid_tier_weights !== [])
|
||||
|
||||
$paidTierWeightsCustom = (is_array($record->paid_tier_weights ?? null) && $record->paid_tier_weights !== [])
|
||||
? $record->paid_tier_weights
|
||||
: null;
|
||||
$freeTierWeights = (is_array($record->free_tier_weights ?? null) && $record->free_tier_weights !== [])
|
||||
$freeTierWeightsCustom = (is_array($record->free_tier_weights ?? null) && $record->free_tier_weights !== [])
|
||||
? $record->free_tier_weights
|
||||
: null;
|
||||
if ($paidConfig === null && $paidTierWeights === null) {
|
||||
$this->markFailed($recordId, '付费未选奖池时需提供 paid_tier_weights');
|
||||
|
||||
$paidPoolConfigId = (int) ($record->paid_lottery_config_id ?? 0);
|
||||
$freePoolConfigId = (int) ($record->free_lottery_config_id ?? 0);
|
||||
|
||||
$paidPoolConfig = $paidPoolConfigId > 0 ? DiceLotteryPoolConfig::find($paidPoolConfigId) : $configType0;
|
||||
if (!$paidPoolConfig) {
|
||||
$paidPoolConfig = $configType0;
|
||||
}
|
||||
$freePoolConfig = $freePoolConfigId > 0 ? DiceLotteryPoolConfig::find($freePoolConfigId) : $configType1;
|
||||
if (!$freePoolConfig) {
|
||||
$freePoolConfig = $configType0;
|
||||
}
|
||||
|
||||
if ($paidTierWeightsCustom !== null && array_sum($paidTierWeightsCustom) <= 0) {
|
||||
$this->markFailed($recordId, 'paid_tier_weights(玩家权重)之和必须大于 0');
|
||||
return;
|
||||
}
|
||||
if ($freeConfig === null && $freeTierWeights === null) {
|
||||
$this->markFailed($recordId, '免费未选奖池时需提供 free_tier_weights');
|
||||
if ($freeTierWeightsCustom !== null && array_sum($freeTierWeightsCustom) <= 0) {
|
||||
$this->markFailed($recordId, 'free_tier_weights(免费玩家权重)之和必须大于 0');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,11 +100,14 @@ class WeightTestRunner
|
||||
DiceRewardConfig::clearRequestInstance();
|
||||
DiceReward::clearRequestInstance();
|
||||
|
||||
// 测试时按“单个虚拟玩家”累计中奖金额来判断是否触发杀分:达到 safety_line 前用自定义档位(玩家权重),达到后用奖池权重
|
||||
$paidSafetyLine = $paidConfig !== null ? (int) ($paidConfig->safety_line ?? 0) : 0;
|
||||
$freeSafetyLine = $freeConfig !== null ? (int) ($freeConfig->safety_line ?? 0) : 0;
|
||||
$paidPlayerWinTotal = 0.0;
|
||||
$freePlayerWinTotal = 0.0;
|
||||
$killModeEnabled = (int) ($record->kill_mode_enabled ?? 0) === 1;
|
||||
$testSafetyLine = (int) ($record->test_safety_line ?? 5000);
|
||||
if ($testSafetyLine < 0) {
|
||||
$testSafetyLine = 0;
|
||||
}
|
||||
|
||||
// 测试内“玩家累计盈利”:用于控制付费局是否切换杀分
|
||||
$playerProfitTotal = 0.0;
|
||||
|
||||
$playLogic = new PlayStartLogic();
|
||||
$resultCounts = [];
|
||||
@@ -100,49 +116,29 @@ class WeightTestRunner
|
||||
$done = 0;
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < $paidS; $i++) {
|
||||
$usePoolWeights = $paidConfig !== null && $paidPlayerWinTotal >= $paidSafetyLine && $paidSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $paidPlayerWinTotal);
|
||||
$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 = $paidConfig !== null && $paidPlayerWinTotal >= $paidSafetyLine && $paidSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $paidPlayerWinTotal);
|
||||
$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++) {
|
||||
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $freeTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
|
||||
$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++) {
|
||||
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $freeTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
$this->runChainFreeMode(
|
||||
$recordId,
|
||||
$playLogic,
|
||||
$paidS,
|
||||
$paidN,
|
||||
$ante,
|
||||
$paidPoolConfig,
|
||||
$freePoolConfig,
|
||||
$configType1,
|
||||
$paidTierWeightsCustom,
|
||||
$freeTierWeightsCustom,
|
||||
$killModeEnabled,
|
||||
$testSafetyLine,
|
||||
$playerProfitTotal,
|
||||
$resultCounts,
|
||||
$tierCounts,
|
||||
$buffer,
|
||||
$done
|
||||
);
|
||||
if (!empty($buffer)) {
|
||||
$this->insertBuffer($buffer);
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts);
|
||||
// 链式/非链式:运行中均不写入 total_play_count,仅在 markSuccess 落库实际总次数
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts, null);
|
||||
}
|
||||
// 平台赚取金额:通过关联 DicePlayRecordTest(reward_config_record_id)统计
|
||||
$this->markSuccess($recordId, $resultCounts, $tierCounts);
|
||||
@@ -152,13 +148,73 @@ class WeightTestRunner
|
||||
}
|
||||
}
|
||||
|
||||
/** 累加单个虚拟玩家在测试过程中的中奖金额(win_coin) */
|
||||
private function accumulatePlayerWin(array $row, float &$runningWinTotal): void
|
||||
{
|
||||
if (!isset($row['win_coin'])) {
|
||||
return;
|
||||
/**
|
||||
* 付费次数仅由配置决定;付费抽到「再来一次」则在队列末尾插入一条免费抽奖(同方向、同底注),可链式触发
|
||||
*/
|
||||
private function runChainFreeMode(
|
||||
int $recordId,
|
||||
PlayStartLogic $playLogic,
|
||||
int $paidS,
|
||||
int $paidN,
|
||||
int $ante,
|
||||
$paidPoolConfig,
|
||||
$freePoolConfig,
|
||||
$killPoolConfig,
|
||||
?array $paidTierWeightsCustom,
|
||||
?array $freeTierWeightsCustom,
|
||||
bool $killModeEnabled,
|
||||
int $testSafetyLine,
|
||||
float &$playerProfitTotal,
|
||||
array &$resultCounts,
|
||||
array &$tierCounts,
|
||||
array &$buffer,
|
||||
int &$done
|
||||
): void {
|
||||
$queue = [];
|
||||
for ($i = 0; $i < $paidS; $i++) {
|
||||
$queue[] = ['paid', 0, $ante];
|
||||
}
|
||||
for ($i = 0; $i < $paidN; $i++) {
|
||||
$queue[] = ['paid', 1, $ante];
|
||||
}
|
||||
$qi = 0;
|
||||
while ($qi < count($queue)) {
|
||||
$item = $queue[$qi];
|
||||
$isPaid = $item[0] === 'paid';
|
||||
$dir = $item[1];
|
||||
$playAnte = $item[2];
|
||||
$lotteryType = $isPaid ? 0 : 1;
|
||||
|
||||
if ($isPaid) {
|
||||
$useKillForPaid = $killModeEnabled && $playerProfitTotal >= $testSafetyLine && $killPoolConfig !== null;
|
||||
if ($useKillForPaid) {
|
||||
$cfg = $killPoolConfig;
|
||||
$customWeights = null;
|
||||
} else {
|
||||
$cfg = $paidPoolConfig;
|
||||
$customWeights = $paidTierWeightsCustom;
|
||||
}
|
||||
} else {
|
||||
$cfg = $freePoolConfig;
|
||||
$customWeights = $freeTierWeightsCustom;
|
||||
}
|
||||
|
||||
$row = $playLogic->simulateOnePlay($cfg, $dir, $lotteryType, $playAnte, $customWeights);
|
||||
$winCoin = (float) ($row['win_coin'] ?? 0);
|
||||
$paidAmount = (float) ($row['paid_amount'] ?? 0);
|
||||
$playerProfitTotal += $winCoin - $paidAmount;
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
|
||||
if (!empty($row['grants_free_ticket'])) {
|
||||
$queue[] = ['free', $dir, $playAnte];
|
||||
}
|
||||
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, count($queue), $resultCounts, $tierCounts, null);
|
||||
|
||||
$qi++;
|
||||
}
|
||||
$runningWinTotal += (float) $row['win_coin'];
|
||||
}
|
||||
|
||||
private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void
|
||||
@@ -179,9 +235,10 @@ class WeightTestRunner
|
||||
'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',
|
||||
'admin_id', 'lottery_config_id', 'lottery_type', 'is_win', 'win_coin',
|
||||
'super_win_coin', 'reward_win_coin', 'direction', 'reward_tier',
|
||||
'ante', 'paid_amount',
|
||||
'start_index', 'target_index', 'roll_array', 'roll_number', 'status',
|
||||
];
|
||||
foreach ($keys as $k) {
|
||||
if (array_key_exists($k, $row)) {
|
||||
@@ -191,14 +248,14 @@ class WeightTestRunner
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function flushIfNeeded(array &$buffer, int $recordId, int $done, int $total, array $resultCounts, array $tierCounts): void
|
||||
private function flushIfNeeded(array &$buffer, int $recordId, int $done, int $total, array $resultCounts, array $tierCounts, ?int $recordTotalPlayCount = null): void
|
||||
{
|
||||
if (count($buffer) < self::BATCH_SIZE) {
|
||||
return;
|
||||
}
|
||||
$this->insertBuffer($buffer);
|
||||
$buffer = [];
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts);
|
||||
$this->updateProgress($recordId, $done, $resultCounts, $tierCounts, $recordTotalPlayCount);
|
||||
}
|
||||
|
||||
private function insertBuffer(array $rows): void
|
||||
@@ -207,15 +264,36 @@ class WeightTestRunner
|
||||
return;
|
||||
}
|
||||
foreach ($rows as $row) {
|
||||
DicePlayRecordTest::create($row);
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$payload = [];
|
||||
foreach (self::PLAY_RECORD_TEST_COLUMNS as $column) {
|
||||
if (array_key_exists($column, $row)) {
|
||||
$payload[$column] = $row[$column];
|
||||
}
|
||||
}
|
||||
if (!array_key_exists('create_time', $payload) || $payload['create_time'] === null || $payload['create_time'] === '') {
|
||||
$payload['create_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
if (!array_key_exists('update_time', $payload) || $payload['update_time'] === null || $payload['update_time'] === '') {
|
||||
$payload['update_time'] = $payload['create_time'];
|
||||
}
|
||||
if ($payload === []) {
|
||||
continue;
|
||||
}
|
||||
Db::name((new DicePlayRecordTest())->getTable())->insert($payload);
|
||||
}
|
||||
}
|
||||
|
||||
private function updateProgress(int $recordId, int $overPlayCount, array $resultCounts, array $tierCounts): void
|
||||
private function updateProgress(int $recordId, int $overPlayCount, array $resultCounts, array $tierCounts, ?int $totalPlayCount = null): void
|
||||
{
|
||||
$record = DiceRewardConfigRecord::find($recordId);
|
||||
if ($record) {
|
||||
$record->over_play_count = $overPlayCount;
|
||||
if ($totalPlayCount !== null) {
|
||||
$record->total_play_count = $totalPlayCount;
|
||||
}
|
||||
$record->result_counts = $resultCounts;
|
||||
$record->tier_counts = $tierCounts;
|
||||
$record->save();
|
||||
@@ -224,7 +302,7 @@ class WeightTestRunner
|
||||
|
||||
/**
|
||||
* 标记测试成功并记录平台总盈利 platform_profit
|
||||
* 通过关联 DicePlayRecordTest(reward_config_record_id)统计:付费(lottery_type=0)次数×100 - win_coin 求和
|
||||
* 通过关联 DicePlayRecordTest(reward_config_record_id)统计:付费金额 paid_amount 求和 - win_coin 求和
|
||||
*/
|
||||
private function markSuccess(int $recordId, array $resultCounts, array $tierCounts): void
|
||||
{
|
||||
@@ -240,6 +318,10 @@ class WeightTestRunner
|
||||
$record->tier_counts = $tierCounts;
|
||||
$record->remark = null;
|
||||
$record->platform_profit = $platformProfit;
|
||||
$record->play_again_count = DiceRewardConfigRecord::computePlayAgainCountFromRelated($recordId);
|
||||
$actualCount = (int) DicePlayRecordTest::where('reward_config_record_id', $recordId)->count();
|
||||
$record->total_play_count = $actualCount;
|
||||
$record->test_count = $actualCount;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
48
server/app/dice/model/ante_config/DiceAnteConfig.php
Normal file
48
server/app/dice/model/ante_config/DiceAnteConfig.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\ante_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
|
||||
/**
|
||||
* 底注配置模型
|
||||
*
|
||||
* @property int $id ID
|
||||
* @property string $name 名称
|
||||
* @property string $title 标题
|
||||
* @property int $is_default 是否默认底注:0否 1是(全表仅允许一条为1)
|
||||
* @property int $mult 底注倍率
|
||||
* @property string $create_time 创建时间
|
||||
* @property string $update_time 更新时间
|
||||
*/
|
||||
class DiceAnteConfig extends BaseModel
|
||||
{
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $table = 'dice_ante_config';
|
||||
|
||||
public function searchNameAttr($query, $value): void
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('name', 'like', '%' . $value . '%');
|
||||
}
|
||||
}
|
||||
|
||||
public function searchTitleAttr($query, $value): void
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('title', 'like', '%' . $value . '%');
|
||||
}
|
||||
}
|
||||
|
||||
public function searchIsDefaultAttr($query, $value): void
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('is_default', (int) $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ 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_weight T1池权重
|
||||
@@ -25,7 +25,7 @@ use plugin\saiadmin\basic\think\BaseModel;
|
||||
* @property $t3_weight T3池权重
|
||||
* @property $t4_weight T4池权重
|
||||
* @property $t5_weight T5池权重
|
||||
* @property $profit_amount 池子累计盈利(每局抽奖累加 100-real_ev,仅展示不可编辑)
|
||||
* @property $profit_amount 池子累计盈利(每局付费按 win_coin-paid_amount,免费按 win_coin 累加;仅展示不可编辑)
|
||||
*/
|
||||
class DiceLotteryPoolConfig extends BaseModel
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class DiceLotteryPoolConfig extends BaseModel
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_lottery_config';
|
||||
protected $table = 'dice_lottery_pool_config';
|
||||
|
||||
/**
|
||||
* 名称 搜索
|
||||
@@ -49,13 +49,4 @@ class DiceLotteryPoolConfig extends BaseModel
|
||||
$query->where('name', 'like', '%'.$value.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖池类型 搜索(type=0/1/2 等)
|
||||
*/
|
||||
public function searchTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('type', '=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,15 @@ use think\model\relation\BelongsTo;
|
||||
* @property $admin_id 关联玩家所属管理员ID(DicePlayer.admin_id)
|
||||
* @property $lottery_config_id 彩金池配置
|
||||
* @property $lottery_type 抽奖类型
|
||||
* @property $ante 底注/注数(dice_ante_config.mult)
|
||||
* @property $paid_amount 付费金额(付费局=ante*1,免费局=0)
|
||||
* @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 $use_coins 消耗平台币(兼容字段:付费局=paid_amount,免费局=0)
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $reward_config_id 奖励配置id
|
||||
* @property $reward_tier 中奖档位:T1,T2,T3,T4,T5,BIGWIN
|
||||
* @property $lottery_id 奖池
|
||||
* @property $start_index 起始索引
|
||||
* @property $target_index 结束索引
|
||||
@@ -61,15 +64,6 @@ class DicePlayRecord extends BaseModel
|
||||
return $this->belongsTo(DicePlayer::class, 'player_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 中奖配置
|
||||
* 关联模型 diceRewardConfig
|
||||
*/
|
||||
public function diceRewardConfig(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DiceRewardConfig::class, 'reward_config_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 彩金池配置
|
||||
* 关联模型 diceLotteryPoolConfig
|
||||
@@ -249,24 +243,19 @@ class DicePlayRecord extends BaseModel
|
||||
}
|
||||
$ids = DiceRewardConfig::where('ui_text', 'like', '%' . $value . '%')->column('id');
|
||||
if (!empty($ids)) {
|
||||
$query->whereIn('reward_config_id', $ids);
|
||||
$query->whereIn('target_index', $ids);
|
||||
} else {
|
||||
$query->whereRaw('1=0');
|
||||
}
|
||||
}
|
||||
|
||||
/** 按奖励档位(diceRewardConfig.tier,中奖名 T1-T5) */
|
||||
/** 按奖励档位(表字段 reward_tier,中奖名 T1-T5/BIGWIN) */
|
||||
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');
|
||||
}
|
||||
$query->where('reward_tier', '=', $value);
|
||||
}
|
||||
|
||||
/** 方向 0=顺时针 1=逆时针 */
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
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;
|
||||
@@ -19,11 +18,13 @@ use think\model\relation\BelongsTo;
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $lottery_config_id 彩金池配置id
|
||||
* @property $lottery_type 抽奖类型:0=付费,1=赠送
|
||||
* @property $lottery_type 抽奖类型:0=付费,1=免费
|
||||
* @property $is_win 中大奖:0=无,1=中奖
|
||||
* @property $win_coin 赢取平台币
|
||||
* @property int|null $ante 底注/注数(dice_ante_config.mult)
|
||||
* @property int|null $paid_amount 付费金额(付费局=ante*1,免费局=0)
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $reward_config_id 奖励配置id
|
||||
* @property $reward_tier 中奖档位:T1,T2,T3,T4,T5,BIGWIN
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
* @property $start_index 起始索引
|
||||
@@ -50,6 +51,10 @@ class DicePlayRecordTest extends BaseModel
|
||||
*/
|
||||
protected $table = 'dice_play_record_test';
|
||||
|
||||
protected $createTime = 'create_time';
|
||||
|
||||
protected $updateTime = 'update_time';
|
||||
|
||||
/**
|
||||
* 彩金池配置
|
||||
* 关联 lottery_config_id -> DiceLotteryPoolConfig.id
|
||||
@@ -59,15 +64,6 @@ class DicePlayRecordTest extends BaseModel
|
||||
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
|
||||
@@ -77,7 +73,7 @@ class DicePlayRecordTest extends BaseModel
|
||||
return $this->belongsTo(DiceRewardConfigRecord::class, 'reward_config_record_id', 'id');
|
||||
}
|
||||
|
||||
/** 抽奖类型 0=付费 1=赠送 */
|
||||
/** 抽奖类型 0=付费 1=免费 */
|
||||
public function searchLotteryTypeAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
@@ -117,18 +113,29 @@ class DicePlayRecordTest extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 中奖档位(按 reward_config_id 对应 DiceRewardConfig.tier) */
|
||||
/** 付费金额(付费局=ante*1,免费局=0) */
|
||||
public function searchPaidAmountAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('paid_amount', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 底注/注数(dice_ante_config.mult) */
|
||||
public function searchAnteAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('ante', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 中奖档位(按表字段 reward_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');
|
||||
}
|
||||
$query->where('reward_tier', '=', $value);
|
||||
}
|
||||
|
||||
/** 点数和 roll_number(摇取点数和 5-30) */
|
||||
@@ -138,4 +145,12 @@ class DicePlayRecordTest extends BaseModel
|
||||
$query->where('roll_number', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 关联 dice_reward_config_record.id(权重测试记录) */
|
||||
public function searchRewardConfigRecordIdAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('reward_config_record_id', '=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
* @property $total_ticket_count 总抽奖次数
|
||||
* @property $paid_ticket_count 购买抽奖次数
|
||||
* @property $free_ticket_count 赠送抽奖次数
|
||||
* @property array|null $free_ticket 免费抽奖券:{"ante":1,"count":1}
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 更新时间
|
||||
* @property $delete_time 删除时间
|
||||
@@ -54,6 +55,10 @@ class DicePlayer extends BaseModel
|
||||
|
||||
protected $updateTime = 'update_time';
|
||||
|
||||
protected $json = ['free_ticket'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
/**
|
||||
* 新增前:生成唯一 uid,昵称 name 默认使用 uid
|
||||
* 用 try-catch 避免表尚未含 uid 时 getAttr/getData 抛 InvalidArgumentException
|
||||
@@ -78,26 +83,26 @@ class DicePlayer extends BaseModel
|
||||
if ($name === null || $name === '') {
|
||||
$model->setAttr('name', $uid);
|
||||
}
|
||||
// 创建玩家时:未指定则自动保存 lottery_config_id 为 DiceLotteryPoolConfig type=0 的 id,没有则为 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('type', 0)->find();
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$model->setAttr('lottery_config_id', $config ? (int) $config->id : 0);
|
||||
}
|
||||
// 彩金池权重默认取 type=0 的奖池配置
|
||||
// 彩金池权重默认取 name=default 的奖池配置
|
||||
self::setDefaultWeightsFromLotteryConfig($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 DiceLotteryPoolConfig type=0 取 t1_weight~t5_weight 作为玩家未设置时的默认值
|
||||
* 从 DiceLotteryPoolConfig name=default 取 t1_weight~t5_weight 作为玩家未设置时的默认值
|
||||
*/
|
||||
protected static function setDefaultWeightsFromLotteryConfig(DicePlayer $model): void
|
||||
{
|
||||
$config = DiceLotteryPoolConfig::where('type', 0)->find();
|
||||
$config = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
if (!$config) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $player_id 玩家id
|
||||
* @property $admin_id 关联玩家所属管理员ID(DicePlayer.admin_id)
|
||||
* @property $use_coins 消耗硬币
|
||||
* @property $ante 底注/注数(历史购买记录默认为1;T5再来一次写入本次注数)
|
||||
* @property $total_ticket_count 总抽奖次数
|
||||
* @property $paid_ticket_count 购买抽奖次数
|
||||
* @property $free_ticket_count 赠送抽奖次数
|
||||
@@ -143,4 +144,12 @@ class DicePlayerTicketRecord extends BaseModel
|
||||
$query->where('create_time', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 底注/注数(ante) */
|
||||
public function searchAnteAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('ante', '=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,23 @@ use think\model\relation\HasMany;
|
||||
* @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 $total_play_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|null $ante 底注/注数(dice_ante_config.mult)
|
||||
* @property int $paid_s_count 付费抽奖顺时针次数
|
||||
* @property int $paid_n_count 付费抽奖逆时针次数
|
||||
* @property int $free_s_count 免费抽奖顺时针次数
|
||||
* @property int $free_n_count 免费抽奖逆时针次数
|
||||
* @property int $chain_free_mode 1=链式再来一次免费抽奖
|
||||
* @property int $kill_mode_enabled 测试内杀分开关 1=开启
|
||||
* @property int $test_safety_line 测试内安全线(模拟玩家累计盈利阈值)
|
||||
* @property int $paid_planned_spins 计划付费抽奖次数(顺+逆)
|
||||
* @property int $play_again_count 再来一次次数(T5触发次数)
|
||||
* @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 float|null $platform_profit 平台赚取金额(付费金额 paid_amount 求和-玩家总收益)
|
||||
* @property array|null $bigwin_weight 测试时 BIGWIN 档位权重快照(JSON:grid_number=>weight)
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
@@ -68,20 +70,48 @@ class DiceRewardConfigRecord extends BaseModel
|
||||
return $this->hasMany(DicePlayRecordTest::class, 'reward_config_record_id', 'id');
|
||||
}
|
||||
|
||||
/** 计划付费抽奖次数(顺+逆) */
|
||||
public function searchPaidPlannedSpinsAttr($query, $value): void
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('paid_planned_spins', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 底注/注数(dice_ante_config.mult) */
|
||||
public function searchAnteAttr($query, $value): void
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('ante', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关联的 DicePlayRecordTest 统计平台赚取平台币
|
||||
* platform_profit = 关联的付费(lottery_type=0)抽取次数 × 100 - 关联的 win_coin 求和
|
||||
* platform_profit = 关联的付费(lottery_type=0)付费金额求和(paid_amount) - 关联的 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)
|
||||
$paidAmount = (float) DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->where('lottery_type', 0)
|
||||
->count();
|
||||
->sum('paid_amount');
|
||||
$sumWinCoin = (float) DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->sum('win_coin');
|
||||
return round($paidCount * 100 - $sumWinCoin, 2);
|
||||
return round($paidAmount - $sumWinCoin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关联的 DicePlayRecordTest 统计再来一次次数(reward_tier=T5)
|
||||
* @param int $recordId
|
||||
* @return int
|
||||
*/
|
||||
public static function computePlayAgainCountFromRelated(int $recordId): int
|
||||
{
|
||||
return (int) DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->where('reward_tier', 'T5')
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\ante_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 底注配置验证器
|
||||
*/
|
||||
class DiceAnteConfigValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require|max:64',
|
||||
'title' => 'require|max:255',
|
||||
'is_default' => 'require|in:0,1',
|
||||
'mult' => 'require|integer|gt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name' => '名称必须填写',
|
||||
'title' => '标题必须填写',
|
||||
'is_default' => '默认底注标记必须为 0 或 1',
|
||||
'mult' => '底注倍率必须为大于 0 的整数',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'save' => ['name', 'title', 'is_default', 'mult'],
|
||||
'update' => ['name', 'title', 'is_default', 'mult'],
|
||||
];
|
||||
}
|
||||
@@ -18,7 +18,6 @@ class DiceLotteryPoolConfigValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
'type' => 'require',
|
||||
't1_weight' => 'require',
|
||||
't2_weight' => 'require',
|
||||
't3_weight' => 'require',
|
||||
@@ -31,7 +30,6 @@ class DiceLotteryPoolConfigValidate extends BaseValidate
|
||||
*/
|
||||
protected $message = [
|
||||
'name' => '名称必须填写',
|
||||
'type' => '奖池类型必须填写',
|
||||
't1_weight' => 'T1池权重必须填写',
|
||||
't2_weight' => 'T2池权重必须填写',
|
||||
't3_weight' => 'T3池权重必须填写',
|
||||
@@ -45,7 +43,6 @@ class DiceLotteryPoolConfigValidate extends BaseValidate
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'name',
|
||||
'type',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
@@ -54,7 +51,6 @@ class DiceLotteryPoolConfigValidate extends BaseValidate
|
||||
],
|
||||
'update' => [
|
||||
'name',
|
||||
'type',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
|
||||
@@ -22,7 +22,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'lottery_type' => 'require',
|
||||
'is_win' => 'require',
|
||||
'win_coin' => 'require',
|
||||
'reward_config_id' => 'require',
|
||||
'reward_tier' => 'require',
|
||||
'roll_array' => 'require|checkRollArray',
|
||||
];
|
||||
|
||||
@@ -35,7 +35,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'lottery_type' => '抽奖类型必须填写',
|
||||
'is_win' => '中奖必须填写',
|
||||
'win_coin' => '赢取平台币必须填写',
|
||||
'reward_config_id' => '奖励配置必须填写',
|
||||
'reward_tier' => '中奖档位必须填写',
|
||||
'roll_array.require' => '摇取点数必须填写',
|
||||
];
|
||||
|
||||
@@ -49,7 +49,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'reward_config_id',
|
||||
'reward_tier',
|
||||
'roll_array',
|
||||
],
|
||||
'update' => [
|
||||
@@ -58,7 +58,7 @@ class DicePlayRecordValidate extends BaseValidate
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'win_coin',
|
||||
'reward_config_id',
|
||||
'reward_tier',
|
||||
'roll_array',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -21,7 +21,7 @@ class DicePlayRecordTestValidate extends BaseValidate
|
||||
'lottery_type' => 'require',
|
||||
'is_win' => 'require',
|
||||
'direction' => 'require',
|
||||
'reward_config_id' => 'require',
|
||||
'reward_tier' => 'require',
|
||||
'status' => 'require',
|
||||
];
|
||||
|
||||
@@ -30,10 +30,10 @@ class DicePlayRecordTestValidate extends BaseValidate
|
||||
*/
|
||||
protected $message = [
|
||||
'lottery_config_id' => '彩金池配置id必须填写',
|
||||
'lottery_type' => '抽奖类型:0=付费,1=赠送必须填写',
|
||||
'lottery_type' => '抽奖类型:0=付费,1=免费必须填写',
|
||||
'is_win' => '中大奖:0=无,1=中奖必须填写',
|
||||
'direction' => '方向:0=顺时针,1=逆时针必须填写',
|
||||
'reward_config_id' => '奖励配置id必须填写',
|
||||
'reward_tier' => '中奖档位必须填写',
|
||||
'status' => '状态:0=失败,1=成功必须填写',
|
||||
];
|
||||
|
||||
@@ -46,7 +46,7 @@ class DicePlayRecordTestValidate extends BaseValidate
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'direction',
|
||||
'reward_config_id',
|
||||
'reward_tier',
|
||||
'status',
|
||||
],
|
||||
'update' => [
|
||||
@@ -54,7 +54,7 @@ class DicePlayRecordTestValidate extends BaseValidate
|
||||
'lottery_type',
|
||||
'is_win',
|
||||
'direction',
|
||||
'reward_config_id',
|
||||
'reward_tier',
|
||||
'status',
|
||||
],
|
||||
];
|
||||
|
||||
15
server/app/view/404.html
Normal file
15
server/app/view/404.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?= $message ?></title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; text-align: center; margin-top: 4rem; color: #333; }
|
||||
h1 { font-size: 1.5rem; font-weight: 600; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1><?= $message ?></h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -22,7 +22,7 @@ return [
|
||||
'dirname' => function () {
|
||||
return date('Ymd');
|
||||
},
|
||||
'domain' => 'http://127.0.0.1:6688',
|
||||
'domain' => 'http://127.0.0.1:8989',
|
||||
'uri' => '/runtime', // 如果 domain + uri 不在 public 目录下,请做好软链接,否则生成的url无法访问
|
||||
'algo' => 'sha1',
|
||||
],
|
||||
|
||||
@@ -16,9 +16,15 @@
|
||||
use Webman\Channel\Server;
|
||||
use Workerman\Protocols\Frame;
|
||||
|
||||
$listenHost = env('WEBMAN_CHANNEL_LISTEN_HOST', '0.0.0.0');
|
||||
$listenPort = filter_var(env('WEBMAN_CHANNEL_PORT'), FILTER_VALIDATE_INT);
|
||||
if ($listenPort === false) {
|
||||
$listenPort = 2207;
|
||||
}
|
||||
|
||||
return [
|
||||
'server' => [
|
||||
'listen' => 'frame://0.0.0.0:2206',
|
||||
'listen' => 'frame://' . $listenHost . ':' . $listenPort,
|
||||
'protocol' => Frame::class,
|
||||
'handler' => Server::class,
|
||||
'reloadable' => false,
|
||||
|
||||
@@ -21,7 +21,7 @@ global $argv;
|
||||
return [
|
||||
'webman' => [
|
||||
'handler' => Http::class,
|
||||
'listen' => 'http://0.0.0.0:6688',
|
||||
'listen' => 'http://0.0.0.0:8989',
|
||||
'count' => cpu_count() * 4,
|
||||
'user' => '',
|
||||
'group' => '',
|
||||
|
||||
@@ -46,9 +46,13 @@ Route::group('/api', function () {
|
||||
Route::any('/user/walletRecord', [app\api\controller\UserController::class, 'walletRecord']);
|
||||
Route::any('/user/playGameRecord', [app\api\controller\UserController::class, 'playGameRecord']);
|
||||
Route::any('/game/config', [app\api\controller\GameController::class, 'config']);
|
||||
Route::any('/game/buyLotteryTickets', [app\api\controller\GameController::class, 'buyLotteryTickets']);
|
||||
// Route::any('/game/buyLotteryTickets', [app\api\controller\GameController::class, 'buyLotteryTickets']);
|
||||
Route::any('/game/lotteryPool', [app\api\controller\GameController::class, 'lotteryPool']);
|
||||
Route::any('/game/anteConfig', [app\api\controller\GameController::class, 'anteConfig']);
|
||||
Route::any('/game/playStart', [app\api\controller\GameController::class, 'playStart']);
|
||||
})->middleware([
|
||||
TokenMiddleware::class,
|
||||
]);
|
||||
|
||||
// 关闭主应用默认路由(/controller/action 隐式映射),未在本文件显式注册的路径返回 404
|
||||
Route::disableDefaultRoute('');
|
||||
|
||||
17
server/db/dice_ante_config.sql
Normal file
17
server/db/dice_ante_config.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- 底注配置表
|
||||
CREATE TABLE IF NOT EXISTS `dice_ante_config` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(64) NOT NULL COMMENT '名称',
|
||||
`title` varchar(255) NOT NULL COMMENT '标题',
|
||||
`is_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否默认底注:0否 1是(全表只允许一条)',
|
||||
`mult` int NOT NULL DEFAULT 1 COMMENT '底注倍率',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_is_default` (`is_default`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Dice 底注配置表';
|
||||
|
||||
-- 可选初始化数据(保留一条默认底注)
|
||||
INSERT INTO `dice_ante_config` (`name`, `title`, `is_default`, `mult`)
|
||||
SELECT 'default', '默认底注', 1, 1
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `dice_ante_config` LIMIT 1);
|
||||
62
server/db/dice_ante_config_menu.sql
Normal file
62
server/db/dice_ante_config_menu.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
-- 底注配置菜单与权限
|
||||
-- 说明:默认挂载在「大富翁」目录(path=/dice)下;若不存在则自动创建目录。
|
||||
|
||||
SET @now = NOW();
|
||||
|
||||
-- 1) 找到或创建 Dice 顶级目录
|
||||
SET @dice_root_id = (
|
||||
SELECT `id` FROM `sa_system_menu`
|
||||
WHERE `path` = '/dice' AND `type` = 1
|
||||
ORDER BY `id` ASC LIMIT 1
|
||||
);
|
||||
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`icon`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT 0, '大富翁', 'Dice', NULL, 1, '/dice', NULL, NULL, 'ri:gamepad-line', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE @dice_root_id IS NULL;
|
||||
|
||||
SET @dice_root_id = (
|
||||
SELECT `id` FROM `sa_system_menu`
|
||||
WHERE `path` = '/dice' AND `type` = 1
|
||||
ORDER BY `id` ASC LIMIT 1
|
||||
);
|
||||
|
||||
-- 2) 创建底注配置菜单
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`icon`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @dice_root_id, '底注配置', 'AnteConfig', NULL, 2, 'ante_config', '/dice/ante_config/index', NULL, 'ri:coins-line', 92, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `sa_system_menu` WHERE `path` = 'ante_config' AND `component` = '/dice/ante_config/index' AND `type` = 2
|
||||
);
|
||||
|
||||
SET @ante_menu_id = (
|
||||
SELECT `id` FROM `sa_system_menu`
|
||||
WHERE `path` = 'ante_config' AND `component` = '/dice/ante_config/index' AND `type` = 2
|
||||
ORDER BY `id` ASC LIMIT 1
|
||||
);
|
||||
|
||||
-- 3) 创建按钮权限
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @ante_menu_id, '数据列表', '', 'dice:ante_config:index:index', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:ante_config:index:index' AND `type` = 3);
|
||||
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @ante_menu_id, '读取', '', 'dice:ante_config:index:read', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:ante_config:index:read' AND `type` = 3);
|
||||
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @ante_menu_id, '添加', '', 'dice:ante_config:index:save', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:ante_config:index:save' AND `type` = 3);
|
||||
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @ante_menu_id, '修改', '', 'dice:ante_config:index:update', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:ante_config:index:update' AND `type` = 3);
|
||||
|
||||
INSERT INTO `sa_system_menu`
|
||||
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||
SELECT @ante_menu_id, '删除', '', 'dice:ante_config:index:destroy', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:ante_config:index:destroy' AND `type` = 3);
|
||||
4
server/db/dice_play_record_add_ante_and_paid_amount.sql
Normal file
4
server/db/dice_play_record_add_ante_and_paid_amount.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- DicePlayRecord 新增注数与付费金额字段
|
||||
ALTER TABLE `dice_play_record`
|
||||
ADD COLUMN `ante` int unsigned NOT NULL DEFAULT 1 COMMENT '底注/注数(必须为 dice_ante_config.mult 中存在的值)' AFTER `lottery_type`,
|
||||
ADD COLUMN `paid_amount` int unsigned NOT NULL DEFAULT 0 COMMENT '付费金额(付费局=ante*1,免费局=0)' AFTER `ante`;
|
||||
3
server/db/dice_player_ticket_record_add_ante.sql
Normal file
3
server/db/dice_player_ticket_record_add_ante.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- DicePlayerTicketRecord 新增注数字段(用于记录“再来一次”免费抽奖的注数)
|
||||
ALTER TABLE `dice_player_ticket_record`
|
||||
ADD COLUMN `ante` int unsigned NOT NULL DEFAULT 1 COMMENT '底注/注数(历史购买记录默认为1)' AFTER `use_coins`;
|
||||
@@ -69,7 +69,7 @@ The exact implementation is in the dice game logic layer and related services. A
|
||||
|
||||
3. Get or create lottery pool:
|
||||
- `LotteryService::getOrCreate()`
|
||||
- Reads from Redis; if missing, reads from DB (for example, `DiceLotteryPoolConfig::where('type', 0/1)->find()`).
|
||||
- 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)`
|
||||
@@ -115,7 +115,7 @@ Goal: hot paths should hit Redis most of the time, and DB should primarily be fo
|
||||
- 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_config SET ev = ev - ?` on a hot row causes lock contention.
|
||||
- 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.
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
3. **获取或创建奖池(LotteryService)**
|
||||
- 调用 `LotteryService::getOrCreate()`:
|
||||
- 优先从 Redis 中读取奖池信息;
|
||||
- 若缓存不存在,则从 DB 中加载:如 `DiceLotteryPoolConfig::where('type', 0/1)->find()`。
|
||||
- 若缓存不存在,则从 DB 中加载:如 `DiceLotteryPoolConfig::where('name','default/killScore')->find()`。
|
||||
|
||||
4. **根据本次玩法加载奖池配置**
|
||||
- 调用 `DiceLotteryPoolConfig::find($configId)`。
|
||||
@@ -113,7 +113,7 @@
|
||||
- 在 `playStart` 中,玩家信息应只查询一次:`$player = DicePlayer::find($playerId)`,后续逻辑统一使用 `$player`,避免重复 `find`。
|
||||
|
||||
3. **EV 更新策略**
|
||||
- 频繁在在线请求中执行 `UPDATE dice_lottery_config SET ev = ev - ?`,会造成该行热点锁竞争;
|
||||
- 频繁在在线请求中执行 `UPDATE dice_lottery_pool_config SET ev = ev - ?`,会造成该行热点锁竞争;
|
||||
- 建议:
|
||||
- 在线请求仅将 EV 变动累加到 Redis 计数器;
|
||||
- 通过定时任务批量同步 Redis 中的统计数据回 MySQL。
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -85,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;
|
||||
@@ -105,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);
|
||||
@@ -142,16 +142,16 @@ class SystemUserLogic extends BaseLogic
|
||||
}
|
||||
$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);
|
||||
@@ -179,12 +179,12 @@ 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);
|
||||
// 超级管理员可删除任意用户,普通管理员仅可删除当前部门和子部门的用户
|
||||
@@ -193,14 +193,14 @@ class SystemUserLogic extends BaseLogic
|
||||
}
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,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);
|
||||
|
||||
@@ -20,6 +20,20 @@ use plugin\saiadmin\exception\ApiException;
|
||||
*/
|
||||
class CrontabLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 获取 webman channel 服务地址
|
||||
* 需要保证与 server/config/plugin/webman/channel/process.php 的 listen 端口一致
|
||||
*/
|
||||
private function channelConfig(): array
|
||||
{
|
||||
$host = env('WEBMAN_CHANNEL_HOST', '127.0.0.1');
|
||||
$port = filter_var(env('WEBMAN_CHANNEL_PORT'), FILTER_VALIDATE_INT);
|
||||
if ($port === false) {
|
||||
$port = 2207;
|
||||
}
|
||||
return ['host' => $host, 'port' => $port];
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
@@ -50,7 +64,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'),
|
||||
};
|
||||
|
||||
// 定时任务模型新增
|
||||
@@ -67,7 +81,8 @@ class CrontabLogic extends BaseLogic
|
||||
|
||||
$id = $model->getKey();
|
||||
// 连接到Channel服务
|
||||
ChannelClient::connect();
|
||||
$channel = $this->channelConfig();
|
||||
ChannelClient::connect($channel['host'], $channel['port']);
|
||||
ChannelClient::publish('crontab', ['args' => $id]);
|
||||
|
||||
return true;
|
||||
@@ -95,13 +110,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([
|
||||
@@ -116,7 +131,8 @@ class CrontabLogic extends BaseLogic
|
||||
]);
|
||||
if ($result) {
|
||||
// 连接到Channel服务
|
||||
ChannelClient::connect();
|
||||
$channel = $this->channelConfig();
|
||||
ChannelClient::connect($channel['host'], $channel['port']);
|
||||
ChannelClient::publish('crontab', ['args' => $id]);
|
||||
}
|
||||
|
||||
@@ -134,14 +150,15 @@ 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];
|
||||
}
|
||||
$result = parent::destroy($ids);
|
||||
if ($result) {
|
||||
// 连接到Channel服务
|
||||
ChannelClient::connect();
|
||||
$channel = $this->channelConfig();
|
||||
ChannelClient::connect($channel['host'], $channel['port']);
|
||||
ChannelClient::publish('crontab', ['args' => $ids]);
|
||||
}
|
||||
return $result;
|
||||
@@ -157,12 +174,13 @@ 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) {
|
||||
// 连接到Channel服务
|
||||
ChannelClient::connect();
|
||||
$channel = $this->channelConfig();
|
||||
ChannelClient::connect($channel['host'], $channel['port']);
|
||||
ChannelClient::publish('crontab', ['args' => $id]);
|
||||
}
|
||||
return $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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ Route::group('/core', function () {
|
||||
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']);
|
||||
@@ -118,6 +117,7 @@ Route::group('/core', function () {
|
||||
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/ante_config/DiceAnteConfig', \app\dice\controller\ante_config\DiceAnteConfigController::class);
|
||||
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']);
|
||||
|
||||
@@ -18,10 +18,7 @@ class ApiException extends BusinessException
|
||||
public function render(Request $request): ?Response
|
||||
{
|
||||
$message = $this->getMessage();
|
||||
$path = $request->path();
|
||||
if (str_contains($path, 'api/')) {
|
||||
$message = \app\api\util\ApiLang::translate($message, $request);
|
||||
}
|
||||
$message = \app\api\util\ApiLang::translate($message, $request);
|
||||
return json(['code' => $this->getCode() ?: 500, 'message' => $message]);
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,13 @@ class Task
|
||||
$dbName = env('DB_NAME');
|
||||
if (!empty($dbName)) {
|
||||
$this->logic = new CrontabLogic();
|
||||
$channelHost = env('WEBMAN_CHANNEL_HOST', '127.0.0.1');
|
||||
$channelPort = filter_var(env('WEBMAN_CHANNEL_PORT'), FILTER_VALIDATE_INT);
|
||||
if ($channelPort === false) {
|
||||
$channelPort = 2207;
|
||||
}
|
||||
// 连接webman channel服务
|
||||
Client::connect();
|
||||
Client::connect($channelHost, $channelPort);
|
||||
// 订阅某个自定义事件并注册回调,收到事件后会自动触发此回调
|
||||
Client::on('crontab', function ($data) {
|
||||
$this->reload($data);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,3 +12,5 @@ Route::group('/tool/install', function () {
|
||||
Route::get('/online/storeAppVersions', [plugin\saipackage\app\controller\InstallController::class, 'storeAppVersions']);
|
||||
Route::post('/online/storeDownloadApp', [plugin\saipackage\app\controller\InstallController::class, 'storeDownloadApp']);
|
||||
});
|
||||
|
||||
Route::disableDefaultRoute('saipackage');
|
||||
|
||||
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