| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <!--
- 这个文件是自动生成的。
- 不要修改此文件。所有改动将在下次重新自动生成时丢失。
- -->
- <mapper namespace="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao">
- <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" id="StudentPaymentOrder">
- <result column="id_" property="id"/>
- <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="user_id_" property="userId"/>
- <result column="organ_id_" property="organId"/>
- <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="expect_amount_" property="expectAmount"/>
- <result column="actual_amount_" property="actualAmount"/>
- <result column="com_amount_" property="comAmount"/>
- <result column="per_amount_" property="perAmount"/>
- <result column="balance_payment_amount_" property="balancePaymentAmount"/>
- <result column="remit_fee_" property="remitFee"/>
- <result column="course_remit_fee_" property="courseRemitFee"/>
- <result column="trans_no_" property="transNo"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="memo_" property="memo"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="payment_channel_" property="paymentChannel"/>
- <result column="payment_business_channel_" property="paymentBusinessChannel"/>
- <result column="payment_account_no_" property="paymentAccountNo"/>
- <result column="mer_nos_" property="merNos"/>
- <result column="order_no_" property="orderNo"/>
- <result column="music_group_id_" property="musicGroupId"/>
- <result column="class_group_id_" property="classGroupId"/>
- <result column="pay_time_" property="payTime"/>
- <result column="version_" property="version"/>
- <result column="receive_status_" property="receiveStatus"/>
- <result column="batch_no_" property="batchNo"/>
- <result column="coupon_code_id_" property="couponCodeId"/>
- <result column="coupon_remit_fee_" property="couponRemitFee"/>
- <result column="activity_id_" property="activityId"/>
- <result column="activity_buy_num_" property="activityBuyNum"/>
- <result column="tenant_id_" property="tenantId"/>
- <result column="calender_id_" property="calenderId"/>
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" extends="StudentPaymentOrder"
- id="PaymentOrderAndStudentInfo">
- <result column="username_" property="user.username"/>
- <result column="phone_" property="user.phone"/>
- <result column="organ_name_" property="organName"/>
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
- <result column="id_" property="id"/>
- <result column="goods_category_id_" property="goodsCategoryId"/>
- <result column="sn_" property="sn"/>
- <result column="name_" property="name"/>
- <result column="brand_" property="brand"/>
- <result column="specification_" property="specification"/>
- <result column="image_" property="image"/>
- <result column="stock_count_" property="stockCount"/>
- <result column="sell_count_" property="sellCount"/>
- <result column="market_price_" property="marketPrice"/>
- <result column="discount_price_" property="discountPrice"/>
- <result column="group_purchase_price_" property="groupPurchasePrice"/>
- <result column="brief_" property="brief"/>
- <result column="desc_" property="desc"/>
- <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="memo_" property="memo"/>
- <result column="publish_time_" property="publishTime"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
- </resultMap>
- <resultMap id="StudentVipDouble11Dto" type="com.ym.mec.biz.dal.dto.StudentVipDouble11Dto">
- <result column="payment_one_to_one_time_" property="paymentOneToOneTime"/>
- <result column="payment_one_to_two_time_" property="paymentOneToTwoTime"/>
- <result column="course_one_to_one_time_" property="courseOneToOneTime"/>
- <result column="course_one_to_two_time_" property="courseOneToTwoTime"/>
- </resultMap>
-
- <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
- <result column="key_" property="key"/>
- <result column="value_" property="value"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE id_ = #{id}
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order where tenant_id_ = #{tenantId}
- ORDER BY id_
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
- keyColumn="id" keyProperty="id">
- INSERT INTO student_payment_order
- (group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
- per_amount_,
- balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
- status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
- payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,batch_no_,coupon_code_id_,
- coupon_remit_fee_,activity_id_,activity_buy_num_,tenant_id_,calender_id_)
- VALUES (#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{userId}, #{organId}, #{routingOrganId},
- #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
- #{remitFee}, #{courseRemitFee}, #{transNo},
- #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
- #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
- #{musicGroupId},
- #{classGroupId}, #{payTime},#{batchNo},#{couponCodeId},#{couponRemitFee},#{activityId},#{activityBuyNum},#{tenantId},#{calenderId})
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
- UPDATE student_payment_order
- <set>
- <if test="activityBuyNum != null">
- activity_buy_num_ = #{activityBuyNum},
- </if>
- <if test="activityId != null">
- activity_id_ = #{activityId},
- </if>
- <if test="receiveStatus != null and receiveStatus != ''">
- receive_status_ = #{receiveStatus},
- </if>
- <if test="status != null">
- status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="groupType != null">
- group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="orderNo != null">
- order_no_ = #{orderNo},
- </if>
- <if test="classGroupId != null">
- class_group_id_ = #{classGroupId},
- </if>
- <if test="expectAmount != null">
- expect_amount_ = #{expectAmount},
- </if>
- <if test="memo != null">
- memo_ = #{memo},
- </if>
- <if test="paymentChannel != null">
- payment_channel_ = #{paymentChannel},
- </if>
- <if test="userId != null">
- user_id_ = #{userId},
- </if>
- <if test="paymentAccountNo != null">
- payment_account_no_ = #{paymentAccountNo},
- </if>
- <if test="merNos != null">
- mer_nos_ = #{merNos},
- </if>
- <if test="paymentBusinessChannel != null">
- payment_business_channel_ = #{paymentBusinessChannel},
- </if>
- <if test="transNo != null">
- trans_no_ = #{transNo},
- </if>
- <if test="actualAmount != null">
- actual_amount_ = #{actualAmount},
- </if>
- <if test="comAmount != null">
- com_amount_ = #{comAmount},
- </if>
- <if test="perAmount != null">
- per_amount_ = #{perAmount},
- </if>
- <if test="balancePaymentAmount != null">
- balance_payment_amount_ = #{balancePaymentAmount},
- </if>
- <if test="remitFee != null">
- remit_fee_ = #{remitFee},
- </if>
- <if test="courseRemitFee != null">
- course_remit_fee_ = #{courseRemitFee},
- </if>
- <if test="type != null">
- type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="musicGroupId != null">
- music_group_id_ = #{musicGroupId},
- </if>
- <if test="organId != null">
- organ_id_ = #{organId},
- </if>
- <if test="routingOrganId != null">
- routing_organ_id_ = #{routingOrganId},
- </if>
- <if test="payTime != null">
- pay_time_ = #{payTime},
- </if>
- <if test="batchNo != null">
- batch_no_ = #{batchNo},
- </if>
- <if test="version != null">
- version_ = version_+1,
- </if>
- update_time_ = NOW()
- </set>
- WHERE id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
- </update>
-
- <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
- <foreach collection="studentPaymentOrderList" item="studentPaymentOrder" separator=";">
- UPDATE student_payment_order
- <set>
- <if test="studentPaymentOrder.activityBuyNum != null">
- activity_buy_num_ = #{studentPaymentOrder.activityBuyNum},
- </if>
- <if test="studentPaymentOrder.activityId != null">
- activity_id_ = #{studentPaymentOrder.activityId},
- </if>
- <if test="studentPaymentOrder.receiveStatus != null and studentPaymentOrder.receiveStatus != ''">
- receive_status_ = #{studentPaymentOrder.receiveStatus},
- </if>
- <if test="studentPaymentOrder.status != null">
- status_ = #{studentPaymentOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="studentPaymentOrder.groupType != null">
- group_type_ = #{studentPaymentOrder.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="studentPaymentOrder.orderNo != null">
- order_no_ = #{studentPaymentOrder.orderNo},
- </if>
- <if test="studentPaymentOrder.classGroupId != null">
- class_group_id_ = #{studentPaymentOrder.classGroupId},
- </if>
- <if test="studentPaymentOrder.expectAmount != null">
- expect_amount_ = #{studentPaymentOrder.expectAmount},
- </if>
- <if test="studentPaymentOrder.memo != null">
- memo_ = #{studentPaymentOrder.memo},
- </if>
- <if test="studentPaymentOrder.paymentChannel != null">
- payment_channel_ = #{studentPaymentOrder.paymentChannel},
- </if>
- <if test="studentPaymentOrder.userId != null">
- user_id_ = #{studentPaymentOrder.userId},
- </if>
- <if test="studentPaymentOrder.paymentAccountNo != null">
- payment_account_no_ = #{studentPaymentOrder.paymentAccountNo},
- </if>
- <if test="studentPaymentOrder.merNos != null">
- mer_nos_ = #{studentPaymentOrder.merNos},
- </if>
- <if test="studentPaymentOrder.paymentBusinessChannel != null">
- payment_business_channel_ = #{studentPaymentOrder.paymentBusinessChannel},
- </if>
- <if test="studentPaymentOrder.transNo != null">
- trans_no_ = #{studentPaymentOrder.transNo},
- </if>
- <if test="studentPaymentOrder.actualAmount != null">
- actual_amount_ = #{studentPaymentOrder.actualAmount},
- </if>
- <if test="studentPaymentOrder.comAmount != null">
- com_amount_ = #{studentPaymentOrder.comAmount},
- </if>
- <if test="studentPaymentOrder.perAmount != null">
- per_amount_ = #{studentPaymentOrder.perAmount},
- </if>
- <if test="studentPaymentOrder.balancePaymentAmount != null">
- balance_payment_amount_ = #{studentPaymentOrder.balancePaymentAmount},
- </if>
- <if test="studentPaymentOrder.remitFee != null">
- remit_fee_ = #{studentPaymentOrder.remitFee},
- </if>
- <if test="studentPaymentOrder.courseRemitFee != null">
- course_remit_fee_ = #{studentPaymentOrder.courseRemitFee},
- </if>
- <if test="studentPaymentOrder.type != null">
- type_ = #{studentPaymentOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="studentPaymentOrder.musicGroupId != null">
- music_group_id_ = #{studentPaymentOrder.musicGroupId},
- </if>
- <if test="studentPaymentOrder.organId != null">
- organ_id_ = #{studentPaymentOrder.organId},
- </if>
- <if test="studentPaymentOrder.routingOrganId != null">
- routing_organ_id_ = #{studentPaymentOrder.routingOrganId},
- </if>
- <if test="studentPaymentOrder.payTime != null">
- pay_time_ = #{studentPaymentOrder.payTime},
- </if>
- <if test="studentPaymentOrder.batchNo != null">
- batch_no_ = #{studentPaymentOrder.batchNo},
- </if>
- <if test="studentPaymentOrder.version != null">
- version_ = version_+1,
- </if>
- update_time_ = NOW()
- </set>
- WHERE id_ = #{studentPaymentOrder.id} AND version_ = #{studentPaymentOrder.version} and tenant_id_ = #{studentPaymentOrder.tenantId}
- </foreach>
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete">
- DELETE
- FROM student_payment_order
- WHERE id_ = #{id}
- </delete>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
- SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
- left join sys_user u on spo.user_id_ = u.id_
- left join organization o on o.id_ = spo.organ_id_
- <include refid="queryPaymentOrder"/>
- ORDER BY spo.id_ DESC
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int" parameterType="map">
- SELECT COUNT(spo.id_) FROM student_payment_order spo
- left join sys_user u on spo.user_id_ = u.id_
- <include refid="queryPaymentOrder"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount1" resultType="int" parameterType="map">
- SELECT COUNT(spo.id_) FROM student_payment_order spo
- WHERE spo.tenant_id_ = 1 AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
- AND spo.group_type_ != 'MALL_SELL'
- </select>
- <sql id="queryPaymentMallOrder">
- <where>
- spo.tenant_id_ = #{tenantId}
- <if test="userIds != null">
- AND spo.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </if>
- <if test="organId != null">
- AND FIND_IN_SET(spo.organ_id_,#{organId})
- </if>
- <if test="orderStartDate != null">
- AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') >= #{orderStartDate}
- </if>
- <if test="orderEndDate != null">
- AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') <= #{orderEndDate}
- </if>
- <if test="notGroupType != null and notGroupType != ''">
- AND spo.group_type_ != #{notGroupType}
- </if>
- <if test="paymentType != null">
- AND spo.type_ = #{paymentType}
- </if>
- <if test="remark != null">
- AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
- </if>
- <if test="studentId != null">
- AND spo.user_id_ = #{studentId}
- </if>
- <if test="paymentStatus != null">
- AND spo.status_ = #{paymentStatus}
- </if>
- <if test="paymentChannel != null">
- AND spo.payment_channel_ NOT IN (#{paymentChannel})
- </if>
- <if test='orderType != null and orderType.toString()=="1".toString()'>
- AND spo.com_amount_ > 0
- </if>
- <if test='orderType != null and orderType.toString()=="2".toString()'>
- AND spo.per_amount_ > 0
- </if>
- <if test="routingOrganId != null">
- AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
- </if>
- <if test="actualAmount != null">
- AND spo.actual_amount_ >= #{actualAmount}
- </if>
- <if test="balancePaymentAmount != null">
- AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
- </if>
- <if test="lessActualAmount != null">
- <![CDATA[ AND spo.actual_amount_ <= #{lessActualAmount}]]>
- </if>
- <if test="lessBalancePaymentAmount != null">
- <![CDATA[AND spo.balance_payment_amount_ <= #{lessBalancePaymentAmount}]]>
- </if>
- <if test="orderNo != null">
- AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
- </if>
- <if test="merNos != null">
- AND FIND_IN_SET(#{merNos},spo.mer_nos_)
- </if>
- <if test="transNo != null">
- AND spo.trans_no_ = #{transNo}
- </if>
- </where>
- </sql>
- <sql id="queryPaymentOrder">
- <where>
- spo.tenant_id_ = #{tenantId}
- <if test="userIds != null">
- AND spo.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </if>
- <if test="organId != null">
- AND FIND_IN_SET(spo.organ_id_,#{organId})
- </if>
- <if test="orderStartDate != null">
- AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') >= #{orderStartDate}
- </if>
- <if test="orderEndDate != null">
- AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') <= #{orderEndDate}
- </if>
- <if test="month != null and month != ''">
- AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
- </if>
- <if test="notGroupType != null and notGroupType != ''">
- AND spo.group_type_ != #{notGroupType}
- </if>
- <if test="paymentType != null">
- AND spo.type_ = #{paymentType}
- </if>
- <if test="remark != null">
- AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
- </if>
- <if test="studentId != null">
- AND spo.user_id_ = #{studentId}
- </if>
- <if test="paymentStatus != null">
- AND spo.status_ = #{paymentStatus}
- </if>
- <if test="paymentChannel != null">
- AND spo.payment_channel_ NOT IN (#{paymentChannel})
- </if>
- <if test='orderType != null and orderType.toString()=="1".toString()'>
- AND spo.com_amount_ > 0
- </if>
- <if test='orderType != null and orderType.toString()=="2".toString()'>
- AND spo.per_amount_ > 0
- </if>
- <if test="routingOrganId != null">
- AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
- </if>
- <if test="actualAmount != null">
- AND spo.actual_amount_ >= #{actualAmount}
- </if>
- <if test="balancePaymentAmount != null">
- AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
- </if>
- <if test="lessActualAmount != null">
- <![CDATA[ AND spo.actual_amount_ <= #{lessActualAmount}]]>
- </if>
- <if test="lessBalancePaymentAmount != null">
- <![CDATA[AND spo.balance_payment_amount_ <= #{lessBalancePaymentAmount}]]>
- </if>
- <if test="orderNo != null">
- AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
- </if>
- <if test="merNos != null">
- AND FIND_IN_SET(#{merNos},spo.mer_nos_)
- </if>
- <if test="transNo != null">
- AND spo.trans_no_ = #{transNo}
- </if>
- <if test="chargeType != null">
- AND spo.group_type_='SPORADIC'
- AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </where>
- </sql>
- <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
- SELECT spo.*
- FROM student_payment_order spo
- WHERE spo.user_id_ = #{userId}
- <if test="musicGroupId != null">
- AND spo.music_group_id_ = #{musicGroupId}
- </if>
- AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- <if test="groupType != null">
- AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </select>
- <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
- SELECT spo.* FROM
- student_payment_order spo
- WHERE spo.user_id_ = #{userId}
- AND spo.music_group_id_ = #{vipGroupId}
- <if test="status!=null and status!=''">
- AND spo.status_=#{status}
- </if>
- <if test="orderType != null and orderType != ''">
- AND spo.type_ = #{orderType}
- </if>
- <if test="orderType == null or orderType == ''">
- AND spo.type_ = 'SMALL_CLASS_TO_BUY'
- </if>
- order by id_ DESC LIMIT 1
- </select>
- <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
- SELECT SUM(cssp.expect_price_)
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE cssp.user_id_ = #{userId}
- AND cssp.music_group_id_ = #{vipGroupId}
- AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
- </select>
- <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
- SELECT spo.*
- FROM student_payment_order spo
- WHERE spo.user_id_ = #{userId}
- AND spo.music_group_id_ = #{vipGroupId}
- AND spo.status_ != 'FAILED'
- AND spo.type_ = 'SMALL_CLASS_TO_BUY'
- </select>
- <!-- 查询报名订单 -->
- <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order
- WHERE music_group_id_ = #{musicGroupId}
- AND user_id_ = #{userId}
- AND type_ = 'APPLY'
- AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- ORDER BY id_ DESC
- </select>
-
- <select id="queryByBatchNo" resultMap="StudentPaymentOrder" parameterType="map">
- SELECT *
- FROM student_payment_order
- WHERE batch_no_ = #{batchNo}
- AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- and user_id_ = #{userId}
- </select>
- <!-- 根据订单号查询订单 -->
- <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE order_no_ = #{orderNo}
- </select>
-
- <select id="findOrderByOrderNos" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE order_no_ in
- <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
- #{orderNo}
- </foreach>
- </select>
- <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
- SELECT *
- FROM student_payment_order
- WHERE music_group_id_ = #{musicGroupId}
- AND type_ = #{type}
- AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </select>
- <resultMap type="com.ym.mec.biz.dal.dto.UserGoodsDto" id="userGoodsDto">
- <result column="goods_id_" property="goodsId"/>
- <collection property="goodsName" ofType="string">
- <result column="goods_name_"/>
- </collection>
- </resultMap>
- <select id="findGoodsIds" resultMap="userGoodsDto">
- SELECT g.id_ goods_id_, g.name_ goods_name_
- FROM student_payment_order spo
- LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
- LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
- WHERE spo.type_ = 'APPLY'
- AND spo.status_ = 'SUCCESS'
- AND spod.goods_id_list_ IS NOT NULL
- AND spo.music_group_id_ = #{musicGroupId}
- AND spo.user_id_ = #{userId}
- </select>
- <select id="getUserGoods" resultMap="userGoodsDto">
- SELECT id_ goods_id_, name_ goods_name_ FROM goods WHERE FIND_IN_SET(id_,#{ids})
- </select>
- <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- <!-- 商城订单由商城控制订单超时 -->
- and group_type_ != 'MALL_SELL' and type_ != 'MALL_BUY'
- </select>
- <!-- 查询支付中超时订单 -->
- <select id="findOrdersOverTime" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order WHERE order_no_ IN
- <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
- #{orderNo}
- </foreach>
- AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
- </select>
- <select id="countStudentPaymentNum" resultType="int">
- select count(DISTINCT user_id_)
- from student_payment_order
- where music_group_id_ = #{musicGroupId}
- AND status_ = 'SUCCESS'
- AND type_ = 'SMALL_CLASS_TO_BUY'
- </select>
- <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
- SELECT COUNT(*)
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE cssp.user_id_ = #{userId}
- AND cssp.music_group_id_ = #{musicGroupId}
- AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
- </select>
- <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
- SELECT
- (CASE WHEN a.a > 0 THEN a.a ELSE c.c END) +
- (CASE WHEN d.d IS NULL THEN 0 ELSE d.d END) +
- (CASE WHEN e.e IS NULL THEN 0 ELSE e.e END) -
- (CASE WHEN b.b IS NULL THEN 0 ELSE b.b END) amount_
- FROM
- (SELECT SUM(CASE WHEN expect_amount_ IS NULL THEN 0 ELSE expect_amount_ END) a FROM student_payment_order
- WHERE group_type_ = #{groupType} AND music_group_id_ = #{vipGroupId} AND status_ = 'SUCCESS') a,
- (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,
- (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,
- (SELECT SUM(CASE WHEN amount_ IS NULL THEN 0 ELSE amount_ END) d FROM sys_user_cash_account_detail WHERE group_id_ = #{vipGroupId}) d,
- (SELECT SUM(CASE WHEN amount_ IS NULL THEN 0 ELSE amount_ END) e FROM sys_user_courses_account_detail WHERE group_id_ = #{vipGroupId}) e
- </select>
- <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
- 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_
- FROM student_payment_order spo
- LEFT JOIN student_registration sr ON sr.user_id_ = spo.user_id_
- LEFT JOIN (SELECT id_,music_group_id_,original_order_id_,CASE WHEN goods_margin_ < 0 THEN goods_margin_ ELSE sell_amount_ END goods_margin_ FROM subject_change WHERE id_ in
- (SELECT max(id_) id_ from subject_change WHERE status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ desc)
- ) sc on spo.music_group_id_ = sc.music_group_id_ and spo.id_ = sc.original_order_id_
- WHERE spo.music_group_id_ = #{musicGroupId} AND sr.music_group_id_ = spo.music_group_id_ AND sr.music_group_status_ = 'NORMAL'
- AND spo.type_ = 'APPLY' and spo.status_ = 'SUCCESS'
- GROUP BY sr.user_id_;
- </select>
- <select id="findPaymentOrderByGroupType" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order
- WHERE group_type_ = #{groupType}
- AND user_id_ = #{userId}
- AND music_group_id_ = #{sporadicId}
- <if test="status != null">
- AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </select>
- <select id="queryExpectAmount" resultType="java.util.Map">
- SELECT spo.expect_amount_ 'value',spo.id_ 'key'
- FROM student_payment_order spo
- WHERE spo.id_ IN
- <foreach collection="paymentOrderNo" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </select>
- <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderMallExportDto" id="mallOrderAndDetail"
- extends="StudentPaymentOrder">
- <result column="organ_name" property="organName"/>
- <result column="username_" property="user.username"/>
- <result column="routeMerNo" property="routeMerNo"/>
- <result column="routeAmount" property="routeAmount"/>
- <result column="routeBalance" property="routeBalance"/>
- <result column="sale_amount_" property="saleAmount"/>
- <result column="service_amount_" property="serviceAmount"/>
- <result column="service_fee_" property="serviceFee"/>
- <result column="routeBalance" property="routeBalance"/>
- <result column="orderAmount" property="orderAmount"/>
- </resultMap>
- <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
- extends="StudentPaymentOrder">
- <result column="organ_name" property="organName"/>
- <result column="username_" property="user.username"/>
- <result column="charge_type_" property="chargeType"/>
- <result column="routeMerNo" property="routeMerNo"/>
- <result column="routeAmount" property="routeAmount"/>
- <result column="routeBalance" property="routeBalance"/>
- <result column="sale_amount_" property="saleAmount"/>
- <result column="service_amount_" property="serviceAmount"/>
- <result column="service_fee_" property="serviceFee"/>
- <result column="routeBalance" property="routeBalance"/>
- <result column="feeFlag" property="feeFlag"/>
- <result column="orderAmount" property="orderAmount"/>
- <result column="cooperation_id_" property="cooperationId"/>
- <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
- <result column="detail_id_" property="id"/>
- <result column="detail_type_" property="type"/>
- <result column="detail_price_" property="price"/>
- <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
- <result column="income_item_" property="incomeItem"/>
- <result column="income_" property="income"/>
- </collection>
- <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
- <result column="goods_id" property="id"/>
- <result column="goods_name" property="name"/>
- </collection>
- </resultMap>
- <!-- 分页查询 -->
- <select id="exportMallQueryPage" resultMap="mallOrderAndDetail" parameterType="map">
- SELECT spo.*,u.username_,o.name_ organ_name,sgs.goods_json_
- FROM student_payment_order spo
- left join student_goods_sell sgs ON sgs.order_no_ = spo.order_no_
- LEFT JOIN sys_user u on spo.user_id_ = u.id_
- <if test='orderType != null and orderType.toString()=="0".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="1".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="2".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="3".toString()'>
- LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
- </if>
- <include refid="queryPaymentMallOrder"/>
- ORDER BY spo.id_ ASC
- </select>
- <!-- 分页查询 -->
- <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
- SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
- detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
- sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name,spo.cooperation_id_
- FROM student_payment_order spo
- LEFT JOIN sys_user u on spo.user_id_ = u.id_
- LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
- <if test='orderType != null and orderType.toString()=="0".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="1".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="2".toString()'>
- LEFT JOIN organization o on spo.organ_id_ = o.id_
- </if>
- <if test='orderType != null and orderType.toString()=="3".toString()'>
- LEFT JOIN organization o on spo.routing_organ_id_ = o.id_
- </if>
- LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
- LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
- <include refid="queryPaymentOrder"/>
- ORDER BY spo.id_ ASC
- </select>
- <select id="ExportQueryPage1" resultMap="orderAndDetail" parameterType="map">
- SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
- detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
- sci.charge_type_
- FROM student_payment_order spo
- LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
- LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
- 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})
- AND spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
- </select>
- <select id="ExportQueryPage2" resultMap="orderAndDetail" parameterType="map">
- select spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
- detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
- sci.charge_type_ from student_payment_order spo
- LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
- LEFT JOIN sporadic_charge_info sci on spo.music_group_id_ = sci.id_
- where spo.tenant_id_ = 1 AND spo.status_ = 'SUCCESS'
- AND spo.order_no_ IN (select distinct order_no_ from sell_order where DATE_FORMAT(delivery_time_,'%Y-%m') = #{month})
- </select>
- <resultMap id="SporadicChargeInfoDtoMap" type="com.ym.mec.biz.dal.dto.SporadicChargeInfoDto">
- <result property="organName" column="organ_name_"/>
- <result property="title" column="title_"/>
- <result property="type" column="type_"/>
- <result property="amount" column="amount_"/>
- <result property="createTime" column="create_time_"/>
- <result property="payTime" column="pay_time_"/>
- <result property="username" column="username_"/>
- <result property="payStatus" column="pay_status_"/>
- </resultMap>
- <select id="sporadicQueryPage" resultMap="SporadicChargeInfoDtoMap">
- SELECT o.name_ organ_name_,sci.title_,sci.charge_type_ type_,
- spo.actual_amount_ amount_,spo.create_time_,spo.pay_time_,su.username_,spo.status_ pay_status_
- FROM student_payment_order spo
- LEFT JOIN sys_user su ON spo.user_id_ = su.id_
- LEFT JOIN organization o ON o.id_ = spo.organ_id_
- LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
- WHERE spo.type_ = 'SPORADIC' and spo.tenant_id_ = #{tenantId}
- <include refid="sporadicQueryPageSql"/>
- ORDER BY spo.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countSporadicPage" resultType="java.lang.Integer">
- SELECT COUNT(spo.id_)
- FROM student_payment_order spo
- LEFT JOIN sys_user su ON spo.user_id_ = su.id_
- LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
- WHERE spo.type_ = 'SPORADIC' and spo.tenant_id_ = #{tenantId}
- <include refid="sporadicQueryPageSql"/>
- </select>
- <sql id="sporadicQueryPageSql">
- <if test="organId != null">
- AND FIND_IN_SET(spo.organ_id_,#{organId})
- </if>
- <if test="search != null">
- AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="chargeType != null">
- AND sci.charge_type_ = #{chargeType}
- </if>
- <if test="payStatus != null">
- AND spo.status_ = #{payStatus}
- </if>
- </sql>
- <resultMap id="luckStatis" type="com.ym.mec.biz.dal.dto.OrderStatisDto">
- <result property="organId" column="organId"/>
- <result property="organName" column="organName"/>
- <result property="estimatedNums" column="estimatedNums"/>
- <result property="nums" column="nums"/>
- <result property="times" column="times"/>
- <result property="scale" column="scale"/>
- <result property="money" column="money"/>
- </resultMap>
- <select id="getLuckStatis" resultMap="luckStatis">
- SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
- FROM student_payment_order spo
- LEFT JOIN organization o ON o.id_ = spo.organ_id_
- WHERE spo.type_ = 'LUCK'
- AND spo.status_ = 'SUCCESS' and spo.tenant_id_ = #{tenantId}
- GROUP BY spo.organ_id_
- ORDER BY nums DESC;
- </select>
- <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
- select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
- where actual_amount_ > 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
- status_ = 'SUCCESS' and organ_id_ not in (36,38)
- and FIND_IN_SET(organ_id_,#{organId})
- </select>
- <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
- select count(*)
- from student_payment_order
- where user_id_ = #{userId}
- and music_group_id_ = #{vipGroupId}
- and group_type_ = 'VIP'
- and status_ = 'SUCCESS'
- </select>
- <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
- select *
- from student_payment_order
- where user_id_ = #{userId}
- and music_group_id_ = #{vipGroupId}
- and group_type_ = 'VIP'
- </select>
- <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
- select * from student_payment_order
- where user_id_=#{userId}
- and music_group_id_=#{groupId}
- and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- <if test="status!=null">
- and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </select>
- <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
- SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_)
- balance_payment_amount_ FROM student_payment_order spo
- <include refid="queryPaymentOrder"/>
- </select>
- <!-- 分页查询 -->
- <select id="queryPageOrder" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
- SELECT spo.*,u.username_,u.phone_,o.name_ organ_name_ FROM student_payment_order spo
- left join sys_user u on spo.user_id_ = u.id_
- left join organization o on o.id_ = spo.organ_id_
- <include refid="queryPaymentOrder"/>
- ORDER BY spo.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order
- WHERE music_group_id_=#{groupId}
- and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- <if test="status!=null">
- and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </select>
- <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
- SELECT SUM(per_amount_)
- FROM student_payment_order
- WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
- AND create_time_ >= #{firstDate}
- AND create_time_ <= NOW()
- AND FIND_IN_SET(#{merNo}, mer_nos_)
- ]]>
- </select>
- <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
- SELECT SUM(actual_amount_) FROM student_payment_order spo
- LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
- <include refid="queryPaymentOrder"/>
- </select>
- <select id="sumAccountAmount" resultType="java.math.BigDecimal">
- <![CDATA[
- SELECT SUM(actual_amount_)
- FROM student_payment_order
- WHERE status_ IN ('SUCCESS', 'ING')
- AND create_time_ >= #{firstDate}
- AND create_time_ <= NOW()
- AND mer_nos_ = #{merNo}
- ]]></select>
- <select id="countGroupOrderWithoutFailed" resultType="int">
- SELECT COUNT(*)
- FROM student_payment_order spo
- WHERE spo.music_group_id_ = #{groupId}
- AND spo.status_ NOT IN ('FAILED','CLOSE')
- AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler }
- </select>
- <select id="countSporadicOrder" resultType="java.lang.Integer">
- SELECT COUNT(id_)
- FROM student_payment_order spo
- WHERE spo.group_type_ = 'SPORADIC'
- AND spo.music_group_id_ = #{sporadicId}
- </select>
- <!-- 查找支付成功和支付中订单 -->
- <select id="findOrganPayOrderNum" resultType="int">
- SELECT COUNT(*)
- FROM student_payment_order
- WHERE organ_id_ = #{organId}
- AND status_ IN ('SUCCESS', 'ING')
- </select>
- <!-- 获取每月用户的对应类型订单订单 -->
- <select id="getOrderByMonthAndType" resultType="com.ym.mec.biz.dal.dto.OrderByTypeExportDto">
- SELECT o.name_ organName, spo.user_id_ studentId,su.username_ studentName,spo.type_ orderType,
- spo.actual_amount_ actualAmount,spo.music_group_id_ musicGroupId,spo.group_type_ groupType,spo.create_time_
- createTime
- FROM student_payment_order spo
- LEFT JOIN sys_user su on spo.user_id_ = su.id_
- LEFT JOIN organization o ON o.id_ = spo.id_
- WHERE spo.status_ = 'SUCCESS'
- AND FIND_IN_SET (spo.organ_id_,#{organIds})
- <if test="orderTypeList != null">
- AND spo.type_ IN
- <foreach collection="orderTypeList" item="orderType" open="(" close=")"
- separator=",">
- #{orderType}
- </foreach>
- </if>
- <if test="startTime != null">
- AND spo.create_time_ >= #{startTime}
- </if>
- <if test="endTime != null"><![CDATA[
- AND spo.create_time_ <= #{endTime}
- ]]></if>
- AND spo.actual_amount_ > 0
- </select>
- <select id="getUsers" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
- SELECT username_ name, id_ userId, phone_ phone
- FROM sys_user
- WHERE id_ = #{search}
- OR username_ LIKE CONCAT('%', #{search}, '%')
- OR phone_ LIKE CONCAT('%', #{search}, '%')
- </select>
- <select id="lockOrder" resultMap="StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE id_ = #{id} FOR
- UPDATE
- </select>
- <select id="doubleEleven2020Statis" resultMap="luckStatis">
- SELECT o.id_ organId, o.name_ organName, SUM(spo.actual_amount_) money, COUNT(DISTINCT spo.user_id_) nums,
- SUM(IF(spo.class_group_id_ is null ,1,spo.class_group_id_)) times FROM student_payment_order spo
- LEFT JOIN organization o ON o.id_ = spo.organ_id_
- WHERE spo.type_ = 'DOUBLE_ELEVEN2020'
- AND spo.status_ = 'SUCCESS'
- AND spo.organ_id_ IN
- <foreach collection="organs" item="organ" open="(" close=")" separator=",">
- #{organ.id}
- </foreach>
- GROUP BY spo.organ_id_
- </select>
- <select id="getUserOrderNumByType" resultType="int">
- SELECT COUNT(*)
- FROM student_payment_order
- WHERE user_id_ = #{userId}
- AND status_ = 'SUCCESS'
- AND type_ = #{orderType}
- </select>
- <select id="getUserOrderByType" resultMap="StudentPaymentOrder">
- 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}
- </select>
- <select id="queryDouble11Students" resultMap="StudentVipDouble11Dto">
- SELECT
- su.id_ userId,
- su.username_ userName,
- su.phone_ phone,
- su.avatar_ avatar,
- SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
- SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
- FROM
- student_payment_order spo
- LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
- LEFT JOIN student s ON spo.user_id_=s.user_id_
- LEFT JOIN sys_user su ON spo.user_id_ = su.id_
- WHERE
- spo.status_ = 'SUCCESS'
- AND spo.type_ = 'DOUBLE_ELEVEN2020'
- AND sci.title_ LIKE '双十一%'
- AND s.teacher_id_= #{teacherId}
- <if test="search!=null and search!=''">
- AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- GROUP BY
- spo.user_id_
- ORDER BY spo.user_id_
- <include refid="global.limit" />
- </select>
- <select id="countDouble11Students" resultType="int">
- SELECT
- COUNT(DISTINCT spo.user_id_)
- FROM
- student_payment_order spo
- LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
- LEFT JOIN student s ON spo.user_id_=s.user_id_
- LEFT JOIN sys_user su ON spo.user_id_ = su.id_
- WHERE
- spo.status_ = 'SUCCESS'
- AND spo.type_ = 'DOUBLE_ELEVEN2020'
- AND sci.title_ LIKE '双十一%'
- AND s.teacher_id_= #{teacherId}
- <if test="search!=null and search!=''">
- AND (su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
- </if>;
- </select>
- <select id="findStudentsDouble11Infos" resultMap="StudentVipDouble11Dto">
- SELECT
- su.id_ userId,
- su.username_ userName,
- su.phone_ phone,
- su.avatar_ avatar,
- SUM(CASE WHEN sci.title_ LIKE '%1V1%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_one_time_,
- SUM(CASE WHEN sci.title_ LIKE '%1V2%' THEN spo.class_group_id_ ELSE 0 END) payment_one_to_two_time_
- FROM
- student_payment_order spo
- LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_=sci.id_
- LEFT JOIN student s ON spo.user_id_=s.user_id_
- LEFT JOIN sys_user su ON spo.user_id_ = su.id_
- WHERE
- spo.status_ = 'SUCCESS'
- AND spo.type_ = 'DOUBLE_ELEVEN2020'
- AND sci.title_ LIKE '双十一%'
- AND spo.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- GROUP BY
- spo.user_id_
- </select>
- <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="applyOrderAndDetail"
- extends="StudentPaymentOrder">
- <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
- <result column="detail_id_" property="id"/>
- <result column="detail_type_" property="type"/>
- <result column="detail_price_" property="price"/>
- <result column="detail_kit_group_purchase_type_" property="kitGroupPurchaseType"/>
- <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
- <result column="goods_id" property="id"/>
- <result column="goods_name" property="name"/>
- <result column="complementGoodsIdList" property="complementGoodsIdList"/>
- </collection>
- </collection>
- </resultMap>
- <select id="getUserApplyOrders" resultMap="applyOrderAndDetail" parameterType="map">
- SELECT spo.*,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
- detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
- g.id_ goods_id, g.name_ goods_name,g.complement_goods_id_list_ complementGoodsIdList
- FROM student_payment_order spo
- LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
- LEFT JOIN goods g on FIND_IN_SET(g.id_,spod.goods_id_list_)
- WHERE spo.user_id_ = #{userId} AND spo.type_='APPLY' AND spo.music_group_id_=#{musicGroupId}
- ORDER BY spo.id_ desc
- </select>
- <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
- SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
- </select>
- <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
- </select>
- <select id="getMoneyInMusicApply" resultMap="Mapper">
- 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_
- FROM student_payment_order spo
- LEFT JOIN student_registration sr ON sr.user_id_ = spo.user_id_
- LEFT JOIN (SELECT id_,music_group_id_,original_order_id_,CASE WHEN goods_margin_ < 0 THEN goods_margin_ ELSE sell_amount_ END goods_margin_
- FROM subject_change WHERE id_ in
- (SELECT max(sc.id_) id_ from subject_change sc WHERE sc.status_ = 2 GROUP BY music_group_id_,student_id_ ORDER BY id_ DESC)
- ) a on spo.music_group_id_ = a.music_group_id_ and spo.id_ = a.original_order_id_
- WHERE spo.music_group_id_ IN
- <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
- #{musicGroupId}
- </foreach>
- AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND sr.music_group_id_ = spo.music_group_id_ AND sr.music_group_status_ = 'NORMAL'
- GROUP BY spo.music_group_id_
- </select>
- <select id="getOrderIdByMusical" resultType="java.lang.Integer">
- SELECT DISTINCT spo.id_ FROM student_payment_order spo
- LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
- WHERE spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spo.music_group_id_ = #{musicGroupId}
- AND spo.user_id_ = #{studentId} AND spod.type_ = 'MUSICAL'
- </select>
- <select id="queryStudentCourseAmountMap" resultType="java.util.Map">
- SELECT user_id_ 'key',expect_amount_ - coupon_remit_fee_ 'value' FROM student_payment_order
- WHERE status_ = 'SUCCESS' AND music_group_id_ = #{vipGroupId}
- GROUP BY user_id_
- </select>
- <select id="queryStudentDoubleElevenOrder" resultType="java.lang.String">
- SELECT GROUP_CONCAT(activity_id_) FROM student_payment_order
- WHERE type_ = 'SMALL_CLASS_TO_BUY' AND group_type_ = 'ACTIVITY' AND memo_ = '2022双十一活动购买' AND status_ = 'SUCCESS' AND user_id_ = #{userId}
- </select>
- <select id="findByCalenderId" resultMap="StudentPaymentOrder">
- SELECT * FROM student_payment_order WHERE calender_id_ = #{calenderId} AND status_ = 'SUCCESS' AND user_id_ = #{userId}
- </select>
- <resultMap type="com.ym.mec.biz.dal.vo.StudentPaymentOrderVo" id="QueryOrderDetail">
- <result column="orderNo" property="orderNo"/>
- <result column="memo_" property="memo"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="orderType" property="orderType"/>
- <result column="orderTypeCode" property="orderTypeCode"/>
- <result column="totalAmount" property="totalAmount"/>
- <result column="actualAmount" property="actualAmount"/>
- <result column="balanceAmount" property="balanceAmount"/>
- <result column="actualAmount" property="actualAmount"/>
- <result column="createTime" property="createTime"/>
- <result column="payTime" property="payTime"/>
- <result column="transNo" property="transNo"/>
- <result column="totalRemitFee" property="totalRemitFee"/>
- <collection property="list" ofType="com.ym.mec.biz.dal.vo.StudentPaymentOrderVo$StudentPaymentDetailVo">
- <result column="goodsName" property="goodsName"/>
- <result column="price" property="price"/>
- </collection>
- </resultMap>
- <select id="queryStudentOrderPage" resultMap="QueryOrderDetail">
- select
- a.order_no_ as orderNo,
- a.status_ ,a.memo_,
- a.type_ as orderType,
- a.type_ as orderTypeCode,
- ifnull(a.actual_amount_, 0) + ifnull(a.balance_payment_amount_, 0) as totalAmount,
- a.create_time_ as createTime
- from student_payment_order as a
- where create_time_ >= #{param.startDate}
- and create_time_ <![CDATA[ < ]]> #{param.endDate}
- and user_id_ = #{param.userId}
- <if test="param.status != null">
- and status_ = #{param.status}
- </if>
- </select>
- <select id="queryOrderDetail" resultMap="QueryOrderDetail">
- select
- a.order_no_ as orderNo,
- a.status_ ,a.memo_,
- a.type_ as orderType,
- ifnull(a.actual_amount_, 0) + ifnull(a.balance_payment_amount_, 0) + ifnull(a.remit_fee_, 0) +
- ifnull(a.coupon_remit_fee_, 0) as totalAmount,
- a.actual_amount_ as actualAmount,
- a.balance_payment_amount_ as balanceAmount,
- ifnull(a.remit_fee_,0) + ifnull(a.coupon_remit_fee_,0) as totalRemitFee,
- a.create_time_ as createTime,
- a.pay_time_ as payTime,
- a.trans_no_ as transNo,
- b.type_ as goodsName,
- ifnull(b.price_, 0) as price
- from student_payment_order as a
- left join
- student_payment_order_detail as b on a.id_ = b.payment_order_id_
- where a.order_no_ = #{orderNo}
- </select>
- <select id="getStudentMusicOrderNum" resultType="int">
- SELECT COUNT(0) FROM student_payment_order spo
- WHERE spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId} AND group_type_ = 'MUSIC' AND status_ = 'SUCCESS' AND spo.id_ < #{orderId}
- </select>
- <select id="getMemberIngOrder" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
- SELECT *
- FROM student_payment_order
- WHERE music_group_id_ IS NULL
- AND type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- LIMIT 1
- </select>
- <select id="countByActivityIds" resultType="java.lang.Integer">
- SELECT COUNT(0) FROM student_payment_order WHERE user_id_ = #{userId} AND status_ = 'SUCCESS' AND activity_id_ IN
- <foreach collection="activityIds" item="activityId" open="(" close=")" separator=",">
- #{activityId}
- </foreach>
- </select>
- <select id="groupSellOrder" resultType="com.ym.mec.biz.dal.dto.BaseMapDto">
- SELECT so.organ_id_ 'key',SUM(so.actual_amount_) 'value'
- FROM sell_order so
- where so.tenant_id_ = 1 AND DATE_FORMAT(so.delivery_time_,'%Y-%m') = #{month}
- group by so.organ_id_
- </select>
- <select id="queryVipQuitOrder" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
- SELECT spo.* FROM student_payment_order spo
- 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_
- WHERE cgsm.music_group_id_ = #{vipGroupId} AND cgsm.status_ != 'QUIT'
- AND spo.type_ IN ('LIVE_GROUP_BUY','SMALL_CLASS_TO_BUY')
- AND spo.status_ = 'SUCCESS' AND spo.class_group_id_ = cgsm.class_group_id_ and spo.music_group_id_ = cgsm.music_group_id_
- </select>
- <select id="saleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
- SELECT
- SUM(actual_amount_) AS 'actualAmount'
- , SUM(balance_payment_amount_) AS 'balancePaymentAmount'
- , COUNT(distinct user_id_) AS 'userPurchaseNumber'
- FROM student_payment_order
- <where>
- status_ = 'SUCCESS'
- <if test="param.tenantId != null">
- AND tenant_id_ =#{param.tenantId}
- </if>
- <if test="param.organId != null">
- AND find_in_set(organ_id_,#{param.organId})
- </if>
- <if test="param.groupType != null">
- AND group_type_ =#{param.groupType}
- </if>
- <if test="param.type != null">
- AND type_ =#{param.type}
- </if>
- <if test="param.activityId != null">
- AND find_in_set(activity_id_,#{param.activityId})
- </if>
- <if test="param.musicGroupId != null">
- AND find_in_set(music_group_id_,#{param.musicGroupId})
- </if>
- </where>
- </select>
- <select id="musicalSaleStatics" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
- SELECT
- SUM(t.actual_amount_) AS 'actualAmount'
- , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
- , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
- FROM student_payment_order t
- LEFT join sell_order so on t.order_no_ = so.order_no_
- <where>
- t.status_ = 'SUCCESS'
- AND find_in_set(so.goods_id_,#{param.goodId})
- AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
- <if test="param.tenantId != null">
- AND t.tenant_id_ =#{param.tenantId}
- </if>
- <if test="param.organId != null">
- AND find_in_set(t.organ_id_,#{param.organId})
- </if>
- </where>
- </select>
- <select id="saleStaticsByOrgId" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleAmountAndUser">
- SELECT
- t.organ_id_ AS organId
- , SUM(t.actual_amount_) AS 'actualAmount'
- , SUM(t.balance_payment_amount_) AS 'balancePaymentAmount'
- , COUNT(distinct t.user_id_) AS 'userPurchaseNumber'
- , group_concat(distinct t.user_id_) AS 'userIds'
- FROM student_payment_order t
- <if test="param.goodId != null">
- LEFT JOIN sell_order so on t.order_no_ = so.order_no_
- </if>
- <where>
- t.status_ = 'SUCCESS'
- <if test="param.tenantId != null">
- AND t.tenant_id_ =#{param.tenantId}
- </if>
- <if test="param.organId != null">
- AND find_in_set(t.organ_id_,#{param.organId})
- </if>
- <if test="param.groupType!= null">
- AND t.group_type_ =#{param.groupType}
- </if>
- <if test="param.type!= null">
- AND t.type_ =#{param.type}
- </if>
- <if test="param.activityId != null">
- AND find_in_set(t.activity_id_,#{param.activityId})
- </if>
- <if test="param.musicGroupId != null">
- AND find_in_set(t.music_group_id_,#{param.musicGroupId})
- </if>
- <if test="param.goodId != null">
- AND find_in_set(so.goods_id_,#{param.goodId})
- </if>
- <if test="param.startPayTime != null and param.endPayTime != null">
- AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
- </if>
- </where>
- GROUP BY t.organ_id_
- </select>
- <select id="queryPaymentStudentByPage" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleStaticsStudent">
- select t.user_id_ as userId
- , t.organ_id_ as organId
- , su.username_ as userName
- , su.phone_ as phone
- , t.pay_time_ as payTime
- , (t.actual_amount_ + t.balance_payment_amount_) as payAmount
- from student_payment_order t
- left join sys_user su on t.user_id_ = su.id_
- <if test="goodId != null">
- LEFT JOIN sell_order so on t.order_no_ = so.order_no_
- </if>
- <where>
- t.status_='SUCCESS'
- <if test="tenantId != null">
- AND t.tenant_id_ =#{tenantId}
- </if>
- <if test="organId != null">
- AND find_in_set(t.organ_id_,#{organId})
- </if>
- <if test="organId != null">
- AND t.organ_id_ = #{organId}
- </if>
- <if test="userName != null and userName.trim() !=''">
- AND su.username_ like concat('%',#{userName},'%')
- </if>
- <if test="groupType != null">
- AND group_type_ =#{groupType}
- </if>
- <if test="type != null">
- AND type_ =#{type}
- </if>
- <if test="activityId != null">
- AND find_in_set(activity_id_,#{activityId})
- </if>
- <if test="musicGroupId != null">
- AND find_in_set(music_group_id_,#{musicGroupId})
- </if>
- <if test="goodId != null">
- AND find_in_set(so.goods_id_,#{goodId})
- </if>
- <if test="startPayTime != null and endPayTime != null">
- AND t.pay_time_ between #{startPayTime} and #{endPayTime}
- </if>
- </where>
- <if test=" orderBy != null and asc == 0">
- order by ${orderBy} desc
- </if>
- <if test=" orderBy != null and asc == 1">
- order by ${orderBy} asc
- </if>
- <include refid="global.limit"/>
- </select>
- <select id="queryPaymentStudentCount" resultType="java.lang.Integer">
- select count(1) from student_payment_order t
- left join sys_user su on t.user_id_ = su.id_
- <if test="goodId != null">
- LEFT JOIN sell_order so on t.order_no_ = so.order_no_
- </if>
- <where>
- t.status_='SUCCESS'
- <if test="tenantId != null">
- AND t.tenant_id_ =#{tenantId}
- </if>
- <if test="organId != null">
- AND find_in_set(t.organ_id_,#{organId})
- </if>
- <if test="userName != null and userName.trim() !=''">
- AND su.username_ like concat('%',#{userName},'%')
- </if>
- <if test="groupType != null">
- AND group_type_ =#{groupType}
- </if>
- <if test="type != null">
- AND type_ =#{type}
- </if>
- <if test="activityId != null">
- AND find_in_set(activity_id_,#{activityId})
- </if>
- <if test="musicGroupId != null">
- AND find_in_set(music_group_id_,#{musicGroupId})
- </if>
- <if test="goodId != null">
- AND find_in_set(so.goods_id_,#{goodId})
- </if>
- <if test="startPayTime != null and endPayTime != null">
- AND t.pay_time_ between #{startPayTime} and #{endPayTime}
- </if>
- </where>
- </select>
- </mapper>
|