wangbin vor 3 Jahren
Ursprung
Commit
3a0990c244

+ 2 - 1
.gitignore

@@ -41,4 +41,5 @@ _test
 /.idea
 /log/*
 log-server
-config.docker.yaml
+config.docker.yaml
+/test

+ 42 - 0
api/v1/log/loging.go

@@ -216,3 +216,45 @@ func (s *ApiLoging) GetComputerStatistics(c *gin.Context) {
 		}, "获取成功", c)
 	}
 }
+
+// @Tags loging
+// @Summary 获取统计电脑数量
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Success 200 {object} response.Response{data=interface{}} "获取统计电脑数量"
+// @Router /loging/getComputerNum [post]
+func (s *ApiLoging) GetComputerNum(c *gin.Context) {
+	var paramsInfo request.GetStatisticsComputerRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	num := ServiceStatisticsLog.GetComputerNum()
+	response.OkWithDetailed(num, "获取成功", c)
+}
+
+// @Tags loging
+// @Summary 获取统计数据通过GameId
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Success 200 {object} response.Response{data=interface{}} "获取统计数据通过GameId"
+// @Router /loging/getGameIdStatistics [post]
+func (s *ApiLoging) GetGameIdStatistics(c *gin.Context) {
+	var paramsInfo request.GetStatisticsComputerRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}*/
+	list, total, err := ServiceStatisticsLog.GameStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}

+ 1 - 1
config.yaml

@@ -118,7 +118,7 @@ qiniu:
   secret-key: ""
   use-cdn-domains: false
 redis:
-  db: 8
+  db: 7
   addr: 120.92.140.137:6379
   password: "rootredis!fu>6Wy2"
 system:

+ 14 - 3
initialize/timer.go

@@ -38,12 +38,23 @@ func Timer() {
 		fmt.Println("add taskCode timer error:", err)
 	}
 
-	_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData", "2 8 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
+	_, err = global.GVA_Timer.AddTaskByFunc("CreateComputerStatisticsData", "40 0/9 7-23 * * * ", serviceStatisticsLog.CreateComputerStatisticsData)
 	if err != nil {
 		fmt.Println("add CreateComputerStatisticsData timer error:", err)
 	}
-	_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
+
+	_, err = global.GVA_Timer.AddTaskByFunc("TodayCreateStatisticsGameInfoLog", "2 0/4 6-23 * * * ", serviceStatisticsLog.TodayCreateStatisticsGameInfoLog)
+	if err != nil {
+		fmt.Println("add TodayCreateStatisticsGameInfoLog timer error:", err)
+	}
+
+	_, err = global.GVA_Timer.AddTaskByFunc("TodayCreateStatisticsGameInfoLog", "2 0/3 6-23 * * * ", serviceStatisticsLog.TaskStatisticsDataCache)
 	if err != nil {
-		fmt.Println("everyDayResetStatisticsCache timer error:", err)
+		fmt.Println("add TodayCreateStatisticsGameInfoLog timer error:", err)
 	}
+
+	//_, err = global.GVA_Timer.AddTaskByFunc("createFailLog", "2 0/5 6-23 * * * ", ServiceLogList.CreateFailLog)
+	//if err != nil {
+	//	fmt.Println("everyDayResetStatisticsCache timer error:", err)
+	//}
 }

+ 14 - 5
model/log/log_computer.go

@@ -1,11 +1,20 @@
 package log
 
 type LogComputer struct {
-	Id         uint   `json:"id"`
-	PcCode     string `json:"pc_code"`
-	GameInfo   string `json:"game_info"`
-	CreateDate string `json:"create_date"`
-	Operator   string `json:"operator"`
+	Id                      uint   `json:"id"`
+	PcCode                  string `json:"pc_code"`
+	GameInfo                string `json:"game_info"`
+	CreateDate              string `json:"create_date"`
+	Operator                string `json:"operator"`
+	GameId                  int    `json:"game_id"`
+	PullAccountNum          int    `json:"pull_account_num"`
+	TaskSuccessNum          int    `json:"task_success_num"`
+	TargetNum               int    `json:"target_num"` // 目标数
+	ComputerFreeTime        int    `json:"computer_free_time"`
+	ComputerFeeRate         int    `json:"computer_fee_rate"`
+	GameFeeRate             int    `json:"game_fee_rate"`
+	ComputerHourAverageRate int    `json:"computer_hour_average_rate"`
+	EnterMain               int    `json:"enter_main"`
 }
 
 func (LogComputer) TableName() string {

+ 12 - 0
model/log/log_statistics.go

@@ -48,6 +48,18 @@ type StatisticsLog struct {
 	Type                int    `json:"type"` // 0新增1活跃
 	CreateDate          string `json:"create_date"`
 	CreateTime          string `json:"create_time"` // 创建时间
+	GameName            string `json:"game_name"`
+	PayComplete         int    `json:"pay_complete"`
+	TargetNum           int    `json:"target_num"`          // 目标数
+	TargetCompleteNum   int    `json:"target_complete_num"` // 目标完成数
+	PayTarget           int    `json:"pay_target"`          // 目标付费
+	OrderSuccessRate    string `json:"order_success_rate"`  // 订单成功率
+	IssuedAccount       int    `json:"issued_account"`
+	NewScanningCode     int    `json:"new_scanning_code"`
+	OrderSuccess        int    `json:"order_success"`        //小绵羊成功付费数
+	OrderCreate         int    `json:"order_create"`         // 小绵羊创建付费订单数
+	RetainedAccountNum  int    `json:"retained_account_num"` // 留存账号
+	FeeAccountNum       int    `json:"fee_account_num"`      // 付费账号
 }
 
 func (StatisticsLog) TableName() string {

+ 34 - 0
model/log/request/log_statistics.go

@@ -15,3 +15,37 @@ type GetStatisticsComputerRequest struct {
 	OrderKey string `json:"orderKey"` // 排序
 	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
 }
+
+type TaskStatistics struct {
+	GameId                int    `json:"game_id"`
+	GameName              string `json:"game_name"`
+	GameIdXmy             string `json:"game_id_xmy"`
+	NewComplete           int    `json:"new_complete"`
+	RetainedComplete      int    `json:"retained_complete"`
+	PayComplete           int    `json:"pay_complete"`
+	NewCompleteLocal      int    `json:"new_complete_local"`
+	RetainedCompleteLocal int    `json:"retained_complete_local"`
+	PayCompleteLocal      int    `json:"pay_complete_local"`
+	NewTarget             int    `json:"new_target"`         // 目标新增
+	RetainedTarget        int    `json:"retained_target"`    // 目标留存
+	PayTarget             int    `json:"pay_target"`         // 目标付费
+	OrderSuccessRate      string `json:"order_success_rate"` // 订单成功率
+	OrderSuccess          int    `json:"order_success"`      //小绵羊成功付费数
+	OrderCreate           int    `json:"order_create"`       // 小绵羊创建付费订单数
+	NewPullAccount        int    `json:"new_pull_account"`
+	RetainedPullAccount   int    `json:"retained_pull_account"`
+	NewScanningCode       int    `json:"new_scanning_code"`
+	RetainedScanningCode  int    `json:"retained_scanning_code"`
+	RetainedAccountNum    int    `json:"retained_account_num"` // 留存账号
+	FeeAccountNum         int    `json:"fee_account_num"`      // 付费账号
+}
+
+type TaskData struct {
+	GameId               int `json:"game_id"`
+	NewPullAccount       int `json:"new_pull_account"`
+	RetainedPullAccount  int `json:"retained_pull_account"`
+	NewScanningCode      int `json:"new_scanning_code"`
+	RetainedScanningCode int `json:"retained_scanning_code"`
+	RetainedAccountNum   int `json:"retained_account_num"`
+	FeeAccountNum        int `json:"fee_account_num"`
+}

+ 23 - 5
model/log/response/loging.go

@@ -43,10 +43,28 @@ type GameInfo struct {
 }
 
 type ComputerStatisticsReply1 struct {
-	PcCode     string      `json:"pc_code"`
-	GameInfo   []*GameInfo `json:"game_info"`
-	CreateDate string      `json:"create_date"`
-	Operator   string      `json:"operator"`
-	GameId     string      `json:"game_id"`
+	PcCode                  string      `json:"pc_code"`
+	GameInfo                []*GameInfo `json:"game_info"`
+	CreateDate              string      `json:"create_date"`
+	Operator                string      `json:"operator"`
+	GameId                  int         `json:"game_id"`
+	TargetNum               int         `json:"target_num"` // 目标数
+	ComputerFreeTime        int         `json:"computer_free_time"`
+	ComputerFeeRate         int         `json:"computer_fee_rate"`
+	ComputerHourAverageRate int         `json:"computer_hour_average_rate"`
+	EnterMain               int         `json:"enter_main"`
 	DataNumInfo
 }
+
+type GameIdStatisticsReply struct {
+	CreateDate               string `json:"create_date"`
+	GameId                   int    `json:"game_id"`
+	TargetNum                int    `json:"target_num"` // 目标数
+	PcCodeTotal              int    `json:"pc_code_total"`
+	TaskSuccessTotal         int    `json:"task_success_total"`
+	GameFeeRate              int    `json:"game_fee_rate"`
+	ComputerFreeTimeTotal    int    `json:"computer_free_time_total"`
+	ComputerHourAverageTotal int    `json:"computer_hour_average_total"`
+	OneComputerAverageNum    int    `json:"one_computer_average_num"`
+	EnterMainTotal           int    `json:"enter_main_total"`
+}

+ 2 - 0
router/log/loging.go

@@ -18,5 +18,7 @@ func (e *LogingRouter) InitLogingRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("getStatisticsLogList", logApi.GetStatisticsLogList)
 		excelRouter.POST("resetStatisticsLog", logApi.ResetStatisticsLog)
 		excelRouter.POST("getComputerStatistics", logApi.GetComputerStatistics)
+		excelRouter.POST("getGameIdStatistics", logApi.GetGameIdStatistics)
+		excelRouter.POST("getComputerNum", logApi.GetComputerNum)
 	}
 }

