MusicGroupPaymentCalenderDetailMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
  4. <mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao">
  5. <resultMap type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
  6. id="MusicGroupPaymentCalenderDetail">
  7. <result column="id_" property="id" />
  8. <result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId" />
  9. <result column="user_id_" property="userId" />
  10. <result column="expect_amount_" property="expectAmount" />
  11. <result column="actual_amount_" property="actualAmount" />
  12. <result column="payment_status_" property="paymentStatus" />
  13. <result column="user_status_" property="userStatus" />
  14. <result column="music_group_id_" property="musicGroupId" />
  15. <result column="pay_time_" property="payTime" />
  16. <result column="start_payment_date_" property="startPaymentDate" />
  17. <result column="deadline_payment_date_" property="deadlinePaymentDate" />
  18. <result column="update_time_" property="updateTime" />
  19. <result column="create_time_" property="createTime" />
  20. <result column="open_" property="open" />
  21. <association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
  22. <result column="username_" property="username" />
  23. </association>
  24. <association property="studentRegistration" javaType="com.ym.mec.biz.dal.entity.StudentRegistration">
  25. <result column="subject_names_" property="subjectName" />
  26. <result column="music_group_status_" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  27. </association>
  28. </resultMap>
  29. <!-- 根据主键查询一条记录 -->
  30. <select id="get" resultMap="MusicGroupPaymentCalenderDetail">
  31. SELECT * FROM music_group_payment_calender_detail WHERE id_ = #{id}
  32. </select>
  33. <!-- 全查询 -->
  34. <select id="findAll" resultMap="MusicGroupPaymentCalenderDetail">
  35. SELECT * FROM music_group_payment_calender_detail ORDER BY id_
  36. </select>
  37. <!-- 向数据库增加一条记录 -->
  38. <insert id="insert"
  39. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
  40. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  41. INSERT INTO music_group_payment_calender_detail
  42. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
  43. user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  44. VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},
  45. #{userStatus},#{payTime},#{updateTime},#{createTime},#{open},#{startPaymentDate},#{deadlinePaymentDate})
  46. </insert>
  47. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  48. INSERT INTO music_group_payment_calender_detail
  49. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
  50. payment_status_,user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  51. VALUES
  52. <foreach collection="list" item="item" separator=",">
  53. (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
  54. #{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},
  55. #{item.updateTime},#{item.createTime},#{item.open},#{item.startPaymentDate},#{item.deadlinePaymentDate})
  56. </foreach>
  57. </insert>
  58. <!-- 根据主键查询一条记录 -->
  59. <update id="update"
  60. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  61. UPDATE music_group_payment_calender_detail
  62. <set>
  63. <if test="startPaymentDate != null">
  64. start_payment_date_ = #{startPaymentDate},
  65. </if>
  66. <if test="deadlinePaymentDate != null">
  67. deadline_payment_date_ = #{deadlinePaymentDate},
  68. </if>
  69. <if test="open != null">
  70. open_ = #{open},
  71. </if>
  72. <if test="userId != null">
  73. user_id_ = #{userId},
  74. </if>
  75. <if test="userStatus != null">
  76. user_status_ = #{userStatus},
  77. </if>
  78. <if test="paymentStatus != null">
  79. payment_status_ = #{paymentStatus},
  80. </if>
  81. <if test="expectAmount != null">
  82. expect_amount_ = #{expectAmount},
  83. </if>
  84. <if test="updateTime != null">
  85. update_time_ = #{updateTime},
  86. </if>
  87. <if test="musicGroupPaymentCalenderId != null">
  88. music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
  89. </if>
  90. <if test="actualAmount != null">
  91. actual_amount_ = #{actualAmount},
  92. </if>
  93. <if test="payTime != null">
  94. pay_time_ = #{payTime},
  95. </if>
  96. </set>
  97. WHERE id_ = #{id}
  98. </update>
  99. <update id="batchUpdate">
  100. <foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
  101. UPDATE music_group_payment_calender_detail
  102. <set>
  103. <if test="item.startPaymentDate != null">
  104. start_payment_date_ = #{item.startPaymentDate},
  105. </if>
  106. <if test="item.deadlinePaymentDate != null">
  107. deadline_payment_date_ = #{item.deadlinePaymentDate},
  108. </if>
  109. <if test="item.open != null">
  110. open_ = #{item.open},
  111. </if>
  112. <if test="item.userId != null">
  113. user_id_ = #{item.userId},
  114. </if>
  115. <if test="item.userStatus != null">
  116. user_status_ = #{item.userStatus},
  117. </if>
  118. <if test="item.paymentStatus != null">
  119. payment_status_ = #{item.paymentStatus},
  120. </if>
  121. <if test="item.expectAmount != null">
  122. expect_amount_ = #{item.expectAmount},
  123. </if>
  124. <if test="item.updateTime != null">
  125. update_time_ = #{item.updateTime},
  126. </if>
  127. <if test="item.musicGroupPaymentCalenderId != null">
  128. music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
  129. </if>
  130. <if test="item.actualAmount != null">
  131. actual_amount_ = #{item.actualAmount},
  132. </if>
  133. <if test="item.payTime != null">
  134. pay_time_ = #{item.payTime}
  135. </if>
  136. </set>
  137. WHERE id_ = #{item.id}
  138. </foreach>
  139. </update>
  140. <update id="refreshUserMusicGroupPaymentStatusTask">
  141. UPDATE music_group_payment_calender_detail mgpcd
  142. SET mgpcd.open_ = 0,mgpcd.start_payment_date_ = NULL,mgpcd.deadline_payment_date_ = NULL
  143. WHERE mgpcd.deadline_payment_date_ &lt; DATE_FORMAT(NOW(),'%Y-%m-%d')
  144. </update>
  145. <!-- 根据主键删除一条记录 -->
  146. <delete id="delete">
  147. DELETE FROM music_group_payment_calender_detail WHERE id_ = #{id}
  148. </delete>
  149. <!-- 分页查询 -->
  150. <select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail"
  151. parameterType="map">
  152. SELECT mgpcd.*,su.username_,st.name_ subject_names_,sr.music_group_status_
  153. FROM music_group_payment_calender_detail mgpcd
  154. LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
  155. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  156. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  157. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  158. <where>
  159. mgpc.music_group_id_ = sr.music_group_id_
  160. <if test="userId != null">
  161. AND mgpcd.user_id_ = #{userId}
  162. </if>
  163. <if test="id != null">
  164. AND mgpcd.music_group_payment_calender_id_ = #{id}
  165. </if>
  166. <if test="paymentStatus != null">
  167. AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  168. </if>
  169. <if test="subjectId != null">
  170. AND #{subjectId} = sr.actual_subject_id_
  171. </if>
  172. </where>
  173. ORDER BY mgpc.create_time_
  174. <include refid="global.limit" />
  175. </select>
  176. <!-- 查询当前表的总记录数 -->
  177. <select id="queryCount" resultType="int">
  178. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
  179. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  180. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  181. <where>
  182. <if test="userId != null">
  183. AND mgpcd.user_id_ = #{userId}
  184. </if>
  185. <if test="id != null">
  186. AND mgpcd.music_group_payment_calender_id_ = #{id}
  187. </if>
  188. <if test="subjectId != null">
  189. AND #{subjectId} = sr.actual_subject_id_
  190. </if>
  191. <if test="paymentStatus != null">
  192. AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  193. </if>
  194. </where>
  195. </select>
  196. <select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
  197. SELECT * FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{ids})
  198. </select>
  199. <select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
  200. SELECT * FROM music_group_payment_calender_detail where music_group_payment_calender_id_ = #{calenderId}
  201. </select>
  202. <select id="findMusicGroupStudentWithSubject" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
  203. SELECT DISTINCT su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
  204. from music_group_student_fee_ mgstf
  205. LEFT JOIN sys_user su ON su.id_=mgstf.user_id_
  206. WHERE mgstf.music_group_id_=#{musicGroupId}
  207. AND mgstf.subject_id_=#{subjectId}
  208. AND mgstf.remain_network_class_times_>0
  209. </select>
  210. <select id="sumActualAmount" resultType="java.math.BigDecimal">
  211. SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
  212. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  213. </select>
  214. <select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
  215. SELECT * FROM music_group_payment_calender_detail mgpcd
  216. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  217. WHERE mgpc.music_group_id_=#{musicGroupId} AND mgpcd.user_id_=#{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT'
  218. AND (mgpc.payment_status_ = '1' OR mgpcd.open_=1)
  219. ORDER BY mgpc.start_payment_date_ DESC LIMIT 1
  220. </select>
  221. <select id="queryCanOpenList" resultMap="MusicGroupPaymentCalenderDetail">
  222. SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
  223. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  224. LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
  225. WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.open_ = 0 AND sr.music_group_status_ != 'QUIT' AND mgpc.payment_status_ = 'YES'
  226. AND FIND_IN_SET(mgpcd.id_,#{ids})
  227. </select>
  228. <select id="queryIntersectionByPaymentDate" resultType="java.lang.Integer">
  229. SELECT COUNT(mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
  230. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  231. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.user_id_ = #{userId}
  232. AND mgpcd.open_ = 1
  233. </select>
  234. </mapper>