StudentPaymentOrderMapper.xml 22 KB

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