+ 5 - 0
service/cache/cache.go

@@ -59,6 +59,11 @@ func (s *Cache) SetCacheNum(ctx context.Context, key string) (err error) {
 	}
 }
 
+func (s *Cache) SetCacheStr(ctx context.Context, key string, value interface{}) (err error) {
+	err = global.GVA_REDIS.Set(ctx, key, value, time.Hour*30).Err()
+	return err
+}
+
 func (s *Cache) GetCacheNum(ctx context.Context, key string) (num int, err error) {
 	num, err = global.GVA_REDIS.Get(ctx, key).Int()
 	if err != nil {

+ 2 - 0
service/log/log_list.go

@@ -37,6 +37,8 @@ func (s *ServiceLogList) GetCodeLogList(ctx context.Context, api log.Loging, inf
 	}
 	if api.GameId != 0 {
 		db = db.Where("game_id = ?", api.GameId)
+	} else {
+		return
 	}
 	if api.PcCode != "" {
 		db = db.Where("pc_code = ?", api.PcCode)

+ 435 - 329
service/log/log_statistics.go

@@ -23,6 +23,8 @@ type ServiceStatisticsLog struct {
 }
 
 var StatisticsCompletedKey = "%s:StatisticsCompleted"
+var taskStatistics = "%s:taskStatistics"
+var ComputerNum = "%s:ComputerNum"
 var TaskType = []int{0, 1}
 
 func (s *ServiceStatisticsLog) CreateStatisticsLog() {
@@ -49,349 +51,237 @@ func (s *ServiceStatisticsLog) CreateStatisticsLog() {
 	var statisticsLogs []*log.StatisticsLog
 	for gameId, _ := range gameMps {
 		for _, tt := range TaskType {
-			statisticsLog := new(log.StatisticsLog)
 			gameIdInt, _ := strconv.Atoi(gameId)
-			pullAccountOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4100000", loging2.OkStatus, tt)
-			pullAccountFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4100000", loging2.FailStatus, tt)
-			ConstituencyFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4604000", loging2.FailStatus, tt)
-			ConstituencyOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4604000", loging2.OkStatus, tt)
-			StartProxyFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4200000", loging2.FailStatus, tt)
-			StartProxyOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4200000", loging2.OkStatus, tt)
-			SimulatorStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4300000", loging2.FailStatus, tt)
-			SimulatorStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4300000", loging2.OkStatus, tt)
-			NetworkCheckFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4400000", loging2.FailStatus, tt)
-			NetworkCheckOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4400000", loging2.OkStatus, tt)
-			GameStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4500000", loging2.FailStatus, tt)
-			GameStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4500000", loging2.OkStatus, tt)
-			xmyLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4601000", loging2.FailStatus, tt)
-			xmyLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4601000", loging2.OkStatus, tt)
-			wxLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4602000", loging2.FailStatus, tt)
-			wxLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4602000", loging2.OkStatus, tt)
-			mzLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4603000", loging2.FailStatus, tt)
-			mzLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4603000", loging2.OkStatus, tt)
-			LoginFail := xmyLoginFail + wxLoginFail + mzLoginFail
-			LoginOk := xmyLoginOk + wxLoginOk + mzLoginOk
-			EnterMainFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4700000", loging2.FailStatus, tt)
-			EnterMainOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4700000", loging2.OkStatus, tt)
-			FeeFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4800000", loging2.FailStatus, tt)
-			FeeOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4800000", loging2.OkStatus, tt)
-			ScriptStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4300000", loging2.FailStatus, tt)
-			ScriptStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4300000", loging2.OkStatus, tt)
-			EnterGameFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4605000", loging2.FailStatus, tt)
-			EnterGameOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4605000", loging2.OkStatus, tt)
-			AuthenticationFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4607000", loging2.FailStatus, tt)
-			AuthenticationOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4607000", loging2.OkStatus, tt)
-			HasRole, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4609902", loging2.NoLogStatus, tt)
-			NotRole, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4609901", loging2.NoLogStatus, tt)
-			EnterStartGame, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4501000", loging2.NoLogStatus, tt)
-			EnterAuthentication, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4607000", loging2.NoLogStatus, tt)
-			EnterConstituency, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4604000", loging2.NoLogStatus, tt)
-			EnterGame, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4605000", loging2.NoLogStatus, tt)
-			EnterMain, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4701000", loging2.NoLogStatus, tt)
-			EnterFee, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4800000", loging2.NoLogStatus, tt)
-			EnterXmyLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4601000", loging2.NoLogStatus, tt)
-			EnterWxLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4602000", loging2.NoLogStatus, tt)
-			EnterMzLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.YesterdayDate(), gameIdInt, "4603000", loging2.NoLogStatus, tt)
-			BanOff1, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4601006", loging2.FailStatus, tt) // 小绵羊登录封号
-			BanOff2, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4602008", loging2.FailStatus, tt) // 微信登录封号
-			BanOff3, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4603006", loging2.FailStatus, tt) // 魅族登录封号
-			BanOff4, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4701003", loging2.FailStatus, tt) // 主线封号
-			Freeze, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4809904", loging2.NoLogStatus, tt) // 冻结
-			BanOff := BanOff1 + BanOff2 + BanOff3 + BanOff4
-			EnterLogin := EnterXmyLogin + EnterMzLogin + EnterWxLogin
-			statisticsLog.PullAccountOk = pullAccountOk
-			statisticsLog.PullAccountFail = pullAccountFail
-			statisticsLog.StartProxyFail = StartProxyFail
-			statisticsLog.StartProxyOk = StartProxyOk
-			statisticsLog.SimulatorStartFail = SimulatorStartFail
-			statisticsLog.SimulatorStartOk = SimulatorStartOk
-			statisticsLog.NetworkCheckFail = NetworkCheckFail
-			statisticsLog.NetworkCheckOk = NetworkCheckOk
-			statisticsLog.EnterMainFail = EnterMainFail
-			statisticsLog.EnterMainOk = EnterMainOk
-			statisticsLog.EnterGameFail = EnterGameFail
-			statisticsLog.EnterGameOk = EnterGameOk
-			statisticsLog.GameId = gameIdInt
-			statisticsLog.ConstituencyFail = ConstituencyFail
-			statisticsLog.ConstituencyOk = ConstituencyOk
-			statisticsLog.FeeFail = FeeFail
-			statisticsLog.FeeOk = FeeOk
-			statisticsLog.GameStartFail = GameStartFail
-			statisticsLog.GameStartOk = GameStartOk
-			statisticsLog.LoginFail = LoginFail
-			statisticsLog.LoginOk = LoginOk
-			statisticsLog.XmyLoginFail = xmyLoginFail
-			statisticsLog.XmyLoginOk = xmyLoginOk
-			statisticsLog.WxLoginFail = wxLoginFail
-			statisticsLog.WxLoginOk = wxLoginOk
-			statisticsLog.MzLoginFail = mzLoginFail
-			statisticsLog.MzLoginOk = mzLoginOk
-			statisticsLog.ScriptStartFail = ScriptStartFail
-			statisticsLog.ScriptStartOk = ScriptStartOk
-			statisticsLog.AuthenticationFail = AuthenticationFail
-			statisticsLog.AuthenticationOk = AuthenticationOk
-			statisticsLog.HasRole = HasRole
-			statisticsLog.NotRole = NotRole
-			statisticsLog.EnterStartGame = EnterStartGame
-			statisticsLog.EnterAuthentication = EnterAuthentication
-			statisticsLog.EnterConstituency = EnterConstituency
-			statisticsLog.EnterGame = EnterGame
-			statisticsLog.EnterMain = EnterMain
-			statisticsLog.EnterFee = EnterFee
-			statisticsLog.EnterLogin = EnterLogin
-			statisticsLog.BanOff = BanOff
-			statisticsLog.Freeze = Freeze
-			statisticsLog.Type = tt
-			statisticsLog.CreateTime = time.Now().Format("2006-01-02 15:04:05")
-			statisticsLog.CreateDate = time.Now().Add(-time.Hour * 24).Format("2006-01-02")
-			statisticsLogs = append(statisticsLogs, statisticsLog)
-			if len(statisticsLogs) == 100 {
-				err = global.GVA_DB.Create(statisticsLogs).Error
+			statisticsLogNew := new(log.StatisticsLog)
+			statisticsLog := s.statisticsData(ctx, gameIdInt, tt, s.LogicalLog.YesterdayDate(), statisticsLogNew)
+			if !errors.Is(global.GVA_DB.Where("create_date = ?", s.LogicalLog.YesterdayDate()).Where("game_id = ?", gameIdInt).First(&log.StatisticsLog{}).Error, gorm.ErrRecordNotFound) {
+				// 已存在,跳过
+				err = global.GVA_DB.Where("game_id", gameIdInt).Where("create_date = ?", s.LogicalLog.YesterdayDate()).Where("type = ?", tt).Updates(statisticsLog).Error
 				if err != nil {
-					global.GVA_LOG.Error("添加statisticsLogs失败!", zap.Error(err))
-					return
+					global.GVA_LOG.Error("update StatisticsLogs失败!", zap.Error(err))
+					continue
 				}
-				statisticsLogs = []*log.StatisticsLog{}
+				continue
 			}
+			statisticsLogs = append(statisticsLogs, statisticsLog)
 		}
 	}
 	if len(statisticsLogs) == 0 {
+		global.GVA_LOG.Info("statisticsLogsGameInfo没有数据!", zap.Error(err))
 		global.GVA_REDIS.Set(ctx, key, 1, 24*time.Hour)
 		return
 	}
 	err = global.GVA_DB.Create(statisticsLogs).Error
 	if err != nil {
-		global.GVA_LOG.Error("添加statisticsLogs失败!", zap.Error(err))
+		global.GVA_LOG.Error("添加statisticsLogsGameInfo失败!", zap.Error(err))
 		return
 	}
 	global.GVA_REDIS.Set(ctx, key, 1, 24*time.Hour)
 	return
 }
 
-func (s *ServiceStatisticsLog) TodayStatisticsLogList1() (interface{}, error) {
-	gameMps, err := s.LogicalLog.GetGameCache(context.Background(), s.CurrentDate())
+func (s *ServiceStatisticsLog) TodayCreateStatisticsGameInfoLog() {
+	date := s.LogicalLog.CurrentDate()
+	gameMps, err := s.LogicalLog.GetGameCache(context.Background(), date)
 	if err != nil {
 		global.GVA_LOG.Error("获取redis game list失败!", zap.Error(err))
-		return nil, err
-	}
-	/*var statisticsLogs []*log.StatisticsLog
-	for _,info := range apiList{
-		statisticsLog := new(log.StatisticsLog)
-		statisticsLog.PullAccountOk = info.PullAccountOk
-		statisticsLog.PullAccountFail = info.PullAccountFail
-		statisticsLog.StartProxyFail = info.StartProxyFail
-		statisticsLog.StartProxyOk = info.StartProxyOk
-		statisticsLog.SimulatorStartFail = info.SimulatorStartFail
-		statisticsLog.SimulatorStartOk = info.SimulatorStartOk
-		statisticsLog.NetworkCheckFail = info.NetworkCheckFail
-		statisticsLog.NetworkCheckOk = info.NetworkCheckOk
-		statisticsLog.EnterMainFail = info.EnterMainFail
-		statisticsLog.EnterMainOk = info.EnterMainOk
-		statisticsLog.EnterGameFail = info.EnterGameFail
-		statisticsLog.EnterGameOk = info.EnterGameOk
-		statisticsLog.GameId = info.GameId
-		statisticsLog.ConstituencyFail = info.ConstituencyFail
-		statisticsLog.ConstituencyOk = info.ConstituencyOk
-		statisticsLog.FeeFail = info.FeeFail
-		statisticsLog.FeeOk = info.FeeOk
-		statisticsLog.GameStartFail = info.GameStartFail
-		statisticsLog.GameStartOk = info.GameStartOk
-		statisticsLog.LoginFail = info.LoginFail
-		statisticsLog.LoginOk = info.LoginOk
-		statisticsLog.XmyLoginFail = info.XmyLoginFail
-		statisticsLog.XmyLoginOk = info.XmyLoginOk
-		statisticsLog.WxLoginFail = info.WxLoginFail
-		statisticsLog.WxLoginOk = info.WxLoginOk
-		statisticsLog.MzLoginFail = info.MzLoginFail
-		statisticsLog.MzLoginOk = info.MzLoginOk
-		statisticsLog.ScriptStartFail = info.ScriptStartFail
-		statisticsLog.ScriptStartOk = info.ScriptStartOk
-		statisticsLog.AuthenticationFail = info.AuthenticationFail
-		statisticsLog.AuthenticationOk = info.AuthenticationOk
-		statisticsLog.HasRole = info.HasRole
-		statisticsLog.NotRole = info.NotRole
-		statisticsLog.EnterStartGame = info.EnterStartGame
-		statisticsLog.EnterAuthentication = info.EnterAuthentication
-		statisticsLog.EnterConstituency = info.EnterConstituency
-		statisticsLog.EnterGame = info.EnterGame
-		statisticsLog.EnterMain = info.EnterMain
-		statisticsLog.EnterFee = info.EnterFee
-		statisticsLog.EnterLogin = info.EnterLogin
-		statisticsLog.BanOff = info.BanOff
-		statisticsLog.Freeze = info.Freeze
-		statisticsLog.Type = info.Type
-		statisticsLog.CreateTime = info.CreateTime
-		statisticsLog.CreateDate = info.CreateDate
-		statisticsLogs = append(statisticsLogs,statisticsLog)
-	}*/
-	ctx := context.Background()
-	var gmps = map[string][]map[int]interface{}{}
+		return
+	}
+	if len(gameMps) == 0 {
+		global.GVA_LOG.Info("获取redis game list没有数据!")
+		return
+	}
+	var statisticsLogs []*log.StatisticsLog
 	for gameId, _ := range gameMps {
-		var TTmps = map[int]interface{}{}
 		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 {
-			cacheKeys, err := s.LogicalLog.GetGameStatisticsCacheKeys(ctx, s.CurrentDate(), gameIdInt, tt)
-			if err != nil {
-				if err == redis.Nil {
-					continue
+			statisticsLog := new(log.StatisticsLog)
+			statisticsLog.GameId = gameIdInt
+			statisticsLog.Type = tt
+			statisticsLog.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+			statisticsLog.CreateDate = date
+			statisticsLogs = append(statisticsLogs, statisticsLog)
+			if len(statisticsLogs) == 100 {
+				err = global.GVA_DB.Create(statisticsLogs).Error
+				if err != nil {
+					global.GVA_LOG.Error("添加statisticsLogs失败!", zap.Error(err))
+					return
 				}
-				return nil, err
-			}
-			var dmps = map[string]string{}
-			for _, cacheKey := range cacheKeys {
-				num, _ := global.GVA_REDIS.Get(ctx, cacheKey).Result()
-				code := s.LogicalLog.ByCacheKeyGetEndNode(cacheKey)
-				dmps[code] = num
-			}
-			if len(dmps) != 0 {
-				TTmps[tt] = dmps
+				statisticsLogs = []*log.StatisticsLog{}
 			}
-
 		}
-		gmps[gameId] = append(gmps[gameId], TTmps)
 	}
-	return gmps, err
+	if len(statisticsLogs) == 0 {
+		global.GVA_LOG.Info("statisticsLogsGameInfo没有数据!", zap.Error(err))
+		return
+	}
+	err = global.GVA_DB.Create(statisticsLogs).Error
+	if err != nil {
+		global.GVA_LOG.Error("添加statisticsLogsGameInfo失败!", zap.Error(err))
+		return
+	}
+	return
 }
 
 func (s *ServiceStatisticsLog) TodayStatisticsLogList(ctx context.Context, api log.StatisticsLog, info request.PageInfo) (interface{}, int64, error) {
-	gameMps, err := s.LogicalLog.GetGameCache(context.Background(), s.CurrentDate())
-	if err != nil {
-		global.GVA_LOG.Error("获取redis game list失败!", zap.Error(err))
-		return nil, 0, err
+	db := global.GVA_DB.Model(&log.StatisticsLog{})
+	if api.GameId != 0 {
+		db = db.Where("game_id = ?", api.GameId)
 	}
-	if len(gameMps) == 0 {
-		global.GVA_LOG.Info("获取redis game list没有数据!")
+	db = db.Where("create_date = ?", s.CurrentDate())
+	var total int64
+	err := db.Count(&total).Error
+	if err != nil {
 		return nil, 0, err
 	}
-	if api.GameId != 0 {
-		_, b := gameMps[strconv.Itoa(api.GameId)]
-		if !b {
-			return nil, 0, nil
-		}
-		gameMps = map[string]string{strconv.Itoa(api.GameId): "1"}
-	}
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
-	total := len(gameMps)
 	var statisticsLogs []*log.StatisticsLog
-	for i := 0; i < limit+offset; i++ {
+	var statisticsLogs2 []*log.StatisticsLog
+	db = db.Limit(limit).Offset(offset)
+	err = db.Order("id").Find(&statisticsLogs).Error
+	for _, gameInfo := range statisticsLogs {
+		tt := gameInfo.Type
+		gameIdInt := gameInfo.GameId
+		statisticsLogNew := new(log.StatisticsLog)
+		statisticsLog := s.statisticsData(ctx, gameIdInt, tt, s.LogicalLog.CurrentDate(), statisticsLogNew)
+		statisticsLogs2 = append(statisticsLogs2, statisticsLog)
+	}
+	return statisticsLogs2, total, err
+}
 
-	}
-	i := 0
-	lf := limit + offset
-	for gameId, _ := range gameMps {
-		if i < offset {
-			i++
-			continue
-		}
-		if i >= lf {
-			break
-		}
-		for _, tt := range TaskType {
-			statisticsLog := new(log.StatisticsLog)
-			gameIdInt, _ := strconv.Atoi(gameId)
-			pullAccountOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4100000", loging2.OkStatus, tt)
-			pullAccountFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4100000", loging2.FailStatus, tt)
-			ConstituencyFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4604000", loging2.FailStatus, tt)
-			ConstituencyOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4604000", loging2.OkStatus, tt)
-			StartProxyFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4200000", loging2.FailStatus, tt)
-			StartProxyOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4200000", loging2.OkStatus, tt)
-			SimulatorStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4300000", loging2.FailStatus, tt)
-			SimulatorStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4300000", loging2.OkStatus, tt)
-			NetworkCheckFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4400000", loging2.FailStatus, tt)
-			NetworkCheckOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4400000", loging2.OkStatus, tt)
-			GameStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4500000", loging2.FailStatus, tt)
-			GameStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4500000", loging2.OkStatus, tt)
-			xmyLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4601000", loging2.FailStatus, tt)
-			xmyLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4601000", loging2.OkStatus, tt)
-			wxLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4602000", loging2.FailStatus, tt)
-			wxLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4602000", loging2.OkStatus, tt)
-			mzLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4603000", loging2.FailStatus, tt)
-			mzLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4603000", loging2.OkStatus, tt)
-			LoginFail := xmyLoginFail + wxLoginFail + mzLoginFail
-			LoginOk := xmyLoginOk + wxLoginOk + mzLoginOk
-			EnterMainFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4700000", loging2.FailStatus, tt)
-			EnterMainOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4700000", loging2.OkStatus, tt)
-			FeeFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4800000", loging2.FailStatus, tt)
-			FeeOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4800000", loging2.OkStatus, tt)
-			ScriptStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4300000", loging2.FailStatus, tt)
-			ScriptStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4300000", loging2.OkStatus, tt)
-			EnterGameFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4605000", loging2.FailStatus, tt)
-			EnterGameOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4605000", loging2.OkStatus, tt)
-			AuthenticationFail, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4607000", loging2.FailStatus, tt)
-			AuthenticationOk, _ := s.LogicalLog.TypeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4607000", loging2.OkStatus, tt)
-			HasRole, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4609902", loging2.NoLogStatus, tt)
-			NotRole, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4609901", loging2.NoLogStatus, tt)
-			EnterStartGame, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4501000", loging2.NoLogStatus, tt)
-			EnterAuthentication, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4607000", loging2.NoLogStatus, tt)
-			EnterConstituency, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4604000", loging2.NoLogStatus, tt)
-			EnterGame, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4605000", loging2.NoLogStatus, tt)
-			EnterMain, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4701000", loging2.NoLogStatus, tt)
-			EnterFee1, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4801000", loging2.NoLogStatus, tt) //小绵羊进入付费
-			EnterFee2, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4802000", loging2.NoLogStatus, tt) //微信进入付费
-			EnterFee3, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4803000", loging2.NoLogStatus, tt) //魅族进入付费
-			EnterFee4, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4804000", loging2.NoLogStatus, tt) //QQ卡进入付费
-			EnterFee := EnterFee1 + EnterFee2 + EnterFee3 + EnterFee4
-			EnterXmyLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4601000", loging2.NoLogStatus, tt)
-			EnterWxLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4602000", loging2.NoLogStatus, tt)
-			EnterMzLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4603000", loging2.NoLogStatus, tt)
-			BanOff1, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4601006", loging2.FailStatus, tt) // 小绵羊登录封号
-			BanOff2, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4602008", loging2.FailStatus, tt) // 微信登录封号
-			BanOff3, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4603006", loging2.FailStatus, tt) // 魅族登录封号
-			BanOff4, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4701003", loging2.FailStatus, tt) // 主线封号
-			Freeze, _ := s.LogicalLog.CodeLogGetNum(ctx, s.CurrentDate(), gameIdInt, "4809904", loging2.NoLogStatus, tt) // 冻结
-			BanOff := BanOff1 + BanOff2 + BanOff3 + BanOff4
-			EnterLogin := EnterXmyLogin + EnterMzLogin + EnterWxLogin
-			statisticsLog.PullAccountOk = pullAccountOk
-			statisticsLog.PullAccountFail = pullAccountFail
-			statisticsLog.StartProxyFail = StartProxyFail
-			statisticsLog.StartProxyOk = StartProxyOk
-			statisticsLog.SimulatorStartFail = SimulatorStartFail
-			statisticsLog.SimulatorStartOk = SimulatorStartOk
-			statisticsLog.NetworkCheckFail = NetworkCheckFail
-			statisticsLog.NetworkCheckOk = NetworkCheckOk
-			statisticsLog.EnterMainFail = EnterMainFail
-			statisticsLog.EnterMainOk = EnterMainOk
-			statisticsLog.EnterGameFail = EnterGameFail
-			statisticsLog.EnterGameOk = EnterGameOk
-			statisticsLog.GameId = gameIdInt
-			statisticsLog.ConstituencyFail = ConstituencyFail
-			statisticsLog.ConstituencyOk = ConstituencyOk
-			statisticsLog.FeeFail = FeeFail
-			statisticsLog.FeeOk = FeeOk
-			statisticsLog.GameStartFail = GameStartFail
-			statisticsLog.GameStartOk = GameStartOk
-			statisticsLog.LoginFail = LoginFail
-			statisticsLog.LoginOk = LoginOk
-			statisticsLog.XmyLoginFail = xmyLoginFail
-			statisticsLog.XmyLoginOk = xmyLoginOk
-			statisticsLog.WxLoginFail = wxLoginFail
-			statisticsLog.WxLoginOk = wxLoginOk
-			statisticsLog.MzLoginFail = mzLoginFail
-			statisticsLog.MzLoginOk = mzLoginOk
-			statisticsLog.ScriptStartFail = ScriptStartFail
-			statisticsLog.ScriptStartOk = ScriptStartOk
-			statisticsLog.AuthenticationFail = AuthenticationFail
-			statisticsLog.AuthenticationOk = AuthenticationOk
-			statisticsLog.HasRole = HasRole
-			statisticsLog.NotRole = NotRole
-			statisticsLog.EnterStartGame = EnterStartGame
-			statisticsLog.EnterAuthentication = EnterAuthentication
-			statisticsLog.EnterConstituency = EnterConstituency
-			statisticsLog.EnterGame = EnterGame
-			statisticsLog.EnterMain = EnterMain
-			statisticsLog.EnterFee = EnterFee
-			statisticsLog.EnterLogin = EnterLogin
-			statisticsLog.BanOff = BanOff
-			statisticsLog.Freeze = Freeze
-			statisticsLog.Type = tt
-			statisticsLog.CreateTime = time.Now().Format("2006-01-02 15:04:05")
-			statisticsLog.CreateDate = time.Now().Format("2006-01-02")
-			statisticsLogs = append(statisticsLogs, statisticsLog)
+func (s *ServiceStatisticsLog) statisticsData(ctx context.Context, gameIdInt, tt int, date string, statisticsLog *log.StatisticsLog) *log.StatisticsLog {
+	key := fmt.Sprintf(taskStatistics, date)
+	gameIdStr := strconv.Itoa(gameIdInt)
+	data, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
+	if err != nil {
+		if err == redis.Nil {
+			global.GVA_LOG.Info("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+		} else {
+			global.GVA_LOG.Error("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+			return nil
 		}
+
 	}
+	var taskStatistics request.TaskStatistics
+	_ = json.Unmarshal([]byte(data), &taskStatistics)
+	pullAccountOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4100000", loging2.OkStatus, tt)
+	pullAccountFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4100000", loging2.FailStatus, tt)
+	ConstituencyFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4604000", loging2.FailStatus, tt)
+	ConstituencyOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4604000", loging2.OkStatus, tt)
+	StartProxyFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4200000", loging2.FailStatus, tt)
+	StartProxyOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4200000", loging2.OkStatus, tt)
+	SimulatorStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4300000", loging2.FailStatus, tt)
+	SimulatorStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4300000", loging2.OkStatus, tt)
+	NetworkCheckFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4400000", loging2.FailStatus, tt)
+	NetworkCheckOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4400000", loging2.OkStatus, tt)
+	GameStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4500000", loging2.FailStatus, tt)
+	GameStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4500000", loging2.OkStatus, tt)
+	xmyLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4601000", loging2.FailStatus, tt)
+	xmyLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4601000", loging2.OkStatus, tt)
+	wxLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4602000", loging2.FailStatus, tt)
+	wxLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4602000", loging2.OkStatus, tt)
+	mzLoginFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4603000", loging2.FailStatus, tt)
+	mzLoginOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4603000", loging2.OkStatus, tt)
+	LoginFail := xmyLoginFail + wxLoginFail + mzLoginFail
+	LoginOk := xmyLoginOk + wxLoginOk + mzLoginOk
+	EnterMainFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4700000", loging2.FailStatus, tt)
+	EnterMainOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4700000", loging2.OkStatus, tt)
+	FeeFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4800000", loging2.FailStatus, tt)
+	FeeOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4800000", loging2.OkStatus, tt)
+	ScriptStartFail, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4300000", loging2.FailStatus, tt)
+	ScriptStartOk, _ := s.LogicalLog.NodeLogGetNum(ctx, date, gameIdInt, "4300000", loging2.OkStatus, tt)
+	EnterGameFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4605000", loging2.FailStatus, tt)
+	EnterGameOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4605000", loging2.OkStatus, tt)
+	AuthenticationFail, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4607000", loging2.FailStatus, tt)
+	AuthenticationOk, _ := s.LogicalLog.TypeLogGetNum(ctx, date, gameIdInt, "4607000", loging2.OkStatus, tt)
+	EnterStartGame, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4501000", loging2.NoLogStatus, tt)
+	EnterAuthentication, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4607000", loging2.NoLogStatus, tt)
+	EnterConstituency, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4604000", loging2.NoLogStatus, tt)
+	EnterGame, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4605000", loging2.NoLogStatus, tt)
+	EnterMain, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4701000", loging2.NoLogStatus, tt)
+	EnterFee, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4800000", loging2.NoLogStatus, tt)
+	EnterXmyLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4601000", loging2.NoLogStatus, tt)
+	EnterWxLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4602000", loging2.NoLogStatus, tt)
+	EnterMzLogin, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4603000", loging2.NoLogStatus, tt)
+	BanOff1, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4601006", loging2.FailStatus, tt) // 小绵羊登录封号
+	BanOff2, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4602008", loging2.FailStatus, tt) // 微信登录封号
+	BanOff3, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4603006", loging2.FailStatus, tt) // 魅族登录封号
+	BanOff4, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4701003", loging2.FailStatus, tt) // 主线封号
+	Freeze, _ := s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4809904", loging2.NoLogStatus, tt) // 冻结
+	BanOff := BanOff1 + BanOff2 + BanOff3 + BanOff4
+	EnterLogin := EnterXmyLogin + EnterMzLogin + EnterWxLogin
+	//statisticsLog.NewHaveRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4604004", loging2.NoLogStatus, tt) // 新增有角色
+	//statisticsLog.RetainedNotRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4604003", loging2.NoLogStatus, tt) // 留存无角色
+	statisticsLog.PullAccountOk = pullAccountOk
+	statisticsLog.PullAccountFail = pullAccountFail
+	statisticsLog.StartProxyFail = StartProxyFail
+	statisticsLog.StartProxyOk = StartProxyOk
+	statisticsLog.SimulatorStartFail = SimulatorStartFail
+	statisticsLog.SimulatorStartOk = SimulatorStartOk
+	statisticsLog.NetworkCheckFail = NetworkCheckFail
+	statisticsLog.NetworkCheckOk = NetworkCheckOk
+	statisticsLog.EnterMainFail = EnterMainFail
+	statisticsLog.EnterMainOk = EnterMainOk
+	statisticsLog.EnterGameFail = EnterGameFail
+	statisticsLog.EnterGameOk = EnterGameOk
+	statisticsLog.GameId = gameIdInt
+	statisticsLog.ConstituencyFail = ConstituencyFail
+	statisticsLog.ConstituencyOk = ConstituencyOk
+	statisticsLog.FeeFail = FeeFail
+	statisticsLog.FeeOk = FeeOk
+	statisticsLog.GameStartFail = GameStartFail
+	statisticsLog.GameStartOk = GameStartOk
+	statisticsLog.LoginFail = LoginFail
+	statisticsLog.LoginOk = LoginOk
+	statisticsLog.XmyLoginFail = xmyLoginFail
+	statisticsLog.XmyLoginOk = xmyLoginOk
+	statisticsLog.WxLoginFail = wxLoginFail
+	statisticsLog.WxLoginOk = wxLoginOk
+	statisticsLog.MzLoginFail = mzLoginFail
+	statisticsLog.MzLoginOk = mzLoginOk
+	statisticsLog.ScriptStartFail = ScriptStartFail
+	statisticsLog.ScriptStartOk = ScriptStartOk
+	statisticsLog.AuthenticationFail = AuthenticationFail
+	statisticsLog.AuthenticationOk = AuthenticationOk
 
-	return statisticsLogs, int64(total), err
+	statisticsLog.EnterStartGame = EnterStartGame
+	statisticsLog.EnterAuthentication = EnterAuthentication
+	statisticsLog.EnterConstituency = EnterConstituency
+	statisticsLog.EnterGame = EnterGame
+	statisticsLog.EnterMain = EnterMain
+	statisticsLog.EnterFee = EnterFee
+	statisticsLog.EnterLogin = EnterLogin
+	statisticsLog.BanOff = BanOff
+	statisticsLog.Freeze = Freeze
+	statisticsLog.Type = tt
+	statisticsLog.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+	statisticsLog.CreateDate = date
+	if tt == 1 {
+		statisticsLog.NotRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4609901", loging2.NoLogStatus, tt)
+		statisticsLog.HasRole = 0
+		statisticsLog.IssuedAccount = taskStatistics.RetainedPullAccount
+		statisticsLog.TargetNum = taskStatistics.RetainedTarget
+		statisticsLog.TargetCompleteNum = taskStatistics.RetainedComplete
+	} else {
+		statisticsLog.NotRole = 0
+		statisticsLog.HasRole, _ = s.LogicalLog.CodeLogGetNum(ctx, date, gameIdInt, "4609902", loging2.NoLogStatus, tt)
+		statisticsLog.IssuedAccount = taskStatistics.NewPullAccount
+		statisticsLog.TargetCompleteNum = taskStatistics.NewComplete
+		statisticsLog.TargetNum = taskStatistics.NewTarget
+	}
+	statisticsLog.NewScanningCode = taskStatistics.NewScanningCode
+	statisticsLog.PayComplete = taskStatistics.PayComplete
+	statisticsLog.PayTarget = taskStatistics.PayTarget
+	statisticsLog.OrderCreate = taskStatistics.OrderCreate
+	statisticsLog.OrderSuccess = taskStatistics.OrderSuccess
+	statisticsLog.RetainedAccountNum = taskStatistics.RetainedAccountNum
+	statisticsLog.FeeAccountNum = taskStatistics.FeeAccountNum
+	return statisticsLog
 }
 
 func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api log.StatisticsLog, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
@@ -405,6 +295,7 @@ func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api l
 	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 {
@@ -413,7 +304,6 @@ func (s *ServiceStatisticsLog) OtherStatisticsLogList(ctx context.Context, api l
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
 	var statisticsLogs []*log.StatisticsLog
-	db = db.Where("create_date = ?", date)
 	db = db.Limit(limit).Offset(offset)
 	err = db.Order("id").Find(&statisticsLogs).Error
 	if err != nil {
@@ -526,12 +416,12 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 	if len(codeMps) == 0 {
 		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())
 	var csReplys []*log.LogComputer
 	for code, r := range codeMps {
-		csReply := new(log.LogComputer)
-		csReply.PcCode = code
-		csReply.Operator = r
-		var gameInfos []*response.GameInfo
 		accountMps, err := s.LogicalLog.GetComputerPullAccountNumCache(ctx, s.LogicalLog.CurrentDate(), code)
 		if err != nil {
 			continue
@@ -540,30 +430,60 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 		if err != nil {
 			continue
 		}
-		for gameId, num := range accountMps {
-			gameInfo := new(response.GameInfo)
-			gameInfo.GameId = gameId
-			gameInfo.PullAccountNum = num
-			gameInfo.TaskSuccessNum = taskMps[gameId]
-			gameInfos = append(gameInfos, gameInfo)
+		enterMainMps, err := s.LogicalLog.GetComputerEnterMainNumCache(ctx, s.LogicalLog.CurrentDate(), code)
+		if err != nil {
+			continue
 		}
-		gameInfoByte, _ := json.Marshal(gameInfos)
-		csReply.GameInfo = string(gameInfoByte)
-		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) {
-			// 已存在,更新
-			mp := make(map[string]interface{})
-			mp["game_info"] = string(gameInfoByte)
-			if csReply.Operator != "" {
-				mp["operator"] = csReply.Operator
-			}
-			err = global.GVA_DB.Table("log_computer").Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).Updates(mp).Error
+		for gameId, num := range accountMps {
+			csReply := new(log.LogComputer)
+			csReply.PcCode = code
+			csReply.Operator = r
+			data, err := global.GVA_REDIS.HGet(ctx, key, gameId).Result()
 			if err != nil {
-				global.GVA_LOG.Error("更新数据失败", zap.Error(err))
+				if err == redis.Nil {
+					global.GVA_LOG.Info("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+				} else {
+					global.GVA_LOG.Error("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+					return
+				}
+
 			}
-			continue
+			var taskStatistics request.TaskStatistics
+			_ = json.Unmarshal([]byte(data), &taskStatistics)
+			csReply.GameId, _ = strconv.Atoi(gameId)
+			csReply.PullAccountNum = num
+			csReply.TaskSuccessNum = taskMps[gameId]
+			csReply.EnterMain = enterMainMps[gameId]
+			csReply.CreateDate = time.Now().Format("2006-01-02")
+			csReply.TargetNum = taskStatistics.NewTarget + taskStatistics.RetainedTarget
+			csReply.ComputerFeeRate = s.GetStatisticsPcFeeRate(ctx, csReply.PcCode, csReply.GameId)
+			csReply.ComputerFreeTime = s.GetStatisticsComputerRate(ctx, csReply.PcCode)
+			csReply.GameFeeRate = s.GetStatisticsFeeRate(ctx, csReply.GameId)
+			runTime := time.Now().Hour() + 1 - csReply.ComputerFreeTime
+			csReply.ComputerHourAverageRate = csReply.TaskSuccessNum / runTime
+			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{})
+				if csReply.Operator != "" {
+					mp["operator"] = csReply.Operator
+				}
+				mp["target_num"] = taskStatistics.NewTarget + taskStatistics.RetainedTarget
+				mp["pull_account_num"] = num
+				mp["task_success_num"] = taskMps[gameId]
+				mp["computer_fee_rate"] = csReply.ComputerFeeRate
+				mp["computer_free_time"] = csReply.ComputerFreeTime
+				mp["game_fee_rate"] = csReply.GameFeeRate
+				mp["computer_hour_average_rate"] = csReply.ComputerHourAverageRate
+				mp["enter_main"] = csReply.EnterMain
+				err = global.GVA_DB.Table("log_computer").Where("create_date = ?", csReply.CreateDate).Where("pc_code = ?", csReply.PcCode).Updates(mp).Error
+				if err != nil {
+					global.GVA_LOG.Error("更新数据失败", zap.Error(err))
+				}
+				continue
+			}
+			csReplys = append(csReplys, csReply)
 		}
-		csReplys = append(csReplys, csReply)
+
 	}
 	if len(csReplys) != 0 {
 		err = global.GVA_DB.Table("log_computer").Create(csReplys).Error
@@ -576,8 +496,10 @@ func (s *ServiceStatisticsLog) CreateComputerStatisticsData() {
 
 func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
 	date := api.CreateDate
+	isCurrentDate := false
 	if date == "" {
 		date = s.CurrentDate()
+		isCurrentDate = true
 	}
 	db := global.GVA_DB.Model(&log.LogComputer{})
 	var total int64
@@ -588,6 +510,9 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 	if api.PcCode != "" {
 		db = db.Where("pc_code = ?", api.PcCode)
 	}
+	if api.GameId != 0 {
+		db = db.Where("game_id = ?", api.GameId)
+	}
 	err := db.Count(&total).Error
 	if err != nil {
 		return nil, 0, err
@@ -601,8 +526,9 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 		return nil, 0, err
 	}
 	var statisticsLogsComputer []*response.ComputerStatisticsReply1
+
 	for _, statisticsLog := range statisticsLogs {
-		var gameInfo []*response.GameInfo
+		/*var gameInfo []*response.GameInfo
 		err = json.Unmarshal([]byte(statisticsLog.GameInfo), &gameInfo)
 		for i, _ := range gameInfo {
 			statisticsLogComputer := new(response.ComputerStatisticsReply1)
@@ -614,7 +540,187 @@ func (s *ServiceStatisticsLog) ComputerStatistics(ctx context.Context, api log.L
 			statisticsLogComputer.PullAccountNum = gameInfo[i].PullAccountNum
 			statisticsLogComputer.TaskSuccessNum = gameInfo[i].TaskSuccessNum
 			statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
+		}*/
+		//gameIdStr:=strconv.Itoa(statisticsLog.GameId)
+		//taskStatistics := s.GameTargetInfo(ctx,s.LogicalLog.CurrentDate(),gameIdStr)
+		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
+		if isCurrentDate {
+			statisticsLogComputer.ComputerFeeRate = s.GetStatisticsPcFeeRate(ctx, statisticsLog.PcCode, statisticsLog.GameId)
 		}
+		statisticsLogComputer.ComputerHourAverageRate = statisticsLog.ComputerHourAverageRate
+		statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
 	}
 	return statisticsLogsComputer, total, err
 }
+
+//根据游戏id查询数据
+func (s *ServiceStatisticsLog) GameStatistics(ctx context.Context, api log.LogComputer, info request.PageInfo) (interface{}, int64, error) {
+	date := api.CreateDate
+	isCurrentDate := false
+	if date == "" {
+		date = s.CurrentDate()
+		isCurrentDate = true
+	}
+	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)
+	}
+	if api.GameId != 0 {
+		db = db.Where("game_id = ?", api.GameId)
+	}
+	db = db.Select("SUM(task_success_num) task_success_total,count(pc_code) pc_code_total,game_id,create_date,SUM(computer_free_time) computer_free_time_total,SUM(computer_hour_average_rate) computer_hour_average_total,SUM(enter_main) enter_main_total,game_fee_rate,target_num").Group("game_id")
+	err := db.Count(&total).Error
+	if err != nil {
+		return nil, 0, err
+	}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	var statisticsLogsByGameId []*response.GameIdStatisticsReply
+
+	db = db.Limit(limit).Offset(offset)
+	err = db.Order("id").Find(&statisticsLogsByGameId).Error
+	if err != nil {
+		return nil, 0, err
+	}
+
+	for _, statisticsLog := range statisticsLogsByGameId {
+		statisticsLog.CreateDate = statisticsLog.CreateDate[:10]
+		statisticsLog.OneComputerAverageNum = statisticsLog.TaskSuccessTotal / statisticsLog.PcCodeTotal
+		if isCurrentDate {
+			statisticsLog.GameFeeRate = s.GetStatisticsFeeRate(ctx, statisticsLog.GameId)
+		}
+	}
+	return statisticsLogsByGameId, total, err
+}
+
+func (s *ServiceStatisticsLog) GameTargetInfo(ctx context.Context, date string, gameId string) (taskStatistics1 request.TaskStatistics) {
+	key := fmt.Sprintf(taskStatistics, date)
+	data, err := global.GVA_REDIS.HGet(ctx, key, gameId).Result()
+	if err != nil {
+		if err == redis.Nil {
+			global.GVA_LOG.Info("TaskStatisticsDataCache"+key+gameId, zap.Error(err))
+		} else {
+			global.GVA_LOG.Error("添加缓存数据失败TaskStatisticsDataCache"+key, zap.Error(err))
+			return
+		}
+
+	}
+	_ = json.Unmarshal([]byte(data), &taskStatistics1)
+	return
+}
+
+// 同步群控任务数据到缓存
+func (s *ServiceStatisticsLog) TaskStatisticsDataCache() {
+	ctx := context.Background()
+	key := fmt.Sprintf(taskStatistics, s.LogicalLog.CurrentDate())
+	data, err := s.LogicalLog.RequestJfRoom()
+	if err != nil {
+		global.GVA_LOG.Error("获取机房数据失败TaskStatisticsDataCache", zap.Error(err))
+		return
+	}
+	dataTask, err := s.LogicalLog.RequestTaskData()
+	if err != nil {
+		global.GVA_LOG.Error("RequestTaskData", zap.Error(err))
+		return
+	}
+	var taskData []request.TaskData
+	var taskStatistics []request.TaskStatistics
+	_ = json.Unmarshal(data, &taskStatistics)
+	_ = json.Unmarshal(dataTask, &taskData)
+	mps := map[int]request.TaskData{}
+	for _, td := range taskData {
+		mps[td.GameId] = td
+	}
+	for _, data := range taskStatistics {
+		var id int
+		id = data.GameId
+		if _, ok := mps[id]; ok {
+			data.NewScanningCode = mps[id].NewScanningCode
+			data.RetainedPullAccount = mps[id].RetainedPullAccount
+			data.NewPullAccount = mps[id].NewPullAccount
+			data.FeeAccountNum = mps[id].FeeAccountNum
+			data.RetainedAccountNum = mps[id].RetainedAccountNum
+		}
+		bd, _ := json.Marshal(data)
+		err = global.GVA_REDIS.HSet(ctx, key, id, bd).Err()
+		if err != nil {
+			global.GVA_LOG.Error("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+			return
+		}
+	}
+}
+
+// 同步群控任务数据到缓存
+func (s *ServiceStatisticsLog) TaskStatisticsDataCache1() {
+	ctx := context.Background()
+	key := fmt.Sprintf(taskStatistics, s.LogicalLog.CurrentDate())
+	data, err := s.LogicalLog.RequestJfRoom()
+	if err != nil {
+		global.GVA_LOG.Error("获取机房数据失败TaskStatisticsDataCache", zap.Error(err))
+		return
+	}
+	dataTask, err := s.LogicalLog.RequestTaskData()
+	if err != nil {
+		global.GVA_LOG.Error("RequestTaskData", zap.Error(err))
+		return
+	}
+	var taskData []request.TaskData
+	var taskStatistics []request.TaskStatistics
+	_ = json.Unmarshal(data, &taskStatistics)
+	_ = json.Unmarshal(dataTask, &taskData)
+	mps := map[int]request.TaskData{}
+	for _, td := range taskData {
+		mps[td.GameId] = td
+	}
+	for _, data := range taskStatistics {
+		var id int
+		if data.GameIdXmy != "" {
+			if data.GameIdXmy == "0" {
+				id = data.GameId
+			} else {
+				id, _ = strconv.Atoi(data.GameIdXmy)
+			}
+		} else {
+			id = data.GameId
+		}
+		if _, ok := mps[id]; ok {
+			data.NewScanningCode = mps[id].NewScanningCode
+			data.RetainedPullAccount = mps[id].RetainedPullAccount
+			data.NewPullAccount = mps[id].NewPullAccount
+			data.FeeAccountNum = mps[id].FeeAccountNum
+			data.RetainedAccountNum = mps[id].RetainedAccountNum
+		}
+		bd, _ := json.Marshal(data)
+		err = global.GVA_REDIS.HSet(ctx, key, id, bd).Err()
+		if err != nil {
+			global.GVA_LOG.Error("添加缓存数据失败TaskStatisticsDataCache", zap.Error(err))
+			return
+		}
+	}
+}
+
+// 同步群控任务数据到缓存
+func (s *ServiceStatisticsLog) GetComputerNum() int {
+	ctx := context.Background()
+	computerNumKey := fmt.Sprintf(ComputerNum, s.CurrentDate())
+	num, err := global.GVA_REDIS.Get(ctx, computerNumKey).Int()
+	if err != nil {
+		num = 0
+	}
+	return num
+}

+ 7 - 3
service/log/loging/enter_main_log.go

@@ -35,6 +35,10 @@ func (s *EnterMainLog) SuccessLog(ctx context.Context, request request.AddLogReq
 		return
 	}
 	err = s.logical.NodeLogSetNum(ctx, s.logical.CurrentDate(), s.logical.Request.GameId, code, OkStatus, s.logical.Request.TaskType)
+	if err != nil {
+		return
+	}
+	err = s.logical.SetComputerTaskSuccessNumCache(ctx, s.logical.CurrentDate(), s.logical.Request.PcCode, s.logical.Request.GameId)
 	return
 }
 
@@ -56,15 +60,15 @@ func (s *EnterMainLog) FailLog(ctx context.Context, request request.AddLogReques
 	} else {
 		_ = s.logical.SetUuidCodeCache(context.Background(), s.logical.CurrentDate(), s.logical.Request.LogUuid, s.logical.Request.Coding, s.logical.Request.GameId)
 	}
+	// 中控数据不统计
 	if s.logical.ScriptType == 1 {
 		return
 	}
 	if code[5:] == "00" {
 		err = s.logical.CodeLogSetNum(ctx, s.logical.CurrentDate(), s.logical.Request.GameId, strconv.Itoa(request.Coding), NoLogStatus, s.logical.Request.TaskType)
-		if err != nil {
-			return
+		if code[3:] == "1000" {
+			err = s.logical.SetComputerEnterMainNumCache(ctx, s.logical.CurrentDate(), s.logical.Request.PcCode, s.logical.Request.GameId)
 		}
-		err = s.logical.SetComputerTaskSuccessNumCache(ctx, s.logical.CurrentDate(), s.logical.Request.PcCode, s.logical.Request.GameId)
 		return
 	}
 	err = s.logical.PartTypeLogSetNum(ctx, s.logical.CurrentDate(), s.logical.Request.GameId, code, FailStatus, s.logical.Request.TaskType)

+ 2 - 0
service/log/loging/fee_log.go

@@ -33,6 +33,8 @@ func (s *FeeLog) SuccessLog(ctx context.Context, request request.AddLogRequest)
 		return
 	}
 	err = s.logical.NodeLogSetNum(ctx, s.logical.CurrentDate(), s.logical.Request.GameId, code, OkStatus, s.logical.Request.TaskType)
+	s.logical.StatisticsPcFeeRateData(ctx, s.logical.Request.PcCode, s.logical.Request.LogUuid, s.logical.Request.GameId)
+	s.logical.StatisticsFeeRateData(ctx, s.logical.Request.GameId, s.logical.Request.LogUuid)
 	return
 }
 

+ 133 - 0
service/log/loging/logical_log.go

@@ -10,6 +10,7 @@ import (
 	"log-server/model/log"
 	"log-server/model/log/request"
 	"log-server/service/cache"
+	"log-server/utils"
 	"strconv"
 	"strings"
 	"time"
@@ -25,7 +26,12 @@ var (
 	logUuidAccountGameId        = "%s:logUuid:account:gameId"
 	ComputerCacheKey            = "%s:computer:list"
 	ComputerPullAccountCacheKey = "%s:computer:%s:pullAccount:"
+	ComputerEnterMainCacheKey   = "%s:computer:%s:enterMain:"
 	ComputerTaskSuccessCacheKey = "%s:computer:%s:taskSuccess:"
+	GameFeeRateCacheKey         = "%s:game:gameFeeRate:%d"
+	GameComputerRateCacheKey    = "%s:Computer:Rate:%s:"
+	GamePcFeeRateCacheKey       = "%s:gamePc:gameFeeRate:%d:%s"
+	PcGameFeeRateCacheKey       = "%s:PcGame:FeeRate:%s"
 )
 
 type LogicalLog struct {
@@ -67,6 +73,7 @@ func (s *LogicalLog) DataAdd() (err error) {
 	}
 	if logInfo.PcCode != "" {
 		err = s.SetComputerCache(context.Background(), s.CurrentDate(), logInfo.PcCode, logInfo.Operator)
+		_ = s.StatisticsComputerRateData(context.Background(), logInfo.PcCode, logInfo.GameId)
 	}
 	return
 }
@@ -514,6 +521,23 @@ func (s *LogicalLog) GetComputerPullAccountNumCache(ctx context.Context, date st
 	return
 }
 
+// 统计电脑进入主线的数量
+func (s *LogicalLog) SetComputerEnterMainNumCache(ctx context.Context, date string, pcCode string, gameId int) (err error) {
+	key := fmt.Sprintf(ComputerEnterMainCacheKey, date, pcCode) + strconv.Itoa(gameId)
+	err = s.cache.SetCacheNum(ctx, key)
+	return err
+}
+
+// 获取统计电脑进入主线的数量
+func (s *LogicalLog) GetComputerEnterMainNumCache(ctx context.Context, date string, pcCode string) (mps map[string]int, err error) {
+	key := fmt.Sprintf(ComputerEnterMainCacheKey, date, pcCode)
+	mps, err = s.GetByPcCodeGameNumCache(ctx, key)
+	if len(mps) == 0 {
+		return
+	}
+	return
+}
+
 // 统计电脑任务成功的数量
 func (s *LogicalLog) SetComputerTaskSuccessNumCache(ctx context.Context, date string, pcCode string, gameId int) (err error) {
 	key := fmt.Sprintf(ComputerTaskSuccessCacheKey, date, pcCode) + strconv.Itoa(gameId)
@@ -546,3 +570,112 @@ func (s *LogicalLog) GetByPcCodeGameNumCache(ctx context.Context, key string) (m
 	}
 	return
 }
+
+// 统计游戏付费效率的预埋数据
+func (s *LogicalLog) StatisticsFeeRateData(ctx context.Context, gameId int, logUuid string) {
+	key := fmt.Sprintf(GameFeeRateCacheKey, s.CurrentDate(), gameId)
+	z := &redis.Z{
+		Member: logUuid,
+		Score:  float64(time.Now().UnixNano() / 1e6),
+	}
+	global.GVA_REDIS.ZAdd(ctx, key, z)
+}
+
+// 获取统计游戏付费效率的数量
+func (s *LogicalLog) GetStatisticsFeeRate(ctx context.Context, gameId int) (num int) {
+	key := fmt.Sprintf(GameFeeRateCacheKey, s.CurrentDate(), gameId)
+	z, err := global.GVA_REDIS.ZRangeWithScores(ctx, key, -1, -1).Result()
+	if err != nil {
+		return
+	}
+	if len(z) == 0 {
+		return
+	}
+	end := z[0].Score
+	start := z[0].Score - 30*60*1000
+	op := redis.ZRangeBy{
+		Min: strconv.Itoa(int(start)),
+		Max: strconv.Itoa(int(end)),
+	}
+	i, err := global.GVA_REDIS.ZRangeByScore(ctx, key, &op).Result()
+	if err != nil {
+		return
+	}
+	num = len(i)
+	return
+}
+
+// 获取统计单台电脑单个游戏付费效率的预埋数据
+func (s *LogicalLog) GetStatisticsPcFeeRate(ctx context.Context, pcCode string, gameId int) (num int) {
+	key := fmt.Sprintf(GamePcFeeRateCacheKey, s.CurrentDate(), gameId, pcCode)
+	z, err := global.GVA_REDIS.ZRangeWithScores(ctx, key, -1, -1).Result()
+	if err != nil {
+		return
+	}
+	if len(z) == 0 {
+		return
+	}
+	end := z[0].Score
+	start := z[0].Score - 30*60*1000
+	op := redis.ZRangeBy{
+		Min: strconv.Itoa(int(start)),
+		Max: strconv.Itoa(int(end)),
+	}
+	i, err := global.GVA_REDIS.ZRangeByScore(ctx, key, &op).Result()
+	if err != nil {
+		return
+	}
+	num = len(i)
+	return
+}
+
+// 统计单台电脑单个游戏付费效率的预埋数据
+func (s *LogicalLog) StatisticsPcFeeRateData(ctx context.Context, pcCode string, logUuid string, gameId int) {
+	key := fmt.Sprintf(GamePcFeeRateCacheKey, s.CurrentDate(), gameId, pcCode)
+	z := &redis.Z{
+		Member: logUuid,
+		Score:  float64(time.Now().UnixNano() / 1e6),
+	}
+	global.GVA_REDIS.ZAdd(ctx, key, z)
+}
+
+// 统计电脑效率的预埋数据
+func (s *LogicalLog) StatisticsComputerRateData(ctx context.Context, pcCode string, gameId int) (err error) {
+	hour := time.Now().Hour()
+	key := fmt.Sprintf(GameComputerRateCacheKey, s.CurrentDate(), pcCode)
+	key = key + strconv.Itoa(hour)
+	err = s.cache.SetCacheStr(ctx, key, gameId)
+	return
+}
+
+// 统计电脑效率的预埋数据
+func (s *LogicalLog) GetStatisticsComputerRate(ctx context.Context, pcCode string) (num int) {
+	key := fmt.Sprintf(GameComputerRateCacheKey, s.CurrentDate(), pcCode)
+	key = key + "*"
+	data, _ := s.cache.GetCacheKeys(ctx, key)
+	hour := time.Now().Hour()
+	num = hour + 1 - len(data)
+	return
+}
+
+// 请求机房任务数据
+func (s *LogicalLog) RequestJfRoom() (result []byte, err error) {
+	today := time.Now().Format("2006-01-02")
+	jfurl := "http://xjf.lianyou.fun:8099/v1/task_statistics"
+	jfparams := map[string]string{
+		"query": "date:" + today + ",type:machine",
+	}
+	result, err = utils.HttpGet(jfurl, jfparams)
+	return
+}
+
+// 请求机房数据接口数据
+func (s *LogicalLog) RequestTaskData() (result []byte, err error) {
+	today := time.Now().Format("2006-01-02")
+	jfurl := "http://xjf.lianyou.fun:8118/data/taskDateLog"
+	jfparams := map[string]string{
+		"date": today,
+	}
+	result, err = utils.HttpGet(jfurl, jfparams)
+	return
+}