DicePlayRecord添加字段super_win_coin和reward_win_coin记录不同的中奖金额类型

This commit is contained in:
2026-03-07 11:09:41 +08:00
parent fe1ceeb4fb
commit e312154b0f
15 changed files with 280 additions and 60 deletions

View File

@@ -5,7 +5,7 @@ import request from '@/utils/http'
*/
export default {
/**
* 获取数据列表
* 获取数据列表DiceLotteryConfig
* @param params 搜索参数
* @returns 数据列表
*/
@@ -16,6 +16,21 @@ export default {
})
},
/**
* 获取彩金池配置下拉选项(来自 DiceLotteryConfig用于 lottery_config_id 选择)
* @returns { id, name }[]
*/
async getOptions(): Promise<Array<{ id: number; name: string }>> {
const res = await request.get<any>({
url: '/dice/lottery_config/DiceLotteryConfig/index',
params: { limit: 500, page: 1 }
})
const rows = (res?.data?.data ?? res?.data?.rows ?? []) as Array<{ id: number; name: string }>
return Array.isArray(rows)
? rows.map((r) => ({ id: Number(r.id), name: String(r.name ?? r.id) }))
: []
},
/**
* 读取数据
* @param id 数据ID

View File

@@ -56,10 +56,10 @@
{{ row.lottery_type === 0 ? '付费' : row.lottery_type === 1 ? '赠送' : '-' }}
</ElTag>
</template>
<!-- tag -->
<!-- 是否中大 tag -->
<template #is_win="{ row }">
<ElTag size="small" :type="row.is_win === 1 ? 'success' : 'info'">
{{ row.is_win === 0 ? '无' : row.is_win === 1 ? '中奖' : '-' }}
{{ row.is_win === 0 ? '无' : row.is_win === 1 ? '中奖' : '-' }}
</ElTag>
</template>
<!-- 方向 tag -->
@@ -182,8 +182,10 @@
useSlot: true
},
{ prop: 'lottery_type', label: '抽奖类型', width: 100, useSlot: true },
{ prop: 'is_win', label: '奖', width: 80, useSlot: true },
{ prop: 'win_coin', label: '赢取平台币' },
{ prop: 'is_win', label: '是否中大奖', width: 100, useSlot: true },
{ prop: 'win_coin', label: '赢取平台币', width: 110 },
{ prop: 'super_win_coin', label: '中大奖平台币', width: 120 },
{ prop: 'reward_win_coin', label: '摇色子中奖平台币', width: 140 },
{ prop: 'direction', label: '方向', width: 90, useSlot: true },
{ prop: 'start_index', label: '起始索引', width: 90 },
{ prop: 'target_index', label: '终点索引', width: 90 },

View File

@@ -54,7 +54,7 @@
<el-option label="赠送" :value="1" />
</el-select>
</el-form-item>
<el-form-item label="奖" prop="is_win">
<el-form-item label="是否中大奖" prop="is_win">
<el-select
v-model="formData.is_win"
placeholder="请选择"
@@ -63,18 +63,38 @@
:disabled="dialogType === 'edit'"
>
<el-option label="无" :value="0" />
<el-option label="中奖" :value="1" />
<el-option label="中奖" :value="1" />
</el-select>
</el-form-item>
<el-form-item label="赢取平台币" prop="win_coin">
<el-input-number
v-model="formData.win_coin"
placeholder="请输入赢取平台币"
placeholder="= 中大奖 + 摇色子中奖"
:precision="2"
style="width: 100%"
:disabled="dialogType === 'edit'"
/>
</el-form-item>
<el-form-item label="中大奖平台币" prop="super_win_coin">
<el-input-number
v-model="formData.super_win_coin"
placeholder="豹子时发放"
:precision="2"
:min="0"
style="width: 100%"
:disabled="dialogType === 'edit'"
/>
</el-form-item>
<el-form-item label="摇色子中奖平台币" prop="reward_win_coin">
<el-input-number
v-model="formData.reward_win_coin"
placeholder="摇色子中奖"
:precision="2"
:min="0"
style="width: 100%"
:disabled="dialogType === 'edit'"
/>
</el-form-item>
<el-form-item label="方向" prop="direction">
<el-select
v-model="formData.direction"
@@ -186,7 +206,7 @@
player_id: [{ required: true, message: '请选择玩家', trigger: 'change' }],
lottery_config_id: [{ required: true, message: '请选择彩金池配置', trigger: 'change' }],
lottery_type: [{ required: true, message: '请选择抽奖类型', trigger: 'change' }],
is_win: [{ required: true, message: '请选择奖', trigger: 'change' }],
is_win: [{ required: true, message: '请选择是否中大奖', trigger: 'change' }],
win_coin: [{ required: true, message: '赢取平台币必填', trigger: 'blur' }],
rollArrayItems: [
{
@@ -219,6 +239,8 @@
lottery_type: null as number | null,
is_win: null as number | null,
win_coin: null as number | null,
super_win_coin: null as number | null,
reward_win_coin: null as number | null,
direction: null as number | null,
start_index: null as number | null,
target_index: null as number | null,
@@ -278,6 +300,8 @@
'lottery_type',
'is_win',
'win_coin',
'super_win_coin',
'reward_win_coin',
'direction',
'start_index',
'target_index',

View File

@@ -27,10 +27,10 @@
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="奖" prop="is_win">
<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-option label="中奖" :value="1" />
</el-select>
</el-form-item>
</el-col>

View File

@@ -112,7 +112,7 @@
phone: undefined,
status: undefined,
coin: undefined,
is_up: undefined
lottery_config_id: undefined
})
// 搜索处理
@@ -127,17 +127,9 @@
return cellValue != null && cellValue !== '' ? `${cellValue}%` : '-'
}
// 倍率列展示0=正常 1=强制杀猪 2=T1高倍率
const isUpFormatter = (row: any) => {
const cellValue = row.is_up
return cellValue === 0
? '正常'
: cellValue === 1
? '强制杀猪'
: cellValue === 2
? 'T1高倍率'
: '-'
}
// 彩金池配置列lottery_config_id 关联 DiceLotteryConfig显示 name
const lotteryConfigNameFormatter = (row: any) =>
row?.diceLotteryConfig?.name ?? (row?.lottery_config_id ? `#${row.lottery_config_id}` : '自定义')
// 表格配置
const {
@@ -176,11 +168,11 @@
useSlot: true
},
{
prop: 'is_up',
label: '倍率',
width: 80,
prop: 'lottery_config_id',
label: '彩金池配置',
width: 120,
align: 'center',
formatter: isUpFormatter
formatter: (row: any) => lotteryConfigNameFormatter(row)
},
{
prop: 't1_weight',

View File

@@ -15,7 +15,13 @@
<el-input v-model="formData.name" placeholder="请输入昵称" />
</el-form-item>
<el-form-item label="手机号" prop="phone">
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable maxlength="20" show-word-limit />
<el-input
v-model="formData.phone"
placeholder="请输入手机号"
clearable
maxlength="20"
show-word-limit
/>
</el-form-item>
<el-form-item label="密码" prop="password" :rules="passwordRules">
<el-input
@@ -38,29 +44,39 @@
style="width: 100%"
/>
</el-form-item>
<el-form-item label="倍率" prop="is_up">
<el-select v-model="formData.is_up" placeholder="请选择倍率" clearable style="width: 100%">
<el-option label="正常" :value="0" />
<el-option label="强制杀猪" :value="1" />
<el-option label="T1高倍率" :value="2" />
<el-form-item label="彩金池配置" prop="lottery_config_id">
<el-select
v-model="formData.lottery_config_id"
placeholder="不选则使用下方自定义权重"
clearable
style="width: 100%"
@change="onLotteryConfigChange"
>
<el-option label="自定义权重" :value="0" />
<el-option
v-for="item in lotteryConfigOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="T1池权重(%)" prop="t1_weight">
<el-form-item v-if="!formData.lottery_config_id" label="T1池权重(%)" prop="t1_weight">
<el-slider v-model="formData.t1_weight" :min="0" :max="100" :step="0.01" show-input />
</el-form-item>
<el-form-item label="T2池权重(%)" prop="t2_weight">
<el-form-item v-if="!formData.lottery_config_id" label="T2池权重(%)" prop="t2_weight">
<el-slider v-model="formData.t2_weight" :min="0" :max="100" :step="0.01" show-input />
</el-form-item>
<el-form-item label="T3池权重(%)" prop="t3_weight">
<el-form-item v-if="!formData.lottery_config_id" label="T3池权重(%)" prop="t3_weight">
<el-slider v-model="formData.t3_weight" :min="0" :max="100" :step="0.01" show-input />
</el-form-item>
<el-form-item label="T4池权重(%)" prop="t4_weight">
<el-form-item v-if="!formData.lottery_config_id" label="T4池权重(%)" prop="t4_weight">
<el-slider v-model="formData.t4_weight" :min="0" :max="100" :step="0.01" show-input />
</el-form-item>
<el-form-item label="T5池权重(%)" prop="t5_weight">
<el-form-item v-if="!formData.lottery_config_id" label="T5池权重(%)" prop="t5_weight">
<el-slider v-model="formData.t5_weight" :min="0" :max="100" :step="0.01" show-input />
</el-form-item>
<el-form-item>
<el-form-item v-if="!formData.lottery_config_id">
<div class="text-gray-500 text-sm">
五个池权重总和<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
weightsSum
@@ -78,9 +94,12 @@
<script setup lang="ts">
import api from '../../../api/player/index'
import lotteryConfigApi from '../../../api/lottery_config/index'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
const WEIGHT_FIELDS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
interface Props {
modelValue: boolean
dialogType: string
@@ -107,9 +126,8 @@
set: (value) => emit('update:modelValue', value)
})
const WEIGHT_KEYS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
const weightsSum = computed(() => {
return WEIGHT_KEYS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
return WEIGHT_FIELDS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
})
/** 新增时密码必填,编辑时选填 */
@@ -133,7 +151,7 @@
password: '',
status: 1 as number,
coin: 0 as number,
is_up: null as number | null,
lottery_config_id: null as number | null,
t1_weight: 0 as number,
t2_weight: 0 as number,
t3_weight: 0 as number,
@@ -143,6 +161,9 @@
const formData = reactive({ ...initialFormData })
/** 彩金池配置下拉选项 */
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
watch(
() => props.modelValue,
(newVal) => {
@@ -150,19 +171,45 @@
}
)
/** 选择彩金池配置时,拉取该配置的权重填入表单(仅展示/备份lottery_config_id 非空时后端以配置为准) */
async function onLotteryConfigChange(lotteryConfigId: number | null) {
if (!lotteryConfigId) return
try {
const res = await lotteryConfigApi.read(lotteryConfigId)
const row = (res as any)?.data
if (row) {
WEIGHT_FIELDS.forEach((key) => {
;(formData as any)[key] = Number(row[key] ?? 0)
})
}
} catch (err) {
console.warn('拉取彩金池配置权重失败', err)
}
}
const initPage = async () => {
Object.assign(formData, initialFormData)
await loadLotteryConfigOptions()
if (props.data) {
await nextTick()
initForm()
}
}
/** 从 DiceLotteryConfig 拉取彩金池配置下拉选项 */
async function loadLotteryConfigOptions() {
try {
lotteryConfigOptions.value = await lotteryConfigApi.getOptions()
} catch {
lotteryConfigOptions.value = []
}
}
const numKeys = [
'id',
'status',
'coin',
'is_up',
'lottery_config_id',
't1_weight',
't2_weight',
't3_weight',
@@ -197,7 +244,8 @@
if (!formRef.value) return
try {
await formRef.value.validate()
if (Math.abs(weightsSum.value - 100) > 0.01) {
const useCustomWeights = !formData.lottery_config_id
if (useCustomWeights && Math.abs(weightsSum.value - 100) > 0.01) {
ElMessage.warning('五个池权重总和必须为100%')
return
}

View File

@@ -44,11 +44,19 @@
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="倍率" prop="is_up">
<el-select v-model="formData.is_up" placeholder="全部" clearable style="width: 100%">
<el-option label="正常" :value="0" />
<el-option label="强制杀猪" :value="1" />
<el-option label="T1高倍率" :value="2" />
<el-form-item label="彩金池配置" prop="lottery_config_id">
<el-select
v-model="formData.lottery_config_id"
placeholder="全部"
clearable
style="width: 100%"
>
<el-option
v-for="item in lotteryConfigOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
@@ -56,6 +64,8 @@
</template>
<script setup lang="ts">
import lotteryConfigApi from '../../../api/lottery_config/index'
interface Props {
modelValue: Record<string, any>
}
@@ -67,6 +77,16 @@
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
const isExpanded = ref<boolean>(false)
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
/** 从 DiceLotteryConfig 拉取彩金池配置下拉选项,用于 lottery_config_id 筛选 */
onMounted(async () => {
try {
lotteryConfigOptions.value = await lotteryConfigApi.getOptions()
} catch {
lotteryConfigOptions.value = []
}
})
const searchBarRef = ref()
const formData = computed({