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.
111 lines
3.1 KiB
111 lines
3.1 KiB
|
1 year ago
|
package statistics
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
"server/modules/backend/app"
|
||
|
|
"server/modules/backend/models"
|
||
|
|
utils "server/modules/backend/util"
|
||
|
|
"server/modules/backend/values"
|
||
|
|
"server/util"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
// 实时数据盈亏
|
||
|
|
func RealDataBalance(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.RealDataBalanceReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := values.RealDataBalanceResp{}
|
||
|
|
|
||
|
|
su, eu := utils.GetQueryUnix(req.Start, req.End)
|
||
|
|
var oneDay int64 = 24 * 60 * 60
|
||
|
|
|
||
|
|
sql := "SELECT COUNT(*) as NewCount from users u WHERE %d <= u.birth and u.birth < %d "
|
||
|
|
|
||
|
|
// 在线人数
|
||
|
|
resp.Online = models.GetOnline()
|
||
|
|
|
||
|
|
currencyEventGameSettle := int(common.CurrencyEventGameSettle)
|
||
|
|
for i := su; i < eu; i += oneDay {
|
||
|
|
s := i
|
||
|
|
e := i + oneDay
|
||
|
|
var realDataBalance values.RealDataBalance
|
||
|
|
// 日期
|
||
|
|
realDataBalance.Date = s
|
||
|
|
|
||
|
|
// 实时在线人数
|
||
|
|
if util.GetZeroTime(time.Now()).Unix() == s {
|
||
|
|
realDataBalance.Online = models.GetOnlineTotal().Total
|
||
|
|
} else {
|
||
|
|
realDataBalance.Online = 0
|
||
|
|
}
|
||
|
|
|
||
|
|
// 新用户数
|
||
|
|
err := db.Mysql().QueryBySql(fmt.Sprintf(sql, i, i+oneDay), &realDataBalance.NewCount)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("获取新用户数量失败, error : [%s]", err.Error())
|
||
|
|
}
|
||
|
|
|
||
|
|
// 利润 (所有场次AI盈亏+百人场系统盈亏)
|
||
|
|
realDataBalance.Profit += models.GetProfit(&s, &e, req.Channel, nil, nil, ¤cyEventGameSettle, nil)
|
||
|
|
|
||
|
|
// 台费
|
||
|
|
// realDataBalance.TableFee = models.GetTableFee(&s, &e, req.Channel, nil, nil) + models.GetMillionFee(&s, &e, req.Channel, nil, nil)
|
||
|
|
|
||
|
|
// roomGame
|
||
|
|
roomGameData := make(map[string]values.RoomGameBalanceData)
|
||
|
|
realDataBalance.RoomGame = roomGameData
|
||
|
|
|
||
|
|
// millionGame
|
||
|
|
millionGameData := make(map[string]values.MillionGameBalanceData)
|
||
|
|
realDataBalance.MillionGame = millionGameData
|
||
|
|
|
||
|
|
resp.List = append(resp.List, realDataBalance)
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func getRoomGameBalanceData(start, end *int64, channel *int, gameId *int) values.RoomGameBalanceData {
|
||
|
|
var roomGameBalanceData values.RoomGameBalanceData
|
||
|
|
|
||
|
|
event := int(common.CurrencyEventGameSettle)
|
||
|
|
|
||
|
|
// 台费
|
||
|
|
// roomGameBalanceData.TableFee = models.GetTableFee(start, end, channel, gameId, nil)
|
||
|
|
|
||
|
|
// 下注额
|
||
|
|
roomGameBalanceData.BetTotal = models.GetBet(start, end, channel, gameId, nil, nil)
|
||
|
|
|
||
|
|
// 利润
|
||
|
|
roomGameBalanceData.Profit = models.GetProfit(start, end, channel, gameId, nil, &event, nil)
|
||
|
|
|
||
|
|
// 活跃人数
|
||
|
|
// roomGameBalanceData.Active = models.GetRoomGamePlayerCount(start, end, channel, gameId, nil)
|
||
|
|
return roomGameBalanceData
|
||
|
|
}
|
||
|
|
|
||
|
|
func getMillionGameBalanceData(start, end *int64, channel *int, gameId *int) values.MillionGameBalanceData {
|
||
|
|
var millionGameBalanceData values.MillionGameBalanceData
|
||
|
|
|
||
|
|
event := int(common.CurrencyEventGameSettle)
|
||
|
|
// 利润
|
||
|
|
millionGameBalanceData.Profit = models.GetProfit(start, end, channel, gameId, nil, &event, nil)
|
||
|
|
|
||
|
|
// 台费
|
||
|
|
// millionGameBalanceData.Profit = models.GetMillionFee(start, end, channel, gameId, nil)
|
||
|
|
|
||
|
|
// 活跃人数
|
||
|
|
// millionGameBalanceData.Active = models.GetMillionPlayerCount(start, end, channel, gameId, nil)
|
||
|
|
return millionGameBalanceData
|
||
|
|
}
|