refactor(用户查询): 将用户标签查询从tagName改为tagId并优化SQL查询
修改SearchAb98UserWithWxQuery中的tagName字段为tagId以支持更精确的标签查询 重构Ab98UserMapper中的SQL查询,使用membership_tag_member表替代ab98_user_tag表
This commit is contained in:
parent
443824093f
commit
b0f11999de
|
|
@ -61,14 +61,15 @@ public interface Ab98UserMapper extends BaseMapper<Ab98UserEntity> {
|
|||
);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
"SELECT DISTINCT u.ab98_user_id, u.openid, u.userid, u.qy_user_id, u.name, u.tel, u.idnum, u.sex, u.face_img, u.idcard_front, u.idcard_back, u.address, u.registered, u.creator_id, u.create_time, u.updater_id, u.update_time, u.deleted, u.ab98_balance, ub.balance, ub.use_balance, ub.balance_limit, w.wx_user_id, w.openid as wx_user_openid, w.nick_name as wx_nick_name, w.avatar as wx_avatar " +
|
||||
"SELECT DISTINCT u.ab98_user_id, u.openid, u.userid, u.qy_user_id, u.name, u.tel, u.idnum, u.sex, u.face_img, u.idcard_front, u.idcard_back, u.address, u.registered, u.creator_id, u.create_time, u.updater_id, u.update_time, u.deleted, u.ab98_balance, ub.balance, ub.use_balance, ub.balance_limit, w.wx_user_id, w.openid as wx_user_openid, w.nick_name as wx_nick_name, w.avatar as wx_avatar, mtm.tag_id " +
|
||||
"FROM ab98_user u " +
|
||||
"LEFT JOIN ab98_user_tag t ON u.ab98_user_id = t.ab98_user_id " +
|
||||
"LEFT JOIN membership_tag_member mtm ON u.ab98_user_id = mtm.ab98_user_id " +
|
||||
"LEFT JOIN user_balance ub ON u.ab98_user_id = ub.ab98_user_id " +
|
||||
"LEFT JOIN wx_user w ON u.ab98_user_id = w.ab98_user_id " +
|
||||
" UNION ALL " +
|
||||
"SELECT NULL as ab98_user_id, NULL as openid, NULL as userid, NULL as qy_user_id, NULL as name, NULL as tel, NULL as idnum, NULL as sex, NULL as face_img, NULL as idcard_front, NULL as idcard_back, NULL as address, NULL as registered, NULL as creator_id, w.create_time as create_time, NULL as updater_id, w.update_time as update_time, NULL as deleted, NULL as ab98_balance, NULL as balance, NULL as use_balance, NULL as balance_limit, w.wx_user_id, w.openid as wx_user_openid, w.nick_name as wx_nick_name, w.avatar as wx_avatar " +
|
||||
"SELECT NULL as ab98_user_id, NULL as openid, NULL as userid, NULL as qy_user_id, NULL as name, NULL as tel, NULL as idnum, NULL as sex, NULL as face_img, NULL as idcard_front, NULL as idcard_back, NULL as address, NULL as registered, NULL as creator_id, w.create_time as create_time, NULL as updater_id, w.update_time as update_time, NULL as deleted, NULL as ab98_balance, NULL as balance, NULL as use_balance, NULL as balance_limit, w.wx_user_id, w.openid as wx_user_openid, w.nick_name as wx_nick_name, w.avatar as wx_avatar, mtm.tag_id " +
|
||||
"FROM wx_user w " +
|
||||
"LEFT JOIN membership_tag_member mtm ON w.wx_user_id = mtm.wx_user_id " +
|
||||
"WHERE w.ab98_user_id IS NULL" +
|
||||
") t ${ew.customSqlSegment} ORDER BY create_time DESC")
|
||||
Page<Ab98UserEntity> getUserListWithWx(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class SearchAb98UserWithWxQuery<T> extends AbstractPageQuery<T> {
|
|||
private Boolean registered;
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
private String tagName;
|
||||
private Long tagId;
|
||||
private String corpid;
|
||||
private String wxUserOpenid;
|
||||
private Boolean hasAb98UserId;
|
||||
|
|
@ -40,6 +40,7 @@ public class SearchAb98UserWithWxQuery<T> extends AbstractPageQuery<T> {
|
|||
.eq(StrUtil.isNotEmpty(sex), "sex", sex)
|
||||
.eq(registered != null, "registered", registered)
|
||||
.eq(StrUtil.isNotEmpty(wxUserOpenid), "wx_user_openid", wxUserOpenid)
|
||||
.eq(tagId != null, "tag_id", tagId)
|
||||
.between(startTime != null && endTime != null, "create_time", startTime, endTime);
|
||||
|
||||
// 添加是否绑定ab98UserId的条件
|
||||
|
|
|
|||
Loading…
Reference in New Issue