gm后台添加金流日志

This commit is contained in:
liuxiaobo 2025-06-25 23:59:33 +08:00
parent ef253158e4
commit 04d2adf592
4 changed files with 74 additions and 30 deletions

View File

@ -20,7 +20,6 @@
"/src/view/example/upload/upload.vue": "Upload",
"/src/view/gameuser/addResourceDialog.vue": "AddResourceDialog",
"/src/view/gameuser/index.vue": "Index",
"/src/view/gameuser/logResource.vue": "LogResource",
"/src/view/init/index.vue": "Init",
"/src/view/layout/aside/asideComponent/asyncSubmenu.vue": "AsyncSubmenu",
"/src/view/layout/aside/asideComponent/index.vue": "AsideComponent",

View File

@ -3,12 +3,12 @@
<el-form :inline="true" class="demo-form-inline">
<!-- 用户ID输入框按您要求放在最左侧 -->
<el-form-item label="用户ID">
<el-input v-model="searchInfo.userId" placeholder="0"></el-input>
<el-input v-model="searchInfo.userId" placeholder="0" :style="{ width: '60px', height: '30px' }" ></el-input>
</el-form-item>
<!-- 游戏ID下拉选择 -->
<el-form-item label="游戏ID">
<el-select v-model="searchInfo.gameId" placeholder="请选择游戏">
<el-select v-model="searchInfo.gameId" placeholder="请选择游戏" :style="{ width: '130px', height: '30px' }" >
<el-option
v-for="item in gameOptions"
:key="item.value"
@ -20,7 +20,7 @@
<!-- 用户ID输入框按您要求放在最左侧 -->
<el-form-item label="对局记录ID">
<el-input v-model="searchInfo.gameNo" ></el-input>
<el-input v-model="searchInfo.gameNo" :style="{ width: '200px', height: '30px' }" ></el-input>
</el-form-item>
<!-- 时间范围选择 -->
@ -28,7 +28,7 @@
<el-date-picker
v-model="searchInfo.startTime"
type="date"
placeholder="选择日期">
placeholder="选择日期" :style="{ width: '140px', height: '30px' }" >
</el-date-picker>
</el-form-item>
@ -36,7 +36,7 @@
<el-date-picker
v-model="searchInfo.endTime"
type="date"
placeholder="选择日期">
placeholder="选择日期" :style="{ width: '140px', height: '30px' }" >
</el-date-picker>
</el-form-item>
@ -46,20 +46,47 @@
</el-form-item>
</el-form>
</div>
<div class="gva-search-box">
<!-- 这里将放置用户表格 -->
<el-table :data="resLogs" border style="width: 100%">
<el-table-column prop="uid" label="id" align="left" min-width="150"></el-table-column>
<el-table-column prop="res_name" label="资源名" align="left" min-width="150"></el-table-column>
<el-table-column prop="res_value" label="变动值" align="left" min-width="150"></el-table-column>
<el-table-column prop="res_after_value" label="变动后总值" align="left" min-width="150"></el-table-column>
<el-table-column prop="game_id" label="游戏名" align="left" min-width="150"></el-table-column>
<el-table-column prop="reason" label="原因" align="left" min-width="150"></el-table-column>
<el-table-column prop="operator_id" label="操作者" align="left" min-width="150"></el-table-column>
<el-table-column prop="time" label="时间" align="left" min-width="150"></el-table-column>
</el-table>
</div>
</template>
<script setup>
import {
getUserResLogs,
} from "@/api/logRecord";
import {ref} from "vue";
import {ElLoading, ElMessage} from 'element-plus'
import {getUserResLogs} from "@/api/logRecord";
const searchInfo = {
const searchInfo = ref({
userId: '',
gameId: 0,
gameId: null,
gameNo:'',
startTime: '',
endTime: '',
}
})
const resLogs= ref([
// {
// game_id: 0,
// game_no: "",
// operator_id: 0,
// reason: "gm",
// res_after_value: 5,
// res_name: "gold",
// res_value: 1,
// time: "2025-06-22T17:17:41Z",
// uid: 1,
// },
])
const gameOptions= [
{ value: 1, label: '王者荣耀' },
@ -67,32 +94,49 @@ const gameOptions= [
{ value: 3, label: '和平精英' }
]
function getDate(time, isStart) {
if(time===null || time === undefined) {
return ''
}
const year = time.getFullYear();
const month = String(time.getMonth() + 1).padStart(2, '0');
const day = String(time.getDate()).padStart(2, '0');
if (isStart){
return `${year}-${month}-${day}`+' 00:00:00';
}else{
return `${year}-${month}-${day}`+' 23:59:59';
}
}
async function onQuery() {
//
const loading = this.$loading({
const loading = ElLoading.service({
lock: true,
text: '加载中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
try {
const sInfo = searchInfo.value
const req = {
user_id:+searchInfo.userId,
game_id:+searchInfo.gameId,
game_no:searchInfo.gameNo,
startTime:searchInfo.startTime,
endTime:searchInfo.endTime,
user_id:+sInfo.userId,
game_id:+sInfo.gameId,
game_no:sInfo.gameNo,
start_time:getDate(sInfo.startTime,true),
end_time:getDate(sInfo.endTime,false),
}
// console.log(req)
const response = await getUserResLogs(req)
if (response.code !== 0) {
console.error('获取金流失败:', response.msg || `请求失败,错误码: ${response.code}`)
this.$message.error('获取金流失败:' + (response.msg || `请求失败,错误码: ${response.code}`))
ElMessage.error('获取金流失败:' + (response.msg || `请求失败,错误码: ${response.code}`))
return
}
console.log(response.data.log)
resLogs.value = response.data.log
// console.log(response.data.log)
}catch (error){
console.error('获取金流失败:', error)
this.$message.error('获取金流失败:'+error)
ElMessage.error('获取金流失败:'+error)
}finally {
//
loading.close()
@ -106,7 +150,4 @@ async function onQuery() {
padding: 20px;
background: #fff;
}
.el-form-item {
margin-bottom: 0;
}
</style>

View File

@ -2,6 +2,7 @@ package logRecord
import (
"encoding/json"
"game/common/model/user"
"game/common/proto/pb"
"game/common/rpc"
"github.com/fox/fox/ipb"
@ -24,7 +25,7 @@ type LogUserResReq struct {
}
// 添加玩家资源,负数为减少
func RpcGetUserResLogs(s service.IService, uid int64, req *LogUserResReq) (map[string]int64, pb.ErrCode) {
func RpcGetUserResLogs(s service.IService, uid int64, req *LogUserResReq) ([]*user.UserResourcesLog, pb.ErrCode) {
rpcMsg := ipb.MakeRpcMsg(rpc.RpcGetUserResLog, uid, req)
rspMsg, err := s.CallByServiceId(int(pb.ServiceTypeId_STI_DB), timeout, rpcMsg)
if err != nil {
@ -32,8 +33,10 @@ func RpcGetUserResLogs(s service.IService, uid int64, req *LogUserResReq) (map[s
return nil, pb.ErrCode_SystemErr
}
if rspMsg.RpcCode == 0 {
res := map[string]int64{}
_ = json.Unmarshal(rspMsg.Msg, &res)
res := []*user.UserResourcesLog{}
if err = json.Unmarshal(rspMsg.Msg, &res); err != nil {
log.ErrorF("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error())
}
return res, pb.ErrCode_OK
}
return nil, pb.ErrCode(rspMsg.RpcCode)

View File

@ -22,7 +22,7 @@ func (s *DbService) onGetUserResLogs(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
}
var logs []user.UserResourcesLog
condition := make(map[string]any)
condition["user_id"] = req.UserId
condition["uid"] = req.UserId
if req.ResName != "" {
condition["res_name"] = req.ResName
}
@ -34,11 +34,12 @@ func (s *DbService) onGetUserResLogs(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
}
db := operation.LogDB.Where(condition)
if req.StartTime != "" {
db = db.Where("start_time >= ?", req.StartTime)
db = db.Where("time >= ?", req.StartTime)
}
if req.EndTime != "" {
db = db.Where("end_time <= ?", req.EndTime)
db = db.Where("time <= ?", req.EndTime)
}
db = db.Order("time desc")
err = db.Find(&logs).Error
if err != nil {
log.ErrorF("find table:%v condition:%v err:%v", user.UserResourcesLog{}.TableName(), utils.JsonMarshal(condition), err)