|
@@ -188,6 +188,46 @@ func GetPotentialUserCountByConditon(condition string, pars []interface{}) (coun
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func GetPotentialUserCountByConditonV2(condition string, pars []interface{}) (count int, err error) {
|
|
|
|
+ sql := `SELECT COUNT(u.user_id) AS count
|
|
|
|
+ FROM user AS u
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ SELECT user_id, MAX(create_time) AS create_time
|
|
|
|
+ FROM user_read_record
|
|
|
|
+ GROUP BY user_id
|
|
|
|
+ ) AS ur
|
|
|
|
+ ON u.user_id = ur.user_id
|
|
|
|
+ WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
|
|
|
|
+ if condition != "" {
|
|
|
|
+ sql += condition
|
|
|
|
+ }
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
+ err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetPotentialUserIdsByConditonV2(condition string, pars []interface{}, sortConditon string, startSize, pageSize int) (items []*UserView, err error) {
|
|
|
|
+ sql := `SELECT DISTINCT u.*, ur.read_cnt, ur.create_time AS last_update_time
|
|
|
|
+ FROM user AS u
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ SELECT user_id, MAX(create_time) AS create_time, COUNT(user_id) AS read_cnt
|
|
|
|
+ FROM user_read_record
|
|
|
|
+ GROUP BY user_id
|
|
|
|
+ ) AS ur
|
|
|
|
+ ON u.user_id = ur.user_id
|
|
|
|
+ WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
|
|
|
|
+ if condition != "" {
|
|
|
|
+ sql += condition
|
|
|
|
+ }
|
|
|
|
+ if sortConditon != "" {
|
|
|
|
+ sql += sortConditon
|
|
|
|
+ }
|
|
|
|
+ sql += ` LIMIT ?,? `
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
+ _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func GetPotentialUserIdsByConditon(condition string, pars []interface{}) (userIds []string, err error) {
|
|
func GetPotentialUserIdsByConditon(condition string, pars []interface{}) (userIds []string, err error) {
|
|
sql := `SELECT DISTINCT u.user_id AS user_id
|
|
sql := `SELECT DISTINCT u.user_id AS user_id
|
|
FROM user AS u
|
|
FROM user AS u
|