StudentPaymentOrderMapper.xml 22 KB

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