|
|
@@ -92,7 +92,8 @@ func (s *LogicalLog) NoLogStatusDataAdd(ctx context.Context) (err error) {
|
|
|
}
|
|
|
|
|
|
func (s *LogicalLog) getLogByUuid(uuid string) (log log.Loging, err error) {
|
|
|
- db := global.GVA_DB.Table("loging")
|
|
|
+ createDate := time.Now().Format("2006-01")
|
|
|
+ db := global.GVA_DB.Table("loging_" + createDate)
|
|
|
db = db.Where("log_uuid = ?", uuid)
|
|
|
db = db.Where("coding = 4101099 or coding = 4103099")
|
|
|
db.First(&log)
|
|
|
@@ -100,7 +101,8 @@ func (s *LogicalLog) getLogByUuid(uuid string) (log log.Loging, err error) {
|
|
|
}
|
|
|
|
|
|
func (s *LogicalLog) GetLogByUuidCoding(uuid string, coding int, scriptType int) (log log.Loging, err error) {
|
|
|
- db := global.GVA_DB.Table("loging")
|
|
|
+ createDate := time.Now().Format("2006-01")
|
|
|
+ db := global.GVA_DB.Table("loging_" + createDate)
|
|
|
db = db.Where("log_uuid = ?", uuid)
|
|
|
db = db.Where("coding = ?", coding)
|
|
|
db = db.Where("script_type = ?", scriptType)
|
|
|
@@ -173,6 +175,13 @@ func (s *LogicalLog) codeData() (nodeCode, typeCode int, err error) {
|
|
|
}
|
|
|
|
|
|
func (s *LogicalLog) LogAdd(l *log.Loging) error {
|
|
|
+ createDate := l.CreateDate
|
|
|
+ splitTime := strings.Split(createDate, "-")
|
|
|
+ date := splitTime[0] + "-" + splitTime[1]
|
|
|
+ if date != "2022-11" {
|
|
|
+ table := "loging_" + splitTime[0] + "-" + splitTime[1]
|
|
|
+ return global.GVA_DB.Table(table).Create(&l).Error
|
|
|
+ }
|
|
|
return global.GVA_DB.Create(&l).Error
|
|
|
}
|
|
|
|
|
|
@@ -751,3 +760,54 @@ func (s *LogicalLog) SetPcReportingLog(ctx context.Context, pcCode string, opera
|
|
|
}
|
|
|
global.GVA_REDIS.ZAdd(ctx, key, z)
|
|
|
}
|
|
|
+
|
|
|
+// 删除hash缓存数据
|
|
|
+func (s *LogicalLog) DelHashKey(ctx context.Context, date string) {
|
|
|
+ gameKeys := fmt.Sprintf(GameCacheKey, date)
|
|
|
+ data, _ := global.GVA_REDIS.HKeys(ctx, gameKeys).Result()
|
|
|
+ global.GVA_REDIS.HDel(ctx, gameKeys, data...)
|
|
|
+ logUuidAccountGameId := fmt.Sprintf(logUuidAccountGameId, date)
|
|
|
+ logUuid, _ := global.GVA_REDIS.HKeys(ctx, logUuidAccountGameId).Result()
|
|
|
+ global.GVA_REDIS.HDel(ctx, logUuidAccountGameId, logUuid...)
|
|
|
+ taskStatisticsKey := fmt.Sprintf("%s:taskStatistics", date)
|
|
|
+ taskStatistics, _ := global.GVA_REDIS.HKeys(ctx, taskStatisticsKey).Result()
|
|
|
+ global.GVA_REDIS.HDel(ctx, taskStatisticsKey, taskStatistics...)
|
|
|
+ computerListKey := fmt.Sprintf(ComputerCacheKey, date)
|
|
|
+ computerListKeys, _ := global.GVA_REDIS.HKeys(ctx, computerListKey).Result()
|
|
|
+ global.GVA_REDIS.HDel(ctx, computerListKey, computerListKeys...)
|
|
|
+}
|
|
|
+
|
|
|
+// 删除ZSet缓存数据
|
|
|
+func (s *LogicalLog) DelZSetKey(ctx context.Context, date string) {
|
|
|
+ gamePcKey := fmt.Sprintf("%s:gamePc:gameFeeRate*", date)
|
|
|
+ gameKey := fmt.Sprintf("%s:game:gameFeeRate*", date)
|
|
|
+ pcReportingKey := fmt.Sprintf("%s:pc:Reporting:*", date)
|
|
|
+ beginTime, _ := time.ParseInLocation("2006-01-02", date, time.Local)
|
|
|
+ beginTimeI := strconv.Itoa(int(beginTime.Unix() * 1000))
|
|
|
+ endTime := strconv.Itoa(int(beginTime.Unix()*1000 + 24*60*60*1000))
|
|
|
+ gamePcKeys, _ := global.GVA_REDIS.Keys(ctx, gamePcKey).Result()
|
|
|
+ gameKeys, _ := global.GVA_REDIS.Keys(ctx, gameKey).Result()
|
|
|
+ pcReportingKeys, _ := global.GVA_REDIS.Keys(ctx, pcReportingKey).Result()
|
|
|
+ for _, k := range gamePcKeys {
|
|
|
+ global.GVA_REDIS.ZRemRangeByScore(ctx, k, beginTimeI, endTime)
|
|
|
+ }
|
|
|
+ for _, k := range gameKeys {
|
|
|
+ global.GVA_REDIS.ZRemRangeByScore(ctx, k, beginTimeI, endTime)
|
|
|
+ }
|
|
|
+ for _, k := range pcReportingKeys {
|
|
|
+ global.GVA_REDIS.ZRemRangeByScore(ctx, k, beginTimeI, endTime)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 删除hashUuid缓存数据
|
|
|
+func (s *LogicalLog) DelHashUuidKey(ctx context.Context, date string) {
|
|
|
+ gameIds, _ := s.GetGameCache(ctx, date)
|
|
|
+ for id, _ := range gameIds {
|
|
|
+ gamekeys := fmt.Sprintf("%s:logUuid:%s:*", date, id)
|
|
|
+ data, _ := global.GVA_REDIS.Keys(ctx, gamekeys).Result()
|
|
|
+ for _, hkey := range data {
|
|
|
+ value, _ := global.GVA_REDIS.HKeys(ctx, hkey).Result()
|
|
|
+ global.GVA_REDIS.HDel(ctx, hkey, value...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|