StudentPaymentOrderMapper.xml 47 KB

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