StudentPaymentOrderMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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_, type_, expect_amount_, actual_amount_, com_amount_, per_amount_,
  81. balance_payment_amount_, remit_fee_, trans_no_,
  82. status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
  83. payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_)
  84. VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  85. #{userId},#{organId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
  87. #{remitFee}, #{transNo},
  88. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
  89. #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo}, #{musicGroupId},
  90. #{classGroupId})
  91. </insert>
  92. <!-- 根据主键查询一条记录 -->
  93. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  94. UPDATE student_payment_order
  95. <set>
  96. <if test="status != null">
  97. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  98. </if>
  99. <if test="groupType != null">
  100. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. <if test="orderNo != null">
  103. order_no_ = #{orderNo},
  104. </if>
  105. <if test="classGroupId != null">
  106. class_group_id_ = #{classGroupId},
  107. </if>
  108. <if test="expectAmount != null">
  109. expect_amount_ = #{expectAmount},
  110. </if>
  111. <if test="memo != null">
  112. memo_ = #{memo},
  113. </if>
  114. <if test="paymentChannel != null">
  115. payment_channel_ = #{paymentChannel},
  116. </if>
  117. <if test="userId != null">
  118. user_id_ = #{userId},
  119. </if>
  120. <if test="paymentAccountNo != null">
  121. payment_account_no_ = #{paymentAccountNo},
  122. </if>
  123. <if test="merNos != null">
  124. mer_nos_ = #{merNos},
  125. </if>
  126. <if test="updateTime != null">
  127. update_time_ = NOW(),
  128. </if>
  129. <if test="paymentBusinessChannel != null">
  130. payment_business_channel_ = #{paymentBusinessChannel},
  131. </if>
  132. <if test="transNo != null">
  133. trans_no_ = #{transNo},
  134. </if>
  135. <if test="actualAmount != null">
  136. actual_amount_ = #{actualAmount},
  137. </if>
  138. <if test="comAmount != null">
  139. com_amount_ = #{comAmount},
  140. </if>
  141. <if test="perAmount != null">
  142. per_amount_ = #{perAmount},
  143. </if>
  144. <if test="balancePaymentAmount != null">
  145. balance_payment_amount_ = #{balancePaymentAmount},
  146. </if>
  147. <if test="remitFee != null">
  148. remit_fee_ = #{remitFee},
  149. </if>
  150. <if test="type != null">
  151. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  152. </if>
  153. <if test="musicGroupId != null">
  154. music_group_id_ = #{musicGroupId},
  155. </if>
  156. <if test="organId != null">
  157. organ_id_ = #{organId},
  158. </if>
  159. <if test="payTime != null">
  160. pay_time_ = #{payTime},
  161. </if>
  162. <if test="version != null">
  163. version_ = version_+1,
  164. </if>
  165. </set>
  166. WHERE id_ = #{id} AND version_ = #{version}
  167. </update>
  168. <!-- 根据主键删除一条记录 -->
  169. <delete id="delete">
  170. DELETE
  171. FROM student_payment_order
  172. WHERE id_ = #{id}
  173. </delete>
  174. <!-- 分页查询 -->
  175. <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  176. SELECT spo.*,u.username_,u.phone_ FROM student_payment_order spo
  177. left join sys_user u on spo.user_id_ = u.id_
  178. <include refid="queryPaymentOrder"/>
  179. ORDER BY spo.id_ DESC
  180. <include refid="global.limit"/>
  181. </select>
  182. <!-- 查询当前表的总记录数 -->
  183. <select id="queryCount" resultType="int" parameterType="map">
  184. SELECT COUNT(spo.id_) FROM student_payment_order spo
  185. left join sys_user u on spo.user_id_ = u.id_
  186. <include refid="queryPaymentOrder"/>
  187. </select>
  188. <sql id="queryPaymentOrder">
  189. <where>
  190. <if test="organId != null">
  191. AND FIND_IN_SET(spo.organ_id_,#{organId})
  192. </if>
  193. <if test="orderStartDate != null">
  194. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  195. </if>
  196. <if test="orderEndDate != null">
  197. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  198. </if>
  199. <if test="paymentType != null">
  200. AND spo.type_ = #{paymentType}
  201. </if>
  202. <if test="remark != null">
  203. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  204. </if>
  205. <if test="studentId != null">
  206. AND spo.user_id_ = #{studentId}
  207. </if>
  208. <if test="paymentStatus != null">
  209. AND spo.status_ = #{paymentStatus}
  210. </if>
  211. <if test="paymentChannel != null">
  212. AND spo.payment_channel_ NOT IN (#{paymentChannel})
  213. </if>
  214. <if test='orderType != null and orderType.toString()=="1".toString()'>
  215. AND spo.com_amount_ > 0
  216. </if>
  217. <if test='orderType != null and orderType.toString()=="2".toString()'>
  218. AND spo.per_amount_ > 0
  219. </if>
  220. </where>
  221. </sql>
  222. <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
  223. select g.*
  224. from goods g
  225. where g.id_ in (SELECT spod.goods_id_list_
  226. FROM student_payment_order spo
  227. left join
  228. student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  229. where spo.music_group_id_ =
  230. #{musicGroupId}
  231. and spo.type_ = 'APPLY'
  232. and spod.type_ =
  233. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  234. </select>
  235. <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
  236. SELECT
  237. spo.*
  238. FROM
  239. student_payment_order spo
  240. WHERE spo.user_id_=#{userId}
  241. AND spo.music_group_id_=#{musicGroupId}
  242. AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  243. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  244. and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  245. </select>
  246. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  247. SELECT
  248. spo.*
  249. FROM
  250. student_payment_order spo
  251. WHERE spo.user_id_=#{userId}
  252. AND spo.music_group_id_=#{vipGroupId}
  253. <if test="status!=null and status!=''">
  254. AND spo.status_=#{status}
  255. </if>
  256. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  257. </select>
  258. <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
  259. SELECT SUM(cssp.expect_price_)
  260. FROM course_schedule_student_payment cssp
  261. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  262. WHERE cssp.user_id_ = #{userId}
  263. AND cssp.music_group_id_ = #{vipGroupId}
  264. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  265. </select>
  266. <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
  267. SELECT spo.*
  268. FROM student_payment_order spo
  269. WHERE spo.user_id_ = #{userId}
  270. AND spo.music_group_id_ = #{vipGroupId}
  271. AND spo.status_ != 'FAILED'
  272. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  273. </select>
  274. <!-- 查询报名订单 -->
  275. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  276. SELECT *
  277. FROM student_payment_order
  278. WHERE music_group_id_ = #{musicGroupId}
  279. AND user_id_ = #{userId}
  280. AND type_ =
  281. 'APPLY'
  282. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  283. ORDER BY id_ DESC
  284. LIMIT 1
  285. </select>
  286. <!-- 根据订单号查询订单 -->
  287. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  288. SELECT *
  289. FROM student_payment_order
  290. WHERE order_no_ = #{orderNo}
  291. </select>
  292. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  293. SELECT *
  294. FROM student_payment_order
  295. WHERE music_group_id_ = #{musicGroupId}
  296. AND type_ =
  297. #{type}
  298. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  299. </select>
  300. <!-- 查找支付成功和支付中订单 -->
  301. <select id="findPayOrderNum" resultType="int">
  302. <![CDATA[
  303. SELECT COUNT(*)
  304. FROM student_payment_order
  305. WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
  306. ]]>
  307. </select>
  308. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  309. <result column="goods_id_" property="goodsId"/>
  310. <collection property="goodsName" ofType="string">
  311. <result column="goods_name_"/>
  312. </collection>
  313. </resultMap>
  314. <select id="findGoodsIds" resultMap="userGoodsDto">
  315. SELECT g.id_ goods_id_, g.name_ goods_name_
  316. FROM student_payment_order spo
  317. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  318. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  319. WHERE spo.type_ = 'APPLY'
  320. AND spo.status_ = 'SUCCESS'
  321. AND spod.goods_id_list_ IS NOT NULL
  322. AND spo.music_group_id_ = #{musicGroupId}
  323. AND spo.user_id_ = #{userId}
  324. </select>
  325. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  326. SELECT * FROM student_payment_order
  327. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  328. AND payment_channel_ = #{paymentChannel} LIMIT 100
  329. </select>
  330. <!-- 查询支付中超时订单 -->
  331. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  332. SELECT * FROM student_payment_order WHERE order_no_ IN
  333. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  334. #{orderNo}
  335. </foreach>
  336. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  337. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  338. </select>
  339. <select id="countStudentPaymentNum" resultType="int">
  340. select count(1)
  341. from student_payment_order
  342. where music_group_id_ = #{musicGroupId}
  343. AND status_ = 'SUCCESS'
  344. AND type_ = 'SMALL_CLASS_TO_BUY'
  345. </select>
  346. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  347. SELECT COUNT(*)
  348. FROM course_schedule_student_payment cssp
  349. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  350. WHERE cssp.user_id_ = #{userId}
  351. AND cssp.music_group_id_ = #{musicGroupId}
  352. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  353. </select>
  354. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  355. SELECT SUM(expect_amount_)
  356. FROM student_payment_order
  357. WHERE group_type_ = #{groupType}
  358. AND music_group_id_ = #{musicGroupId}
  359. AND status_='SUCCESS'
  360. </select>
  361. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  362. SELECT *
  363. FROM student_payment_order
  364. WHERE id_ IN (SELECT MAX(sp.id_)
  365. FROM (SELECT *
  366. FROM student_payment_order
  367. WHERE group_type_ = #{groupType}
  368. AND type_ = 'APPLY'
  369. AND music_group_id_ = #{musicGroupId}
  370. AND status_ = 'SUCCESS'
  371. ORDER BY id_ DESC) sp
  372. GROUP BY sp.user_id_)
  373. </select>
  374. <select id="findOrderByGroupType" resultType="int">
  375. SELECT COUNT(id_) FROM student_payment_order
  376. WHERE group_type_ = #{groupType}
  377. AND user_id_ = #{userId}
  378. AND music_group_id_ = #{sporadicId}
  379. <if test="status != null">
  380. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  381. </if>
  382. </select>
  383. <select id="queryActualAmount" resultType="java.util.Map">
  384. SELECT spo.actual_amount_ 'value',spo.id_ 'key'
  385. FROM student_payment_order spo
  386. WHERE spo.id_ IN
  387. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  388. #{item}
  389. </foreach>
  390. </select>
  391. <select id="findFixOrder" resultMap="StudentPaymentOrder">
  392. SELECT * FROM student_payment_order where status_ ='SUCCESS' AND type_='APPLY' AND actual_amount_> 0 and mer_nos_ IS NULL LIMIT 100
  393. </select>
  394. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  395. extends="StudentPaymentOrder">
  396. <result column="organ_name" property="organName"/>
  397. <result column="username_" property="user.username"/>
  398. <result column="charge_type_" property="chargeType"/>
  399. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  400. <result column="detail_id_" property="id"/>
  401. <result column="detail_type_" property="type"/>
  402. <result column="detail_price_" property="price"/>
  403. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  404. </collection>
  405. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  406. <result column="goods_id" property="id"/>
  407. <result column="goods_name" property="name"/>
  408. </collection>
  409. </resultMap>
  410. <!-- 分页查询 -->
  411. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  412. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_ detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  413. o.name_ organ_name,sci.charge_type_,g.id_ goods_id, g.name_ goods_name FROM student_payment_order spo
  414. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  415. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  416. LEFT JOIN organization o on spo.organ_id_ = o.id_
  417. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  418. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  419. <include refid="queryPaymentOrder"/>
  420. ORDER BY spo.id_ ASC
  421. </select>
  422. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  423. <result property="organName" column="organ_name_"/>
  424. <result property="title" column="title_"/>
  425. <result property="type" column="type_"/>
  426. <result property="amount" column="amount_"/>
  427. <result property="createTime" column="create_time_"/>
  428. <result property="payTime" column="pay_time_"/>
  429. <result property="username" column="username_"/>
  430. <result property="payStatus" column="pay_status_"/>
  431. </resultMap>
  432. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  433. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  434. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  435. FROM student_payment_order spo
  436. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  437. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  438. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  439. WHERE spo.type_ = 'SPORADIC'
  440. <include refid="sporadicQueryPageSql"/>
  441. ORDER BY spo.id_ DESC
  442. <include refid="global.limit"/>
  443. </select>
  444. <select id="countSporadicPage" resultType="java.lang.Integer">
  445. SELECT COUNT(spo.id_)
  446. FROM student_payment_order spo
  447. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  448. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  449. WHERE spo.type_ = 'SPORADIC'
  450. <include refid="sporadicQueryPageSql"/>
  451. </select>
  452. <sql id="sporadicQueryPageSql">
  453. <if test="organId != null">
  454. AND FIND_IN_SET(spo.organ_id_,#{organId})
  455. </if>
  456. <if test="search != null">
  457. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  458. </if>
  459. <if test="chargeType != null">
  460. AND sci.charge_type_ = #{chargeType}
  461. </if>
  462. <if test="payStatus != null">
  463. AND spo.status_ = #{payStatus}
  464. </if>
  465. </sql>
  466. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  467. <result property="organName" column="organName"/>
  468. <result property="nums" column="nums"/>
  469. <result property="money" column="money"/>
  470. </resultMap>
  471. <select id="getLuckStatis" resultMap="luckStatis">
  472. SELECT o.name_ organName, SUM(spo.actual_amount_) money ,COUNT(spo.id_) nums FROM student_payment_order spo LEFT JOIN organization o ON o.id_=spo.organ_id_
  473. WHERE spo.type_='LUCK' AND spo.status_='SUCCESS' GROUP BY spo.organ_id_ ORDER BY nums DESC;
  474. </select>
  475. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  476. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  477. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND status_ = 'SUCCESS'
  478. <if test="organId != null">
  479. and FIND_IN_SET(organ_id_,#{organId})
  480. </if>
  481. </select>
  482. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  483. select count(*) from student_payment_order where user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP' and status_='SUCCESS'
  484. </select>
  485. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  486. select * from student_payment_order where user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP'
  487. </select>
  488. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  489. select * from student_payment_order
  490. where user_id_=#{userId}
  491. and music_group_id_=#{groupId}
  492. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  493. <if test="status!=null">
  494. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  495. </if>
  496. </select>
  497. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  498. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_ FROM student_payment_order spo
  499. <include refid="queryPaymentOrder"/>
  500. </select>
  501. <!-- 分页查询 -->
  502. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  503. SELECT spo.*,u.username_,u.phone_ FROM student_payment_order spo
  504. left join sys_user u on spo.user_id_ = u.id_
  505. <include refid="queryPaymentOrder"/>
  506. ORDER BY spo.id_ DESC
  507. <include refid="global.limit"/>
  508. </select>
  509. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  510. SELECT * FROM student_payment_order
  511. WHERE music_group_id_=#{groupId}
  512. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  513. <if test="status!=null">
  514. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  515. </if>
  516. </select>
  517. </mapper>