|
|
@@ -880,6 +880,50 @@ func isUserYearData(tableName string) bool { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
func getBonusWeekDataMap() map[int64][]int { |
|
|
|
bonusMap := make(map[int64][]int) |
|
|
|
url := setting.RecommentRepoAddr + "bonus/weekdata/record.txt" |
|
|
|
content, err := GetContentFromPromote(url) |
|
|
|
if err == nil { |
|
|
|
filenames := strings.Split(content, "\n") |
|
|
|
for i := 0; i < len(filenames); i++ { |
|
|
|
url = setting.RecommentRepoAddr + "bonus/weekdata/" + filenames[i] |
|
|
|
csvContent, err1 := GetContentFromPromote(url) |
|
|
|
if err1 == nil { |
|
|
|
//read csv |
|
|
|
lines := strings.Split(csvContent, "\n") |
|
|
|
for j := 1; j < len(lines); j++ { |
|
|
|
aLine := strings.Split(lines[j], ",") |
|
|
|
if len(aLine) < 4 { |
|
|
|
continue |
|
|
|
} |
|
|
|
userId := getInt64Value(aLine[0]) |
|
|
|
order := getIntValue(aLine[2]) |
|
|
|
money := getIntValue(aLine[3]) |
|
|
|
//email := lines[2] |
|
|
|
record, ok := bonusMap[userId] |
|
|
|
if !ok { |
|
|
|
record = make([]int, 2) |
|
|
|
record[0] = order |
|
|
|
record[1] = money |
|
|
|
bonusMap[userId] = record |
|
|
|
} else { |
|
|
|
if record[0] > order { |
|
|
|
record[0] = order |
|
|
|
record[1] = money |
|
|
|
} else { |
|
|
|
if record[0] == order && record[1] < money { |
|
|
|
record[1] = money |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return bonusMap |
|
|
|
} |
|
|
|
|
|
|
|
func getBonusMap() map[string]map[string]int { |
|
|
|
bonusMap := make(map[string]map[string]int) |
|
|
|
url := setting.RecommentRepoAddr + "bonus/record.txt" |
|
|
@@ -923,6 +967,14 @@ func getIntValue(val string) int { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
func getInt64Value(val string) int64 { |
|
|
|
i, err := strconv.ParseInt(val, 10, 64) |
|
|
|
if err == nil { |
|
|
|
return i |
|
|
|
} |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
func getPlayARoll(bonusMap map[string]map[string]int, userName string, scoreMap map[string]float64) string { |
|
|
|
bonusInfo := make(map[string]string) |
|
|
|
record, ok := bonusMap[userName] |
|
|
|