MusicGroupPaymentCalenderDetailMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  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. <result column="phone_" property="phone" />
  24. </association>
  25. <association property="studentRegistration" javaType="com.ym.mec.biz.dal.entity.StudentRegistration">
  26. <result column="subject_names_" property="subjectName" />
  27. <result column="music_group_status_" property="musicGroupStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. </association>
  29. </resultMap>
  30. <!-- 根据主键查询一条记录 -->
  31. <select id="get" resultMap="MusicGroupPaymentCalenderDetail">
  32. SELECT * FROM music_group_payment_calender_detail WHERE id_ = #{id}
  33. </select>
  34. <!-- 全查询 -->
  35. <select id="findAll" resultMap="MusicGroupPaymentCalenderDetail">
  36. SELECT * FROM music_group_payment_calender_detail ORDER BY id_
  37. </select>
  38. <!-- 向数据库增加一条记录 -->
  39. <insert id="insert"
  40. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail"
  41. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  42. INSERT INTO music_group_payment_calender_detail
  43. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
  44. user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  45. VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  46. #{userStatus},#{payTime},#{updateTime},#{createTime},#{open},#{startPaymentDate},#{deadlinePaymentDate})
  47. </insert>
  48. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  49. INSERT INTO music_group_payment_calender_detail
  50. (id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
  51. payment_status_,user_status_,pay_time_,update_time_,create_time_,open_,start_payment_date_,deadline_payment_date_)
  52. VALUES
  53. <foreach collection="list" item="item" separator=",">
  54. (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
  55. #{item.actualAmount},#{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.userStatus},#{item.payTime},
  56. #{item.updateTime},#{item.createTime},#{item.open},#{item.startPaymentDate},#{item.deadlinePaymentDate})
  57. </foreach>
  58. </insert>
  59. <!-- 根据主键查询一条记录 -->
  60. <update id="update"
  61. parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
  62. UPDATE music_group_payment_calender_detail
  63. <set>
  64. <if test="startPaymentDate != null">
  65. start_payment_date_ = #{startPaymentDate},
  66. </if>
  67. <if test="deadlinePaymentDate != null">
  68. deadline_payment_date_ = #{deadlinePaymentDate},
  69. </if>
  70. <if test="open != null">
  71. open_ = #{open},
  72. </if>
  73. <if test="userId != null">
  74. user_id_ = #{userId},
  75. </if>
  76. <if test="userStatus != null">
  77. user_status_ = #{userStatus},
  78. </if>
  79. <if test="paymentStatus != null">
  80. payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  81. </if>
  82. <if test="expectAmount != null">
  83. expect_amount_ = #{expectAmount},
  84. </if>
  85. <if test="updateTime != null">
  86. update_time_ = #{updateTime},
  87. </if>
  88. <if test="musicGroupPaymentCalenderId != null">
  89. music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
  90. </if>
  91. <if test="actualAmount != null">
  92. actual_amount_ = #{actualAmount},
  93. </if>
  94. <if test="payTime != null">
  95. pay_time_ = #{payTime},
  96. </if>
  97. </set>
  98. WHERE id_ = #{id}
  99. </update>
  100. <update id="batchUpdate">
  101. <foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
  102. UPDATE music_group_payment_calender_detail
  103. <set>
  104. <if test="item.startPaymentDate != null">
  105. start_payment_date_ = #{item.startPaymentDate},
  106. </if>
  107. <if test="item.deadlinePaymentDate != null">
  108. deadline_payment_date_ = #{item.deadlinePaymentDate},
  109. </if>
  110. <if test="item.open != null">
  111. open_ = #{item.open},
  112. </if>
  113. <if test="item.userId != null">
  114. user_id_ = #{item.userId},
  115. </if>
  116. <if test="item.userStatus != null">
  117. user_status_ = #{item.userStatus},
  118. </if>
  119. <if test="item.paymentStatus != null">
  120. payment_status_ = #{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  121. </if>
  122. <if test="item.expectAmount != null">
  123. expect_amount_ = #{item.expectAmount},
  124. </if>
  125. <if test="item.updateTime != null">
  126. update_time_ = #{item.updateTime},
  127. </if>
  128. <if test="item.musicGroupPaymentCalenderId != null">
  129. music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
  130. </if>
  131. <if test="item.actualAmount != null">
  132. actual_amount_ = #{item.actualAmount},
  133. </if>
  134. <if test="item.payTime != null">
  135. pay_time_ = #{item.payTime}
  136. </if>
  137. </set>
  138. WHERE id_ = #{item.id}
  139. </foreach>
  140. </update>
  141. <update id="refreshUserMusicGroupPaymentStatusTask">
  142. UPDATE music_group_payment_calender_detail mgpcd
  143. SET mgpcd.open_ = 0,mgpcd.start_payment_date_ = NULL,mgpcd.deadline_payment_date_ = NULL
  144. WHERE mgpcd.deadline_payment_date_ &lt; DATE_FORMAT(NOW(),'%Y-%m-%d')
  145. </update>
  146. <!-- 根据主键删除一条记录 -->
  147. <delete id="delete">
  148. DELETE FROM music_group_payment_calender_detail WHERE id_ = #{id}
  149. </delete>
  150. <!-- 分页查询 -->
  151. <select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail"
  152. parameterType="map">
  153. SELECT mgpcd.*,su.username_,su.phone_,st.name_ subject_names_,sr.music_group_status_
  154. FROM music_group_payment_calender_detail mgpcd
  155. LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
  156. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  157. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  158. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  159. <where>
  160. mgpc.music_group_id_ = sr.music_group_id_
  161. <if test="search != null and search != ''">
  162. AND (mgpcd.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  163. </if>
  164. <if test="id != null">
  165. AND mgpcd.music_group_payment_calender_id_ = #{id}
  166. </if>
  167. <if test="paymentStatus != null and paymentStatus != ''">
  168. AND mgpcd.payment_status_ = #{paymentStatus}
  169. </if>
  170. <if test="musicGroupStatus != null and musicGroupStatus != ''">
  171. AND sr.music_group_status_ = #{musicGroupStatus}
  172. </if>
  173. <if test="subjectId != null">
  174. AND #{subjectId} = sr.actual_subject_id_
  175. </if>
  176. </where>
  177. ORDER BY mgpc.update_time_ DESC
  178. <include refid="global.limit" />
  179. </select>
  180. <!-- 查询当前表的总记录数 -->
  181. <select id="queryCount" resultType="int">
  182. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
  183. LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_
  184. LEFT JOIN `subject` st ON st.id_ = sr.actual_subject_id_
  185. LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
  186. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  187. <where>
  188. mgpc.music_group_id_ = sr.music_group_id_
  189. <if test="search != null and search != ''">
  190. AND (mgpcd.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  191. </if>
  192. <if test="id != null">
  193. AND mgpcd.music_group_payment_calender_id_ = #{id}
  194. </if>
  195. <if test="subjectId != null">
  196. AND #{subjectId} = sr.actual_subject_id_
  197. </if>
  198. <if test="paymentStatus != null and paymentStatus != ''">
  199. AND mgpcd.payment_status_ = #{paymentStatus}
  200. </if>
  201. <if test="musicGroupStatus != null and musicGroupStatus != ''">
  202. AND sr.music_group_status_ = #{musicGroupStatus}
  203. </if>
  204. </where>
  205. </select>
  206. <select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
  207. SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
  208. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  209. WHERE FIND_IN_SET(mgpcd.id_,#{ids})
  210. GROUP BY mgpcd.id_
  211. </select>
  212. <select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
  213. SELECT * FROM music_group_payment_calender_detail where music_group_payment_calender_id_ = #{calenderId}
  214. </select>
  215. <select id="findMusicGroupStudentWithSubject" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
  216. SELECT DISTINCT su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
  217. from music_group_student_fee_ mgstf
  218. LEFT JOIN sys_user su ON su.id_=mgstf.user_id_
  219. WHERE mgstf.music_group_id_=#{musicGroupId}
  220. AND mgstf.subject_id_=#{subjectId}
  221. AND mgstf.remain_network_class_times_>0
  222. ORDER BY su.id_
  223. </select>
  224. <select id="sumActualAmount" resultType="java.math.BigDecimal">
  225. SELECT SUM(mgpcd.actual_amount_) FROM music_group_payment_calender_detail mgpcd
  226. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  227. </select>
  228. <select id="getUserLastCalenderDetail" resultMap="MusicGroupPaymentCalenderDetail">
  229. SELECT * 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} AND mgpcd.payment_status_ = 'NON_PAYMENT'
  232. AND (mgpc.payment_status_ = '1' OR mgpcd.open_=1)
  233. ORDER BY mgpc.start_payment_date_ DESC LIMIT 1
  234. </select>
  235. <select id="queryCanOpenList" resultMap="MusicGroupPaymentCalenderDetail">
  236. SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
  237. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  238. LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
  239. WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND (mgpcd.open_ = 0 OR mgpcd.open_ IS NULL) AND sr.music_group_status_ != 'QUIT' AND mgpc.payment_status_ = 2
  240. AND FIND_IN_SET(mgpcd.id_,#{ids})
  241. GROUP BY mgpcd.id_
  242. </select>
  243. <select id="queryIntersectionByPaymentDate" resultType="java.lang.Integer">
  244. SELECT COUNT(mgpcd.id_) FROM music_group_payment_calender_detail mgpcd
  245. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  246. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.user_id_ = #{userId}
  247. AND mgpcd.open_ = 1
  248. </select>
  249. <select id="queryCanPushList" resultMap="MusicGroupPaymentCalenderDetail">
  250. SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender_detail mgpcd
  251. LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  252. LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_
  253. WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND sr.music_group_status_ != 'QUIT' AND mgpc.id_ = #{musicGroupPaymentCalenderId}
  254. GROUP BY mgpcd.id_
  255. </select>
  256. <select id="queryNoPaymentCanPushList" resultMap="MusicGroupPaymentCalenderDetail">
  257. SELECT mgpcd.*,mgpc.music_group_id_ FROM music_group_payment_calender mgpc
  258. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  259. WHERE mgpc.create_time_ = DATE_FORMAT(NOW(),'%Y-%m-%d') AND mgpc.payment_status_ = 1 AND mgpcd.payment_status_ = 'NON_PAYMENT'
  260. </select>
  261. </mapper>