StudentPaymentOrderMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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="trans_no_" property="transNo"/>
  21. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  22. <result column="memo_" property="memo"/>
  23. <result column="create_time_" property="createTime"/>
  24. <result column="update_time_" property="updateTime"/>
  25. <result column="payment_channel_" property="paymentChannel"/>
  26. <result column="payment_business_channel_" property="paymentBusinessChannel"/>
  27. <result column="payment_account_no_" property="paymentAccountNo"/>
  28. <result column="mer_nos_" property="merNos"/>
  29. <result column="order_no_" property="orderNo"/>
  30. <result column="music_group_id_" property="musicGroupId"/>
  31. <result column="class_group_id_" property="classGroupId"/>
  32. <result column="pay_time_" property="payTime"/>
  33. <result column="version_" property="version"/>
  34. </resultMap>
  35. <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" extends="StudentPaymentOrder"
  36. id="PaymentOrderAndStudentInfo">
  37. <result column="username_" property="user.username"/>
  38. <result column="phone_" property="user.phone"/>
  39. </resultMap>
  40. <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
  41. <result column="id_" property="id"/>
  42. <result column="goods_category_id_" property="goodsCategoryId"/>
  43. <result column="sn_" property="sn"/>
  44. <result column="name_" property="name"/>
  45. <result column="brand_" property="brand"/>
  46. <result column="specification_" property="specification"/>
  47. <result column="image_" property="image"/>
  48. <result column="stock_count_" property="stockCount"/>
  49. <result column="sell_count_" property="sellCount"/>
  50. <result column="market_price_" property="marketPrice"/>
  51. <result column="discount_price_" property="discountPrice"/>
  52. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  53. <result column="brief_" property="brief"/>
  54. <result column="desc_" property="desc"/>
  55. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  56. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  57. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  58. <result column="memo_" property="memo"/>
  59. <result column="publish_time_" property="publishTime"/>
  60. <result column="create_time_" property="createTime"/>
  61. <result column="update_time_" property="updateTime"/>
  62. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  63. </resultMap>
  64. <!-- 根据主键查询一条记录 -->
  65. <select id="get" resultMap="StudentPaymentOrder">
  66. SELECT *
  67. FROM student_payment_order
  68. WHERE id_ = #{id}
  69. </select>
  70. <!-- 全查询 -->
  71. <select id="findAll" resultMap="StudentPaymentOrder">
  72. SELECT *
  73. FROM student_payment_order
  74. ORDER BY id_
  75. </select>
  76. <!-- 向数据库增加一条记录 -->
  77. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
  78. keyColumn="id" keyProperty="id">
  79. INSERT INTO student_payment_order
  80. (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
  81. per_amount_,
  82. balance_payment_amount_, remit_fee_, trans_no_,
  83. status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
  84. payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_)
  85. VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. #{userId}, #{organId}, #{routingOrganId},
  87. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  88. #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
  89. #{remitFee}, #{transNo},
  90. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
  91. #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
  92. #{musicGroupId},
  93. #{classGroupId})
  94. </insert>
  95. <!-- 根据主键查询一条记录 -->
  96. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  97. UPDATE student_payment_order
  98. <set>
  99. <if test="status != null">
  100. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. <if test="groupType != null">
  103. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  104. </if>
  105. <if test="orderNo != null">
  106. order_no_ = #{orderNo},
  107. </if>
  108. <if test="classGroupId != null">
  109. class_group_id_ = #{classGroupId},
  110. </if>
  111. <if test="expectAmount != null">
  112. expect_amount_ = #{expectAmount},
  113. </if>
  114. <if test="memo != null">
  115. memo_ = #{memo},
  116. </if>
  117. <if test="paymentChannel != null">
  118. payment_channel_ = #{paymentChannel},
  119. </if>
  120. <if test="userId != null">
  121. user_id_ = #{userId},
  122. </if>
  123. <if test="paymentAccountNo != null">
  124. payment_account_no_ = #{paymentAccountNo},
  125. </if>
  126. <if test="merNos != null">
  127. mer_nos_ = #{merNos},
  128. </if>
  129. <if test="updateTime != null">
  130. update_time_ = NOW(),
  131. </if>
  132. <if test="paymentBusinessChannel != null">
  133. payment_business_channel_ = #{paymentBusinessChannel},
  134. </if>
  135. <if test="transNo != null">
  136. trans_no_ = #{transNo},
  137. </if>
  138. <if test="actualAmount != null">
  139. actual_amount_ = #{actualAmount},
  140. </if>
  141. <if test="comAmount != null">
  142. com_amount_ = #{comAmount},
  143. </if>
  144. <if test="perAmount != null">
  145. per_amount_ = #{perAmount},
  146. </if>
  147. <if test="balancePaymentAmount != null">
  148. balance_payment_amount_ = #{balancePaymentAmount},
  149. </if>
  150. <if test="remitFee != null">
  151. remit_fee_ = #{remitFee},
  152. </if>
  153. <if test="type != null">
  154. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  155. </if>
  156. <if test="musicGroupId != null">
  157. music_group_id_ = #{musicGroupId},
  158. </if>
  159. <if test="organId != null">
  160. organ_id_ = #{organId},
  161. </if>
  162. <if test="routingOrganId != null">
  163. routing_organ_id_ = #{routingOrganId},
  164. </if>
  165. <if test="payTime != null">
  166. pay_time_ = #{payTime},
  167. </if>
  168. <if test="version != null">
  169. version_ = version_+1,
  170. </if>
  171. </set>
  172. WHERE id_ = #{id} AND version_ = #{version}
  173. </update>
  174. <!-- 根据主键删除一条记录 -->
  175. <delete id="delete">
  176. DELETE
  177. FROM student_payment_order
  178. WHERE id_ = #{id}
  179. </delete>
  180. <!-- 分页查询 -->
  181. <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  182. SELECT spo.*,u.username_,u.phone_ FROM student_payment_order spo
  183. left join sys_user u on spo.user_id_ = u.id_
  184. <include refid="queryPaymentOrder"/>
  185. ORDER BY spo.id_ DESC
  186. <include refid="global.limit"/>
  187. </select>
  188. <!-- 查询当前表的总记录数 -->
  189. <select id="queryCount" resultType="int" parameterType="map">
  190. SELECT COUNT(spo.id_) FROM student_payment_order spo
  191. left join sys_user u on spo.user_id_ = u.id_
  192. <include refid="queryPaymentOrder"/>
  193. </select>
  194. <sql id="queryPaymentOrder">
  195. <where>
  196. <if test="organId != null">
  197. AND FIND_IN_SET(spo.organ_id_,#{organId})
  198. </if>
  199. <if test="orderStartDate != null">
  200. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  201. </if>
  202. <if test="orderEndDate != null">
  203. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  204. </if>
  205. <if test="paymentType != null">
  206. AND spo.type_ = #{paymentType}
  207. </if>
  208. <if test="remark != null">
  209. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  210. </if>
  211. <if test="studentId != null">
  212. AND spo.user_id_ = #{studentId}
  213. </if>
  214. <if test="paymentStatus != null">
  215. AND spo.status_ = #{paymentStatus}
  216. </if>
  217. <if test="paymentChannel != null">
  218. AND spo.payment_channel_ NOT IN (#{paymentChannel})
  219. </if>
  220. <if test='orderType != null and orderType.toString()=="1".toString()'>
  221. AND spo.com_amount_ > 0
  222. </if>
  223. <if test='orderType != null and orderType.toString()=="2".toString()'>
  224. AND spo.per_amount_ > 0
  225. </if>
  226. <if test="routingOrganId != null">
  227. AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
  228. </if>
  229. <if test="actualAmount != null">
  230. AND spo.actual_amount_ >= #{actualAmount}
  231. </if>
  232. <if test="balancePaymentAmount != null">
  233. AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
  234. </if>
  235. <if test="orderNo != null">
  236. AND spo.order_no_ >= #{orderNo}
  237. </if>
  238. <if test="merNos != null">
  239. AND spo.mer_nos_ >= #{merNos}
  240. </if>
  241. <if test="transNo != null">
  242. AND spo.trans_no_ >= #{transNo}
  243. </if>
  244. <if test="chargeType != null">
  245. AND spo.group_type_='SPORADIC'
  246. AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  247. </if>
  248. </where>
  249. </sql>
  250. <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
  251. select g.*
  252. from goods g
  253. where g.id_ in (SELECT spod.goods_id_list_
  254. FROM student_payment_order spo
  255. left join
  256. student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  257. where spo.music_group_id_ =
  258. #{musicGroupId}
  259. and spo.type_ = 'APPLY'
  260. and spod.type_ =
  261. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  262. </select>
  263. <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
  264. SELECT spo.*
  265. FROM student_payment_order spo
  266. WHERE spo.user_id_ = #{userId}
  267. AND spo.music_group_id_ = #{musicGroupId}
  268. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  269. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  270. and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  271. </select>
  272. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  273. SELECT
  274. spo.*
  275. FROM
  276. student_payment_order spo
  277. WHERE spo.user_id_=#{userId}
  278. AND spo.music_group_id_=#{vipGroupId}
  279. <if test="status!=null and status!=''">
  280. AND spo.status_=#{status}
  281. </if>
  282. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  283. </select>
  284. <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
  285. SELECT SUM(cssp.expect_price_)
  286. FROM course_schedule_student_payment cssp
  287. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  288. WHERE cssp.user_id_ = #{userId}
  289. AND cssp.music_group_id_ = #{vipGroupId}
  290. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  291. </select>
  292. <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
  293. SELECT spo.*
  294. FROM student_payment_order spo
  295. WHERE spo.user_id_ = #{userId}
  296. AND spo.music_group_id_ = #{vipGroupId}
  297. AND spo.status_ != 'FAILED'
  298. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  299. </select>
  300. <!-- 查询报名订单 -->
  301. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  302. SELECT *
  303. FROM student_payment_order
  304. WHERE music_group_id_ = #{musicGroupId}
  305. AND user_id_ = #{userId}
  306. AND type_ =
  307. 'APPLY'
  308. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  309. ORDER BY id_ DESC
  310. LIMIT 1
  311. </select>
  312. <!-- 根据订单号查询订单 -->
  313. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  314. SELECT *
  315. FROM student_payment_order
  316. WHERE order_no_ = #{orderNo}
  317. </select>
  318. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  319. SELECT *
  320. FROM student_payment_order
  321. WHERE music_group_id_ = #{musicGroupId}
  322. AND type_ =
  323. #{type}
  324. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  325. </select>
  326. <!-- 查找支付成功和支付中订单 -->
  327. <select id="findPayOrderNum" resultType="int">
  328. <![CDATA[
  329. SELECT COUNT(*)
  330. FROM student_payment_order
  331. WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
  332. ]]>
  333. </select>
  334. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  335. <result column="goods_id_" property="goodsId"/>
  336. <collection property="goodsName" ofType="string">
  337. <result column="goods_name_"/>
  338. </collection>
  339. </resultMap>
  340. <select id="findGoodsIds" resultMap="userGoodsDto">
  341. SELECT g.id_ goods_id_, g.name_ goods_name_
  342. FROM student_payment_order spo
  343. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  344. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  345. WHERE spo.type_ = 'APPLY'
  346. AND spo.status_ = 'SUCCESS'
  347. AND spod.goods_id_list_ IS NOT NULL
  348. AND spo.music_group_id_ = #{musicGroupId}
  349. AND spo.user_id_ = #{userId}
  350. </select>
  351. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  352. SELECT *
  353. FROM student_payment_order
  354. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  355. AND payment_channel_ = #{paymentChannel}
  356. LIMIT 100
  357. </select>
  358. <!-- 查询支付中超时订单 -->
  359. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  360. SELECT * FROM student_payment_order WHERE order_no_ IN
  361. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  362. #{orderNo}
  363. </foreach>
  364. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  365. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  366. </select>
  367. <select id="countStudentPaymentNum" resultType="int">
  368. select count(1)
  369. from student_payment_order
  370. where music_group_id_ = #{musicGroupId}
  371. AND status_ = 'SUCCESS'
  372. AND type_ = 'SMALL_CLASS_TO_BUY'
  373. </select>
  374. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  375. SELECT COUNT(*)
  376. FROM course_schedule_student_payment cssp
  377. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  378. WHERE cssp.user_id_ = #{userId}
  379. AND cssp.music_group_id_ = #{musicGroupId}
  380. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  381. </select>
  382. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  383. SELECT SUM(expect_amount_)
  384. FROM student_payment_order
  385. WHERE group_type_ = #{groupType}
  386. AND music_group_id_ = #{musicGroupId}
  387. AND status_ = 'SUCCESS'
  388. </select>
  389. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  390. SELECT *
  391. FROM student_payment_order
  392. WHERE id_ IN (SELECT MAX(sp.id_)
  393. FROM (SELECT *
  394. FROM student_payment_order
  395. WHERE group_type_ = #{groupType}
  396. AND type_ = 'APPLY'
  397. AND music_group_id_ = #{musicGroupId}
  398. AND status_ = 'SUCCESS'
  399. ORDER BY id_ DESC) sp
  400. GROUP BY sp.user_id_)
  401. </select>
  402. <select id="findOrderByGroupType" resultType="int">
  403. SELECT COUNT(id_) FROM student_payment_order
  404. WHERE group_type_ = #{groupType}
  405. AND user_id_ = #{userId}
  406. AND music_group_id_ = #{sporadicId}
  407. <if test="status != null">
  408. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  409. </if>
  410. </select>
  411. <select id="queryActualAmount" resultType="java.util.Map">
  412. SELECT spo.actual_amount_ 'value',spo.id_ 'key'
  413. FROM student_payment_order spo
  414. WHERE spo.id_ IN
  415. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  416. #{item}
  417. </foreach>
  418. </select>
  419. <select id="findFixOrder" resultMap="StudentPaymentOrder">
  420. SELECT *
  421. FROM student_payment_order
  422. where status_ = 'SUCCESS'
  423. AND type_ = 'APPLY'
  424. AND actual_amount_ > 0
  425. and mer_nos_ IS NULL
  426. LIMIT 100
  427. </select>
  428. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  429. extends="StudentPaymentOrder">
  430. <result column="organ_name" property="organName"/>
  431. <result column="username_" property="user.username"/>
  432. <result column="charge_type_" property="chargeType"/>
  433. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  434. <result column="detail_id_" property="id"/>
  435. <result column="detail_type_" property="type"/>
  436. <result column="detail_price_" property="price"/>
  437. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  438. </collection>
  439. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  440. <result column="goods_id" property="id"/>
  441. <result column="goods_name" property="name"/>
  442. </collection>
  443. </resultMap>
  444. <!-- 分页查询 -->
  445. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  446. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  447. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  448. sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name
  449. FROM student_payment_order spo
  450. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  451. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  452. <if test='orderType != null and orderType.toString()=="0".toString()'>
  453. LEFT JOIN organization o on spo.organ_id_ = o.id_
  454. </if>
  455. <if test='orderType != null and orderType.toString()=="1".toString()'>
  456. LEFT JOIN organization o on spo.organ_id_ = o.id_
  457. </if>
  458. <if test='orderType != null and orderType.toString()=="2".toString()'>
  459. LEFT JOIN organization o on spo.organ_id_ = o.id_
  460. </if>
  461. <if test='orderType != null and orderType.toString()=="3".toString()'>
  462. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  463. </if>
  464. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  465. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  466. <include refid="queryPaymentOrder"/>
  467. ORDER BY spo.id_ ASC
  468. </select>
  469. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  470. <result property="organName" column="organ_name_"/>
  471. <result property="title" column="title_"/>
  472. <result property="type" column="type_"/>
  473. <result property="amount" column="amount_"/>
  474. <result property="createTime" column="create_time_"/>
  475. <result property="payTime" column="pay_time_"/>
  476. <result property="username" column="username_"/>
  477. <result property="payStatus" column="pay_status_"/>
  478. </resultMap>
  479. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  480. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  481. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  482. FROM student_payment_order spo
  483. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  484. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  485. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  486. WHERE spo.type_ = 'SPORADIC'
  487. <include refid="sporadicQueryPageSql"/>
  488. ORDER BY spo.id_ DESC
  489. <include refid="global.limit"/>
  490. </select>
  491. <select id="countSporadicPage" resultType="java.lang.Integer">
  492. SELECT COUNT(spo.id_)
  493. FROM student_payment_order spo
  494. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  495. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  496. WHERE spo.type_ = 'SPORADIC'
  497. <include refid="sporadicQueryPageSql"/>
  498. </select>
  499. <sql id="sporadicQueryPageSql">
  500. <if test="organId != null">
  501. AND FIND_IN_SET(spo.organ_id_,#{organId})
  502. </if>
  503. <if test="search != null">
  504. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  505. </if>
  506. <if test="chargeType != null">
  507. AND sci.charge_type_ = #{chargeType}
  508. </if>
  509. <if test="payStatus != null">
  510. AND spo.status_ = #{payStatus}
  511. </if>
  512. </sql>
  513. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  514. <result property="organName" column="organName"/>
  515. <result property="nums" column="nums"/>
  516. <result property="money" column="money"/>
  517. </resultMap>
  518. <select id="getLuckStatis" resultMap="luckStatis">
  519. SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
  520. FROM student_payment_order spo
  521. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  522. WHERE spo.type_ = 'LUCK'
  523. AND spo.status_ = 'SUCCESS'
  524. GROUP BY spo.organ_id_
  525. ORDER BY nums DESC;
  526. </select>
  527. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  528. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  529. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
  530. status_ = 'SUCCESS' and organ_id_ not in (36,38)
  531. <if test="organId != null">
  532. and FIND_IN_SET(organ_id_,#{organId})
  533. </if>
  534. </select>
  535. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  536. select count(*)
  537. from student_payment_order
  538. where user_id_ = #{userId}
  539. and music_group_id_ = #{vipGroupId}
  540. and group_type_ = 'VIP'
  541. and status_ = 'SUCCESS'
  542. </select>
  543. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  544. select *
  545. from student_payment_order
  546. where user_id_ = #{userId}
  547. and music_group_id_ = #{vipGroupId}
  548. and group_type_ = 'VIP'
  549. </select>
  550. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  551. select * from student_payment_order
  552. where user_id_=#{userId}
  553. and music_group_id_=#{groupId}
  554. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  555. <if test="status!=null">
  556. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  557. </if>
  558. </select>
  559. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  560. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_) balance_payment_amount_ FROM student_payment_order spo
  561. <include refid="queryPaymentOrder"/>
  562. </select>
  563. <!-- 分页查询 -->
  564. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  565. SELECT spo.*,u.username_,u.phone_ FROM student_payment_order spo
  566. left join sys_user u on spo.user_id_ = u.id_
  567. <include refid="queryPaymentOrder"/>
  568. ORDER BY spo.id_ DESC
  569. <include refid="global.limit"/>
  570. </select>
  571. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  572. SELECT * FROM student_payment_order
  573. WHERE music_group_id_=#{groupId}
  574. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  575. <if test="status!=null">
  576. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  577. </if>
  578. </select>
  579. <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
  580. SELECT SUM(per_amount_)
  581. FROM student_payment_order
  582. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  583. AND create_time_ >= #{firstDate}
  584. AND create_time_ <= NOW()
  585. AND FIND_IN_SET(#{merNo}, mer_nos_)
  586. ]]>
  587. </select>
  588. <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
  589. SELECT SUM(actual_amount_) FROM student_payment_order spo
  590. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
  591. <include refid="queryPaymentOrder"/>
  592. </select>
  593. <select id="countGroupOrderWithoutFailed" resultType="int">
  594. SELECT COUNT(*)
  595. FROM student_payment_order spo
  596. LEFT JOIN class_group_student_mapper cgsm ON spo.music_group_id_=cgsm.music_group_id_ AND spo.user_id_=cgsm.user_id_
  597. WHERE spo.music_group_id_ = #{groupId}
  598. AND spo.status_ != 'FAILED'
  599. AND cgsm.status_!= 'QUIT'
  600. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  601. AND cgsm.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  602. </select>
  603. </mapper>