MusicGroupPaymentCalenderMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. </resultMap>
  34. <!-- 根据主键查询一条记录 -->
  35. <select id="get" resultMap="MusicGroupPaymentCalender">
  36. SELECT * FROM music_group_payment_calender WHERE id_ = #{id}
  37. </select>
  38. <!-- 全查询 -->
  39. <select id="findAll" resultMap="MusicGroupPaymentCalender">
  40. SELECT * FROM music_group_payment_calender ORDER BY id_
  41. </select>
  42. <!-- 向数据库增加一条记录 -->
  43. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  44. keyColumn="id_" keyProperty="id">
  45. INSERT INTO music_group_payment_calender
  46. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  47. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,
  48. payment_pattern_,payment_type_,payment_amount_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_)
  49. VALUES(#{musicGroupId},#{musicGroupOrganizationCourseSettingId},#{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  50. #{rejectReason},#{startPaymentDate},#{deadlinePaymentDate},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  51. #{expectNum},#{actualNum},#{memo},#{isGiveMusicNetwork},now(),now(),
  52. #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  53. #{paymentAmount},#{batchNo},#{auditMemo},#{operator},#{attribute1},#{attribute2},#{studentIds})
  54. </insert>
  55. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
  56. keyColumn="id_" keyProperty="id">
  57. INSERT INTO music_group_payment_calender
  58. (music_group_id_,music_group_organization_course_settings_id_,pay_user_type_,reject_reason_,start_payment_date_,deadline_payment_date_,status_,expect_num_,
  59. actual_num_,memo_,is_give_music_network_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_amount_,
  60. payment_type_,batch_no_,audit_memo_,operator_,attribute1_,attribute2_,student_ids_)
  61. VALUES
  62. <foreach collection="list" item="item" index="index" separator=",">
  63. (#{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},
  64. #{item.expectNum},#{item.actualNum},#{item.memo},#{item.isGiveMusicNetwork},now(),now(),
  65. #{item.paymentValidStartDate},#{item.paymentValidEndDate},#{item.paymentPattern},#{item.paymentAmount},#{item.paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  66. #{item.batchNo},#{item.auditMemo},#{item.operator},#{item.attribute1},#{item.attribute2},#{item.studentIds})
  67. </foreach>
  68. </insert>
  69. <!-- 根据主键查询一条记录 -->
  70. <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  71. UPDATE music_group_payment_calender
  72. <set>
  73. <if test="studentIds != null and studentIds != ''">
  74. student_ids_ = #{studentIds},
  75. </if>
  76. <if test="auditMemo != null and auditMemo != ''">
  77. audit_memo_ = #{auditMemo},
  78. </if>
  79. <if test="paymentType != null">
  80. payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  81. </if>
  82. <if test="paymentValidStartDate != null">
  83. payment_valid_start_date_ = #{paymentValidStartDate},
  84. payment_valid_end_date_ = #{paymentValidEndDate},
  85. </if>
  86. <if test="paymentPattern != null">
  87. payment_pattern_ = #{paymentPattern},
  88. </if>
  89. <if test="isGiveMusicNetwork != null">
  90. is_give_music_network_ = #{isGiveMusicNetwork},
  91. </if>
  92. <if test="deadlinePaymentDate != null">
  93. deadline_payment_date_ = #{deadlinePaymentDate},
  94. </if>
  95. <if test="status != null">
  96. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  97. </if>
  98. <if test="expectNum != null">
  99. expect_num_ = #{expectNum},
  100. </if>
  101. <if test="actualNum != null">
  102. actual_num_ = #{actualNum},
  103. </if>
  104. <if test="memo != null">
  105. memo_ = #{memo},
  106. </if>
  107. <if test="startPaymentDate != null">
  108. start_payment_date_ = #{startPaymentDate},
  109. </if>
  110. <if test="musicGroupOrganizationCourseSettingId != null">
  111. music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingId},
  112. </if>
  113. <if test="payUserType != null">
  114. pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  115. </if>
  116. <if test="rejectReason != null">
  117. reject_reason_ = #{rejectReason},
  118. </if>
  119. <if test="updateTime != null">
  120. update_time_ = NOW(),
  121. </if>
  122. <if test="musicGroupId != null">
  123. music_group_id_ = #{musicGroupId},
  124. </if>
  125. <if test="batchNo != null">
  126. batch_no_ = #{batchNo},
  127. </if>
  128. <if test="paymentAmount != null">
  129. payment_amount_ = #{paymentAmount},
  130. </if>
  131. <if test="attribute1 != null">
  132. attribute1_ = #{attribute1},
  133. </if>
  134. <if test="attribute2 != null">
  135. attribute2_ = #{attribute2},
  136. </if>
  137. </set>
  138. WHERE id_ = #{id}
  139. </update>
  140. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
  141. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  142. UPDATE music_group_payment_calender
  143. <set>
  144. <if test="item.studentIds != null and item.studentIds != ''">
  145. student_ids_ = #{item.studentIds},
  146. </if>
  147. <if test="item.paymentPattern != null">
  148. payment_pattern_ = #{item.paymentPattern},
  149. </if>
  150. <if test="item.isGiveMusicNetwork != null">
  151. is_give_music_network_ = #{item.isGiveMusicNetwork},
  152. </if>
  153. <if test="item.deadlinePaymentDate != null">
  154. deadline_payment_date_ = #{item.deadlinePaymentDate},
  155. </if>
  156. <if test="item.status != null">
  157. status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  158. </if>
  159. <if test="item.expectNum != null">
  160. expect_num_ = #{item.expectNum},
  161. </if>
  162. <if test="item.actualNum != null">
  163. actual_num_ = #{item.actualNum},
  164. </if>
  165. <if test="item.memo != null">
  166. memo_ = #{item.memo},
  167. </if>
  168. <if test="item.startPaymentDate != null">
  169. start_payment_date_ = #{item.startPaymentDate},
  170. </if>
  171. <if test="item.musicGroupOrganizationCourseSettingId != null">
  172. music_group_organization_course_settings_id_ = #{item.musicGroupOrganizationCourseSettingId},
  173. </if>
  174. <if test="item.payUserType != null">
  175. pay_user_type_ = #{item.payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  176. </if>
  177. <if test="item.rejectReason != null">
  178. reject_reason_ = #{item.rejectReason},
  179. </if>
  180. <if test="item.updateTime != null">
  181. update_time_ = NOW(),
  182. </if>
  183. <if test="item.musicGroupId != null">
  184. music_group_id_ = #{item.musicGroupId},
  185. </if>
  186. <if test="item.batchNo != null">
  187. batch_no_ = #{item.batchNo},
  188. </if>
  189. <if test="item.paymentAmount != null">
  190. payment_amount_ = #{item.paymentAmount},
  191. </if>
  192. <if test="item.attribute1 != null">
  193. attribute1_ = #{item.attribute1},
  194. </if>
  195. <if test="item.attribute2 != null">
  196. attribute2_ = #{item.attribute2},
  197. </if>
  198. </set>
  199. WHERE id_ = #{item.id}
  200. </foreach>
  201. </update>
  202. <!-- 根据主键删除一条记录 -->
  203. <delete id="delete">
  204. DELETE FROM music_group_payment_calender WHERE id_ = #{id}
  205. </delete>
  206. <delete id="delByGroupId">
  207. DELETE FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId}
  208. </delete>
  209. <!-- 分页查询 -->
  210. <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
  211. SELECT * FROM music_group_payment_calender mgpc
  212. <where>
  213. <if test="musicGroupId != null">
  214. and mgpc.music_group_id_ = #{musicGroupId}
  215. </if>
  216. <if test="payUserType != null">
  217. and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  218. </if>
  219. <if test="paymentType != null">
  220. and mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  221. </if>
  222. <if test="status != null">
  223. and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  224. </if>
  225. </where>
  226. ORDER BY mgpc.payment_valid_start_date_ DESC
  227. <include refid="global.limit"/>
  228. </select>
  229. <!-- 查询当前表的总记录数 -->
  230. <select id="queryCount" resultType="int">
  231. SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
  232. <where>
  233. <if test="musicGroupId != null">
  234. and mgpc.music_group_id_ = #{musicGroupId}
  235. </if>
  236. <if test="payUserType != null">
  237. and mgpc.pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  238. </if>
  239. <if test="status != null">
  240. and mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  241. </if>
  242. </where>
  243. </select>
  244. <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
  245. SELECT * FROM music_group_payment_calender mgpc
  246. WHERE music_group_id_ = #{musicGroupId}
  247. ORDER BY id_
  248. </select>
  249. <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
  250. SELECT * FROM music_group_payment_calender mgpc
  251. <where>
  252. <if test="status != null">
  253. status_ in
  254. <foreach collection="status" item="item" open="(" close=")" separator=",">
  255. #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  256. </foreach>
  257. </if>
  258. <if test="payUserType != null">
  259. AND pay_user_type_ = #{payUserType}
  260. </if>
  261. </where>
  262. </select>
  263. <select id="getForLock" resultMap="MusicGroupPaymentCalender">
  264. SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
  265. </select>
  266. <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
  267. SELECT count(*) FROM music_group_payment_calender mgpc
  268. WHERE music_group_id_ = #{musicGroupId}
  269. and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
  270. or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
  271. <if test="calenderId != null">
  272. AND mgpc.id_ != #{calenderId}
  273. </if>
  274. </select>
  275. <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
  276. SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
  277. </select>
  278. <select id="queryIntersectionByDate" resultType="java.lang.Integer">
  279. SELECT COUNT(DISTINCT mgpcd.id_) FROM music_group_payment_calender mgpc
  280. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  281. WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpcd.payment_status_ != 'PAID_COMPLETED'
  282. AND (DATE_FORMAT(mgpcd.start_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime}
  283. OR DATE_FORMAT(mgpcd.deadline_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime})
  284. </select>
  285. <select id="queryIntersectionByValidDate" resultType="java.lang.Integer">
  286. SELECT COUNT(*) FROM music_group_payment_calender mgpc
  287. WHERE music_group_id_ = #{musicGroupId}
  288. AND (payment_valid_end_date_ IS NULL OR payment_valid_start_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}
  289. OR payment_valid_end_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}) AND payment_valid_start_date_ IS NOT NULL
  290. <if test="payUserType != null">
  291. and pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  292. </if>
  293. <if test="calenderId != null">
  294. AND mgpc.id_ != #{calenderId}
  295. </if>
  296. </select>
  297. <select id="queryCalenderByDay" resultType="java.util.Map">
  298. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(mgpcd.payment_status_) 'value'
  299. FROM music_group_payment_calender_detail mgpcd
  300. WHERE mgpcd.music_group_payment_calender_id_ IN
  301. (SELECT id_ FROM music_group_payment_calender WHERE status_ != 0
  302. AND DATEDIFF(#{format},DATE_FORMAT(start_payment_date_,'%Y-%m-%d')) = #{configValue})
  303. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  304. GROUP BY mgpcd.music_group_payment_calender_id_
  305. </select>
  306. <select id="queryByIds" resultMap="MusicGroupPaymentCalender">
  307. SELECT * FROM music_group_payment_calender WHERE id_ IN
  308. <foreach collection="calenderId" open="(" close=")" item="item" separator=",">
  309. #{item}
  310. </foreach>
  311. </select>
  312. <select id="queryEndIds" resultType="java.lang.Long">
  313. SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
  314. WHERE mgpc.payment_valid_end_date_ IS NOT NULL AND DATEDIFF(mgpc.payment_valid_end_date_,#{format}) = #{configValue} AND mgpc.payment_type_ IN ('MUSIC_APPLY','MUSIC_RENEW')
  315. </select>
  316. <resultMap id="CalenderPushDto" type="com.ym.mec.biz.dal.dto.CalenderPushDto">
  317. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  318. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  319. <result property="teacherId" column="educational_teacher_id_"/>
  320. <result property="musicGroupName" column="name_"/>
  321. <result property="teacherPhone" column="phone_"/>
  322. <result property="calenderId" column="id_"/>
  323. </resultMap>
  324. <select id="getCalenderPushDto" resultMap="CalenderPushDto">
  325. SELECT mgpc.id_,mgpc.payment_valid_start_date_,mgpc.payment_valid_end_date_,
  326. mg.educational_teacher_id_,mg.name_,su.phone_
  327. FROM music_group_payment_calender mgpc
  328. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  329. LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
  330. WHERE mgpc.id_ IN
  331. <foreach collection="calenderIds" open="(" close=")" separator="," item="item">
  332. #{item}
  333. </foreach>
  334. </select>
  335. <select id="getMusicCalenderPushDto" resultMap="CalenderPushDto">
  336. SELECT mg.payment_valid_start_date_,mg.payment_valid_end_date_,
  337. mg.educational_teacher_id_,su.phone_,mg.name_ FROM music_group mg
  338. LEFT JOIN sys_user su ON mg.educational_teacher_id_ = su.id_
  339. WHERE mg.payment_valid_end_date_ IS NOT NULL AND
  340. DATEDIFF(mg.payment_valid_end_date_,#{format}) = #{configValue}
  341. </select>
  342. <select id="getMusicGroupUnusedFirstPaymentCalender" resultMap="MusicGroupPaymentCalender">
  343. SELECT
  344. mgpc.*
  345. FROM
  346. music_group_payment_calender_detail mgpcd
  347. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  348. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  349. WHERE
  350. mgpcd.music_group_payment_calender_id_ = mgpccs.music_group_payment_calender_id_
  351. AND mgpc.music_group_id_ = #{musicGroupId}
  352. AND mgpcd.use_in_course_ = 0
  353. AND mgpcd.user_id_ IN
  354. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  355. #{studentId}
  356. </foreach>
  357. ORDER BY
  358. mgpc.payment_valid_start_date_
  359. LIMIT 1;
  360. </select>
  361. <select id="getUnusedFirstPaymentCalenderWithCalenders" resultMap="MusicGroupPaymentCalender">
  362. SELECT * FROM music_group_payment_calender mgpc
  363. WHERE id_ IN
  364. <foreach collection="calenderIds" item="calenderId" open="(" close=")" separator=",">
  365. #{calenderId}
  366. </foreach>
  367. ORDER BY create_time_ LIMIT 1;
  368. </select>
  369. <select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
  370. SELECT * FROM music_group_payment_calender WHERE batch_no_=#{batchNo}
  371. </select>
  372. <resultMap id="MusicGroupPaymentCalenderAuditDtoMap" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto">
  373. <result property="musicGroupId" column="music_group_id_"/>
  374. <result property="musicGroupName" column="music_group_name_"/>
  375. <result property="organId" column="organ_id_"/>
  376. <result property="createTime" column="create_time_"/>
  377. <result property="paymentType" column="payment_type_"/>
  378. <result property="memo" column="memo_"/>
  379. <result property="operator" column="operator_"/>
  380. <result property="auditStatus" column="status_"/>
  381. <result property="addCourseTotalTime" column="course_total_minuties_"/>
  382. <result property="courseCurrentPrice" column="course_current_price_"/>
  383. <result property="courseOriginalPrice" column="course_original_price_"/>
  384. <result property="musicGroupPaymentCalenderId" column="id_"/>
  385. <result property="payUserType" column="pay_user_type_"/>
  386. <result property="calenderSettingsName" column="calender_settings_name_"/>
  387. <result property="paymentPattern" column="payment_pattern_"/>
  388. <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
  389. <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
  390. <result property="startPaymentDate" column="start_payment_date_"/>
  391. <result property="deadlinePaymentDate" column="deadline_payment_date_"/>
  392. <result property="auditMemo" column="audit_memo_"/>
  393. <result property="paymentAmount" column="payment_amount_"/>
  394. <result property="isGiveMusicNetwork" column="is_give_music_network_"/>
  395. </resultMap>
  396. <sql id="MusicGroupPaymentCalenderAuditDtoSql">
  397. <where>
  398. <if test="paymentType != null">
  399. AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  400. </if>
  401. <if test="status != null">
  402. AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  403. </if>
  404. <if test="organId != null and organId != ''">
  405. AND FIND_IN_SET(mg.organ_id_,#{organId})
  406. </if>
  407. <if test="search != null and search != ''">
  408. AND (mg.id_ LIKE CONCAT('%',#{search},'%') OR mg.name_ LIKE CONCAT('%',#{search},'%'))
  409. </if>
  410. </where>
  411. </sql>
  412. <select id="countAuditList" resultType="java.lang.Integer">
  413. SELECT COUNT(DISTINCT mgpc.id_)
  414. FROM music_group_payment_calender mgpc
  415. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  416. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  417. </select>
  418. <select id="queryAuditList" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  419. SELECT mgpc.id_,mgpc.music_group_id_,mgpc.create_time_,mgpc.payment_type_,mgpc.operator_,
  420. mgpc.pay_user_type_,mgpc.memo_,mgpc.status_,SUM(mgpccs.course_total_minuties_) course_total_minuties_,
  421. SUM(mgpccs.course_original_price_) course_original_price_,SUM(mgpccs.course_current_price_) course_current_price_,
  422. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,mgpc.payment_pattern_
  423. FROM music_group_payment_calender mgpc
  424. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  425. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  426. <include refid="MusicGroupPaymentCalenderAuditDtoSql"/>
  427. GROUP BY mgpc.id_
  428. ORDER BY create_time_ DESC
  429. <include refid="global.limit"/>
  430. </select>
  431. <select id="countExpectNum" resultType="java.util.Map">
  432. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  433. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  434. GROUP BY mgpcd.music_group_payment_calender_id_
  435. </select>
  436. <select id="countActualNum" resultType="java.util.Map">
  437. SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
  438. WHERE mgpcd.music_group_payment_calender_id_ = #{id}
  439. AND mgpcd.payment_status_ = 'PAID_COMPLETED'
  440. GROUP BY mgpcd.music_group_payment_calender_id_
  441. </select>
  442. <select id="getAuditDetail" resultMap="MusicGroupPaymentCalenderAuditDtoMap">
  443. SELECT mgpc.id_,mgpc.music_group_id_,mgpc.create_time_,mgpc.payment_type_,mgpc.operator_,
  444. mgpc.pay_user_type_,mgpc.memo_,mgpc.status_,SUM(mgpccs.course_total_minuties_) course_total_minuties_,
  445. SUM(mgpccs.course_original_price_) course_original_price_,SUM(mgpccs.course_current_price_) course_current_price_,
  446. MAX(mg.name_) music_group_name_,MAX(mg.organ_id_) organ_id_,MAX(mgpccs.name_) calender_settings_name_,mgpc.payment_pattern_,mgpc.payment_valid_start_date_,
  447. mgpc.payment_valid_end_date_,mgpc.start_payment_date_,mgpc.deadline_payment_date_,mgpc.audit_memo_,mgpc.payment_amount_,mgpc.is_give_music_network_
  448. FROM music_group_payment_calender mgpc
  449. LEFT JOIN music_group mg ON mg.id_ = mgpc.music_group_id_
  450. LEFT JOIN music_group_payment_calender_course_settings mgpccs ON mgpc.id_ = mgpccs.music_group_payment_calender_id_
  451. WHERE mgpc.id_ = #{calenderId} LIMIT 1
  452. </select>
  453. <select id="findByMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  454. SELECT * FROM music_group_payment_calender WHERE music_group_id_=#{musicGroupId} AND payment_type_='MUSIC_APPLY'
  455. </select>
  456. <select id="getCalenderSettingsName" resultType="java.lang.String">
  457. SELECT name_ FROM music_group_payment_calender_course_settings
  458. WHERE music_group_payment_calender_id_ = #{calenderId} LIMIT 1
  459. </select>
  460. <select id="countAuditReject" resultType="java.lang.Integer">
  461. SELECT COUNT(0) FROM music_group_payment_calender
  462. WHERE music_group_id_ = #{musicGroupId} AND payment_type_='MUSIC_APPLY' AND status_ IN ('REJECT','AUDITING')
  463. <if test="calenderId != null">
  464. AND id_ != #{calenderId}
  465. </if>
  466. </select>
  467. <select id="getMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
  468. SELECT * FROM music_group_payment_calender
  469. WHERE music_group_id_ = #{musicGroupId}
  470. AND payment_type_ = 'MUSIC_APPLY'
  471. AND pay_user_type_='STUDENT'
  472. </select>
  473. <select id="queryUserPaymentStatus" resultType="java.util.Map">
  474. SELECT mg.id_ 'key',CASE WHEN COUNT(mgpc.id_) = 0 OR COUNT(DISTINCT mgpcd.id_) > 0 THEN 'NON_PAYMENT' ELSE 'PAID_COMPLETED' END 'value'
  475. FROM music_group mg
  476. LEFT JOIN music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
  477. LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
  478. AND mgpcd.user_id_ = #{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT'
  479. WHERE FIND_IN_SET(mg.id_,#{musicGroupId}) AND DATE_FORMAT(NOW(),'%Y-%m-%d') > DATE_FORMAT(mgpc.payment_valid_end_date_,'%Y-%m-%d')
  480. GROUP BY mg.id_
  481. </select>
  482. </mapper>