StudentPaymentOrderMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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.StudentPaymentOrderDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" id="StudentPaymentOrder">
  9. <result column="id_" property="id"/>
  10. <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="organ_id_" property="organId"/>
  13. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  14. <result column="expect_amount_" property="expectAmount"/>
  15. <result column="actual_amount_" property="actualAmount"/>
  16. <result column="com_amount_" property="comAmount"/>
  17. <result column="per_amount_" property="perAmount"/>
  18. <result column="balance_payment_amount_" property="balancePaymentAmount"/>
  19. <result column="remit_fee_" property="remitFee"/>
  20. <result column="course_remit_fee_" property="courseRemitFee"/>
  21. <result column="trans_no_" property="transNo"/>
  22. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  23. <result column="memo_" property="memo"/>
  24. <result column="create_time_" property="createTime"/>
  25. <result column="update_time_" property="updateTime"/>
  26. <result column="payment_channel_" property="paymentChannel"/>
  27. <result column="payment_business_channel_" property="paymentBusinessChannel"/>
  28. <result column="payment_account_no_" property="paymentAccountNo"/>
  29. <result column="mer_nos_" property="merNos"/>
  30. <result column="order_no_" property="orderNo"/>
  31. <result column="music_group_id_" property="musicGroupId"/>
  32. <result column="class_group_id_" property="classGroupId"/>
  33. <result column="pay_time_" property="payTime"/>
  34. <result column="version_" property="version"/>
  35. <result column="receive_status_" property="receiveStatus"/>
  36. <result column="batch_no_" property="batchNo"/>
  37. </resultMap>
  38. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" extends="StudentPaymentOrder"
  39. id="PaymentOrderAndStudentInfo">
  40. <result column="username_" property="user.username"/>
  41. <result column="phone_" property="user.phone"/>
  42. <result column="organ_name_" property="organName"/>
  43. </resultMap>
  44. <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
  45. <result column="id_" property="id"/>
  46. <result column="goods_category_id_" property="goodsCategoryId"/>
  47. <result column="sn_" property="sn"/>
  48. <result column="name_" property="name"/>
  49. <result column="brand_" property="brand"/>
  50. <result column="specification_" property="specification"/>
  51. <result column="image_" property="image"/>
  52. <result column="stock_count_" property="stockCount"/>
  53. <result column="sell_count_" property="sellCount"/>
  54. <result column="market_price_" property="marketPrice"/>
  55. <result column="discount_price_" property="discountPrice"/>
  56. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  57. <result column="brief_" property="brief"/>
  58. <result column="desc_" property="desc"/>
  59. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  60. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  61. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  62. <result column="memo_" property="memo"/>
  63. <result column="publish_time_" property="publishTime"/>
  64. <result column="create_time_" property="createTime"/>
  65. <result column="update_time_" property="updateTime"/>
  66. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  67. </resultMap>
  68. <resultMap id="StudentVipDouble11Dto" type="com.ym.mec.biz.dal.dto.StudentVipDouble11Dto">
  69. <result column="payment_one_to_one_time_" property="paymentOneToOneTime"/>
  70. <result column="payment_one_to_two_time_" property="paymentOneToTwoTime"/>
  71. <result column="course_one_to_one_time_" property="courseOneToOneTime"/>
  72. <result column="course_one_to_two_time_" property="courseOneToTwoTime"/>
  73. </resultMap>
  74. <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
  75. <result column="key_" property="key"/>
  76. <result column="value_" property="value"/>
  77. </resultMap>
  78. <!-- 根据主键查询一条记录 -->
  79. <select id="get" resultMap="StudentPaymentOrder">
  80. SELECT *
  81. FROM student_payment_order
  82. WHERE id_ = #{id}
  83. </select>
  84. <!-- 全查询 -->
  85. <select id="findAll" resultMap="StudentPaymentOrder">
  86. SELECT *
  87. FROM student_payment_order
  88. ORDER BY id_
  89. </select>
  90. <!-- 向数据库增加一条记录 -->
  91. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
  92. keyColumn="id" keyProperty="id">
  93. INSERT INTO student_payment_order
  94. (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
  95. per_amount_,
  96. balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
  97. status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
  98. payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,batch_no_)
  99. VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  100. #{userId}, #{organId}, #{routingOrganId},
  101. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  102. #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
  103. #{remitFee}, #{courseRemitFee}, #{transNo},
  104. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
  105. #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
  106. #{musicGroupId},
  107. #{classGroupId}, #{payTime},#{batchNo})
  108. </insert>
  109. <!-- 根据主键查询一条记录 -->
  110. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  111. UPDATE student_payment_order
  112. <set>
  113. <if test="receiveStatus != null and receiveStatus != ''">
  114. receive_status_ = #{receiveStatus},
  115. </if>
  116. <if test="status != null">
  117. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  118. </if>
  119. <if test="groupType != null">
  120. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  121. </if>
  122. <if test="orderNo != null">
  123. order_no_ = #{orderNo},
  124. </if>
  125. <if test="classGroupId != null">
  126. class_group_id_ = #{classGroupId},
  127. </if>
  128. <if test="expectAmount != null">
  129. expect_amount_ = #{expectAmount},
  130. </if>
  131. <if test="memo != null">
  132. memo_ = #{memo},
  133. </if>
  134. <if test="paymentChannel != null">
  135. payment_channel_ = #{paymentChannel},
  136. </if>
  137. <if test="userId != null">
  138. user_id_ = #{userId},
  139. </if>
  140. <if test="paymentAccountNo != null">
  141. payment_account_no_ = #{paymentAccountNo},
  142. </if>
  143. <if test="merNos != null">
  144. mer_nos_ = #{merNos},
  145. </if>
  146. <if test="paymentBusinessChannel != null">
  147. payment_business_channel_ = #{paymentBusinessChannel},
  148. </if>
  149. <if test="transNo != null">
  150. trans_no_ = #{transNo},
  151. </if>
  152. <if test="actualAmount != null">
  153. actual_amount_ = #{actualAmount},
  154. </if>
  155. <if test="comAmount != null">
  156. com_amount_ = #{comAmount},
  157. </if>
  158. <if test="perAmount != null">
  159. per_amount_ = #{perAmount},
  160. </if>
  161. <if test="balancePaymentAmount != null">
  162. balance_payment_amount_ = #{balancePaymentAmount},
  163. </if>
  164. <if test="remitFee != null">
  165. remit_fee_ = #{remitFee},
  166. </if>
  167. <if test="courseRemitFee != null">
  168. course_remit_fee_ = #{courseRemitFee},
  169. </if>
  170. <if test="type != null">
  171. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  172. </if>
  173. <if test="musicGroupId != null">
  174. music_group_id_ = #{musicGroupId},
  175. </if>
  176. <if test="organId != null">
  177. organ_id_ = #{organId},
  178. </if>
  179. <if test="routingOrganId != null">
  180. routing_organ_id_ = #{routingOrganId},
  181. </if>
  182. <if test="payTime != null">
  183. pay_time_ = #{payTime},
  184. </if>
  185. <if test="batchNo != null">
  186. batch_no_ = #{batchNo},
  187. </if>
  188. <if test="version != null">
  189. version_ = version_+1,
  190. </if>
  191. update_time_ = NOW()
  192. </set>
  193. WHERE id_ = #{id} AND version_ = #{version}
  194. </update>
  195. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  196. <foreach collection="studentPaymentOrderList" item="studentPaymentOrder" separator=";">
  197. UPDATE student_payment_order
  198. <set>
  199. <if test="studentPaymentOrder.receiveStatus != null and studentPaymentOrder.receiveStatus != ''">
  200. receive_status_ = #{studentPaymentOrder.receiveStatus},
  201. </if>
  202. <if test="studentPaymentOrder.status != null">
  203. status_ = #{studentPaymentOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  204. </if>
  205. <if test="studentPaymentOrder.groupType != null">
  206. group_type_ = #{studentPaymentOrder.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  207. </if>
  208. <if test="studentPaymentOrder.orderNo != null">
  209. order_no_ = #{studentPaymentOrder.orderNo},
  210. </if>
  211. <if test="studentPaymentOrder.classGroupId != null">
  212. class_group_id_ = #{studentPaymentOrder.classGroupId},
  213. </if>
  214. <if test="studentPaymentOrder.expectAmount != null">
  215. expect_amount_ = #{studentPaymentOrder.expectAmount},
  216. </if>
  217. <if test="studentPaymentOrder.memo != null">
  218. memo_ = #{studentPaymentOrder.memo},
  219. </if>
  220. <if test="studentPaymentOrder.paymentChannel != null">
  221. payment_channel_ = #{studentPaymentOrder.paymentChannel},
  222. </if>
  223. <if test="studentPaymentOrder.userId != null">
  224. user_id_ = #{studentPaymentOrder.userId},
  225. </if>
  226. <if test="studentPaymentOrder.paymentAccountNo != null">
  227. payment_account_no_ = #{studentPaymentOrder.paymentAccountNo},
  228. </if>
  229. <if test="studentPaymentOrder.merNos != null">
  230. mer_nos_ = #{studentPaymentOrder.merNos},
  231. </if>
  232. <if test="studentPaymentOrder.paymentBusinessChannel != null">
  233. payment_business_channel_ = #{studentPaymentOrder.paymentBusinessChannel},
  234. </if>
  235. <if test="studentPaymentOrder.transNo != null">
  236. trans_no_ = #{studentPaymentOrder.transNo},
  237. </if>
  238. <if test="studentPaymentOrder.actualAmount != null">
  239. actual_amount_ = #{studentPaymentOrder.actualAmount},
  240. </if>
  241. <if test="studentPaymentOrder.comAmount != null">
  242. com_amount_ = #{studentPaymentOrder.comAmount},
  243. </if>
  244. <if test="studentPaymentOrder.perAmount != null">
  245. per_amount_ = #{studentPaymentOrder.perAmount},
  246. </if>
  247. <if test="studentPaymentOrder.balancePaymentAmount != null">
  248. balance_payment_amount_ = #{studentPaymentOrder.balancePaymentAmount},
  249. </if>
  250. <if test="studentPaymentOrder.remitFee != null">
  251. remit_fee_ = #{studentPaymentOrder.remitFee},
  252. </if>
  253. <if test="studentPaymentOrder.courseRemitFee != null">
  254. course_remit_fee_ = #{studentPaymentOrder.courseRemitFee},
  255. </if>
  256. <if test="studentPaymentOrder.type != null">
  257. type_ = #{studentPaymentOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  258. </if>
  259. <if test="studentPaymentOrder.musicGroupId != null">
  260. music_group_id_ = #{studentPaymentOrder.musicGroupId},
  261. </if>
  262. <if test="studentPaymentOrder.organId != null">
  263. organ_id_ = #{studentPaymentOrder.organId},
  264. </if>
  265. <if test="studentPaymentOrder.routingOrganId != null">
  266. routing_organ_id_ = #{studentPaymentOrder.routingOrganId},
  267. </if>
  268. <if test="studentPaymentOrder.payTime != null">
  269. pay_time_ = #{studentPaymentOrder.payTime},
  270. </if>
  271. <if test="studentPaymentOrder.batchNo != null">
  272. batch_no_ = #{studentPaymentOrder.batchNo},
  273. </if>
  274. <if test="studentPaymentOrder.version != null">
  275. version_ = version_+1,
  276. </if>
  277. update_time_ = NOW()
  278. </set>
  279. WHERE id_ = #{studentPaymentOrder.id} AND version_ = #{studentPaymentOrder.version}
  280. </foreach>
  281. </update>
  282. <!-- 根据主键删除一条记录 -->
  283. <delete id="delete">
  284. DELETE
  285. FROM student_payment_order
  286. WHERE id_ = #{id}
  287. </delete>
  288. <!-- 分页查询 -->
  289. <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  290. SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
  291. left join sys_user u on spo.user_id_ = u.id_
  292. left join organization o on o.id_ = spo.organ_id_
  293. <include refid="queryPaymentOrder"/>
  294. ORDER BY spo.id_ DESC
  295. <include refid="global.limit"/>
  296. </select>
  297. <!-- 查询当前表的总记录数 -->
  298. <select id="queryCount" resultType="int" parameterType="map">
  299. SELECT COUNT(spo.id_) FROM student_payment_order spo
  300. left join sys_user u on spo.user_id_ = u.id_
  301. <include refid="queryPaymentOrder"/>
  302. </select>
  303. <sql id="queryPaymentOrder">
  304. <where>
  305. <if test="userIds != null">
  306. AND spo.user_id_ IN
  307. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  308. #{userId}
  309. </foreach>
  310. </if>
  311. <if test="organId != null">
  312. AND FIND_IN_SET(spo.organ_id_,#{organId})
  313. </if>
  314. <if test="orderStartDate != null">
  315. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  316. </if>
  317. <if test="orderEndDate != null">
  318. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  319. </if>
  320. <if test="paymentType != null">
  321. AND spo.type_ = #{paymentType}
  322. </if>
  323. <if test="remark != null">
  324. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  325. </if>
  326. <if test="studentId != null">
  327. AND spo.user_id_ = #{studentId}
  328. </if>
  329. <if test="paymentStatus != null">
  330. AND spo.status_ = #{paymentStatus}
  331. </if>
  332. <if test="paymentChannel != null">
  333. AND spo.payment_channel_ NOT IN (#{paymentChannel})
  334. </if>
  335. <if test='orderType != null and orderType.toString()=="1".toString()'>
  336. AND spo.com_amount_ > 0
  337. </if>
  338. <if test='orderType != null and orderType.toString()=="2".toString()'>
  339. AND spo.per_amount_ > 0
  340. </if>
  341. <if test="routingOrganId != null">
  342. AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
  343. </if>
  344. <if test="actualAmount != null">
  345. AND spo.actual_amount_ >= #{actualAmount}
  346. </if>
  347. <if test="balancePaymentAmount != null">
  348. AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
  349. </if>
  350. <if test="lessActualAmount != null">
  351. <![CDATA[ AND spo.actual_amount_ <= #{lessActualAmount}]]>
  352. </if>
  353. <if test="lessBalancePaymentAmount != null">
  354. <![CDATA[AND spo.balance_payment_amount_ <= #{lessBalancePaymentAmount}]]>
  355. </if>
  356. <if test="orderNo != null">
  357. AND spo.order_no_ = #{orderNo}
  358. </if>
  359. <if test="merNos != null">
  360. AND FIND_IN_SET(#{merNos},spo.mer_nos_)
  361. </if>
  362. <if test="transNo != null">
  363. AND spo.trans_no_ = #{transNo}
  364. </if>
  365. <if test="chargeType != null">
  366. AND spo.group_type_='SPORADIC'
  367. AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  368. </if>
  369. </where>
  370. </sql>
  371. <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
  372. select g.*
  373. from goods g
  374. where g.id_ in (SELECT spod.goods_id_list_
  375. FROM student_payment_order spo
  376. left join
  377. student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  378. where spo.music_group_id_ =
  379. #{musicGroupId}
  380. and spo.type_ = 'APPLY'
  381. and spod.type_ =
  382. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  383. </select>
  384. <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
  385. SELECT spo.*
  386. FROM student_payment_order spo
  387. WHERE spo.user_id_ = #{userId}
  388. AND spo.music_group_id_ = #{musicGroupId}
  389. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  390. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  391. and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  392. </select>
  393. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  394. SELECT
  395. spo.*
  396. FROM
  397. student_payment_order spo
  398. WHERE spo.user_id_=#{userId}
  399. AND spo.music_group_id_=#{vipGroupId}
  400. <if test="status!=null and status!=''">
  401. AND spo.status_=#{status}
  402. </if>
  403. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  404. </select>
  405. <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
  406. SELECT SUM(cssp.expect_price_)
  407. FROM course_schedule_student_payment cssp
  408. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  409. WHERE cssp.user_id_ = #{userId}
  410. AND cssp.music_group_id_ = #{vipGroupId}
  411. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  412. </select>
  413. <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
  414. SELECT spo.*
  415. FROM student_payment_order spo
  416. WHERE spo.user_id_ = #{userId}
  417. AND spo.music_group_id_ = #{vipGroupId}
  418. AND spo.status_ != 'FAILED'
  419. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  420. </select>
  421. <!-- 查询报名订单 -->
  422. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  423. SELECT *
  424. FROM student_payment_order
  425. WHERE music_group_id_ = #{musicGroupId}
  426. AND user_id_ = #{userId}
  427. AND type_ = 'APPLY'
  428. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  429. ORDER BY id_ DESC
  430. LIMIT 1
  431. </select>
  432. <select id="queryByBatchNo" resultMap="StudentPaymentOrder" parameterType="map">
  433. SELECT *
  434. FROM student_payment_order
  435. WHERE batch_no_ = #{batchNo}
  436. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  437. and user_id_ = #{userId}
  438. </select>
  439. <!-- 根据订单号查询订单 -->
  440. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  441. SELECT *
  442. FROM student_payment_order
  443. WHERE order_no_ = #{orderNo}
  444. </select>
  445. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  446. SELECT *
  447. FROM student_payment_order
  448. WHERE music_group_id_ = #{musicGroupId}
  449. AND type_ =
  450. #{type}
  451. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  452. </select>
  453. <!-- 查找支付成功和支付中订单 -->
  454. <select id="findPayOrderNum" resultType="int">
  455. <![CDATA[
  456. SELECT COUNT(*)
  457. FROM student_payment_order
  458. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  459. ]]>
  460. </select>
  461. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  462. <result column="goods_id_" property="goodsId"/>
  463. <collection property="goodsName" ofType="string">
  464. <result column="goods_name_"/>
  465. </collection>
  466. </resultMap>
  467. <select id="findGoodsIds" resultMap="userGoodsDto">
  468. SELECT g.id_ goods_id_, g.name_ goods_name_
  469. FROM student_payment_order spo
  470. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  471. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  472. WHERE spo.type_ = 'APPLY'
  473. AND spo.status_ = 'SUCCESS'
  474. AND spod.goods_id_list_ IS NOT NULL
  475. AND spo.music_group_id_ = #{musicGroupId}
  476. AND spo.user_id_ = #{userId}
  477. </select>
  478. <select id="getUserGoods" resultMap="userGoodsDto">
  479. SELECT id_ goods_id_, name_ goods_name_ FROM goods WHERE FIND_IN_SET(id_,#{ids})
  480. </select>
  481. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  482. SELECT *
  483. FROM student_payment_order
  484. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  485. AND payment_channel_ = #{paymentChannel}
  486. LIMIT 100
  487. </select>
  488. <!-- 查询支付中超时订单 -->
  489. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  490. SELECT * FROM student_payment_order WHERE order_no_ IN
  491. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  492. #{orderNo}
  493. </foreach>
  494. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  495. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  496. </select>
  497. <select id="countStudentPaymentNum" resultType="int">
  498. select count(DISTINCT user_id_)
  499. from student_payment_order
  500. where music_group_id_ = #{musicGroupId}
  501. AND status_ = 'SUCCESS'
  502. AND type_ = 'SMALL_CLASS_TO_BUY'
  503. </select>
  504. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  505. SELECT COUNT(*)
  506. FROM course_schedule_student_payment cssp
  507. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  508. WHERE cssp.user_id_ = #{userId}
  509. AND cssp.music_group_id_ = #{musicGroupId}
  510. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  511. </select>
  512. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  513. SELECT SUM(expect_amount_)
  514. FROM student_payment_order
  515. WHERE group_type_ = #{groupType}
  516. AND music_group_id_ = #{musicGroupId}
  517. AND status_ = 'SUCCESS'
  518. </select>
  519. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  520. SELECT *
  521. FROM student_payment_order
  522. WHERE id_ IN (SELECT id_
  523. FROM student_payment_order
  524. WHERE group_type_ = #{groupType}
  525. AND type_ = 'APPLY'
  526. AND music_group_id_ = #{musicGroupId}
  527. AND status_ = 'SUCCESS'
  528. ORDER BY id_ DESC)
  529. </select>
  530. <select id="findOrderByGroupType" resultType="int">
  531. SELECT COUNT(id_) FROM student_payment_order
  532. WHERE group_type_ = #{groupType}
  533. AND user_id_ = #{userId}
  534. AND music_group_id_ = #{sporadicId}
  535. <if test="status != null">
  536. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  537. </if>
  538. </select>
  539. <select id="findPaymentOrderByGroupType" resultMap="StudentPaymentOrder">
  540. SELECT * FROM student_payment_order
  541. WHERE group_type_ = #{groupType}
  542. AND user_id_ = #{userId}
  543. AND music_group_id_ = #{sporadicId}
  544. <if test="status != null">
  545. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  546. </if>
  547. </select>
  548. <select id="queryExpectAmount" resultType="java.util.Map">
  549. SELECT spo.expect_amount_ 'value',spo.id_ 'key'
  550. FROM student_payment_order spo
  551. WHERE spo.id_ IN
  552. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  553. #{item}
  554. </foreach>
  555. </select>
  556. <select id="findFixOrder" resultMap="StudentPaymentOrder">
  557. SELECT *
  558. FROM student_payment_order
  559. where status_ = 'SUCCESS'
  560. AND type_ = 'APPLY'
  561. AND actual_amount_ > 0
  562. and mer_nos_ IS NULL
  563. LIMIT 100
  564. </select>
  565. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  566. extends="StudentPaymentOrder">
  567. <result column="organ_name" property="organName"/>
  568. <result column="username_" property="user.username"/>
  569. <result column="charge_type_" property="chargeType"/>
  570. <result column="routeMerNo" property="routeMerNo"/>
  571. <result column="routeAmount" property="routeAmount"/>
  572. <result column="routeBalance" property="routeBalance"/>
  573. <result column="sale_amount_" property="saleAmount"/>
  574. <result column="service_amount_" property="serviceAmount"/>
  575. <result column="routeBalance" property="routeBalance"/>
  576. <result column="feeFlag" property="feeFlag"/>
  577. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  578. <result column="detail_id_" property="id"/>
  579. <result column="detail_type_" property="type"/>
  580. <result column="detail_price_" property="price"/>
  581. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  582. </collection>
  583. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  584. <result column="goods_id" property="id"/>
  585. <result column="goods_name" property="name"/>
  586. </collection>
  587. </resultMap>
  588. <!-- 分页查询 -->
  589. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  590. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  591. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  592. sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name
  593. FROM student_payment_order spo
  594. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  595. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  596. <if test='orderType != null and orderType.toString()=="0".toString()'>
  597. LEFT JOIN organization o on spo.organ_id_ = o.id_
  598. </if>
  599. <if test='orderType != null and orderType.toString()=="1".toString()'>
  600. LEFT JOIN organization o on spo.organ_id_ = o.id_
  601. </if>
  602. <if test='orderType != null and orderType.toString()=="2".toString()'>
  603. LEFT JOIN organization o on spo.organ_id_ = o.id_
  604. </if>
  605. <if test='orderType != null and orderType.toString()=="3".toString()'>
  606. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  607. </if>
  608. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  609. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  610. <include refid="queryPaymentOrder"/>
  611. ORDER BY spo.id_ ASC
  612. </select>
  613. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  614. <result property="organName" column="organ_name_"/>
  615. <result property="title" column="title_"/>
  616. <result property="type" column="type_"/>
  617. <result property="amount" column="amount_"/>
  618. <result property="createTime" column="create_time_"/>
  619. <result property="payTime" column="pay_time_"/>
  620. <result property="username" column="username_"/>
  621. <result property="payStatus" column="pay_status_"/>
  622. </resultMap>
  623. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  624. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  625. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  626. FROM student_payment_order spo
  627. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  628. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  629. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  630. WHERE spo.type_ = 'SPORADIC'
  631. <include refid="sporadicQueryPageSql"/>
  632. ORDER BY spo.id_ DESC
  633. <include refid="global.limit"/>
  634. </select>
  635. <select id="countSporadicPage" resultType="java.lang.Integer">
  636. SELECT COUNT(spo.id_)
  637. FROM student_payment_order spo
  638. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  639. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  640. WHERE spo.type_ = 'SPORADIC'
  641. <include refid="sporadicQueryPageSql"/>
  642. </select>
  643. <sql id="sporadicQueryPageSql">
  644. <if test="organId != null">
  645. AND FIND_IN_SET(spo.organ_id_,#{organId})
  646. </if>
  647. <if test="search != null">
  648. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  649. </if>
  650. <if test="chargeType != null">
  651. AND sci.charge_type_ = #{chargeType}
  652. </if>
  653. <if test="payStatus != null">
  654. AND spo.status_ = #{payStatus}
  655. </if>
  656. </sql>
  657. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  658. <result property="organId" column="organId"/>
  659. <result property="organName" column="organName"/>
  660. <result property="estimatedNums" column="estimatedNums"/>
  661. <result property="nums" column="nums"/>
  662. <result property="times" column="times"/>
  663. <result property="scale" column="scale"/>
  664. <result property="money" column="money"/>
  665. </resultMap>
  666. <select id="getLuckStatis" resultMap="luckStatis">
  667. SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
  668. FROM student_payment_order spo
  669. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  670. WHERE spo.type_ = 'LUCK'
  671. AND spo.status_ = 'SUCCESS'
  672. GROUP BY spo.organ_id_
  673. ORDER BY nums DESC;
  674. </select>
  675. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  676. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  677. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
  678. status_ = 'SUCCESS' and organ_id_ not in (36,38)
  679. <if test="organId != null">
  680. and FIND_IN_SET(organ_id_,#{organId})
  681. </if>
  682. </select>
  683. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  684. select count(*)
  685. from student_payment_order
  686. where user_id_ = #{userId}
  687. and music_group_id_ = #{vipGroupId}
  688. and group_type_ = 'VIP'
  689. and status_ = 'SUCCESS'
  690. </select>
  691. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  692. select *
  693. from student_payment_order
  694. where user_id_ = #{userId}
  695. and music_group_id_ = #{vipGroupId}
  696. and group_type_ = 'VIP'
  697. </select>
  698. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  699. select * from student_payment_order
  700. where user_id_=#{userId}
  701. and music_group_id_=#{groupId}
  702. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  703. <if test="status!=null">
  704. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  705. </if>
  706. </select>
  707. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  708. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_)
  709. balance_payment_amount_ FROM student_payment_order spo
  710. <include refid="queryPaymentOrder"/>
  711. </select>
  712. <!-- 分页查询 -->
  713. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  714. SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
  715. left join sys_user u on spo.user_id_ = u.id_
  716. left join organization o on o.id_ = spo.organ_id_
  717. <include refid="queryPaymentOrder"/>
  718. ORDER BY spo.id_ DESC
  719. <include refid="global.limit"/>
  720. </select>
  721. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  722. SELECT * FROM student_payment_order
  723. WHERE music_group_id_=#{groupId}
  724. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  725. <if test="status!=null">
  726. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  727. </if>
  728. </select>
  729. <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
  730. SELECT SUM(per_amount_)
  731. FROM student_payment_order
  732. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  733. AND create_time_ >= #{firstDate}
  734. AND create_time_ <= NOW()
  735. AND FIND_IN_SET(#{merNo}, mer_nos_)
  736. ]]>
  737. </select>
  738. <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
  739. SELECT SUM(actual_amount_) FROM student_payment_order spo
  740. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
  741. <include refid="queryPaymentOrder"/>
  742. </select>
  743. <select id="sumAccountAmount" resultType="java.math.BigDecimal">
  744. <![CDATA[
  745. SELECT SUM(actual_amount_)
  746. FROM student_payment_order
  747. WHERE status_ IN ('SUCCESS', 'ING')
  748. AND create_time_ >= #{firstDate}
  749. AND create_time_ <= NOW()
  750. AND mer_nos_ = #{merNo}
  751. ]]></select>
  752. <select id="countGroupOrderWithoutFailed" resultType="int">
  753. SELECT COUNT(*)
  754. FROM student_payment_order spo
  755. LEFT JOIN class_group_student_mapper cgsm
  756. ON spo.music_group_id_ = cgsm.music_group_id_ AND spo.user_id_ = cgsm.user_id_
  757. WHERE spo.music_group_id_ = #{groupId}
  758. AND spo.status_ != 'FAILED'
  759. AND cgsm.status_ != 'QUIT'
  760. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  761. AND cgsm.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  762. </select>
  763. <select id="countSporadicOrder" resultType="java.lang.Integer">
  764. SELECT COUNT(id_)
  765. FROM student_payment_order spo
  766. WHERE spo.group_type_ = 'SPORADIC'
  767. AND spo.music_group_id_ = #{sporadicId}
  768. </select>
  769. <!-- 查找支付成功和支付中订单 -->
  770. <select id="findOrganPayOrderNum" resultType="int">
  771. SELECT COUNT(*)
  772. FROM student_payment_order
  773. WHERE organ_id_ = #{organId}
  774. AND status_ IN ('SUCCESS', 'ING')
  775. </select>
  776. <!-- 获取每月用户的对应类型订单订单 -->
  777. <select id="getOrderByMonthAndType" resultType="com.ym.mec.biz.dal.dto.OrderByTypeExportDto">
  778. SELECT o.name_ organName, spo.user_id_ studentId,su.username_ studentName,spo.type_ orderType,
  779. spo.actual_amount_ actualAmount,spo.music_group_id_ musicGroupId,spo.group_type_ groupType,spo.create_time_
  780. createTime
  781. FROM student_payment_order spo
  782. LEFT JOIN sys_user su on spo.user_id_ = su.id_
  783. LEFT JOIN organization o ON o.id_ = spo.id_
  784. WHERE spo.status_ = 'SUCCESS'
  785. <if test="organIds != null">
  786. AND FIND_IN_SET (spo.organ_id_,#{organIds})
  787. </if>
  788. <if test="orderTypeList != null">
  789. AND spo.type_ IN
  790. <foreach collection="orderTypeList" item="orderType" open="(" close=")"
  791. separator=",">
  792. #{orderType}
  793. </foreach>
  794. </if>
  795. <if test="startTime != null">
  796. AND spo.create_time_ >= #{startTime}
  797. </if>
  798. <if test="endTime != null"><![CDATA[
  799. AND spo.create_time_ <= #{endTime}
  800. ]]></if>
  801. AND spo.actual_amount_ > 0
  802. </select>
  803. <select id="getUsers" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  804. SELECT username_ name, id_ userId, phone_ phone
  805. FROM sys_user
  806. WHERE id_ = #{search}
  807. OR username_ LIKE CONCAT('%', #{search}, '%')
  808. OR phone_ LIKE CONCAT('%', #{search}, '%')
  809. </select>
  810. <select id="lockOrder" resultMap="StudentPaymentOrder">
  811. SELECT *
  812. FROM student_payment_order
  813. WHERE id_ = #{id} FOR
  814. UPDATE
  815. </select>
  816. <select id="doubleEleven2020Statis" resultMap="luckStatis">
  817. SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums,
  818. SUM(IF(spo.class_group_id_ is null ,1,spo.class_group_id_)) times FROM student_payment_order spo
  819. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  820. WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
  821. AND spo.status_ = 'SUCCESS'
  822. AND spo.organ_id_ IN
  823. <foreach collection="organs" item="organ" open="(" close=")" separator=",">
  824. #{organ.id}
  825. </foreach>
  826. GROUP BY spo.organ_id_
  827. </select>
  828. <select id="getUserOrderNumByType" resultType="int">
  829. SELECT COUNT(*)
  830. FROM student_payment_order
  831. WHERE user_id_ = #{userId}
  832. AND status_ = 'SUCCESS'
  833. AND type_ = #{orderType}
  834. </select>
  835. <select id="getUserOrderByType" resultMap="StudentPaymentOrder">
  836. SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND type_=#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  837. </select>
  838. <select id="queryDouble11Students" resultMap="StudentVipDouble11Dto">
  839. SELECT
  840. su.id_ userId,
  841. su.username_ userName,
  842. su.phone_ phone,
  843. su.avatar_ avatar,
  844. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  845. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  846. FROM
  847. student_payment_order spo
  848. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  849. LEFT JOIN student s ON spo.user_id_=s.user_id_
  850. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  851. WHERE
  852. spo.status_ = 'SUCCESS'
  853. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  854. AND sci.title_ LIKE '双十一%'
  855. AND s.teacher_id_= #{teacherId}
  856. <if test="search!=null and search!=''">
  857. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  858. </if>
  859. GROUP BY
  860. spo.user_id_
  861. ORDER BY spo.user_id_
  862. <include refid="global.limit" />
  863. </select>
  864. <select id="countDouble11Students" resultType="int">
  865. SELECT
  866. COUNT(DISTINCT spo.user_id_)
  867. FROM
  868. student_payment_order spo
  869. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  870. LEFT JOIN student s ON spo.user_id_=s.user_id_
  871. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  872. WHERE
  873. spo.status_ = 'SUCCESS'
  874. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  875. AND sci.title_ LIKE '双十一%'
  876. AND s.teacher_id_= #{teacherId}
  877. <if test="search!=null and search!=''">
  878. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  879. </if>;
  880. </select>
  881. <select id="findStudentsDouble11Infos" resultMap="StudentVipDouble11Dto">
  882. SELECT
  883. su.id_ userId,
  884. su.username_ userName,
  885. su.phone_ phone,
  886. su.avatar_ avatar,
  887. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  888. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  889. FROM
  890. student_payment_order spo
  891. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  892. LEFT JOIN student s ON spo.user_id_=s.user_id_
  893. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  894. WHERE
  895. spo.status_ = 'SUCCESS'
  896. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  897. AND sci.title_ LIKE '双十一%'
  898. AND spo.user_id_ IN
  899. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  900. #{studentId}
  901. </foreach>
  902. GROUP BY
  903. spo.user_id_
  904. </select>
  905. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="applyOrderAndDetail"
  906. extends="StudentPaymentOrder">
  907. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  908. <result column="detail_id_" property="id"/>
  909. <result column="detail_type_" property="type"/>
  910. <result column="detail_price_" property="price"/>
  911. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  912. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  913. <result column="goods_id" property="id"/>
  914. <result column="goods_name" property="name"/>
  915. <result column="complementGoodsIdList" property="complementGoodsIdList"/>
  916. </collection>
  917. </collection>
  918. </resultMap>
  919. <select id="getUserApplyOrders" resultMap="applyOrderAndDetail" parameterType="map">
  920. SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  921. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  922. g.id_ goods_id, g.name_ goods_name,g.complement_goods_id_list_ complementGoodsIdList
  923. FROM student_payment_order spo
  924. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  925. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  926. WHERE spo.user_id_ = #{userId} AND spo.type_='APPLY' AND spo.music_group_id_=#{musicGroupId}
  927. ORDER BY spo.id_ desc
  928. </select>
  929. <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
  930. SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
  931. </select>
  932. <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
  933. SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
  934. </select>
  935. <select id="getMoneyInMusicApply" resultMap="Mapper">
  936. SELECT spo.music_group_id_ key_, sum(case when a.id_ is null then spo.expect_amount_ else (spo.expect_amount_ + a.goods_margin_) end) value_ from student_payment_order spo LEFT JOIN
  937. (
  938. SELECT * FROM subject_change WHERE id_ in
  939. (SELECT max(sc.id_) id_ from subject_change sc WHERE sc.status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ desc)
  940. ) a on spo.music_group_id_ = a.music_group_id_ and spo.user_id_ = a.student_id_
  941. WHERE spo.music_group_id_ IN
  942. <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
  943. #{musicGroupId}
  944. </foreach>
  945. AND spo.type_ = 'APPLY' and spo.status_ = 'SUCCESS'
  946. GROUP BY spo.music_group_id_
  947. </select>
  948. </mapper>