StudentPaymentOrderMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. </where>
  236. </sql>
  237. <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
  238. select g.*
  239. from goods g
  240. where g.id_ in (SELECT spod.goods_id_list_
  241. FROM student_payment_order spo
  242. left join
  243. student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  244. where spo.music_group_id_ =
  245. #{musicGroupId}
  246. and spo.type_ = 'APPLY'
  247. and spod.type_ =
  248. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  249. </select>
  250. <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
  251. SELECT spo.*
  252. FROM student_payment_order spo
  253. WHERE spo.user_id_ = #{userId}
  254. AND spo.music_group_id_ = #{musicGroupId}
  255. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  256. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  257. and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  258. </select>
  259. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  260. SELECT
  261. spo.*
  262. FROM
  263. student_payment_order spo
  264. WHERE spo.user_id_=#{userId}
  265. AND spo.music_group_id_=#{vipGroupId}
  266. <if test="status!=null and status!=''">
  267. AND spo.status_=#{status}
  268. </if>
  269. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  270. </select>
  271. <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
  272. SELECT SUM(cssp.expect_price_)
  273. FROM course_schedule_student_payment cssp
  274. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  275. WHERE cssp.user_id_ = #{userId}
  276. AND cssp.music_group_id_ = #{vipGroupId}
  277. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  278. </select>
  279. <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
  280. SELECT spo.*
  281. FROM student_payment_order spo
  282. WHERE spo.user_id_ = #{userId}
  283. AND spo.music_group_id_ = #{vipGroupId}
  284. AND spo.status_ != 'FAILED'
  285. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  286. </select>
  287. <!-- 查询报名订单 -->
  288. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  289. SELECT *
  290. FROM student_payment_order
  291. WHERE music_group_id_ = #{musicGroupId}
  292. AND user_id_ = #{userId}
  293. AND type_ =
  294. 'APPLY'
  295. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  296. ORDER BY id_ DESC
  297. LIMIT 1
  298. </select>
  299. <!-- 根据订单号查询订单 -->
  300. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  301. SELECT *
  302. FROM student_payment_order
  303. WHERE order_no_ = #{orderNo}
  304. </select>
  305. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  306. SELECT *
  307. FROM student_payment_order
  308. WHERE music_group_id_ = #{musicGroupId}
  309. AND type_ =
  310. #{type}
  311. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  312. </select>
  313. <!-- 查找支付成功和支付中订单 -->
  314. <select id="findPayOrderNum" resultType="int">
  315. <![CDATA[
  316. SELECT COUNT(*)
  317. FROM student_payment_order
  318. WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
  319. ]]>
  320. </select>
  321. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  322. <result column="goods_id_" property="goodsId"/>
  323. <collection property="goodsName" ofType="string">
  324. <result column="goods_name_"/>
  325. </collection>
  326. </resultMap>
  327. <select id="findGoodsIds" resultMap="userGoodsDto">
  328. SELECT g.id_ goods_id_, g.name_ goods_name_
  329. FROM student_payment_order spo
  330. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  331. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  332. WHERE spo.type_ = 'APPLY'
  333. AND spo.status_ = 'SUCCESS'
  334. AND spod.goods_id_list_ IS NOT NULL
  335. AND spo.music_group_id_ = #{musicGroupId}
  336. AND spo.user_id_ = #{userId}
  337. </select>
  338. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  339. SELECT *
  340. FROM student_payment_order
  341. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  342. AND payment_channel_ = #{paymentChannel}
  343. LIMIT 100
  344. </select>
  345. <!-- 查询支付中超时订单 -->
  346. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  347. SELECT * FROM student_payment_order WHERE order_no_ IN
  348. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  349. #{orderNo}
  350. </foreach>
  351. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  352. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  353. </select>
  354. <select id="countStudentPaymentNum" resultType="int">
  355. select count(1)
  356. from student_payment_order
  357. where music_group_id_ = #{musicGroupId}
  358. AND status_ = 'SUCCESS'
  359. AND type_ = 'SMALL_CLASS_TO_BUY'
  360. </select>
  361. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  362. SELECT COUNT(*)
  363. FROM course_schedule_student_payment cssp
  364. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  365. WHERE cssp.user_id_ = #{userId}
  366. AND cssp.music_group_id_ = #{musicGroupId}
  367. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  368. </select>
  369. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  370. SELECT SUM(expect_amount_)
  371. FROM student_payment_order
  372. WHERE group_type_ = #{groupType}
  373. AND music_group_id_ = #{musicGroupId}
  374. AND status_ = 'SUCCESS'
  375. </select>
  376. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  377. SELECT *
  378. FROM student_payment_order
  379. WHERE id_ IN (SELECT MAX(sp.id_)
  380. FROM (SELECT *
  381. FROM student_payment_order
  382. WHERE group_type_ = #{groupType}
  383. AND type_ = 'APPLY'
  384. AND music_group_id_ = #{musicGroupId}
  385. AND status_ = 'SUCCESS'
  386. ORDER BY id_ DESC) sp
  387. GROUP BY sp.user_id_)
  388. </select>
  389. <select id="findOrderByGroupType" resultType="int">
  390. SELECT COUNT(id_) FROM student_payment_order
  391. WHERE group_type_ = #{groupType}
  392. AND user_id_ = #{userId}
  393. AND music_group_id_ = #{sporadicId}
  394. <if test="status != null">
  395. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  396. </if>
  397. </select>
  398. <select id="queryActualAmount" resultType="java.util.Map">
  399. SELECT spo.actual_amount_ 'value',spo.id_ 'key'
  400. FROM student_payment_order spo
  401. WHERE spo.id_ IN
  402. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  403. #{item}
  404. </foreach>
  405. </select>
  406. <select id="findFixOrder" resultMap="StudentPaymentOrder">
  407. SELECT *
  408. FROM student_payment_order
  409. where status_ = 'SUCCESS'
  410. AND type_ = 'APPLY'
  411. AND actual_amount_ > 0
  412. and mer_nos_ IS NULL
  413. LIMIT 100
  414. </select>
  415. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  416. extends="StudentPaymentOrder">
  417. <result column="organ_name" property="organName"/>
  418. <result column="username_" property="user.username"/>
  419. <result column="charge_type_" property="chargeType"/>
  420. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  421. <result column="detail_id_" property="id"/>
  422. <result column="detail_type_" property="type"/>
  423. <result column="detail_price_" property="price"/>
  424. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  425. </collection>
  426. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  427. <result column="goods_id" property="id"/>
  428. <result column="goods_name" property="name"/>
  429. </collection>
  430. </resultMap>
  431. <!-- 分页查询 -->
  432. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  433. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  434. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  435. sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name
  436. FROM student_payment_order spo
  437. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  438. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  439. <if test='orderType != null and orderType.toString()=="0".toString()'>
  440. LEFT JOIN organization o on spo.organ_id_ = o.id_
  441. </if>
  442. <if test='orderType != null and orderType.toString()=="1".toString()'>
  443. LEFT JOIN organization o on spo.organ_id_ = o.id_
  444. </if>
  445. <if test='orderType != null and orderType.toString()=="2".toString()'>
  446. LEFT JOIN organization o on spo.organ_id_ = o.id_
  447. </if>
  448. <if test='orderType != null and orderType.toString()=="3".toString()'>
  449. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  450. </if>
  451. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  452. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  453. <include refid="queryPaymentOrder"/>
  454. ORDER BY spo.id_ ASC
  455. </select>
  456. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  457. <result property="organName" column="organ_name_"/>
  458. <result property="title" column="title_"/>
  459. <result property="type" column="type_"/>
  460. <result property="amount" column="amount_"/>
  461. <result property="createTime" column="create_time_"/>
  462. <result property="payTime" column="pay_time_"/>
  463. <result property="username" column="username_"/>
  464. <result property="payStatus" column="pay_status_"/>
  465. </resultMap>
  466. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  467. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  468. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  469. FROM student_payment_order spo
  470. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  471. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  472. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  473. WHERE spo.type_ = 'SPORADIC'
  474. <include refid="sporadicQueryPageSql"/>
  475. ORDER BY spo.id_ DESC
  476. <include refid="global.limit"/>
  477. </select>
  478. <select id="countSporadicPage" resultType="java.lang.Integer">
  479. SELECT COUNT(spo.id_)
  480. FROM student_payment_order spo
  481. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  482. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  483. WHERE spo.type_ = 'SPORADIC'
  484. <include refid="sporadicQueryPageSql"/>
  485. </select>
  486. <sql id="sporadicQueryPageSql">
  487. <if test="organId != null">
  488. AND FIND_IN_SET(spo.organ_id_,#{organId})
  489. </if>
  490. <if test="search != null">
  491. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  492. </if>
  493. <if test="chargeType != null">
  494. AND sci.charge_type_ = #{chargeType}
  495. </if>
  496. <if test="payStatus != null">
  497. AND spo.status_ = #{payStatus}
  498. </if>
  499. </sql>
  500. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  501. <result property="organName" column="organName"/>
  502. <result property="nums" column="nums"/>
  503. <result property="money" column="money"/>
  504. </resultMap>
  505. <select id="getLuckStatis" resultMap="luckStatis">
  506. SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
  507. FROM student_payment_order spo
  508. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  509. WHERE spo.type_ = 'LUCK'
  510. AND spo.status_ = 'SUCCESS'
  511. GROUP BY spo.organ_id_
  512. ORDER BY nums DESC;
  513. </select>
  514. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  515. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  516. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
  517. status_ = 'SUCCESS' and organ_id_ not in (36,38)
  518. <if test="organId != null">
  519. and FIND_IN_SET(organ_id_,#{organId})
  520. </if>
  521. </select>
  522. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  523. select count(*)
  524. from student_payment_order
  525. where user_id_ = #{userId}
  526. and music_group_id_ = #{vipGroupId}
  527. and group_type_ = 'VIP'
  528. and status_ = 'SUCCESS'
  529. </select>
  530. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  531. select *
  532. from student_payment_order
  533. where user_id_ = #{userId}
  534. and music_group_id_ = #{vipGroupId}
  535. and group_type_ = 'VIP'
  536. </select>
  537. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  538. select * from student_payment_order
  539. where user_id_=#{userId}
  540. and music_group_id_=#{groupId}
  541. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  542. <if test="status!=null">
  543. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  544. </if>
  545. </select>
  546. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  547. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_ FROM student_payment_order spo
  548. <include refid="queryPaymentOrder"/>
  549. </select>
  550. <!-- 分页查询 -->
  551. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  552. SELECT spo.*,u.username_,u.phone_ FROM student_payment_order spo
  553. left join sys_user u on spo.user_id_ = u.id_
  554. <include refid="queryPaymentOrder"/>
  555. ORDER BY spo.id_ DESC
  556. <include refid="global.limit"/>
  557. </select>
  558. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  559. SELECT * FROM student_payment_order
  560. WHERE music_group_id_=#{groupId}
  561. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  562. <if test="status!=null">
  563. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  564. </if>
  565. </select>
  566. <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
  567. SELECT SUM(per_amount_)
  568. FROM student_payment_order
  569. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  570. AND create_time_ >= #{firstDate}
  571. AND create_time_ <= NOW()
  572. AND FIND_IN_SET(#{merNo}, mer_nos_)
  573. ]]>
  574. </select>
  575. </mapper>