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

@@ -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({