印度包网
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.6 KiB

package statistics
import (
"server/modules/backend/app"
"server/modules/backend/models"
utils "server/modules/backend/util"
"server/modules/backend/values"
"time"
"github.com/gin-gonic/gin"
)
// 用户牌局分析
func PlayData(c *gin.Context) {
a := app.NewApp(c)
defer func() {
a.Response()
}()
req := new(values.PlayDataReq)
if !a.S(req) {
return
}
resp := values.PlayDataResp{}
su, eu := utils.GetQueryUnix(req.Start, req.End)
var newCount, oldCount int64
// 新用户数
newCount = models.GetNewPlayerCountBySql(req.Channel, su, eu)
// 老用户数
oldCount = models.GetOldPlayerCountBySql(req.Channel, su, eu)
// 活跃玩牌率
resp.ActivePlayPer = utils.GetPer(resp.Play, newCount+oldCount)
// 新用户玩牌率
resp.NewPlayerPer = utils.GetPer(resp.NewPlay, newCount)
resp.Map1 = getPlayDataMap1(su, eu, req.Channel, req.Games)
resp.Map2 = getPlayDataMap2(su, eu, req.Channel, req.Games)
resp.Map3 = getPlayDataMap3(su, eu, req.Channel)
a.Data = resp
}
func getPlayDataMap1(s, e int64, channel *int, games *string) map[string]values.PlayDataMap1 {
ret := map[string]values.PlayDataMap1{}
// var oneDay int64 = 24 * 60 * 60
// s := util.GetZeroTime(time.Unix(int64(start), 0)).Unix()
// e := util.GetZeroTime(time.Unix(int64(end), 0)).AddDate(0, 0, 1).Unix()
return ret
}
func getPlayDataMap2(s, e int64, channel *int, games *string) map[string]values.PlayDataMap2 {
ret := map[string]values.PlayDataMap2{}
var oneDay int64 = 24 * 60 * 60
// s := util.GetZeroTime(time.Unix(int64(start), 0)).Unix()
// e := util.GetZeroTime(time.Unix(int64(end), 0)).AddDate(0, 0, 1).Unix()
// IsNew := true
// flag := false
// var gameId *int
// if games != nil {
// gId := common.GetGameIDByGames(*games)
// gameId = &gId
// }
for i := s; i < e; i += oneDay {
// j := i + oneDay
t := time.Unix(i, 0).Format("20060102")
one := values.PlayDataMap2{}
// active := models.GetActive(&i, &j, false, false, channel)
// play := models.GetPlayGameUserCount(&i, &j, gameId, nil, channel, &flag)
// one.ActivePlayPer = utils.GetPer(play, active)
// newUser := models.GetNewPlayerCountBySql(channel, i, j)
// newPlay := models.GetPlayGameUserCount(&i, &j, gameId, nil, channel, &IsNew)
// one.NewPlayPer = utils.GetPer(newPlay, newUser)
ret[t] = one
}
return ret
}
func getPlayDataMap3(s, e int64, channel *int) map[int]int64 {
ret := map[int]int64{}
// for _, v := range common.Games {
// gameId := common.GetGameIDByGames(v)
// ret[common.GetGameIDByGames(v)] = models.GetPlayGameUserCount(&s, &e, &gameId, nil, channel, nil)
// }
return ret
}