game汇总
This commit is contained in:
44
src/api/gameSummary/gameSummary.js
Normal file
44
src/api/gameSummary/gameSummary.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request';
|
||||
import {genQueryParam} from "@/utils/maintainer";
|
||||
|
||||
export const gameList = query => {
|
||||
return request({
|
||||
url: '/admin/game/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
export const getGamedata = query => {
|
||||
return request({
|
||||
url: '/admin/gamedata/total',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
// 导出
|
||||
export const exportForMiniGame = query => {
|
||||
return request({
|
||||
url: `/admin/gamedata/total/export`,
|
||||
method: 'post',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
});
|
||||
};
|
||||
|
||||
// 明细
|
||||
export const getUserGamedata = query => {
|
||||
return request({
|
||||
url: '/admin/gamedata/user/total',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
// 导出
|
||||
export const exportUserForMiniGame = query => {
|
||||
return request({
|
||||
url: `/admin/gamedata/user/export`,
|
||||
method: 'post',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
});
|
||||
};
|
334
src/views/gameSummary/GameSummary.vue
Normal file
334
src/views/gameSummary/GameSummary.vue
Normal file
@@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<div class="box">
|
||||
<!-- 查询 -->
|
||||
<div class="inquire">
|
||||
<span>分区</span>
|
||||
<el-select v-model="formData.partitionId" placeholder="请选择">
|
||||
<el-option v-for="item in partitionOptions" :key="item.id" :label="item.desc" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="inquire">
|
||||
<span>第三方名称</span>
|
||||
<el-select v-model="formData.channel" placeholder="请选择" @change="changeEvent">
|
||||
<el-option v-for="item in nameOptions" :key="item.channel" :label="item.name" :value="item.channel">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="inquire" v-if="formData.channel">
|
||||
<span>游戏名称</span>
|
||||
<el-select v-model="formData.gameId" placeholder="请选择">
|
||||
<el-option v-for="item in gameOptions[formData.channel]" :key="item.gameId" :label="item.gameName"
|
||||
:value="item.gameId">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="inquire">
|
||||
<span class="demonstration">日期</span>
|
||||
<el-date-picker v-model="dataTime" type="daterange" range-separator="至" start-placeholder="开始日期"
|
||||
end-placeholder="结束日期">
|
||||
</el-date-picker>
|
||||
</div>
|
||||
<el-button style="" type="primary" @click="getData()">查询</el-button>
|
||||
<el-button class="primary" type="primary" @click="resetFormData()">重置</el-button>
|
||||
<el-button class="primary" type="primary" @click="confirmExport2Excel()">导出</el-button>
|
||||
<!-- 表格数据 -->
|
||||
<el-table v-loading="tableData.loadingOuter" :data="tableData.dataOuter" ref="multipleTable"
|
||||
@selection-change="handleSelectionChange" border style="width: 100%; margin-top: 25px">
|
||||
<el-table-column prop="statDate" align="center" label="日期" />
|
||||
<el-table-column prop="newUsersCount" align="center" label="新用户参与人数" />
|
||||
<el-table-column prop="totalUsersCount" align="center" label="总参与人数" />
|
||||
<el-table-column prop="payGold" align="center" label="投入" />
|
||||
<el-table-column prop="winGold" align="center" label="支出" />
|
||||
<el-table-column prop="totalRemain" align="center" label="剩余" />
|
||||
<el-table-column prop="betRate" align="center" label="比例">
|
||||
<template #default="row">
|
||||
<span>{{ (row.row.betRate * 100).toFixed(2) + '%' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="操作" width="300">
|
||||
<template v-slot="scope">
|
||||
<el-button class="primary" type="primary" @click="
|
||||
detailPageFun(scope.row);
|
||||
" size="default">明细</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<el-pagination style="margin-top: 10px" class="paginationClass" :current-page="formData.pageNo"
|
||||
:page-size="formData.pageSize" :page-sizes="[10, 20, 50, 100, 200]" layout="sizes, prev, pager, next"
|
||||
:total="formData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||
|
||||
<!-- 详情 -->
|
||||
<el-dialog v-model="detailsDialog" title="用户明细" width="70%">
|
||||
<el-button class="primary" type="primary" @click="confirmExport2ExcelTwo()">导出</el-button>
|
||||
|
||||
<!-- 内表格 -->
|
||||
<el-table v-loading="tableData.loadingInner" :data="tableData.dataInner" border
|
||||
style="width: 100%; margin-top: 25px">
|
||||
<el-table-column prop="erbanNo" align="center" label="用户id" />
|
||||
<el-table-column prop="nick" align="center" label="用户昵称" />
|
||||
<el-table-column prop="partitionId" align="center" label="分区">
|
||||
<template #default="row">
|
||||
<span>{{ getPartitionDesc(row.row.partitionId) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="channel" align="center" label="第三方名称" />
|
||||
<el-table-column prop="gameName" align="center" label="游戏名称" />
|
||||
<el-table-column prop="payGold" align="center" label="投入" />
|
||||
<el-table-column prop="winGold" align="center" label="支出" />
|
||||
<el-table-column prop="totalRemain" align="center" label="剩余" />
|
||||
<el-table-column prop="betRate" align="center" label="比例">
|
||||
<template #default="row">
|
||||
<span>{{ (row.row.betRate * 100).toFixed(2) + '%' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 操作 -->
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button type="primary" class="primary" @click="detailsDialog = false">关闭</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { listPartitionInfo } from "@/api/common/partition";
|
||||
import { dateFormat } from "@/utils/system-helper";
|
||||
import { formatDate } from "@/utils/relDate";
|
||||
import {
|
||||
gameList,
|
||||
getGamedata,
|
||||
exportForMiniGame,
|
||||
getUserGamedata,
|
||||
exportUserForMiniGame
|
||||
} from "@/api/gameSummary/gameSummary";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
export default {
|
||||
name: "GameSummary",
|
||||
setup() {
|
||||
const partitionOptions = ref([]);
|
||||
const nameOptions = ref([{ name: '灵', channel: 'LEADERCC' }, { name: '百顺', channel: 'BAISHUN' }]);
|
||||
const gameOptions = ref({});
|
||||
const dataTime = ref('');
|
||||
const formData = ref({
|
||||
channel: '',
|
||||
partitionId: undefined,
|
||||
gameId: '',
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
});
|
||||
const tableData = ref({
|
||||
dataOuter: [],
|
||||
dataInner: [],
|
||||
loadingOuter: false,
|
||||
loadingInner: false
|
||||
});
|
||||
const detailsDialog = ref(false);
|
||||
const exportStatDate = ref('');
|
||||
const changeEvent = () => {
|
||||
formData.value.gameId = gameOptions.value[formData.value.channel][0].gameId;
|
||||
}
|
||||
const getGameOptions = () => {
|
||||
nameOptions.value.forEach(item => {
|
||||
gameList({ channel: item.channel }).then(res => {
|
||||
if (res.code == 200) {
|
||||
gameOptions.value[item.channel] = res.data;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// 查询
|
||||
const getData = () => {
|
||||
tableData.value.loadingOuter = true;
|
||||
if (dataTime.value && dataTime.value.length > 0) {
|
||||
formData.value.startTime = dateFormat(dataTime.value[0], "yyyy-MM-dd hh:mm:ss");
|
||||
formData.value.endTime = dateFormat(dataTime.value[1], "yyyy-MM-dd hh:mm:ss");
|
||||
}
|
||||
const { channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
||||
getGamedata({ channel, endTime, gameId, pageNo, pageSize, partitionId, startTime }).then(res => {
|
||||
if (res.code == 200) {
|
||||
tableData.value.dataOuter = res.data.rows;
|
||||
tableData.value.loadingOuter = false;
|
||||
formData.value.total = res.data.total
|
||||
} else {
|
||||
tableData.value.loadingOuter = false;
|
||||
ElMessage.error(res.message);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
//重置
|
||||
const resetFormData = () => {
|
||||
Object.assign(formData.value, {
|
||||
channel: '',
|
||||
partitionId: undefined,
|
||||
gameId: '',
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
});
|
||||
tableData.value.dataOuter = [];
|
||||
tableData.value.dataInner = [];
|
||||
};
|
||||
// 导出
|
||||
const confirmExport2Excel = async () => {
|
||||
Object.assign(formData.value, { pageSize: 10000, pageNo: 1 });
|
||||
const { channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
||||
try {
|
||||
const res = await exportForMiniGame({
|
||||
channel, endTime, gameId, pageNo, pageSize, partitionId, startTime
|
||||
})
|
||||
if (res) {
|
||||
ElMessage({
|
||||
message: '导出成功',
|
||||
type: 'success',
|
||||
});
|
||||
let time = formatDate(new Date());
|
||||
let alink = document.createElement("a");
|
||||
alink.download = `game汇总${time}.xls`;
|
||||
alink.style.display = "none";
|
||||
const blob = new Blob([res.data]);
|
||||
alink.href = URL.createObjectURL(blob);
|
||||
document.body.appendChild(alink);
|
||||
alink.click();
|
||||
URL.revokeObjectURL(alink.href);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
ElMessage({
|
||||
message: error.message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
}
|
||||
const confirmExport2ExcelTwo = async () => {
|
||||
try {
|
||||
console.log(exportStatDate.value, '-----')
|
||||
const res = await exportUserForMiniGame({
|
||||
channel: formData.value.channel,
|
||||
endTime: exportStatDate.value,
|
||||
startTime: exportStatDate.value,
|
||||
})
|
||||
if (res) {
|
||||
ElMessage({
|
||||
message: '导出成功',
|
||||
type: 'success',
|
||||
});
|
||||
let time = formatDate(new Date());
|
||||
let alink = document.createElement("a");
|
||||
alink.download = `game汇总用户明细${time}.xls`;
|
||||
alink.style.display = "none";
|
||||
const blob = new Blob([res.data]);
|
||||
alink.href = URL.createObjectURL(blob);
|
||||
document.body.appendChild(alink);
|
||||
alink.click();
|
||||
URL.revokeObjectURL(alink.href);
|
||||
exportStatDate.value = ''
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
ElMessage({
|
||||
message: error.message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const detailPageFun = async (row) => {
|
||||
tableData.value.loadingInner = true;
|
||||
exportStatDate.value = row.statDate
|
||||
const res = await getUserGamedata({
|
||||
channel: formData.value.channel,
|
||||
endTime: row.statDate,
|
||||
startTime: row.statDate,
|
||||
})
|
||||
if (res.code == 200) {
|
||||
tableData.value.dataInner = res.data.rows;
|
||||
tableData.value.loadingInner = false;
|
||||
detailsDialog.value = true
|
||||
|
||||
}
|
||||
}
|
||||
const handleSizeChange = (val) => {
|
||||
formData.value.pageSize = val;
|
||||
getData();
|
||||
};
|
||||
const handleCurrentChange = (val) => {
|
||||
formData.value.pageNo = val;
|
||||
getData();
|
||||
};
|
||||
const getPartitionDesc = (partitionId) => {
|
||||
if (!partitionOptions.value || !partitionId) return '空';
|
||||
const item = partitionOptions.value.find(item => item.id === partitionId);
|
||||
return item?.desc || '空';
|
||||
}
|
||||
onMounted(() => {
|
||||
listPartitionInfo().then(res => {
|
||||
partitionOptions.value = res.data;
|
||||
});
|
||||
getGameOptions()
|
||||
});
|
||||
return {
|
||||
partitionOptions,
|
||||
nameOptions,
|
||||
formData,
|
||||
changeEvent,
|
||||
getGameOptions,
|
||||
gameOptions,
|
||||
dataTime,
|
||||
getData,
|
||||
confirmExport2Excel,
|
||||
tableData,
|
||||
resetFormData,
|
||||
detailPageFun,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
detailsDialog,
|
||||
getPartitionDesc,
|
||||
confirmExport2ExcelTwo,
|
||||
exportStatDate
|
||||
};
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.box {
|
||||
padding-top: 20px;
|
||||
background: #ecf0f5;
|
||||
|
||||
.inquire {
|
||||
display: inline-block;
|
||||
margin-right: 20px;
|
||||
|
||||
span {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 180px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.dialogTableVisibleBut {
|
||||
display: block;
|
||||
margin: 30px 0 0 830px;
|
||||
}
|
||||
|
||||
.paginationClass {
|
||||
margin: 15px 0 5px 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user