Преглед изворни кода

fix:更新潜在用户列表查询

zqbao пре 9 месеци
родитељ
комит
26bb859faf
1 измењених фајлова са 35 додато и 8 уклоњено
  1. 35 8
      controllers/user.go

+ 35 - 8
controllers/user.go

@@ -735,20 +735,47 @@ func (this *UserController) PotentialList() {
 	}
 
 	if registerStartDate != "" {
-		condition += " AND u.register_time>? "
-		pars = append(pars, registerStartDate)
+		registerStartTime, er := time.Parse(utils.FormatDate, registerStartDate)
+		if er != nil {
+			br.Msg = "日期格式有误"
+			return
+		}
+		condition += " AND u.register_time>=? "
+		registerStartDateStr := registerStartTime.Format(utils.FormatDateTime)
+		pars = append(pars, registerStartDateStr)
 	}
 	if registerEndDate != "" {
-		condition += " AND u.register_time<? "
-		pars = append(pars, registerEndDate)
+		registerEndTime, er := time.Parse(utils.FormatDate, registerEndDate)
+		if er != nil {
+			br.Msg = "日期格式有误"
+			return
+		}
+		condition += " AND u.register_time<=? "
+		// 结束时间包含今天
+		registerEndTime = registerEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
+		registerEndDateStr := registerEndTime.Format(utils.FormatDateTime)
+		pars = append(pars, registerEndDateStr)
 	}
 	if lastUpdateStartDate != "" {
-		condition += " AND ur.create_time>? "
-		pars = append(pars, lastUpdateStartDate)
+		lastUpdateStartTime, er := time.Parse(utils.FormatDate, lastUpdateStartDate)
+		if er != nil {
+			br.Msg = "日期格式有误"
+			return
+		}
+		condition += " AND ur.create_time>=? "
+
+		lastUpdateStartDateStr := lastUpdateStartTime.Format(utils.FormatDateTime)
+		pars = append(pars, lastUpdateStartDateStr)
 	}
 	if lastUpdateEndDate != "" {
-		condition += " AND ur.create_time<? "
-		pars = append(pars, lastUpdateEndDate)
+		lastUpdateEndTime, er := time.Parse(utils.FormatDate, lastUpdateEndDate)
+		if er != nil {
+			br.Msg = "日期格式有误"
+			return
+		}
+		lastUpdateEndDateStr := lastUpdateEndTime.Format(utils.FormatDateTime)
+		condition += " AND ur.create_time<=? "
+		pars = append(pars, lastUpdateEndDateStr)
 	}
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20