From a3d4a917d05836955a027aa5554dcd9872904174 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 9 Jan 2023 10:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B4=E5=BA=A6=E6=95=B0=E6=8D=AE=E4=B8=AD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=AA=E4=BA=BA=E5=90=8D=E6=AC=A1=E6=9C=80?= =?UTF-8?q?=E5=A5=BD=E7=9A=84=E5=91=A8=E5=BA=A6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_analysis_for_activity.go | 2 ++ models/user_business_analysis.go | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/models/user_analysis_for_activity.go b/models/user_analysis_for_activity.go index 39f8c545d..6d8201e69 100644 --- a/models/user_analysis_for_activity.go +++ b/models/user_analysis_for_activity.go @@ -470,6 +470,8 @@ func QueryUserAnnualReport(userId int64) *UserSummaryCurrentYear { bonusInfo := make(map[string]int) bonusInfo["order"] = record[0] bonusInfo["money"] = record[1] + bonusInfo["week"] = record[2] + bonusInfo["num"] = record[3] bonusInfoJson, _ := json.Marshal(bonusInfo) reList[0].WeekBonusData = string(bonusInfoJson) } diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 9f81f1c27..c18e1f51a 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -900,20 +900,27 @@ func getBonusWeekDataMap() map[int64][]int { userId := getInt64Value(aLine[0]) order := getIntValue(aLine[2]) money := getIntValue(aLine[3]) + week, num := getWeekAndNum(filenames[i]) //email := lines[2] record, ok := bonusMap[userId] if !ok { - record = make([]int, 2) + record = make([]int, 4) record[0] = order record[1] = money + record[2] = week + record[3] = num bonusMap[userId] = record } else { if record[0] > order { record[0] = order record[1] = money + record[2] = week + record[3] = num } else { if record[0] == order && record[1] < money { record[1] = money + record[2] = week + record[3] = num } } } @@ -924,6 +931,17 @@ func getBonusWeekDataMap() map[int64][]int { return bonusMap } +func getWeekAndNum(name string) (int, int) { + name = name[0 : len(name)-4] + tmp := strings.Split(name, "_") + if len(tmp) == 2 { + week := getIntValue(tmp[0]) + num := getIntValue(tmp[1]) + return week, num + } + return 0, 0 +} + func getBonusMap() map[string]map[string]int { bonusMap := make(map[string]map[string]int) url := setting.RecommentRepoAddr + "bonus/record.txt"