|
|
|
|
package handler
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"server/call"
|
|
|
|
|
"server/common"
|
|
|
|
|
"server/db"
|
|
|
|
|
"server/modules/web/app"
|
|
|
|
|
"server/modules/web/values"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/liangdas/mqant/log"
|
|
|
|
|
"github.com/olivere/elastic/v7"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func BalanceHistory(c *gin.Context) {
|
|
|
|
|
a := app.NewApp(c)
|
|
|
|
|
defer func() {
|
|
|
|
|
a.Response()
|
|
|
|
|
}()
|
|
|
|
|
req := new(values.BalanceHisReq)
|
|
|
|
|
if !a.S(req) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if req.PageSize > 100 {
|
|
|
|
|
log.Error("balance req num:%v", req.PageSize)
|
|
|
|
|
req.PageSize = 100
|
|
|
|
|
}
|
|
|
|
|
// ret := []common.CurrencyBalance{}
|
|
|
|
|
// var count int64
|
|
|
|
|
// var err error
|
|
|
|
|
// if req.Start != nil && req.End != nil {
|
|
|
|
|
// if *req.Start > *req.End {
|
|
|
|
|
// a.Code = values.CodeParam
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
// count, err = db.Mysql().QueryCurrencyHistory(req.Page, req.Num, &common.CurrencyBalance{Uid: a.UID}, &ret,
|
|
|
|
|
// fmt.Sprintf("uid = %v and time > %v and time < %v", a.UID, *req.Start, *req.End), "id desc")
|
|
|
|
|
// } else {
|
|
|
|
|
// count, err = db.Mysql().QueryCurrencyHistory(req.Page, req.Num, &common.CurrencyBalance{Uid: a.UID}, &ret,
|
|
|
|
|
// fmt.Sprintf("uid = %v", a.UID), "id desc")
|
|
|
|
|
// }
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// log.Error("err:%v", err)
|
|
|
|
|
// a.Code = values.CodeRetry
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
start := time.Now().Unix() - 30*24*60*60 // 最大30天
|
|
|
|
|
resp := values.BalanceHisResp{}
|
|
|
|
|
q := elastic.NewBoolQuery()
|
|
|
|
|
// q.MustNot(elastic.NewMatchQuery("event", common.CurrencyEventGameBetReturn), elastic.NewMatchQuery("event", common.CurrencyEventGameBet),
|
|
|
|
|
// elastic.NewMatchQuery("event", common.CurrencyEventGameSettleReturn))
|
|
|
|
|
q.Filter(elastic.NewRangeQuery("uid").Gte(a.UID), elastic.NewRangeQuery("uid").Lt(a.UID+1))
|
|
|
|
|
if req.Type == 1 {
|
|
|
|
|
q.Filter(elastic.NewRangeQuery("value").Gt(0))
|
|
|
|
|
} else if req.Type == 2 {
|
|
|
|
|
q.Filter(elastic.NewRangeQuery("value").Lt(0))
|
|
|
|
|
}
|
|
|
|
|
player, _ := call.GetUserXInfo(a.UID, "birth")
|
|
|
|
|
if start < player.Birth {
|
|
|
|
|
start = player.Birth
|
|
|
|
|
}
|
|
|
|
|
q.Filter(elastic.NewRangeQuery("time").Gte(start))
|
|
|
|
|
|
|
|
|
|
// q.Must(elastic.NewMatchQuery("uid", a.UID))
|
|
|
|
|
resp.Count, _ = db.ES().QueryList(common.ESIndexBalance, req.Page, req.PageSize, q, &resp.List, "id", false)
|
|
|
|
|
a.Data = resp
|
|
|
|
|
}
|