MusicGroupPaymentCalenderDetailMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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="pay_time_" property="payTime" />
  15. <result column="start_payment_date_" property="startPaymentDate" />
  16. <result column="deadline_payment_date_" property="deadlinePaymentDate" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="open_" property="open" />
  20. <association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
  21. <result column="username_" property="username" />
  22. </association>
  23. <association property="studentRegistration" javaType="com.ym.mec.biz.dal.entity.StudentRegistration">
  24. <result column="subject_names_" property="subjectName" />
  25. <result column="music_group_status_" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  26. </association>
  27. </resultMap>
  28. <!-- 根据主键查询一条记录 -->
  29. <select id="get" resultMap="MusicGroupPaymentCalenderDetail">
  30. SELECT * FROM music_group_payment_calender_detail WHERE id_ = #{id}
  31. </select>
  32. <!-- 全查询 -->
  33. <select id="findAll" resultMap="MusicGroupPaymentCalenderDetail">
  34. SELECT * FROM music_group_payment_calender_detail ORDER BY id_
  35. </select>
  36. <!-- 向数据库增加一条记录 -->
  37. <insert id="insert"
  38. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
  39. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  40. INSERT INTO music_group_payment_calender_detail
  41. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
  42. user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  43. VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},
  44. #{userStatus},#{payTime},#{updateTime},#{createTime},#{open},#{startPaymentDate},#{deadlinePaymentDate})
  45. </insert>
  46. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  47. INSERT INTO music_group_payment_calender_detail
  48. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
  49. payment_status_,user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  50. VALUES
  51. <foreach collection="list" item="item" separator=",">
  52. (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
  53. #{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},
  54. #{item.updateTime},#{item.createTime},#{item.open},#{item.startPaymentDate},#{item.deadlinePaymentDate})
  55. </foreach>
  56. </insert>
  57. <!-- 根据主键查询一条记录 -->
  58. <update id="update"
  59. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  60. UPDATE music_group_payment_calender_detail
  61. <set>
  62. <if test="startPaymentDate != null">
  63. start_payment_date_ = #{startPaymentDate},
  64. </if>
  65. <if test="deadlinePaymentDate != null">
  66. deadline_payment_date_ = #{deadlinePaymentDate},
  67. </if>
  68. <if test="open != null">
  69. open_ = #{open},
  70. </if>
  71. <if test="userId != null">
  72. user_id_ = #{userId},
  73. </if>
  74. <if test="userStatus != null">
  75. user_status_ = #{userStatus},
  76. </if>
  77. <if test="paymentStatus != null">
  78. payment_status_ = #{paymentStatus},
  79. </if>
  80. <if test="expectAmount != null">
  81. expect_amount_ = #{expectAmount},
  82. </if>
  83. <if test="updateTime != null">
  84. update_time_ = #{updateTime},
  85. </if>
  86. <if test="musicGroupPaymentCalenderId != null">
  87. music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
  88. </if>
  89. <if test="actualAmount != null">
  90. actual_amount_ = #{actualAmount},
  91. </if>
  92. <if test="payTime != null">
  93. pay_time_ = #{payTime},
  94. </if>
  95. </set>
  96. WHERE id_ = #{id}
  97. </update>
  98. <update id="batchUpdate">
  99. <foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
  100. UPDATE music_group_payment_calender_detail
  101. <set>
  102. <if test="item.open != null">
  103. open_ = #{item.open},
  104. </if>
  105. <if test="item.userId != null">
  106. user_id_ = #{item.userId},
  107. </if>
  108. <if test="item.userStatus != null">
  109. user_status_ = #{item.userStatus},
  110. </if>
  111. <if test="item.paymentStatus != null">
  112. payment_status_ = #{item.paymentStatus},
  113. </if>
  114. <if test="item.expectAmount != null">
  115. expect_amount_ = #{item.expectAmount},
  116. </if>
  117. <if test="item.updateTime != null">
  118. update_time_ = #{item.updateTime},
  119. </if>
  120. <if test="item.musicGroupPaymentCalenderId != null">
  121. music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
  122. </if>
  123. <if test="item.actualAmount != null">
  124. actual_amount_ = #{item.actualAmount},
  125. </if>
  126. <if test="item.payTime != null">
  127. pay_time_ = #{item.payTime}
  128. </if>
  129. </set>
  130. WHERE id_ = #{item.id}
  131. </foreach>
  132. </update>
  133. <!-- 根据主键删除一条记录 -->
  134. <delete id="delete">
  135. DELETE FROM music_group_payment_calender_detail WHERE id_ = #{id}
  136. </delete>
  137. <!-- 分页查询 -->
  138. <select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail"
  139. parameterType="map">
  140. SELECT mgpcd.*,su.username_,st.name_ subject_names_,sr.music_group_status_
  141. FROM music_group_payment_calender_detail mgpcd
  142. LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
  143. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  144. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  145. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  146. <where>
  147. mgpc.music_group_id_ = sr.music_group_id_
  148. <if test="userId != null">
  149. AND mgpcd.user_id_ = #{userId}
  150. </if>
  151. <if test="id != null">
  152. AND mgpcd.music_group_payment_calender_id_ = #{id}
  153. </if>
  154. <if test="paymentStatus != null">
  155. AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  156. </if>
  157. <if test="subjectId != null">
  158. AND #{subjectId} = sr.actual_subject_id_
  159. </if>
  160. </where>
  161. ORDER BY mgpc.create_time_
  162. <include refid="global.limit" />
  163. </select>
  164. <!-- 查询当前表的总记录数 -->
  165. <select id="queryCount" resultType="int">
  166. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
  167. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  168. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  169. <where>
  170. <if test="userId != null">
  171. AND mgpcd.user_id_ = #{userId}
  172. </if>
  173. <if test="id != null">
  174. AND mgpcd.music_group_payment_calender_id_ = #{id}
  175. </if>
  176. <if test="subjectId != null">
  177. AND #{subjectId} = sr.actual_subject_id_
  178. </if>
  179. <if test="paymentStatus != null">
  180. AND mgpcd.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  181. </if>
  182. </where>
  183. </select>
  184. <select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
  185. SELECT * FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{ids})
  186. </select>
  187. <select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
  188. SELECT * FROM music_group_payment_calender_detail where music_group_payment_calender_id_ = #{calenderId}
  189. </select>
  190. <select id="findMusicGroupStudentWithSubject" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
  191. SELECT DISTINCT su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
  192. from music_group_student_fee_ mgstf
  193. LEFT JOIN sys_user su ON su.id_=mgstf.user_id_
  194. WHERE mgstf.music_group_id_=#{musicGroupId}
  195. AND mgstf.subject_id_=#{subjectId}
  196. AND mgstf.remain_network_class_times_>0
  197. </select>
  198. <select id="sumActualAmount" resultType="java.math.BigDecimal">
  199. SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
  200. WHERE mgpcd.music_group_payment_calender_id_ = #{id} AND mgpcd.payment_status_ = "PAID_COMPLETED"
  201. </select>
  202. <select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
  203. SELECT * FROM music_group_payment_calender_detail mgpcd
  204. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  205. WHERE mgpc.music_group_id_=#{musicGroupId} AND mgpcd.user_id_=#{userId} AND mgpcd.payment_status_ = 'PROCESSING'
  206. ORDER BY mgpc.start_payment_date_ DESC
  207. </select>
  208. </mapper>