MusicGroupPaymentCalenderMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  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. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" id="MusicGroupPaymentCalender">
  9. <result column="id_" property="id"/>
  10. <result column="music_group_id_" property="musicGroupId"/>
  11. <result column="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingId"/>
  12. <result column="pay_user_type_" property="payUserType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="start_payment_date_" property="startPaymentDate"/>
  14. <result column="deadline_payment_date_" property="deadlinePaymentDate"/>
  15. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  16. <result column="expect_num_" property="expectNum"/>
  17. <result column="actual_num_" property="actualNum"/>
  18. <result column="memo_" property="memo"/>
  19. <result column="audit_memo_" property="auditMemo"/>
  20. <result column="reject_reason_" property="rejectReason"/>
  21. <result column="is_give_music_network_" property="isGiveMusicNetwork"/>
  22. <result column="create_time_" property="createTime"/>
  23. <result column="update_time_" property="updateTime"/>
  24. <result column="payment_valid_start_date_" property="paymentValidStartDate"/>
  25. <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
  26. <result column="payment_pattern_" property="paymentPattern"/>
  27. <result column="payment_type_" property="paymentType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <result column="batch_no_" property="batchNo"/>
  29. <result column="payment_amount_" property="paymentAmount"/>
  30. <result column="attribute1_" property="attribute1"/>
  31. <result column="attribute2_" property="attribute2"/>
  32. <result column="student_ids_" property="studentIds"/>
  33. <result column="member_payment_amount_" property="memberPaymentAmount"/>
  34. <result column="original_member_payment_amount_" property="originalMemberPaymentAmount"/>
  35. <result column="member_rank_setting_id_" property="memberRankSettingId"/>
  36. <result column="member_valid_date_" property="memberValidDate"/>
  37. <result column="member_period_" property="memberPeriod" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  38. <result column="member_optional_flag_" property="memberOptionalFlag"/>
  39. <result column="music_repair_num_" property="musicRepairNum"/>
  40. <result column="music_repair_actual_price_" property="musicRepairActualPrice"/>
  41. <result column="music_repair_optional_flag_" property="musicRepairOptionalFlag"/>
  42. <result column="current_total_amount_" property="currentTotalAmount"/>
  43. <result column="original_total_amount_" property="originalTotalAmount"/>
  44. </resultMap>
  45. <!-- 根据主键查询一条记录 -->
  46. <select id="get" resultMap="MusicGroupPaymentCalender">
  47. SELECT * FROM music_group_payment_calender WHERE id_ = #{id}
  48. </select>
  49. <!-- 全查询 -->
  50. <select id="findAll" resultMap="MusicGroupPaymentCalender">
  51. SELECT * FROM music_group_payment_calender ORDER BY id_
  52. </select>
  53. <!-- 向数据库增加一条记录 -->
  54. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  55. keyColumn="id_" keyProperty="id">
  56. INSERT INTO music_group_payment_calender
  57. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  58. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
  59. payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,
  60. attribute2_,student_ids_,member_payment_amount_,member_rank_setting_id_,member_valid_date_
  61. ,original_member_payment_amount_,member_period_,member_optional_flag_,
  62. music_repair_num_,music_repair_actual_price_,music_repair_optional_flag_,current_total_amount_,original_total_amount_)
  63. VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  64. #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  65. #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
  66. #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  67. #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds},
  68. #{memberPaymentAmount},#{memberRankSettingId},#{memberValidDate},#{originalMemberPaymentAmount},#{memberPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  69. #{memberOptionalFlag},#{musicRepairNum},#{musicRepairActualPrice},#{musicRepairOptionalFlag},#{currentTotalAmount},#{originalTotalAmount})
  70. </insert>
  71. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  72. keyColumn="id_" keyProperty="id">
  73. INSERT INTO music_group_payment_calender
  74. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  75. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
  76. payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_,
  77. member_payment_amount_,member_rank_setting_id_,member_valid_date_,original_member_payment_amount_,member_period_
  78. ,member_optional_flag_,music_repair_num_,music_repair_actual_price_,music_repair_optional_flag_,current_total_amount_,original_total_amount_)
  79. VALUES
  80. <foreach collection="list" item="item" index="index" separator=",">
  81. (#{item.musicGroupId},#{item.musicGroupOrganizationCourseSettingId},#{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.rejectReason},#{item.startPaymentDate},#{item.deadlinePaymentDate},#{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  82. #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
  83. #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  84. #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2},
  85. #{item.studentIds},#{item.memberPaymentAmount},#{item.memberRankSettingId},#{item.memberValidDate},#{item.originalMemberPaymentAmount},#{item.memberPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. #{item.memberOptionalFlag},#{item.musicRepairNum},#{item.musicRepairActualPrice},#{item.musicRepairOptionalFlag},#{item.currentTotalAmount},#{item.originalTotalAmount})
  87. </foreach>
  88. </insert>
  89. <!-- 根据主键查询一条记录 -->
  90. <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  91. UPDATE music_group_payment_calender
  92. <set>
  93. <if test="currentTotalAmount != null">
  94. current_total_amount_ = #{currentTotalAmount},
  95. </if>
  96. <if test="originalTotalAmount != null">
  97. original_total_amount_ = #{originalTotalAmount},
  98. </if>
  99. <if test="memberOptionalFlag != null">
  100. member_optional_flag_ = #{memberOptionalFlag},
  101. </if>
  102. <if test="musicRepairNum != null">
  103. music_repair_num_ = #{musicRepairNum},
  104. </if>
  105. <if test="musicRepairActualPrice != null">
  106. music_repair_actual_price_ = #{musicRepairActualPrice},
  107. </if>
  108. <if test="musicRepairOptionalFlag != null">
  109. music_repair_optional_flag_ = #{musicRepairOptionalFlag},
  110. </if>
  111. <if test="memberPeriod != null">
  112. member_period_ = #{memberPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  113. </if>
  114. <if test="originalMemberPaymentAmount != null">
  115. original_member_payment_amount_ = #{originalMemberPaymentAmount},
  116. </if>
  117. <if test="memberPaymentAmount != null">
  118. member_payment_amount_ = #{memberPaymentAmount},
  119. </if>
  120. <if test="memberRankSettingId != null">
  121. member_rank_setting_id_ = #{memberRankSettingId},
  122. </if>
  123. <if test="memberValidDate != null">
  124. member_valid_date_ = #{memberValidDate},
  125. </if>
  126. <if test="studentIds != null and studentIds != ''">
  127. student_ids_ = #{studentIds},
  128. </if>
  129. <if test="auditMemo != null and auditMemo != ''">
  130. audit_memo_ = #{auditMemo},
  131. </if>
  132. <if test="paymentType != null">
  133. payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  134. </if>
  135. <if test="paymentValidStartDate != null">
  136. payment_valid_start_date_ = #{paymentValidStartDate},
  137. payment_valid_end_date_ = #{paymentValidEndDate},
  138. </if>
  139. <if test="paymentPattern != null">
  140. payment_pattern_ = #{paymentPattern},
  141. </if>
  142. <if test="isGiveMusicNetwork != null">
  143. is_give_music_network_ = #{isGiveMusicNetwork},
  144. </if>
  145. <if test="deadlinePaymentDate != null">
  146. deadline_payment_date_ = #{deadlinePaymentDate},
  147. </if>
  148. <if test="status != null">
  149. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  150. </if>
  151. <if test="expectNum != null">
  152. expect_num_ = #{expectNum},
  153. </if>
  154. <if test="actualNum != null">
  155. actual_num_ = #{actualNum},
  156. </if>
  157. <if test="memo != null">
  158. memo_ = #{memo},
  159. </if>
  160. <if test="startPaymentDate != null">
  161. start_payment_date_ = #{startPaymentDate},
  162. </if>
  163. <if test="musicGroupOrganizationCourseSettingId != null">
  164. music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingId},
  165. </if>
  166. <if test="payUserType != null">
  167. pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  168. </if>
  169. <if test="rejectReason != null">
  170. reject_reason_ = #{rejectReason},
  171. </if>
  172. <if test="updateTime != null">
  173. update_time_ = NOW(),
  174. </if>
  175. <if test="musicGroupId != null">
  176. music_group_id_ = #{musicGroupId},
  177. </if>
  178. <if test="batchNo != null">
  179. batch_no_ = #{batchNo},
  180. </if>
  181. <if test="paymentAmount != null">
  182. payment_amount_ = #{paymentAmount},
  183. </if>
  184. <if test="attribute1 != null">
  185. attribute1_ = #{attribute1},
  186. </if>
  187. <if test="attribute2 != null">
  188. attribute2_ = #{attribute2},
  189. </if>
  190. </set>
  191. WHERE id_ = #{id}
  192. </update>
  193. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  194. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  195. UPDATE music_group_payment_calender
  196. <set>
  197. <if test="item.currentTotalAmount != null">
  198. current_total_amount_ = #{item.currentTotalAmount},
  199. </if>
  200. <if test="item.originalTotalAmount != null">
  201. original_total_amount_ = #{item.originalTotalAmount},
  202. </if>
  203. <if test="item.originalMemberPaymentAmount != null">
  204. original_member_payment_amount_ = #{item.originalMemberPaymentAmount},
  205. </if>
  206. <if test="item.memberPaymentAmount != null">
  207. member_payment_amount_ = #{item.memberPaymentAmount},
  208. </if>
  209. <if test="item.memberRankSettingId != null">
  210. member_rank_setting_id_ = #{item.memberRankSettingId},
  211. </if>
  212. <if test="item.memberValidDate != null">
  213. member_valid_date_ = #{item.memberValidDate},
  214. </if>
  215. <if test="item.studentIds != null and item.studentIds != ''">
  216. student_ids_ = #{item.studentIds},
  217. </if>
  218. <if test="item.paymentPattern != null">
  219. payment_pattern_ = #{item.paymentPattern},
  220. </if>
  221. <if test="item.isGiveMusicNetwork != null">
  222. is_give_music_network_ = #{item.isGiveMusicNetwork},
  223. </if>
  224. <if test="item.deadlinePaymentDate != null">
  225. deadline_payment_date_ = #{item.deadlinePaymentDate},
  226. </if>
  227. <if test="item.status != null">
  228. status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  229. </if>
  230. <if test="item.expectNum != null">
  231. expect_num_ = #{item.expectNum},
  232. </if>
  233. <if test="item.actualNum != null">
  234. actual_num_ = #{item.actualNum},
  235. </if>
  236. <if test="item.memo != null">
  237. memo_ = #{item.memo},
  238. </if>
  239. <if test="item.auditMemo != null">
  240. audit_memo_ = #{item.auditMemo},
  241. </if>
  242. <if test="item.startPaymentDate != null">
  243. start_payment_date_ = #{item.startPaymentDate},
  244. </if>
  245. <if test="item.musicGroupOrganizationCourseSettingId != null">
  246. music_group_organization_course_settings_id_ = #{item.musicGroupOrganizationCourseSettingId},
  247. </if>
  248. <if test="item.payUserType != null">
  249. pay_user_type_ = #{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  250. </if>
  251. <if test="item.rejectReason != null">
  252. reject_reason_ = #{item.rejectReason},
  253. </if>
  254. <if test="item.updateTime != null">
  255. update_time_ = NOW(),
  256. </if>
  257. <if test="item.musicGroupId != null">
  258. music_group_id_ = #{item.musicGroupId},
  259. </if>
  260. <if test="item.batchNo != null">
  261. batch_no_ = #{item.batchNo},
  262. </if>
  263. <if test="item.paymentAmount != null">
  264. payment_amount_ = #{item.paymentAmount},
  265. </if>
  266. <if test="item.attribute1 != null">
  267. attribute1_ = #{item.attribute1},
  268. </if>
  269. <if test="item.attribute2 != null">
  270. attribute2_ = #{item.attribute2},
  271. </if>
  272. </set>
  273. WHERE id_ = #{item.id}
  274. </foreach>
  275. </update>
  276. <update id="cutCalenderExpectNum">
  277. UPDATE music_group_payment_calender
  278. SET expect_num_ = expect_num_ - 1
  279. WHERE id_ IN (SELECT music_group_payment_calender_id_ FROM music_group_payment_calender_detail
  280. WHERE user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT')
  281. AND expect_num_ > 0 AND music_group_id_ = #{musicGroupId}
  282. </update>
  283. <select id="findStudentNoPaymentCalender" resultType="java.lang.Long">
  284. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  285. WHERE mgpc.student_ids_ = #{userId} AND mgpc.payment_type_ = 'ADD_STUDENT'
  286. AND mgpc.music_group_id_ = #{musicGroupId} AND status_ in ('AUDITING','REJECT')
  287. </select>
  288. <!-- 根据主键删除一条记录 -->
  289. <delete id="delete">
  290. DELETE FROM music_group_payment_calender WHERE id_ = #{id}
  291. </delete>
  292. <!-- 根据主键删除一条记录 -->
  293. <delete id="delByIds">
  294. DELETE FROM music_group_payment_calender WHERE id_ IN
  295. <foreach collection="calenderIds" item="item" separator="," open="(" close=")">
  296. #{item}
  297. </foreach>
  298. </delete>
  299. <delete id="delByGroupId">
  300. DELETE FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId}
  301. </delete>
  302. <!-- 分页查询 -->
  303. <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
  304. SELECT * FROM music_group_payment_calender mgpc
  305. <include refid="queryPageSql"/>
  306. ORDER BY mgpc.payment_valid_start_date_,mgpc.id_ DESC
  307. <include refid="global.limit"/>
  308. </select>
  309. <sql id="queryPageSql">
  310. <where>
  311. <if test="musicGroupId != null">
  312. AND mgpc.music_group_id_ = #{musicGroupId}
  313. </if>
  314. <if test="batchNo != null">
  315. AND mgpc.batch_no_ = #{batchNo}
  316. </if>
  317. <if test="payUserType != null">
  318. AND mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  319. </if>
  320. <if test="paymentType != null">
  321. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  322. </if>
  323. <if test="status != null">
  324. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  325. </if>
  326. </where>
  327. </sql>
  328. <!-- 查询当前表的总记录数 -->
  329. <select id="queryCount" resultType="int">
  330. SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
  331. <include refid="queryPageSql"/>
  332. </select>
  333. <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
  334. SELECT * FROM music_group_payment_calender mgpc
  335. WHERE music_group_id_ = #{musicGroupId}
  336. ORDER BY id_
  337. </select>
  338. <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
  339. SELECT * FROM music_group_payment_calender mgpc
  340. <where>
  341. <if test="status != null">
  342. status_ in
  343. <foreach collection="status" item="item" open="(" close=")" separator=",">
  344. #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  345. </foreach>
  346. </if>
  347. <if test="payUserType != null">
  348. AND pay_user_type_ = #{payUserType}
  349. </if>
  350. <if test="musicGroupId != null">
  351. AND music_group_id_ = #{musicGroupId}
  352. </if>
  353. </where>
  354. </select>
  355. <select id="getForLock" resultMap="MusicGroupPaymentCalender">
  356. SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
  357. </select>
  358. <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
  359. SELECT count(*) FROM music_group_payment_calender mgpc
  360. WHERE music_group_id_ = #{musicGroupId}
  361. and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
  362. or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
  363. <if test="calenderId != null">
  364. AND mgpc.id_ != #{calenderId}
  365. </if>
  366. </select>
  367. <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
  368. SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
  369. </select>
  370. <select id="queryIntersectionByDate" resultType="java.lang.Integer">
  371. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender mgpc
  372. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  373. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.payment_status_ != 'PAID_COMPLETED'
  374. AND (DATE_FORMAT(mgpcd.start_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime}
  375. OR DATE_FORMAT(mgpcd.deadline_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime})
  376. </select>
  377. <select id="queryIntersectionByValidDate" resultType="java.lang.Integer">
  378. SELECT COUNT(*) FROM music_group_payment_calender mgpc
  379. WHERE music_group_id_ = #{musicGroupId}
  380. AND (payment_valid_end_date_ IS NULL OR payment_valid_start_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}
  381. OR payment_valid_end_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}) AND payment_valid_start_date_ IS NOT NULL
  382. AND mgpc.payment_type_ NOT IN ('SPAN_GROUP_CLASS_ADJUST','ADD_STUDENT','ADD_COURSE') AND mgpc.batch_no_ IS NOT NULL
  383. <if test="payUserType != null">
  384. and pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  385. </if>
  386. <if test="calenderId != null">
  387. AND mgpc.id_ != #{calenderId}
  388. </if>
  389. </select>
  390. <select id="queryCalenderByDay" resultType="java.util.Map">
  391. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(mgpcd.payment_status_) 'value'
  392. FROM music_group_payment_calender_detail mgpcd
  393. WHERE mgpcd.music_group_payment_calender_id_ IN
  394. (SELECT id_ FROM music_group_payment_calender WHERE status_ != 0
  395. AND DATEDIFF(#{format},DATE_FORMAT(start_payment_date_,'%Y-%m-%d')) = #{configValue})
  396. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  397. GROUP BY mgpcd.music_group_payment_calender_id_
  398. </select>
  399. <select id="queryByIds" resultMap="MusicGroupPaymentCalender">
  400. SELECT * FROM music_group_payment_calender WHERE id_ IN
  401. <foreach collection="calenderId" open="(" close=")" item="item" separator=",">
  402. #{item}
  403. </foreach>
  404. </select>
  405. <select id="queryEndIds" resultType="java.lang.Long">
  406. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  407. WHERE mgpc.payment_valid_end_date_ IS NOT NULL AND DATEDIFF(mgpc.payment_valid_end_date_,#{format}) = #{configValue}
  408. AND mgpc.payment_type_ IN ('MUSIC_APPLY','MUSIC_RENEW')
  409. <if test="musicGroupIds != null">
  410. AND mgpc.music_group_id_ IN
  411. <foreach collection="musicGroupIds" open="(" close=")" item="item" separator=",">
  412. #{item}
  413. </foreach>
  414. </if>
  415. </select>
  416. <resultMap id="CalenderPushDto" type="com.ym.mec.biz.dal.dto.CalenderPushDto">
  417. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  418. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  419. <result property="teacherId" column="educational_teacher_id_"/>
  420. <result property="musicGroupName" column="name_"/>
  421. <result property="teacherPhone" column="phone_"/>
  422. <result property="calenderId" column="id_"/>
  423. </resultMap>
  424. <select id="getCalenderPushDto" resultMap="CalenderPushDto">
  425. SELECT mgpc.id_,mgpc.payment_valid_start_date_,mgpc.payment_valid_end_date_,
  426. mg.educational_teacher_id_,mg.name_,su.phone_
  427. FROM music_group_payment_calender mgpc
  428. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  429. LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
  430. WHERE mgpc.id_ IN
  431. <foreach collection="calenderIds" open="(" close=")" separator="," item="item">
  432. #{item}
  433. </foreach>
  434. </select>
  435. <select id="getMusicCalenderPushDto" resultMap="CalenderPushDto">
  436. SELECT mg.payment_valid_start_date_,mg.payment_valid_end_date_,
  437. mg.educational_teacher_id_,su.phone_,mg.name_ FROM music_group mg
  438. LEFT JOIN sys_user su ON mg.educational_teacher_id_ = su.id_
  439. WHERE mg.payment_valid_end_date_ IS NOT NULL AND
  440. DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
  441. </select>
  442. <select id="getMusicGroupUnusedFirstPaymentCalender" resultMap="MusicGroupPaymentCalender">
  443. SELECT
  444. mgpc.*
  445. FROM
  446. music_group_payment_calender_detail mgpcd
  447. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  448. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  449. WHERE
  450. mgpcd.music_group_payment_calender_id_ = mgpccs.music_group_payment_calender_id_
  451. AND mgpc.music_group_id_ = #{musicGroupId}
  452. AND mgpcd.use_in_course_ = 0
  453. AND mgpcd.user_id_ IN
  454. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  455. #{studentId}
  456. </foreach>
  457. ORDER BY
  458. mgpc.payment_valid_start_date_
  459. LIMIT 1;
  460. </select>
  461. <select id="getUnusedFirstPaymentCalenderWithCalenders" resultMap="MusicGroupPaymentCalender">
  462. SELECT * FROM music_group_payment_calender mgpc
  463. WHERE id_ IN
  464. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  465. #{calenderId}
  466. </foreach>
  467. ORDER BY create_time_ LIMIT 1;
  468. </select>
  469. <select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
  470. SELECT * FROM music_group_payment_calender WHERE FIND_IN_SET(batch_no_,#{batchNo})
  471. </select>
  472. <resultMap id="MusicGroupPaymentCalenderAuditDtoMap" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto">
  473. <result property="musicGroupId" column="music_group_id_"/>
  474. <result column="music_group_organization_course_settings_id_" property="musicGroupOrganizationCourseSettingsId" />
  475. <result property="batchNo" column="batch_no_"/>
  476. <result property="musicGroupName" column="music_group_name_"/>
  477. <result property="organId" column="organ_id_"/>
  478. <result property="organName" column="organ_name_"/>
  479. <result property="createTime" column="create_time_"/>
  480. <result property="paymentType" column="payment_type_"/>
  481. <result property="memo" column="memo_"/>
  482. <result property="operator" column="operator_"/>
  483. <result property="auditStatus" column="status_"/>
  484. <result property="addCourseTotalTime" column="course_total_minuties_"/>
  485. <result property="courseCurrentPrice" column="course_current_price_"/>
  486. <result property="courseOriginalPrice" column="course_original_price_"/>
  487. <result property="musicGroupPaymentCalenderId" column="id_"/>
  488. <result property="payUserType" column="pay_user_type_"/>
  489. <result property="calenderSettingsName" column="calender_settings_name_"/>
  490. <result property="paymentPattern" column="payment_pattern_"/>
  491. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  492. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  493. <result property="startPaymentDate" column="start_payment_date_"/>
  494. <result property="deadlinePaymentDate" column="deadline_payment_date_"/>
  495. <result property="auditMemo" column="audit_memo_"/>
  496. <result property="paymentAmount" column="payment_amount_"/>
  497. <result property="isGiveMusicNetwork" column="is_give_music_network_"/>
  498. <result property="memberPaymentAmount" column="member_payment_amount_"/>
  499. <result property="originalMemberPaymentAmount" column="original_member_payment_amount_"/>
  500. </resultMap>
  501. <sql id="MusicGroupPaymentCalenderAuditDtoSql">
  502. <where>
  503. mgpc.batch_no_ IS NOT NULL
  504. <if test="paymentType != null">
  505. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  506. </if>
  507. <if test="payUserType != null">
  508. AND mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  509. </if>
  510. <if test="status != null">
  511. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  512. </if>
  513. <if test="organId != null and organId != ''">
  514. AND FIND_IN_SET(mg.organ_id_,#{organId})
  515. </if>
  516. <if test="search != null and search != ''">
  517. AND (mg.id_ LIKE CONCAT('%',#{search},'%') OR mg.name_ LIKE CONCAT('%',#{search},'%'))
  518. </if>
  519. </where>
  520. </sql>
  521. <select id="countAuditList" resultType="java.lang.Integer">
  522. SELECT COUNT(DISTINCT mgpc.batch_no_)
  523. FROM music_group_payment_calender mgpc
  524. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  525. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  526. </select>
  527. <select id="queryAuditList" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  528. SELECT mgpc.batch_no_,MAX(mgpc.music_group_id_) music_group_id_
  529. ,MAX(mgpc.create_time_) create_time_,MIN(mgpc.payment_type_) payment_type_,MAX(mgpc.operator_) operator_,
  530. MAX(mgpc.pay_user_type_) pay_user_type_,MAX(mgpc.memo_) memo_,MAX(mgpc.audit_memo_) audit_memo_,MAX(mgpc.status_) status_,
  531. CASE WHEN MAX(mgpc.payment_type_) = 'SPAN_GROUP_CLASS_ADJUST' THEN MAX(mgsca.master_class_course_times_) ELSE SUM(mgpccs.course_total_minuties_) END course_total_minuties_,
  532. CASE WHEN MAX(mgpc.payment_type_) = 'SPAN_GROUP_CLASS_ADJUST' THEN MAX(mgpc.payment_amount_) ELSE SUM(mgpccs.course_original_price_) END course_original_price_,
  533. SUM(mgpccs.course_current_price_) course_current_price_,
  534. mgpc.member_payment_amount_,
  535. mgpc.original_member_payment_amount_,
  536. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,MAX(mgpc.payment_pattern_)payment_pattern_
  537. FROM music_group_payment_calender mgpc
  538. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  539. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  540. LEFT JOIN music_group_student_class_adjust mgsca ON mgsca.batch_no_ = mgpc.batch_no_
  541. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  542. GROUP BY mgpc.batch_no_
  543. ORDER BY create_time_ DESC
  544. <include refid="global.limit"/>
  545. </select>
  546. <select id="countExpectNum" resultType="java.util.Map">
  547. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  548. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  549. GROUP BY mgpcd.music_group_payment_calender_id_
  550. </select>
  551. <select id="countActualNum" resultType="java.util.Map">
  552. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  553. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  554. AND mgpcd.payment_status_ = 'PAID_COMPLETED'
  555. GROUP BY mgpcd.music_group_payment_calender_id_
  556. </select>
  557. <select id="getAuditDetail" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  558. SELECT mgpc.batch_no_,MAX(mgpc.music_group_id_) music_group_id_
  559. ,MAX(mgpc.create_time_) create_time_,MAX(mgpc.payment_type_) payment_type_,MAX(mgpc.music_group_organization_course_settings_id_) music_group_organization_course_settings_id_,
  560. MAX(mgpc.pay_user_type_) pay_user_type_,MAX(mg.name_) music_group_name_,MAX(mgpc.payment_pattern_)payment_pattern_,MAX(o.name_) organ_name_
  561. FROM music_group_payment_calender mgpc
  562. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  563. LEFT JOIN organization o ON o.id_ = mg.organ_id_
  564. WHERE mgpc.batch_no_ = #{batchNo}
  565. GROUP BY mgpc.batch_no_
  566. </select>
  567. <select id="findByMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  568. SELECT * FROM music_group_payment_calender WHERE music_group_id_=#{musicGroupId} AND payment_type_='MUSIC_APPLY'
  569. </select>
  570. <select id="getCalenderSettingsName" resultType="java.lang.String">
  571. SELECT name_ FROM music_group_payment_calender_course_settings
  572. WHERE music_group_payment_calender_id_ = #{calenderId} LIMIT 1
  573. </select>
  574. <select id="countAuditReject" resultType="java.lang.Integer">
  575. SELECT COUNT(0) FROM music_group_payment_calender
  576. WHERE music_group_id_ = #{musicGroupId} AND payment_type_='MUSIC_APPLY' AND status_ IN ('REJECT','AUDITING')
  577. <if test="calenderId != null">
  578. AND id_ != #{calenderId}
  579. </if>
  580. </select>
  581. <select id="getMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  582. SELECT * FROM music_group_payment_calender
  583. WHERE music_group_id_ = #{musicGroupId}
  584. AND payment_type_ = 'MUSIC_APPLY'
  585. AND pay_user_type_='STUDENT'
  586. </select>
  587. <select id="queryUserPaymentStatus" resultType="java.util.Map">
  588. SELECT mg.id_ 'key',CASE WHEN MIN(mgpcd.payment_status_) IS NULL THEN 'PAID_COMPLETED' ELSE MIN(mgpcd.payment_status_) END 'value'
  589. FROM music_group mg
  590. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  591. AND mgpc.status_ IN ('NO','OPEN','OVER')
  592. AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(mgpc.payment_valid_start_date_,'%Y-%m-%d')
  593. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_ AND mgpcd.user_id_ = #{userId}
  594. WHERE FIND_IN_SET(mg.id_,#{musicGroupId}) AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
  595. GROUP BY mg.id_
  596. </select>
  597. <select id="queryUserCoursePaymentStatus" resultType="java.util.Map">
  598. SELECT mgpcd.user_id_ 'key',
  599. CASE WHEN MIN(mgpcd.payment_status_) IS NULL THEN 'PAID_COMPLETED' ELSE MIN(mgpcd.payment_status_) END 'value'
  600. FROM music_group mg
  601. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  602. AND mgpc.status_ IN ('NO','OPEN','OVER')
  603. AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(mgpc.payment_valid_start_date_,'%Y-%m-%d')
  604. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  605. WHERE mg.id_ = #{musicGroupId} AND mgpcd.expect_amount_ > 0 AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT' AND mgpcd.user_id_ IN
  606. <foreach collection="studentId" item="item" separator="," open="(" close=")">
  607. #{item}
  608. </foreach>
  609. GROUP BY mgpcd.user_id_
  610. </select>
  611. <select id="findByBatchNoAndStudentId" resultType="Long">
  612. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  613. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  614. WHERE FIND_IN_SET(batch_no_,#{batchNo}) AND mgpcd.user_id_ = #{studentId}
  615. </select>
  616. <select id="getPaymentCalenderWithCalenderIdsAndPayUserType" resultMap="MusicGroupPaymentCalender">
  617. SELECT * FROM music_group_payment_calender
  618. WHERE id_ IN
  619. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  620. #{calenderId}
  621. </foreach>
  622. AND pay_user_type_ = #{payUserType}
  623. AND status_ IN ('NO', 'OPEN', 'OVER', 'PAID');
  624. </select>
  625. <select id="getSchoolCalender" resultMap="MusicGroupPaymentCalender">
  626. SELECT * FROM music_group_payment_calender WHERE id_ = #{calenderId} AND status_ IN ('NO', 'OPEN', 'OVER', 'PAID');
  627. </select>
  628. <select id="queryMusicGroupIds" resultType="java.lang.String">
  629. SELECT DISTINCT music_group_id_ FROM music_group_payment_calender
  630. WHERE id_ IN
  631. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  632. #{calenderId}
  633. </foreach>
  634. </select>
  635. <select id="getMusicGroupCalenderBatchNoTimes" resultMap="MusicGroupPaymentCalender">
  636. SELECT batch_no_, COUNT(*) expect_num_ FROM music_group_payment_calender
  637. WHERE music_group_id_ = #{musicGroupId}
  638. AND status_ IN ('AUDITING','NO', 'OPEN', 'OVER', 'PAID')
  639. GROUP BY batch_no_
  640. </select>
  641. <select id="getMusicGroupRegCalenderByIds" resultMap="MusicGroupPaymentCalender">
  642. SELECT * FROM music_group_payment_calender WHERE music_group_id_ IN
  643. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  644. #{id}
  645. </foreach>
  646. AND payment_type_='MUSIC_APPLY' AND batch_no_ IS NOT NULL
  647. </select>
  648. <select id="getMusicGroupCalenderBatchNoByIds" resultMap="MusicGroupPaymentCalender">
  649. SELECT music_group_id_,batch_no_, COUNT(*) expect_num_ FROM music_group_payment_calender
  650. WHERE music_group_id_ IN
  651. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  652. #{id}
  653. </foreach>
  654. AND status_ IN ('AUDITING','NO', 'OPEN', 'OVER', 'PAID')
  655. AND batch_no_ IS NOT NULL
  656. GROUP BY music_group_id_,batch_no_
  657. </select>
  658. <select id="queryCalenderStudentIds" resultType="java.lang.String">
  659. SELECT GROUP_CONCAT(DISTINCT student_ids_) FROM music_group_payment_calender
  660. WHERE status_ IN ('AUDITING','REJECT') AND music_group_id_ = #{musicGroupId}
  661. <if test="batchNo != null and batchNo != ''">
  662. AND batch_no_ != #{batchNo}
  663. </if>
  664. </select>
  665. </mapper>