|
@@ -104,7 +104,7 @@ func (m *memberPush) Datas(Mgo_bidding mg.MongodbSim, bidding, bidding_back stri
|
|
return
|
|
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) {
|
|
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 := ""
|
|
findStr := ""
|
|
if selectTime != "" {
|
|
if selectTime != "" {
|
|
startTime := selectTime + " 00:00:00"
|
|
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())
|
|
findStr += " and date < " + fmt.Sprint(et.Unix()) + " and date >= " + fmt.Sprint(st.Unix())
|
|
}
|
|
}
|
|
if area != "" {
|
|
if area != "" {
|
|
- findStr += " and city in ("
|
|
|
|
- var _area = ""
|
|
|
|
|
|
+ var _area, _city = "", ""
|
|
for _, v := range strings.Split(area, ",") {
|
|
for _, v := range strings.Split(area, ",") {
|
|
if v == "全部" {
|
|
if v == "全部" {
|
|
continue
|
|
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
|
|
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"
|
|
findStr += " order by id desc"
|
|
- count = PushMysql.CountBySql(fmt.Sprintf(findSQL, "select count(id) from pushmember"))
|
|
|
|
if isLimit {
|
|
if isLimit {
|
|
findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
|
|
findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
|
|
}
|
|
}
|