diff --git a/saiadmin-artd/src/views/plugin/dice/api/lottery_pool_config/index.ts b/saiadmin-artd/src/views/plugin/dice/api/lottery_pool_config/index.ts index 61ff4ab..fb2b905 100644 --- a/saiadmin-artd/src/views/plugin/dice/api/lottery_pool_config/index.ts +++ b/saiadmin-artd/src/views/plugin/dice/api/lottery_pool_config/index.ts @@ -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), diff --git a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/index.vue b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/index.vue index b103e0c..ec02292 100644 --- a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/index.vue +++ b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/index.vue @@ -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) => - 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) => { + 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) => { @@ -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', diff --git a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/edit-dialog.vue b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/edit-dialog.vue index 1869ce7..7876959 100644 --- a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/edit-dialog.vue +++ b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/edit-dialog.vue @@ -25,19 +25,7 @@ show-word-limit /> - - - - - - - + (() => ({ 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', diff --git a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/table-search.vue b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/table-search.vue index 997068a..ee8a882 100644 --- a/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/table-search.vue +++ b/saiadmin-artd/src/views/plugin/dice/lottery_pool_config/index/modules/table-search.vue @@ -13,16 +13,7 @@ - - - - - + @@ -42,11 +33,7 @@ const isExpanded = ref(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({ diff --git a/saiadmin-artd/src/views/plugin/dice/player/index/modules/edit-dialog.vue b/saiadmin-artd/src/views/plugin/dice/player/index/modules/edit-dialog.vue index 0c87724..8c7097b 100644 --- a/saiadmin-artd/src/views/plugin/dice/player/index/modules/edit-dialog.vue +++ b/saiadmin-artd/src/views/plugin/dice/player/index/modules/edit-dialog.vue @@ -89,7 +89,7 @@
{{ $t('page.form.configLabelType') }}: - {{ lotteryConfigTypeText(currentLotteryConfig.type) }} + {{ lotteryConfigTypeText(currentLotteryConfig.name) }}
{{ $t('page.form.configLabelWeights') }}: @@ -265,11 +265,12 @@ /** 当前选中的 DiceLotteryConfig 完整数据(用于展示) */ const currentLotteryConfig = ref | 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) */ diff --git a/saiadmin-artd/src/views/plugin/dice/reward/index/modules/weight-test-dialog.vue b/saiadmin-artd/src/views/plugin/dice/reward/index/modules/weight-test-dialog.vue index 2066d25..a9feed7 100644 --- a/saiadmin-artd/src/views/plugin/dice/reward/index/modules/weight-test-dialog.vue +++ b/saiadmin-artd/src/views/plugin/dice/reward/index/modules/weight-test-dialog.vue @@ -18,7 +18,7 @@ >([]) - /** 将 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 paidLotteryOptions = computed(() => - lotteryOptions.value.filter((r) => tierTypeNum(r) === 0) - ) - /** - * 免费抽奖券可选档位:优先 type=1(DiceLotteryPoolConfig.type=1),若无则显示全部以便下拉有选项 - */ + const lotteryOptions = ref>([]) + /** 付费抽奖券可选档位:name=default */ + const paidLotteryOptions = computed(() => lotteryOptions.value.filter((r) => r.name === 'default')) + /** 免费抽奖券可选档位:优先 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) @@ -211,22 +202,16 @@ 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 })) + // 付费抽奖券默认使用 name=default + 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 + // 免费抽奖券默认使用 name=killScore;若无则默认选第一项 + const kill = list.find((r: { name?: string }) => r.name === 'killScore') + if (kill) { + form.free_lottery_config_id = kill.id } else if (list.length > 0) { form.free_lottery_config_id = list[0].id } @@ -312,7 +297,7 @@ } }) - // 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 type=1 的选项,避免显示错误 + // 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 killScore 的选项,避免显示错误 watch(currentStep, (step) => { if (step === 1) { const freeOpts = freeLotteryOptions.value diff --git a/saiadmin-artd/src/views/plugin/dice/reward_config_record/index/modules/detail-drawer.vue b/saiadmin-artd/src/views/plugin/dice/reward_config_record/index/modules/detail-drawer.vue index ce8920e..48a758c 100644 --- a/saiadmin-artd/src/views/plugin/dice/reward_config_record/index/modules/detail-drawer.vue +++ b/saiadmin-artd/src/views/plugin/dice/reward_config_record/index/modules/detail-drawer.vue @@ -266,7 +266,7 @@ const importing = ref(false) const importPaidLotteryConfigId = ref(null) const importFreeLotteryConfigId = ref(null) - const lotteryConfigOptions = ref>([]) + const lotteryConfigOptions = ref>([]) function tierWeightsToTableData(t: Record | null | undefined) { if (!t || typeof t !== 'object') return [] diff --git a/server/app/api/lang/en.php b/server/app/api/lang/en.php index 4c02220..117a7d8 100644 --- a/server/app/api/lang/en.php +++ b/server/app/api/lang/en.php @@ -39,9 +39,9 @@ return [ '配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty', '该方向下暂无可用路径配置' => 'No path config available for this direction', // Dice / pool config - '奖池配置不存在(需 type=0)' => 'Lottery pool config not found (type=0 required)', + '奖池配置不存在(需 name=default)' => 'Lottery pool config not found (name=default required)', '暂无可用奖励配置' => 'No available reward config', - '未找到 type=0 的奖池配置,请先创建' => 'No type=0 pool config found, please create one first', + '未找到 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', diff --git a/server/app/api/logic/PlayStartLogic.php b/server/app/api/logic/PlayStartLogic.php index c03f4ef..40eb6ae 100644 --- a/server/app/api/logic/PlayStartLogic.php +++ b/server/app/api/logic/PlayStartLogic.php @@ -71,10 +71,10 @@ class PlayStartLogic $lotteryService = LotteryService::getOrCreate($playerId); $ticketType = LotteryService::drawTicketType($paid, $free); - $configType0 = DiceLotteryPoolConfig::where('type', 0)->find(); - $configType1 = DiceLotteryPoolConfig::where('type', 1)->find(); + $configType0 = DiceLotteryPoolConfig::where('name', 'default')->find(); + $configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find(); if (!$configType0) { - throw new ApiException('奖池配置不存在(需 type=0)'); + throw new ApiException('奖池配置不存在(需 name=default)'); } // 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数) diff --git a/server/app/api/service/LotteryService.php b/server/app/api/service/LotteryService.php index decf949..fd659a7 100644 --- a/server/app/api/service/LotteryService.php +++ b/server/app/api/service/LotteryService.php @@ -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; diff --git a/server/app/dice/controller/lottery_pool_config/DiceLotteryPoolConfigController.php b/server/app/dice/controller/lottery_pool_config/DiceLotteryPoolConfigController.php index 344d85a..4aada8d 100644 --- a/server/app/dice/controller/lottery_pool_config/DiceLotteryPoolConfigController.php +++ b/server/app/dice/controller/lottery_pool_config/DiceLotteryPoolConfigController.php @@ -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), diff --git a/server/app/dice/logic/lottery_pool_config/DiceLotteryPoolConfigLogic.php b/server/app/dice/logic/lottery_pool_config/DiceLotteryPoolConfigLogic.php index 6bdd3c1..e0446a8 100644 --- a/server/app/dice/logic/lottery_pool_config/DiceLotteryPoolConfigLogic.php +++ b/server/app/dice/logic/lottery_pool_config/DiceLotteryPoolConfigLogic.php @@ -38,11 +38,11 @@ class DiceLotteryPoolConfigLogic extends BaseLogic */ 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('未找到 name=default 的奖池配置,请先创建'); } - $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 = [ diff --git a/server/app/dice/logic/reward_config/DiceRewardConfigLogic.php b/server/app/dice/logic/reward_config/DiceRewardConfigLogic.php index 06a80f6..ea8a1a7 100644 --- a/server/app/dice/logic/reward_config/DiceRewardConfigLogic.php +++ b/server/app/dice/logic/reward_config/DiceRewardConfigLogic.php @@ -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 = [ diff --git a/server/app/dice/model/lottery_pool_config/DiceLotteryPoolConfig.php b/server/app/dice/model/lottery_pool_config/DiceLotteryPoolConfig.php index a6240c4..5725862 100644 --- a/server/app/dice/model/lottery_pool_config/DiceLotteryPoolConfig.php +++ b/server/app/dice/model/lottery_pool_config/DiceLotteryPoolConfig.php @@ -16,7 +16,6 @@ use plugin\saiadmin\basic\think\BaseModel; * @property $id ID * @property $name 名称 * @property $remark 备注 - * @property $type 奖池类型 * @property $safety_line 安全线 * @property $kill_enabled 是否启用杀分:0=关闭 1=开启 * @property $create_time 创建时间 @@ -50,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); - } - } } diff --git a/server/app/dice/model/player/DicePlayer.php b/server/app/dice/model/player/DicePlayer.php index 3dc7d53..db529e0 100644 --- a/server/app/dice/model/player/DicePlayer.php +++ b/server/app/dice/model/player/DicePlayer.php @@ -78,26 +78,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; } diff --git a/server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md b/server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md index 527820d..f32ea17 100644 --- a/server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md +++ b/server/docs/PERFORMANCE_AND_QPS_ANALYSIS.md @@ -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)` diff --git a/server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md b/server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md index 91073a7..de8ad61 100644 --- a/server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md +++ b/server/docs/PERFORMANCE_AND_QPS_ANALYSIS_CN.md @@ -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)`。 diff --git a/server/resource/translations/api/en.php b/server/resource/translations/api/en.php index fc153f4..7e47c58 100644 --- a/server/resource/translations/api/en.php +++ b/server/resource/translations/api/en.php @@ -37,9 +37,9 @@ return [ '奖池配置不存在' => 'Lottery config not found', '配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty', '该方向下暂无可用路径配置' => 'No path config available for this direction', - '奖池配置不存在(需 type=0)' => 'Lottery pool config not found (type=0 required)', + '奖池配置不存在(需 name=default)' => 'Lottery pool config not found (name=default required)', '暂无可用奖励配置' => 'No available reward config', - '未找到 type=0 的奖池配置,请先创建' => 'No type=0 pool config found, please create one first', + '未找到 name=default 的奖池配置,请先创建' => 'No name=default pool config found, please create one first', '参数错误:需要有效的 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',