123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <?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"/>
- <result property="telphone" column="telphone"/>
- <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"/>
- </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"/>
- <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="selectList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
- SELECT
- u.*
- <if test="getOrderNum != null and getOrderNum == 1" >
- ,ou.goods_course_num,ou.goods_bank_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,
- 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)
- GROUP BY
- o.user_id
- ) ou ON u.user_id = ou.user_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="nickname != null and nickname != ''" >
- AND u.nickname like concat('%', #{nickname}, '%')
- </if>
- <if test="telphone != null and telphone != ''" >
- AND u.telphone = #{telphone}
- </if>
- <if test="idCard != null and idCard != ''" >
- AND u.id_card = #{idCard}
- </if>
- <if test="realname != null and realname != ''" >
- AND u.realname like concat('%', #{realname}, '%')
- </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="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>
- </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>
- </mapper>
|