StudentPaymentOrderMapper.xml 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  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="course_remit_fee_" property="courseRemitFee"/>
  21. <result column="trans_no_" property="transNo"/>
  22. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  23. <result column="memo_" property="memo"/>
  24. <result column="create_time_" property="createTime"/>
  25. <result column="update_time_" property="updateTime"/>
  26. <result column="payment_channel_" property="paymentChannel"/>
  27. <result column="payment_business_channel_" property="paymentBusinessChannel"/>
  28. <result column="payment_account_no_" property="paymentAccountNo"/>
  29. <result column="mer_nos_" property="merNos"/>
  30. <result column="order_no_" property="orderNo"/>
  31. <result column="music_group_id_" property="musicGroupId"/>
  32. <result column="class_group_id_" property="classGroupId"/>
  33. <result column="pay_time_" property="payTime"/>
  34. <result column="version_" property="version"/>
  35. <result column="receive_status_" property="receiveStatus"/>
  36. <result column="batch_no_" property="batchNo"/>
  37. <result column="coupon_code_id_" property="couponCodeId"/>
  38. <result column="coupon_remit_fee_" property="couponRemitFee"/>
  39. <result column="activity_id_" property="activityId"/>
  40. <result column="activity_buy_num_" property="activityBuyNum"/>
  41. <result column="tenant_id_" property="tenantId"/>
  42. <result column="calender_id_" property="calenderId"/>
  43. </resultMap>
  44. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" extends="StudentPaymentOrder"
  45. id="PaymentOrderAndStudentInfo">
  46. <result column="username_" property="user.username"/>
  47. <result column="phone_" property="user.phone"/>
  48. <result column="organ_name_" property="organName"/>
  49. </resultMap>
  50. <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
  51. <result column="id_" property="id"/>
  52. <result column="goods_category_id_" property="goodsCategoryId"/>
  53. <result column="sn_" property="sn"/>
  54. <result column="name_" property="name"/>
  55. <result column="brand_" property="brand"/>
  56. <result column="specification_" property="specification"/>
  57. <result column="image_" property="image"/>
  58. <result column="stock_count_" property="stockCount"/>
  59. <result column="sell_count_" property="sellCount"/>
  60. <result column="market_price_" property="marketPrice"/>
  61. <result column="discount_price_" property="discountPrice"/>
  62. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  63. <result column="brief_" property="brief"/>
  64. <result column="desc_" property="desc"/>
  65. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  66. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  67. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  68. <result column="memo_" property="memo"/>
  69. <result column="publish_time_" property="publishTime"/>
  70. <result column="create_time_" property="createTime"/>
  71. <result column="update_time_" property="updateTime"/>
  72. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  73. </resultMap>
  74. <resultMap id="StudentVipDouble11Dto" type="com.ym.mec.biz.dal.dto.StudentVipDouble11Dto">
  75. <result column="payment_one_to_one_time_" property="paymentOneToOneTime"/>
  76. <result column="payment_one_to_two_time_" property="paymentOneToTwoTime"/>
  77. <result column="course_one_to_one_time_" property="courseOneToOneTime"/>
  78. <result column="course_one_to_two_time_" property="courseOneToTwoTime"/>
  79. </resultMap>
  80. <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
  81. <result column="key_" property="key"/>
  82. <result column="value_" property="value"/>
  83. </resultMap>
  84. <!-- 根据主键查询一条记录 -->
  85. <select id="get" resultMap="StudentPaymentOrder">
  86. SELECT *
  87. FROM student_payment_order
  88. WHERE id_ = #{id}
  89. </select>
  90. <!-- 全查询 -->
  91. <select id="findAll" resultMap="StudentPaymentOrder">
  92. SELECT *
  93. FROM student_payment_order where tenant_id_ = #{tenantId}
  94. ORDER BY id_
  95. </select>
  96. <!-- 向数据库增加一条记录 -->
  97. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
  98. keyColumn="id" keyProperty="id">
  99. INSERT INTO student_payment_order
  100. (group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
  101. per_amount_,
  102. balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
  103. status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
  104. payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,batch_no_,coupon_code_id_,
  105. coupon_remit_fee_,activity_id_,activity_buy_num_,tenant_id_,calender_id_)
  106. VALUES (#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  107. #{userId}, #{organId}, #{routingOrganId},
  108. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  109. #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
  110. #{remitFee}, #{courseRemitFee}, #{transNo},
  111. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
  112. #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
  113. #{musicGroupId},
  114. #{classGroupId}, #{payTime},#{batchNo},#{couponCodeId},#{couponRemitFee},#{activityId},#{activityBuyNum},#{tenantId},#{calenderId})
  115. </insert>
  116. <!-- 根据主键查询一条记录 -->
  117. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  118. UPDATE student_payment_order
  119. <set>
  120. <if test="activityBuyNum != null">
  121. activity_buy_num_ = #{activityBuyNum},
  122. </if>
  123. <if test="activityId != null">
  124. activity_id_ = #{activityId},
  125. </if>
  126. <if test="receiveStatus != null and receiveStatus != ''">
  127. receive_status_ = #{receiveStatus},
  128. </if>
  129. <if test="status != null">
  130. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  131. </if>
  132. <if test="groupType != null">
  133. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  134. </if>
  135. <if test="orderNo != null">
  136. order_no_ = #{orderNo},
  137. </if>
  138. <if test="classGroupId != null">
  139. class_group_id_ = #{classGroupId},
  140. </if>
  141. <if test="expectAmount != null">
  142. expect_amount_ = #{expectAmount},
  143. </if>
  144. <if test="memo != null">
  145. memo_ = #{memo},
  146. </if>
  147. <if test="paymentChannel != null">
  148. payment_channel_ = #{paymentChannel},
  149. </if>
  150. <if test="userId != null">
  151. user_id_ = #{userId},
  152. </if>
  153. <if test="paymentAccountNo != null">
  154. payment_account_no_ = #{paymentAccountNo},
  155. </if>
  156. <if test="merNos != null">
  157. mer_nos_ = #{merNos},
  158. </if>
  159. <if test="paymentBusinessChannel != null">
  160. payment_business_channel_ = #{paymentBusinessChannel},
  161. </if>
  162. <if test="transNo != null">
  163. trans_no_ = #{transNo},
  164. </if>
  165. <if test="actualAmount != null">
  166. actual_amount_ = #{actualAmount},
  167. </if>
  168. <if test="comAmount != null">
  169. com_amount_ = #{comAmount},
  170. </if>
  171. <if test="perAmount != null">
  172. per_amount_ = #{perAmount},
  173. </if>
  174. <if test="balancePaymentAmount != null">
  175. balance_payment_amount_ = #{balancePaymentAmount},
  176. </if>
  177. <if test="remitFee != null">
  178. remit_fee_ = #{remitFee},
  179. </if>
  180. <if test="courseRemitFee != null">
  181. course_remit_fee_ = #{courseRemitFee},
  182. </if>
  183. <if test="type != null">
  184. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  185. </if>
  186. <if test="musicGroupId != null">
  187. music_group_id_ = #{musicGroupId},
  188. </if>
  189. <if test="organId != null">
  190. organ_id_ = #{organId},
  191. </if>
  192. <if test="routingOrganId != null">
  193. routing_organ_id_ = #{routingOrganId},
  194. </if>
  195. <if test="payTime != null">
  196. pay_time_ = #{payTime},
  197. </if>
  198. <if test="batchNo != null">
  199. batch_no_ = #{batchNo},
  200. </if>
  201. <if test="version != null">
  202. version_ = version_+1,
  203. </if>
  204. update_time_ = NOW()
  205. </set>
  206. WHERE id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
  207. </update>
  208. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  209. <foreach collection="studentPaymentOrderList" item="studentPaymentOrder" separator=";">
  210. UPDATE student_payment_order
  211. <set>
  212. <if test="studentPaymentOrder.activityBuyNum != null">
  213. activity_buy_num_ = #{studentPaymentOrder.activityBuyNum},
  214. </if>
  215. <if test="studentPaymentOrder.activityId != null">
  216. activity_id_ = #{studentPaymentOrder.activityId},
  217. </if>
  218. <if test="studentPaymentOrder.receiveStatus != null and studentPaymentOrder.receiveStatus != ''">
  219. receive_status_ = #{studentPaymentOrder.receiveStatus},
  220. </if>
  221. <if test="studentPaymentOrder.status != null">
  222. status_ = #{studentPaymentOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  223. </if>
  224. <if test="studentPaymentOrder.groupType != null">
  225. group_type_ = #{studentPaymentOrder.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  226. </if>
  227. <if test="studentPaymentOrder.orderNo != null">
  228. order_no_ = #{studentPaymentOrder.orderNo},
  229. </if>
  230. <if test="studentPaymentOrder.classGroupId != null">
  231. class_group_id_ = #{studentPaymentOrder.classGroupId},
  232. </if>
  233. <if test="studentPaymentOrder.expectAmount != null">
  234. expect_amount_ = #{studentPaymentOrder.expectAmount},
  235. </if>
  236. <if test="studentPaymentOrder.memo != null">
  237. memo_ = #{studentPaymentOrder.memo},
  238. </if>
  239. <if test="studentPaymentOrder.paymentChannel != null">
  240. payment_channel_ = #{studentPaymentOrder.paymentChannel},
  241. </if>
  242. <if test="studentPaymentOrder.userId != null">
  243. user_id_ = #{studentPaymentOrder.userId},
  244. </if>
  245. <if test="studentPaymentOrder.paymentAccountNo != null">
  246. payment_account_no_ = #{studentPaymentOrder.paymentAccountNo},
  247. </if>
  248. <if test="studentPaymentOrder.merNos != null">
  249. mer_nos_ = #{studentPaymentOrder.merNos},
  250. </if>
  251. <if test="studentPaymentOrder.paymentBusinessChannel != null">
  252. payment_business_channel_ = #{studentPaymentOrder.paymentBusinessChannel},
  253. </if>
  254. <if test="studentPaymentOrder.transNo != null">
  255. trans_no_ = #{studentPaymentOrder.transNo},
  256. </if>
  257. <if test="studentPaymentOrder.actualAmount != null">
  258. actual_amount_ = #{studentPaymentOrder.actualAmount},
  259. </if>
  260. <if test="studentPaymentOrder.comAmount != null">
  261. com_amount_ = #{studentPaymentOrder.comAmount},
  262. </if>
  263. <if test="studentPaymentOrder.perAmount != null">
  264. per_amount_ = #{studentPaymentOrder.perAmount},
  265. </if>
  266. <if test="studentPaymentOrder.balancePaymentAmount != null">
  267. balance_payment_amount_ = #{studentPaymentOrder.balancePaymentAmount},
  268. </if>
  269. <if test="studentPaymentOrder.remitFee != null">
  270. remit_fee_ = #{studentPaymentOrder.remitFee},
  271. </if>
  272. <if test="studentPaymentOrder.courseRemitFee != null">
  273. course_remit_fee_ = #{studentPaymentOrder.courseRemitFee},
  274. </if>
  275. <if test="studentPaymentOrder.type != null">
  276. type_ = #{studentPaymentOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  277. </if>
  278. <if test="studentPaymentOrder.musicGroupId != null">
  279. music_group_id_ = #{studentPaymentOrder.musicGroupId},
  280. </if>
  281. <if test="studentPaymentOrder.organId != null">
  282. organ_id_ = #{studentPaymentOrder.organId},
  283. </if>
  284. <if test="studentPaymentOrder.routingOrganId != null">
  285. routing_organ_id_ = #{studentPaymentOrder.routingOrganId},
  286. </if>
  287. <if test="studentPaymentOrder.payTime != null">
  288. pay_time_ = #{studentPaymentOrder.payTime},
  289. </if>
  290. <if test="studentPaymentOrder.batchNo != null">
  291. batch_no_ = #{studentPaymentOrder.batchNo},
  292. </if>
  293. <if test="studentPaymentOrder.version != null">
  294. version_ = version_+1,
  295. </if>
  296. update_time_ = NOW()
  297. </set>
  298. WHERE id_ = #{studentPaymentOrder.id} AND version_ = #{studentPaymentOrder.version} and tenant_id_ = #{studentPaymentOrder.tenantId}
  299. </foreach>
  300. </update>
  301. <!-- 根据主键删除一条记录 -->
  302. <delete id="delete">
  303. DELETE
  304. FROM student_payment_order
  305. WHERE id_ = #{id}
  306. </delete>
  307. <!-- 分页查询 -->
  308. <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  309. SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
  310. left join sys_user u on spo.user_id_ = u.id_
  311. left join organization o on o.id_ = spo.organ_id_
  312. <include refid="queryPaymentOrder"/>
  313. ORDER BY spo.id_ DESC
  314. <include refid="global.limit"/>
  315. </select>
  316. <!-- 查询当前表的总记录数 -->
  317. <select id="queryCount" resultType="int" parameterType="map">
  318. SELECT COUNT(spo.id_) FROM student_payment_order spo
  319. left join sys_user u on spo.user_id_ = u.id_
  320. <include refid="queryPaymentOrder"/>
  321. </select>
  322. <!-- 查询当前表的总记录数 -->
  323. <select id="queryCount1" resultType="int" parameterType="map">
  324. SELECT COUNT(spo.id_) FROM student_payment_order spo
  325. WHERE spo.tenant_id_ = 1 AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
  326. AND spo.group_type_ != 'MALL_SELL'
  327. </select>
  328. <sql id="queryPaymentMallOrder">
  329. <where>
  330. spo.tenant_id_ = #{tenantId}
  331. <if test="userIds != null">
  332. AND spo.user_id_ IN
  333. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  334. #{userId}
  335. </foreach>
  336. </if>
  337. <if test="organId != null">
  338. AND FIND_IN_SET(spo.organ_id_,#{organId})
  339. </if>
  340. <if test="orderStartDate != null">
  341. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  342. </if>
  343. <if test="orderEndDate != null">
  344. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  345. </if>
  346. <if test="notGroupType != null and notGroupType != ''">
  347. AND spo.group_type_ != #{notGroupType}
  348. </if>
  349. <if test="paymentType != null">
  350. AND spo.type_ = #{paymentType}
  351. </if>
  352. <if test="remark != null">
  353. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  354. </if>
  355. <if test="studentId != null">
  356. AND spo.user_id_ = #{studentId}
  357. </if>
  358. <if test="paymentStatus != null">
  359. AND spo.status_ = #{paymentStatus}
  360. </if>
  361. <if test="paymentChannel != null">
  362. AND spo.payment_channel_ NOT IN (#{paymentChannel})
  363. </if>
  364. <if test='orderType != null and orderType.toString()=="1".toString()'>
  365. AND spo.com_amount_ > 0
  366. </if>
  367. <if test='orderType != null and orderType.toString()=="2".toString()'>
  368. AND spo.per_amount_ > 0
  369. </if>
  370. <if test="routingOrganId != null">
  371. AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
  372. </if>
  373. <if test="actualAmount != null">
  374. AND spo.actual_amount_ >= #{actualAmount}
  375. </if>
  376. <if test="balancePaymentAmount != null">
  377. AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
  378. </if>
  379. <if test="lessActualAmount != null">
  380. <![CDATA[ AND spo.actual_amount_ <= #{lessActualAmount}]]>
  381. </if>
  382. <if test="lessBalancePaymentAmount != null">
  383. <![CDATA[AND spo.balance_payment_amount_ <= #{lessBalancePaymentAmount}]]>
  384. </if>
  385. <if test="orderNo != null">
  386. AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
  387. </if>
  388. <if test="merNos != null">
  389. AND FIND_IN_SET(#{merNos},spo.mer_nos_)
  390. </if>
  391. <if test="transNo != null">
  392. AND spo.trans_no_ = #{transNo}
  393. </if>
  394. </where>
  395. </sql>
  396. <sql id="queryPaymentOrder">
  397. <where>
  398. spo.tenant_id_ = #{tenantId}
  399. <if test="userIds != null">
  400. AND spo.user_id_ IN
  401. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  402. #{userId}
  403. </foreach>
  404. </if>
  405. <if test="organId != null">
  406. AND FIND_IN_SET(spo.organ_id_,#{organId})
  407. </if>
  408. <if test="orderStartDate != null">
  409. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &gt;= #{orderStartDate}
  410. </if>
  411. <if test="orderEndDate != null">
  412. AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
  413. </if>
  414. <if test="month != null and month != ''">
  415. AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
  416. </if>
  417. <if test="notGroupType != null and notGroupType != ''">
  418. AND spo.group_type_ != #{notGroupType}
  419. </if>
  420. <if test="paymentType != null">
  421. AND spo.type_ = #{paymentType}
  422. </if>
  423. <if test="remark != null">
  424. AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
  425. </if>
  426. <if test="studentId != null">
  427. AND spo.user_id_ = #{studentId}
  428. </if>
  429. <if test="paymentStatus != null">
  430. AND spo.status_ = #{paymentStatus}
  431. </if>
  432. <if test="paymentChannel != null">
  433. AND spo.payment_channel_ NOT IN (#{paymentChannel})
  434. </if>
  435. <if test='orderType != null and orderType.toString()=="1".toString()'>
  436. AND spo.com_amount_ > 0
  437. </if>
  438. <if test='orderType != null and orderType.toString()=="2".toString()'>
  439. AND spo.per_amount_ > 0
  440. </if>
  441. <if test="routingOrganId != null">
  442. AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
  443. </if>
  444. <if test="actualAmount != null">
  445. AND spo.actual_amount_ >= #{actualAmount}
  446. </if>
  447. <if test="balancePaymentAmount != null">
  448. AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
  449. </if>
  450. <if test="lessActualAmount != null">
  451. <![CDATA[ AND spo.actual_amount_ <= #{lessActualAmount}]]>
  452. </if>
  453. <if test="lessBalancePaymentAmount != null">
  454. <![CDATA[AND spo.balance_payment_amount_ <= #{lessBalancePaymentAmount}]]>
  455. </if>
  456. <if test="orderNo != null">
  457. AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
  458. </if>
  459. <if test="merNos != null">
  460. AND FIND_IN_SET(#{merNos},spo.mer_nos_)
  461. </if>
  462. <if test="transNo != null">
  463. AND spo.trans_no_ = #{transNo}
  464. </if>
  465. <if test="chargeType != null">
  466. AND spo.group_type_='SPORADIC'
  467. AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  468. </if>
  469. </where>
  470. </sql>
  471. <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
  472. SELECT spo.*
  473. FROM student_payment_order spo
  474. WHERE spo.user_id_ = #{userId}
  475. <if test="musicGroupId != null">
  476. AND spo.music_group_id_ = #{musicGroupId}
  477. </if>
  478. AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  479. <if test="groupType != null">
  480. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  481. </if>
  482. and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  483. </select>
  484. <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
  485. SELECT spo.* FROM
  486. student_payment_order spo
  487. WHERE spo.user_id_ = #{userId}
  488. AND spo.music_group_id_ = #{vipGroupId}
  489. <if test="status!=null and status!=''">
  490. AND spo.status_=#{status}
  491. </if>
  492. <if test="orderType != null and orderType != ''">
  493. AND spo.type_ = #{orderType}
  494. </if>
  495. <if test="orderType == null or orderType == ''">
  496. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  497. </if>
  498. order by id_ DESC LIMIT 1
  499. </select>
  500. <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
  501. SELECT SUM(cssp.expect_price_)
  502. FROM course_schedule_student_payment cssp
  503. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  504. WHERE cssp.user_id_ = #{userId}
  505. AND cssp.music_group_id_ = #{vipGroupId}
  506. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  507. </select>
  508. <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
  509. SELECT spo.*
  510. FROM student_payment_order spo
  511. WHERE spo.user_id_ = #{userId}
  512. AND spo.music_group_id_ = #{vipGroupId}
  513. AND spo.status_ != 'FAILED'
  514. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  515. </select>
  516. <!-- 查询报名订单 -->
  517. <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
  518. SELECT * FROM student_payment_order
  519. WHERE music_group_id_ = #{musicGroupId}
  520. AND user_id_ = #{userId}
  521. AND type_ = 'APPLY'
  522. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  523. ORDER BY id_ DESC
  524. </select>
  525. <select id="queryByBatchNo" resultMap="StudentPaymentOrder" parameterType="map">
  526. SELECT *
  527. FROM student_payment_order
  528. WHERE batch_no_ = #{batchNo}
  529. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  530. and user_id_ = #{userId}
  531. </select>
  532. <!-- 根据订单号查询订单 -->
  533. <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
  534. SELECT *
  535. FROM student_payment_order
  536. WHERE order_no_ = #{orderNo}
  537. </select>
  538. <select id="findOrderByOrderNos" resultMap="StudentPaymentOrder">
  539. SELECT *
  540. FROM student_payment_order
  541. WHERE order_no_ in
  542. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  543. #{orderNo}
  544. </foreach>
  545. </select>
  546. <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
  547. SELECT *
  548. FROM student_payment_order
  549. WHERE music_group_id_ = #{musicGroupId}
  550. AND type_ = #{type}
  551. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  552. </select>
  553. <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
  554. <result column="goods_id_" property="goodsId"/>
  555. <collection property="goodsName" ofType="string">
  556. <result column="goods_name_"/>
  557. </collection>
  558. </resultMap>
  559. <select id="findGoodsIds" resultMap="userGoodsDto">
  560. SELECT g.id_ goods_id_, g.name_ goods_name_
  561. FROM student_payment_order spo
  562. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  563. LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
  564. WHERE spo.type_ = 'APPLY'
  565. AND spo.status_ = 'SUCCESS'
  566. AND spod.goods_id_list_ IS NOT NULL
  567. AND spo.music_group_id_ = #{musicGroupId}
  568. AND spo.user_id_ = #{userId}
  569. </select>
  570. <select id="getUserGoods" resultMap="userGoodsDto">
  571. SELECT id_ goods_id_, name_ goods_name_ FROM goods WHERE FIND_IN_SET(id_,#{ids})
  572. </select>
  573. <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
  574. SELECT *
  575. FROM student_payment_order
  576. WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  577. <!-- 商城订单由商城控制订单超时 -->
  578. and group_type_ != 'MALL_SELL' and type_ != 'MALL_BUY'
  579. </select>
  580. <!-- 查询支付中超时订单 -->
  581. <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
  582. SELECT * FROM student_payment_order WHERE order_no_ IN
  583. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  584. #{orderNo}
  585. </foreach>
  586. AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  587. <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
  588. </select>
  589. <select id="countStudentPaymentNum" resultType="int">
  590. select count(DISTINCT user_id_)
  591. from student_payment_order
  592. where music_group_id_ = #{musicGroupId}
  593. AND status_ = 'SUCCESS'
  594. AND type_ = 'SMALL_CLASS_TO_BUY'
  595. </select>
  596. <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
  597. SELECT COUNT(*)
  598. FROM course_schedule_student_payment cssp
  599. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  600. WHERE cssp.user_id_ = #{userId}
  601. AND cssp.music_group_id_ = #{musicGroupId}
  602. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  603. </select>
  604. <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
  605. SELECT
  606. (CASE WHEN a.a > 0 THEN a.a ELSE c.c END) +
  607. (CASE WHEN d.d IS NULL THEN 0 ELSE d.d END) +
  608. (CASE WHEN e.e IS NULL THEN 0 ELSE e.e END) -
  609. (CASE WHEN b.b IS NULL THEN 0 ELSE b.b END) amount_
  610. FROM
  611. (SELECT SUM(CASE WHEN expect_amount_ IS NULL THEN 0 ELSE expect_amount_ END) a FROM student_payment_order
  612. WHERE group_type_ = #{groupType} AND music_group_id_ = #{vipGroupId} AND status_ = 'SUCCESS') a,
  613. (SELECT SUM(CASE WHEN amount_ IS NULL THEN 0 ELSE amount_ END) b FROM sys_user_cash_account_log WHERE group_id_ = #{vipGroupId} AND group_type_ = #{groupType}) b,
  614. (SELECT SUM(CASE WHEN actual_price_ IS NULL THEN 0 ELSE actual_price_ END) c FROM activity_user_mapper WHERE vip_group_id_ = #{vipGroupId}) c,
  615. (SELECT SUM(CASE WHEN amount_ IS NULL THEN 0 ELSE amount_ END) d FROM sys_user_cash_account_detail WHERE group_id_ = #{vipGroupId}) d,
  616. (SELECT SUM(CASE WHEN amount_ IS NULL THEN 0 ELSE amount_ END) e FROM sys_user_courses_account_detail WHERE group_id_ = #{vipGroupId}) e
  617. </select>
  618. <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
  619. SELECT sr.user_id_ ,sum(case when sc.id_ is null then spo.expect_amount_ else (spo.expect_amount_ + sc.goods_margin_) end) expect_amount_,spo.pay_time_
  620. FROM student_payment_order spo
  621. LEFT JOIN student_registration sr ON sr.user_id_ = spo.user_id_
  622. LEFT JOIN (SELECT id_,music_group_id_,original_order_id_,CASE WHEN goods_margin_ &lt; 0 THEN goods_margin_ ELSE sell_amount_ END goods_margin_ FROM subject_change WHERE id_ in
  623. (SELECT max(id_) id_ from subject_change WHERE status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ desc)
  624. ) sc on spo.music_group_id_ = sc.music_group_id_ and spo.id_ = sc.original_order_id_
  625. WHERE spo.music_group_id_ = #{musicGroupId} AND sr.music_group_id_ = spo.music_group_id_ AND sr.music_group_status_ = 'NORMAL'
  626. AND spo.type_ = 'APPLY' and spo.status_ = 'SUCCESS'
  627. GROUP BY sr.user_id_;
  628. </select>
  629. <select id="findPaymentOrderByGroupType" resultMap="StudentPaymentOrder">
  630. SELECT * FROM student_payment_order
  631. WHERE group_type_ = #{groupType}
  632. AND user_id_ = #{userId}
  633. AND music_group_id_ = #{sporadicId}
  634. <if test="status != null">
  635. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  636. </if>
  637. </select>
  638. <select id="queryExpectAmount" resultType="java.util.Map">
  639. SELECT spo.expect_amount_ 'value',spo.id_ 'key'
  640. FROM student_payment_order spo
  641. WHERE spo.id_ IN
  642. <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
  643. #{item}
  644. </foreach>
  645. </select>
  646. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderMallExportDto" id="mallOrderAndDetail"
  647. extends="StudentPaymentOrder">
  648. <result column="organ_name" property="organName"/>
  649. <result column="username_" property="user.username"/>
  650. <result column="routeMerNo" property="routeMerNo"/>
  651. <result column="routeAmount" property="routeAmount"/>
  652. <result column="routeBalance" property="routeBalance"/>
  653. <result column="sale_amount_" property="saleAmount"/>
  654. <result column="service_amount_" property="serviceAmount"/>
  655. <result column="service_fee_" property="serviceFee"/>
  656. <result column="routeBalance" property="routeBalance"/>
  657. <result column="orderAmount" property="orderAmount"/>
  658. </resultMap>
  659. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
  660. extends="StudentPaymentOrder">
  661. <result column="organ_name" property="organName"/>
  662. <result column="username_" property="user.username"/>
  663. <result column="charge_type_" property="chargeType"/>
  664. <result column="routeMerNo" property="routeMerNo"/>
  665. <result column="routeAmount" property="routeAmount"/>
  666. <result column="routeBalance" property="routeBalance"/>
  667. <result column="sale_amount_" property="saleAmount"/>
  668. <result column="service_amount_" property="serviceAmount"/>
  669. <result column="service_fee_" property="serviceFee"/>
  670. <result column="routeBalance" property="routeBalance"/>
  671. <result column="feeFlag" property="feeFlag"/>
  672. <result column="orderAmount" property="orderAmount"/>
  673. <result column="cooperation_id_" property="cooperationId"/>
  674. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  675. <result column="detail_id_" property="id"/>
  676. <result column="detail_type_" property="type"/>
  677. <result column="detail_price_" property="price"/>
  678. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  679. <result column="income_item_" property="incomeItem"/>
  680. <result column="income_" property="income"/>
  681. </collection>
  682. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  683. <result column="goods_id" property="id"/>
  684. <result column="goods_name" property="name"/>
  685. </collection>
  686. </resultMap>
  687. <!-- 分页查询 -->
  688. <select id="exportMallQueryPage" resultMap="mallOrderAndDetail" parameterType="map">
  689. SELECT spo.*,u.username_,o.name_ organ_name,sgs.goods_json_
  690. FROM student_payment_order spo
  691. left join student_goods_sell sgs ON sgs.order_no_ = spo.order_no_
  692. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  693. <if test='orderType != null and orderType.toString()=="0".toString()'>
  694. LEFT JOIN organization o on spo.organ_id_ = o.id_
  695. </if>
  696. <if test='orderType != null and orderType.toString()=="1".toString()'>
  697. LEFT JOIN organization o on spo.organ_id_ = o.id_
  698. </if>
  699. <if test='orderType != null and orderType.toString()=="2".toString()'>
  700. LEFT JOIN organization o on spo.organ_id_ = o.id_
  701. </if>
  702. <if test='orderType != null and orderType.toString()=="3".toString()'>
  703. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  704. </if>
  705. <include refid="queryPaymentMallOrder"/>
  706. ORDER BY spo.id_ ASC
  707. </select>
  708. <!-- 分页查询 -->
  709. <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
  710. SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  711. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  712. sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name,spo.cooperation_id_
  713. FROM student_payment_order spo
  714. LEFT JOIN sys_user u on spo.user_id_ = u.id_
  715. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  716. <if test='orderType != null and orderType.toString()=="0".toString()'>
  717. LEFT JOIN organization o on spo.organ_id_ = o.id_
  718. </if>
  719. <if test='orderType != null and orderType.toString()=="1".toString()'>
  720. LEFT JOIN organization o on spo.organ_id_ = o.id_
  721. </if>
  722. <if test='orderType != null and orderType.toString()=="2".toString()'>
  723. LEFT JOIN organization o on spo.organ_id_ = o.id_
  724. </if>
  725. <if test='orderType != null and orderType.toString()=="3".toString()'>
  726. LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
  727. </if>
  728. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  729. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  730. <include refid="queryPaymentOrder"/>
  731. ORDER BY spo.id_ ASC
  732. </select>
  733. <select id="ExportQueryPage1" resultMap="orderAndDetail" parameterType="map">
  734. SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  735. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  736. sci.charge_type_
  737. FROM student_payment_order spo
  738. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  739. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  740. where DATE_FORMAT(spo.pay_time_,'%Y-%m') = #{month} AND spo.order_no_ NOT IN (select distinct order_no_ from sell_order where DATE_FORMAT(sell_time_,'%Y-%m') = #{month})
  741. AND spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
  742. </select>
  743. <select id="ExportQueryPage2" resultMap="orderAndDetail" parameterType="map">
  744. select spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  745. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  746. sci.charge_type_ from student_payment_order spo
  747. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  748. LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
  749. where spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
  750. AND spo.order_no_ IN (select distinct order_no_ from sell_order where DATE_FORMAT(delivery_time_,'%Y-%m') = #{month})
  751. </select>
  752. <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
  753. <result property="organName" column="organ_name_"/>
  754. <result property="title" column="title_"/>
  755. <result property="type" column="type_"/>
  756. <result property="amount" column="amount_"/>
  757. <result property="createTime" column="create_time_"/>
  758. <result property="payTime" column="pay_time_"/>
  759. <result property="username" column="username_"/>
  760. <result property="payStatus" column="pay_status_"/>
  761. </resultMap>
  762. <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
  763. SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
  764. spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
  765. FROM student_payment_order spo
  766. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  767. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  768. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  769. WHERE spo.type_ = 'SPORADIC' and spo.tenant_id_ = #{tenantId}
  770. <include refid="sporadicQueryPageSql"/>
  771. ORDER BY spo.id_ DESC
  772. <include refid="global.limit"/>
  773. </select>
  774. <select id="countSporadicPage" resultType="java.lang.Integer">
  775. SELECT COUNT(spo.id_)
  776. FROM student_payment_order spo
  777. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  778. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  779. WHERE spo.type_ = 'SPORADIC' and spo.tenant_id_ = #{tenantId}
  780. <include refid="sporadicQueryPageSql"/>
  781. </select>
  782. <sql id="sporadicQueryPageSql">
  783. <if test="organId != null">
  784. AND FIND_IN_SET(spo.organ_id_,#{organId})
  785. </if>
  786. <if test="search != null">
  787. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  788. </if>
  789. <if test="chargeType != null">
  790. AND sci.charge_type_ = #{chargeType}
  791. </if>
  792. <if test="payStatus != null">
  793. AND spo.status_ = #{payStatus}
  794. </if>
  795. </sql>
  796. <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
  797. <result property="organId" column="organId"/>
  798. <result property="organName" column="organName"/>
  799. <result property="estimatedNums" column="estimatedNums"/>
  800. <result property="nums" column="nums"/>
  801. <result property="times" column="times"/>
  802. <result property="scale" column="scale"/>
  803. <result property="money" column="money"/>
  804. </resultMap>
  805. <select id="getLuckStatis" resultMap="luckStatis">
  806. SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
  807. FROM student_payment_order spo
  808. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  809. WHERE spo.type_ = 'LUCK'
  810. AND spo.status_ = 'SUCCESS' and spo.tenant_id_ = #{tenantId}
  811. GROUP BY spo.organ_id_
  812. ORDER BY nums DESC;
  813. </select>
  814. <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
  815. select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
  816. where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
  817. status_ = 'SUCCESS' and organ_id_ not in (36,38)
  818. and FIND_IN_SET(organ_id_,#{organId})
  819. </select>
  820. <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
  821. select count(*)
  822. from student_payment_order
  823. where user_id_ = #{userId}
  824. and music_group_id_ = #{vipGroupId}
  825. and group_type_ = 'VIP'
  826. and status_ = 'SUCCESS'
  827. </select>
  828. <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
  829. select *
  830. from student_payment_order
  831. where user_id_ = #{userId}
  832. and music_group_id_ = #{vipGroupId}
  833. and group_type_ = 'VIP'
  834. </select>
  835. <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
  836. select * from student_payment_order
  837. where user_id_=#{userId}
  838. and music_group_id_=#{groupId}
  839. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  840. <if test="status!=null">
  841. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  842. </if>
  843. </select>
  844. <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
  845. SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_)
  846. balance_payment_amount_ FROM student_payment_order spo
  847. <include refid="queryPaymentOrder"/>
  848. </select>
  849. <!-- 分页查询 -->
  850. <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
  851. SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
  852. left join sys_user u on spo.user_id_ = u.id_
  853. left join organization o on o.id_ = spo.organ_id_
  854. <include refid="queryPaymentOrder"/>
  855. ORDER BY spo.id_ DESC
  856. <include refid="global.limit"/>
  857. </select>
  858. <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
  859. SELECT * FROM student_payment_order
  860. WHERE music_group_id_=#{groupId}
  861. and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  862. <if test="status!=null">
  863. and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  864. </if>
  865. </select>
  866. <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
  867. SELECT SUM(per_amount_)
  868. FROM student_payment_order
  869. WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
  870. AND create_time_ >= #{firstDate}
  871. AND create_time_ <= NOW()
  872. AND FIND_IN_SET(#{merNo}, mer_nos_)
  873. ]]>
  874. </select>
  875. <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
  876. SELECT SUM(actual_amount_) FROM student_payment_order spo
  877. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
  878. <include refid="queryPaymentOrder"/>
  879. </select>
  880. <select id="sumAccountAmount" resultType="java.math.BigDecimal">
  881. <![CDATA[
  882. SELECT SUM(actual_amount_)
  883. FROM student_payment_order
  884. WHERE status_ IN ('SUCCESS', 'ING')
  885. AND create_time_ >= #{firstDate}
  886. AND create_time_ <= NOW()
  887. AND mer_nos_ = #{merNo}
  888. ]]></select>
  889. <select id="countGroupOrderWithoutFailed" resultType="int">
  890. SELECT COUNT(*)
  891. FROM student_payment_order spo
  892. WHERE spo.music_group_id_ = #{groupId}
  893. AND spo.status_ NOT IN ('FAILED','CLOSE')
  894. AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
  895. </select>
  896. <select id="countSporadicOrder" resultType="java.lang.Integer">
  897. SELECT COUNT(id_)
  898. FROM student_payment_order spo
  899. WHERE spo.group_type_ = 'SPORADIC'
  900. AND spo.music_group_id_ = #{sporadicId}
  901. </select>
  902. <!-- 查找支付成功和支付中订单 -->
  903. <select id="findOrganPayOrderNum" resultType="int">
  904. SELECT COUNT(*)
  905. FROM student_payment_order
  906. WHERE organ_id_ = #{organId}
  907. AND status_ IN ('SUCCESS', 'ING')
  908. </select>
  909. <!-- 获取每月用户的对应类型订单订单 -->
  910. <select id="getOrderByMonthAndType" resultType="com.ym.mec.biz.dal.dto.OrderByTypeExportDto">
  911. SELECT o.name_ organName, spo.user_id_ studentId,su.username_ studentName,spo.type_ orderType,
  912. spo.actual_amount_ actualAmount,spo.music_group_id_ musicGroupId,spo.group_type_ groupType,spo.create_time_
  913. createTime
  914. FROM student_payment_order spo
  915. LEFT JOIN sys_user su on spo.user_id_ = su.id_
  916. LEFT JOIN organization o ON o.id_ = spo.id_
  917. WHERE spo.status_ = 'SUCCESS'
  918. AND FIND_IN_SET (spo.organ_id_,#{organIds})
  919. <if test="orderTypeList != null">
  920. AND spo.type_ IN
  921. <foreach collection="orderTypeList" item="orderType" open="(" close=")"
  922. separator=",">
  923. #{orderType}
  924. </foreach>
  925. </if>
  926. <if test="startTime != null">
  927. AND spo.create_time_ >= #{startTime}
  928. </if>
  929. <if test="endTime != null"><![CDATA[
  930. AND spo.create_time_ <= #{endTime}
  931. ]]></if>
  932. AND spo.actual_amount_ > 0
  933. </select>
  934. <select id="getUsers" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  935. SELECT username_ name, id_ userId, phone_ phone
  936. FROM sys_user
  937. WHERE id_ = #{search}
  938. OR username_ LIKE CONCAT('%', #{search}, '%')
  939. OR phone_ LIKE CONCAT('%', #{search}, '%')
  940. </select>
  941. <select id="lockOrder" resultMap="StudentPaymentOrder">
  942. SELECT *
  943. FROM student_payment_order
  944. WHERE id_ = #{id} FOR
  945. UPDATE
  946. </select>
  947. <select id="doubleEleven2020Statis" resultMap="luckStatis">
  948. SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums,
  949. SUM(IF(spo.class_group_id_ is null ,1,spo.class_group_id_)) times FROM student_payment_order spo
  950. LEFT JOIN organization o ON o.id_ = spo.organ_id_
  951. WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
  952. AND spo.status_ = 'SUCCESS'
  953. AND spo.organ_id_ IN
  954. <foreach collection="organs" item="organ" open="(" close=")" separator=",">
  955. #{organ.id}
  956. </foreach>
  957. GROUP BY spo.organ_id_
  958. </select>
  959. <select id="getUserOrderNumByType" resultType="int">
  960. SELECT COUNT(*)
  961. FROM student_payment_order
  962. WHERE user_id_ = #{userId}
  963. AND status_ = 'SUCCESS'
  964. AND type_ = #{orderType}
  965. </select>
  966. <select id="getUserOrderByType" resultMap="StudentPaymentOrder">
  967. SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND type_=#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  968. </select>
  969. <select id="queryDouble11Students" resultMap="StudentVipDouble11Dto">
  970. SELECT
  971. su.id_ userId,
  972. su.username_ userName,
  973. su.phone_ phone,
  974. su.avatar_ avatar,
  975. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  976. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  977. FROM
  978. student_payment_order spo
  979. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  980. LEFT JOIN student s ON spo.user_id_=s.user_id_
  981. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  982. WHERE
  983. spo.status_ = 'SUCCESS'
  984. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  985. AND sci.title_ LIKE '双十一%'
  986. AND s.teacher_id_= #{teacherId}
  987. <if test="search!=null and search!=''">
  988. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  989. </if>
  990. GROUP BY
  991. spo.user_id_
  992. ORDER BY spo.user_id_
  993. <include refid="global.limit" />
  994. </select>
  995. <select id="countDouble11Students" resultType="int">
  996. SELECT
  997. COUNT(DISTINCT spo.user_id_)
  998. FROM
  999. student_payment_order spo
  1000. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  1001. LEFT JOIN student s ON spo.user_id_=s.user_id_
  1002. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  1003. WHERE
  1004. spo.status_ = 'SUCCESS'
  1005. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  1006. AND sci.title_ LIKE '双十一%'
  1007. AND s.teacher_id_= #{teacherId}
  1008. <if test="search!=null and search!=''">
  1009. AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
  1010. </if>;
  1011. </select>
  1012. <select id="findStudentsDouble11Infos" resultMap="StudentVipDouble11Dto">
  1013. SELECT
  1014. su.id_ userId,
  1015. su.username_ userName,
  1016. su.phone_ phone,
  1017. su.avatar_ avatar,
  1018. SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
  1019. SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
  1020. FROM
  1021. student_payment_order spo
  1022. LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
  1023. LEFT JOIN student s ON spo.user_id_=s.user_id_
  1024. LEFT JOIN sys_user su ON spo.user_id_ = su.id_
  1025. WHERE
  1026. spo.status_ = 'SUCCESS'
  1027. AND spo.type_ = 'DOUBLE_ELEVEN2020'
  1028. AND sci.title_ LIKE '双十一%'
  1029. AND spo.user_id_ IN
  1030. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  1031. #{studentId}
  1032. </foreach>
  1033. GROUP BY
  1034. spo.user_id_
  1035. </select>
  1036. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="applyOrderAndDetail"
  1037. extends="StudentPaymentOrder">
  1038. <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
  1039. <result column="detail_id_" property="id"/>
  1040. <result column="detail_type_" property="type"/>
  1041. <result column="detail_price_" property="price"/>
  1042. <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
  1043. <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
  1044. <result column="goods_id" property="id"/>
  1045. <result column="goods_name" property="name"/>
  1046. <result column="complementGoodsIdList" property="complementGoodsIdList"/>
  1047. </collection>
  1048. </collection>
  1049. </resultMap>
  1050. <select id="getUserApplyOrders" resultMap="applyOrderAndDetail" parameterType="map">
  1051. SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
  1052. detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
  1053. g.id_ goods_id, g.name_ goods_name,g.complement_goods_id_list_ complementGoodsIdList
  1054. FROM student_payment_order spo
  1055. LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
  1056. LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
  1057. WHERE spo.user_id_ = #{userId} AND spo.type_='APPLY' AND spo.music_group_id_=#{musicGroupId}
  1058. ORDER BY spo.id_ desc
  1059. </select>
  1060. <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
  1061. SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
  1062. </select>
  1063. <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
  1064. SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
  1065. </select>
  1066. <select id="getMoneyInMusicApply" resultMap="Mapper">
  1067. SELECT spo.music_group_id_ key_, SUM(CASE WHEN a.id_ IS NULL THEN spo.expect_amount_ ELSE (spo.expect_amount_ + a.goods_margin_) END) value_
  1068. FROM student_payment_order spo
  1069. LEFT JOIN student_registration sr ON sr.user_id_ = spo.user_id_
  1070. LEFT JOIN (SELECT id_,music_group_id_,original_order_id_,CASE WHEN goods_margin_ &lt; 0 THEN goods_margin_ ELSE sell_amount_ END goods_margin_
  1071. FROM subject_change WHERE id_ in
  1072. (SELECT max(sc.id_) id_ from subject_change sc WHERE sc.status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ DESC)
  1073. ) a on spo.music_group_id_ = a.music_group_id_ and spo.id_ = a.original_order_id_
  1074. WHERE spo.music_group_id_ IN
  1075. <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
  1076. #{musicGroupId}
  1077. </foreach>
  1078. AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND sr.music_group_id_ = spo.music_group_id_ AND sr.music_group_status_ = 'NORMAL'
  1079. GROUP BY spo.music_group_id_
  1080. </select>
  1081. <select id="getOrderIdByMusical" resultType="java.lang.Integer">
  1082. SELECT DISTINCT spo.id_ FROM student_payment_order spo
  1083. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1084. WHERE spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spo.music_group_id_ = #{musicGroupId}
  1085. AND spo.user_id_ = #{studentId} AND spod.type_ = 'MUSICAL'
  1086. </select>
  1087. <select id="queryStudentCourseAmountMap" resultType="java.util.Map">
  1088. SELECT user_id_ 'key',expect_amount_ - coupon_remit_fee_ 'value' FROM student_payment_order
  1089. WHERE status_ = 'SUCCESS' AND music_group_id_ = #{vipGroupId}
  1090. GROUP BY user_id_
  1091. </select>
  1092. <select id="queryStudentDoubleElevenOrder" resultType="java.lang.String">
  1093. SELECT GROUP_CONCAT(activity_id_) FROM student_payment_order
  1094. WHERE type_ = 'SMALL_CLASS_TO_BUY' AND group_type_ = 'ACTIVITY' AND memo_ = '2022双十一活动购买' AND status_ = 'SUCCESS' AND user_id_ = #{userId}
  1095. </select>
  1096. <select id="findByCalenderId" resultMap="StudentPaymentOrder">
  1097. SELECT * FROM student_payment_order WHERE calender_id_ = #{calenderId} AND status_ = 'SUCCESS' AND user_id_ = #{userId}
  1098. </select>
  1099. <resultMap type="com.ym.mec.biz.dal.vo.StudentPaymentOrderVo" id="QueryOrderDetail">
  1100. <result column="orderNo" property="orderNo"/>
  1101. <result column="memo_" property="memo"/>
  1102. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1103. <result column="orderType" property="orderType"/>
  1104. <result column="orderTypeCode" property="orderTypeCode"/>
  1105. <result column="totalAmount" property="totalAmount"/>
  1106. <result column="actualAmount" property="actualAmount"/>
  1107. <result column="balanceAmount" property="balanceAmount"/>
  1108. <result column="actualAmount" property="actualAmount"/>
  1109. <result column="createTime" property="createTime"/>
  1110. <result column="payTime" property="payTime"/>
  1111. <result column="transNo" property="transNo"/>
  1112. <result column="totalRemitFee" property="totalRemitFee"/>
  1113. <collection property="list" ofType="com.ym.mec.biz.dal.vo.StudentPaymentOrderVo$StudentPaymentDetailVo">
  1114. <result column="goodsName" property="goodsName"/>
  1115. <result column="price" property="price"/>
  1116. </collection>
  1117. </resultMap>
  1118. <select id="queryStudentOrderPage" resultMap="QueryOrderDetail">
  1119. select
  1120. a.order_no_ as orderNo,
  1121. a.status_ ,a.memo_,
  1122. a.type_ as orderType,
  1123. a.type_ as orderTypeCode,
  1124. ifnull(a.actual_amount_, 0) + ifnull(a.balance_payment_amount_, 0) as totalAmount,
  1125. a.create_time_ as createTime
  1126. from student_payment_order as a
  1127. where create_time_ >= #{param.startDate}
  1128. and create_time_ <![CDATA[ < ]]> #{param.endDate}
  1129. and user_id_ = #{param.userId}
  1130. <if test="param.status != null">
  1131. and status_ = #{param.status}
  1132. </if>
  1133. </select>
  1134. <select id="queryOrderDetail" resultMap="QueryOrderDetail">
  1135. select
  1136. a.order_no_ as orderNo,
  1137. a.status_ ,a.memo_,
  1138. a.type_ as orderType,
  1139. ifnull(a.actual_amount_, 0) + ifnull(a.balance_payment_amount_, 0) + ifnull(a.remit_fee_, 0) +
  1140. ifnull(a.coupon_remit_fee_, 0) as totalAmount,
  1141. a.actual_amount_ as actualAmount,
  1142. a.balance_payment_amount_ as balanceAmount,
  1143. ifnull(a.remit_fee_,0) + ifnull(a.coupon_remit_fee_,0) as totalRemitFee,
  1144. a.create_time_ as createTime,
  1145. a.pay_time_ as payTime,
  1146. a.trans_no_ as transNo,
  1147. b.type_ as goodsName,
  1148. ifnull(b.price_, 0) as price
  1149. from student_payment_order as a
  1150. left join
  1151. student_payment_order_detail as b on a.id_ = b.payment_order_id_
  1152. where a.order_no_ = #{orderNo}
  1153. </select>
  1154. <select id="getStudentMusicOrderNum" resultType="int">
  1155. SELECT COUNT(0) FROM student_payment_order spo
  1156. WHERE spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId} AND group_type_ = 'MUSIC' AND status_ = 'SUCCESS' AND spo.id_ &lt; #{orderId}
  1157. </select>
  1158. <select id="getMemberIngOrder" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  1159. SELECT *
  1160. FROM student_payment_order
  1161. WHERE music_group_id_ IS NULL
  1162. AND type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1163. AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1164. LIMIT 1
  1165. </select>
  1166. <select id="countByActivityIds" resultType="java.lang.Integer">
  1167. SELECT COUNT(0) FROM student_payment_order WHERE user_id_ = #{userId} AND status_ = 'SUCCESS' AND activity_id_ IN
  1168. <foreach collection="activityIds" item="activityId" open="(" close=")" separator=",">
  1169. #{activityId}
  1170. </foreach>
  1171. </select>
  1172. <select id="groupSellOrder" resultType="com.ym.mec.biz.dal.dto.BaseMapDto">
  1173. SELECT so.organ_id_ 'key',SUM(so.actual_amount_) 'value'
  1174. FROM sell_order so
  1175. where so.tenant_id_ = 1 AND DATE_FORMAT(so.delivery_time_,'%Y-%m') = #{month}
  1176. group by so.organ_id_
  1177. </select>
  1178. <select id="queryVipQuitOrder" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
  1179. SELECT spo.* FROM student_payment_order spo
  1180. left join class_group_student_mapper cgsm ON spo.class_group_id_ = cgsm.class_group_id_ and spo.music_group_id_ = cgsm.music_group_id_
  1181. WHERE cgsm.music_group_id_ = #{vipGroupId} AND cgsm.status_ != 'QUIT'
  1182. AND spo.type_ IN ('LIVE_GROUP_BUY','SMALL_CLASS_TO_BUY')
  1183. AND spo.status_ = 'SUCCESS' AND spo.class_group_id_ = cgsm.class_group_id_ and spo.music_group_id_ = cgsm.music_group_id_
  1184. </select>
  1185. <select id="saleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
  1186. SELECT
  1187. SUM(actual_amount_) AS 'actualAmount'
  1188. , SUM(balance_payment_amount_) AS 'balancePaymentAmount'
  1189. , COUNT(distinct user_id_) AS 'userPurchaseNumber'
  1190. FROM student_payment_order
  1191. <where>
  1192. status_ = 'SUCCESS'
  1193. <if test="param.tenantId != null">
  1194. AND tenant_id_ =#{param.tenantId}
  1195. </if>
  1196. <if test="param.groupType != null">
  1197. AND group_type_ =#{param.groupType}
  1198. </if>
  1199. <if test="param.type != null">
  1200. AND type_ =#{param.type}
  1201. </if>
  1202. <if test="param.activityId != null">
  1203. AND find_in_set(activity_id_,#{param.activityId})
  1204. </if>
  1205. <if test="param.musicGroupId != null">
  1206. AND find_in_set(music_group_id_,#{param.musicGroupId})
  1207. </if>
  1208. </where>
  1209. </select>
  1210. <select id="musicalSaleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
  1211. SELECT
  1212. SUM(t.actual_amount_) AS 'actualAmount'
  1213. , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
  1214. , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
  1215. FROM student_payment_order t
  1216. LEFT join sell_order so on t.order_no_ = so.order_no_
  1217. <where>
  1218. t.status_ = 'SUCCESS'
  1219. AND t.tenant_id_ = #{param.tenantId}
  1220. AND find_in_set(so.goods_id_,#{param.goodId})
  1221. AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
  1222. </where>
  1223. </select>
  1224. <select id="saleStaticsByOrgId" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
  1225. SELECT
  1226. t.organ_id_ AS organId
  1227. , SUM(t.actual_amount_) AS 'actualAmount'
  1228. , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
  1229. , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
  1230. FROM student_payment_order t
  1231. <if test="param.goodId != null">
  1232. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1233. </if>
  1234. <where>
  1235. t.status_ = 'SUCCESS'
  1236. <if test="param.tenantId != null">
  1237. AND t.tenant_id_ =#{param.tenantId}
  1238. </if>
  1239. <if test="param.groupType!= null">
  1240. AND t.group_type_ =#{param.groupType}
  1241. </if>
  1242. <if test="param.type!= null">
  1243. AND t.type_ =#{param.type}
  1244. </if>
  1245. <if test="param.activityId != null">
  1246. AND find_in_set(t.activity_id_,#{param.activityId})
  1247. </if>
  1248. <if test="param.musicGroupId != null">
  1249. AND find_in_set(t.music_group_id_,#{param.musicGroupId})
  1250. </if>
  1251. <if test="param.goodId != null">
  1252. AND find_in_set(so.goods_id_,#{param.goodId})
  1253. </if>
  1254. <if test="param.startPayTime != null and param.endPayTime != null">
  1255. AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
  1256. </if>
  1257. </where>
  1258. GROUP BY organ_id_
  1259. </select>
  1260. <select id="queryPaymentStudentByPage" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleStaticsStudent">
  1261. select t.user_id_ as userId
  1262. , t.organ_id_ as organId
  1263. , su.username_ as userName
  1264. , su.phone_ as phone
  1265. , t.pay_time_ as payTime
  1266. , (t.actual_amount_ + t.balance_payment_amount_) as payAmount
  1267. from student_payment_order t
  1268. left join sys_user su on t.user_id_ = su.id_
  1269. <if test="goodId != null">
  1270. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1271. </if>
  1272. <where>
  1273. t.status_='SUCCESS'
  1274. <if test="tenantId != null">
  1275. AND t.tenant_id_ =#{tenantId}
  1276. </if>
  1277. <if test="organId != null">
  1278. AND t.organ_id_ = #{organId}
  1279. </if>
  1280. <if test="userName != null and userName.trim() !=''">
  1281. AND su.username_ like concat('%',#{userName},'%')
  1282. </if>
  1283. <if test="groupType != null">
  1284. AND group_type_ =#{groupType}
  1285. </if>
  1286. <if test="type != null">
  1287. AND type_ =#{type}
  1288. </if>
  1289. <if test="activityId != null">
  1290. AND find_in_set(activity_id_,#{activityId})
  1291. </if>
  1292. <if test="musicGroupId != null">
  1293. AND find_in_set(music_group_id_,#{musicGroupId})
  1294. </if>
  1295. <if test="goodId != null">
  1296. AND find_in_set(so.goods_id_,#{goodId})
  1297. </if>
  1298. <if test="startPayTime != null and endPayTime != null">
  1299. AND t.pay_time_ between #{startPayTime} and #{endPayTime}
  1300. </if>
  1301. </where>
  1302. <if test=" orderBy != null and asc == 0">
  1303. order by ${orderBy} desc
  1304. </if>
  1305. <if test=" orderBy != null and asc == 1">
  1306. order by ${orderBy} asc
  1307. </if>
  1308. <include refid="global.limit"/>
  1309. </select>
  1310. <select id="queryPaymentStudentCount" resultType="java.lang.Integer">
  1311. select count(1) from student_payment_order t
  1312. left join sys_user su on t.user_id_ = su.id_
  1313. <if test="goodId != null">
  1314. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1315. </if>
  1316. <where>
  1317. t.status_='SUCCESS'
  1318. <if test="tenantId != null">
  1319. AND t.tenant_id_ =#{tenantId}
  1320. </if>
  1321. <if test="organId != null">
  1322. AND t.organ_id_ = #{organId}
  1323. </if>
  1324. <if test="userName != null and userName.trim() !=''">
  1325. AND su.username_ like concat('%',#{userName},'%')
  1326. </if>
  1327. <if test="groupType != null">
  1328. AND group_type_ =#{groupType}
  1329. </if>
  1330. <if test="type != null">
  1331. AND type_ =#{type}
  1332. </if>
  1333. <if test="activityId != null">
  1334. AND find_in_set(activity_id_,#{activityId})
  1335. </if>
  1336. <if test="musicGroupId != null">
  1337. AND find_in_set(music_group_id_,#{musicGroupId})
  1338. </if>
  1339. <if test="goodId != null">
  1340. AND find_in_set(so.goods_id_,#{goodId})
  1341. </if>
  1342. <if test="startPayTime != null and endPayTime != null">
  1343. AND t.pay_time_ between #{startPayTime} and #{endPayTime}
  1344. </if>
  1345. </where>
  1346. </select>
  1347. </mapper>