28 changed files with 3149 additions and 889 deletions
@ -0,0 +1,49 @@
|
||||
package game |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
type RoleSearchReq struct { |
||||
g.Meta `path:"/basicinfo/rolelist" tags:"账号的所有角色" method:"get" summary:"角色列表"` |
||||
Account string `p:"account" v:"required#账号ID不能为空"` |
||||
} |
||||
|
||||
type RoleSearchRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
RoleList []*entity.RolePost `json:"list"` |
||||
} |
||||
|
||||
type RoleDetailReq struct { |
||||
g.Meta `path:"/basicinfo/detail" tags:"角色详情" method:"get" summary:"详情"` |
||||
Uid int32 `p:"Uid" v:"required#角色ID不能为空"` |
||||
Channel int `p:"channel" v:"required#渠道不能为空"` |
||||
} |
||||
|
||||
type RoleDetailRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
RoleDetail *entity.RoleDetail `json:"roleDetail"` |
||||
} |
||||
|
||||
type RoleOnlineReq struct { |
||||
g.Meta `path:"/basicinfo/online" tags:"在线列表" method:"get" summary:"玩家在线列表"` |
||||
ServerId int32 `p:"serverId" v:"required#服务器ID不能为空"` |
||||
} |
||||
|
||||
type RoleOnlineRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Onlines []*entity.Online `json:"onlines"` |
||||
} |
||||
type AccountReq struct { |
||||
g.Meta `path:"/basicinfo/account" tags:"账号数据" method:"get" summary:"总服账号数据"` |
||||
Account string `p:"account"` |
||||
Tel string `p:"tel"` |
||||
Ident string `p:"ident"` |
||||
Name string `p:"name"` |
||||
} |
||||
|
||||
type AccountRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Accounts []*entity.AccountInfo `json:"list"` |
||||
} |
@ -0,0 +1,50 @@
|
||||
package game |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
type MailsSearchReq struct { |
||||
g.Meta `path:"/mail/list" tags:"查询邮件" method:"get" summary:"邮件列表"` |
||||
ServerId string `p:"serverId" v:""` |
||||
Uid string `p:"uid"` |
||||
LowTime int64 `p:"lowTime"` |
||||
UpperTime int64 `p:"upperTime"` |
||||
} |
||||
|
||||
type MailsSearchRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Mails []*entity.Mail `json:"mails"` |
||||
} |
||||
|
||||
type MailSendReq struct { |
||||
g.Meta `path:"/mail/send" tags:"发送邮件" method:"post"` |
||||
ServerId string `p:"serverId" v:"required#区服不能为空"` |
||||
To string `p:"to" ` |
||||
GmName string `p:"gmName" v:"required#GMm名字不能为空"` |
||||
Type string `p:"type" v:"required#邮件类型不能为空"` |
||||
Time int64 `p:"time"` |
||||
Expired int64 `p:"expired" ` |
||||
NewGet string `p:"newGet" v:"required#类型不能为空"` |
||||
RepeatedCollection interface{} `p:"repeatedCollection" v:"required#领取类型不能为空"` |
||||
Title string `p:"title" v:"required#标题不能为空"` |
||||
Content string `p:"content" v:"required#邮件内容不能为空"` |
||||
Drops string `p:"drops" ` |
||||
Remark string `p:"remark" v:"required#说明不能为空"` |
||||
} |
||||
type MailSendRes struct { |
||||
} |
||||
|
||||
//type OnlineSearchReq struct {
|
||||
// g.Meta `path:"/online/list" tags:"在线玩家" method:"get" summary:"在线玩家列表"`
|
||||
// ServerId string `p:"serverId" v:""`
|
||||
// Uid string `p:"uid"`
|
||||
// LowTime int64 `p:"lowTime"`
|
||||
// UpperTime int64 `p:"upperTime"`
|
||||
//}
|
||||
//
|
||||
//type OnlineSearchRes struct {
|
||||
// g.Meta `mime:"application/json"`
|
||||
// Lines []*entity.Online `json:"lines"`
|
||||
//}
|
@ -0,0 +1,26 @@
|
||||
package game |
||||
|
||||
import "github.com/gogf/gf/v2/frame/g" |
||||
|
||||
// 修改GM权限
|
||||
type ChangeGmReq struct { |
||||
g.Meta `path:"/mange/changegm" tags:"修改GM权限" method:"post" summary:"修改GM权限"` |
||||
Account string `p:"account"` |
||||
ChangeValue int `p:"changeValue"` //0开,1关
|
||||
ServerId int `p:"serverId"` //0,总服,其他分服
|
||||
} |
||||
|
||||
type ChangeGmRes struct { |
||||
Account string `p:"account"` |
||||
ServerId int `p:"serverId"` //0,总服,其他分服
|
||||
} |
||||
|
||||
type SearchGmReq struct { |
||||
g.Meta `path:"/mange/searchgm" tags:"修改GM权限" method:"post" summary:"修改GM权限"` |
||||
Account string `p:"account"` |
||||
ServerId int `p:"serverId"` //0,总服,其他分服
|
||||
} |
||||
|
||||
type SearchGmRes struct { |
||||
Result int `p:"result"` |
||||
} |
@ -0,0 +1,62 @@
|
||||
package game |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
type OrderSearchReq struct { |
||||
g.Meta `path:"/order/list" tags:"查询订单" method:"get" summary:"订单列表"` |
||||
SearchType int `p:"searchType"` //1.账号查询,2角色UID查询,3 时间段查询 4.订单号查询
|
||||
Id string `p:"id"` |
||||
OrderId string `p:"orderId"` |
||||
ServerId int `p:"serverId"` |
||||
Uid int32 `p:"uid"` |
||||
Account string `p:"account"` //rechargeorder表的 uid
|
||||
Channel string `p:"channel"'` //渠道
|
||||
LowTime int64 `p:"lowTime"` |
||||
UpTime int64 `p:"upTime"` |
||||
} |
||||
|
||||
type OrderSearchRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Orders []*entity.Order `json:"list"` |
||||
} |
||||
|
||||
type OrderCountReq struct { |
||||
g.Meta `path:"/order/count" tags:"查询订单" method:"get" summary:"订单列表"` |
||||
Amount int `p:"amount"` |
||||
CompareType int `p:"compareType"` |
||||
Gender int `p:"gender"` |
||||
LowAge int `p:"lowAge"` |
||||
UpAge int `p:"upAge"` |
||||
ServerId int `p:"serverId"` |
||||
} |
||||
|
||||
type OrderCountRes struct { |
||||
g.Meta `mime:"application/json"` |
||||
Orders []*entity.OrderCount `json:"list"` |
||||
} |
||||
|
||||
// 充值
|
||||
type OrderDepositReq struct { |
||||
g.Meta `path:"/order/deposit" tags:"充值" method:"post" summary:"补单充值"` |
||||
Account string `p:"account"` |
||||
DepositId int `p:"depositId"` |
||||
ServerId int `p:"serverId"` |
||||
} |
||||
|
||||
type OrderDepositRes struct { |
||||
} |
||||
|
||||
// 加游戏币
|
||||
type AddCoinReq struct { |
||||
g.Meta `path:"/order/addcoin" tags:"修改游戏币" method:"post" summary:"修改游戏币"` |
||||
Uid string `p:"uid"` |
||||
Amount int `p:"amount"` |
||||
AmountType int `p:"amountType"` |
||||
ServerId int `p:"serverId"` |
||||
} |
||||
|
||||
type AddCoinRes struct { |
||||
} |
@ -0,0 +1,34 @@
|
||||
package controller |
||||
|
||||
import ( |
||||
"context" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/serviceGame" |
||||
) |
||||
|
||||
var GameRole = gameRoleController{} |
||||
|
||||
type gameRoleController struct { |
||||
BaseController |
||||
} |
||||
|
||||
// list 玩家角色列表
|
||||
func (c *gameRoleController) List(ctx context.Context, req *game.RoleSearchReq) (res *game.RoleSearchRes, err error) { |
||||
res, err = serviceGame.GameRole().GetGameRoleListSearch(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *gameRoleController) RoleDetail(ctx context.Context, req *game.RoleDetailReq) (res *game.RoleDetailRes, err error) { |
||||
res, err = serviceGame.GameRole().GetRoleDetail(ctx, req) |
||||
return res, err |
||||
} |
||||
|
||||
func (c *gameRoleController) OnlineList(ctx context.Context, req *game.RoleOnlineReq) (res *game.RoleOnlineRes, err error) { |
||||
res, err = serviceGame.GameRole().GetOnlineList(ctx, req) |
||||
return res, err |
||||
} |
||||
|
||||
func (c *gameRoleController) AccountList(ctx context.Context, req *game.AccountReq) (res *game.AccountRes, err error) { |
||||
res, err = serviceGame.GameRole().GetAccount(ctx, req) |
||||
return res, err |
||||
} |
@ -0,0 +1,24 @@
|
||||
package controller |
||||
|
||||
import ( |
||||
"context" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/serviceGame" |
||||
) |
||||
|
||||
var GameMail = mailController{} |
||||
|
||||
type mailController struct { |
||||
BaseController |
||||
} |
||||
|
||||
// mail 列表
|
||||
func (c *mailController) MialList(ctx context.Context, req *game.MailsSearchReq) (res *game.MailsSearchRes, err error) { |
||||
res, err = serviceGame.GameMail().GetMailList(ctx, req) |
||||
return |
||||
} |
||||
|
||||
func (c *mailController) SendMail(ctx context.Context, req *game.MailSendReq) (res *game.MailSendRes, err error) { |
||||
res, err = serviceGame.GameMail().SendMail(ctx, req) |
||||
return |
||||
} |
@ -0,0 +1,25 @@
|
||||
package controller |
||||
|
||||
import ( |
||||
"context" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/serviceGame" |
||||
) |
||||
|
||||
var GameOrder = orderController{} |
||||
|
||||
type orderController struct { |
||||
BaseController |
||||
} |
||||
|
||||
// mail 列表
|
||||
func (c *mailController) OrderList(ctx context.Context, req *game.OrderSearchReq) (res *game.OrderSearchRes, err error) { |
||||
res, err = serviceGame.GameOrder().GetOrders(ctx, req) |
||||
return |
||||
} |
||||
|
||||
// 订单统计数据
|
||||
func (c *mailController) OrderCount(ctx context.Context, req *game.OrderCountReq) (res *game.OrderCountRes, err error) { |
||||
res, err = serviceGame.GameOrder().GetOrderCount(ctx, req) |
||||
return |
||||
} |
@ -0,0 +1,27 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package dao |
||||
|
||||
import ( |
||||
"tyj_admin/internal/dao/internal" |
||||
) |
||||
|
||||
// internalGmOperateLogDao is internal type for wrapping internal DAO implements.
|
||||
type internalGmOperateLogDao = *internal.GmOperateLogDao |
||||
|
||||
// gmOperateLogDao is the data access object for table gm_operate_log.
|
||||
// You can define custom methods on it to extend its functionality as you wish.
|
||||
type gmOperateLogDao struct { |
||||
internalGmOperateLogDao |
||||
} |
||||
|
||||
var ( |
||||
// GmOperateLog is globally public accessible object for table gm_operate_log operations.
|
||||
GmOperateLog = gmOperateLogDao{ |
||||
internal.NewGmOperateLogDao(), |
||||
} |
||||
) |
||||
|
||||
// Fill with you ideas below.
|
@ -0,0 +1,93 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/gogf/gf/v2/database/gdb" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
) |
||||
|
||||
// GmOperateLogDao is the data access object for table gm_operate_log.
|
||||
type GmOperateLogDao struct { |
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of current DAO.
|
||||
columns GmOperateLogColumns // columns contains all the column names of Table for convenient usage.
|
||||
} |
||||
|
||||
// GmOperateLogColumns defines and stores column names for table gm_operate_log.
|
||||
type GmOperateLogColumns struct { |
||||
Id string // ID
|
||||
OperateType string // 操作类型,1修改名称,2发送邮件
|
||||
CreateName string // GM用户名
|
||||
MailId string // 邮件id
|
||||
ChannelId string // 区服ID
|
||||
Uid string // 角色ID
|
||||
Remark string // 备注
|
||||
CreatedBy string // 创建人
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 修改时间
|
||||
DeletedAt string // 删除时间
|
||||
} |
||||
|
||||
// gmOperateLogColumns holds the columns for table gm_operate_log.
|
||||
var gmOperateLogColumns = GmOperateLogColumns{ |
||||
Id: "id", |
||||
OperateType: "operate_type", |
||||
CreateName: "create_name", |
||||
MailId: "mail_id", |
||||
ChannelId: "channel_id", |
||||
Uid: "uid", |
||||
Remark: "remark", |
||||
CreatedBy: "created_by", |
||||
CreatedAt: "created_at", |
||||
UpdatedAt: "updated_at", |
||||
DeletedAt: "deleted_at", |
||||
} |
||||
|
||||
// NewGmOperateLogDao creates and returns a new DAO object for table data access.
|
||||
func NewGmOperateLogDao() *GmOperateLogDao { |
||||
return &GmOperateLogDao{ |
||||
group: "default", |
||||
table: "gm_operate_log", |
||||
columns: gmOperateLogColumns, |
||||
} |
||||
} |
||||
|
||||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
func (dao *GmOperateLogDao) DB() gdb.DB { |
||||
return g.DB(dao.group) |
||||
} |
||||
|
||||
// Table returns the table name of current dao.
|
||||
func (dao *GmOperateLogDao) Table() string { |
||||
return dao.table |
||||
} |
||||
|
||||
// Columns returns all column names of current dao.
|
||||
func (dao *GmOperateLogDao) Columns() GmOperateLogColumns { |
||||
return dao.columns |
||||
} |
||||
|
||||
// Group returns the configuration group name of database of current dao.
|
||||
func (dao *GmOperateLogDao) Group() string { |
||||
return dao.group |
||||
} |
||||
|
||||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
func (dao *GmOperateLogDao) Ctx(ctx context.Context) *gdb.Model { |
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx) |
||||
} |
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
// It commits the transaction and returns nil if function f returns nil.
|
||||
//
|
||||
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
// as it is automatically handled by this function.
|
||||
func (dao *GmOperateLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { |
||||
return dao.Ctx(ctx).Transaction(ctx, f) |
||||
} |
@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package do |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"github.com/gogf/gf/v2/os/gtime" |
||||
) |
||||
|
||||
// GmOperateLog is the golang structure of table gm_operate_log for DAO operations like Where/Data.
|
||||
type GmOperateLog struct { |
||||
g.Meta `orm:"table:gm_operate_log, do:true"` |
||||
Id interface{} // ID
|
||||
OperateType interface{} // 操作类型,1修改名称,2发送邮件
|
||||
CreateName interface{} // GM用户名
|
||||
MailId interface{} // 邮件id
|
||||
ChannelId interface{} // 区服ID
|
||||
Uid interface{} // 角色ID
|
||||
Remark interface{} // 备注
|
||||
CreatedBy interface{} // 创建人
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 修改时间
|
||||
DeletedAt *gtime.Time // 删除时间
|
||||
} |
@ -0,0 +1,83 @@
|
||||
package entity |
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive" |
||||
|
||||
type RolePost struct { |
||||
Uid int64 `json:"uid" description:"桃园ID"` |
||||
Name string `json:"name" description:"桃园名字"` |
||||
Region int `json:"region" description:"区服"` |
||||
TotalTime int64 `json:"totalTime" description:"总在线时间"` |
||||
RechargeTotal int32 `json:"rechargeTotal" description:"累计充值"` |
||||
CreateTime primitive.DateTime `json:"createTime" description:"创建时间"` |
||||
LastLeaveTime primitive.DateTime `json:"lastLeaveTime" description:"修改时间"` |
||||
} |
||||
|
||||
type RoleDetail struct { |
||||
Uid int64 `json:"uid" description:"桃园ID"` |
||||
Name string `json:"name" description:"桃园名字"` |
||||
Boom int32 `json:"boom" description:"繁荣度"` |
||||
VillageScale int32 `json:"villageScale" description:"规模等级"` |
||||
GiftIds []int32 `json:"giftIds" description:"礼包码"` |
||||
Account string `json:"account" description:"账号名字"` |
||||
} |
||||
|
||||
type Mail struct { |
||||
Id string `json:"id" description:"邮件ID"` |
||||
ServerId string `json:"serverId" bson:"serverId" description:"服务器ID"` |
||||
C_date interface{} `json:"c_date" bson:"c_date" description:"邮件创建时间"` |
||||
To interface{} `json:"to" description:"邮件发送对象"` |
||||
From string `json:"from" description:"发送者"` |
||||
GmName string `json:"gmName" bson:"gmName" description:"GM名字"` |
||||
Type string `json:"type" description:"1 奖励,2活动,3公告"` |
||||
Expired int64 `json:"expired" description:"过期时间"` |
||||
Time int64 `json:"time" description:"发送时间,0表示马上发送"` |
||||
NewGet string `json:"newGet" bson:"newGet" description:"新玩家可领取"` |
||||
RepeatedCollection interface{} `json:"repeatedCollection" bson:"repeatedCollection" description:"1表示可以重复领取"` |
||||
Title string `json:"title" description:"标题"` |
||||
Content string `json:"content" description:"邮件内容"` |
||||
Drops []Drop `json:"drops" bson:"drops" description:"赠送物品"` |
||||
Remark string `json:"remark" description:"发送理由"` |
||||
} |
||||
type Drop struct { |
||||
Id string `json:"id" bson:"id"` |
||||
Num string `json:"num" bson:"num"` |
||||
} |
||||
|
||||
type Order struct { |
||||
Id string `json:"_id" description:"订单ID"` |
||||
Uid string `json:"uid" description:"账号uid"` |
||||
Server int32 `json:"server" description:"服务器id"` |
||||
Money int32 `json:"money" description:"充值数额"` |
||||
Timestamp int64 `json:"timestamp" description:"订单时间"` |
||||
RechargeId int32 `json:"rechargeId" description:"商品ID"` |
||||
CreateTime interface{} `json:"createTime" description:"本条记录产生的时间"` |
||||
OrderId string `json:"orderId" description:"渠道订单ID"` |
||||
State int32 `json:"state" description:"订单状态 3: 金额问题; 8:年龄不足,身份未认证,账号不存在;7:获取账号失败;6:获取订单充值配置失败,订单配置与充值金额不匹配;4:充值达到上限;5:订单验证失败;10:令牌验证失败;1:参数错误,2成功,9:分服http error"` |
||||
} |
||||
|
||||
type OrderCount struct { |
||||
ServerId int `json:"serverId"` |
||||
Num int32 `json:"num" description:"充值人数"` |
||||
Times int32 `json:"times" description:"充值笔数"` |
||||
AllMoney int32 `json:"allMoney" ` |
||||
TotalMoney int32 `json:"totalMoney" ` |
||||
TotalNum int32 `json:"totalNum" description:"总充值人数"` |
||||
TotalTimes int32 `json:"totalTimes" description:"总充值笔数"` |
||||
} |
||||
|
||||
type Online struct { |
||||
ConnectId string `json:"connectId"` |
||||
Uid int32 `json:"uid"` |
||||
Address string `json:"address"` |
||||
LoginTime int64 `json:"loginTime"` |
||||
} |
||||
|
||||
type AccountInfo struct { |
||||
Account string `json:"account"` |
||||
TrueName string `json:"trueName"` |
||||
IdentityCard string `json:"identityCard"` |
||||
Tel string `json:"tel"` |
||||
LastLeaveTime primitive.DateTime `json:"lastLeaveTime"` |
||||
CreateTime primitive.DateTime `json:"createTime"` |
||||
LeftPlayTime int64 `json:"leftPlayTime"` |
||||
} |
@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity |
||||
|
||||
import ( |
||||
"github.com/gogf/gf/v2/os/gtime" |
||||
) |
||||
|
||||
// GmOperateLog is the golang structure for table gm_operate_log.
|
||||
type GmOperateLog struct { |
||||
Id uint64 `json:"id" description:"ID"` |
||||
OperateType int `json:"operateType" description:"操作类型,1修改名称,2发送邮件"` |
||||
CreateName string `json:"createName" description:"GM用户名"` |
||||
MailId string `json:"mailId" description:"邮件id"` |
||||
ChannelId int `json:"channelId" description:"区服ID"` |
||||
Uid int `json:"uid" description:"角色ID"` |
||||
Remark string `json:"remark" description:"备注"` |
||||
CreatedBy uint64 `json:"createdBy" description:"创建人"` |
||||
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` |
||||
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` |
||||
DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` |
||||
} |
@ -0,0 +1,85 @@
|
||||
package serviceGame |
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"github.com/gogf/gf/v2/errors/gerror" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/model/entity" |
||||
"tyj_admin/internal/serviceGame/internal" |
||||
) |
||||
|
||||
type IGameRole interface { |
||||
GetGameRoleListSearch(ctx context.Context, req *game.RoleSearchReq) (res *game.RoleSearchRes, err error) |
||||
GetRoleDetail(ctx context.Context, req *game.RoleDetailReq) (res *game.RoleDetailRes, err error) |
||||
GetOnlineList(ctx context.Context, req *game.RoleOnlineReq) (res *game.RoleOnlineRes, err error) |
||||
GetAccount(ctx context.Context, req *game.AccountReq) (res *game.AccountRes, err error) |
||||
} |
||||
|
||||
type gameRoleImpl struct { |
||||
} |
||||
|
||||
var gameRoleService = gameRoleImpl{} |
||||
|
||||
func GameRole() IGameRole { |
||||
return &gameRoleService |
||||
} |
||||
|
||||
// 获取玩家角色列表
|
||||
func (s *gameRoleImpl) GetGameRoleListSearch(ctx context.Context, req *game.RoleSearchReq) (res *game.RoleSearchRes, err error) { |
||||
res = new(game.RoleSearchRes) |
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.RoleList, err = internal.GetRoleList(ctx, req.Account) |
||||
}) |
||||
return |
||||
} |
||||
|
||||
// 获取角色详情
|
||||
func (s *gameRoleImpl) GetRoleDetail(ctx context.Context, req *game.RoleDetailReq) (res *game.RoleDetailRes, err error) { |
||||
res = new(game.RoleDetailRes) |
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.RoleDetail, err = internal.GetRoleDetail(ctx, req.Uid, req.Channel) |
||||
}) |
||||
return |
||||
} |
||||
|
||||
func (m *gameRoleImpl) GetOnlineList(ctx context.Context, req *game.RoleOnlineReq) (res *game.RoleOnlineRes, err error) { |
||||
res = new(game.RoleOnlineRes) |
||||
mqttMsg := internal.MqttOnlineReq{1, "onlineUser"} |
||||
js, err := json.Marshal(mqttMsg) |
||||
connectCh := make(chan *internal.MqttOnlineRes) |
||||
defer close(connectCh) |
||||
server := "192.168.2.100:3005" |
||||
internal.SendMqttOnline(js, connectCh, server) |
||||
var result *internal.MqttOnlineRes |
||||
for { |
||||
select { |
||||
case result = <-connectCh: |
||||
if result.Error != nil { |
||||
err = gerror.New("失败") |
||||
return |
||||
} else { |
||||
for _, v := range result.Body { |
||||
for _, login := range v.LoginedList { |
||||
info := new(entity.Online) |
||||
info.ConnectId = v.ServerId |
||||
info.Uid = login.Uid |
||||
info.LoginTime = login.LoginTime |
||||
info.Address = login.Address |
||||
res.Onlines = append(res.Onlines, info) |
||||
} |
||||
|
||||
} |
||||
return |
||||
} |
||||
} |
||||
} |
||||
return |
||||
} |
||||
|
||||
func (m *gameRoleImpl) GetAccount(ctx context.Context, req *game.AccountReq) (res *game.AccountRes, err error) { |
||||
res = new(game.AccountRes) |
||||
res.Accounts, err = internal.GetAccountList(ctx, req.Account, req.Tel, req.Ident, req.Name) |
||||
return |
||||
} |
@ -0,0 +1,66 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"fmt" |
||||
"github.com/gogf/gf/v2/errors/gerror" |
||||
"go.mongodb.org/mongo-driver/bson" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
func GetServerList(account string, ctx context.Context) []int { |
||||
rdbTop := RedisDbList[0] |
||||
rdbTop.Do(ctx, "select", 0) |
||||
var m []int |
||||
result := rdbTop.HGet(ctx, "accounts", account) |
||||
json.Unmarshal([]byte(result.Val()), &m) |
||||
return m |
||||
|
||||
} |
||||
|
||||
func GetRoleList(ctx context.Context, account string) (RoleList []*entity.RolePost, err error) { |
||||
serverList := GetServerList(account, ctx) |
||||
for _, v := range serverList { |
||||
one := &entity.RolePost{} |
||||
ds := MongoDatabaseList[v] |
||||
err = ds.Collection("colony").Find(ctx, bson.M{"account": account}).One(one) |
||||
if err != nil { |
||||
return |
||||
} |
||||
one.Region = v |
||||
RoleList = append(RoleList, one) |
||||
fmt.Println("one") |
||||
} |
||||
|
||||
return RoleList, err |
||||
} |
||||
|
||||
func GetRoleDetail(ctx context.Context, uid int32, serverId int) (roleDetail *entity.RoleDetail, err error) { |
||||
if serverId > len(MongoDatabaseList)+1 || serverId <= 0 { |
||||
err = gerror.New("not find server mongo") |
||||
return |
||||
} |
||||
err = MongoDatabaseList[serverId].Collection("colony").Find(ctx, bson.M{"uid": uid}).One(roleDetail) |
||||
return |
||||
} |
||||
|
||||
func GetAccountList(ctx context.Context, account string, tel string, ident string, name string) (AccountList []*entity.AccountInfo, err error) { |
||||
|
||||
filtter := bson.M{} |
||||
if len(account) > 0 { |
||||
filtter["account"] = account |
||||
} |
||||
if len(tel) > 0 { |
||||
filtter["telephone"] = tel |
||||
} |
||||
if len(ident) > 0 { |
||||
filtter["identityCard"] = ident |
||||
} |
||||
if len(name) > 0 { |
||||
filtter["trueName"] = name |
||||
} |
||||
|
||||
err = MongoDatabaseList[0].Collection("account").Find(ctx, filtter).All(&AccountList) |
||||
return |
||||
} |
@ -0,0 +1,64 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
"github.com/go-redis/redis/v8" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"github.com/gogf/gf/v2/os/gctx" |
||||
"github.com/qiniu/qmgo" |
||||
"time" |
||||
) |
||||
|
||||
var ( |
||||
MongoDatabaseList []*qmgo.Database |
||||
RedisDbList []*redis.Client |
||||
) |
||||
|
||||
func init() { |
||||
//加载游戏相关配置
|
||||
ctx := gctx.New() |
||||
mongoCfg, err := g.Cfg().Get(ctx, "game.mongo") |
||||
if err != nil { |
||||
return |
||||
} |
||||
MongoInit(mongoCfg.Maps()) |
||||
|
||||
redisCfg, err := g.Cfg().Get(ctx, "game.redis") |
||||
if err != nil { |
||||
return |
||||
} |
||||
RedisInit(redisCfg.Maps()) |
||||
|
||||
} |
||||
func MongoInit(config []map[string]interface{}) { |
||||
ctx := context.Background() |
||||
for _, v := range config { |
||||
client, err := qmgo.NewClient(ctx, &qmgo.Config{Uri: v["link"].(string)}) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
db := client.Database(v["name"].(string)) |
||||
MongoDatabaseList = append(MongoDatabaseList, db) |
||||
} |
||||
|
||||
} |
||||
|
||||
func RedisInit(config []map[string]interface{}) { |
||||
for _, v := range config { |
||||
rdb := redis.NewClient(&redis.Options{ |
||||
Addr: v["address"].(string), |
||||
DialTimeout: 10 * time.Second, |
||||
ReadTimeout: 30 * time.Second, |
||||
WriteTimeout: 30 * time.Second, |
||||
PoolSize: 10, |
||||
PoolTimeout: 30 * time.Second, |
||||
}) |
||||
RedisDbList = append(RedisDbList, rdb) |
||||
} |
||||
ctx := context.Background() |
||||
Test(ctx) |
||||
} |
||||
|
||||
func Test(ctx context.Context) { |
||||
|
||||
} |
@ -0,0 +1,111 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"fmt" |
||||
mqtt "github.com/eclipse/paho.mqtt.golang" |
||||
"go.mongodb.org/mongo-driver/bson" |
||||
"strings" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
func GetMails(ctx context.Context, uid string, serverId string, createTime1 int64, createTime2 int64) (mailList []*entity.Mail, err error) { |
||||
filter := bson.M{} |
||||
if len(uid) > 0 { |
||||
filter["to"] = uid |
||||
} |
||||
if len(serverId) > 0 { |
||||
filter["serverId"] = serverId |
||||
} |
||||
if createTime1 >= 0 && createTime2 > createTime1 { |
||||
filter["c_date"] = bson.M{"$lte": createTime2} |
||||
} |
||||
err = MongoDatabaseList[0].Collection("mail").Find(ctx, filter).All(&mailList) |
||||
return |
||||
|
||||
} |
||||
|
||||
func AddMail(ctx context.Context, mail entity.Mail) (err error) { |
||||
ss, err := MongoDatabaseList[0].Collection("mail").InsertOne(ctx, mail) |
||||
fmt.Println("ss %v", ss) |
||||
return |
||||
} |
||||
|
||||
type MailBody struct { |
||||
entity.Mail |
||||
ModuleType string `json:"moduleType"` |
||||
} |
||||
|
||||
type MqttMail struct { |
||||
ReqId int64 `json:"reqId"` |
||||
ModuleId string `json:"moduleId"` |
||||
Body MailBody `json:"body"` |
||||
} |
||||
|
||||
func SendMqttMail(msg interface{}, c chan bool, server string) { |
||||
|
||||
registerFunc := func(client mqtt.Client, qtmsg mqtt.Message) { |
||||
ss := string(msg.([]byte)) |
||||
fmt.Println(ss) |
||||
err := ClientSend("client", 0, false, ss) |
||||
if err != nil { |
||||
c <- false |
||||
} |
||||
//ClientSend("client", 0, false, `{"reqId":3,"moduleId":"webadmin","body":{"uids":"lq0001","gm":1,"moduleType":"changeGM"}}`)
|
||||
} |
||||
|
||||
mailFunc := func(client mqtt.Client, qtmsg mqtt.Message) { |
||||
res := &MqttResult{} |
||||
client.Disconnect(1) |
||||
ss := string(qtmsg.Payload()) |
||||
ss = ss[1 : len(ss)-1] |
||||
ss = strings.Replace(ss, "\\", "", -1) |
||||
err := json.Unmarshal([]byte(ss), res) |
||||
if err == nil && res.RespId == 1 { |
||||
c <- true |
||||
return |
||||
} |
||||
fmt.Println("error" + err.Error()) |
||||
c <- false |
||||
|
||||
} |
||||
if NewMqttClient(registerFunc, mailFunc, server) != nil { |
||||
c <- false |
||||
} |
||||
|
||||
} |
||||
|
||||
type MqttResult struct { |
||||
RespId int `json:"respId"` |
||||
Error interface{} `json:"error"` |
||||
} |
||||
|
||||
//func Mailcallback(c mqtt.Client, msg mqtt.Message) {
|
||||
// res := &MqttResult{}
|
||||
// c.Disconnect(1)
|
||||
// fmt.Println(string(msg.Payload()))
|
||||
// ss := string(msg.Payload())
|
||||
// ss = ss[1 : len(ss)-1]
|
||||
// ss = strings.Replace(ss, "\\", "", -1)
|
||||
// fmt.Println(ss)
|
||||
// err := json.Unmarshal([]byte(ss), res)
|
||||
// if err == nil && res.RespId == 1 {
|
||||
// ch <- true
|
||||
// return
|
||||
// }
|
||||
// fmt.Println("error" + err.Error())
|
||||
// ch <- false
|
||||
//
|
||||
//}
|
||||
//
|
||||
//func RegisterCallback(c mqtt.Client, msg mqtt.Message) {
|
||||
// ss := string(Payload.([]byte))
|
||||
// fmt.Println(ss)
|
||||
// err := ClientSend("client", 0, false, ss)
|
||||
// if err != nil {
|
||||
// ch <- false
|
||||
// }
|
||||
// //ClientSend("client", 0, false, `{"reqId":3,"moduleId":"webadmin","body":{"uids":"lq0001","gm":1,"moduleType":"changeGM"}}`)
|
||||
//
|
||||
//}
|
@ -0,0 +1,83 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"fmt" |
||||
mqtt "github.com/eclipse/paho.mqtt.golang" |
||||
"github.com/gogf/gf/v2/errors/gerror" |
||||
) |
||||
|
||||
var client mqtt.Client |
||||
|
||||
func NewMqttClient(registerCallback mqtt.MessageHandler, callback mqtt.MessageHandler, server string) error { |
||||
if client == nil { |
||||
opts := mqtt.NewClientOptions() |
||||
opts.AddBroker(server) // 这个中转服务器不需要任何账号密码
|
||||
opts.SetClientID("go_mqtt_client1") |
||||
opts.KeepAlive = 10 |
||||
// opts.SetUsername("")
|
||||
// opts.SetPassword("")
|
||||
opts.OnConnect = func(c mqtt.Client) { |
||||
fmt.Println("MQTT链接成功!") |
||||
//ClientSend("client", 0, false, msg)
|
||||
|
||||
//ClientSend("client", 0, false, `{"reqId":3,"moduleId":"webadmin","body":{"uids":"lq0001","gm":0,"moduleType":"changeGM","moduleId":"webadmin","clientId":"pomelo_cli_1669166814692","username":"monitor"}}`)
|
||||
|
||||
ClientSend("register", 0, false, `{"type":"client","id":1,"username":"monitor","password":"monitor","md5":false}`) |
||||
//ClientSend("monitor", 0, false, `{"type":"client","moduleId":"webadmin","body":{"uids":"","gm":1,"moduleType":"changeGM","moduleId":"webadmin"}}`)
|
||||
|
||||
} |
||||
opts.OnConnectionLost = func(c mqtt.Client, err error) { |
||||
//NewClient()
|
||||
} |
||||
|
||||
client = mqtt.NewClient(opts) |
||||
} |
||||
|
||||
if token := client.Connect(); token.Wait() && token.Error() != nil { |
||||
fmt.Println(token.Error()) |
||||
return gerror.New("GM工具无法连接游戏服务器") |
||||
} |
||||
|
||||
client.Subscribe("register", 0, registerCallback) |
||||
client.Subscribe("client", 0, callback) |
||||
return nil |
||||
|
||||
} |
||||
|
||||
func ClientSend(topic string, qos byte, retained bool, payload interface{}) error { |
||||
token := client.Publish(topic, qos, retained, payload) |
||||
if token != nil { |
||||
token.Wait() |
||||
if token.Error() != nil { |
||||
fmt.Println(topic+"失败!", token.Error()) |
||||
return token.Error() |
||||
} |
||||
} |
||||
|
||||
fmt.Println("消息发布成功!" + topic) |
||||
return nil |
||||
} |
||||
|
||||
// 订阅消息
|
||||
func ClientSubscribe(topic string, qos byte, callback mqtt.MessageHandler, err func(error)) { |
||||
if token := client.Subscribe(topic, qos, func(c mqtt.Client, msg mqtt.Message) { |
||||
callback(c, msg) |
||||
}); token.Wait() && token.Error() != nil { |
||||
err(token.Error()) |
||||
} |
||||
} |
||||
|
||||
func errorcallback(err error) { |
||||
fmt.Println("err:", err.Error()) |
||||
} |
||||
|
||||
func registerCallback(c mqtt.Client, msg mqtt.Message) { |
||||
fmt.Println("registerCallback:", string(msg.Payload())) |
||||
ClientSend("client", 0, false, `{"reqId":3,"moduleId":"webadmin","body":{"uids":"lq0001","gm":1,"moduleType":"changeGM"}}`) |
||||
ClientSend("client", 0, false, `{"reqId":3,"moduleId":"onlineUser","body":{}}`) |
||||
|
||||
} |
||||
|
||||
func clientCallback(c mqtt.Client, msg mqtt.Message) { |
||||
fmt.Println("clientCallback:", string(msg.Payload())) |
||||
} |
@ -0,0 +1,62 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"fmt" |
||||
mqtt "github.com/eclipse/paho.mqtt.golang" |
||||
"strings" |
||||
) |
||||
|
||||
type MqttOnlineReq struct { |
||||
ReqId int64 `json:"reqId"` |
||||
ModuleId string `json:"moduleId"` |
||||
} |
||||
|
||||
type MqttOnlineRes struct { |
||||
RespId int `json:"respId"` |
||||
Error interface{} `json:"error"` |
||||
Body map[string]OnlineBody `json:"body"` |
||||
} |
||||
|
||||
type OnlineBody struct { |
||||
ServerId string `json:"serverId"` |
||||
LoginedList []OnlineLoginInfo `json:"loginedList"` |
||||
} |
||||
|
||||
type OnlineLoginInfo struct { |
||||
LoginTime int64 `json:"loginTime"` |
||||
Uid int32 `json:"uid"` |
||||
Address string `json:"address"` |
||||
} |
||||
|
||||
func SendMqttOnline(msg interface{}, c chan *MqttOnlineRes, server string) { |
||||
|
||||
registerFunc := func(client mqtt.Client, qtmsg mqtt.Message) { |
||||
ss := string(msg.([]byte)) |
||||
fmt.Println(ss) |
||||
err := ClientSend("client", 0, false, ss) |
||||
if err != nil { |
||||
c <- &MqttOnlineRes{Error: err} |
||||
} |
||||
//ClientSend("client", 0, false, `{"reqId":3,"moduleId":"webadmin","body":{"uids":"lq0001","gm":1,"moduleType":"changeGM"}}`)
|
||||
} |
||||
|
||||
callback := func(client mqtt.Client, qtmsg mqtt.Message) { |
||||
res := &MqttOnlineRes{} |
||||
client.Disconnect(1) |
||||
ss := string(qtmsg.Payload()) |
||||
ss = ss[1 : len(ss)-1] |
||||
ss = strings.Replace(ss, "\\", "", -1) |
||||
err := json.Unmarshal([]byte(ss), res) |
||||
if err == nil && res.RespId == 1 { |
||||
c <- res |
||||
return |
||||
} |
||||
c <- &MqttOnlineRes{Error: err} |
||||
|
||||
} |
||||
if err := NewMqttClient(registerFunc, callback, server); err != nil { |
||||
c <- &MqttOnlineRes{Error: err} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package internal |
||||
|
||||
import ( |
||||
"context" |
||||
"github.com/qiniu/qmgo" |
||||
"go.mongodb.org/mongo-driver/bson" |
||||
"tyj_admin/internal/model/entity" |
||||
) |
||||
|
||||
func GetOrdersByAccount(ctx context.Context, account string) (orders []*entity.Order, err error) { |
||||
bm := bson.M{"uid": account} |
||||
err = MongoDatabaseList[0].Collection("rechargeOrder").Find(ctx, bm).All(&orders) |
||||
return |
||||
|
||||
} |
||||
|
||||
func GetOrdersByTime(ctx context.Context, lowTime int64, upperTime int64) (orders []*entity.Order, err error) { |
||||
bm := bson.M{"timestamp": bson.M{"$gte": lowTime, "$lte": upperTime}} |
||||
err = MongoDatabaseList[0].Collection("rechargeOrder").Find(ctx, bm).All(&orders) |
||||
return |
||||
|
||||
} |
||||
|
||||
func GetOrdersByOrderId(ctx context.Context, orderId string) (orders []*entity.Order, err error) { |
||||
bm := bson.M{"_id": orderId} |
||||
err = MongoDatabaseList[0].Collection("rechargeOrder").Find(ctx, bm).All(&orders) |
||||
return |
||||
} |
||||
|
||||
func GetorderCount(ctx context.Context, filter bson.M, serverId int) (Orders []*entity.OrderCount, err error) { |
||||
if serverId == 0 { |
||||
for i := 1; i < len(MongoDatabaseList); i++ { |
||||
orderCount := new(entity.OrderCount) |
||||
orderCount.ServerId = i |
||||
serverMatch := bson.D{{"$match", bson.M{"server": i}}} |
||||
matchStage := bson.D{{"$match", filter}} |
||||
groupStage := bson.D{{"group", bson.M{"uid": `$uid`, "server": `$server`}}} |
||||
var in []bson.M |
||||
MongoDatabaseList[0].Collection("rechargeOrder").Aggregate(ctx, qmgo.Pipeline{serverMatch, matchStage, groupStage}).All(&in) |
||||
orderCount.Num = 1 |
||||
|
||||
groupStage = bson.D{{"group", bson.M{"totalMoney": bson.M{"$sum": "$money"}, "times": bson.M{"$sum": 1}}}} |
||||
|
||||
var in2 []bson.M |
||||
MongoDatabaseList[0].Collection("rechargeOrder").Aggregate(ctx, qmgo.Pipeline{serverMatch, groupStage}).All(&in2) |
||||
} |
||||
} else { |
||||
orderCount := new(entity.OrderCount) |
||||
orderCount.ServerId = serverId |
||||
serverMatch := bson.D{{"$match", bson.M{"server": serverId}}} |
||||
matchStage := bson.D{{"$match", filter}} |
||||
groupStage := bson.D{{"group", bson.M{"uid": `$uid`, "server": `$server`}}} |
||||
var in []bson.M |
||||
MongoDatabaseList[0].Collection("rechargeOrder").Aggregate(ctx, qmgo.Pipeline{serverMatch, matchStage, groupStage}).All(&in) |
||||
orderCount.Num = 1 |
||||
|
||||
groupStage = bson.D{{"group", bson.M{"totalMoney": bson.M{"$sum": "$money"}, "times": bson.M{"$sum": 1}}}} |
||||
|
||||
var in2 []bson.M |
||||
MongoDatabaseList[0].Collection("rechargeOrder").Aggregate(ctx, qmgo.Pipeline{serverMatch, groupStage}).All(&in2) |
||||
} |
||||
return |
||||
} |
@ -0,0 +1,101 @@
|
||||
package serviceGame |
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"github.com/gogf/gf/v2/errors/gerror" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"github.com/gogf/gf/v2/util/guid" |
||||
"strings" |
||||
"time" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/model/entity" |
||||
"tyj_admin/internal/serviceGame/internal" |
||||
) |
||||
|
||||
type IGameMail interface { |
||||
GetMailList(ctx context.Context, req *game.MailsSearchReq) (res *game.MailsSearchRes, err error) |
||||
SendMail(ctx context.Context, req *game.MailSendReq) (res *game.MailSendRes, err error) |
||||
} |
||||
|
||||
type gameMailImpl struct { |
||||
} |
||||
|
||||
var gameMailService = gameMailImpl{} |
||||
|
||||
func GameMail() IGameMail { |
||||
return &gameMailService |
||||
} |
||||
|
||||
func (m *gameMailImpl) GetMailList(ctx context.Context, req *game.MailsSearchReq) (res *game.MailsSearchRes, err error) { |
||||
res = new(game.MailsSearchRes) |
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Mails, err = internal.GetMails(ctx, req.Uid, req.ServerId, req.LowTime, req.UpperTime) |
||||
}) |
||||
return |
||||
} |
||||
|
||||
func (m *gameMailImpl) SendMail(ctx context.Context, req *game.MailSendReq) (res *game.MailSendRes, err error) { |
||||
res = new(game.MailSendRes) |
||||
mqttMail := internal.MqttMail{} |
||||
//mail := entity.Mail{}
|
||||
mqttMail.Body.Mail.C_date = time.Now().UnixMilli() |
||||
mqttMail.Body.Mail.Id = guid.S() |
||||
mqttMail.Body.Mail.ServerId = req.ServerId |
||||
mqttMail.Body.Mail.Time = req.Time |
||||
mqttMail.Body.Mail.To = req.To |
||||
mqttMail.Body.Mail.From = "陶渊明" |
||||
mqttMail.Body.Mail.GmName = req.GmName |
||||
mqttMail.Body.Mail.Type = req.Type |
||||
mqttMail.Body.Mail.Expired = req.Expired |
||||
mqttMail.Body.Mail.NewGet = req.NewGet |
||||
mqttMail.Body.Mail.RepeatedCollection = req.RepeatedCollection |
||||
mqttMail.Body.Mail.Title = req.Title |
||||
mqttMail.Body.Mail.Content = req.Content |
||||
mqttMail.Body.Mail.Drops = GetDrops(req.Drops) |
||||
mqttMail.Body.Mail.Remark = req.Remark |
||||
mqttMail.Body.ModuleType = "sendMail" |
||||
mqttMail.ModuleId = "webadmin" |
||||
mqttMail.ReqId = 1 |
||||
js, err := json.Marshal(mqttMail) |
||||
connectCh := make(chan bool) |
||||
server := "192.168.2.100:3005" |
||||
defer close(connectCh) |
||||
internal.SendMqttMail(js, connectCh, server) |
||||
var result bool |
||||
for { |
||||
select { |
||||
case result = <-connectCh: |
||||
if result == false { |
||||
err = gerror.New("失败") |
||||
return |
||||
} else { |
||||
return |
||||
} |
||||
} |
||||
} |
||||
|
||||
internal.AddMail(ctx, mqttMail.Body.Mail) |
||||
return |
||||
|
||||
} |
||||
|
||||
func GetDrops(drop string) []entity.Drop { |
||||
var realDrops []entity.Drop |
||||
if len(drop) == 0 { |
||||
return realDrops |
||||
} |
||||
drops := strings.Split(drop, ",") |
||||
for _, v := range drops { |
||||
temp := strings.Split(v, ":") |
||||
if len(temp) != 2 { |
||||
continue |
||||
} |
||||
ss := entity.Drop{temp[0], temp[1]} |
||||
realDrops = append(realDrops, ss) |
||||
|
||||
} |
||||
|
||||
return realDrops |
||||
|
||||
} |
@ -0,0 +1,91 @@
|
||||
package serviceGame |
||||
|
||||
import ( |
||||
"context" |
||||
"github.com/gogf/gf/v2/frame/g" |
||||
"go.mongodb.org/mongo-driver/bson" |
||||
"time" |
||||
"tyj_admin/api/v1/game" |
||||
"tyj_admin/internal/model/entity" |
||||
"tyj_admin/internal/serviceGame/internal" |
||||
) |
||||
|
||||
type IGameOrder interface { |
||||
GetOrders(ctx context.Context, req *game.OrderSearchReq) (res *game.OrderSearchRes, err error) |
||||
GetOrderCount(ctx context.Context, req *game.OrderCountReq) (res *game.OrderCountRes, err error) |
||||
} |
||||
|
||||
type gameOrderImpl struct { |
||||
} |
||||
|
||||
var gameOrderService = gameOrderImpl{} |
||||
|
||||
func GameOrder() IGameOrder { |
||||
return &gameOrderService |
||||
} |
||||
|
||||
func (o gameOrderImpl) GetOrders(ctx context.Context, req *game.OrderSearchReq) (res *game.OrderSearchRes, err error) { |
||||
account := req.Account |
||||
role := new(entity.RoleDetail) |
||||
res = new(game.OrderSearchRes) |
||||
if req.SearchType == 1 { //账号+渠道查询
|
||||
if len(req.Channel) > 0 { |
||||
account = req.Channel + "_" + account |
||||
} |
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Orders, err = internal.GetOrdersByAccount(ctx, account) |
||||
}) |
||||
} else if req.SearchType == 2 { //角色UID+区服
|
||||
role, err = internal.GetRoleDetail(ctx, req.Uid, req.ServerId) |
||||
if err != nil { |
||||
return |
||||
} |
||||
account = role.Account |
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Orders, err = internal.GetOrdersByAccount(ctx, account) |
||||
}) |
||||
} else if req.SearchType == 3 { //时间段查询
|
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Orders, err = internal.GetOrdersByTime(ctx, req.LowTime, req.UpTime) |
||||
}) |
||||
} else if req.SearchType == 4 { //时间段查询
|
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Orders, err = internal.GetOrdersByOrderId(ctx, req.OrderId) |
||||
}) |
||||
} |
||||
|
||||
return |
||||
} |
||||
|
||||
func (o gameOrderImpl) GetOrderCount(ctx context.Context, req *game.OrderCountReq) (res *game.OrderCountRes, err error) { |
||||
filter := bson.M{} |
||||
|
||||
if req.Amount > 0 { |
||||
switch req.CompareType { |
||||
case 1: |
||||
filter["money"] = req.Amount |
||||
case 2: |
||||
filter["money"] = bson.M{"$lte": req.Amount} |
||||
case 3: |
||||
filter["money"] = bson.M{"$lt": req.Amount} |
||||
case 4: |
||||
filter["money"] = bson.M{"$gt": req.Amount} |
||||
case 5: |
||||
filter["money"] = bson.M{"$gte": req.Amount} |
||||
} |
||||
} |
||||
if req.Gender > 0 { |
||||
filter["gender"] = req.Gender |
||||
} |
||||
if req.LowAge >= 0 && req.UpAge > 0 { |
||||
low := (time.Now().AddDate(-req.UpAge, 0, 0)).Unix() |
||||
up := (time.Now().AddDate(-req.LowAge, 0, 0)).Unix() |
||||
filter["bearTime"] = bson.M{"$gte": low, "$lte": up} |
||||
} |
||||
|
||||
g.Try(ctx, func(ctx context.Context) { |
||||
res.Orders, err = internal.GetorderCount(ctx, filter, req.ServerId) |
||||
}) |
||||
|
||||
return |
||||
} |
Loading…
Reference in new issue