UserProfileMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.base.mapper.UserProfileMapper">
  6. <resultMap type="com.zhongzheng.modules.base.domain.UserProfile" id="UserProfileResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="oneTime" column="one_time"/>
  14. <result property="lastTime" column="last_time"/>
  15. <result property="keyValue" column="key_value"/>
  16. <result property="createByName" column="create_by_name"/>
  17. <result property="currentStatus" column="current_status"/>
  18. <result property="changeStatus" column="change_status"/>
  19. <result property="text" column="text"/>
  20. <result property="auditTime" column="audit_time"/>
  21. <result property="orderGoodsId" column="order_goods_id"/>
  22. </resultMap>
  23. <resultMap type="com.zhongzheng.modules.base.vo.UserProfileVo" id="UserProfileVo">
  24. <result property="id" column="id"/>
  25. <result property="userId" column="user_id"/>
  26. <result property="goodsId" column="goods_id"/>
  27. <result property="sex" column="sex"/>
  28. <result property="status" column="status"/>
  29. <result property="oneTime" column="one_time"/>
  30. <result property="lastTime" column="last_time"/>
  31. <result property="keyValue" column="key_value"/>
  32. <result property="currentStatus" column="current_status"/>
  33. <result property="changeStatus" column="change_status"/>
  34. <result property="realname" column="realname"/>
  35. <result property="userAccount" column="user_account"/>
  36. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  37. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  38. <result property="goodsName" column="goods_name"/>
  39. <result property="goodsCode" column="goods_code"/>
  40. <result property="educationName" column="education_name"/>
  41. <result property="projectName" column="project_name"/>
  42. <result property="businessName" column="business_name"/>
  43. <result property="text" column="text"/>
  44. <result property="auditTime" column="audit_time"/>
  45. <result property="orderGoodsId" column="order_goods_id"/>
  46. <result property="applyTime" column="apply_time"/>
  47. <result property="companyName" column="company_name"/>
  48. </resultMap>
  49. <select id="selectUserProfile" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  50. SELECT
  51. up.*,
  52. og.create_time as apply_time,
  53. u.company_name,
  54. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  55. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  56. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  57. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  58. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  59. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  60. (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,
  61. (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,
  62. (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
  63. FROM
  64. user_profile up
  65. LEFT JOIN goods g ON up.goods_id = g.goods_id
  66. LEFT JOIN course_business cb on g.business_id = cb.id
  67. LEFT JOIN order_goods og on up.order_goods_id = og.order_goods_id
  68. LEFT JOIN `user` u on up.user_id = u.user_id
  69. where 1=1
  70. and up.current_status = 1
  71. and up.status != -1
  72. <if test="status != null and status.size()!=0 ">
  73. AND up.status in
  74. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  75. #{item}
  76. </foreach>
  77. </if>
  78. <if test="id != null and id !='' ">
  79. AND up.id =#{id}
  80. </if>
  81. <if test="typeStatus != null and typeStatus !='' ">
  82. and up.type_status = #{typeStatus}
  83. </if>
  84. <if test="userId != null and userId !='' ">
  85. AND up.user_id =#{userId}
  86. </if>
  87. <if test="goodsId != null and goodsId !='' ">
  88. AND up.goods_id =#{goodsId}
  89. </if>
  90. <if test="educationTypeId != null and educationTypeId !='' ">
  91. 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}
  92. </if>
  93. <if test="businessId != null and businessId !='' ">
  94. AND cb.id =#{businessId}
  95. </if>
  96. <if test="schoolId != null and schoolId !='' ">
  97. AND (SELECT g.school_id FROM goods g where up.goods_id = g.goods_id) =#{schoolId}
  98. </if>
  99. <if test="majorId != null and majorId !='' ">
  100. AND (SELECT g.major_id FROM goods g where up.goods_id = g.goods_id) =#{majorId}
  101. </if>
  102. <if test="changeStatus != null and changeStatus !='' ">
  103. AND up.change_status =#{changeStatus}
  104. </if>
  105. <if test="realname != null and realname !='' ">
  106. AND u.realname like concat('%', #{realname}, '%')
  107. </if>
  108. <if test="searchStartTime != null and searchStartTime !='' ">
  109. AND up.create_time >=#{searchStartTime}
  110. </if>
  111. <if test="searchEndTime != null and searchEndTime !='' ">
  112. AND #{searchEndTime} >= up.create_time
  113. </if>
  114. <if test="applyStartTime != null and applyStartTime !='' ">
  115. AND og.create_time >=#{searchStartTime}
  116. </if>
  117. <if test="applyEndTime != null and applyEndTime !='' ">
  118. AND #{searchEndTime} >= og.create_time
  119. </if>
  120. <if test="companyName != null and companyName !='' ">
  121. AND u.company_name like concat('%', #{companyName}, '%')
  122. </if>
  123. <!-- 数据范围过滤 -->
  124. ${params.dataScope}
  125. order by up.create_time desc
  126. </select>
  127. <select id="getInfo" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  128. SELECT
  129. up.*,
  130. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  131. (SELECT u.sex FROM `user` u where u.user_id = up.user_id) as sex,
  132. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  133. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  134. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  135. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  136. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  137. (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,
  138. (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,
  139. (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
  140. FROM
  141. user_profile up
  142. where 1=1
  143. and up.current_status = 1
  144. <if test="typeStatus != null and typeStatus !='' ">
  145. and up.type_status = #{typeStatus}
  146. </if>
  147. <if test="status != null and status.size()!=0 ">
  148. AND up.status in
  149. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  150. #{item}
  151. </foreach>
  152. </if>
  153. <if test="id != null and id !='' ">
  154. AND up.id =#{id}
  155. </if>
  156. <if test="userId != null and userId !='' ">
  157. AND up.user_id =#{userId}
  158. </if>
  159. <if test="goodsId != null and goodsId !='' ">
  160. AND up.goods_id =#{goodsId}
  161. </if>
  162. <if test="orderGoodsId != null and orderGoodsId !='' ">
  163. AND up.order_goods_id =#{orderGoodsId}
  164. </if>
  165. order by up.create_time desc LIMIT 1
  166. </select>
  167. <select id="listRecord" parameterType="com.zhongzheng.modules.base.bo.UserProfileQueryBo" resultMap="UserProfileVo">
  168. SELECT
  169. up.*,
  170. (SELECT u.realname FROM `user` u where u.user_id = up.user_id) as realname,
  171. (SELECT u.user_account FROM `user` u where u.user_id = up.user_id) as user_account,
  172. (SELECT u.telphone FROM `user` u where u.user_id = up.user_id) as telphone,
  173. (SELECT u.id_card FROM `user` u where u.user_id = up.user_id) as id_card,
  174. (SELECT g.goods_name FROM goods g where up.goods_id = g.goods_id) as goods_name,
  175. (SELECT g.`code` FROM goods g where up.goods_id = g.goods_id) as goods_code,
  176. (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,
  177. (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,
  178. (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
  179. FROM
  180. user_profile up
  181. where 1=1
  182. and up.status != 2
  183. AND up.change_status != 2
  184. <if test="typeStatus != null and typeStatus !='' ">
  185. and up.type_status = #{typeStatus}
  186. </if>
  187. <if test="status != null and status.size()!=0 ">
  188. AND up.status in
  189. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  190. #{item}
  191. </foreach>
  192. </if>
  193. <if test="id != null and id !='' ">
  194. AND up.id =#{id}
  195. </if>
  196. <if test="userId != null and userId !='' ">
  197. AND up.user_id =#{userId}
  198. </if>
  199. <if test="goodsId != null and goodsId !='' ">
  200. AND up.goods_id =#{goodsId}
  201. </if>
  202. <if test="educationTypeId != null and educationTypeId !='' ">
  203. AND g.education_type_id =#{educationTypeId}
  204. </if>
  205. <if test="businessId != null and businessId !='' ">
  206. AND g.business_id =#{businessId}
  207. </if>
  208. <if test="schoolId != null and schoolId !='' ">
  209. AND g.school_id =#{schoolId}
  210. </if>
  211. <if test="majorId != null and majorId !='' ">
  212. AND g.major_id =#{majorId}
  213. </if>
  214. <if test="changeStatus != null and changeStatus !='' ">
  215. AND up.change_status =#{changeStatus}
  216. </if>
  217. order by up.create_time desc
  218. </select>
  219. <select id="selectCountProfile" parameterType="map" resultType="Long">
  220. SELECT
  221. COUNT(1)
  222. FROM
  223. 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
  224. WHERE
  225. 1 = 1
  226. AND FIND_IN_SET(#{goodsId},p.goods_ids)
  227. and FIND_IN_SET(#{userId},b.profile_tp_user_ids)
  228. </select>
  229. <select id="selectGrade" parameterType="map" resultType="Long">
  230. SELECT
  231. cgu.grade_id
  232. FROM
  233. class_grade_user cgu
  234. LEFT JOIN order_goods og on og.order_goods_id = cgu.order_goods_id
  235. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  236. WHERE
  237. cgu.user_id = #{userId}
  238. and og.goods_id = #{goodsId}
  239. and cg.`status` = 1
  240. and cgu.`status` = 1
  241. ORDER BY cgu.create_time desc
  242. LIMIT 1
  243. </select>
  244. <select id="getProfileStatusNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="java.lang.Integer">
  245. SELECT COUNT(up.id)
  246. FROM
  247. user_profile up
  248. LEFT JOIN goods g ON up.goods_id = g.goods_id
  249. WHERE 1=1
  250. and up.type_status = 1
  251. and up.current_status = 1
  252. <if test="periodStatus != null">
  253. and up.`status` = #{periodStatus}
  254. </if>
  255. <if test="businessId != null and businessId != ''">
  256. and g.business_id = #{businessId}
  257. </if>
  258. </select>
  259. <select id="getByOrderGoodsIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.base.domain.UserProfile">
  260. SELECT * FROM user_profile WHERE order_goods_id = #{orderGoodsId} AND current_status = 1 AND `status` NOT IN (3,-1)
  261. </select>
  262. </mapper>