Sfoglia il codice sorgente

统计添加游戏端口查询

wangbin 3 anni fa
parent
commit
0b1db7da4e

+ 1 - 1
api/v1/log/loging.go

@@ -236,7 +236,7 @@ func (s *ApiLoging) GetStatisticsLogList(c *gin.Context) {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
-	list, total, err := ServiceStatisticsLog.OtherStatisticsLogList(c, paramsInfo.StatisticsLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	list, total, err := ServiceStatisticsLog.OtherStatisticsLogList(c, paramsInfo.StatisticsLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc, paramsInfo.GamePortId)
 	if err != nil {
 		global.GVA_LOG.Error("获取失败!", zap.Error(err))
 		response.FailWithMessage("获取失败", c)

+ 3 - 3
model/log/request/log_statistics.go

@@ -7,8 +7,9 @@ import (
 type GetStatisticsLogRequest struct {
 	log.StatisticsLog
 	PageInfo
-	OrderKey string `json:"orderKey"` // 排序
-	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+	GamePortId int    `json:"game_port_id"`
+	OrderKey   string `json:"orderKey"` // 排序
+	Desc       bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
 }
 
 type GetStatisticsComputerRequest struct {
@@ -80,7 +81,6 @@ type ExcelIpInfo struct {
 	} `json:"infoList"`
 }
 
-
 type GetLogScanningCodeRequest struct {
 	LogScanningRequest
 	PageInfo

+ 14 - 8
service/log/log_statistics.go

@@ -347,19 +347,25 @@ func (s *ServiceStatisticsLog) statisticsData(ctx context.Context, gameIdInt, tt
 	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, gamePortId int) (interface{}, int64, error) {
 	date := api.CreateDate
 	if date == "" {
 		date = s.CurrentDate()
 	}
 
-	db := global.GVA_DB.Model(&log.StatisticsLog{})
+	db := global.GVA_DB.Table("log_statistics gtc")
+
+	db = db.Joins("left join game_task gt on gt.task_id = gtc.game_id")
 	if api.GameId != 0 {
-		db = db.Where("game_id = ?", api.GameId)
+		db = db.Where("gtc.game_id = ?", api.GameId)
+	}
+	db = db.Where("gtc.create_date = ?", date)
+	if gamePortId != 0 {
+		db = db.Where("gt.game_port_id = ?", gamePortId)
 	}
-	db = db.Where("create_date = ?", date)
 	var total int64
 	err := db.Count(&total).Error
+	db = db.Select("gtc.*")
 	if err != nil {
 		return nil, 0, err
 	}
@@ -381,9 +387,9 @@ func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api l
 		orderMap["game_id"] = true
 		if orderMap[order] {
 			if desc {
-				OrderStr = order + " desc"
+				OrderStr = "gtc." + order + " desc"
 			} else {
-				OrderStr = order
+				OrderStr = "gtc." + order
 			}
 		} else { // didn't matched any order key in `orderMap`
 			global.GVA_LOG.Error("获取失败!", zap.Error(err))
@@ -392,7 +398,7 @@ func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api l
 
 		err = db.Order(OrderStr).Find(&statisticsLogs).Error
 	} else {
-		err = db.Order("id").Find(&statisticsLogs).Error
+		err = db.Order("gtc.id").Find(&statisticsLogs).Error
 	}
 	if err != nil {
 		return nil, 0, err
@@ -1072,7 +1078,7 @@ func (s *ServiceStatisticsLog) RegularCheckPc() {
 			}
 			ct = fmt.Sprintf("<font color=\"warning\">%s</font>", ct)
 			ct = c + ct
-			go s.SendContent(ct, mpsPerson[name].Url)
+			//go s.SendContent(ct, mpsPerson[name].Url)
 		}
 	}
 	if content != "" {