Browse Source

debug

master
linquan 3 months ago
parent
commit
24bd8dd1c3
  1. 42
      api/v1/game/basicinfo.go
  2. 7
      api/v1/game/ccd.go
  3. 2
      api/v1/game/notice.go
  4. 13
      api/v1/game/pub.go
  5. 5
      internal/controller/game_login_url.go
  6. 5
      internal/controller/game_manage.go
  7. 30
      internal/dao/internal/game_shop_log.go
  8. 17
      internal/model/do/game_shop_log.go
  9. 15
      internal/model/entity/game_shop_log.go
  10. 80
      internal/serviceGame/internal/basicinfo.go
  11. 80
      internal/serviceGame/internal/blackList.go
  12. 18
      internal/serviceGame/internal/dbinit.go
  13. 4
      internal/serviceGame/loginUrl.go
  14. 8
      internal/serviceGame/manage.go

42
api/v1/game/basicinfo.go

@ -2,6 +2,7 @@ package game
import (
"github.com/gogf/gf/v2/frame/g"
"tyj_admin/api/v1/common"
"tyj_admin/internal/model/entity"
)
@ -136,18 +137,47 @@ type GetItemLogRes struct {
}
type GetShopItemLogReq struct {
g.Meta `path:"/order/shopList" tags:"获取物品记录" method:"get" summary:"获取商店物品记录"`
LowTime int64 `p:"startTime"`
Uptime int64 `p:"endTime"`
g.Meta `path:"/order/shopLog" tags:"获取物品记录" method:"get" summary:"获取商店物品记录"`
LowTime string `p:"startTime"`
Uptime string `p:"endTime"`
GM int `p:"gm"`
ServerId int `p:"serverId" `
Channel string `p:"channel" `
common.PageReq
}
type ShopItemLog struct {
ItemId int `json:"itemId" description:"物品Id"`
Num int `json:"num" description:"数量"`
ConfigType int `json:"config_type" description:"消耗途径"`
}
type GetShopItemLogRes struct {
g.Meta `mime:"application/json"`
Logs []entity.GameShopLog `json:"logs"`
RechargeTotal int `json:"rechargeTotal"`
Logs []ShopItemLog `json:"logs"`
RechargeTotal int `json:"rechargeTotal"`
common.ListRes
}
type GetShopItemListReq struct {
g.Meta `path:"/order/shopList" tags:"获取物品记录" method:"get" summary:"获取商店物品记录"`
LowTime string `p:"startTime"`
Uptime string `p:"endTime"`
GM int `p:"gm"`
ServerId int `p:"serverId" `
Uid int `p:"uid" `
common.PageReq
}
type ShopItemList struct {
Account string `json:"account" description:"账号"`
UniqueId string `json:"uniqueId" description:"账号"`
StringId string `json:"stringId" description:"账号"`
entity.GameShopLog
}
type GetShopItemListRes struct {
g.Meta `mime:"application/json"`
Logs []ShopItemList `json:"logs"`
common.ListRes
}
type GetRegisterReq struct {

7
api/v1/game/ccd.go

@ -269,15 +269,14 @@ type DelWhiteListRes struct {
}
type GetListBlackListReq struct {
g.Meta `path:"/blackList/get" tags:"ip白名单" method:"post" summary:"获取ip白名单列表"`
PageNum int `p:"pageNum"`
PageSize int `p:"pageSize"`
g.Meta `path:"/blackList/get" tags:"ip白名单" method:"post" summary:"获取ip白名单列表"`
common.PageReq
}
type GetListBlackListRes struct {
g.Meta `mime:"application/json"`
WhiteList []entity.GameBlackList `json:"whiteList"`
Total int `json:"total"`
common.ListRes
}
type GetBlackListReq struct {

2
api/v1/game/notice.go

@ -2,6 +2,7 @@ package game
import (
"github.com/gogf/gf/v2/frame/g"
"tyj_admin/api/v1/common"
"tyj_admin/internal/model/entity"
)
@ -105,6 +106,7 @@ type GetNoticeListReq struct {
g.Meta `path:"/notice/list" tags:"公告" method:"post" summary:"公告列表"`
Channel string `p:"channel"`
NoticeType int `p:"noticeType"`
common.PageReq
}
type GetNoticeListRes struct {

13
api/v1/game/pub.go

@ -157,12 +157,13 @@ type ItemRecordRes struct {
}
type ShopRecordReq struct {
g.Meta `path:"/shopRecord" tags:"外部接口" method:"post" summary:"添加商城流向记录"`
Uid int64 `p:"uid"`
ItemId int `p:"itemId"`
Price int `p:"price"`
Num int32 `p:"num"`
ServerId int32 `p:"serverId"`
g.Meta `path:"/shopRecord" tags:"外部接口" method:"post" summary:"添加商城流向记录"`
Uid int64 `p:"uid"`
ItemId int `p:"itemId"`
Price int `p:"price"`
Num int32 `p:"num"`
ServerId int32 `p:"serverId"`
ConfigType int32 `p:"configType"`
}
type ShopRecordRes struct {

5
internal/controller/game_login_url.go

@ -71,3 +71,8 @@ func (c *loginUrlController) GetServerVersionList(ctx context.Context, req *game
res, err = serviceGame.GameLoginUrl().GetServerVersionList(ctx, req)
return res, err
}
func (c *loginUrlController) UpdateRouter(ctx context.Context, req *game.AddRouterReq) (res *game.AddRouterRes, err error) {
res, err = serviceGame.GameLoginUrl().UpdateRouter(ctx, req)
return res, err
}

5
internal/controller/game_manage.go

@ -61,3 +61,8 @@ func (c *manageController) GetShopItemLog(ctx context.Context, req *game.GetShop
res, err = serviceGame.GameManage().GetShopItemLog(ctx, req)
return res, err
}
func (c *manageController) GetShopItemList(ctx context.Context, req *game.GetShopItemListReq) (res *game.GetShopItemListRes, err error) {
res, err = serviceGame.GameManage().GetShopItemList(ctx, req)
return res, err
}

30
internal/dao/internal/game_shop_log.go

@ -20,24 +20,26 @@ type GameShopLogDao struct {
// GameShopLogColumns defines and stores column names for table game_shop_log.
type GameShopLogColumns struct {
Id string //
Uid string //
ItemId string //
Num string //
Price string // 价格
CDate string //
ServerId string //
Id string //
Uid string //
ItemId string //
Num string //
Price string // 价格
CDate string //
ServerId string //
ConfigType string //
}
// gameShopLogColumns holds the columns for table game_shop_log.
var gameShopLogColumns = GameShopLogColumns{
Id: "id",
Uid: "uid",
ItemId: "itemId",
Num: "num",
Price: "price",
CDate: "c_date",
ServerId: "serverId",
Id: "id",
Uid: "uid",
ItemId: "itemId",
Num: "num",
Price: "price",
CDate: "c_date",
ServerId: "serverId",
ConfigType: "config_type",
}
// NewGameShopLogDao creates and returns a new DAO object for table data access.

17
internal/model/do/game_shop_log.go

@ -11,12 +11,13 @@ import (
// GameShopLog is the golang structure of table game_shop_log for DAO operations like Where/Data.
type GameShopLog struct {
g.Meta `orm:"table:game_shop_log, do:true"`
Id interface{} //
Uid interface{} //
ItemId interface{} //
Num interface{} //
Price interface{} // 价格
CDate *gtime.Time //
ServerId interface{} //
g.Meta `orm:"table:game_shop_log, do:true"`
Id interface{} //
Uid interface{} //
ItemId interface{} //
Num interface{} //
Price interface{} // 价格
CDate *gtime.Time //
ServerId interface{} //
ConfigType interface{} //
}

15
internal/model/entity/game_shop_log.go

@ -10,11 +10,12 @@ import (
// GameShopLog is the golang structure for table game_shop_log.
type GameShopLog struct {
Id int64 `json:"id" description:""`
Uid int64 `json:"uid" description:""`
ItemId int `json:"itemId" description:""`
Num int `json:"num" description:""`
Price int `json:"price" description:"价格"`
CDate *gtime.Time `json:"cDate" description:""`
ServerId int `json:"serverId" description:""`
Id int64 `json:"id" description:""`
Uid int64 `json:"uid" description:""`
ItemId int `json:"itemId" description:""`
Num int `json:"num" description:""`
Price int `json:"price" description:"价格"`
CDate *gtime.Time `json:"cDate" description:""`
ServerId int `json:"serverId" description:""`
ConfigType int `json:"configType" description:""`
}

80
internal/serviceGame/internal/basicinfo.go

@ -943,52 +943,52 @@ func ItemIncomeExpenseRecords(ctx context.Context, req *game.ItemRecordReq) (res
func ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error) {
res = new(game.ShopRecordRes)
g.Try(ctx, func(ctx context.Context) {
model := dao.GameShopLog.Ctx(ctx)
_, err = model.Insert(&do.GameShopLog{
Uid: req.Uid,
ItemId: req.ItemId,
Price: req.Price,
Num: req.Num,
ServerId: req.ServerId,
Uid: req.Uid,
ItemId: req.ItemId,
Price: req.Price,
Num: req.Num,
ServerId: req.ServerId,
ConfigType: req.ConfigType,
})
return
})
g.Log().Info(ctx, "a== ", res)
return
}
func GetShopItemLog(ctx context.Context, req *game.GetShopItemLogReq) (res *game.GetShopItemLogRes, err error) {
res = new(game.GetShopItemLogRes)
g.Try(ctx, func(ctx context.Context) {
shopLogSql := fmt.Sprintf(`select u.account,s.itemId,s.num,s.price from game_shop_log s inner join game_unit u on s.uid=u.uid where 1=1`)
shopLogSql := fmt.Sprintf(`select u.account,s.itemId,s.num,s.price,s.config_type from game_shop_log s inner join game_unit u on s.uid=u.uid and s.serverId=u.server where 1=1`)
rechargeSql := fmt.Sprintf(`select DISTINCT u.account from game_recharge r inner join game_unit u on r.unitId=u.uid inner join game_register rr on rr.account=u.account where r.status=2`)
if req.LowTime != 0 {
start := time.Unix(req.LowTime, 0).Format(consts.TIME_FORMAT)
rechargeSql += fmt.Sprintf(` and rr.create_time>%s`, start)
shopLogSql += fmt.Sprintf(` and s.c_date>%s`, start)
if req.LowTime != "" {
//start := time.Unix(req.LowTime, 0).Format(consts.TIME_FORMAT)
rechargeSql += fmt.Sprintf(` and rr.create_time>"%s"`, req.LowTime)
shopLogSql += fmt.Sprintf(` and s.c_date>"%s"`, req.LowTime)
}
if req.Uptime != 0 {
end := time.Unix(req.Uptime, 0).Format(consts.TIME_FORMAT)
rechargeSql = fmt.Sprintf(`%s and rr.create_time<%s`, rechargeSql, end)
shopLogSql = fmt.Sprintf(`%s and s.c_date<%s`, shopLogSql, end)
if req.Uptime != "" {
//end := time.Unix(req.Uptime, 0).Format(consts.TIME_FORMAT)
rechargeSql = fmt.Sprintf(`%s and rr.create_time<"%s"`, rechargeSql, req.Uptime)
shopLogSql = fmt.Sprintf(`%s and s.c_date<"%s"`, shopLogSql, req.Uptime)
}
if req.ServerId != 0 {
rechargeSql = fmt.Sprintf(`%s and u.server=%d`, rechargeSql, req.ServerId)
shopLogSql = fmt.Sprintf(`%s and u.server=%d`, shopLogSql, req.ServerId)
}
if req.Channel != "" {
rechargeSql = fmt.Sprintf(`%s and u.channel=%s`, rechargeSql, req.Channel)
shopLogSql = fmt.Sprintf(`%s and u.channel=%s`, shopLogSql, req.Channel)
rechargeSql = fmt.Sprintf(`%s and u.channel="%s"`, rechargeSql, req.Channel)
shopLogSql = fmt.Sprintf(`%s and u.channel="%s"`, shopLogSql, req.Channel)
}
if req.GM == 0 {
rechargeSql = fmt.Sprintf(`%s and r.tradeNo NOT LIKE 'GM%%'`, rechargeSql)
rechargeSql = fmt.Sprintf(`%s and r.tradeNo NOT LIKE "GM%%"`, rechargeSql)
}
shopLogSql = fmt.Sprintf(`select a.account, a.itemId from (%s) as a group by a.itemId,a.account`, shopLogSql)
shopLogSql = fmt.Sprintf(`select count(1) as num, b.itemId from (%s) as b group by b.itemId`, shopLogSql)
err = g.Model().Raw(shopLogSql).Scan(&res.Logs)
shopLogSql = fmt.Sprintf(`select a.account, a.itemId, a.config_type from (%s) as a group by a.itemId,a.config_type,a.account`, shopLogSql)
shopLogSql = fmt.Sprintf(`select count(1) as num, b.itemId, b.config_type from (%s) as b group by b.itemId,b.config_type`, shopLogSql)
res.Total, err = g.Model().Raw(shopLogSql).Count()
err = g.Model().Raw(shopLogSql).Page(req.PageNum, req.PageSize).Scan(&res.Logs)
res.RechargeTotal, err = g.Model().Raw(rechargeSql).Count()
if err != nil {
return
@ -998,6 +998,42 @@ func GetShopItemLog(ctx context.Context, req *game.GetShopItemLogReq) (res *game
return
}
func GetShopItemList(ctx context.Context, req *game.GetShopItemListReq) (res *game.GetShopItemListRes, err error) {
res = new(game.GetShopItemListRes)
g.Try(ctx, func(ctx context.Context) {
model := dao.GameShopLog.Ctx(ctx)
if req.LowTime != "" {
model = model.Where("c_date>?", req.LowTime)
}
if req.Uptime != "" {
model = model.Where("c_date<?", req.Uptime)
}
if req.ServerId != 0 {
model = model.Where("serverId=?", req.ServerId)
}
if req.Uid != 0 {
id, _ := GetIdToUid(ctx, int64(req.Uid))
model = model.Where("uid=?", id)
}
err = model.Page(req.PageNum, req.PageSize).OrderDesc("c_date").Scan(&res.Logs)
res.Total, err = model.Count()
for k, v := range res.Logs {
res.Logs[k].StringId = fmt.Sprint(v.Uid)
res.Logs[k].UniqueId, _ = GetStringIdToUid(ctx, res.Logs[k].StringId)
account, err := GetUnitById(ctx, v.Uid, v.ServerId)
if err != nil {
continue
}
res.Logs[k].Account = fmt.Sprint(account.Account)
}
if err != nil {
return
}
return
})
return
}
func GameUserDel(ctx context.Context, req *game.UserDelReq) (res *game.UserDelRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
res = new(game.UserDelRes)

80
internal/serviceGame/internal/blackList.go

@ -2,7 +2,6 @@ package internal
import (
"context"
"fmt"
"tyj_admin/api/v1/game"
"tyj_admin/internal/dao"
"tyj_admin/internal/model/do"
@ -11,18 +10,6 @@ import (
)
func GetBlackListByPage(ctx context.Context, req *game.GetListBlackListReq) (res *game.GetListBlackListRes, err error) {
//rdbTop := RedisDbList[0]
//rdbTop.Do(ctx, "select", 0)
//var m []string
//result := rdbTop.Get(ctx, "ipWhiteList")
//json.Unmarshal([]byte(result.Val()), &m)
//start := (req.PageNum - 1) * req.PageSize
//end := req.PageNum * req.PageSize
//fmt.Println("GetWhiteListByPage: ", start, end, len(m))
//if end >= len(m) {
// return m[start:], len(m), result.Err()
//}
//return m[start:end], len(m), result.Err()
res = new(game.GetListBlackListRes)
model := dao.GameBlackList.Ctx(ctx)
res.Total, err = model.Count()
@ -32,7 +19,6 @@ func GetBlackListByPage(ctx context.Context, req *game.GetListBlackListReq) (res
}
func UpdateBlackList(ctx context.Context, req *game.UpdateBlackListReq) (res *game.UpdateBlackListRes, err error) {
model := dao.GameBlackList.Ctx(ctx)
var list []*entity.GameBlackList
err = model.Where("ip=? ", req.Ip).Scan(&list)
@ -49,23 +35,6 @@ func UpdateBlackList(ctx context.Context, req *game.UpdateBlackListReq) (res *ga
_, err = model.Insert(&do.GameBlackList{Ip: req.Ip})
}
//rdbTop := RedisDbList[0]
//rdbTop.Do(ctx, "select", 0)
//var m []string
//result := rdbTop.Get(ctx, "ipBlackList")
//
//json.Unmarshal([]byte(result.Val()), &m)
//if utils.ContainsString(m, ip) {
// return
//}
//
//m = append(m, ip)
//save, _ := json.Marshal(m)
//err = rdbTop.Set(ctx, "ipWhiteList", save, 0).Err()
//if err != nil {
// panic(err)
//}
////log.Print("res.Bazaar", m, err)
return
}
@ -80,23 +49,6 @@ func DelBlackList(ctx context.Context, req *game.DelBlackListReq) (res *game.Del
return
}
//rdbTop := RedisDbList[0]
//rdbTop.Do(ctx, "select", 0)
//var m []string
//result := rdbTop.Get(ctx, "ipWhiteList")
//
//json.Unmarshal([]byte(result.Val()), &m)
//if !utils.ContainsString(m, ip) {
// return
//}
//
//m = utils.DeleteSlice1(m, ip)
//save, _ := json.Marshal(m)
//err = rdbTop.Set(ctx, "ipWhiteList", save, 0).Err()
//if err != nil {
// panic(err)
//}
//log.Print("DelWhiteList", m, err)
return
}
@ -105,36 +57,4 @@ func GetBlackList(ctx context.Context) (list []*entity.GameBlackList, err error)
list = []*entity.GameBlackList{}
err = model.Scan(&list)
return
//rdbTop := RedisDbList[0]
//rdbTop.Do(ctx, "select", 0)
//var m []string
//result := rdbTop.Get(ctx, "ipWhiteList")
//
//json.Unmarshal([]byte(result.Val()), &m)
//
//return m, result.Err()
}
func GetBlackLock(ctx context.Context) (string, error) {
rdbTop := RedisDbList[0]
rdbTop.Do(ctx, "select", 0)
//var m string
result := rdbTop.Get(ctx, "ipWhiteLock")
fmt.Println("GetWhiteLock ---》 ipWhiteLock: ", result.Val())
//json.Unmarshal(byte(result.Val()), &m)
return result.Val(), result.Err()
}
func SetBlackLock(ctx context.Context, lock int32) error {
rdbTop := RedisDbList[0]
rdbTop.Do(ctx, "select", 0)
//var m string
result := rdbTop.Set(ctx, "ipWhiteLock", lock, 0)
fmt.Println("GetWhiteLock ---》 ipWhiteLock: ", result.Val())
//json.Unmarshal(byte(result.Val()), &m)
return result.Err()
}

18
internal/serviceGame/internal/dbinit.go

@ -36,11 +36,11 @@ var (
func init() {
//加载游戏相关配置
ctx := gctx.New()
mongoCfg, err := g.Cfg().Get(ctx, "game.mongo")
if err != nil {
return
}
MongoInit(mongoCfg.Maps())
//mongoCfg, err := g.Cfg().Get(ctx, "game.mongo")
//if err != nil {
// return
//}
MongoInit(ctx)
redisCfg, err := g.Cfg().Get(ctx, "game.redis")
if err != nil {
@ -70,8 +70,12 @@ func init() {
}
func MongoInit(config []map[string]interface{}) {
ctx := context.Background()
func MongoInit(ctx context.Context) {
mongoCfg, err := g.Cfg().Get(ctx, "game.mongo")
if err != nil {
return
}
config := mongoCfg.Maps()
MongoDatabaseList = map[string]*qmgo.Database{}
MongoConfigs = map[string]MongoType{}
for _, v := range config {

4
internal/serviceGame/loginUrl.go

@ -32,6 +32,7 @@ type IGameLoginUrl interface {
AddServerConfig(ctx context.Context, req *game.AddServerConfigReq) (res *game.AddServerConfigRes, err error)
GetRouter(ctx context.Context, req *game.GetRouterReq) (res *game.GetRouterRes, err error)
GetServerVersionList(ctx context.Context, req *game.GetServerVersionListReq) (res *game.GetServerVersionListRes, err error)
UpdateRouter(ctx context.Context, req *game.AddRouterReq) (res *game.AddRouterRes, err error)
}
type gameLoginUrlImpl struct {
@ -220,6 +221,7 @@ func (c *gameLoginUrlImpl) ReConfigServer(ctx context.Context, req *game.ReConfi
internal.InitRechargeServer(ctx)
internal.InitChannel(ctx)
internal.InitRouterServer(ctx)
internal.MongoInit(ctx)
return
}
@ -275,7 +277,7 @@ func (c *gameLoginUrlImpl) AddServerConfig(ctx context.Context, req *game.AddSer
return
}
func (c *gameLoginUrlImpl) updateRouter(ctx context.Context, req *game.AddRouterReq) (res *game.AddRouterRes, err error) {
func (c *gameLoginUrlImpl) UpdateRouter(ctx context.Context, req *game.AddRouterReq) (res *game.AddRouterRes, err error) {
res = new(game.AddRouterRes)
err = g.Try(ctx, func(ctx context.Context) {
server := []entity.GameRouter{}

8
internal/serviceGame/manage.go

@ -31,6 +31,7 @@ type IGameManage interface {
GetLive(ctx context.Context, req *game.GetLiveReq) (res *game.GetLiveRes, err error)
RegisterCount(ctx context.Context, req *game.RegisterCountReq) (res *game.RegisterCountRes, err error)
GetShopItemLog(ctx context.Context, req *game.GetShopItemLogReq) (res *game.GetShopItemLogRes, err error)
GetShopItemList(ctx context.Context, req *game.GetShopItemListReq) (res *game.GetShopItemListRes, err error)
}
type gameManageImpl struct {
@ -274,7 +275,7 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe
log.Printf("os.Remove failed with %s\n", err)
return
}
})
fmt.Println("UpdateUnit GetRoleDelta", req.DestName)
return
@ -338,3 +339,8 @@ func (ga *gameManageImpl) GetShopItemLog(ctx context.Context, req *game.GetShopI
res, err = internal.GetShopItemLog(ctx, req)
return
}
func (ga *gameManageImpl) GetShopItemList(ctx context.Context, req *game.GetShopItemListReq) (res *game.GetShopItemListRes, err error) {
res, err = internal.GetShopItemList(ctx, req)
return
}

Loading…
Cancel
Save