game用户汇总,优化每日金币统计
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<span class="demonstration">开始时间</span>
|
<span class="demonstration">开始时间</span>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="inquire.time[0]"
|
v-model="inquire.time[0]"
|
||||||
type="datetime"
|
type="dates"
|
||||||
placeholder="开始时间"
|
placeholder="开始时间"
|
||||||
>
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<span class="demonstration">结束时间</span>
|
<span class="demonstration">结束时间</span>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="inquire.time[1]"
|
v-model="inquire.time[1]"
|
||||||
type="datetime"
|
type="dates"
|
||||||
placeholder="结束时间"
|
placeholder="结束时间"
|
||||||
>
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ scope.row.totalDiamond }}
|
{{ formattedNumber(scope.row.totalDiamond) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ scope.row.arDiamond }}
|
{{ formattedNumber(scope.row.arDiamond) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ scope.row.enDiamond }}
|
{{ formattedNumber(scope.row.enDiamond) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ scope.row.zhDiamond }}
|
{{ formattedNumber(scope.row.zhDiamond) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
{{ scope.row.trDiamond }}
|
{{ formattedNumber(scope.row.trDiamond) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -150,6 +150,14 @@
|
|||||||
<el-table-column prop="domainDesc" align="center" label="类型" />
|
<el-table-column prop="domainDesc" align="center" label="类型" />
|
||||||
<el-table-column prop="addDiamond" align="center" label="增加" />
|
<el-table-column prop="addDiamond" align="center" label="增加" />
|
||||||
<el-table-column prop="subDiamond" align="center" label="消耗" />
|
<el-table-column prop="subDiamond" align="center" label="消耗" />
|
||||||
|
<el-table-column prop="subDiamond" align="center" label="留存" >
|
||||||
|
<template #default="row">
|
||||||
|
{{ totalDiamonds(row.row) }}
|
||||||
|
<div v-if="row.row.domainDesc ==='小游戏'">
|
||||||
|
{{ percentage(row.row) }}%
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -189,7 +197,34 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
// this.getData();
|
// this.getData();
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
formattedNumber() {
|
||||||
|
return (num) => {
|
||||||
|
if (num === null || num === undefined) return '';
|
||||||
|
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
totalDiamonds(row) {
|
||||||
|
const subDiamond = Number(row.subDiamond || 0);
|
||||||
|
const addDiamond = Number(row.addDiamond || 0);
|
||||||
|
return subDiamond + addDiamond;
|
||||||
|
},
|
||||||
|
// 计算百分比,防止除零异常
|
||||||
|
percentage(row) {
|
||||||
|
const subDiamond = Number(row.subDiamond || 0);
|
||||||
|
const addDiamond = Number(row.addDiamond || 0);
|
||||||
|
|
||||||
|
if (subDiamond === 0) {
|
||||||
|
return '0.00'; // 防止除零错误
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const result = (addDiamond / subDiamond) * 100;
|
||||||
|
return result.toFixed(2); // 格式化为两位小数
|
||||||
|
},
|
||||||
// 查询
|
// 查询
|
||||||
getData() {
|
getData() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -198,10 +233,10 @@ export default {
|
|||||||
let endTime = null;
|
let endTime = null;
|
||||||
if (time.length > 0) {
|
if (time.length > 0) {
|
||||||
startTime = this.inquire.time[0]
|
startTime = this.inquire.time[0]
|
||||||
? dateFormat(this.inquire.time[0], "yyyy-MM-dd hh:mm:ss")
|
? dateFormat(this.inquire.time[0], "yyyy-MM-dd")
|
||||||
: null;
|
: null;
|
||||||
endTime = this.inquire.time[1]
|
endTime = this.inquire.time[1]
|
||||||
? dateFormat(this.inquire.time[1], "yyyy-MM-dd hh:mm:ss")
|
? dateFormat(this.inquire.time[1], "yyyy-MM-dd")
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
diamondStatList({
|
diamondStatList({
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ export default {
|
|||||||
if (dataTime.value && dataTime.value.length > 0) {
|
if (dataTime.value && dataTime.value.length > 0) {
|
||||||
formData.value.startTime = dateFormat(dataTime.value[0], "yyyy-MM-dd hh:mm:ss");
|
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");
|
formData.value.endTime = dateFormat(dataTime.value[1], "yyyy-MM-dd hh:mm:ss");
|
||||||
|
}else{
|
||||||
|
formData.value.startTime = dataTime.value
|
||||||
|
formData.value.endTime = dataTime.value
|
||||||
}
|
}
|
||||||
const { channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
const { channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
||||||
getGamedata({ channel, endTime, gameId, pageNo, pageSize, partitionId, startTime }).then(res => {
|
getGamedata({ channel, endTime, gameId, pageNo, pageSize, partitionId, startTime }).then(res => {
|
||||||
|
|||||||
257
src/views/gameUserSummary/gameUserSummary.vue
Normal file
257
src/views/gameUserSummary/gameUserSummary.vue
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
<template>
|
||||||
|
<div class="box">
|
||||||
|
<div class="inquire">
|
||||||
|
<span>用户ID</span>
|
||||||
|
<el-input
|
||||||
|
v-model="formData.erbanNoStr"
|
||||||
|
placeholder="请输入用户id,逗号隔开"
|
||||||
|
class="input"
|
||||||
|
></el-input>
|
||||||
|
</div>
|
||||||
|
<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="结束日期" @calendar-change="calendarChange()">
|
||||||
|
</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="channel" align="center" label="第三方名称" />
|
||||||
|
<el-table-column prop="gameName" align="center" label="Game名称" />
|
||||||
|
<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="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>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<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" />
|
||||||
|
</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,
|
||||||
|
getUserGamedata,
|
||||||
|
exportUserForMiniGame
|
||||||
|
} from "@/api/gameSummary/gameSummary";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
export default {
|
||||||
|
name: "gameUserSummary",
|
||||||
|
setup () {
|
||||||
|
const partitionOptions = ref([]);
|
||||||
|
const nameOptions = ref([{ name: '灵', channel: 'LEADERCC' }, { name: '百顺', channel: 'BAISHUN' }]);
|
||||||
|
const gameOptions = ref({});
|
||||||
|
const dataTime = ref('');
|
||||||
|
const formData = ref({
|
||||||
|
erbanNoStr:'',
|
||||||
|
channel: '',
|
||||||
|
partitionId: undefined,
|
||||||
|
gameId: '',
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
startTime: '',
|
||||||
|
endTime: ''
|
||||||
|
});
|
||||||
|
const tableData = ref({
|
||||||
|
dataOuter: [],
|
||||||
|
loadingOuter:false
|
||||||
|
});
|
||||||
|
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;
|
||||||
|
console.log(dataTime.value,'-----------')
|
||||||
|
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");
|
||||||
|
}else{
|
||||||
|
formData.value.startTime = dataTime.value
|
||||||
|
formData.value.endTime = dataTime.value
|
||||||
|
}
|
||||||
|
const { erbanNoStr,channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
||||||
|
getUserGamedata({erbanNoStr, 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, {
|
||||||
|
erbanNoStr:'',
|
||||||
|
channel: '',
|
||||||
|
partitionId: undefined,
|
||||||
|
gameId: '',
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
startTime: '',
|
||||||
|
endTime: ''
|
||||||
|
});
|
||||||
|
tableData.value.dataOuter = [];
|
||||||
|
};
|
||||||
|
// 导出
|
||||||
|
const confirmExport2Excel = async () => {
|
||||||
|
Object.assign(formData.value, { pageSize: 10000, pageNo: 1 });
|
||||||
|
const {erbanNoStr, channel, endTime, gameId, pageNo, pageSize, partitionId, startTime } = formData.value;
|
||||||
|
try {
|
||||||
|
const res = await exportUserForMiniGame({
|
||||||
|
erbanNoStr,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]);
|
||||||
|
alink.href = URL.createObjectURL(blob);
|
||||||
|
document.body.appendChild(alink);
|
||||||
|
alink.click();
|
||||||
|
URL.revokeObjectURL(alink.href);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage({
|
||||||
|
message: error.message,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 || '空';
|
||||||
|
}
|
||||||
|
const calendarChange = () => {
|
||||||
|
console.log()
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
listPartitionInfo().then(res => {
|
||||||
|
partitionOptions.value = res.data;
|
||||||
|
});
|
||||||
|
getGameOptions()
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
partitionOptions,
|
||||||
|
nameOptions,
|
||||||
|
gameOptions,
|
||||||
|
dataTime,
|
||||||
|
formData,
|
||||||
|
tableData,
|
||||||
|
changeEvent,
|
||||||
|
getGameOptions,
|
||||||
|
resetFormData,
|
||||||
|
handleSizeChange,
|
||||||
|
handleCurrentChange,
|
||||||
|
getPartitionDesc,
|
||||||
|
getData,
|
||||||
|
confirmExport2Excel,
|
||||||
|
calendarChange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</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