1.新增游戏管理接口和菜单
2.创建对接第三方文档
This commit is contained in:
40
saiadmin-artd/src/views/plugin/dice/api/game/index.ts
Normal file
40
saiadmin-artd/src/views/plugin/dice/api/game/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/game/DiceGame/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/game/DiceGame/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
save(params: Record<string, unknown>) {
|
||||
return request.post({
|
||||
url: '/core/dice/game/DiceGame/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
update(params: Record<string, unknown>) {
|
||||
return request.put({
|
||||
url: '/core/dice/game/DiceGame/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
delete(params: Record<string, unknown>) {
|
||||
return request.del({
|
||||
url: '/core/dice/game/DiceGame/destroy',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
}
|
||||
141
saiadmin-artd/src/views/plugin/dice/game/index/index.vue
Normal file
141
saiadmin-artd/src/views/plugin/dice/game/index/index.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<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:game:index:save'" @click="showDialog('add')" v-ripple>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:game: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 #status="{ row }">
|
||||
<ElTag :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '禁用' }}</ElTag>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:game:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:game: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/game/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
const searchForm = ref({
|
||||
provider_code: undefined,
|
||||
game_code: undefined,
|
||||
game_type: undefined,
|
||||
status: 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', align: 'center' },
|
||||
{ prop: 'id', label: 'ID', width: 80, align: 'center' },
|
||||
{ prop: 'provider', label: '供应商', minWidth: 120, align: 'center' },
|
||||
{ prop: 'provider_code', label: '供应商编码', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_code', label: '游戏编号', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_key', label: '游戏唯一值', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_name', label: '中文名', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_name_en', label: '英文名', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_type', label: '类型', minWidth: 90, align: 'center' },
|
||||
{ prop: 'sort', label: '排序', width: 80, align: 'center' },
|
||||
{ prop: 'status', label: '状态', width: 90, align: 'center', useSlot: true },
|
||||
{ prop: 'update_time', label: '更新时间', minWidth: 160, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
@@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增游戏' : '编辑游戏'"
|
||||
width="680px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="供应商" prop="provider">
|
||||
<el-input v-model="formData.provider" placeholder="请输入供应商名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="供应商编码" prop="provider_code">
|
||||
<el-input v-model="formData.provider_code" placeholder="请输入供应商编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏编号" prop="game_code">
|
||||
<el-input v-model="formData.game_code" placeholder="请输入游戏编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏唯一值" prop="game_key">
|
||||
<el-input v-model="formData.game_key" placeholder="请输入游戏唯一值" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="中文名称" prop="game_name">
|
||||
<el-input v-model="formData.game_name" placeholder="请输入中文名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="英文名称" prop="game_name_en">
|
||||
<el-input v-model="formData.game_name_en" placeholder="请输入英文名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏类型" prop="game_type">
|
||||
<el-input v-model="formData.game_type" placeholder="请输入游戏类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="Logo地址" prop="logo">
|
||||
<el-tabs v-model="logoInputMode" class="w-full">
|
||||
<el-tab-pane label="图片选择" name="picker">
|
||||
<sa-image-picker
|
||||
v-model="formData.logo"
|
||||
:multiple="false"
|
||||
:limit="1"
|
||||
width="120px"
|
||||
height="120px"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="图片上传" name="upload">
|
||||
<sa-image-upload
|
||||
v-model="formData.logo"
|
||||
:multiple="false"
|
||||
:limit="1"
|
||||
:max-size="5"
|
||||
:show-tips="true"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-form-item>
|
||||
<el-form-item label="游戏地址" prop="game_url">
|
||||
<el-input v-model="formData.game_url" placeholder="请输入游戏地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="大厅地址" prop="hall_url">
|
||||
<el-input v-model="formData.hall_url" placeholder="请输入大厅地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio :value="1">启用</el-radio>
|
||||
<el-radio :value="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="2" 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/game/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
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 logoInputMode = ref<'picker' | 'upload'>('picker')
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
type GameFormData = {
|
||||
id: number | null
|
||||
provider: string
|
||||
provider_code: string
|
||||
game_code: string
|
||||
game_key: string
|
||||
game_name: string
|
||||
game_name_en: string
|
||||
game_type: string
|
||||
logo: string
|
||||
game_url: string
|
||||
hall_url: string
|
||||
status: number
|
||||
sort: number
|
||||
remark: string
|
||||
}
|
||||
|
||||
const initialFormData: GameFormData = {
|
||||
id: null,
|
||||
provider: 'Dicey Fun',
|
||||
provider_code: 'DF',
|
||||
game_code: '',
|
||||
game_key: '',
|
||||
game_name: '',
|
||||
game_name_en: '',
|
||||
game_type: 'slot',
|
||||
logo: '',
|
||||
game_url: '',
|
||||
hall_url: '',
|
||||
status: 1,
|
||||
sort: 100,
|
||||
remark: ''
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
provider: [{ required: true, message: '请输入供应商', trigger: 'blur' }],
|
||||
provider_code: [{ required: true, message: '请输入供应商编码', trigger: 'blur' }],
|
||||
game_code: [{ required: true, message: '请输入游戏编号', trigger: 'blur' }],
|
||||
game_key: [{ required: true, message: '请输入游戏唯一值', trigger: 'blur' }],
|
||||
game_name: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
|
||||
game_type: [{ required: true, message: '请输入游戏类型', trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
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.provider === 'string') formData.provider = props.data.provider
|
||||
if (typeof props.data.provider_code === 'string') formData.provider_code = props.data.provider_code
|
||||
if (typeof props.data.game_code === 'string') formData.game_code = props.data.game_code
|
||||
if (typeof props.data.game_key === 'string') formData.game_key = props.data.game_key
|
||||
if (typeof props.data.game_name === 'string') formData.game_name = props.data.game_name
|
||||
if (typeof props.data.game_name_en === 'string') formData.game_name_en = props.data.game_name_en
|
||||
if (typeof props.data.game_type === 'string') formData.game_type = props.data.game_type
|
||||
if (typeof props.data.logo === 'string') formData.logo = props.data.logo
|
||||
if (typeof props.data.game_url === 'string') formData.game_url = props.data.game_url
|
||||
if (typeof props.data.hall_url === 'string') formData.hall_url = props.data.hall_url
|
||||
formData.status = Number(props.data.status ?? 1) === 1 ? 1 : 0
|
||||
const sortValue = Number(props.data.sort ?? 100)
|
||||
formData.sort = Number.isFinite(sortValue) ? sortValue : 100
|
||||
if (typeof props.data.remark === 'string') formData.remark = props.data.remark
|
||||
}
|
||||
)
|
||||
|
||||
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('新增成功')
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('更新成功')
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,81 @@
|
||||
<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="供应商编码" prop="provider_code">
|
||||
<el-input v-model="formData.provider_code" placeholder="请输入供应商编码" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="游戏编号" prop="game_code">
|
||||
<el-input v-model="formData.game_code" placeholder="请输入游戏编号" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="游戏类型" prop="game_type">
|
||||
<el-input v-model="formData.game_type" placeholder="请输入游戏类型" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type GameSearchForm = {
|
||||
provider_code?: string
|
||||
game_code?: string
|
||||
game_type?: string
|
||||
status?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: GameSearchForm
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: GameSearchForm): void
|
||||
(e: 'search', params: GameSearchForm): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed<GameSearchForm>({
|
||||
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>
|
||||
@@ -5,6 +5,7 @@ namespace app\api\controller\v1;
|
||||
|
||||
use app\api\logic\UserLogic;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\dice\model\game\DiceGame;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
@@ -22,6 +23,53 @@ use app\api\cache\UserCache;
|
||||
*/
|
||||
class GameController extends BaseController
|
||||
{
|
||||
private const GAME_PUBLIC_FIELDS = [
|
||||
'provider',
|
||||
'provider_code',
|
||||
'game_code',
|
||||
'game_key',
|
||||
'game_type',
|
||||
'logo',
|
||||
'game_url',
|
||||
'hall_url',
|
||||
'status',
|
||||
'sort',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取游戏列表
|
||||
* POST 参数:lang(可选,zh/en,默认 zh)
|
||||
* 当前返回启用中的游戏列表
|
||||
*/
|
||||
public function getGameList(Request $request): Response
|
||||
{
|
||||
$lang = $this->resolveLang($request->post('lang', 'zh'));
|
||||
$games = $this->buildPublicGameList($lang);
|
||||
return $this->success([
|
||||
'game_list' => $games,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏大厅信息(脱敏)
|
||||
* POST 参数:lang(可选,zh/en,默认 zh)
|
||||
*/
|
||||
public function getGameHall(Request $request): Response
|
||||
{
|
||||
$lang = $this->resolveLang($request->post('lang', 'zh'));
|
||||
$games = $this->buildPublicGameList($lang);
|
||||
$hallUrl = '';
|
||||
if (!empty($games)) {
|
||||
$hallUrl = $games[0]['hall_url'] ?? '';
|
||||
}
|
||||
return $this->success([
|
||||
'provider' => 'Dicey Fun',
|
||||
'provider_code' => 'DF',
|
||||
'hall_url' => $hallUrl,
|
||||
'game_list' => $games,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏地址
|
||||
* 根据 username 创建登录 token(JWT),拼接游戏地址返回
|
||||
@@ -310,4 +358,41 @@ class GameController extends BaseController
|
||||
$recordArr['dice_player'] = ['id' => (int) $player->id, 'username' => $player->username ?? '', 'phone' => $player->phone ?? ''];
|
||||
return $this->success($recordArr);
|
||||
}
|
||||
|
||||
private function resolveLang($lang): string
|
||||
{
|
||||
if (!is_string($lang)) {
|
||||
return 'zh';
|
||||
}
|
||||
$langValue = strtolower(trim($lang));
|
||||
if (!in_array($langValue, ['zh', 'en'], true)) {
|
||||
return 'zh';
|
||||
}
|
||||
return $langValue;
|
||||
}
|
||||
|
||||
private function buildPublicGameList(string $lang): array
|
||||
{
|
||||
$rows = DiceGame::where('status', 1)
|
||||
->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc')
|
||||
->select(array_merge(self::GAME_PUBLIC_FIELDS, ['game_name', 'game_name_en']))
|
||||
->get()
|
||||
->toArray();
|
||||
if (empty($rows)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$games = [];
|
||||
foreach ($rows as $row) {
|
||||
$game = [];
|
||||
foreach (self::GAME_PUBLIC_FIELDS as $fieldName) {
|
||||
$game[$fieldName] = $row[$fieldName] ?? '';
|
||||
}
|
||||
$gameNameEn = $row['game_name_en'] ?? '';
|
||||
$game['game_name'] = $lang === 'en' && $gameNameEn !== '' ? $gameNameEn : ($row['game_name'] ?? '');
|
||||
$games[] = $game;
|
||||
}
|
||||
return $games;
|
||||
}
|
||||
}
|
||||
|
||||
89
server/app/dice/controller/game/DiceGameController.php
Normal file
89
server/app/dice/controller/game/DiceGameController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\game;
|
||||
|
||||
use app\dice\logic\game\DiceGameLogic;
|
||||
use app\dice\validate\game\DiceGameValidate;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 游戏管理控制器
|
||||
*/
|
||||
class DiceGameController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceGameLogic();
|
||||
$this->validate = new DiceGameValidate();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[Permission('游戏管理列表', 'dice:game:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['provider_code', ''],
|
||||
['game_code', ''],
|
||||
['game_type', ''],
|
||||
['status', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('游戏管理读取', 'dice:game:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('游戏管理添加', 'dice:game:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if (!$result) {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
return $this->success('add success');
|
||||
}
|
||||
|
||||
#[Permission('游戏管理修改', 'dice:game: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->fail('update failed');
|
||||
}
|
||||
return $this->success('update success');
|
||||
}
|
||||
|
||||
#[Permission('游戏管理删除', 'dice:game:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if ($ids === '' || $ids === null) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if (!$result) {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
return $this->success('delete success');
|
||||
}
|
||||
}
|
||||
19
server/app/dice/logic/game/DiceGameLogic.php
Normal file
19
server/app/dice/logic/game/DiceGameLogic.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\game;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseLogic;
|
||||
use app\dice\model\game\DiceGame;
|
||||
|
||||
/**
|
||||
* 游戏管理逻辑层
|
||||
*/
|
||||
class DiceGameLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceGame();
|
||||
}
|
||||
}
|
||||
53
server/app/dice/model/game/DiceGame.php
Normal file
53
server/app/dice/model/game/DiceGame.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\game;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
|
||||
/**
|
||||
* 游戏管理模型
|
||||
*
|
||||
* dice_game 游戏配置表
|
||||
*/
|
||||
class DiceGame extends BaseModel
|
||||
{
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $table = 'dice_game';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
public function searchProviderCodeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('provider_code', '=', $value);
|
||||
}
|
||||
|
||||
public function searchGameCodeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('game_code', 'like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
public function searchGameTypeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('game_type', '=', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('status', '=', $value);
|
||||
}
|
||||
}
|
||||
61
server/app/dice/validate/game/DiceGameValidate.php
Normal file
61
server/app/dice/validate/game/DiceGameValidate.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\game;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 游戏管理验证器
|
||||
*/
|
||||
class DiceGameValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'provider' => 'require|max:64',
|
||||
'provider_code' => 'require|max:32',
|
||||
'game_code' => 'require|max:64',
|
||||
'game_key' => 'require|max:64',
|
||||
'game_name' => 'require|max:128',
|
||||
'game_name_en' => 'max:128',
|
||||
'game_type' => 'require|max:32',
|
||||
'status' => 'require|in:0,1',
|
||||
'sort' => 'number',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'provider' => 'provider 必填',
|
||||
'provider_code' => 'provider_code 必填',
|
||||
'game_code' => 'game_code 必填',
|
||||
'game_key' => 'game_key 必填',
|
||||
'game_name' => 'game_name 必填',
|
||||
'game_type' => 'game_type 必填',
|
||||
'status' => 'status 仅支持 0 或 1',
|
||||
'sort' => 'sort 必须为数字',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'provider',
|
||||
'provider_code',
|
||||
'game_code',
|
||||
'game_key',
|
||||
'game_name',
|
||||
'game_name_en',
|
||||
'game_type',
|
||||
'status',
|
||||
'sort',
|
||||
],
|
||||
'update' => [
|
||||
'provider',
|
||||
'provider_code',
|
||||
'game_code',
|
||||
'game_key',
|
||||
'game_name',
|
||||
'game_name_en',
|
||||
'game_type',
|
||||
'status',
|
||||
'sort',
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -23,6 +23,8 @@ Route::group('/api/v1', function () {
|
||||
|
||||
// 平台 v1 接口:需在请求头携带 auth-token
|
||||
Route::group('/api/v1', function () {
|
||||
Route::any('/getGameList', [app\api\controller\v1\GameController::class, 'getGameList']);
|
||||
Route::any('/getGameHall', [app\api\controller\v1\GameController::class, 'getGameHall']);
|
||||
Route::any('/getGameUrl', [app\api\controller\v1\GameController::class, 'getGameUrl']);
|
||||
Route::any('/getPlayerInfo', [app\api\controller\v1\GameController::class, 'getPlayerInfo']);
|
||||
Route::any('/getPlayerGameRecord', [app\api\controller\v1\GameController::class, 'getPlayerGameRecord']);
|
||||
|
||||
535
server/docs/DICEY_FUN_THIRD_PARTY_ACCESS.md
Normal file
535
server/docs/DICEY_FUN_THIRD_PARTY_ACCESS.md
Normal file
@@ -0,0 +1,535 @@
|
||||
# Dicey Fun 第三方接入文档(基于现有项目接口)
|
||||
|
||||
## 1. 基础信息
|
||||
|
||||
- provider: `Dicey Fun`
|
||||
- provider_code: `DF`
|
||||
- game_type: `slot`
|
||||
- game_list: `["dafuwen"]`
|
||||
- provider_logo: ``
|
||||
- 获取大厅地址: `https://dice-v3-lobby.yuliao666.top`
|
||||
- 后台管理地址: `https://dice-v3.yuliao666.top/`
|
||||
- agent_token: `[我来填]`
|
||||
- agent_id: `5ef059938ba799aaa845e1c2e8a762bd`
|
||||
|
||||
## 2. 接口域名与协议
|
||||
|
||||
- 协议: `HTTP/HTTPS`(建议生产使用 `HTTPS`)
|
||||
- Base URL: `https://{your-domain}`(由部署方提供)
|
||||
- 数据格式: `application/json`
|
||||
- 字符编码: `UTF-8`
|
||||
|
||||
### 2.1 调用规范(建议第三方按此统一实现)
|
||||
|
||||
- `/api/v1/authToken` 使用 `GET + Query 参数`
|
||||
- 其他 `/api/v1/*` 接口使用 `POST + JSON Body`(本项目路由为 `Route::any`,但建议第三方统一按 `POST` 接入)
|
||||
- 请求头统一:
|
||||
- `Content-Type: application/json`
|
||||
- `Accept: application/json`
|
||||
- `auth-token: {authtoken}`(除 `/api/v1/authToken` 外必传)
|
||||
- 时间相关参数统一使用 Unix 时间戳(秒)
|
||||
- 建议所有请求设置超时:连接超时 `3s`,读取超时 `10s`
|
||||
- 生产环境建议增加调用方 IP 白名单和重试退避机制(避免瞬时重试风暴)
|
||||
|
||||
---
|
||||
|
||||
## 3. 通用返回格式
|
||||
|
||||
所有接口统一返回:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
- `code=200` 表示成功
|
||||
- 失败时通常返回:`400/401/402/403/404/422/500`
|
||||
|
||||
常见错误码:
|
||||
|
||||
- `400` 参数错误
|
||||
- `401` 未携带 token
|
||||
- `402` token 无效或过期
|
||||
- `403` 签名或鉴权失败
|
||||
- `404` 资源不存在
|
||||
- `422` 业务错误(如余额不足)
|
||||
- `500` 服务端异常
|
||||
|
||||
---
|
||||
|
||||
## 4. 鉴权流程(平台级)
|
||||
|
||||
`/api/v1/*` 接口调用前,先获取 `auth-token`。
|
||||
|
||||
### 4.1 获取 auth-token
|
||||
|
||||
- 路径: `GET /api/v1/authToken`
|
||||
- 鉴权参数(Query):
|
||||
- `agent_id`:代理标识(商户标识)
|
||||
- `secret`:双方约定密钥
|
||||
- `time`:Unix 时间戳(秒)
|
||||
- `signature`:签名
|
||||
|
||||
签名规则:
|
||||
|
||||
```text
|
||||
signature = md5(agent_id + secret + time)
|
||||
```
|
||||
|
||||
签名示例(原串与结果):
|
||||
|
||||
```text
|
||||
agent_id = 9f86d081884c7d659a2feaa0c55ad015
|
||||
secret = xF75oK91TQj13s0UmNIr1NBWMWGfflNO
|
||||
time = 1713753600
|
||||
sign_src = 9f86d081884c7d659a2feaa0c55ad015xF75oK91TQj13s0UmNIr1NBWMWGfflNO1713753600
|
||||
signature= md5(sign_src)
|
||||
```
|
||||
|
||||
PHP 生成签名示例:
|
||||
|
||||
```php
|
||||
$agentId = '9f86d081884c7d659a2feaa0c55ad015';
|
||||
$secret = 'xF75oK91TQj13s0UmNIr1NBWMWGfflNO';
|
||||
$time = (string) time();
|
||||
$signature = md5($agentId . $secret . $time);
|
||||
```
|
||||
|
||||
JavaScript 生成签名示例(Node.js):
|
||||
|
||||
```javascript
|
||||
const crypto = require('crypto');
|
||||
|
||||
const agentId = '9f86d081884c7d659a2feaa0c55ad015';
|
||||
const secret = 'xF75oK91TQj13s0UmNIr1NBWMWGfflNO';
|
||||
const time = Math.floor(Date.now() / 1000).toString();
|
||||
const signature = crypto.createHash('md5').update(agentId + secret + time).digest('hex');
|
||||
```
|
||||
|
||||
服务端校验逻辑(关键点):
|
||||
|
||||
- `agent_id/secret/time/signature` 任一缺失即失败(`400`)
|
||||
- `secret` 不匹配即失败(`403`)
|
||||
- `time` 超出容差窗口即失败(`403`,默认容差 `300s`)
|
||||
- `signature` 校验失败即失败(`403`)
|
||||
- 校验通过后颁发 `authtoken`,后续请求必须放在 Header `auth-token`
|
||||
|
||||
防重放与时间同步建议:
|
||||
|
||||
- 调用方服务器必须启用 NTP 时间同步
|
||||
- `time` 使用发起请求时的当前秒级时间戳,不要复用旧值
|
||||
- 遇到 “Timestamp expired or invalid” 时优先检查服务器时间偏差
|
||||
|
||||
成功返回示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"authtoken": "xxx.yyy.zzz"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
后续调用 `/api/v1/*` 时,请在 Header 携带:
|
||||
|
||||
```text
|
||||
auth-token: {authtoken}
|
||||
```
|
||||
|
||||
### 4.2 完整调用链(推荐)
|
||||
|
||||
1. 计算 `signature = md5(agent_id + secret + time)`
|
||||
2. 调用 `GET /api/v1/authToken` 获取 `authtoken`
|
||||
3. 在 Header 添加 `auth-token: {authtoken}`
|
||||
4. 调用业务接口(如 `getPlayerInfo`、`setPlayerWallet`、`getGameUrl`)
|
||||
5. 若返回 `402`,重新获取 `authtoken` 后重试一次
|
||||
|
||||
---
|
||||
|
||||
## 5. 游戏相关接口
|
||||
|
||||
以下接口均需 Header: `auth-token`。
|
||||
|
||||
## 5.1 获取游戏列表(已支持)
|
||||
|
||||
- 路径: `POST /api/v1/getGameList`
|
||||
- Header:
|
||||
- `auth-token: {authtoken}`
|
||||
- Body 参数:
|
||||
- `lang`(可选):`zh`/`en`,默认 `zh`
|
||||
- 返回说明:
|
||||
- 从 `dice_game` 表读取启用状态(`status=1`)的游戏
|
||||
- 当前默认仅返回一个游戏:`dafuwen`
|
||||
- 按 `lang` 返回中英文 `game_name`
|
||||
- 已做字段脱敏:不会返回敏感配置(如 `sensitive_config_json`)
|
||||
|
||||
返回字段(`data.game_list[]`):
|
||||
|
||||
- `provider`:供应商名称
|
||||
- `provider_code`:供应商编码
|
||||
- `game_code`:游戏编号
|
||||
- `game_key`:游戏唯一值
|
||||
- `game_type`:游戏类型
|
||||
- `logo`:游戏 Logo 地址
|
||||
- `game_url`:游戏地址
|
||||
- `hall_url`:大厅地址
|
||||
- `status`:状态(`1` 启用)
|
||||
- `sort`:排序值
|
||||
- `game_name`:游戏名称(跟随 `lang` 返回中文或英文)
|
||||
|
||||
成功返回示例(`lang=zh`):
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"game_list": [
|
||||
{
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"game_code": "dafuwen",
|
||||
"game_key": "dafuwen",
|
||||
"game_type": "slot",
|
||||
"logo": "",
|
||||
"game_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"status": 1,
|
||||
"sort": 1,
|
||||
"game_name": "大富翁"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
成功返回示例(`lang=en`):
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"game_list": [
|
||||
{
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"game_code": "dafuwen",
|
||||
"game_key": "dafuwen",
|
||||
"game_type": "slot",
|
||||
"logo": "",
|
||||
"game_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"status": 1,
|
||||
"sort": 1,
|
||||
"game_name": "Dafuweng"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5.2 获取游戏大厅信息(已支持,脱敏)
|
||||
|
||||
- 路径: `POST /api/v1/getGameHall`
|
||||
- Header:
|
||||
- `auth-token: {authtoken}`
|
||||
- Body 参数:
|
||||
- `lang`(可选):`zh`/`en`,默认 `zh`
|
||||
- 返回说明:
|
||||
- 返回大厅地址 `hall_url`
|
||||
- 返回游戏列表(来自 `dice_game`)
|
||||
- 不返回敏感信息字段
|
||||
|
||||
返回字段:
|
||||
|
||||
- `data.provider`:供应商名称
|
||||
- `data.provider_code`:供应商编码
|
||||
- `data.hall_url`:大厅地址
|
||||
- `data.game_list`:游戏列表(字段结构同 `/api/v1/getGameList`)
|
||||
|
||||
成功返回示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"game_list": [
|
||||
{
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"game_code": "dafuwen",
|
||||
"game_key": "dafuwen",
|
||||
"game_type": "slot",
|
||||
"logo": "",
|
||||
"game_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"status": 1,
|
||||
"sort": 1,
|
||||
"game_name": "大富翁"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
成功返回示例(`lang=en`):
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"game_list": [
|
||||
{
|
||||
"provider": "Dicey Fun",
|
||||
"provider_code": "DF",
|
||||
"game_code": "dafuwen",
|
||||
"game_key": "dafuwen",
|
||||
"game_type": "slot",
|
||||
"logo": "",
|
||||
"game_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"hall_url": "https://dice-v3-game.yuliao666.top/",
|
||||
"status": 1,
|
||||
"sort": 1,
|
||||
"game_name": "Dafuweng"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5.3 获取某个游戏地址(已支持)
|
||||
|
||||
- 路径: `POST /api/v1/getGameUrl`
|
||||
- Body 参数:
|
||||
- `username`(必填):玩家账号(不存在会自动创建)
|
||||
- `password`(可选):默认 `123456`
|
||||
- `time`(可选):不传则服务端取当前时间戳
|
||||
- `lang`(可选):`zh`/`en`,默认 `zh`
|
||||
|
||||
成功返回示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"url": "https://{game-domain}/?token=...&lang=zh"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 5.4 获取大厅地址(当前项目建议)
|
||||
|
||||
当前项目以 `getGameUrl` 作为主要入场方式,`game_list` 仅有 `dafuwen`。
|
||||
|
||||
- 若第三方需要独立大厅地址,可使用你方配置值:`[代填]`
|
||||
- 若第三方可直接跳游戏,可直接调用 `getGameUrl`
|
||||
|
||||
### 5.5 获取游戏列表 API(当前项目状态)
|
||||
|
||||
已提供独立接口:`POST /api/v1/getGameList`,支持中英文格式,且数据来自 `dice_game` 表。
|
||||
|
||||
---
|
||||
|
||||
## 6. 游戏管理后台(新增)
|
||||
|
||||
本次已新增游戏管理数据表与菜单,用于统一管理游戏基础信息。
|
||||
|
||||
### 6.1 数据表
|
||||
|
||||
- 建表 SQL:`server/db/dice_game.sql`
|
||||
- 表名:`dice_game`
|
||||
- 关键字段:
|
||||
- `logo`:游戏 logo
|
||||
- `game_url`:游戏地址
|
||||
- `hall_url`:大厅地址
|
||||
- `game_code`:游戏编号
|
||||
- `game_key`:游戏唯一值
|
||||
- `status`:状态(1 启用 / 0 禁用)
|
||||
- `game_type`:游戏类型
|
||||
- `merchant_config_json`:商户可见扩展
|
||||
- `sensitive_config_json`:敏感配置(大厅接口不返回)
|
||||
|
||||
### 6.2 菜单与权限
|
||||
|
||||
- 菜单 SQL:`server/db/dice_game_menu.sql`
|
||||
- 菜单路径:`/dice/game/index`
|
||||
- 权限标识:
|
||||
- `dice:game:index:index`
|
||||
- `dice:game:index:read`
|
||||
- `dice:game:index:save`
|
||||
- `dice:game:index:update`
|
||||
- `dice:game:index:destroy`
|
||||
|
||||
---
|
||||
|
||||
## 7. 钱包相关接口
|
||||
|
||||
以下接口均需 Header: `auth-token`。
|
||||
|
||||
### 7.1 查询余额(已支持)
|
||||
|
||||
方式 1(推荐):`POST /api/v1/getPlayerInfo`
|
||||
|
||||
- 请求参数:
|
||||
- `username`(必填)
|
||||
- 余额字段:
|
||||
- `data.coin`
|
||||
|
||||
### 7.2 额度转入 / 额度转出(已支持)
|
||||
|
||||
接口:`POST /api/v1/setPlayerWallet`
|
||||
|
||||
- 请求参数:
|
||||
- `username`(必填)
|
||||
- `coin`(必填)
|
||||
- `coin > 0`:额度转入(充值)
|
||||
- `coin < 0`:额度转出(提现)
|
||||
- `coin = 0`:非法
|
||||
|
||||
成功返回 `wallet record`,包含转账前后余额等信息。
|
||||
|
||||
### 7.3 获取大厅地址(钱包侧)
|
||||
|
||||
如接入方钱包流程要求“转账后返回大厅地址”,可在完成 `setPlayerWallet` 后再调用:
|
||||
|
||||
- `POST /api/v1/getGameUrl`
|
||||
|
||||
---
|
||||
|
||||
## 8. 商户(代理)可配置字段
|
||||
|
||||
建议在对接参数表中配置以下字段:
|
||||
|
||||
- `provider`:`Dicey Fun`
|
||||
- `provider_code`:`DF`
|
||||
- `agent_id`:`5ef059938ba799aaa845e1c2e8a762bd`
|
||||
- `secret`:签名密钥(双方约定)
|
||||
- `agent_token`:`[我来填]`(如需额外业务层 token)
|
||||
- `game_url`:游戏前端域名/地址
|
||||
- `lobby_url`:大厅地址(可选)
|
||||
- `lang`:默认语言(`zh`/`en`)
|
||||
- `callback_url`:业务回调地址(如后续扩展)
|
||||
- `ip_whitelist`:调用白名单(建议)
|
||||
|
||||
---
|
||||
|
||||
## 9. 后台管理信息
|
||||
|
||||
- 后台管理地址:`https://dice-v3.yuliao666.top/`
|
||||
- 后台账号:`zhuguan`
|
||||
- 后台密码:`qwer1234`
|
||||
|
||||
---
|
||||
|
||||
## 10. 对接时序(建议)
|
||||
|
||||
1. 平台分配 `agent_id`、`secret`
|
||||
2. 第三方调用 `/api/v1/authToken` 获取 `authtoken`
|
||||
3. 第三方调用 `/api/v1/getGameHall` 或 `/api/v1/getGameList` 获取大厅/游戏信息
|
||||
4. 第三方调用 `/api/v1/getPlayerInfo`(可选,检查用户与余额)
|
||||
5. 第三方调用 `/api/v1/setPlayerWallet` 进行额度转入(如有)
|
||||
6. 第三方调用 `/api/v1/getGameUrl` 获取游戏地址并跳转
|
||||
7. 结束后调用 `/api/v1/setPlayerWallet` 执行额度转出(如有)
|
||||
|
||||
---
|
||||
|
||||
## 11. Postman 调用示例
|
||||
|
||||
### 11.1 获取 auth-token
|
||||
|
||||
```bash
|
||||
curl --location --request GET 'https://{your-domain}/api/v1/authToken?agent_id={agent_id}&secret={secret}&time={time}&signature={signature}'
|
||||
```
|
||||
|
||||
建议在接入测试时,先本地打印以下值再发请求,便于排查:
|
||||
|
||||
- `agent_id`
|
||||
- `time`
|
||||
- `sign_src`(拼接前字符串)
|
||||
- `signature`
|
||||
- 最终请求 URL
|
||||
|
||||
### 11.2 获取游戏地址
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/getGameUrl' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"username":"test_player_001",
|
||||
"lang":"zh"
|
||||
}'
|
||||
```
|
||||
|
||||
### 11.3 获取游戏列表(中文)
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/getGameList' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"lang":"zh"
|
||||
}'
|
||||
```
|
||||
|
||||
### 11.4 获取游戏列表(英文)
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/getGameList' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"lang":"en"
|
||||
}'
|
||||
```
|
||||
|
||||
### 11.5 获取游戏大厅(中文)
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/getGameHall' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"lang":"zh"
|
||||
}'
|
||||
```
|
||||
|
||||
### 11.6 额度转入
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/setPlayerWallet' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"username":"test_player_001",
|
||||
"coin":100
|
||||
}'
|
||||
```
|
||||
|
||||
### 11.7 查询余额
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{your-domain}/api/v1/getPlayerInfo' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'auth-token: {authtoken}' \
|
||||
--data-raw '{
|
||||
"username":"test_player_001"
|
||||
}'
|
||||
```
|
||||
@@ -117,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/game/DiceGame', \app\dice\controller\game\DiceGameController::class);
|
||||
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']);
|
||||
|
||||
42
server/scripts/gen_auth_token_signature.php
Normal file
42
server/scripts/gen_auth_token_signature.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 生成 /api/v1/authToken(或 /api/v1/authtoken)所需 signature
|
||||
*
|
||||
* 用法:
|
||||
* php scripts/gen_auth_token_signature.php --agent_id=1001 --secret=your_secret
|
||||
* php scripts/gen_auth_token_signature.php --agent_id=1001 --secret=your_secret --time=1713772800
|
||||
*/
|
||||
|
||||
$options = getopt('', ['agent_id:', 'secret:', 'time::']);
|
||||
|
||||
$agentId = $options['agent_id'] ?? '';
|
||||
$secret = $options['secret'] ?? '';
|
||||
$time = $options['time'] ?? (string) time();
|
||||
|
||||
if ($agentId === '' || $secret === '' || $time === '') {
|
||||
echo "缺少参数。\n";
|
||||
echo "用法: php scripts/gen_auth_token_signature.php --agent_id=1001 --secret=your_secret [--time=unix_timestamp]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ctype_digit($time) === false) {
|
||||
echo "time 必须是 unix 时间戳(纯数字字符串)。\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$signature = md5($agentId . $secret . $time);
|
||||
$query = http_build_query([
|
||||
'agent_id' => $agentId,
|
||||
'secret' => $secret,
|
||||
'time' => $time,
|
||||
'signature' => $signature,
|
||||
]);
|
||||
|
||||
echo "agent_id: {$agentId}\n";
|
||||
echo "secret: {$secret}\n";
|
||||
echo "time: {$time}\n";
|
||||
echo "signature: {$signature}\n";
|
||||
echo "query: {$query}\n";
|
||||
|
||||
@@ -43,7 +43,6 @@ $fallbackCn = [
|
||||
'添加失败' => 'add failed',
|
||||
'修改失败' => 'update failed',
|
||||
'删除失败' => 'delete failed',
|
||||
'请选择要删除的数据' => 'please select data to delete',
|
||||
'参数错误,请检查' => 'invalid parameters, please check',
|
||||
'参数错误,请检查参数' => 'invalid parameters, please check',
|
||||
'操作失败' => 'operation failed',
|
||||
|
||||
Reference in New Issue
Block a user