Ver Fonte

推送历史搜索支持省份和城市

wangkaiyue há 4 anos atrás
pai
commit
3c4a8ad5ff
1 ficheiros alterados com 27 adições e 8 exclusões
  1. 27 8
      src/jfw/modules/common/src/qfw/util/jy/memberpush.go

+ 27 - 8
src/jfw/modules/common/src/qfw/util/jy/memberpush.go

@@ -104,7 +104,7 @@ func (m *memberPush) Datas(Mgo_bidding mg.MongodbSim, bidding, bidding_back stri
 	return
 }
 func (m *memberPush) getDatasFromMysql(Mgo_bidding mg.MongodbSim, bidding, bidding_back string, PushMysql *mysql.Mysql, userId string, pageNum, myPageSize int, selectTime, area string, isLimit bool, startTime, endTime string) (result []*SubPushList, count int64) {
-	findSQL := `%s where userid="` + userId + `"`
+	findSQL := ` %s where userid="` + userId + `" `
 	findStr := ""
 	if selectTime != "" {
 		startTime := selectTime + " 00:00:00"
@@ -120,22 +120,41 @@ func (m *memberPush) getDatasFromMysql(Mgo_bidding mg.MongodbSim, bidding, biddi
 		findStr += " and date < " + fmt.Sprint(et.Unix()) + " and date >= " + fmt.Sprint(st.Unix())
 	}
 	if area != "" {
-		findStr += " and city in ("
-		var _area = ""
+		var _area, _city = "", ""
 		for _, v := range strings.Split(area, ",") {
 			if v == "全部" {
 				continue
 			}
-			if _area != "" {
-				_area += ","
+			//省份
+			if province, ok := PushMapping.Area[v]; ok {
+				if _area != "" {
+					_area += ","
+				}
+				_area += fmt.Sprint(province)
 			}
-			_area += fmt.Sprint(PushMapping.City[v])
+			//城市
+			if city, ok := PushMapping.City[v]; ok {
+				if _city != "" {
+					_city += ","
+				}
+				_city += fmt.Sprint(city)
+			}
+		}
+
+		if _area != "" && _city != "" {
+			findStr += fmt.Sprintf(" and ( area in ( %s ) or city in ( %s ) )", _area, _city)
+		} else if _area != "" && _city == "" { //仅查询省份
+			findStr += fmt.Sprintf(" and area in ( %s ) ", _area)
+		} else if _area == "" && _city != "" { //仅查询城市
+			findStr += fmt.Sprintf(" and  city in ( %s ) ", _city)
 		}
-		findStr += _area + ")"
 	}
 	start := (pageNum - 1) * myPageSize
+	count = PushMysql.CountBySql(fmt.Sprintf(findSQL+findStr, "select count(id) from pushmember"))
+
+	log.Println("count:", count, " sql:", fmt.Sprintf(findSQL+findStr, "select count(id) from pushmember"))
+
 	findStr += " order by id desc"
-	count = PushMysql.CountBySql(fmt.Sprintf(findSQL, "select count(id) from pushmember"))
 	if isLimit {
 		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
 	}