| @@ -142,6 +142,22 @@ func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis | |||||
| return userBusinessAnalysisReturnList | return userBusinessAnalysisReturnList | ||||
| } | } | ||||
| func getLastCountDate() int64 { | |||||
| statictisSess := xStatistic.NewSession() | |||||
| defer statictisSess.Close() | |||||
| statictisSess.Limit(1, 0) | |||||
| userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) | |||||
| if err := statictisSess.Table("user_business_analysis").OrderBy("countdate desc").Limit(1, 0). | |||||
| Find(&userBusinessAnalysisList); err == nil { | |||||
| for _, userRecord := range userBusinessAnalysisList { | |||||
| return userRecord.CountDate - 10000 | |||||
| } | |||||
| } | |||||
| currentTimeNow := time.Now() | |||||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) | |||||
| return pageStartTime.Unix() | |||||
| } | |||||
| func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { | func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { | ||||
| log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) | log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) | ||||
| @@ -149,8 +165,8 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| defer statictisSess.Close() | defer statictisSess.Close() | ||||
| currentTimeNow := time.Now() | currentTimeNow := time.Now() | ||||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) | |||||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||||
| pageStartTime := getLastCountDate() | |||||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).Unix() | |||||
| var cond = builder.NewCond() | var cond = builder.NewCond() | ||||
| if len(opts.UserName) > 0 { | if len(opts.UserName) > 0 { | ||||
| @@ -159,10 +175,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| ) | ) | ||||
| } | } | ||||
| cond = cond.And( | cond = cond.And( | ||||
| builder.Gte{"count_date": pageStartTime.Unix()}, | |||||
| builder.Gte{"count_date": pageStartTime}, | |||||
| ) | ) | ||||
| cond = cond.And( | cond = cond.And( | ||||
| builder.Lte{"count_date": pageEndTime.Unix()}, | |||||
| builder.Lte{"count_date": pageEndTime}, | |||||
| ) | ) | ||||
| count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) | count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) | ||||