Browse Source

itemLog

master
linquan 4 weeks ago
parent
commit
21ce3abc87
  1. 20
      api/v1/game/basicinfo.go
  2. 1
      api/v1/game/model.go
  3. 30
      api/v1/game/pub.go
  4. 4
      internal/controller/baseinfo_role.go
  5. 2
      internal/controller/game_pub.go
  6. 8
      internal/controller/game_server.go
  7. 38
      internal/dao/internal/item_income_expense_records.go
  8. 91
      internal/dao/internal/item_records_two.go
  9. 27
      internal/dao/item_records_two.go
  10. 21
      internal/model/do/item_income_expense_records.go
  11. 25
      internal/model/do/item_records_two.go
  12. 19
      internal/model/entity/item_income_expense_records.go
  13. 23
      internal/model/entity/item_records_two.go
  14. 6
      internal/serviceGame/game_role.go
  15. 3
      internal/serviceGame/internal/advertisement.go
  16. 72
      internal/serviceGame/internal/basicinfo.go
  17. 12
      internal/serviceGame/pub.go

20
api/v1/game/basicinfo.go

@ -101,7 +101,7 @@ type GetLoginOutLogRes struct {
type GetItemLogReq struct {
g.Meta `path:"/itemRecord/get" tags:"获取物品记录" method:"get" summary:"获取物品记录"`
Uid string `p:"uid"`
Uid int64 `p:"uid"`
Id string `p:"id"`
Account string `p:"account"`
ItemId int `p:"ItemId"`
@ -160,17 +160,25 @@ type GetShopItemListRes struct {
common.ListRes
}
type GetRegisterReq struct {
g.Meta `path:"/register/get" tags:"留存记录" method:"get" summary:"获取注册记录"`
Uid string `p:"id"`
type GetItemLogTwoReq struct {
g.Meta `path:"/itemRecord/getTwo" tags:"获取物品记录" method:"get" summary:"获取物品记录"`
Uid int64 `p:"uid"`
Id string `p:"id"`
Account string `p:"account"`
ItemId int `p:"itemId"`
ServerId int `p:"serverId" `
common.PageReq
}
type GetRegisterRes struct {
type ItemRecordsTwo struct {
entity.ItemRecordsTwo
StringId string `json:"stringId"`
UniqueId int64 `json:"uniqueId"`
}
type GetItemLogTwoRes struct {
g.Meta `mime:"application/json"`
Logs []entity.GameRegister `json:"logs"`
Logs []ItemRecordsTwo `json:"logs"`
common.ListRes
}

1
api/v1/game/model.go

@ -65,6 +65,7 @@ type GetLoginOutGmReq struct {
ServerId int `p:"serverId"`
StoneAmount int `p:"stoneAmount"`
VouchersNum int `p:"vouchersNum"`
GoldIngot int `p:"goldIngot"`
CDate int64 `p:"cDate"`
common.PageReq
}

30
api/v1/game/pub.go

@ -79,13 +79,14 @@ type UnitChangeNameRes struct {
}
type ItemRecordReq struct {
g.Meta `path:"/itemRecord" tags:"外部接口" method:"post" summary:"添加物品流向记录"`
Uid int64 `p:"uid"`
ItemId int32 `p:"itemId"`
Num int32 `p:"num"`
Way string `p:"way"`
State int32 `p:"state"`
Server int `p:"server"`
g.Meta `path:"/itemRecord" tags:"外部接口" method:"post" summary:"添加物品流向记录"`
Uid int64 `p:"uid"`
ItemId int32 `p:"itemId"`
Num int32 `p:"num"`
Way string `p:"way"`
State int32 `p:"state"`
Server int `p:"server"`
OldTotal int `p:"oldTotal"`
}
type ItemRecordRes struct {
@ -151,3 +152,18 @@ type GetOpenIdRes struct {
g.Meta `mime:"application/json"`
State int `json:"state"`
}
type ItemRecordTwoReq struct {
g.Meta `path:"/itemRecordTwo" tags:"外部接口" method:"post" summary:"添加物品流向记录"`
Uid int64 `p:"uid"`
ItemId int32 `p:"itemId"`
Num int32 `p:"num"`
Way string `p:"way"`
State int32 `p:"state"`
Server int `p:"server"`
OldTotal int `p:"oldTotal"`
}
type ItemRecordTwoRes struct {
g.Meta `mime:"application/json"`
}

4
internal/controller/baseinfo_role.go

@ -47,8 +47,8 @@ func (c *gameRoleController) GetItemLog(ctx context.Context, req *game.GetItemLo
return res, err
}
func (c *gameRoleController) GetRegister(ctx context.Context, req *game.GetRegisterReq) (res *game.GetRegisterRes, err error) {
res, err = serviceGame.GameRole().GetRegister(ctx, req)
func (c *gameRoleController) GetItemLogTwo(ctx context.Context, req *game.GetItemLogTwoReq) (res *game.GetItemLogTwoRes, err error) {
res, err = serviceGame.GameRole().GetItemLogTwo(ctx, req)
return res, err
}

2
internal/controller/game_pub.go

@ -140,7 +140,7 @@ func (c *pubController) ConversionHugeAmount(ctx context.Context, req *game.CSHA
}
func (c *pubController) AdvertiseHugeAmount(ctx context.Context, req *game.AdvertiseHAReq) (res *game.AdvertiseHARes, err error) {
log.Print("AdvertiseHugeAmount", gjson.MustEncodeString(req))
//log.Print("AdvertiseHugeAmount", gjson.MustEncodeString(req))
res, err = serviceGame.Advertisement().AdvertiseHugeAmount(ctx, req)
return
}

8
internal/controller/game_server.go

@ -38,6 +38,14 @@ func (c *serverController) ItemIncomeExpenseRecords(ctx context.Context, req *ga
return
}
func (c *serverController) ItemRecordTwo(ctx context.Context, req *game.ItemRecordTwoReq) (res *game.ItemRecordTwoRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
res = new(game.ItemRecordTwoRes)
res, err = serviceGame.GamePub().ItemRecordTwo(ctx, req)
})
return
}
func (c *serverController) ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
res = new(game.ShopRecordRes)

38
internal/dao/internal/item_income_expense_records.go

@ -20,28 +20,30 @@ type ItemIncomeExpenseRecordsDao struct {
// ItemIncomeExpenseRecordsColumns defines and stores column names for table item_income_expense_records.
type ItemIncomeExpenseRecordsColumns struct {
Id string // 唯一
Uid string // 账号
ItemId string // 物品Id
Num string // 数量
Way string // 消耗途径
State string // 1:消耗,2:增加
AddTime string // 添加时间
CTime string // 创建记录时间
Server string // 区服
Id string // 唯一
Uid string // 账号
ItemId string // 物品Id
Num string // 数量
Way string // 消耗途径
State string // 1:消耗,2:增加
AddTime string // 添加时间
CTime string // 创建记录时间
Server string // 区服
OldTotal string //
}
// itemIncomeExpenseRecordsColumns holds the columns for table item_income_expense_records.
var itemIncomeExpenseRecordsColumns = ItemIncomeExpenseRecordsColumns{
Id: "id",
Uid: "uid",
ItemId: "item_id",
Num: "num",
Way: "way",
State: "state",
AddTime: "add_time",
CTime: "c_time",
Server: "server",
Id: "id",
Uid: "uid",
ItemId: "item_id",
Num: "num",
Way: "way",
State: "state",
AddTime: "add_time",
CTime: "c_time",
Server: "server",
OldTotal: "old_total",
}
// NewItemIncomeExpenseRecordsDao creates and returns a new DAO object for table data access.

91
internal/dao/internal/item_records_two.go

@ -0,0 +1,91 @@
// ==========================================================================
// 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"
)
// ItemRecordsTwoDao is the data access object for table item_records_two.
type ItemRecordsTwoDao 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 ItemRecordsTwoColumns // columns contains all the column names of Table for convenient usage.
}
// ItemRecordsTwoColumns defines and stores column names for table item_records_two.
type ItemRecordsTwoColumns struct {
Id string // 唯一
Uid string // 账号
ItemId string // 物品Id
Num string // 数量
Way string // 消耗途径
State string // 1:消耗,2:增加
AddTime string // 添加时间
CTime string // 创建记录时间
Server string // 区服
OldTotal string //
}
// itemRecordsTwoColumns holds the columns for table item_records_two.
var itemRecordsTwoColumns = ItemRecordsTwoColumns{
Id: "id",
Uid: "uid",
ItemId: "item_id",
Num: "num",
Way: "way",
State: "state",
AddTime: "add_time",
CTime: "c_time",
Server: "server",
OldTotal: "old_total",
}
// NewItemRecordsTwoDao creates and returns a new DAO object for table data access.
func NewItemRecordsTwoDao() *ItemRecordsTwoDao {
return &ItemRecordsTwoDao{
group: "default",
table: "item_records_two",
columns: itemRecordsTwoColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *ItemRecordsTwoDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *ItemRecordsTwoDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *ItemRecordsTwoDao) Columns() ItemRecordsTwoColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *ItemRecordsTwoDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *ItemRecordsTwoDao) 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 *ItemRecordsTwoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

27
internal/dao/item_records_two.go

@ -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"
)
// internalItemRecordsTwoDao is internal type for wrapping internal DAO implements.
type internalItemRecordsTwoDao = *internal.ItemRecordsTwoDao
// itemRecordsTwoDao is the data access object for table item_records_two.
// You can define custom methods on it to extend its functionality as you wish.
type itemRecordsTwoDao struct {
internalItemRecordsTwoDao
}
var (
// ItemRecordsTwo is globally public accessible object for table item_records_two operations.
ItemRecordsTwo = itemRecordsTwoDao{
internal.NewItemRecordsTwoDao(),
}
)
// Fill with you ideas below.

21
internal/model/do/item_income_expense_records.go

@ -11,14 +11,15 @@ import (
// ItemIncomeExpenseRecords is the golang structure of table item_income_expense_records for DAO operations like Where/Data.
type ItemIncomeExpenseRecords struct {
g.Meta `orm:"table:item_income_expense_records, do:true"`
Id interface{} // 唯一
Uid interface{} // 账号
ItemId interface{} // 物品Id
Num interface{} // 数量
Way interface{} // 消耗途径
State interface{} // 1:消耗,2:增加
AddTime interface{} // 添加时间
CTime *gtime.Time // 创建记录时间
Server interface{} // 区服
g.Meta `orm:"table:item_income_expense_records, do:true"`
Id interface{} // 唯一
Uid interface{} // 账号
ItemId interface{} // 物品Id
Num interface{} // 数量
Way interface{} // 消耗途径
State interface{} // 1:消耗,2:增加
AddTime interface{} // 添加时间
CTime *gtime.Time // 创建记录时间
Server interface{} // 区服
OldTotal interface{} //
}

25
internal/model/do/item_records_two.go

@ -0,0 +1,25 @@
// =================================================================================
// 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"
)
// ItemRecordsTwo is the golang structure of table item_records_two for DAO operations like Where/Data.
type ItemRecordsTwo struct {
g.Meta `orm:"table:item_records_two, do:true"`
Id interface{} // 唯一
Uid interface{} // 账号
ItemId interface{} // 物品Id
Num interface{} // 数量
Way interface{} // 消耗途径
State interface{} // 1:消耗,2:增加
AddTime interface{} // 添加时间
CTime *gtime.Time // 创建记录时间
Server interface{} // 区服
OldTotal interface{} //
}

19
internal/model/entity/item_income_expense_records.go

@ -10,13 +10,14 @@ import (
// ItemIncomeExpenseRecords is the golang structure for table item_income_expense_records.
type ItemIncomeExpenseRecords struct {
Id int64 `json:"id" description:"唯一"`
Uid int64 `json:"uid" description:"账号"`
ItemId int `json:"itemId" description:"物品Id"`
Num int64 `json:"num" description:"数量"`
Way string `json:"way" description:"消耗途径"`
State int `json:"state" description:"1:消耗,2:增加"`
AddTime int64 `json:"addTime" description:"添加时间"`
CTime *gtime.Time `json:"cTime" description:"创建记录时间"`
Server int `json:"server" description:"区服"`
Id int64 `json:"id" description:"唯一"`
Uid int64 `json:"uid" description:"账号"`
ItemId int `json:"itemId" description:"物品Id"`
Num int64 `json:"num" description:"数量"`
Way string `json:"way" description:"消耗途径"`
State int `json:"state" description:"1:消耗,2:增加"`
AddTime int64 `json:"addTime" description:"添加时间"`
CTime *gtime.Time `json:"cTime" description:"创建记录时间"`
Server int `json:"server" description:"区服"`
OldTotal int64 `json:"oldTotal" description:""`
}

23
internal/model/entity/item_records_two.go

@ -0,0 +1,23 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// ItemRecordsTwo is the golang structure for table item_records_two.
type ItemRecordsTwo struct {
Id int64 `json:"id" description:"唯一"`
Uid int64 `json:"uid" description:"账号"`
ItemId int `json:"itemId" description:"物品Id"`
Num int64 `json:"num" description:"数量"`
Way string `json:"way" description:"消耗途径"`
State int `json:"state" description:"1:消耗,2:增加"`
AddTime int64 `json:"addTime" description:"添加时间"`
CTime *gtime.Time `json:"cTime" description:"创建记录时间"`
Server int `json:"server" description:"区服"`
OldTotal int64 `json:"oldTotal" description:""`
}

6
internal/serviceGame/game_role.go

@ -23,7 +23,7 @@ type IGameRole interface {
GetLoginOut(ctx context.Context, req *game.GetLoginOutReq) (res *game.GetLoginOutRes, err error)
GetLoginOutLog(ctx context.Context, req *game.GetLoginOutLogReq) (res *game.GetLoginOutLogRes, err error)
GetItemLog(ctx context.Context, req *game.GetItemLogReq) (res *game.GetItemLogRes, err error)
GetRegister(ctx context.Context, req *game.GetRegisterReq) (res *game.GetRegisterRes, err error)
GetItemLogTwo(ctx context.Context, req *game.GetItemLogTwoReq) (res *game.GetItemLogTwoRes, err error)
GameUserDel(ctx context.Context, req *game.UserDelReq) (res *game.UserDelRes, err error)
GetLoginOutGm(ctx context.Context, req *game.GetLoginOutGmReq) (res *game.GetLoginOutGmRes, err error)
}
@ -130,8 +130,8 @@ func (s *gameRoleImpl) GetItemLog(ctx context.Context, req *game.GetItemLogReq)
return
}
func (s *gameRoleImpl) GetRegister(ctx context.Context, req *game.GetRegisterReq) (res *game.GetRegisterRes, err error) {
res, err = internal.GetRegister(ctx, req)
func (s *gameRoleImpl) GetItemLogTwo(ctx context.Context, req *game.GetItemLogTwoReq) (res *game.GetItemLogTwoRes, err error) {
res, err = internal.GetItemLogTwo(ctx, req)
return
}

3
internal/serviceGame/internal/advertisement.go

@ -7,7 +7,6 @@ import (
"fmt"
"github.com/gogf/gf/v2/encoding/gcharset"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"log"
"strconv"
@ -157,7 +156,7 @@ func AttributionHugeAmount(ctx context.Context, req *game.ATHAReq) (res *game.AT
}
_, _ = dao.AdvertisementOceanegine.Ctx(ctx).Insert(advertiseData)
} else {
return nil, gerror.New("获取失败")
return nil, errors.New("获取失败")
}
return

72
internal/serviceGame/internal/basicinfo.go

@ -688,10 +688,9 @@ func GetItemLog(ctx context.Context, req *game.GetItemLogReq) (res *game.GetItem
}
model = model.Where("uid=? ", uid)
model = model.Where("server=? ", req.ServerId)
} else if req.Uid != "" {
uid, _ := strconv.ParseInt(req.Uid, 10, 64)
if uid == 0 {
} else if req.Uid != 0 {
uid, err1 := GetIdToUid(ctx, req.Uid)
if err1 != nil {
err = gerror.New("获取账号失败!")
return
}
@ -719,33 +718,47 @@ func GetItemLog(ctx context.Context, req *game.GetItemLogReq) (res *game.GetItem
return
}
func GetRegister(ctx context.Context, req *game.GetRegisterReq) (res *game.GetRegisterRes, err error) {
res = new(game.GetRegisterRes)
func GetItemLogTwo(ctx context.Context, req *game.GetItemLogTwoReq) (res *game.GetItemLogTwoRes, err error) {
res = new(game.GetItemLogTwoRes)
g.Try(ctx, func(ctx context.Context) {
model := dao.ItemIncomeExpenseRecords.Ctx(ctx)
model := dao.ItemRecordsTwo.Ctx(ctx)
if req.Account != "" {
uid, _ := GetAccountUid2(ctx, req.Account, fmt.Sprint(req.ServerId))
if uid == 0 {
//g.Log().Debugf(ctx, "LoginOut -> "+fmt.Sprint(uid))
err = gerror.New("获取账号失败!")
return
}
model = model.Where("uid=? ", uid)
} else if req.Uid != "" {
uid, _ := strconv.ParseInt(req.Uid, 10, 64)
model = model.Where("server=? ", req.ServerId)
} else if req.Uid != 0 {
uid, _ := GetIdToUid(ctx, req.Uid)
if uid == 0 {
err = gerror.New("获取账号失败!")
return
}
model = model.Where("uid=? ", uid)
model = model.Where("server=? ", req.ServerId)
} else if req.Id != "" {
uid, _ := strconv.ParseInt(req.Id, 10, 64)
if uid == 0 {
//g.Log().Debugf(ctx, "LoginOut -> "+fmt.Sprint(uid))
err = gerror.New("获取账号失败!")
return
}
model = model.Where("uid=? ", uid)
model = model.Where("server=? ", req.ServerId)
}
if req.ItemId != 0 {
model = model.Where("item_id=? ", req.ItemId)
}
res.Total, err = model.Count()
err = model.Page(req.PageNum, req.PageSize).Scan(&res.Logs)
err = model.Page(req.PageNum, req.PageSize).Order("c_time desc").Scan(&res.Logs)
if err != nil {
return
}
for k, v := range res.Logs {
res.Logs[k].StringId = fmt.Sprint(v.Uid)
res.Logs[k].UniqueId, _ = GetIdToUid(ctx, v.Uid)
}
return
})
return
@ -978,12 +991,30 @@ func ItemIncomeExpenseRecords(ctx context.Context, req *game.ItemRecordReq) (res
g.Try(ctx, func(ctx context.Context) {
model := dao.ItemIncomeExpenseRecords.Ctx(ctx)
_, err = model.Insert(&do.ItemIncomeExpenseRecords{
Uid: req.Uid,
ItemId: req.ItemId,
Num: req.Num,
Way: req.Way,
State: req.State,
Server: req.Server,
Uid: req.Uid,
ItemId: req.ItemId,
Num: req.Num,
Way: req.Way,
State: req.State,
Server: req.Server,
OldTotal: req.OldTotal,
})
return
})
return
}
func ItemRecordsTwo(ctx context.Context, req *game.ItemRecordTwoReq) (res *game.ItemRecordTwoRes, err error) {
g.Try(ctx, func(ctx context.Context) {
model := dao.ItemRecordsTwo.Ctx(ctx)
_, err = model.Insert(&do.ItemRecordsTwo{
Uid: req.Uid,
ItemId: req.ItemId,
Num: req.Num,
Way: req.Way,
State: req.State,
Server: req.Server,
OldTotal: req.OldTotal,
})
return
})
@ -1177,6 +1208,9 @@ func GetLoginOutGm(ctx context.Context, req *game.GetLoginOutGmReq) (res *game.G
if req.VouchersNum > 0 {
model = model.Where("vouchersNum>? ", req.VouchersNum)
}
if req.GoldIngot > 0 {
model = model.Where("goldIngot>? ", req.GoldIngot)
}
if req.StoneAmount > 0 {
model = model.Where("stoneAmount>? ", req.StoneAmount)
}

12
internal/serviceGame/pub.go

@ -17,6 +17,7 @@ type IGamePub interface {
GetId(ctx context.Context, req *game.GetOutIdReq) (res *game.GetOutIdRes, err error)
LoginOut(ctx context.Context, req *game.LoginOutReq) (res *game.LoginOutRes, err error)
ItemRecord(ctx context.Context, req *game.ItemRecordReq) (res *game.ItemRecordRes, err error)
ItemRecordTwo(ctx context.Context, req *game.ItemRecordTwoReq) (res *game.ItemRecordTwoRes, err error)
ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error)
SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, err error)
GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (res *game.GetOpenIdRes, err error)
@ -76,6 +77,17 @@ func (c *gamePubImpl) ItemRecord(ctx context.Context, req *game.ItemRecordReq) (
return
}
func (c *gamePubImpl) ItemRecordTwo(ctx context.Context, req *game.ItemRecordTwoReq) (res *game.ItemRecordTwoRes, err error) {
//ip := libUtils.GetClientIp(ctx)
//fmt.Println("ip: ", ip)
g.Try(ctx, func(ctx context.Context) {
res = new(game.ItemRecordTwoRes)
res, err = internal.ItemRecordsTwo(ctx, req)
return
})
return
}
func (c *gamePubImpl) ShopRecords(ctx context.Context, req *game.ShopRecordReq) (res *game.ShopRecordRes, err error) {
res, err = internal.ShopRecords(ctx, req)
return

Loading…
Cancel
Save