You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.5 KiB
92 lines
2.5 KiB
3 years ago
|
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
|
||
|
}
|