UserSubscribeMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.user.mapper.UserSubscribeMapper">
  6. <resultMap type="com.zhongzheng.modules.user.domain.UserSubscribe" id="UserSubscribeResult">
  7. <result property="subscribeId" column="subscribe_id"/>
  8. <result property="goodsId" column="goods_id"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="subscribeStatus" column="subscribe_status"/>
  11. <result property="beforeStatus" column="before_status"/>
  12. <result property="examStatus" column="exam_status"/>
  13. <result property="performance" column="performance"/>
  14. <result property="result" column="result"/>
  15. <result property="certificateCode" column="certificate_code"/>
  16. <result property="applyId" column="apply_id"/>
  17. <result property="studentType" column="student_type"/>
  18. <result property="examExpend" column="exam_expend"/>
  19. <result property="beforeExpend" column="before_expend"/>
  20. <result property="createTime" column="create_time"/>
  21. <result property="updateTime" column="update_time"/>
  22. </resultMap>
  23. <resultMap type="com.zhongzheng.modules.user.vo.UserSubscribeVo" id="UserSubscribeVo">
  24. <result property="subscribeId" column="subscribe_id"/>
  25. <result property="goodsId" column="goods_id"/>
  26. <result property="userId" column="user_id"/>
  27. <result property="subscribeStatus" column="subscribe_status"/>
  28. <result property="beforeStatus" column="before_status"/>
  29. <result property="examStatus" column="exam_status"/>
  30. <result property="performance" column="performance"/>
  31. <result property="result" column="result"/>
  32. <result property="certificateCode" column="certificate_code"/>
  33. <result property="applyId" column="apply_id"/>
  34. <result property="studentType" column="student_type"/>
  35. <result property="examExpend" column="exam_expend"/>
  36. <result property="beforeExpend" column="before_expend"/>
  37. <result property="createTime" column="create_time"/>
  38. <result property="goodsName" column="goods_name"/>
  39. <result property="categoryName" column="category_name"/>
  40. <result property="goodsCode" column="goods_code"/>
  41. <result property="remark" column="remark"/>
  42. <result property="standPrice" column="stand_price"/>
  43. <result property="realname" column="realname"/>
  44. <result property="idCard" column="id_card"/>
  45. <result property="applyName" column="apply_name"/>
  46. <result property="beforeId" column="before_id"/>
  47. <result property="beforeName" column="before_name"/>
  48. <result property="applySiteAddress" column="apply_site_address"/>
  49. <result property="applySiteStartTime" column="apply_site_start_time"/>
  50. <result property="applySiteEndTime" column="apply_site_end_time"/>
  51. <result property="applySiteExamTime" column="apply_site_exam_time"/>
  52. <result property="applySiteAddressTrain" column="apply_site_address_train"/>
  53. <result property="applySiteStartTrainTime" column="apply_site_start_train_time"/>
  54. <result property="applySiteEndTrainTime" column="apply_site_end_train_time"/>
  55. <result property="applySiteExamTrainTime" column="apply_site_exam_train_time"/>
  56. <result property="applyStartTime" column="apply_start_time"/>
  57. <result property="applyEndTime" column="apply_end_time"/>
  58. <result property="businessId" column="business_id"/>
  59. </resultMap>
  60. <select id="listSubscribe" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">
  61. SELECT
  62. *,
  63. (SELECT g.goods_name FROM goods g where us.goods_id = g.goods_id) as goods_name,
  64. (SELECT g.code FROM goods g where us.goods_id = g.goods_id) as goods_code,
  65. (SELECT g.stand_price FROM goods g where us.goods_id = g.goods_id) as stand_price,
  66. (SELECT m.category_name FROM goods g LEFT JOIN major m on g.major_id= m.id where us.goods_id = g.goods_id) as category_name,
  67. (SELECT u.realname FROM `user` u where us.user_id = u.user_id) as realname,
  68. (SELECT u.id_card FROM `user` u where us.user_id = u.user_id) as id_card,
  69. (SELECT ea.apply_name FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_name,
  70. (SELECT ea.apply_start_time FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_start_time,
  71. (SELECT ea.apply_end_time FROM exam_apply ea where ea.apply_id = us.apply_id) as apply_end_time,
  72. (SELECT eb.before_name FROM exam_before eb where eb.before_id = us.before_id) as before_name
  73. FROM
  74. user_subscribe us
  75. WHERE
  76. 1 =1
  77. <if test="userId != null and userId != '' ">
  78. and us.user_id = #{userId}
  79. </if>
  80. <if test="goodsId != null and goodsId != '' ">
  81. and us.goods_id = #{goodsId}
  82. </if>
  83. <if test="result != null ">
  84. and us.result = #{result}
  85. </if>
  86. <if test="subscribeId != null and subscribeId != '' ">
  87. and us.subscribe_id = #{subscribeId}
  88. </if>
  89. <if test="subscribeStatus != null and subscribeStatus != '' ">
  90. and us.subscribe_status = #{subscribeStatus}
  91. </if>
  92. <if test="applyId != null and applyId != '' ">
  93. and us.apply_id = #{applyId}
  94. </if>
  95. <if test="studentType != null and studentType != '' ">
  96. and us.student_type = #{studentType}
  97. </if>
  98. <if test="examStatus != null ">
  99. and us.exam_status = #{examStatus}
  100. </if>
  101. <if test="examExpend != null ">
  102. and us.exam_expend is NOT NULL
  103. </if>
  104. <if test="beforeExpend != null ">
  105. and us.before_expend is NOT NULL
  106. </if>
  107. <if test="beforeId != null ">
  108. and us.before_id =#{beforeId}
  109. </if>
  110. <if test="majorId != null and majorId != '' ">
  111. and (SELECT m.id FROM goods g LEFT JOIN major m on g.major_id= m.id where us.goods_id = g.goods_id) = #{majorId}
  112. </if>
  113. <if test="realname != null and realname != '' ">
  114. and (SELECT u.realname FROM `user` u where us.user_id = u.user_id) like concat('%', #{realname}, '%')
  115. </if>
  116. order by us.create_time desc
  117. </select>
  118. <select id="selectGoodsId" parameterType="string" resultType="Long">
  119. SELECT g.goods_id FROM goods g where g.`code`=#{code} and g.status = 1
  120. </select>
  121. <select id="selectUserId" parameterType="map" resultType="Long">
  122. SELECT u.user_id FROM `user` u where u.realname=#{userName} and u.id_card=#{idCard}
  123. </select>
  124. <select id="selectBeforeId" parameterType="map" resultType="Long">
  125. SELECT eb.before_id FROM exam_before eb where eb.before_name=#{beforeName} and eb.status = 1
  126. </select>
  127. <select id="selectApplyId" parameterType="map" resultType="Long">
  128. SELECT ea.apply_id FROM exam_apply ea where ea.apply_name=#{applyName} and ea.status = 1
  129. </select>
  130. <select id="selectSubscribeId" parameterType="map" resultType="Long">
  131. SELECT
  132. us.subscribe_id
  133. FROM
  134. user_subscribe us
  135. WHERE 1=1
  136. and us.subscribe_status =1
  137. and us.apply_id = #{applyId}
  138. and us.goods_id=#{goodsId}
  139. and us.user_id = #{userId}
  140. </select>
  141. <select id="queryBusinessId" parameterType="map" resultType="Long">
  142. SELECT
  143. COUNT( 1 )
  144. FROM
  145. user_subscribe us
  146. LEFT JOIN exam_apply ea ON ea.apply_id = us.apply_id
  147. LEFT JOIN exam_apply_goods eag on ea.apply_id = eag.apply_id
  148. LEFT JOIN goods g on eag.goods_id = g.goods_id
  149. where 1=1
  150. AND g.business_id = #{businessId}
  151. AND us.subscribe_id = #{subscribeId}
  152. </select>
  153. <select id="timeSend" resultMap="UserSubscribeVo">
  154. SELECT
  155. * ,
  156. (SELECT g.business_id FROM goods g where g.goods_id = us.goods_id) as business_id
  157. FROM
  158. user_subscribe us
  159. WHERE us.subscribe_status = 1
  160. and unix_timestamp(now())+86400 > us.apply_site_exam_time
  161. and unix_timestamp(now()) &lt; us.apply_site_exam_time
  162. and (SELECT COUNT(1) FROM inform_remind ir LEFT JOIN inform_remind_business irb on ir.id = irb.remind_id where ir.id=16 and (SELECT g.business_id FROM goods g where g.goods_id = us.goods_id) = irb.business_id) > 0
  163. </select>
  164. <select id="sendExamSucceed" parameterType="map" resultType="Long">
  165. SELECT
  166. COUNT( 1 )
  167. FROM
  168. inform_remind ir
  169. LEFT JOIN inform_remind_business irb on irb.remind_id =ir.id
  170. LEFT JOIN goods g on g.business_id = irb.business_id
  171. where 1=1
  172. and g.goods_id = #{goodsId}
  173. </select>
  174. </mapper>