StudentPaymentOrderMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  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.id_ = #{orderNo} OR 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. </select>
  431. <select id="queryByBatchNo" resultMap="StudentPaymentOrder" parameterType="map">
  432. SELECT *
  433. FROM student_payment_order
  434. WHERE batch_no_ = #{batchNo}
  435. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  436. and user_id_ = #{userId}
  437. </select>
  438. <!-- 根据订单号查询订单 -->
  439. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  440. SELECT *
  441. FROM student_payment_order
  442. WHERE order_no_ = #{orderNo}
  443. </select>
  444. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  445. SELECT *
  446. FROM student_payment_order
  447. WHERE music_group_id_ = #{musicGroupId}
  448. AND type_ =
  449. #{type}
  450. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  451. </select>
  452. <!-- 查找支付成功和支付中订单 -->
  453. <select id="findPayOrderNum" resultType="int">
  454. <![CDATA[
  455. SELECT COUNT(*)
  456. FROM student_payment_order
  457. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  458. ]]>
  459. </select>
  460. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  461. <result column="goods_id_" property="goodsId"/>
  462. <collection property="goodsName" ofType="string">
  463. <result column="goods_name_"/>
  464. </collection>
  465. </resultMap>
  466. <select id="findGoodsIds" resultMap="userGoodsDto">
  467. SELECT g.id_ goods_id_, g.name_ goods_name_
  468. FROM student_payment_order spo
  469. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  470. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  471. WHERE spo.type_ = 'APPLY'
  472. AND spo.status_ = 'SUCCESS'
  473. AND spod.goods_id_list_ IS NOT NULL
  474. AND spo.music_group_id_ = #{musicGroupId}
  475. AND spo.user_id_ = #{userId}
  476. </select>
  477. <select id="getUserGoods" resultMap="userGoodsDto">
  478. SELECT id_ goods_id_, name_ goods_name_ FROM goods WHERE FIND_IN_SET(id_,#{ids})
  479. </select>
  480. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  481. SELECT *
  482. FROM student_payment_order
  483. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  484. AND payment_channel_ = #{paymentChannel}
  485. LIMIT 100
  486. </select>
  487. <!-- 查询支付中超时订单 -->
  488. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  489. SELECT * FROM student_payment_order WHERE order_no_ IN
  490. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  491. #{orderNo}
  492. </foreach>
  493. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  494. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  495. </select>
  496. <select id="countStudentPaymentNum" resultType="int">
  497. select count(DISTINCT user_id_)
  498. from student_payment_order
  499. where music_group_id_ = #{musicGroupId}
  500. AND status_ = 'SUCCESS'
  501. AND type_ = 'SMALL_CLASS_TO_BUY'
  502. </select>
  503. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  504. SELECT COUNT(*)
  505. FROM course_schedule_student_payment cssp
  506. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  507. WHERE cssp.user_id_ = #{userId}
  508. AND cssp.music_group_id_ = #{musicGroupId}
  509. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  510. </select>
  511. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  512. SELECT SUM(expect_amount_)
  513. FROM student_payment_order
  514. WHERE group_type_ = #{groupType}
  515. AND music_group_id_ = #{musicGroupId}
  516. AND status_ = 'SUCCESS'
  517. </select>
  518. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  519. SELECT *
  520. FROM student_payment_order
  521. WHERE id_ IN (SELECT id_
  522. FROM student_payment_order
  523. WHERE group_type_ = #{groupType}
  524. AND type_ = 'APPLY'
  525. AND music_group_id_ = #{musicGroupId}
  526. AND status_ = 'SUCCESS'
  527. ORDER BY id_ DESC)
  528. </select>
  529. <select id="findOrderByGroupType" resultType="int">
  530. SELECT COUNT(id_) FROM student_payment_order
  531. WHERE group_type_ = #{groupType}
  532. AND user_id_ = #{userId}
  533. AND music_group_id_ = #{sporadicId}
  534. <if test="status != null">
  535. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  536. </if>
  537. </select>
  538. <select id="findPaymentOrderByGroupType" resultMap="StudentPaymentOrder">
  539. SELECT * FROM student_payment_order
  540. WHERE group_type_ = #{groupType}
  541. AND user_id_ = #{userId}
  542. AND music_group_id_ = #{sporadicId}
  543. <if test="status != null">
  544. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  545. </if>
  546. </select>
  547. <select id="queryExpectAmount" resultType="java.util.Map">
  548. SELECT spo.expect_amount_ 'value',spo.id_ 'key'
  549. FROM student_payment_order spo
  550. WHERE spo.id_ IN
  551. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  552. #{item}
  553. </foreach>
  554. </select>
  555. <select id="findFixOrder" resultMap="StudentPaymentOrder">
  556. SELECT *
  557. FROM student_payment_order
  558. where status_ = 'SUCCESS'
  559. AND type_ = 'APPLY'
  560. AND actual_amount_ > 0
  561. and mer_nos_ IS NULL
  562. LIMIT 100
  563. </select>
  564. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  565. extends="StudentPaymentOrder">
  566. <result column="organ_name" property="organName"/>
  567. <result column="username_" property="user.username"/>
  568. <result column="charge_type_" property="chargeType"/>
  569. <result column="routeMerNo" property="routeMerNo"/>
  570. <result column="routeAmount" property="routeAmount"/>
  571. <result column="routeBalance" property="routeBalance"/>
  572. <result column="sale_amount_" property="saleAmount"/>
  573. <result column="service_amount_" property="serviceAmount"/>
  574. <result column="routeBalance" property="routeBalance"/>
  575. <result column="feeFlag" property="feeFlag"/>
  576. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  577. <result column="detail_id_" property="id"/>
  578. <result column="detail_type_" property="type"/>
  579. <result column="detail_price_" property="price"/>
  580. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  581. </collection>
  582. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  583. <result column="goods_id" property="id"/>
  584. <result column="goods_name" property="name"/>
  585. </collection>
  586. </resultMap>
  587. <!-- 分页查询 -->
  588. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  589. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  590. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  591. sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name
  592. FROM student_payment_order spo
  593. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  594. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  595. <if test='orderType != null and orderType.toString()=="0".toString()'>
  596. LEFT JOIN organization o on spo.organ_id_ = o.id_
  597. </if>
  598. <if test='orderType != null and orderType.toString()=="1".toString()'>
  599. LEFT JOIN organization o on spo.organ_id_ = o.id_
  600. </if>
  601. <if test='orderType != null and orderType.toString()=="2".toString()'>
  602. LEFT JOIN organization o on spo.organ_id_ = o.id_
  603. </if>
  604. <if test='orderType != null and orderType.toString()=="3".toString()'>
  605. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  606. </if>
  607. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  608. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  609. <include refid="queryPaymentOrder"/>
  610. ORDER BY spo.id_ ASC
  611. </select>
  612. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  613. <result property="organName" column="organ_name_"/>
  614. <result property="title" column="title_"/>
  615. <result property="type" column="type_"/>
  616. <result property="amount" column="amount_"/>
  617. <result property="createTime" column="create_time_"/>
  618. <result property="payTime" column="pay_time_"/>
  619. <result property="username" column="username_"/>
  620. <result property="payStatus" column="pay_status_"/>
  621. </resultMap>
  622. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  623. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  624. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  625. FROM student_payment_order spo
  626. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  627. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  628. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  629. WHERE spo.type_ = 'SPORADIC'
  630. <include refid="sporadicQueryPageSql"/>
  631. ORDER BY spo.id_ DESC
  632. <include refid="global.limit"/>
  633. </select>
  634. <select id="countSporadicPage" resultType="java.lang.Integer">
  635. SELECT COUNT(spo.id_)
  636. FROM student_payment_order spo
  637. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  638. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  639. WHERE spo.type_ = 'SPORADIC'
  640. <include refid="sporadicQueryPageSql"/>
  641. </select>
  642. <sql id="sporadicQueryPageSql">
  643. <if test="organId != null">
  644. AND FIND_IN_SET(spo.organ_id_,#{organId})
  645. </if>
  646. <if test="search != null">
  647. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  648. </if>
  649. <if test="chargeType != null">
  650. AND sci.charge_type_ = #{chargeType}
  651. </if>
  652. <if test="payStatus != null">
  653. AND spo.status_ = #{payStatus}
  654. </if>
  655. </sql>
  656. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  657. <result property="organId" column="organId"/>
  658. <result property="organName" column="organName"/>
  659. <result property="estimatedNums" column="estimatedNums"/>
  660. <result property="nums" column="nums"/>
  661. <result property="times" column="times"/>
  662. <result property="scale" column="scale"/>
  663. <result property="money" column="money"/>
  664. </resultMap>
  665. <select id="getLuckStatis" resultMap="luckStatis">
  666. SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
  667. FROM student_payment_order spo
  668. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  669. WHERE spo.type_ = 'LUCK'
  670. AND spo.status_ = 'SUCCESS'
  671. GROUP BY spo.organ_id_
  672. ORDER BY nums DESC;
  673. </select>
  674. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  675. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  676. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
  677. status_ = 'SUCCESS' and organ_id_ not in (36,38)
  678. <if test="organId != null">
  679. and FIND_IN_SET(organ_id_,#{organId})
  680. </if>
  681. </select>
  682. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  683. select count(*)
  684. from student_payment_order
  685. where user_id_ = #{userId}
  686. and music_group_id_ = #{vipGroupId}
  687. and group_type_ = 'VIP'
  688. and status_ = 'SUCCESS'
  689. </select>
  690. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  691. select *
  692. from student_payment_order
  693. where user_id_ = #{userId}
  694. and music_group_id_ = #{vipGroupId}
  695. and group_type_ = 'VIP'
  696. </select>
  697. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  698. select * from student_payment_order
  699. where user_id_=#{userId}
  700. and music_group_id_=#{groupId}
  701. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  702. <if test="status!=null">
  703. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  704. </if>
  705. </select>
  706. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  707. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_)
  708. balance_payment_amount_ FROM student_payment_order spo
  709. <include refid="queryPaymentOrder"/>
  710. </select>
  711. <!-- 分页查询 -->
  712. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  713. SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
  714. left join sys_user u on spo.user_id_ = u.id_
  715. left join organization o on o.id_ = spo.organ_id_
  716. <include refid="queryPaymentOrder"/>
  717. ORDER BY spo.id_ DESC
  718. <include refid="global.limit"/>
  719. </select>
  720. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  721. SELECT * FROM student_payment_order
  722. WHERE music_group_id_=#{groupId}
  723. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  724. <if test="status!=null">
  725. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  726. </if>
  727. </select>
  728. <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
  729. SELECT SUM(per_amount_)
  730. FROM student_payment_order
  731. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  732. AND create_time_ >= #{firstDate}
  733. AND create_time_ <= NOW()
  734. AND FIND_IN_SET(#{merNo}, mer_nos_)
  735. ]]>
  736. </select>
  737. <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
  738. SELECT SUM(actual_amount_) FROM student_payment_order spo
  739. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
  740. <include refid="queryPaymentOrder"/>
  741. </select>
  742. <select id="sumAccountAmount" resultType="java.math.BigDecimal">
  743. <![CDATA[
  744. SELECT SUM(actual_amount_)
  745. FROM student_payment_order
  746. WHERE status_ IN ('SUCCESS', 'ING')
  747. AND create_time_ >= #{firstDate}
  748. AND create_time_ <= NOW()
  749. AND mer_nos_ = #{merNo}
  750. ]]></select>
  751. <select id="countGroupOrderWithoutFailed" resultType="int">
  752. SELECT COUNT(*)
  753. FROM student_payment_order spo
  754. LEFT JOIN class_group_student_mapper cgsm
  755. ON spo.music_group_id_ = cgsm.music_group_id_ AND spo.user_id_ = cgsm.user_id_
  756. WHERE spo.music_group_id_ = #{groupId}
  757. AND spo.status_ != 'FAILED'
  758. AND cgsm.status_ != 'QUIT'
  759. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  760. AND cgsm.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  761. </select>
  762. <select id="countSporadicOrder" resultType="java.lang.Integer">
  763. SELECT COUNT(id_)
  764. FROM student_payment_order spo
  765. WHERE spo.group_type_ = 'SPORADIC'
  766. AND spo.music_group_id_ = #{sporadicId}
  767. </select>
  768. <!-- 查找支付成功和支付中订单 -->
  769. <select id="findOrganPayOrderNum" resultType="int">
  770. SELECT COUNT(*)
  771. FROM student_payment_order
  772. WHERE organ_id_ = #{organId}
  773. AND status_ IN ('SUCCESS', 'ING')
  774. </select>
  775. <!-- 获取每月用户的对应类型订单订单 -->
  776. <select id="getOrderByMonthAndType" resultType="com.ym.mec.biz.dal.dto.OrderByTypeExportDto">
  777. SELECT o.name_ organName, spo.user_id_ studentId,su.username_ studentName,spo.type_ orderType,
  778. spo.actual_amount_ actualAmount,spo.music_group_id_ musicGroupId,spo.group_type_ groupType,spo.create_time_
  779. createTime
  780. FROM student_payment_order spo
  781. LEFT JOIN sys_user su on spo.user_id_ = su.id_
  782. LEFT JOIN organization o ON o.id_ = spo.id_
  783. WHERE spo.status_ = 'SUCCESS'
  784. <if test="organIds != null">
  785. AND FIND_IN_SET (spo.organ_id_,#{organIds})
  786. </if>
  787. <if test="orderTypeList != null">
  788. AND spo.type_ IN
  789. <foreach collection="orderTypeList" item="orderType" open="(" close=")"
  790. separator=",">
  791. #{orderType}
  792. </foreach>
  793. </if>
  794. <if test="startTime != null">
  795. AND spo.create_time_ >= #{startTime}
  796. </if>
  797. <if test="endTime != null"><![CDATA[
  798. AND spo.create_time_ <= #{endTime}
  799. ]]></if>
  800. AND spo.actual_amount_ > 0
  801. </select>
  802. <select id="getUsers" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  803. SELECT username_ name, id_ userId, phone_ phone
  804. FROM sys_user
  805. WHERE id_ = #{search}
  806. OR username_ LIKE CONCAT('%', #{search}, '%')
  807. OR phone_ LIKE CONCAT('%', #{search}, '%')
  808. </select>
  809. <select id="lockOrder" resultMap="StudentPaymentOrder">
  810. SELECT *
  811. FROM student_payment_order
  812. WHERE id_ = #{id} FOR
  813. UPDATE
  814. </select>
  815. <select id="doubleEleven2020Statis" resultMap="luckStatis">
  816. SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums,
  817. SUM(IF(spo.class_group_id_ is null ,1,spo.class_group_id_)) times FROM student_payment_order spo
  818. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  819. WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
  820. AND spo.status_ = 'SUCCESS'
  821. AND spo.organ_id_ IN
  822. <foreach collection="organs" item="organ" open="(" close=")" separator=",">
  823. #{organ.id}
  824. </foreach>
  825. GROUP BY spo.organ_id_
  826. </select>
  827. <select id="getUserOrderNumByType" resultType="int">
  828. SELECT COUNT(*)
  829. FROM student_payment_order
  830. WHERE user_id_ = #{userId}
  831. AND status_ = 'SUCCESS'
  832. AND type_ = #{orderType}
  833. </select>
  834. <select id="getUserOrderByType" resultMap="StudentPaymentOrder">
  835. 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}
  836. </select>
  837. <select id="queryDouble11Students" resultMap="StudentVipDouble11Dto">
  838. SELECT
  839. su.id_ userId,
  840. su.username_ userName,
  841. su.phone_ phone,
  842. su.avatar_ avatar,
  843. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  844. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  845. FROM
  846. student_payment_order spo
  847. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  848. LEFT JOIN student s ON spo.user_id_=s.user_id_
  849. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  850. WHERE
  851. spo.status_ = 'SUCCESS'
  852. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  853. AND sci.title_ LIKE '双十一%'
  854. AND s.teacher_id_= #{teacherId}
  855. <if test="search!=null and search!=''">
  856. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  857. </if>
  858. GROUP BY
  859. spo.user_id_
  860. ORDER BY spo.user_id_
  861. <include refid="global.limit" />
  862. </select>
  863. <select id="countDouble11Students" resultType="int">
  864. SELECT
  865. COUNT(DISTINCT spo.user_id_)
  866. FROM
  867. student_payment_order spo
  868. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  869. LEFT JOIN student s ON spo.user_id_=s.user_id_
  870. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  871. WHERE
  872. spo.status_ = 'SUCCESS'
  873. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  874. AND sci.title_ LIKE '双十一%'
  875. AND s.teacher_id_= #{teacherId}
  876. <if test="search!=null and search!=''">
  877. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  878. </if>;
  879. </select>
  880. <select id="findStudentsDouble11Infos" resultMap="StudentVipDouble11Dto">
  881. SELECT
  882. su.id_ userId,
  883. su.username_ userName,
  884. su.phone_ phone,
  885. su.avatar_ avatar,
  886. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  887. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  888. FROM
  889. student_payment_order spo
  890. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  891. LEFT JOIN student s ON spo.user_id_=s.user_id_
  892. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  893. WHERE
  894. spo.status_ = 'SUCCESS'
  895. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  896. AND sci.title_ LIKE '双十一%'
  897. AND spo.user_id_ IN
  898. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  899. #{studentId}
  900. </foreach>
  901. GROUP BY
  902. spo.user_id_
  903. </select>
  904. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="applyOrderAndDetail"
  905. extends="StudentPaymentOrder">
  906. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  907. <result column="detail_id_" property="id"/>
  908. <result column="detail_type_" property="type"/>
  909. <result column="detail_price_" property="price"/>
  910. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  911. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  912. <result column="goods_id" property="id"/>
  913. <result column="goods_name" property="name"/>
  914. <result column="complementGoodsIdList" property="complementGoodsIdList"/>
  915. </collection>
  916. </collection>
  917. </resultMap>
  918. <select id="getUserApplyOrders" resultMap="applyOrderAndDetail" parameterType="map">
  919. SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  920. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  921. g.id_ goods_id, g.name_ goods_name,g.complement_goods_id_list_ complementGoodsIdList
  922. FROM student_payment_order spo
  923. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  924. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  925. WHERE spo.user_id_ = #{userId} AND spo.type_='APPLY' AND spo.music_group_id_=#{musicGroupId}
  926. ORDER BY spo.id_ desc
  927. </select>
  928. <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
  929. SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
  930. </select>
  931. <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
  932. SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
  933. </select>
  934. <select id="getMoneyInMusicApply" resultMap="Mapper">
  935. 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
  936. (
  937. SELECT * FROM subject_change WHERE id_ in
  938. (SELECT max(sc.id_) id_ from subject_change sc WHERE sc.status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ desc)
  939. ) a on spo.music_group_id_ = a.music_group_id_ and spo.user_id_ = a.student_id_
  940. WHERE spo.music_group_id_ IN
  941. <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
  942. #{musicGroupId}
  943. </foreach>
  944. AND spo.type_ = 'APPLY' and spo.status_ = 'SUCCESS'
  945. GROUP BY spo.music_group_id_
  946. </select>
  947. <select id="findByUserAndActive" resultMap="StudentPaymentOrder">
  948. SELECT spo.* FROM cloud_teacher_order cto
  949. LEFT JOIN student_payment_order spo ON spo.id_ = cto.order_id_
  950. WHERE spo.status_ NOT ('SUCCESS','ING') AND cto.active_remark_ = #{activeRemark}
  951. AND cto.remark_ = #{remark} AND cto.student_id_ = #{userId}
  952. <if test="status != null and status != ''">
  953. AND spo.status_ = #{status}
  954. </if>
  955. LIMIT 1
  956. </select>
  957. </mapper>