|
|
@@ -305,6 +305,165 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
ORDER BY u.user_id DESC
|
|
|
</select>
|
|
|
|
|
|
+ <select id="selectListNoTenant" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
|
|
|
+ SELECT DISTINCT
|
|
|
+ u.*,
|
|
|
+ (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx
|
|
|
+ <if test="getOrderNum != null and getOrderNum == 1" >
|
|
|
+ ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
|
|
|
+ </if>
|
|
|
+ FROM
|
|
|
+ `user` u
|
|
|
+
|
|
|
+ <if test="getOrderNum != null and getOrderNum == 1" >
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
|
|
|
+ sum( CASE WHEN g.goods_type = 2 THEN 1 ELSE 0 END ) AS goods_bank_num,
|
|
|
+ sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num,
|
|
|
+ o.user_id
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN order_goods og ON o.order_sn = og.order_sn
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ WHERE o.`status` = 1
|
|
|
+ AND og.refund_status in (0,1,3)
|
|
|
+ AND og.pay_status in (2,3,4)
|
|
|
+ GROUP BY
|
|
|
+ o.user_id
|
|
|
+ ) ou ON u.user_id = ou.user_id
|
|
|
+ </if>
|
|
|
+ <if test="businessId != null and businessId != ''">
|
|
|
+ LEFT JOIN `order` o ON u.user_id = o.user_id and o.`status` = 1
|
|
|
+ LEFT JOIN order_goods og ON o.order_sn = og.order_sn and og.`status` = 1
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ </if>
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ <if test="status != null and status.size()!=0 ">
|
|
|
+ AND u.status in
|
|
|
+ <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="businessId != null and businessId != ''">
|
|
|
+ and og.`status` = 1
|
|
|
+ and og.refund_status in (0,1,3)
|
|
|
+ and og.pay_status in (2,3,4)
|
|
|
+ AND g.business_id = #{businessId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND u.create_time > #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND u.create_time < #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="userKerWord != null and userKerWord != ''" >
|
|
|
+ AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
|
|
|
+ </if>
|
|
|
+ <if test="nickname != null and nickname != ''" >
|
|
|
+ AND u.nickname like concat('%', #{nickname}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="telphone != null and telphone != ''" >
|
|
|
+ AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="idCard != null and idCard != ''" >
|
|
|
+ AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="realname != null and realname != ''" >
|
|
|
+ AND u.realname like concat('%', #{realname}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="companyName != null and companyName != ''" >
|
|
|
+ AND u.company_name like concat('%', #{companyName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId != ''" >
|
|
|
+ AND u.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="empty != null and empty != ''" >
|
|
|
+ and u.realname is NOT NULL
|
|
|
+ </if>
|
|
|
+ <if test="goodsSearchKey != null and goodsSearchKey != ''" >
|
|
|
+ and ( SELECT
|
|
|
+ count(og.*)
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN order_goods og on o.order_sn = og.order_sn
|
|
|
+ where 1=1
|
|
|
+ and og.`status` = 1
|
|
|
+ and og.refund_status in (0,1,3)
|
|
|
+ and og.pay_status in (2,3,4))
|
|
|
+ and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
|
|
|
+ and o.user_id = u.user_id)>0
|
|
|
+ </if>
|
|
|
+ <if test="goodsSearchKey != null and goodsSearchKey != ''" >
|
|
|
+ and ( SELECT
|
|
|
+ count(*)
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN order_goods og on o.order_sn = og.order_sn
|
|
|
+ LEFT JOIN goods g on og.goods_id = g.goods_id
|
|
|
+ where 1=1
|
|
|
+ and og.`status` = 1
|
|
|
+ and og.refund_status in (0,1,3)
|
|
|
+ and og.pay_status in (2,3,4)
|
|
|
+ and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
|
|
|
+ and o.user_id = u.user_id)>0
|
|
|
+ </if>
|
|
|
+ <if test="gradePoint != null and gradePoint == 1" >
|
|
|
+ AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) > 0
|
|
|
+ </if>
|
|
|
+ <if test="gradePoint != null and gradePoint == 2" >
|
|
|
+ AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) = 0
|
|
|
+ </if>
|
|
|
+ <if test="searchKey != null and searchKey != '' and searchType == 0 ">
|
|
|
+ and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
|
|
|
+ </if>
|
|
|
+ <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
|
|
|
+ AND u.id_card in
|
|
|
+ <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
|
|
|
+ #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="searchType == 1" >
|
|
|
+ and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
|
|
|
+ u.id_card in
|
|
|
+ <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
|
|
|
+ #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
|
|
|
+ </foreach>)
|
|
|
+ </if>
|
|
|
+ <if test="hasBindWx != null and hasBindWx == 1 ">
|
|
|
+ AND u.union_id is not null
|
|
|
+ </if>
|
|
|
+ <if test="hasBindWx != null and hasBindWx == 0 ">
|
|
|
+ AND u.union_id is null
|
|
|
+ </if>
|
|
|
+ <if test="visitStartTime != null and visitStartTime !=''">
|
|
|
+ and (SELECT
|
|
|
+ count(*)
|
|
|
+ FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >= create_time)>0
|
|
|
+ </if>
|
|
|
+ <if test="studyStartTime != null and studyStartTime !=''">
|
|
|
+ and (SELECT
|
|
|
+ count(*)
|
|
|
+ FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >= create_time)>0
|
|
|
+ </if>
|
|
|
+ <if test="gradeName != null and gradeName != ''">
|
|
|
+ and ( SELECT
|
|
|
+ count(*)
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN order_goods og on o.order_sn = og.order_sn
|
|
|
+ LEFT JOIN class_grade cg on cg.grade_id = og.grade_id
|
|
|
+ where 1=1
|
|
|
+ and og.`status` = 1
|
|
|
+ and og.refund_status in (0,1,3)
|
|
|
+ and og.pay_status in (2,3,4)
|
|
|
+ and (cg.class_name like concat('%', #{gradeName}, '%'))
|
|
|
+ and o.user_id = u.user_id)>0
|
|
|
+ </if>
|
|
|
+ ORDER BY u.user_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
<select id="selectStudyRecordList" resultMap="StudyRecordResult">
|
|
|
SELECT
|