[色子游戏]玩家抽奖记录
This commit is contained in:
65
saiadmin-artd/src/views/plugin/dice/api/play_record/index.ts
Normal file
65
saiadmin-artd/src/views/plugin/dice/api/play_record/index.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import request from '@/utils/http'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家抽奖记录 API接口
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 获取数据列表
|
||||||
|
* @param params 搜索参数
|
||||||
|
* @returns 数据列表
|
||||||
|
*/
|
||||||
|
list(params: Record<string, any>) {
|
||||||
|
return request.get<Api.Common.ApiPage>({
|
||||||
|
url: '/dice/play_record/DicePlayRecord/index',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取数据
|
||||||
|
* @param id 数据ID
|
||||||
|
* @returns 数据详情
|
||||||
|
*/
|
||||||
|
read(id: number | string) {
|
||||||
|
return request.get<Api.Common.ApiData>({
|
||||||
|
url: '/dice/play_record/DicePlayRecord/read?id=' + id
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建数据
|
||||||
|
* @param params 数据参数
|
||||||
|
* @returns 执行结果
|
||||||
|
*/
|
||||||
|
save(params: Record<string, any>) {
|
||||||
|
return request.post<any>({
|
||||||
|
url: '/dice/play_record/DicePlayRecord/save',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @param params 数据参数
|
||||||
|
* @returns 执行结果
|
||||||
|
*/
|
||||||
|
update(params: Record<string, any>) {
|
||||||
|
return request.put<any>({
|
||||||
|
url: '/dice/play_record/DicePlayRecord/update',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
* @param id 数据ID
|
||||||
|
* @returns 执行结果
|
||||||
|
*/
|
||||||
|
delete(params: Record<string, any>) {
|
||||||
|
return request.del<any>({
|
||||||
|
url: '/dice/play_record/DicePlayRecord/destroy',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
137
saiadmin-artd/src/views/plugin/dice/play_record/index/index.vue
Normal file
137
saiadmin-artd/src/views/plugin/dice/play_record/index/index.vue
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<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:play_record:index:save'" @click="showDialog('add')" v-ripple>
|
||||||
|
<template #icon>
|
||||||
|
<ArtSvgIcon icon="ri:add-fill" />
|
||||||
|
</template>
|
||||||
|
新增
|
||||||
|
</ElButton>
|
||||||
|
<ElButton
|
||||||
|
v-permission="'dice:play_record:index:destroy'"
|
||||||
|
:disabled="selectedRows.length === 0"
|
||||||
|
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||||
|
v-ripple
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</ElButton>
|
||||||
|
</ElSpace>
|
||||||
|
</template>
|
||||||
|
</ArtTableHeader>
|
||||||
|
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ArtTable
|
||||||
|
ref="tableRef"
|
||||||
|
rowKey="id"
|
||||||
|
:loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:columns="columns"
|
||||||
|
:pagination="pagination"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
@pagination:size-change="handleSizeChange"
|
||||||
|
@pagination:current-change="handleCurrentChange"
|
||||||
|
>
|
||||||
|
<!-- 操作列 -->
|
||||||
|
<template #operation="{ row }">
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<SaButton
|
||||||
|
v-permission="'dice:play_record:index:update'"
|
||||||
|
type="secondary"
|
||||||
|
@click="showDialog('edit', row)"
|
||||||
|
/>
|
||||||
|
<SaButton
|
||||||
|
v-permission="'dice:play_record:index:destroy'"
|
||||||
|
type="error"
|
||||||
|
@click="deleteRow(row, api.delete, refreshData)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ArtTable>
|
||||||
|
</ElCard>
|
||||||
|
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<EditDialog
|
||||||
|
v-model="dialogVisible"
|
||||||
|
:dialog-type="dialogType"
|
||||||
|
:data="dialogData"
|
||||||
|
@success="refreshData"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useTable } from '@/hooks/core/useTable'
|
||||||
|
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||||
|
import api from '../../api/play_record/index'
|
||||||
|
import TableSearch from './modules/table-search.vue'
|
||||||
|
import EditDialog from './modules/edit-dialog.vue'
|
||||||
|
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = ref({
|
||||||
|
lottery_type: undefined,
|
||||||
|
lottery_name: undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 搜索处理
|
||||||
|
const handleSearch = (params: Record<string, any>) => {
|
||||||
|
Object.assign(searchParams, params)
|
||||||
|
getData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格配置
|
||||||
|
const {
|
||||||
|
columns,
|
||||||
|
columnChecks,
|
||||||
|
data,
|
||||||
|
loading,
|
||||||
|
getData,
|
||||||
|
searchParams,
|
||||||
|
pagination,
|
||||||
|
resetSearchParams,
|
||||||
|
handleSortChange,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
refreshData
|
||||||
|
} = useTable({
|
||||||
|
core: {
|
||||||
|
apiFn: api.list,
|
||||||
|
columnsFactory: () => [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ prop: 'player_id', label: '玩家id' },
|
||||||
|
{ prop: 'lottery_config_id', label: '彩金池配置' },
|
||||||
|
{ prop: 'lottery_type', label: '抽奖类型' },
|
||||||
|
{ prop: 'is_win', label: '中奖' },
|
||||||
|
{ prop: 'win_coin', label: '赢取平台币' },
|
||||||
|
{ prop: 'reward_config_id', label: '奖励配置id' },
|
||||||
|
{ prop: 'lottery_id', label: '奖池' },
|
||||||
|
{ prop: 'lottery_name', label: '奖池名' },
|
||||||
|
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 编辑配置
|
||||||
|
const {
|
||||||
|
dialogType,
|
||||||
|
dialogVisible,
|
||||||
|
dialogData,
|
||||||
|
showDialog,
|
||||||
|
deleteRow,
|
||||||
|
deleteSelectedRows,
|
||||||
|
handleSelectionChange,
|
||||||
|
selectedRows
|
||||||
|
} = useSaiAdmin()
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="visible"
|
||||||
|
:title="dialogType === 'add' ? '新增玩家抽奖记录' : '编辑玩家抽奖记录'"
|
||||||
|
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="player_id">
|
||||||
|
<el-cascader v-model="formData.player_id" :options="[]" placeholder="请选择玩家id" allow-clear />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="彩金池配置" prop="lottery_config_id">
|
||||||
|
<el-cascader v-model="formData.lottery_config_id" :options="[]" placeholder="请选择彩金池配置" allow-clear />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="抽奖类型" prop="lottery_type">
|
||||||
|
<el-select v-model="formData.lottery_type" :options="[]" placeholder="请选择抽奖类型" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="中奖" prop="is_win">
|
||||||
|
<el-select v-model="formData.is_win" :options="[]" placeholder="请选择中奖" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="赢取平台币" prop="win_coin">
|
||||||
|
<el-input-number v-model="formData.win_coin" placeholder="请输入赢取平台币" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="奖励配置id" prop="reward_config_id">
|
||||||
|
<el-cascader v-model="formData.reward_config_id" :options="[]" placeholder="请选择奖励配置id" allow-clear />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="奖池" prop="lottery_id">
|
||||||
|
<el-cascader v-model="formData.lottery_id" :options="[]" placeholder="请选择奖池" allow-clear />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="奖池名" prop="lottery_name">
|
||||||
|
<el-input v-model="formData.lottery_name" placeholder="请输入奖池名" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="handleClose">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSubmit">提交</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import api from '../../../api/play_record/index'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
modelValue: boolean
|
||||||
|
dialogType: string
|
||||||
|
data?: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'update:modelValue', value: boolean): void
|
||||||
|
(e: 'success'): void
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
modelValue: false,
|
||||||
|
dialogType: 'add',
|
||||||
|
data: undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>()
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 弹窗显示状态双向绑定
|
||||||
|
*/
|
||||||
|
const visible = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value) => emit('update:modelValue', value)
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单验证规则
|
||||||
|
*/
|
||||||
|
const rules = reactive<FormRules>({
|
||||||
|
player_id: [{ required: true, message: '玩家id必需填写', trigger: 'blur' }],
|
||||||
|
lottery_config_id: [{ required: true, message: '彩金池配置必需填写', trigger: 'blur' }],
|
||||||
|
lottery_type: [{ required: true, message: '抽奖类型必需填写', trigger: 'blur' }],
|
||||||
|
is_win: [{ required: true, message: '中奖必需填写', trigger: 'blur' }],
|
||||||
|
win_coin: [{ required: true, message: '赢取平台币必需填写', trigger: 'blur' }],
|
||||||
|
reward_config_id: [{ required: true, message: '奖励配置id必需填写', trigger: 'blur' }],
|
||||||
|
lottery_id: [{ required: true, message: '奖池必需填写', trigger: 'blur' }],
|
||||||
|
lottery_name: [{ required: true, message: '奖池名必需填写', trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始数据
|
||||||
|
*/
|
||||||
|
const initialFormData = {
|
||||||
|
id: null,
|
||||||
|
player_id: null,
|
||||||
|
lottery_config_id: null,
|
||||||
|
lottery_type: null,
|
||||||
|
is_win: null,
|
||||||
|
win_coin: null,
|
||||||
|
reward_config_id: null,
|
||||||
|
lottery_id: null,
|
||||||
|
lottery_name: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单数据
|
||||||
|
*/
|
||||||
|
const formData = reactive({ ...initialFormData })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听弹窗打开,初始化表单数据
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(newVal) => {
|
||||||
|
if (newVal) {
|
||||||
|
initPage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
*/
|
||||||
|
const initPage = async () => {
|
||||||
|
// 先重置为初始值
|
||||||
|
Object.assign(formData, initialFormData)
|
||||||
|
// 如果有数据,则填充数据
|
||||||
|
if (props.data) {
|
||||||
|
await nextTick()
|
||||||
|
initForm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化表单数据
|
||||||
|
*/
|
||||||
|
const initForm = () => {
|
||||||
|
if (props.data) {
|
||||||
|
for (const key in formData) {
|
||||||
|
if (props.data[key] != null && props.data[key] != undefined) {
|
||||||
|
;(formData as any)[key] = props.data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭弹窗并重置表单
|
||||||
|
*/
|
||||||
|
const handleClose = () => {
|
||||||
|
visible.value = false
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交表单
|
||||||
|
*/
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!formRef.value) return
|
||||||
|
try {
|
||||||
|
await formRef.value.validate()
|
||||||
|
if (props.dialogType === 'add') {
|
||||||
|
await api.save(formData)
|
||||||
|
ElMessage.success('新增成功')
|
||||||
|
} else {
|
||||||
|
await api.update(formData)
|
||||||
|
ElMessage.success('修改成功')
|
||||||
|
}
|
||||||
|
emit('success')
|
||||||
|
handleClose()
|
||||||
|
} catch (error) {
|
||||||
|
console.log('表单验证失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<template>
|
||||||
|
<sa-search-bar
|
||||||
|
ref="searchBarRef"
|
||||||
|
v-model="formData"
|
||||||
|
label-width="100px"
|
||||||
|
:showExpand="false"
|
||||||
|
@reset="handleReset"
|
||||||
|
@search="handleSearch"
|
||||||
|
@expand="handleExpand"
|
||||||
|
>
|
||||||
|
<el-col v-bind="setSpan(6)">
|
||||||
|
<el-form-item label="抽奖类型" prop="lottery_type">
|
||||||
|
<el-select v-model="formData.lottery_type" :options="[]" placeholder="请选择抽奖类型" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col v-bind="setSpan(6)">
|
||||||
|
<el-form-item label="奖池名" prop="lottery_name">
|
||||||
|
<el-input v-model="formData.lottery_name" placeholder="请输入奖池名" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</sa-search-bar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
interface Props {
|
||||||
|
modelValue: Record<string, any>
|
||||||
|
}
|
||||||
|
interface Emits {
|
||||||
|
(e: 'update:modelValue', value: Record<string, any>): void
|
||||||
|
(e: 'search', params: Record<string, any>): void
|
||||||
|
(e: 'reset'): void
|
||||||
|
}
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
const emit = defineEmits<Emits>()
|
||||||
|
// 展开/收起
|
||||||
|
const isExpanded = ref<boolean>(false)
|
||||||
|
|
||||||
|
// 表单数据双向绑定
|
||||||
|
const searchBarRef = ref()
|
||||||
|
const formData = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchBarRef.value?.ref.resetFields()
|
||||||
|
emit('reset')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
async function handleSearch() {
|
||||||
|
emit('search', formData.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开/收起
|
||||||
|
function handleExpand(expanded: boolean) {
|
||||||
|
isExpanded.value = expanded
|
||||||
|
}
|
||||||
|
|
||||||
|
// 栅格占据的列数
|
||||||
|
const setSpan = (span: number) => {
|
||||||
|
return {
|
||||||
|
span: span,
|
||||||
|
xs: 24, // 手机:满宽显示
|
||||||
|
sm: span >= 12 ? span : 12, // 平板:大于等于12保持,否则用半宽
|
||||||
|
md: span >= 8 ? span : 8, // 中等屏幕:大于等于8保持,否则用三分之一宽
|
||||||
|
lg: span,
|
||||||
|
xl: span
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | saiadmin [ saiadmin快速开发框架 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: your name
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace app\dice\controller\play_record;
|
||||||
|
|
||||||
|
use plugin\saiadmin\basic\BaseController;
|
||||||
|
use app\dice\logic\play_record\DicePlayRecordLogic;
|
||||||
|
use app\dice\validate\play_record\DicePlayRecordValidate;
|
||||||
|
use plugin\saiadmin\service\Permission;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家抽奖记录控制器
|
||||||
|
*/
|
||||||
|
class DicePlayRecordController extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->logic = new DicePlayRecordLogic();
|
||||||
|
$this->validate = new DicePlayRecordValidate;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('玩家抽奖记录列表', 'dice:play_record:index:index')]
|
||||||
|
public function index(Request $request): Response
|
||||||
|
{
|
||||||
|
$where = $request->more([
|
||||||
|
['lottery_type', ''],
|
||||||
|
['lottery_name', ''],
|
||||||
|
]);
|
||||||
|
$query = $this->logic->search($where);
|
||||||
|
$query->with([
|
||||||
|
'dicePlayer',
|
||||||
|
'diceRewardConfig',
|
||||||
|
'diceLotteryConfig',
|
||||||
|
]);
|
||||||
|
$data = $this->logic->getList($query);
|
||||||
|
return $this->success($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取数据
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('玩家抽奖记录读取', 'dice:play_record:index:read')]
|
||||||
|
public function read(Request $request): Response
|
||||||
|
{
|
||||||
|
$id = $request->input('id', '');
|
||||||
|
$model = $this->logic->read($id);
|
||||||
|
if ($model) {
|
||||||
|
$data = is_array($model) ? $model : $model->toArray();
|
||||||
|
return $this->success($data);
|
||||||
|
} else {
|
||||||
|
return $this->fail('未查找到信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存数据
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('玩家抽奖记录添加', 'dice:play_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
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('玩家抽奖记录修改', 'dice:play_record:index:update')]
|
||||||
|
public function update(Request $request): Response
|
||||||
|
{
|
||||||
|
$data = $request->post();
|
||||||
|
$this->validate('update', $data);
|
||||||
|
$result = $this->logic->edit($data['id'], $data);
|
||||||
|
if ($result) {
|
||||||
|
return $this->success('修改成功');
|
||||||
|
} else {
|
||||||
|
return $this->fail('修改失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('玩家抽奖记录删除', 'dice:play_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('删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
server/app/dice/logic/play_record/DicePlayRecordLogic.php
Normal file
27
server/app/dice/logic/play_record/DicePlayRecordLogic.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | saiadmin [ saiadmin快速开发框架 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: your name
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace app\dice\logic\play_record;
|
||||||
|
|
||||||
|
use plugin\saiadmin\basic\think\BaseLogic;
|
||||||
|
use plugin\saiadmin\exception\ApiException;
|
||||||
|
use plugin\saiadmin\utils\Helper;
|
||||||
|
use app\dice\model\play_record\DicePlayRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家抽奖记录逻辑层
|
||||||
|
*/
|
||||||
|
class DicePlayRecordLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new DicePlayRecord();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
server/app/dice/model/play_record/DicePlayRecord.php
Normal file
78
server/app/dice/model/play_record/DicePlayRecord.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | saiadmin [ saiadmin快速开发框架 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: your name
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace app\dice\model\play_record;
|
||||||
|
|
||||||
|
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||||
|
use app\dice\model\player\DicePlayer;
|
||||||
|
use app\dice\model\reward_config\DiceRewardConfig;
|
||||||
|
use plugin\saiadmin\basic\think\BaseModel;
|
||||||
|
use think\model\relation\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家抽奖记录模型
|
||||||
|
*
|
||||||
|
* dice_play_record 玩家抽奖记录
|
||||||
|
*
|
||||||
|
* @property $id ID
|
||||||
|
* @property $player_id 玩家id
|
||||||
|
* @property $lottery_config_id 彩金池配置
|
||||||
|
* @property $lottery_type 抽奖类型
|
||||||
|
* @property $is_win 中奖
|
||||||
|
* @property $win_coin 赢取平台币
|
||||||
|
* @property $reward_config_id 奖励配置id
|
||||||
|
* @property $lottery_id 奖池
|
||||||
|
* @property $lottery_name 奖池名
|
||||||
|
* @property $create_time 创建时间
|
||||||
|
* @property $update_time 修改时间
|
||||||
|
*/
|
||||||
|
class DicePlayRecord extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 数据表主键
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库表名称
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'dice_play_record';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 奖池名 搜索
|
||||||
|
*/
|
||||||
|
public function searchLotteryNameAttr($query, $value)
|
||||||
|
{
|
||||||
|
$query->where('lottery_name', 'like', '%'.$value.'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联模型 dicePlayer
|
||||||
|
*/
|
||||||
|
public function dicePlayer(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(DicePlayer::class, 'player_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联模型 diceRewardConfig
|
||||||
|
*/
|
||||||
|
public function diceRewardConfig(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(DiceRewardConfig::class, 'reward_config_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联模型 diceLotteryConfig
|
||||||
|
*/
|
||||||
|
public function diceLotteryConfig(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(DiceLotteryConfig::class, 'lottery_config_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | saiadmin [ saiadmin快速开发框架 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: your name
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace app\dice\validate\play_record;
|
||||||
|
|
||||||
|
use plugin\saiadmin\basic\BaseValidate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家抽奖记录验证器
|
||||||
|
*/
|
||||||
|
class DicePlayRecordValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义验证规则
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'player_id' => 'require',
|
||||||
|
'lottery_config_id' => 'require',
|
||||||
|
'lottery_type' => 'require',
|
||||||
|
'is_win' => 'require',
|
||||||
|
'win_coin' => 'require',
|
||||||
|
'reward_config_id' => 'require',
|
||||||
|
'lottery_id' => 'require',
|
||||||
|
'lottery_name' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义错误信息
|
||||||
|
*/
|
||||||
|
protected $message = [
|
||||||
|
'player_id' => '玩家id必须填写',
|
||||||
|
'lottery_config_id' => '彩金池配置必须填写',
|
||||||
|
'lottery_type' => '抽奖类型必须填写',
|
||||||
|
'is_win' => '中奖必须填写',
|
||||||
|
'win_coin' => '赢取平台币必须填写',
|
||||||
|
'reward_config_id' => '奖励配置id必须填写',
|
||||||
|
'lottery_id' => '奖池必须填写',
|
||||||
|
'lottery_name' => '奖池名必须填写',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义场景
|
||||||
|
*/
|
||||||
|
protected $scene = [
|
||||||
|
'save' => [
|
||||||
|
'player_id',
|
||||||
|
'lottery_config_id',
|
||||||
|
'lottery_type',
|
||||||
|
'is_win',
|
||||||
|
'win_coin',
|
||||||
|
'reward_config_id',
|
||||||
|
'lottery_id',
|
||||||
|
'lottery_name',
|
||||||
|
],
|
||||||
|
'update' => [
|
||||||
|
'player_id',
|
||||||
|
'lottery_config_id',
|
||||||
|
'lottery_type',
|
||||||
|
'is_win',
|
||||||
|
'win_coin',
|
||||||
|
'reward_config_id',
|
||||||
|
'lottery_id',
|
||||||
|
'lottery_name',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user