|
@@ -82,6 +82,7 @@ func (s *ServiceStatisticsLog) CreateStatisticsLog() {
|
|
|
|
|
|
|
|
func (s *ServiceStatisticsLog) TodayCreateStatisticsGameInfoLog() {
|
|
func (s *ServiceStatisticsLog) TodayCreateStatisticsGameInfoLog() {
|
|
|
date := s.LogicalLog.CurrentDate()
|
|
date := s.LogicalLog.CurrentDate()
|
|
|
|
|
+ ctx := context.Background()
|
|
|
gameMps, err := s.LogicalLog.GetGameCache(context.Background(), date)
|
|
gameMps, err := s.LogicalLog.GetGameCache(context.Background(), date)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
global.GVA_LOG.Error("获取redis game list失败!", zap.Error(err))
|
|
global.GVA_LOG.Error("获取redis game list失败!", zap.Error(err))
|
|
@@ -93,17 +94,19 @@ func (s *ServiceStatisticsLog) TodayCreateStatisticsGameInfoLog() {
|
|
|
}
|
|
}
|
|
|
var statisticsLogs []*log.StatisticsLog
|
|
var statisticsLogs []*log.StatisticsLog
|
|
|
for gameId, _ := range gameMps {
|
|
for gameId, _ := range gameMps {
|
|
|
- gameIdInt, _ := strconv.Atoi(gameId)
|
|
|
|
|
- if !errors.Is(global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", gameIdInt).First(&log.StatisticsLog{}).Error, gorm.ErrRecordNotFound) {
|
|
|
|
|
- // 已存在,跳过
|
|
|
|
|
- continue
|
|
|
|
|
- }
|
|
|
|
|
for _, tt := range TaskType {
|
|
for _, tt := range TaskType {
|
|
|
- statisticsLog := new(log.StatisticsLog)
|
|
|
|
|
- statisticsLog.GameId = gameIdInt
|
|
|
|
|
- statisticsLog.Type = tt
|
|
|
|
|
- statisticsLog.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
|
|
|
- statisticsLog.CreateDate = date
|
|
|
|
|
|
|
+ gameIdInt, _ := strconv.Atoi(gameId)
|
|
|
|
|
+ statisticsLogNew := new(log.StatisticsLog)
|
|
|
|
|
+ statisticsLog := s.statisticsData(ctx, gameIdInt, tt, date, statisticsLogNew)
|
|
|
|
|
+ if !errors.Is(global.GVA_DB.Where("create_date = ?", date).Where("game_id = ?", gameIdInt).First(&log.StatisticsLog{}).Error, gorm.ErrRecordNotFound) {
|
|
|
|
|
+ // 已存在,跳过
|
|
|
|
|
+ err = global.GVA_DB.Where("game_id", gameIdInt).Where("create_date = ?", date).Where("type = ?", tt).Updates(statisticsLog).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ global.GVA_LOG.Error("update StatisticsLogs失败!", zap.Error(err))
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
statisticsLogs = append(statisticsLogs, statisticsLog)
|
|
statisticsLogs = append(statisticsLogs, statisticsLog)
|
|
|
if len(statisticsLogs) == 100 {
|
|
if len(statisticsLogs) == 100 {
|
|
|
err = global.GVA_DB.Create(statisticsLogs).Error
|
|
err = global.GVA_DB.Create(statisticsLogs).Error
|
|
@@ -267,25 +270,103 @@ func (s *ServiceStatisticsLog) statisticsData(ctx context.Context, gameIdInt, tt
|
|
|
statisticsLog.IssuedAccount = taskStatistics.RetainedPullAccount
|
|
statisticsLog.IssuedAccount = taskStatistics.RetainedPullAccount
|
|
|
statisticsLog.TargetNum = taskStatistics.RetainedTarget
|
|
statisticsLog.TargetNum = taskStatistics.RetainedTarget
|
|
|
statisticsLog.TargetCompleteNum = taskStatistics.RetainedComplete
|
|
statisticsLog.TargetCompleteNum = taskStatistics.RetainedComplete
|
|
|
|
|
+ statisticsLog.ScanningSuccessRate = 0
|
|
|
} else {
|
|
} else {
|
|
|
statisticsLog.NotRole = 0
|
|
statisticsLog.NotRole = 0
|
|
|
statisticsLog.HasRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4609902", loging2.NoLogStatus, tt)
|
|
statisticsLog.HasRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4609902", loging2.NoLogStatus, tt)
|
|
|
statisticsLog.IssuedAccount = taskStatistics.NewPullAccount
|
|
statisticsLog.IssuedAccount = taskStatistics.NewPullAccount
|
|
|
statisticsLog.TargetCompleteNum = taskStatistics.NewComplete
|
|
statisticsLog.TargetCompleteNum = taskStatistics.NewComplete
|
|
|
statisticsLog.TargetNum = taskStatistics.NewTarget
|
|
statisticsLog.TargetNum = taskStatistics.NewTarget
|
|
|
|
|
+ statisticsLog.NewScanningCode = taskStatistics.NewScanningCode
|
|
|
|
|
+ if statisticsLog.NewScanningCode != 0 {
|
|
|
|
|
+ statisticsLog.ScanningSuccessRate = float64(statisticsLog.TargetNum) / float64(statisticsLog.NewScanningCode) * 100
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- statisticsLog.NewScanningCode = taskStatistics.NewScanningCode
|
|
|
|
|
statisticsLog.PayComplete = taskStatistics.PayComplete
|
|
statisticsLog.PayComplete = taskStatistics.PayComplete
|
|
|
statisticsLog.PayTarget = taskStatistics.PayTarget
|
|
statisticsLog.PayTarget = taskStatistics.PayTarget
|
|
|
statisticsLog.OrderCreate = taskStatistics.OrderCreate
|
|
statisticsLog.OrderCreate = taskStatistics.OrderCreate
|
|
|
statisticsLog.OrderSuccess = taskStatistics.OrderSuccess
|
|
statisticsLog.OrderSuccess = taskStatistics.OrderSuccess
|
|
|
statisticsLog.RetainedAccountNum = taskStatistics.RetainedAccountNum
|
|
statisticsLog.RetainedAccountNum = taskStatistics.RetainedAccountNum
|
|
|
statisticsLog.FeeAccountNum = taskStatistics.FeeAccountNum
|
|
statisticsLog.FeeAccountNum = taskStatistics.FeeAccountNum
|
|
|
|
|
+ statisticsLog.Operator = taskStatistics.Remark
|
|
|
|
|
+ statisticsLog.GameName = taskStatistics.GameName
|
|
|
|
|
+ if statisticsLog.IssuedAccount != 0 {
|
|
|
|
|
+ statisticsLog.PullSuccessRate = float64(statisticsLog.PullAccountOk) / float64(statisticsLog.IssuedAccount) * 100
|
|
|
|
|
+ }
|
|
|
|
|
+ if statisticsLog.PullAccountOk != 0 {
|
|
|
|
|
+ statisticsLog.StartSuccessRate = float64(statisticsLog.SimulatorStartOk) / float64(statisticsLog.PullAccountOk) * 100
|
|
|
|
|
+ }
|
|
|
|
|
+ if statisticsLog.GameStartOk != 0 {
|
|
|
|
|
+ statisticsLog.MainSuccessRate = float64(statisticsLog.EnterMain) / float64(statisticsLog.GameStartOk) * 100
|
|
|
|
|
+ }
|
|
|
|
|
+ if statisticsLog.TargetNum != 0 {
|
|
|
|
|
+ statisticsLog.TaskSuccessRate = float64(statisticsLog.EnterMain) / float64(statisticsLog.TargetNum) * 100
|
|
|
|
|
+ }
|
|
|
|
|
+ if statisticsLog.OrderCreate != 0 {
|
|
|
|
|
+ statisticsLog.LocalOrderSuccessRate = float64(statisticsLog.FeeOk) / float64(statisticsLog.OrderCreate) * 100
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return statisticsLog
|
|
return statisticsLog
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api log.StatisticsLog, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
|
|
func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api log.StatisticsLog, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
|
|
|
date := api.CreateDate
|
|
date := api.CreateDate
|
|
|
|
|
+ if date == "" {
|
|
|
|
|
+ date = s.CurrentDate()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ db := global.GVA_DB.Model(&log.StatisticsLog{})
|
|
|
|
|
+ if api.GameId != 0 {
|
|
|
|
|
+ db = db.Where("game_id = ?", api.GameId)
|
|
|
|
|
+ }
|
|
|
|
|
+ db = db.Where("create_date = ?", date)
|
|
|
|
|
+ var total int64
|
|
|
|
|
+ err := db.Count(&total).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, 0, err
|
|
|
|
|
+ }
|
|
|
|
|
+ limit := info.PageSize
|
|
|
|
|
+ offset := info.PageSize * (info.Page - 1)
|
|
|
|
|
+ var statisticsLogs []*log.StatisticsLog
|
|
|
|
|
+ db = db.Limit(limit).Offset(offset)
|
|
|
|
|
+ if order != "" {
|
|
|
|
|
+ var OrderStr string
|
|
|
|
|
+ // 设置有效排序key 防止sql注入
|
|
|
|
|
+ // 感谢 Tom4t0 提交漏洞信息
|
|
|
|
|
+ orderMap := make(map[string]bool, 7)
|
|
|
|
|
+ orderMap["pull_success_rate"] = true
|
|
|
|
|
+ orderMap["start_success_rate"] = true
|
|
|
|
|
+ orderMap["main_success_rate"] = true
|
|
|
|
|
+ orderMap["task_success_rate"] = true
|
|
|
|
|
+ orderMap["scanning_success_rate"] = true
|
|
|
|
|
+ orderMap["local_order_success_rate"] = true
|
|
|
|
|
+ orderMap["game_id"] = true
|
|
|
|
|
+ if orderMap[order] {
|
|
|
|
|
+ if desc {
|
|
|
|
|
+ OrderStr = order + " desc"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ OrderStr = order
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { // didn't matched any order key in `orderMap`
|
|
|
|
|
+ global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
|
|
|
|
+ return statisticsLogs, total, err
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ err = db.Order(OrderStr).Find(&statisticsLogs).Error
|
|
|
|
|
+ } else {
|
|
|
|
|
+ err = db.Order("id").Find(&statisticsLogs).Error
|
|
|
|
|
+ }
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, 0, err
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, statisticsLog := range statisticsLogs {
|
|
|
|
|
+ statisticsLog.CreateDate = statisticsLog.CreateDate[:10]
|
|
|
|
|
+ }
|
|
|
|
|
+ return statisticsLogs, total, err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (s *ServiceStatisticsLog) StatisticsNodeLogList(ctx context.Context, api log.StatisticsLog, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
|
|
|
|
|
+ date := api.CreateDate
|
|
|
if date == "" || date == s.CurrentDate() {
|
|
if date == "" || date == s.CurrentDate() {
|
|
|
apilist, total, err := s.TodayStatisticsLogList(ctx, api, info)
|
|
apilist, total, err := s.TodayStatisticsLogList(ctx, api, info)
|
|
|
return apilist, total, err
|
|
return apilist, total, err
|
|
@@ -416,10 +497,9 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
if len(codeMps) == 0 {
|
|
if len(codeMps) == 0 {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- // 统计运行的电脑台数
|
|
|
|
|
- computerNumKey := fmt.Sprintf(ComputerNum, s.CurrentDate())
|
|
|
|
|
- global.GVA_REDIS.Set(ctx, computerNumKey, len(codeMps), 24*time.Hour)
|
|
|
|
|
key := fmt.Sprintf(taskStatistics, s.LogicalLog.CurrentDate())
|
|
key := fmt.Sprintf(taskStatistics, s.LogicalLog.CurrentDate())
|
|
|
|
|
+ onlineComputerMpa, _ := s.LogicalLog.GetOnlineComputerNumCache(ctx, s.LogicalLog.CurrentDate())
|
|
|
|
|
+ fmt.Println(onlineComputerMpa)
|
|
|
var csReplys []*log.LogComputer
|
|
var csReplys []*log.LogComputer
|
|
|
for code, r := range codeMps {
|
|
for code, r := range codeMps {
|
|
|
accountMps, err := s.LogicalLog.GetComputerPullAccountNumCache(ctx, s.LogicalLog.CurrentDate(), code)
|
|
accountMps, err := s.LogicalLog.GetComputerPullAccountNumCache(ctx, s.LogicalLog.CurrentDate(), code)
|
|
@@ -434,8 +514,12 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
for gameId, num := range accountMps {
|
|
for gameId, num := range accountMps {
|
|
|
csReply := new(log.LogComputer)
|
|
csReply := new(log.LogComputer)
|
|
|
|
|
+ if _, ok := onlineComputerMpa[csReply.PcCode]; ok {
|
|
|
|
|
+ delete(onlineComputerMpa, csReply.PcCode)
|
|
|
|
|
+ }
|
|
|
csReply.PcCode = code
|
|
csReply.PcCode = code
|
|
|
csReply.Operator = r
|
|
csReply.Operator = r
|
|
|
data, err := global.GVA_REDIS.HGet(ctx, key, gameId).Result()
|
|
data, err := global.GVA_REDIS.HGet(ctx, key, gameId).Result()
|
|
@@ -461,6 +545,7 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
csReply.GameFeeRate = s.GetStatisticsFeeRate(ctx, csReply.GameId)
|
|
csReply.GameFeeRate = s.GetStatisticsFeeRate(ctx, csReply.GameId)
|
|
|
runTime := time.Now().Hour() + 1 - csReply.ComputerFreeTime
|
|
runTime := time.Now().Hour() + 1 - csReply.ComputerFreeTime
|
|
|
csReply.ComputerHourAverageRate = csReply.TaskSuccessNum / runTime
|
|
csReply.ComputerHourAverageRate = csReply.TaskSuccessNum / runTime
|
|
|
|
|
+ global.GVA_DB.Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).Where("game_id = ?", 0).Delete(&log.LogComputer{})
|
|
|
if !errors.Is(global.GVA_DB.Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).First(&log.LogComputer{}).Error, gorm.ErrRecordNotFound) {
|
|
if !errors.Is(global.GVA_DB.Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).First(&log.LogComputer{}).Error, gorm.ErrRecordNotFound) {
|
|
|
// 已存在,更新
|
|
// 已存在,更新
|
|
|
mp := make(map[string]interface{})
|
|
mp := make(map[string]interface{})
|
|
@@ -483,7 +568,6 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
}
|
|
}
|
|
|
csReplys = append(csReplys, csReply)
|
|
csReplys = append(csReplys, csReply)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
if len(csReplys) != 0 {
|
|
if len(csReplys) != 0 {
|
|
|
err = global.GVA_DB.Table("log_computer").Create(csReplys).Error
|
|
err = global.GVA_DB.Table("log_computer").Create(csReplys).Error
|
|
@@ -491,10 +575,31 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
|
|
|
global.GVA_LOG.Error("更新数据失败", zap.Error(err))
|
|
global.GVA_LOG.Error("更新数据失败", zap.Error(err))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 在线电脑没有跑数据记录
|
|
|
|
|
+ if len(onlineComputerMpa) != 0 {
|
|
|
|
|
+ var onlineComputer []*log.LogComputer
|
|
|
|
|
+ for pcCode, op := range onlineComputerMpa {
|
|
|
|
|
+ csReply := new(log.LogComputer)
|
|
|
|
|
+ csReply.PcCode = pcCode
|
|
|
|
|
+ csReply.Operator = op
|
|
|
|
|
+ csReply.CreateDate = time.Now().Format("2006-01-02")
|
|
|
|
|
+ if !errors.Is(global.GVA_DB.Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).First(&log.LogComputer{}).Error, gorm.ErrRecordNotFound) {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ onlineComputer = append(onlineComputer, csReply)
|
|
|
|
|
+ }
|
|
|
|
|
+ if len(onlineComputer) != 0 {
|
|
|
|
|
+ err = global.GVA_DB.Table("log_computer").Create(onlineComputer).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ global.GVA_LOG.Error("更新数据失败", zap.Error(err))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
|
|
|
|
|
|
|
+func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
|
|
|
date := api.CreateDate
|
|
date := api.CreateDate
|
|
|
isCurrentDate := false
|
|
isCurrentDate := false
|
|
|
if date == "" {
|
|
if date == "" {
|
|
@@ -521,7 +626,28 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
|
|
|
offset := info.PageSize * (info.Page - 1)
|
|
offset := info.PageSize * (info.Page - 1)
|
|
|
var statisticsLogs []*log.LogComputer
|
|
var statisticsLogs []*log.LogComputer
|
|
|
db = db.Limit(limit).Offset(offset)
|
|
db = db.Limit(limit).Offset(offset)
|
|
|
- err = db.Order("id").Find(&statisticsLogs).Error
|
|
|
|
|
|
|
+ if order != "" {
|
|
|
|
|
+ var OrderStr string
|
|
|
|
|
+ // 设置有效排序key 防止sql注入
|
|
|
|
|
+ // 感谢 Tom4t0 提交漏洞信息
|
|
|
|
|
+ orderMap := make(map[string]bool, 3)
|
|
|
|
|
+ orderMap["pc_code"] = true
|
|
|
|
|
+ orderMap["game_id"] = true
|
|
|
|
|
+ orderMap["operator"] = true
|
|
|
|
|
+ if orderMap[order] {
|
|
|
|
|
+ if desc {
|
|
|
|
|
+ OrderStr = order + " desc"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ OrderStr = order
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { // didn't matched any order key in `orderMap`
|
|
|
|
|
+ global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
|
|
|
|
+ return statisticsLogs, total, err
|
|
|
|
|
+ }
|
|
|
|
|
+ err = db.Order(OrderStr).Find(&statisticsLogs).Error
|
|
|
|
|
+ } else {
|
|
|
|
|
+ err = db.Order("id").Find(&statisticsLogs).Error
|
|
|
|
|
+ }
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, 0, err
|
|
return nil, 0, err
|
|
|
}
|
|
}
|
|
@@ -563,6 +689,74 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
|
|
|
return statisticsLogsComputer, total, err
|
|
return statisticsLogsComputer, total, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 在线电脑
|
|
|
|
|
+func (s *ServiceStatisticsLog) OnlineComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
|
|
|
|
|
+ date := api.CreateDate
|
|
|
|
|
+ if date == "" {
|
|
|
|
|
+ date = s.CurrentDate()
|
|
|
|
|
+ }
|
|
|
|
|
+ db := global.GVA_DB.Model(&log.LogComputer{})
|
|
|
|
|
+ var total int64
|
|
|
|
|
+ db = db.Where("create_date = ?", date)
|
|
|
|
|
+ if api.Operator != "" {
|
|
|
|
|
+ db = db.Where("operator = ?", api.Operator)
|
|
|
|
|
+ }
|
|
|
|
|
+ if api.PcCode != "" {
|
|
|
|
|
+ db = db.Where("pc_code = ?", api.PcCode)
|
|
|
|
|
+ }
|
|
|
|
|
+ db = db.Group("pc_code")
|
|
|
|
|
+ err := db.Count(&total).Error
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, 0, err
|
|
|
|
|
+ }
|
|
|
|
|
+ limit := info.PageSize
|
|
|
|
|
+ offset := info.PageSize * (info.Page - 1)
|
|
|
|
|
+ var statisticsLogs []*log.LogComputer
|
|
|
|
|
+ db = db.Limit(limit).Offset(offset)
|
|
|
|
|
+ if order != "" {
|
|
|
|
|
+ var OrderStr string
|
|
|
|
|
+ // 设置有效排序key 防止sql注入
|
|
|
|
|
+ // 感谢 Tom4t0 提交漏洞信息
|
|
|
|
|
+ orderMap := make(map[string]bool, 3)
|
|
|
|
|
+ orderMap["pc_code"] = true
|
|
|
|
|
+ orderMap["operator"] = true
|
|
|
|
|
+ if orderMap[order] {
|
|
|
|
|
+ if desc {
|
|
|
|
|
+ OrderStr = order + " desc"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ OrderStr = order
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { // didn't matched any order key in `orderMap`
|
|
|
|
|
+ global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
|
|
|
|
+ return statisticsLogs, total, err
|
|
|
|
|
+ }
|
|
|
|
|
+ err = db.Order(OrderStr).Find(&statisticsLogs).Error
|
|
|
|
|
+ } else {
|
|
|
|
|
+ err = db.Order("id").Find(&statisticsLogs).Error
|
|
|
|
|
+ }
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, 0, err
|
|
|
|
|
+ }
|
|
|
|
|
+ var statisticsLogsComputer []*response.ComputerStatisticsReply1
|
|
|
|
|
+
|
|
|
|
|
+ for _, statisticsLog := range statisticsLogs {
|
|
|
|
|
+ statisticsLogComputer := new(response.ComputerStatisticsReply1)
|
|
|
|
|
+ statisticsLogComputer.PcCode = statisticsLog.PcCode
|
|
|
|
|
+ statisticsLogComputer.Operator = statisticsLog.Operator
|
|
|
|
|
+ statisticsLogComputer.CreateDate = statisticsLog.CreateDate[:10]
|
|
|
|
|
+ statisticsLogComputer.GameId = statisticsLog.GameId
|
|
|
|
|
+ statisticsLogComputer.PullAccountNum = statisticsLog.PullAccountNum
|
|
|
|
|
+ statisticsLogComputer.TaskSuccessNum = statisticsLog.TaskSuccessNum
|
|
|
|
|
+ statisticsLogComputer.TargetNum = statisticsLog.TargetNum
|
|
|
|
|
+ statisticsLogComputer.ComputerFreeTime = statisticsLog.ComputerFreeTime
|
|
|
|
|
+ statisticsLogComputer.ComputerFeeRate = statisticsLog.ComputerFeeRate
|
|
|
|
|
+ statisticsLogComputer.EnterMain = statisticsLog.EnterMain
|
|
|
|
|
+ statisticsLogComputer.ComputerHourAverageRate = statisticsLog.ComputerHourAverageRate
|
|
|
|
|
+ statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
|
|
|
|
|
+ }
|
|
|
|
|
+ return statisticsLogsComputer, total, err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
//根据游戏id查询数据
|
|
//根据游戏id查询数据
|
|
|
func (s *ServiceStatisticsLog) GameStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
|
|
func (s *ServiceStatisticsLog) GameStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
|
|
|
date := api.CreateDate
|
|
date := api.CreateDate
|
|
@@ -715,12 +909,28 @@ func (s *ServiceStatisticsLog) TaskStatisticsDataCache1() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 同步群控任务数据到缓存
|
|
// 同步群控任务数据到缓存
|
|
|
-func (s *ServiceStatisticsLog) GetComputerNum() int {
|
|
|
|
|
- ctx := context.Background()
|
|
|
|
|
- computerNumKey := fmt.Sprintf(ComputerNum, s.CurrentDate())
|
|
|
|
|
- num, err := global.GVA_REDIS.Get(ctx, computerNumKey).Int()
|
|
|
|
|
|
|
+func (s *ServiceStatisticsLog) GetComputerNum(date string) int64 {
|
|
|
|
|
+ var total int64
|
|
|
|
|
+ if date == "" {
|
|
|
|
|
+ date = s.CurrentDate()
|
|
|
|
|
+ }
|
|
|
|
|
+ db := global.GVA_DB.Model(&log.LogComputer{})
|
|
|
|
|
+ db = db.Distinct("pc_code").Where("create_date = ?", date)
|
|
|
|
|
+ _ = db.Count(&total).Error
|
|
|
|
|
+ return total
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 在线电脑接口
|
|
|
|
|
+func (s *ServiceStatisticsLog) ComputerHeartbeat(c context.Context, onlineComputer request.OnlineComputerRequest) error {
|
|
|
|
|
+ err := s.LogicalLog.SetOnlineComputerNumCache(c, s.LogicalLog.CurrentDate(), onlineComputer.PcCode, onlineComputer.Operator)
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 在线电脑接口测试
|
|
|
|
|
+func (s *ServiceStatisticsLog) ComputerTest(c context.Context) (interface{}, error) {
|
|
|
|
|
+ mps, err := s.LogicalLog.GetOnlineComputerNumCache(c, s.LogicalLog.CurrentDate())
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
- num = 0
|
|
|
|
|
|
|
+ return mps, err
|
|
|
}
|
|
}
|
|
|
- return num
|
|
|
|
|
|
|
+ return mps, err
|
|
|
}
|
|
}
|