| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <?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.base.mapper.UserProfileMapper">
- <resultMap type="com.zhongzheng.modules.base.domain.UserProfile" id="UserProfileResult">
- <result property="id" column="id"/>
- <result property="userId" column="user_id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="status" column="status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="oneTime" column="one_time"/>
- <result property="lastTime" column="last_time"/>
- <result property="keyValue" column="key_value"/>
- <result property="createByName" column="create_by_name"/>
- <result property="currentStatus" column="current_status"/>
- <result property="changeStatus" column="change_status"/>
- <result property="text" column="text"/>
- <result property="auditTime" column="audit_time"/>
- <result property="orderGoodsId" column="order_goods_id"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.base.vo.UserProfileVo" id="UserProfileVo">
- <result property="id" column="id"/>
- <result property="userId" column="user_id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="sex" column="sex"/>
- <result property="status" column="status"/>
- <result property="oneTime" column="one_time"/>
- <result property="lastTime" column="last_time"/>
- <result property="keyValue" column="key_value"/>
- <result property="currentStatus" column="current_status"/>
- <result property="changeStatus" column="change_status"/>
- <result property="realname" column="realname"/>
- <result property="userAccount" column="user_account"/>
- <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="goodsName" column="goods_name"/>
- <result property="goodsCode" column="goods_code"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="text" column="text"/>
- <result property="auditTime" column="audit_time"/>
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="applyTime" column="apply_time"/>
- <result property="companyName" column="company_name"/>
- </resultMap>
- <select id="selectUserProfile" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
- SELECT
- up.*,
- og.create_time as apply_time,
- u.company_name,
- (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
- (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
- (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
- (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
- (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
- (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
- (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
- (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
- (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
- FROM
- user_profile up
- LEFT JOIN goods g ON up.goods_id = g.goods_id
- LEFT JOIN course_business cb on g.business_id = cb.id
- LEFT JOIN order_goods og on up.order_goods_id = og.order_goods_id
- LEFT JOIN `user` u on up.user_id = u.user_id
- where 1=1
- and up.current_status = 1
- and up.status != -1
- <if test="status != null and status.size()!=0 ">
- AND up.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="id != null and id !='' ">
- AND up.id =#{id}
- </if>
- <if test="typeStatus != null and typeStatus !='' ">
- and up.type_status = #{typeStatus}
- </if>
- <if test="userId != null and userId !='' ">
- AND up.user_id =#{userId}
- </if>
- <if test="goodsId != null and goodsId !='' ">
- AND up.goods_id =#{goodsId}
- </if>
- <if test="educationTypeId != null and educationTypeId !='' ">
- AND (SELECT cet.id FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) =#{educationTypeId}
- </if>
- <if test="businessId != null and businessId !='' ">
- AND cb.id =#{businessId}
- </if>
- <if test="schoolId != null and schoolId !='' ">
- AND (SELECT g.school_id FROM goods g where up.goods_id = g.goods_id) =#{schoolId}
- </if>
- <if test="majorId != null and majorId !='' ">
- AND (SELECT g.major_id FROM goods g where up.goods_id = g.goods_id) =#{majorId}
- </if>
- <if test="changeStatus != null and changeStatus !='' ">
- AND up.change_status =#{changeStatus}
- </if>
- <if test="realname != null and realname !='' ">
- AND u.realname like concat('%', #{realname}, '%')
- </if>
- <if test="searchStartTime != null and searchStartTime !='' ">
- AND up.create_time >=#{searchStartTime}
- </if>
- <if test="searchEndTime != null and searchEndTime !='' ">
- AND #{searchEndTime} >= up.create_time
- </if>
- <if test="applyStartTime != null and applyStartTime !='' ">
- AND og.create_time >=#{searchStartTime}
- </if>
- <if test="applyEndTime != null and applyEndTime !='' ">
- AND #{searchEndTime} >= og.create_time
- </if>
- <if test="companyName != null and companyName !='' ">
- AND u.company_name like concat('%', #{companyName}, '%')
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by up.create_time desc
- </select>
- <select id="getInfo" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
- SELECT
- up.*,
- (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
- (SELECT u.sex FROM `user` u where u.user_id = up.user_id) as sex,
- (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
- (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
- (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
- (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
- (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
- (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
- (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
- (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
- FROM
- user_profile up
- where 1=1
- and up.current_status = 1
- <if test="typeStatus != null and typeStatus !='' ">
- and up.type_status = #{typeStatus}
- </if>
- <if test="status != null and status.size()!=0 ">
- AND up.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="id != null and id !='' ">
- AND up.id =#{id}
- </if>
- <if test="userId != null and userId !='' ">
- AND up.user_id =#{userId}
- </if>
- <if test="goodsId != null and goodsId !='' ">
- AND up.goods_id =#{goodsId}
- </if>
- <if test="orderGoodsId != null and orderGoodsId !='' ">
- AND up.order_goods_id =#{orderGoodsId}
- </if>
- order by up.create_time desc LIMIT 1
- </select>
- <select id="listRecord" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
- SELECT
- up.*,
- (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
- (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
- (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
- (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
- (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
- (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
- (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on g.education_type_id = cet.id where up.goods_id = g.goods_id) as education_name,
- (SELECT cet.project_name FROM goods g LEFT JOIN course_project_type cet on g.project_id = cet.id where up.goods_id = g.goods_id) as project_name,
- (SELECT cet.business_name FROM goods g LEFT JOIN course_business cet on g.business_id = cet.id where up.goods_id = g.goods_id) as business_name
- FROM
- user_profile up
- where 1=1
- and up.status != 2
- AND up.change_status != 2
- <if test="typeStatus != null and typeStatus !='' ">
- and up.type_status = #{typeStatus}
- </if>
- <if test="status != null and status.size()!=0 ">
- AND up.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="id != null and id !='' ">
- AND up.id =#{id}
- </if>
- <if test="userId != null and userId !='' ">
- AND up.user_id =#{userId}
- </if>
- <if test="goodsId != null and goodsId !='' ">
- AND up.goods_id =#{goodsId}
- </if>
- <if test="educationTypeId != null and educationTypeId !='' ">
- AND g.education_type_id =#{educationTypeId}
- </if>
- <if test="businessId != null and businessId !='' ">
- AND g.business_id =#{businessId}
- </if>
- <if test="schoolId != null and schoolId !='' ">
- AND g.school_id =#{schoolId}
- </if>
- <if test="majorId != null and majorId !='' ">
- AND g.major_id =#{majorId}
- </if>
- <if test="changeStatus != null and changeStatus !='' ">
- AND up.change_status =#{changeStatus}
- </if>
- order by up.create_time desc
- </select>
- <select id="selectCountProfile" parameterType="map" resultType="Long">
- SELECT
- COUNT(1)
- FROM
- profile_tp p JOIN profile_tp_business tb on p.profile_tp_id = tb.profile_tp_id JOIN course_business b on tb.business_id = b.id
- WHERE
- 1 = 1
- AND FIND_IN_SET(#{goodsId},p.goods_ids)
- and FIND_IN_SET(#{userId},b.profile_tp_user_ids)
- </select>
- <select id="selectGrade" parameterType="map" resultType="Long">
- SELECT
- cgu.grade_id
- FROM
- class_grade_user cgu
- LEFT JOIN order_goods og on og.order_goods_id = cgu.order_goods_id
- LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
- WHERE
- cgu.user_id = #{userId}
- and og.goods_id = #{goodsId}
- and cg.`status` = 1
- and cgu.`status` = 1
- ORDER BY cgu.create_time desc
- LIMIT 1
- </select>
- <select id="getProfileStatusNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="java.lang.Integer">
- SELECT COUNT(up.id)
- FROM
- user_profile up
- LEFT JOIN goods g ON up.goods_id = g.goods_id
- WHERE 1=1
- and up.type_status = 1
- and up.current_status = 1
- <if test="periodStatus != null">
- and up.`status` = #{periodStatus}
- </if>
- <if test="businessId != null and businessId != ''">
- and g.business_id = #{businessId}
- </if>
- </select>
- <select id="getByOrderGoodsIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.base.domain.UserProfile">
- SELECT * FROM user_profile WHERE order_goods_id = #{orderGoodsId} AND current_status = 1 AND `status` NOT IN (3,-1)
- </select>
- </mapper>
|