StudentPaymentOrderMapper.xml 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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.organId != null">
  1197. AND find_in_set(organ_id_,#{param.organId})
  1198. </if>
  1199. <if test="param.groupType != null">
  1200. AND group_type_ =#{param.groupType}
  1201. </if>
  1202. <if test="param.type != null">
  1203. AND type_ =#{param.type}
  1204. </if>
  1205. <if test="param.activityId != null">
  1206. AND find_in_set(activity_id_,#{param.activityId})
  1207. </if>
  1208. <if test="param.musicGroupId != null">
  1209. AND find_in_set(music_group_id_,#{param.musicGroupId})
  1210. </if>
  1211. </where>
  1212. </select>
  1213. <select id="musicalSaleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
  1214. SELECT
  1215. SUM(t.actual_amount_) AS 'actualAmount'
  1216. , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
  1217. , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
  1218. FROM student_payment_order t
  1219. LEFT join sell_order so on t.order_no_ = so.order_no_
  1220. <where>
  1221. t.status_ = 'SUCCESS'
  1222. AND find_in_set(so.goods_id_,#{param.goodId})
  1223. AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
  1224. <if test="param.tenantId != null">
  1225. AND t.tenant_id_ =#{param.tenantId}
  1226. </if>
  1227. <if test="param.organId != null">
  1228. AND find_in_set(t.organ_id_,#{param.organId})
  1229. </if>
  1230. </where>
  1231. </select>
  1232. <select id="saleStaticsByOrgId" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
  1233. SELECT
  1234. t.organ_id_ AS organId
  1235. , SUM(t.actual_amount_) AS 'actualAmount'
  1236. , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
  1237. , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
  1238. , group_concat(distinct t.user_id_) AS 'userIds'
  1239. FROM student_payment_order t
  1240. <if test="param.goodId != null">
  1241. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1242. </if>
  1243. <where>
  1244. t.status_ = 'SUCCESS'
  1245. <if test="param.tenantId != null">
  1246. AND t.tenant_id_ =#{param.tenantId}
  1247. </if>
  1248. <if test="param.organId != null">
  1249. AND find_in_set(t.organ_id_,#{param.organId})
  1250. </if>
  1251. <if test="param.groupType!= null">
  1252. AND t.group_type_ =#{param.groupType}
  1253. </if>
  1254. <if test="param.type!= null">
  1255. AND t.type_ =#{param.type}
  1256. </if>
  1257. <if test="param.activityId != null">
  1258. AND find_in_set(t.activity_id_,#{param.activityId})
  1259. </if>
  1260. <if test="param.musicGroupId != null">
  1261. AND find_in_set(t.music_group_id_,#{param.musicGroupId})
  1262. </if>
  1263. <if test="param.goodId != null">
  1264. AND find_in_set(so.goods_id_,#{param.goodId})
  1265. </if>
  1266. <if test="param.startPayTime != null and param.endPayTime != null">
  1267. AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
  1268. </if>
  1269. </where>
  1270. GROUP BY t.organ_id_
  1271. </select>
  1272. <select id="queryPaymentStudentByPage" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleStaticsStudent">
  1273. select t.user_id_ as userId
  1274. , t.organ_id_ as organId
  1275. , su.username_ as userName
  1276. , su.phone_ as phone
  1277. , t.pay_time_ as payTime
  1278. , (t.actual_amount_ + t.balance_payment_amount_) as payAmount
  1279. from student_payment_order t
  1280. left join sys_user su on t.user_id_ = su.id_
  1281. <if test="goodId != null">
  1282. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1283. </if>
  1284. <where>
  1285. t.status_='SUCCESS'
  1286. <if test="tenantId != null">
  1287. AND t.tenant_id_ =#{tenantId}
  1288. </if>
  1289. <if test="organId != null">
  1290. AND find_in_set(t.organ_id_,#{organId})
  1291. </if>
  1292. <if test="organId != null">
  1293. AND t.organ_id_ = #{organId}
  1294. </if>
  1295. <if test="userName != null and userName.trim() !=''">
  1296. AND su.username_ like concat('%',#{userName},'%')
  1297. </if>
  1298. <if test="groupType != null">
  1299. AND group_type_ =#{groupType}
  1300. </if>
  1301. <if test="type != null">
  1302. AND type_ =#{type}
  1303. </if>
  1304. <if test="activityId != null">
  1305. AND find_in_set(activity_id_,#{activityId})
  1306. </if>
  1307. <if test="musicGroupId != null">
  1308. AND find_in_set(music_group_id_,#{musicGroupId})
  1309. </if>
  1310. <if test="goodId != null">
  1311. AND find_in_set(so.goods_id_,#{goodId})
  1312. </if>
  1313. <if test="startPayTime != null and endPayTime != null">
  1314. AND t.pay_time_ between #{startPayTime} and #{endPayTime}
  1315. </if>
  1316. </where>
  1317. <if test=" orderBy != null and asc == 0">
  1318. order by ${orderBy} desc
  1319. </if>
  1320. <if test=" orderBy != null and asc == 1">
  1321. order by ${orderBy} asc
  1322. </if>
  1323. <include refid="global.limit"/>
  1324. </select>
  1325. <select id="queryPaymentStudentCount" resultType="java.lang.Integer">
  1326. select count(1) from student_payment_order t
  1327. left join sys_user su on t.user_id_ = su.id_
  1328. <if test="goodId != null">
  1329. LEFT JOIN sell_order so on t.order_no_ = so.order_no_
  1330. </if>
  1331. <where>
  1332. t.status_='SUCCESS'
  1333. <if test="tenantId != null">
  1334. AND t.tenant_id_ =#{tenantId}
  1335. </if>
  1336. <if test="organId != null">
  1337. AND find_in_set(t.organ_id_,#{organId})
  1338. </if>
  1339. <if test="userName != null and userName.trim() !=''">
  1340. AND su.username_ like concat('%',#{userName},'%')
  1341. </if>
  1342. <if test="groupType != null">
  1343. AND group_type_ =#{groupType}
  1344. </if>
  1345. <if test="type != null">
  1346. AND type_ =#{type}
  1347. </if>
  1348. <if test="activityId != null">
  1349. AND find_in_set(activity_id_,#{activityId})
  1350. </if>
  1351. <if test="musicGroupId != null">
  1352. AND find_in_set(music_group_id_,#{musicGroupId})
  1353. </if>
  1354. <if test="goodId != null">
  1355. AND find_in_set(so.goods_id_,#{goodId})
  1356. </if>
  1357. <if test="startPayTime != null and endPayTime != null">
  1358. AND t.pay_time_ between #{startPayTime} and #{endPayTime}
  1359. </if>
  1360. </where>
  1361. </select>
  1362. </mapper>