123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zhongzheng.modules.user.mapper.UserMapper">
- <resultMap type="com.zhongzheng.modules.user.domain.User" id="UserResult">
- <result property="userId" column="user_id"/>
- <result property="userAccount" column="user_account"/>
- <result property="nickname" column="nickname"/>
- <result property="realname" column="realname"/>
- <result property="sex" column="sex"/>
- <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="userLevel" column="user_level"/>
- <result property="userBirth" column="user_birth"/>
- <result property="eduLevel" column="edu_level"/>
- <result property="schoolId" column="school_id"/>
- <result property="major" column="major"/>
- <result property="entranceTime" column="entrance_time"/>
- <result property="openId" column="open_id"/>
- <result property="idCardImg1" column="id_card_img1"/>
- <result property="idCardImg2" column="id_card_img2"/>
- <result property="country" column="country"/>
- <result property="province" column="province"/>
- <result property="city" column="city"/>
- <result property="integral" column="integral"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="status" column="status"/>
- <result property="unionId" column="union_id"/>
- <result property="registerPlat" column="register_plat"/>
- <result property="lastLoginIp" column="last_login_ip"/>
- <result property="lastLoginTime" column="last_login_time"/>
- <result property="certified" column="certified"/>
- <result property="certifiedTime" column="certified_time"/>
- <result property="district" column="district"/>
- <result property="marry" column="marry"/>
- <result property="houseProvince" column="house_province"/>
- <result property="houseCity" column="house_city"/>
- <result property="houseDistrict" column="house_district"/>
- <result property="oneInchPhotos" column="one_inch_photos"/>
- <result property="politic" column="politic"/>
- <result property="email" column="email"/>
- <result property="avatar" column="avatar"/>
- <result property="inviteUserAccount" column="invite_user_account"/>
- <result property="courseNum" column="course_num"/>
- <result property="studyTime" column="study_time"/>
- <result property="password" column="password"/>
- <result property="goodsCourseNum" column="goods_course_num"/>
- <result property="goodsBankNum" column="goods_bank_num"/>
- <result property="importNo" column="import_no"/>
- <result property="goodsLiveNum" column="goods_live_num"/>
- <result property="userBindWx" column="user_bind_wx"/>
- <result property="userFollowWx" column="user_follow_wx"/>
- <result property="lastVisitTime" column="last_visit_time"/>
- <result property="visitFromPlat" column="visit_from_plat"/>
- <result property="studyFromPlat" column="study_from_plat"/>
- <result property="lastStudyTime" column="last_study_time"/>
- <result property="job" column="job"/>
- <result property="shareCode" column="share_code"/>
- <result property="pwdTime" column="pwd_time"/>
- <result property="unitContact" column="unit_contact"/>
- <result property="unitTel" column="unit_tel"/>
- <result property="school" column="school"/>
- <result property="graduationTime" column="graduation_time"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.user.vo.RanKingUser" id="RanKingUserResult">
- <result property="hourse" column="sum_study"/>
- <result property="avatar" column="avatar"/>
- <result property="nickname" column="nickname"/>
- <result property="rank" column="pm"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.user.vo.UserStudyRecordVo" id="StudyRecordResult">
- <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="realname" column="realname"/>
- <result property="endTime" column="end_time"/>
- <result property="startTime" column="start_time"/>
- <result property="title" column="title"/>
- <result property="courseName" column="course_name"/>
- <result property="studyDuration" column="study_duration"/>
- </resultMap>
- <select id="selectByRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
- SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
- LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
- <if test="userId != null and userId != ''">
- AND u.user_id = #{userId}
- </if>
- <if test="startTime != null and startTime != ''">
- AND s.create_time BETWEEN #{startTime} and #{endTime}
- </if>
- GROUP BY u.user_id
- </select>
- <select id="selectByRanks" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
- SELECT A.*
- FROM
- (
- SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
- LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
- <if test="startTime != null and startTime != ''">
- AND s.create_time BETWEEN #{startTime} and #{endTime}
- </if>
- GROUP BY u.user_id ORDER BY sum_study desc LIMIT 20
- ) A where
- A.sum_study >0
- </select>
- <select id="selectByRankOne" parameterType="integer" resultType="int">
- SELECT
- COUNT(s.sum_study)
- FROM
- (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1 GROUP BY s.user_id) s
- WHERE s.sum_study >= #{hourse}
- </select>
- <select id="selectByRankOneByTime" parameterType="map" resultType="int">
- SELECT
- COUNT(s.sum_study)
- FROM
- (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1
- <if test="startTime != null and startTime != ''">
- and s.create_time BETWEEN #{startTime} and #{endTime}
- </if>
- GROUP BY s.user_id) s
- WHERE s.sum_study >= #{hourse}
- </select>
- <select id="selectByOneRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
- SELECT u.nickname,u.avatar FROM `user` u
- where 1=1
- <if test="userId != null and userId != ''">
- AND u.user_id = #{userId}
- </if>
- GROUP BY u.user_id
- </select>
- <select id="selectUserNum" parameterType="integer" resultType="int">
- SELECT
- COUNT(user_id)
- FROM
- `user`
- WHERE 1=1 and user_level = #{grade}
- </select>
- <select id="selectListByBo" 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="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
- usr.study_duration,
- c.course_name,
- pv.title,
- usr.start_time,
- usr.end_time,
- u.realname,
- u.telphone
- FROM
- user_study_record usr
- LEFT JOIN course c ON usr.course_id = c.course_id
- LEFT JOIN course_section cs ON usr.section_id = cs.section_id
- LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
- LEFT JOIN `user` u ON usr.user_id = u.user_id
- WHERE 1=1
- <if test="userId != null and userId != ''" >
- AND usr.user_id = #{userId}
- </if>
- <if test="courseName != null and courseName != ''" >
- AND c.course_name like concat('%', #{courseName}, '%')
- </if>
- <if test="title != null and title != ''" >
- AND pv.title like concat('%', #{title}, '%')
- </if>
- <if test="startTime1 != null and startTime1 != ''" >
- AND usr.start_time > #{startTime1}
- </if>
- <if test="startTime2 != null and startTime2 != ''" >
- AND #{startTime2} > usr.start_time
- </if>
- <if test="endTime1 != null and endTime1 != ''" >
- AND usr.end_time > #{endTime1}
- </if>
- <if test="endTime2 != null and endTime2 != ''" >
- AND #{endTime2} > usr.end_time
- </if>
- ORDER BY
- usr.record_id DESC
- </select>
- <select id="selectLookNum" parameterType="Long" resultType="integer">
- SELECT
- COUNT( user_id )
- FROM
- recruit_interview_message
- WHERE
- 1 = 1
- AND user_id = #{userId}
- AND look_status = 0
- </select>
- <select id="periodSum" parameterType="Long" resultType="Long">
- SELECT
- COUNT(1)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON ups.period_id = up.id
- LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
- WHERE
- up.user_id = #{userId}
- and ups.period_status =1
- and cgu.change_grade = 0
- and ups.`status` in (0,3)
- </select>
- <select id="subscribeSum" parameterType="Long" resultType="Long">
- SELECT
- COUNT(1)
- FROM
- user_subscribe us
- WHERE
- us.user_id = #{userId}
- AND us.subscribe_status = 1
- and (us.exam_expend is null or us.exam_expend = 0)
- </select>
- <select id="informSum" parameterType="Long" resultType="Long">
- SELECT
- COUNT(1)
- FROM
- inform_user iu
- WHERE
- iu.user_id = #{userId}
- and iu.receipt_status = 0
- and iu.system_status in (1,2)
- </select>
- <select id="orderSum" parameterType="Long" resultType="Long">
- SELECT
- COUNT( 1 )
- FROM
- `order`
- WHERE
- user_id = #{userId}
- AND order_status =0
- </select>
- <select id="queryUserByTelphoneTenant" parameterType="map" resultMap="UserResult">
- SELECT
- *
- FROM
- `user`
- WHERE
- telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- AND status = 1 AND tenant_id = #{tenantId}
- </select>
- <select id="getUserByTelNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
- </select>
- <select id="getUserByIdNumNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
- </select>
- <select id="queryUserByIdNumTenant" parameterType="map" resultMap="UserResult">
- SELECT
- *
- FROM
- `user`
- WHERE
- id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- AND status = 1 AND tenant_id = #{tenantId}
- </select>
- <select id="selectAllUserList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
- SELECT
- *
- FROM
- `user`
- </select>
- <select id="editUserInfo" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo">
- UPDATE `user`
- <trim prefix="set" suffixOverrides=",">
- <if test="telphone != null">
- telphone = #{telphone},
- </if>
- <if test="idCard != null">
- id_card = #{idCard},
- </if>
- </trim>
- WHERE
- user_id = #{userId}
- </select>
- <select id="getUserByTel" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- status = 1
- AND(id_card = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- OR telphone = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler})
- </select>
- <select id="getUserByAccount" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- status = 1
- AND user_account = #{userAccount}
- </select>
- <select id="listByIdsNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- status = 1 AND user_id IN
- <foreach collection="userIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </select>
- <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- status = 1 AND user_id = #{userId}
- </select>
- <select id="getByCardNoTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
- SELECT
- *
- FROM
- `user`
- WHERE
- status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- LIMIT 1
- </select>
- <select id="getUserOrderCount" parameterType="map" resultType="java.lang.Long">
- SELECT
- COUNT(o.order_sn)
- FROM
- `order` o
- INNER JOIN order_goods og ON o.order_sn = og.order_sn
- AND og.tenant_id = #{tenantId}
- INNER JOIN goods g ON og.goods_id = g.goods_id
- AND g.tenant_id = #{tenantId}
- WHERE
- o.`status` = 1
- AND o.user_id = #{userId}
- AND g.`code` = #{code}
- AND g.goods_name = #{goodsName}
- AND og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND g.`status` = 1
- AND og.`status` = 1
- AND o.tenant_id = #{tenantId}
- </select>
- <select id="dangAnList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
- SELECT u.* from `user` u where 1=1
- <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="educationTypeId != null and educationTypeId != ''" >
- 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 o.`status` = 1 AND og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2 AND g.education_type_id = #{educationTypeId})>0
- </if>
- <if test="businessId != null and businessId != ''" >
- 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 o.`status` = 1 AND og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2 AND g.business_id = #{businessId})>0
- </if>
- order by u.user_id desc
- </select>
- </mapper>
|