|
@@ -1213,7 +1213,7 @@ func GetLikeKeyword(keyword string) string {
|
|
|
return `%` + keyword + `%`
|
|
|
}
|
|
|
|
|
|
-func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYear, yearMax int) (startDate, endDate string) {
|
|
|
+func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYear int, latestDate time.Time) (startDate, endDate string) {
|
|
|
startDate = tmpStartDate
|
|
|
endDate = tmpEndDate
|
|
|
switch dateType {
|
|
@@ -1248,16 +1248,46 @@ func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYea
|
|
|
case 11:
|
|
|
startDate = "2022-01-01"
|
|
|
endDate = ""
|
|
|
+ case 12:
|
|
|
+ startDate = "2023-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 13:
|
|
|
+ startDate = "2024-01-01"
|
|
|
+ endDate = ""
|
|
|
case DateTypeNYears:
|
|
|
if startYear == 0 { //默认取最近5年
|
|
|
startYear = 5
|
|
|
}
|
|
|
- if yearMax == 0 {
|
|
|
+ if latestDate.IsZero() {
|
|
|
return
|
|
|
}
|
|
|
- startYear = startYear - 1
|
|
|
- baseDate, _ := time.Parse(FormatDate, fmt.Sprintf("%d-01-01", yearMax))
|
|
|
- startDate = baseDate.AddDate(-startYear, 0, 0).Format(FormatDate)
|
|
|
+ startDate = latestDate.AddDate(-startYear, 0, 0).Format(FormatDate)
|
|
|
+ endDate = ""
|
|
|
+ case DateTypeOneWeek:
|
|
|
+ //if startDate != "" {
|
|
|
+ // st, e := time.ParseInLocation(FormatDate, startDate, time.Local)
|
|
|
+ // if e != nil {
|
|
|
+ // FileLog.Info(fmt.Sprintf("日期格式解析失败, %s, %v", startDate, e))
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // startDate = st.AddDate(0, 0, -7).Format(FormatDate)
|
|
|
+ //}
|
|
|
+ startDate = time.Now().AddDate(0, 0, -7).Format(FormatDate)
|
|
|
+ endDate = ""
|
|
|
+ case DateTypeOneMonth:
|
|
|
+ startDate = time.Now().AddDate(0, -1, 0).Format(FormatDate)
|
|
|
+ endDate = ""
|
|
|
+ case DateTypeTwoMonth:
|
|
|
+ startDate = time.Now().AddDate(0, -2, 0).Format(FormatDate)
|
|
|
+ endDate = ""
|
|
|
+ case DateTypeThreeMonth:
|
|
|
+ startDate = time.Now().AddDate(0, -3, 0).Format(FormatDate)
|
|
|
+ endDate = ""
|
|
|
+ case DateTypeNMonth:
|
|
|
+ if startYear == 0 {
|
|
|
+ startYear = 6
|
|
|
+ }
|
|
|
+ startDate = time.Now().AddDate(0, -startYear, 0).Format(FormatDate)
|
|
|
endDate = ""
|
|
|
}
|
|
|
|
|
@@ -1267,7 +1297,11 @@ func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYea
|
|
|
startDate = startDate + "-01"
|
|
|
}
|
|
|
if strings.Count(endDate, "-") == 1 {
|
|
|
- endDate = endDate + "-01"
|
|
|
+ endTime, err := time.Parse(FormatYearMonthDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endDate = endTime.AddDate(0, 1, -1).Format(FormatDate)
|
|
|
}
|
|
|
}
|
|
|
|