gm后台添加金流日志
This commit is contained in:
parent
ef253158e4
commit
04d2adf592
@ -20,7 +20,6 @@
|
|||||||
"/src/view/example/upload/upload.vue": "Upload",
|
"/src/view/example/upload/upload.vue": "Upload",
|
||||||
"/src/view/gameuser/addResourceDialog.vue": "AddResourceDialog",
|
"/src/view/gameuser/addResourceDialog.vue": "AddResourceDialog",
|
||||||
"/src/view/gameuser/index.vue": "Index",
|
"/src/view/gameuser/index.vue": "Index",
|
||||||
"/src/view/gameuser/logResource.vue": "LogResource",
|
|
||||||
"/src/view/init/index.vue": "Init",
|
"/src/view/init/index.vue": "Init",
|
||||||
"/src/view/layout/aside/asideComponent/asyncSubmenu.vue": "AsyncSubmenu",
|
"/src/view/layout/aside/asideComponent/asyncSubmenu.vue": "AsyncSubmenu",
|
||||||
"/src/view/layout/aside/asideComponent/index.vue": "AsideComponent",
|
"/src/view/layout/aside/asideComponent/index.vue": "AsideComponent",
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
<el-form :inline="true" class="demo-form-inline">
|
<el-form :inline="true" class="demo-form-inline">
|
||||||
<!-- 用户ID输入框(按您要求放在最左侧) -->
|
<!-- 用户ID输入框(按您要求放在最左侧) -->
|
||||||
<el-form-item label="用户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>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 游戏ID下拉选择 -->
|
<!-- 游戏ID下拉选择 -->
|
||||||
<el-form-item label="游戏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
|
<el-option
|
||||||
v-for="item in gameOptions"
|
v-for="item in gameOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<!-- 用户ID输入框(按您要求放在最左侧) -->
|
<!-- 用户ID输入框(按您要求放在最左侧) -->
|
||||||
<el-form-item label="对局记录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>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 时间范围选择 -->
|
<!-- 时间范围选择 -->
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="searchInfo.startTime"
|
v-model="searchInfo.startTime"
|
||||||
type="date"
|
type="date"
|
||||||
placeholder="选择日期">
|
placeholder="选择日期" :style="{ width: '140px', height: '30px' }" >
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="searchInfo.endTime"
|
v-model="searchInfo.endTime"
|
||||||
type="date"
|
type="date"
|
||||||
placeholder="选择日期">
|
placeholder="选择日期" :style="{ width: '140px', height: '30px' }" >
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@ -46,20 +46,47 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {ref} from "vue";
|
||||||
getUserResLogs,
|
import {ElLoading, ElMessage} from 'element-plus'
|
||||||
} from "@/api/logRecord";
|
import {getUserResLogs} from "@/api/logRecord";
|
||||||
|
|
||||||
const searchInfo = {
|
const searchInfo = ref({
|
||||||
userId: '',
|
userId: '',
|
||||||
gameId: 0,
|
gameId: null,
|
||||||
gameNo:'',
|
gameNo:'',
|
||||||
startTime: '',
|
startTime: '',
|
||||||
endTime: '',
|
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= [
|
const gameOptions= [
|
||||||
{ value: 1, label: '王者荣耀' },
|
{ value: 1, label: '王者荣耀' },
|
||||||
@ -67,32 +94,49 @@ const gameOptions= [
|
|||||||
{ value: 3, label: '和平精英' }
|
{ 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() {
|
async function onQuery() {
|
||||||
// 显示加载状态
|
// 显示加载状态
|
||||||
const loading = this.$loading({
|
const loading = ElLoading.service({
|
||||||
lock: true,
|
lock: true,
|
||||||
text: '加载中...',
|
text: '加载中...',
|
||||||
spinner: 'el-icon-loading',
|
spinner: 'el-icon-loading',
|
||||||
background: 'rgba(0, 0, 0, 0.7)'
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
|
const sInfo = searchInfo.value
|
||||||
const req = {
|
const req = {
|
||||||
user_id:+searchInfo.userId,
|
user_id:+sInfo.userId,
|
||||||
game_id:+searchInfo.gameId,
|
game_id:+sInfo.gameId,
|
||||||
game_no:searchInfo.gameNo,
|
game_no:sInfo.gameNo,
|
||||||
startTime:searchInfo.startTime,
|
start_time:getDate(sInfo.startTime,true),
|
||||||
endTime:searchInfo.endTime,
|
end_time:getDate(sInfo.endTime,false),
|
||||||
}
|
}
|
||||||
|
// console.log(req)
|
||||||
const response = await getUserResLogs(req)
|
const response = await getUserResLogs(req)
|
||||||
if (response.code !== 0) {
|
if (response.code !== 0) {
|
||||||
console.error('获取金流失败:', response.msg || `请求失败,错误码: ${response.code}`)
|
console.error('获取金流失败:', response.msg || `请求失败,错误码: ${response.code}`)
|
||||||
this.$message.error('获取金流失败:' + (response.msg || `请求失败,错误码: ${response.code}`))
|
ElMessage.error('获取金流失败:' + (response.msg || `请求失败,错误码: ${response.code}`))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(response.data.log)
|
resLogs.value = response.data.log
|
||||||
|
// console.log(response.data.log)
|
||||||
}catch (error){
|
}catch (error){
|
||||||
console.error('获取金流失败:', error)
|
console.error('获取金流失败:', error)
|
||||||
this.$message.error('获取金流失败:'+error)
|
ElMessage.error('获取金流失败:'+error)
|
||||||
}finally {
|
}finally {
|
||||||
// 关闭加载状态
|
// 关闭加载状态
|
||||||
loading.close()
|
loading.close()
|
||||||
@ -106,7 +150,4 @@ async function onQuery() {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
.el-form-item {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
@ -2,6 +2,7 @@ package logRecord
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"game/common/model/user"
|
||||||
"game/common/proto/pb"
|
"game/common/proto/pb"
|
||||||
"game/common/rpc"
|
"game/common/rpc"
|
||||||
"github.com/fox/fox/ipb"
|
"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)
|
rpcMsg := ipb.MakeRpcMsg(rpc.RpcGetUserResLog, uid, req)
|
||||||
rspMsg, err := s.CallByServiceId(int(pb.ServiceTypeId_STI_DB), timeout, rpcMsg)
|
rspMsg, err := s.CallByServiceId(int(pb.ServiceTypeId_STI_DB), timeout, rpcMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,8 +33,10 @@ func RpcGetUserResLogs(s service.IService, uid int64, req *LogUserResReq) (map[s
|
|||||||
return nil, pb.ErrCode_SystemErr
|
return nil, pb.ErrCode_SystemErr
|
||||||
}
|
}
|
||||||
if rspMsg.RpcCode == 0 {
|
if rspMsg.RpcCode == 0 {
|
||||||
res := map[string]int64{}
|
res := []*user.UserResourcesLog{}
|
||||||
_ = json.Unmarshal(rspMsg.Msg, &res)
|
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 res, pb.ErrCode_OK
|
||||||
}
|
}
|
||||||
return nil, pb.ErrCode(rspMsg.RpcCode)
|
return nil, pb.ErrCode(rspMsg.RpcCode)
|
||||||
|
@ -22,7 +22,7 @@ func (s *DbService) onGetUserResLogs(iMsg *ipb.InternalMsg) *ipb.InternalMsg {
|
|||||||
}
|
}
|
||||||
var logs []user.UserResourcesLog
|
var logs []user.UserResourcesLog
|
||||||
condition := make(map[string]any)
|
condition := make(map[string]any)
|
||||||
condition["user_id"] = req.UserId
|
condition["uid"] = req.UserId
|
||||||
if req.ResName != "" {
|
if req.ResName != "" {
|
||||||
condition["res_name"] = 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)
|
db := operation.LogDB.Where(condition)
|
||||||
if req.StartTime != "" {
|
if req.StartTime != "" {
|
||||||
db = db.Where("start_time >= ?", req.StartTime)
|
db = db.Where("time >= ?", req.StartTime)
|
||||||
}
|
}
|
||||||
if req.EndTime != "" {
|
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
|
err = db.Find(&logs).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorF("find table:%v condition:%v err:%v", user.UserResourcesLog{}.TableName(), utils.JsonMarshal(condition), err)
|
log.ErrorF("find table:%v condition:%v err:%v", user.UserResourcesLog{}.TableName(), utils.JsonMarshal(condition), err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user