package models import ( "server/common" "server/db" "server/util" "github.com/olivere/elastic/v7" ) func GetOutputData(su, eu int64, cid, uid int) map[string]string { ret := map[string]string{} q := elastic.NewBoolQuery() if su > 0 { q.Filter(elastic.NewRangeQuery("time").Gte(su)) } if eu > 0 { q.Filter(elastic.NewRangeQuery("time").Lt(eu)) } if cid > 0 { q.Filter(elastic.NewTermsQuery("channel_id", cid)) } if uid > 0 { q.Filter(elastic.NewTermQuery("uid", uid)) } buk := &common.GroupSumBuckets{} db.ES().GroupSumBy(common.ESIndexBalance, "event", q, buk, "", false, 0, "value") for _, v := range buk.Buckets { ret[common.GetCurrencyTypeName(common.CurrencyEvent(util.GetInt(v.Key)))] = util.RoundFloat(v.Value.Value/common.DecimalDigits, 2) } return ret }