package utils import ( "encoding/json" "gd_adm_data/consts" "time" ) func GetYearByVin10(vin10 string) int { nowYear := time.Now().Year() if v, ok := consts.YearMap[vin10]; ok { if v > nowYear { year := v - 30 if year < 2001 { return 0 } return year } else if v == nowYear { return nowYear } else { return getLastYear(v, nowYear) } } else { return nowYear } } func getLastYear(year, nowYear int) int { lastYear := year + 30 if lastYear > nowYear { return year } else if lastYear == nowYear { return nowYear } else { return getLastYear(lastYear, nowYear) } } func MarshalJsonString(args ...interface{}) (result string) { if len(args) > 0 { if r, err := json.Marshal(args); err == nil { result = string(r) } } return }