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.
526 lines
14 KiB
526 lines
14 KiB
|
1 year ago
|
package models
|
||
|
|
|
||
|
|
import (
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
"server/util"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
"github.com/olivere/elastic/v7"
|
||
|
|
)
|
||
|
|
|
||
|
|
// 通过流水表查询盈亏
|
||
|
|
func GetProfit(start, end *int64, channel *int, gameId *int, roomId *int, event *int, controlType *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if controlType != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("control_type", *controlType))
|
||
|
|
}
|
||
|
|
|
||
|
|
million, err := db.ES().SumBy(common.ESIndexBalance, "value", q)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("查询盈亏失败, error : [%s]", err.Error())
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
return -int64(million)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 聚合通过流水表查询盈亏
|
||
|
|
func GetProfitGroup(start, end *int64, channel *int, controlType *int, gameIDs []int) map[string]map[string]int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
if len(gameIDs) > 0 {
|
||
|
|
terms := []interface{}{}
|
||
|
|
for _, v := range gameIDs {
|
||
|
|
terms = append(terms, v)
|
||
|
|
}
|
||
|
|
q.Must(elastic.NewTermsQuery("desc.keyword", terms...))
|
||
|
|
}
|
||
|
|
ret := map[string]map[string]int64{}
|
||
|
|
totalBulk, err := db.ES().Group2SumBy(common.ESIndexBalance, "desc.keyword", "room_name.keyword", "value", q, "", false, 0)
|
||
|
|
if err == nil {
|
||
|
|
for _, v := range totalBulk.Buckets {
|
||
|
|
one := map[string]int64{}
|
||
|
|
for _, j := range v.Sub1.Buckets {
|
||
|
|
one[strconv.Itoa(util.GetInt(j.Key))] = -int64(j.Sub2.Value)
|
||
|
|
}
|
||
|
|
ret[strconv.Itoa(util.GetInt(v.Key))] = one
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return ret
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表查询盈亏 Value Gt
|
||
|
|
func GetProfitLimitValue(start, end *int64, channel *int, gameId *int, roomId *int, value *int64) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if value != nil {
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gt(*value))
|
||
|
|
}
|
||
|
|
|
||
|
|
million, err := db.ES().SumBy(common.ESIndexBalance, "value", q)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("查询盈亏失败, error : [%s]", err.Error())
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
return -int64(million)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取游戏下注总额
|
||
|
|
func GetBet(start, end *int64, channel *int, gameId *int, roomId *int, uid *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
// q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameBet))
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", strconv.Itoa(*uid)))
|
||
|
|
}
|
||
|
|
|
||
|
|
Bet, err := db.ES().SumBy(common.ESIndexBalance, "value", q)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("查询下注额度失败, error : [%s]", err.Error())
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
return -int64(Bet)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 聚合通过流水表获取游戏下注总额
|
||
|
|
func GetBetGroup(start, end *int64, channel *int, gameIDs []int) map[string]map[string]int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
// q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameBet))
|
||
|
|
if len(gameIDs) > 0 {
|
||
|
|
terms := []interface{}{}
|
||
|
|
for _, v := range gameIDs {
|
||
|
|
terms = append(terms, v)
|
||
|
|
}
|
||
|
|
q.Must(elastic.NewTermsQuery("desc.keyword", terms...))
|
||
|
|
}
|
||
|
|
ret := map[string]map[string]int64{}
|
||
|
|
totalBulk, err := db.ES().Group2SumBy(common.ESIndexBalance, "desc.keyword", "room_name.keyword", "value", q, "", false, 0)
|
||
|
|
if err == nil {
|
||
|
|
for _, v := range totalBulk.Buckets {
|
||
|
|
one := map[string]int64{}
|
||
|
|
for _, j := range v.Sub1.Buckets {
|
||
|
|
one[strconv.Itoa(util.GetInt(j.Key))] = -int64(j.Sub2.Value)
|
||
|
|
}
|
||
|
|
ret[strconv.Itoa(util.GetInt(v.Key))] = one
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return ret
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取总局数
|
||
|
|
func GetGameTotal(start, end *int64, channel *int, gameId *int, roomId *int, dropStart *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if dropStart != nil {
|
||
|
|
q.Must(elastic.NewRangeQuery("drop").Gt(*dropStart))
|
||
|
|
}
|
||
|
|
return db.ES().CountCard(common.ESIndexBalance, "extern.keyword", q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取总局数
|
||
|
|
func GetGameTotalGroup(start, end *int64, channel *int, drop bool, gameIDs []int) map[string]map[string]int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
if len(gameIDs) > 0 {
|
||
|
|
terms := []interface{}{}
|
||
|
|
for _, v := range gameIDs {
|
||
|
|
terms = append(terms, v)
|
||
|
|
}
|
||
|
|
q.Must(elastic.NewTermsQuery("desc.keyword", terms...))
|
||
|
|
}
|
||
|
|
if drop {
|
||
|
|
q.Must(elastic.NewRangeQuery("drop").Gt(0))
|
||
|
|
}
|
||
|
|
ret := map[string]map[string]int64{}
|
||
|
|
totalBulk, err := db.ES().GroupBy2Card(common.ESIndexBalance, "desc.keyword", "room_name.keyword", "extern.keyword", q, 0)
|
||
|
|
if err == nil {
|
||
|
|
for _, v := range totalBulk.Buckets {
|
||
|
|
one := map[string]int64{}
|
||
|
|
for _, j := range v.Sub1.Buckets {
|
||
|
|
one[strconv.Itoa(util.GetInt(j.Key))] = int64(j.Sub2.Value)
|
||
|
|
}
|
||
|
|
ret[strconv.Itoa(util.GetInt(v.Key))] = one
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return ret
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取控杀次数(怒气 + 小黑屋)
|
||
|
|
func GetControlCount(start, end *int64, uid *int, event *int, valueLt bool) int64 {
|
||
|
|
q := NewQt(start, end, nil, nil)
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", uid))
|
||
|
|
}
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
q.Filter(elastic.NewRangeQuery("control_type").Gt(1))
|
||
|
|
|
||
|
|
if valueLt {
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(0))
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().Count(common.ESIndexBalance, q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取幸运次数
|
||
|
|
func GetLuckCount(start, end *int64, uid *int, channel *int, event *int, valueGt, isUidCountCard bool) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", uid))
|
||
|
|
}
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
if valueGt {
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gt(0))
|
||
|
|
}
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("control_type", 1))
|
||
|
|
|
||
|
|
if isUidCountCard {
|
||
|
|
return db.ES().CountCard(common.ESIndexBalance, "uid", q)
|
||
|
|
} else {
|
||
|
|
return db.ES().Count(common.ESIndexBalance, q)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// QueryPlayerAllBalance 查询玩家所有流水记录
|
||
|
|
func QueryPlayerAllBalance(uid *string, page, num int, start, end *int64, gameId, roomId, controlType, channelId, event *int, ret *[]common.CurrencyBalance) (int64, error) {
|
||
|
|
q := NewQt(start, end, nil, channelId)
|
||
|
|
if uid != nil {
|
||
|
|
id := *uid
|
||
|
|
if len(id) == 19 { // 牌局的唯一id
|
||
|
|
q.Must(elastic.NewMatchQuery("extern.keyword", id))
|
||
|
|
} else {
|
||
|
|
Id, err := strconv.Atoi(id)
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
} else {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", Id))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", *gameId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", *roomId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if controlType != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("control_type", *controlType))
|
||
|
|
}
|
||
|
|
|
||
|
|
if channelId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("ChannelID", *channelId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
|
||
|
|
if start != nil {
|
||
|
|
q.Filter(elastic.NewRangeQuery("time").Gte(*start))
|
||
|
|
}
|
||
|
|
if end != nil {
|
||
|
|
q.Filter(elastic.NewRangeQuery("time").Lt(*end))
|
||
|
|
}
|
||
|
|
|
||
|
|
count, err := db.ES().QueryList(common.ESIndexBalance, page, num, q, ret, "time", false)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return 0, err
|
||
|
|
}
|
||
|
|
return count, err
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取玩家人数
|
||
|
|
func GetPlayerCount(start, end *int64, channel *int, gameId *int, roomId *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().CountCard(common.ESIndexBalance, "uid", q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取玩家游玩场次
|
||
|
|
func GetGameCountByBalance(start, end *int64, uid *int, channel *int, gameId *int, roomId *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", *uid))
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().Count(common.ESIndexBalance, q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取玩家赢的游戏场次
|
||
|
|
func GetWinGameCountByBalance(start, end *int64, uid *int, channel *int, gameId *int, roomId *int, isWin *bool) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", *uid))
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if isWin != nil {
|
||
|
|
if *isWin {
|
||
|
|
q.Must(elastic.NewRangeQuery("value").Gt(0))
|
||
|
|
} else {
|
||
|
|
q.Must(elastic.NewRangeQuery("value").Lt(0))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().Count(common.ESIndexBalance, q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取控杀次数
|
||
|
|
func GetControlTotal(start, end *int64, channel, gameId, roomId, controlType *int, isWin bool) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if controlType != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("control_type", *controlType))
|
||
|
|
}
|
||
|
|
|
||
|
|
if isWin {
|
||
|
|
q.Must(elastic.NewRangeQuery("value").Gt(0))
|
||
|
|
}
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
return db.ES().CountCard(common.ESIndexBalance, "extern.keyword", q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取玩家赢的游戏场次
|
||
|
|
func GetGameProfitByUid(start, end *int64, uid *int, channel *int, gameId *int, roomId *int, isWin *bool) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", common.CurrencyEventGameSettle))
|
||
|
|
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", *uid))
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", strconv.Itoa(*gameId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", strconv.Itoa(*roomId)))
|
||
|
|
}
|
||
|
|
|
||
|
|
if isWin != nil {
|
||
|
|
if *isWin {
|
||
|
|
q.Must(elastic.NewRangeQuery("value").Gt(0))
|
||
|
|
} else {
|
||
|
|
q.Must(elastic.NewRangeQuery("value").Lt(0))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
million, err := db.ES().SumBy(common.ESIndexBalance, "value", q)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("查询盈亏失败, error : [%s]", err.Error())
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
return int64(million)
|
||
|
|
}
|
||
|
|
|
||
|
|
// QueryPlayerAllBalance 查询玩家所有流水记录
|
||
|
|
func QueryUserBalance(uid *string, page, num int, start, end *int64, gameId, roomId, controlType, channelId, event *int, ret *[]common.CurrencyBalance) (int64, error) {
|
||
|
|
q := NewQt(start, end, nil, channelId)
|
||
|
|
if uid != nil {
|
||
|
|
Id, err := strconv.Atoi(*uid)
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
} else {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", Id))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if gameId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("desc.keyword", *gameId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if roomId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("room_name.keyword", *roomId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if controlType != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("control_type", *controlType))
|
||
|
|
}
|
||
|
|
|
||
|
|
if channelId != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("ChannelID", *channelId))
|
||
|
|
}
|
||
|
|
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
|
||
|
|
if start != nil {
|
||
|
|
q.Filter(elastic.NewRangeQuery("time").Gte(*start))
|
||
|
|
}
|
||
|
|
if end != nil {
|
||
|
|
q.Filter(elastic.NewRangeQuery("time").Lt(*end))
|
||
|
|
}
|
||
|
|
|
||
|
|
count, err := db.ES().QueryList(common.ESIndexBalance, page, num, q, ret, "time", false)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return 0, err
|
||
|
|
}
|
||
|
|
return count, err
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取玩家人数
|
||
|
|
func GetPlayerCountByEvent(start, end *int64, channel *int, event *int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().CountCard(common.ESIndexBalance, "uid", q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 通过流水表获取玩家人数
|
||
|
|
func GetPlayerCountByValue(start, end *int64, channel *int, event *int, value int) int64 {
|
||
|
|
q := NewQt(start, end, nil, channel)
|
||
|
|
|
||
|
|
if event != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("event", *event))
|
||
|
|
}
|
||
|
|
|
||
|
|
switch value {
|
||
|
|
case 1:
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(1000))
|
||
|
|
break
|
||
|
|
case 2:
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gte(1000))
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(3000))
|
||
|
|
break
|
||
|
|
case 3:
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gte(3000))
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(5000))
|
||
|
|
break
|
||
|
|
case 4:
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gte(5000))
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(10000))
|
||
|
|
break
|
||
|
|
case 5:
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gte(10000))
|
||
|
|
break
|
||
|
|
}
|
||
|
|
|
||
|
|
return db.ES().Count(common.ESIndexBalance, q)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取幸运次数
|
||
|
|
func GetShareAmountByBalance(uid *int, channel *int, event int) int64 {
|
||
|
|
q := NewQt(nil, nil, nil, channel)
|
||
|
|
if uid != nil {
|
||
|
|
q.Must(elastic.NewMatchQuery("uid", uid))
|
||
|
|
}
|
||
|
|
|
||
|
|
q.Must(elastic.NewMatchQuery("event", event))
|
||
|
|
|
||
|
|
million, err := db.ES().SumBy(common.ESIndexBalance, "value", q)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("查询盈亏失败, error : [%s]", err.Error())
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
return int64(million)
|
||
|
|
}
|
||
|
|
|
||
|
|
func GetGameCountByUIDs(uids []interface{}, win bool) (ret *common.GroupBuckets) {
|
||
|
|
q := elastic.NewBoolQuery()
|
||
|
|
q.Filter(elastic.NewRangeQuery("event").Gte(common.CurrencyEventGameSettle))
|
||
|
|
q.Filter(elastic.NewRangeQuery("event").Lt(common.CurrencyEventGameSettle + 1))
|
||
|
|
q.Must(elastic.NewTermsQuery("uid", uids...))
|
||
|
|
if win {
|
||
|
|
q.Filter(elastic.NewRangeQuery("value").Gt(0))
|
||
|
|
}
|
||
|
|
ret, _ = db.ES().GroupBy(common.ESIndexBalance, "uid", q, len(uids))
|
||
|
|
return
|
||
|
|
}
|