12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373 |
- <?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.caimei.modules.order.dao.CmDiscernReceiptDao">
- <sql id="cmDiscernReceiptColumns">
- a.id AS "id",
- a.payWay AS "payWay",
- a.payType AS "payType",
- a.receiptType AS "receiptType",
- a.receiptStatus AS "receiptStatus",
- a.smsContent AS "smsContent",
- a.smsMd5Code AS "smsMd5Code",
- a.receiptAmount AS "receiptAmount",
- a.handlingFee AS "handlingFee",
- a.confirmType AS "confirmType",
- a.confirmUserPermissionID AS "confirmUserPermissionID",
- a.reviewUserPermissionID AS "reviewUserPermissionID",
- a.cancelUserPermissionID AS "cancelUserPermissionID",
- a.transactionNum AS "transactionNum",
- a.bankID AS "bankID",
- a.bankCode AS "bankCode",
- a.kuaiQianPayTypeID AS "kuaiQianPayTypeID",
- a.kuaiQianPayerID AS "kuaiQianPayerID",
- a.rePayFlag AS "rePayFlag",
- a.actualAmount AS "actualAmount",
- a.formData AS "formData",
- a.problem AS "problem",
- a.noOrderReason AS "noOrderReason",
- a.reviewReason AS "reviewReason",
- a.cancelReason AS "cancelReason",
- a.receiptDate AS "receiptDate",
- a.confirmDate AS "confirmDate",
- a.reviewDate AS "reviewDate",
- a.cancelDate AS "cancelDate",
- a.updateDate AS "updateDate",
- a.delFlag AS "delFlag",
- a.newReceiptType
- </sql>
- <sql id="cmDiscernReceiptJoins">
- </sql>
- <select id="get" resultType="CmDiscernReceipt">
- SELECT
- <include refid="cmDiscernReceiptColumns"/>
- FROM cm_discern_receipt a
- <include refid="cmDiscernReceiptJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="getAssociateAmount" resultType="double">
- select IFNULL(sum(cdr.receiptAmount),0) From cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr on cdr.id = cror.receiptID
- where cror.orderID = #{orderID} and cror.relationType = '2' and cdr.delFlag = 0
- and cror.delFlag = 0 and cdr.receiptStatus in (3) and payWay != '3';
- </select>
- <select id="getShopAssociateAmount" resultType="double">
- select IFNULL(sum(cdr.receiptAmount),0) From cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr on cdr.id = cror.receiptID
- where cror.shopOrderId = #{shopOrderId} and cror.relationType = '2' and cdr.delFlag = 0
- and cror.delFlag = 0 and cdr.receiptStatus in (3) and payWay != '3';
- </select>
- <select id="getReturnBalanceAmount" resultType="double">
- select IFNULL(sum(amount),0) from cm_user_balance_record where balanceType = 2 and receiptId = #{receiptId} and delFlag = 0;
- </select>
- <select id="orderlist" resultType="CmDiscernReceipt">
- SELECT
- u.userID,
- csp.id AS receiptID,
- cms.orderID,
- cms.shopOrderID,
- cms.shopOrderNo,
- cms.orderType as orderType,
- s.name AS shopName,
- cms.productAmount,
- cmo.orderNo,
- u.userName,
- u.name AS jgName,
- cmo.confirmTime,
- cms.receiptAmount,
- cms.needPayAmount
- FROM cm_shop_order cms
- LEFT JOIN shop s ON s.shopID = cms.shopID
- LEFT JOIN cm_order cmo ON cmo.orderID = cms.orderID
- LEFT JOIN `user` u ON u.userID = cms.userID
- LEFT JOIN cm_discern_receipt csp ON csp.shopOrderID = cms.shopOrderID
- where csp.id=#{id}
- </select>
- <select id="findList" resultType="CmDiscernReceipt">
- SELECT * from ((SELECT
- <include refid="cmDiscernReceiptColumns"/>,
- cso.orderId AS orderID,
- cso.shopOrderNo as shopOrderNo,
- cso.shopOrderId as shopOrderId,
- cof.bankAccount AS bankNameType,
- s.checkMan,
- s.name AS shopName,
- u.userName AS "userName",
- u.name AS "name",
- IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",
- cr.organizeID AS organizeID
- FROM cm_discern_receipt a
- LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'
- LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
- LEFT JOIN cm_shop_order cso ON cso.shopOrderId = crr.orderId
- LEFT JOIN cm_order cr ON cr.orderId = cso.orderId
- LEFT JOIN shop s ON s.shopID = cso.shopID
- left join user u on u.userID = cr.userID
- LEFT JOIN club c ON cr.userId = c.userId
- LEFT JOIN cm_offline_collection cof ON a.payType = cof.type
- <where>
- crr.relationType = 1
- <if test="id != null and id != '' and id != 0 ">
- AND a.id = #{id}
- </if>
- <if test="organizeID != null and organizeID != 9999 ">
- AND cr.organizeID = #{organizeID}
- </if>
- <if test="organizeID == 9999 ">
- AND cr.orderType = 2
- </if>
- <if test="startTime != null and startTime != ''">
- AND (a.receiptDate > #{startTime} OR a.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (a.receiptDate < #{endTime} OR a.receiptDate = #{endTime})
- </if>
- <if test="payWay != null and payWay != ''">
- AND a.payWay = #{payWay}
- </if>
- <if test="payType != null and payType != ''">
- AND a.payType = #{payType}
- </if>
- <if test="receiptType != null and receiptType != ''">
- <if test="receiptType==2 and newReceiptType==3">
- and (a.receiptType = 9)
- or a.receiptType = #{receiptType}
- </if>
- <if test="receiptType!=2">
- AND a.receiptType = #{receiptType}
- </if>
- AND a.receiptType = #{receiptType}
- </if>
- <if test="newReceiptType !=null">
- <if test="newReceiptType==3">
- and a.newReceiptType =3
- </if>
- <if test="newReceiptType != 3">
- and a.newReceiptType=#{newReceiptType}
- </if>
- </if>
- <if test="receiptStatus != null and receiptStatus != ''">
- AND a.receiptStatus = #{receiptStatus}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND (cr.orderNo like concat('%',#{orderNo},'%'))
- </if>
- <if test="orderID != null and orderID != ''">
- AND (cr.orderID = #{orderID} )
- </if>
- <if test="shopOrderId != null and shopOrderId != ''">
- AND (cso.shopOrderId = #{shopOrderId} )
- </if>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- AND (cso.shopOrderNo = #{shopOrderNo} )
- </if>
- <if test="userName != null and userName != ''">
- AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- and (case when crr.relationType = '1' then
- cso_cr.receiptStatus
- else
- cr.receiptStatus
- end) = #{receiptProgress}
- </if>
- <if test="receiptOrderType != null and receiptOrderType != ''">
- and (case when crr.relationType = '1' then
- cso.orderType
- else
- cr.orderType
- end) = #{receiptOrderType}
- </if>
- <if test="associationNum != null and associationNum != ''">
- <if test="associationNum == 1">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1
- </if>
- <if test="associationNum == 2">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')
- <![CDATA[ > ]]> 1
- </if>
- </if>
- <if test="paYee !=null and paYee != ''">
- <if test="paYee == '采美'">
- and a.payWay = 3
- OR a.payWay = 2
- AND a.newReceiptType != 3 AND a.payWay = 2
- </if>
- <if test="payWay==1">
- and s.name=#{paYee}
- </if>
- </if>
- and a.delFlag = '0'
- </where>
- group by a.id
- )
- union
- (
- SELECT
- <include refid="cmDiscernReceiptColumns"/>,
- cso.orderId AS orderID,
- cso.shopOrderNo as shopOrderNo,
- cso.shopOrderId as shopOrderId,
- cof.bankAccount AS bankNameType,
- s.checkMan,
- s.name AS shopName,
- u.userName AS "userName",
- u.name AS "name",
- IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",
- cr.organizeID AS organizeID
- FROM cm_discern_receipt a
- LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'
- LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
- LEFT JOIN cm_shop_order cso ON cso.orderId = crr.orderId
- LEFT JOIN cm_order cr ON cr.orderId = cso.orderId
- LEFT JOIN shop s ON s.shopID = cso.shopID
- left join user u on u.userID = cr.userID
- LEFT JOIN club c ON cr.userId = c.userId
- LEFT JOIN cm_offline_collection cof ON a.payType = cof.type
- <where>
- crr.relationType != 1
- <if test="id != null and id != '' and id != 0 ">
- AND a.id = #{id}
- </if>
- <if test="organizeID != null and organizeID != 9999 ">
- AND cr.organizeID = #{organizeID}
- </if>
- <if test="organizeID == 9999 ">
- AND cr.orderType = 2
- </if>
- <if test="startTime != null and startTime != ''">
- AND (a.receiptDate > #{startTime} OR a.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (a.receiptDate < #{endTime} OR a.receiptDate = #{endTime})
- </if>
- <if test="payWay != null and payWay != ''">
- AND a.payWay = #{payWay}
- </if>
- <if test="payType != null and payType != ''">
- AND a.payType = #{payType}
- </if>
- <if test="receiptType != null and receiptType != ''">
- <if test="receiptType==2 and newReceiptType==3">
- and (a.receiptType = 9)
- or a.receiptType = #{receiptType}
- </if>
- <if test="receiptType!=2">
- AND a.receiptType = #{receiptType}
- </if>
- AND a.receiptType = #{receiptType}
- </if>
- <if test="newReceiptType !=null">
- <if test="newReceiptType==3">
- and a.newReceiptType =3
- </if>
- <if test="newReceiptType != 3">
- and a.newReceiptType=#{newReceiptType}
- </if>
- </if>
- <if test="receiptStatus != null and receiptStatus != ''">
- AND a.receiptStatus = #{receiptStatus}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND ((cr.orderNo like concat('%',#{orderNo},'%')) OR (cso.shopOrderNo like concat('%',#{orderNo},'%')))
- </if>
- <if test="orderID != null and orderID != ''">
- AND (cr.orderID = #{orderID} )
- </if>
- <if test="shopOrderId != null and shopOrderId != ''">
- AND (cso.shopOrderId = #{shopOrderId} )
- </if>
- <if test="userName != null and userName != ''">
- AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- and (case when crr.relationType = '1' then
- cso_cr.receiptStatus
- else
- cr.receiptStatus
- end) = #{receiptProgress}
- </if>
- <if test="receiptOrderType != null and receiptOrderType != ''">
- and (case when crr.relationType = '1' then
- cso.orderType
- else
- cr.orderType
- end) = #{receiptOrderType}
- </if>
- <if test="associationNum != null and associationNum != ''">
- <if test="associationNum == 1">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1
- </if>
- <if test="associationNum == 2">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')
- <![CDATA[ > ]]> 1
- </if>
- </if>
- <if test="paYee !=null and paYee != ''">
- <if test="paYee == '采美'">
- and a.payWay = 3
- OR a.payWay = 2
- AND a.newReceiptType != 3 AND a.payWay = 2
- </if>
- <if test="payWay==1">
- and s.name=#{paYee}
- </if>
- </if>
- and a.delFlag = '0'
- </where>
- group by a.id
- )
- union
- (
- SELECT
- <include refid="cmDiscernReceiptColumns"/>,
- cso.orderId AS orderID,
- cso.shopOrderNo as shopOrderNo,
- cso.shopOrderId as shopOrderId,
- cof.bankAccount AS bankNameType,
- s.checkMan,
- s.name AS shopName,
- u.userName AS "userName",
- u.name AS "name",
- IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",
- cr.organizeID AS organizeID
- FROM cm_discern_receipt a
- LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'
- LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
- LEFT JOIN cm_shop_order cso ON cso.orderId = crr.orderId
- LEFT JOIN cm_order cr ON cr.orderId = cso.orderId
- LEFT JOIN shop s ON s.shopID = cso.shopID
- left join user u on u.userID = cr.userID
- LEFT JOIN club c ON cr.userId = c.userId
- LEFT JOIN cm_offline_collection cof ON a.payType = cof.type
- <where>
- crr.relationType is null
- <if test="id != null and id != '' and id != 0 ">
- AND a.id = #{id}
- </if>
- <if test="organizeID != null and organizeID != 9999 ">
- AND cr.organizeID = #{organizeID}
- </if>
- <if test="organizeID == 9999 ">
- AND cr.orderType = 2
- </if>
- <if test="startTime != null and startTime != ''">
- AND (a.receiptDate > #{startTime} OR a.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (a.receiptDate < #{endTime} OR a.receiptDate = #{endTime})
- </if>
- <if test="payWay != null and payWay != ''">
- AND a.payWay = #{payWay}
- </if>
- <if test="payType != null and payType != ''">
- AND a.payType = #{payType}
- </if>
- <if test="receiptType != null and receiptType != ''">
- <if test="receiptType==2 and newReceiptType==3">
- and (a.receiptType = 9)
- or a.receiptType = #{receiptType}
- </if>
- <if test="receiptType!=2">
- AND a.receiptType = #{receiptType}
- </if>
- AND a.receiptType = #{receiptType}
- </if>
- <if test="newReceiptType !=null">
- <if test="newReceiptType==3">
- and a.newReceiptType =3
- </if>
- <if test="newReceiptType != 3">
- and a.newReceiptType=#{newReceiptType}
- </if>
- </if>
- <if test="receiptStatus != null and receiptStatus != ''">
- AND a.receiptStatus = #{receiptStatus}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND ((cr.orderNo like concat('%',#{orderNo},'%')) OR (cso.shopOrderNo like concat('%',#{orderNo},'%')))
- </if>
- <if test="orderID != null and orderID != ''">
- AND (cr.orderID = #{orderID} )
- </if>
- <if test="shopOrderId != null and shopOrderId != ''">
- AND (cso.shopOrderId = #{shopOrderId} )
- </if>
- <if test="userName != null and userName != ''">
- AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- and (case when crr.relationType = '1' then
- cso_cr.receiptStatus
- else
- cr.receiptStatus
- end) = #{receiptProgress}
- </if>
- <if test="receiptOrderType != null and receiptOrderType != ''">
- and (case when crr.relationType = '1' then
- cso.orderType
- else
- cr.orderType
- end) = #{receiptOrderType}
- </if>
- <if test="associationNum != null and associationNum != ''">
- <if test="associationNum == 1">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1
- </if>
- <if test="associationNum == 2">
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')
- <![CDATA[ > ]]> 1
- </if>
- </if>
- <if test="paYee !=null and paYee != ''">
- <if test="paYee == '采美'">
- and a.payWay = 3
- OR a.payWay = 2
- AND a.newReceiptType != 3 AND a.payWay = 2
- </if>
- <if test="payWay==1">
- and s.name=#{paYee}
- </if>
- </if>
- and a.delFlag = '0'
- </where>
- group by a.id
- )
- ) as a order by a.id desc
- </select>
- <select id="findAllList" resultType="CmDiscernReceipt">
- SELECT
- <include refid="cmDiscernReceiptColumns"/>
- FROM cm_discern_receipt a
- <include refid="cmDiscernReceiptJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="exportTest" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- r.orderID,
- (select group_concat(distinct p.name) from product p left join cm_order_product cop on p.productID = cop.productID where cop.orderID = o.orderID group by cop.orderID) as productNames,
- IF(u.userIdentity = 2,u.name,u.userName) AS userName,
- d.receiptDate,
- d.payType,
- IFNULL(r.associateAmount,0) as associateAmount,
- cof.bankAccount AS bankNameType,
- d.receiptType
- FROM
- cm_receipt_order_relation r
- LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
- LEFT JOIN cm_order o ON r.orderID = o.orderID
- LEFT JOIN USER u ON u.userID = o.userID
- LEFT JOIN cm_offline_collection cof ON d.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ >= ]]> #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ <= ]]> #{endTime})
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- AND o.receiptStatus = #{receiptProgress}
- </if>
- AND d.receiptType = 1
- AND d.receiptStatus = 3
- AND d.delFlag = '0'
- AND r.delFlag = '0'
- </where>
- ORDER BY
- d.receiptDate DESC;
- </select>
- <select id="exportRebate" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- so.orderID,
- (select group_concat(distinct p.name) from product p left join cm_order_product cop on p.productID = cop.productID where cop.orderID = so.orderID group by cop.orderID) as productNames,
- IF(u.userIdentity = 2,u.name,u.userName) AS userName,
- d.receiptDate,
- d.payType,
- IFNULL(d.receiptAmount,0) as associateAmount,
- cof.bankAccount AS bankNameType,
- d.receiptType
- FROM
- cm_receipt_order_relation r
- LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
- LEFT JOIN cm_shop_order so ON r.orderID = so.shopOrderID
- LEFT JOIN USER u ON u.userID = so.userID
- LEFT JOIN cm_offline_collection cof ON d.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ >= ]]> #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ <= ]]> #{endTime})
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- AND o.receiptStatus = #{receiptProgress}
- </if>
- AND d.receiptStatus = 2
- AND d.delFlag = '0'
- AND r.delFlag = '0'
- AND r.relationType='1'
- </where>
- ORDER BY
- d.receiptDate DESC;
- </select>
- <!--订单已付款又进行交易全退,此处需要结合订单状态导出,单纯的进账会不明确-->
- <select id="exportReceiptPay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- DISTINCT r.orderID
- FROM
- cm_receipt_order_relation r
- LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
- LEFT JOIN cm_order o ON r.orderID = o.orderID
- LEFT JOIN USER u ON u.userID = o.userID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- AND o.receiptStatus = #{receiptProgress}
- </if>
- AND d.receiptStatus = 3
- AND d.delFlag = '0'
- AND r.delFlag = '0'
- </where>
- ORDER BY
- d.receiptDate DESC;
- </select>
- <select id="exportOnlyBalancePay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- DISTINCT o.orderID
- FROM
- cm_order o
- <where>
- <if test="startTime != null and startTime != ''">
- AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- AND o.receiptStatus = #{receiptProgress}
- </if>
- AND o.balancePayFee > 0
- AND o.delFlag = '0'
- </where>
- HAVING (SELECT count(a.id) as num from cm_receipt_order_relation a left JOIN cm_discern_receipt d on a.receiptID
- = d.id where a.orderID=o.orderID and d.receiptStatus = 3 and d.delFlag = '0') = 0
- ORDER BY
- o.orderTime DESC;
- </select>
- <select id="exportPay" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- ps.id AS orderID,
- u.`name` AS userName,
- r.payTime AS receiptDate,
- ps.payType AS payType,
- ps.totalAmount AS associateAmount,
- GROUP_CONCAT(CONCAT(ss.shopOrderID , '/' ,ss.payedShopAmount , '/' , ss.`userName` )) AS shopOrderID
- FROM
- cm_pay_shop ps
- LEFT JOIN cm_pay_shop_record r ON ps.id = r.payShopID
- LEFT JOIN (select so.shopOrderID,so.payedShopAmount,o.userName from cm_shop_order so LEFT JOIN user o on
- o.userID = so.userID) as ss on ss.shopOrderID = r.shopOrderID
- LEFT JOIN shop u ON r.shopID = u.shopID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (r.payTime <![CDATA[ > ]]> #{startTime} OR r.payTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (r.payTime <![CDATA[ < ]]> #{endTime} OR r.payTime = #{endTime})
- </if>
- AND r. STATUS = 1
- AND ps. STATUS = 1
- </where>
- GROUP BY
- ps.id
- ORDER BY
- r.payTime DESC;
- </select>
- <select id="exportPayData" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT DISTINCT
- o.orderID
- FROM
- cm_order o
- LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
- LEFT JOIN cm_pay_shop_record psr ON psr.shopOrderID = so.shopOrderID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (psr.payTime <![CDATA[ > ]]> #{startTime} OR psr.payTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (psr.payTime <![CDATA[ < ]]> #{endTime} OR psr.payTime = #{endTime})
- </if>
- <if test="receiptProgress != null and receiptProgress != ''">
- AND o.payStatus = #{receiptProgress}
- </if>
- AND psr. STATUS = 1
- </where>
- ORDER BY
- psr.payTime DESC
- </select>
- <select id="exportOrderDate" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT DISTINCT
- o.orderID,o.status
- FROM
- cm_order o
- <where>
- <if test="startTime != null and startTime != ''">
- AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
- </if>
- AND o.delFlag='0'
- AND o.status!='6'
- AND o.orderID NOT IN (
- SELECT so.orderID
- FROM cm_shop_order so
- LEFT JOIN cm_receipt_order_relation ror ON ror.orderID = so.shopOrderID
- LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
- WHERE ror.relationType = '1'
- AND dr.receiptStatus = '2'
- AND so.delFlag = '0'
- GROUP BY so.orderID
- )
- </where>
- </select>
- <select id="getListOrder" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT o.orderID, o.status, SUM(dr.receiptAmount) AS receiptAmount, ror.relationType
- FROM cm_order o
- LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
- LEFT JOIN cm_receipt_order_relation ror ON so.shopOrderID = ror.`orderID`
- LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (o.orderTime <![CDATA[ > ]]> #{startTime} OR o.orderTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (o.orderTime <![CDATA[ < ]]> #{endTime} OR o.orderTime = #{endTime})
- </if>
- AND ror.`relationType` = '1'
- AND dr.receiptStatus = '2'
- AND o.delFlag='0'
- </where>
- GROUP BY o.orderID
- </select>
- <select id="exportPayment" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT so.orderID, ror.relationType, SUM(dr.receiptAmount) AS receiptAmount
- FROM cm_shop_order so
- LEFT JOIN cm_receipt_order_relation ror ON ror.orderID = so.shopOrderID
- LEFT JOIN cm_discern_receipt dr ON dr.id = ror.receiptID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (dr.receiptDate <![CDATA[ > ]]> #{startTime} OR dr.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (dr.receiptDate <![CDATA[ < ]]> #{endTime} OR dr.receiptDate = #{endTime})
- </if>
- AND ror.relationType = '1'
- AND dr.receiptStatus = '2'
- AND so.delFlag = '0'
- </where>
- GROUP BY so.orderID
- </select>
- <insert id="insert" parameterType="CmDiscernReceipt" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_discern_receipt(
- payWay,
- payType,
- receiptType,
- receiptStatus,
- smsContent,
- smsMd5Code,
- receiptAmount,
- handlingFee,
- confirmType,
- confirmUserPermissionID,
- reviewUserPermissionID,
- cancelUserPermissionID,
- transactionNum,
- bankID,
- bankCode,
- kuaiQianPayTypeID,
- kuaiQianPayerID,
- rePayFlag,
- actualAmount,
- formData,
- problem,
- noOrderReason,
- reviewReason,
- cancelReason,
- receiptDate,
- confirmDate,
- reviewDate,
- cancelDate,
- updateDate,
- delFlag
- ) VALUES (
- #{payWay},
- #{payType},
- #{receiptType},
- #{receiptStatus},
- #{smsContent},
- #{smsMd5Code},
- #{receiptAmount},
- #{handlingFee},
- #{confirmType},
- #{confirmUserPermissionID},
- #{reviewUserPermissionID},
- #{cancelUserPermissionID},
- #{transactionNum},
- #{bankID},
- #{bankCode},
- #{kuaiQianPayTypeID},
- #{kuaiQianPayerID},
- #{rePayFlag},
- #{actualAmount},
- #{formData},
- #{problem},
- #{noOrderReason},
- #{reviewReason},
- #{cancelReason},
- #{receiptDate},
- #{confirmDate},
- #{reviewDate},
- #{cancelDate},
- #{cancelDate},
- #{delFlag}
- )
- </insert>
- <update id="update">
- UPDATE cm_discern_receipt SET
- payWay = #{payWay},
- payType = #{payType},
- receiptType = #{receiptType},
- receiptStatus = #{receiptStatus},
- smsContent = #{smsContent},
- smsMd5Code = #{smsMd5Code},
- receiptAmount = #{receiptAmount},
- handlingFee = #{handlingFee},
- confirmType = #{confirmType},
- confirmUserPermissionID = #{confirmUserPermissionID},
- reviewUserPermissionID = #{reviewUserPermissionID},
- cancelUserPermissionID = #{cancelUserPermissionID},
- transactionNum = #{transactionNum},
- bankID = #{bankID},
- bankCode = #{bankCode},
- kuaiQianPayTypeID = #{kuaiQianPayTypeID},
- kuaiQianPayerID = #{kuaiQianPayerID},
- rePayFlag = #{rePayFlag},
- actualAmount = #{actualAmount},
- formData = #{formData},
- problem = #{problem},
- noOrderReason = #{noOrderReason},
- reviewReason = #{reviewReason},
- cancelReason = #{cancelReason},
- receiptDate = #{receiptDate},
- confirmDate = #{confirmDate},
- reviewDate = #{reviewDate},
- cancelDate = #{cancelDate},
- updateDate = DATE_FORMAT(#{updateDate},'%Y-%m-%d %H:%i:%s'),
- balanceAccountsRemark = #{balanceAccountsRemark},
- delFlag = #{delFlag}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM cm_discern_receipt
- WHERE id = #{id}
- </delete>
- <select id="getShopOrderIDStr" parameterType="string" resultType="map">
- SELECT
- cso.shopOrderId,
- cso.shopOrderNo,
- cso.orderId AS orderID,
- (case when cror.relationType = '1'
- then (select b.orderType from cm_shop_order b where cso.shopOrderID = b.shopOrderID)
- else (select c.orderType from cm_order c where cso.orderID = c.orderID)
- end) AS orderType
- FROM cm_receipt_order_relation cror
- LEFT JOIN cm_shop_order cso ON cror.shopOrderId = cso.shopOrderID
- LEFT JOIN cm_order co ON cso.orderID = co.orderID
- LEFT JOIN cm_order cou ON cror.orderID = cou.orderID
- WHERE cror.relationType != '1' and cror.receiptID = #{id} AND cror.delFlag = '0'
- union
- SELECT
- cso.shopOrderId,
- cso.shopOrderNo,
- cso.orderId AS orderID,
- (CASE WHEN cror.relationType = '1'
- THEN (SELECT b.orderType FROM cm_shop_order b WHERE cso.shopOrderID = b.shopOrderID)
- ELSE (SELECT c.orderType FROM cm_order c WHERE cso.orderID = c.orderID)
- END) AS orderType
- FROM cm_receipt_order_relation cror
- LEFT JOIN cm_shop_order cso ON cror.orderID = cso.shopOrderID
- LEFT JOIN cm_order cou ON cror.orderID = cou.orderID
- WHERE cror.relationType = '1' AND cror.receiptID = #{id} AND cror.delFlag = '0'
- </select>
- <select id="getOrderIDStr" parameterType="string" resultType="map">
- -- relationType值为1是为子订单ID,为2时为主订单ID)
- select
- cso.shopOrderId,
- cso.shopOrderNo,
- (case when cror.relationType = '1'
- then concat('子订单',cso.shopOrderNo,'(', cso.shopOrderID,')')
- else concat(cou.orderNo,'(', cou.orderID,')')
- end) AS orderNo,
- (CASE WHEN cror.relationType = '1'
- THEN co.orderID
- ELSE cou.orderID
- END) AS orderID ,
- (case when cror.relationType = '1'
- then (select b.orderType from cm_shop_order b where cso.shopOrderID = b.shopOrderID)
- else (select c.orderType from cm_order c where cou.orderID = c.orderID)
- end) AS orderType
- from cm_receipt_order_relation cror
- left join cm_shop_order cso on cror.orderID = cso.shopOrderID
- left join cm_order co on cso.orderID = co.orderID
- LEFT JOIN cm_order cou ON cror.orderID = cou.orderID
- where cror.receiptID = #{id} and cror.delFlag = '0'
- </select>
- <select id="getInfos" parameterType="CmDiscernReceipt" resultType="com.caimei.modules.order.entity.ReceiptDetailVo">
- select
- cdr.id AS receiptID,
- cdr.receiptType AS receiptType,
- cdr.confirmType AS confirmType,
- cdr.payType AS payType,
- cof.bankAccount AS bankNameType,
- cdr.receiptAmount AS receiptAmount,
- cdr.receiptDate AS receiptDate,
- cdr.receiptStatus AS receiptStatus,
- cdr.noOrderReason AS noOrderReason,
- cdr.confirmDate AS confirmTime,
- cdr.smsContent AS smsContent,
- cdr.cancelReason AS cancelReason,
- cdr.payWay AS payWay,
- rup.name AS confirmer,
- cdr.rebateRemarks AS rebateRemarks,
- cdr.shopName as shopName
- from
- cm_discern_receipt cdr
- left join cm_receipt_user rup on cdr.confirmUserPermissionID = rup.id
- LEFT JOIN cm_offline_collection cof ON cdr.payType = cof.type
- where cdr.id = #{receiptID}
- </select>
- <select id="getOrderInfoByShopOrderID" resultType="com.caimei.modules.order.entity.ReceiptOrderInfoVo">
- select
- cso.orderNo AS orderNo,
- cso.orderID AS orderID,
- co.payTotalFee AS orderAmount,
- ifnull(co.payableAmount, 0) AS payableAmount,
- co.onlinePayFlag,
- ifnull(cso.receiptAmount, 0) AS receiptAmount,
- ifnull(cso.accountAmount, 0) AS accountAmount,
- -- (select
- -- sum(o.needPayAmount)
- -- from cm_receipt_order_relation cror
- -- left join cm_shop_order o on cror.orderID = o.shopOrderID
- -- left join cm_discern_receipt cdr on cdr.id = cror.receiptID
- -- where o.orderID = cso.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
- -- and cdr.receiptStatus = '2'
- -- ) AS receiptAmount,
- bou.name AS customerName,
- cso.orderStatusFlag AS orderStatusFlag,
- cso.receiptStatus AS receiptStatus,
- co.orderType AS orderType,
- co.orderTime AS orderTime,
- co.userID AS userID,
- cso.shopOrderNo AS shopOrderNo,
- cso.shopOrderID AS shopOrderID,
- ifnull(cso.needPayAmount, 0) AS shopOrderAmount,
- ifnull(cso.shouldPayShopAmount, 0) AS shouldPayShopAmount,
- ifnull(cso.payedShopAmount, 0) AS payedShopAmount,
- s.name AS shopName
- from cm_shop_order cso
- left join cm_order co on cso.orderID = co.orderID
- left join shop s on cso.shopID = s.shopID
- left join bp_order_userinfo bou on bou.orderId = cso.orderID
- where cso.shopOrderID = #{shopOrderID}
- </select>
- <select id="getOrderInfoByOrderID" resultType="com.caimei.modules.order.entity.ReceiptOrderInfoVo">
- select
- co.orderNo AS orderNo,
- co.orderID AS orderID,
- co.payTotalFee AS orderAmount,
- co.payableAmount AS payableAmount,
- co.onlinePayFlag,
- (select
- sum(cror.associateAmount)
- from cm_receipt_order_relation cror
- left join cm_order o on o.orderID = cror.orderID
- left join cm_discern_receipt cdr on cdr.id = cror.receiptID
- where o.orderID = co.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
- and cdr.receiptStatus = '3'
- ) AS receiptAmount,
- bou.name AS customerName,
- co.receiptStatus AS receiptStatus,
- co.orderType AS orderType,
- co.orderTime AS orderTime,
- co.organizeID AS organizeID,
- co.userID AS userID
- from cm_order co
- left join bp_order_userinfo bou on bou.orderId = co.orderID
- where co.orderID = #{orderID}
- </select>
- <select id="findReceiptRecordByOrderID" resultType="com.caimei.modules.order.entity.ReceiptRecordVo">
- select
- cror.receiptID AS receiptID,
- cdr.receiptDate AS receiptTime,
- cdr.receiptStatus AS receiptStatus,
- cdr.confirmType AS confirmType,
- cdr.receiptType AS receiptType,
- cdr.payType AS payType,
- IFNULL(cof.bankAccount,'未知')AS bankNameType,
- cdr.receiptAmount AS receiptAmount,
- cror.associationType AS associationType,
- cdr.payWay AS payWay,
- cdr.transactionNum AS transactionNum,
- cror.mbOrderId AS mbOrderId,
- cdr.confirmUserPermissionID AS confirmUserPermissionID,
- (select rup.name from cm_receipt_user rup where rup.id = cdr.confirmUserPermissionID) AS
- confirmUserName,
- cdr.confirmDate AS confirmDate,
- cdr.reviewUserPermissionID AS reviewUserPermissionID,
- (select rup.name from cm_receipt_user rup where rup.id = cdr.reviewUserPermissionID) AS reviewUserName,
- cdr.reviewDate AS reviewDate,
- cdr.cancelUserPermissionID AS cancelUserPermissionID,
- (select su.name from sys_user su where su.id = cdr.cancelUserPermissionID) AS cancelUserName,
- cdr.cancelDate AS cancelDate,
- cdr.cancelReason AS cancelReason
- from cm_receipt_order_relation cror
- left join cm_discern_receipt cdr on cdr.id = cror.receiptID
- left join cm_offline_collection cof on cdr.payType = cof.type
- where cror.delFlag = '0' and cdr.delFlag = '0'
- <if test="identifying == 2">
- <if test="relationType == 1">
- and cror.orderID in (select shopOrderID from cm_shop_order where orderID = #{orderID}) and (cror.relationType = '1' or cror.relationType = '7')
- </if>
- <if test="relationType == 2">
- and cror.orderID = #{orderID} and (cror.relationType = '2' or cror.relationType = '7')
- </if>
- <if test="relationType == 7">
- and cror.shopOrderId = #{shopOrderID} and (cror.relationType = '2' or cror.relationType = '7')
- </if>
- </if>
- <if test="identifying == 1">
- and cror.shopOrderId = #{shopOrderID} and (cror.relationType = 2 or cror.relationType = 7)
- </if>
- </select>
- <select id="findOrderIDs" resultType="string">
- select orderID from cm_receipt_order_relation cror
- where cror.receiptID = #{receiptID} and cror.delFlag = '0' and cror.relationType = '2'
- </select>
- <select id="hasReceiptRecordOrder" resultType="string">
- select cror.receiptID
- from cm_receipt_order_relation cror
- join cm_discern_receipt cdr on cror.receiptID = cdr.id
- where cror.orderID = #{orderID} and cror.receiptID != #{receiptID}
- and cror.relationType = '2' and cror.delFlag = '0'
- and cdr.receiptStatus = '3' and cdr.delFlag = '0'
- </select>
- <select id="findShopOrderIDs" resultType="string">
- select cror.orderID from cm_receipt_order_relation cror
- where cror.receiptID = #{receiptID} and cror.delFlag = '0' and cror.relationType = '1'
- </select>
- <select id="hasReceiptRecordShopOrder" resultType="string">
- select cror.receiptID
- from cm_receipt_order_relation cror
- join cm_discern_receipt cdr on cror.receiptID = cdr.id
- where cror.orderID in
- (select cso2.shopOrderID
- from cm_shop_order cso1
- left join cm_shop_order cso2 on cso2.orderID = cso1.orderID
- where cso1.shopOrderID = #{shopOrderID} and cso2.shopOrderID != #{shopOrderID})
- and cror.orderID != #{shopOrderID}
- and cdr.receiptStatus = '2' and cdr.delFlag = '0'
- and cror.relationType = '1' and cror.delFlag = '0'
- </select>
- <select id="getExportInfo" resultType="com.caimei.modules.order.entity.ReceiptExportVo">
- -- 1订单款,2非订单款,3返佣款
- select
- (case when co.orderType = '0' then '协销' else '自主' end) AS type,
- (case when co.freePostFlag = '1'
- then co.freight else 0 end) as freight,
- (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = co.orderID) AS tax,
- <if test="t == 1">
- -- 1订单款
- co.payTotalFee AS amount,
- cror.associateAmount AS associateAmount,
- co.orderNo AS no,
- </if>
- <if test="t == 3">
- -- 3返佣款
- concat(cso.needPayAmount, '(子)') AS amount,
- concat(cso.needPayAmount, '(子)') AS associateAmount,
- concat(cso.shopOrderNo, '(子)') AS no,
- </if>
- co.orderID AS id
- from cm_receipt_order_relation cror
- left join cm_discern_receipt cdr on cror.receiptID = cdr.id
- <if test="t == 1">
- left join cm_order co on cror.orderID = co.orderID
- </if>
- <if test="t == 3">
- left join cm_shop_order cso on cror.orderID = cso.shopOrderID
- left join cm_order co on cso.orderID = co.orderID
- </if>
- where cror.receiptID = #{id} and cror.delFlag = '0'
- and cdr.delFlag = '0'
- <if test="t == 1">
- and cror.relationType = '2'
- </if>
- <if test="t == 3">
- and cror.relationType = '1'
- </if>
- </select>
- <select id="getReceiptRecords" resultType="integer">
- select cror.receiptID from cm_receipt_order_relation cror
- where cror.delFlag = '0' and (
- (cror.orderID = #{shopOrderID} and cror.relationType = '1')
- or
- (cror.orderID in (select orderID from cm_shop_order where shopOrderID = #{shopOrderID}) and cror.relationType = '2')
- )
- </select>
- <select id="findRebateOrderID" resultType="integer">
- select cso.orderID AS orderID
- from cm_receipt_order_relation cror left join cm_shop_order cso
- on cror.orderID = cso.shopOrderID
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- where cror.relationType = '1' and cror.delFlag = '0' AND cdr.receiptStatus = '2'
- and cdr.receiptType = '3' and cso.orderID in
- <foreach collection="orderIds" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- <select id="findShopOrder" resultType="com.caimei.modules.order.entity.CmReceiptExport">
- SELECT
- o.orderID,
- o.payStatus,
- so.shopID,
- so.shopOrderID,
- o.orderTime,
- u.userName,
- p. NAME AS supplierName,
- (
- so.productAmount - IFNULL(so.discountAmount, 0)
- ) AS productFee,
- IFNULL(so.totalAddedValueTax,0) AS taxFee,
- IFNULL(so.totalAmount,0) AS receiptAmount,
- IFNULL(so.shopTaxFee,0) AS payTaxFee,
- IFNULL(so.shopPostFee,0) AS payFreight,
- IFNULL(so.shopOtherFee,0) AS payOther,
- IFNULL(so.shouldPayShopAmount,0) AS payAmount,
- IFNULL(so.productAmount,0) AS productAmount
- FROM
- cm_order o
- LEFT JOIN cm_shop_order so ON so.orderID = o.orderID
- LEFT JOIN user u ON u.userID = o.userID
- LEFT JOIN shop p ON p.shopID = so.shopID
- WHERE
- o.orderID = #{orderID}
- AND so.delFlag = 0
- AND o.delFlag = 0;
- </select>
- <select id="findSmoothoutInfo" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
- select * from cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror on cror.receiptID = cdr.id
- where cdr.receiptType = 1 and cror.relationType = 2 and cror.delFlag = 0
- and cdr.delFlag = 0 and cdr.confirmType in (1,2,3) and cdr.receiptStatus = '3'
- and cror.orderID = #{orderID} LIMIT 1;
- </select>
- <select id="findSmoothoutshopInfo" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
- select * from cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror on cror.receiptID = cdr.id
- where cdr.receiptType = 1 and cror.relationType = 2 and cror.delFlag = 0
- and cdr.delFlag = 0 and cdr.confirmType in (1,2,3) and cdr.receiptStatus = '3'
- and cror.shopOrderId = #{shopOrderId} LIMIT 1;
- </select>
- <select id="getPaidAmountByOrderId" resultType="com.caimei.modules.order.entity.CmReceiptOrderRelation">
- SELECT receiptID, associateAmount FROM cm_receipt_order_relation WHERE shopOrderId = #{shopOrderId}
- </select>
- <select id="findOrderReceipt" resultType="double">
- select sum(associateAmount) from cm_receipt_order_relation cror
- left join cm_discern_receipt cdr on cror.receiptID = cdr.id
- where cror.orderID = #{orderID} and cror.delFlag = '0' and cror.relationType = '2'
- and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay != '3'
- </select>
- <select id="findShoOrderIDReceipt" resultType="double">
- select ifnull(sum(cror.associateAmount), 0) as associateAmount from cm_receipt_order_relation cror
- left join cm_discern_receipt cdr on cror.receiptID = cdr.id
- where cror.shopOrderID = #{shopOrderID} and cror.delFlag = '0' and cror.relationType = '2'
- and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay = '2'
- </select>
- <select id="findShopReceipt" resultType="java.lang.Double">
- SELECT ifnull(SUM(associateAmount), 0) as associateAmount FROM (
- SELECT
- SUM(cror.associateAmount) AS associateAmount
- FROM cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- WHERE cror.relationType = 2 AND cror.orderId = #{orderID}
- AND cror.delFlag = '0' AND cror.relationType = '2' AND cdr.delFlag = '0'
- UNION
- SELECT
- SUM(cror.associateAmount) AS associateAmount
- FROM cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- WHERE cror.relationType = 1 AND cror.orderId = #{shopOrderID}
- AND cror.delFlag = '0' AND cror.relationType = '2' AND cdr.delFlag = '0'
- ) AS d
- </select>
- <select id="gathering" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT
- d.receiptDate,d.payType
- FROM
- cm_receipt_order_relation r
- LEFT JOIN cm_discern_receipt d ON d.id = r.receiptID
- WHERE r.orderID=#{orderID}
- AND d.receiptStatus = 3
- AND d.delFlag = '0'
- AND r.delFlag = '0'
- </select>
- <select id="exportRefund" resultType="com.caimei.modules.order.entity.CmReturnedPurchase">
- SELECT bou.name as userName, cof.bankAccount AS bankNameType, crp.*
- FROM `cm_returned_purchase` crp
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = crp.orderId
- LEFT JOIN cm_offline_collection cof ON crp.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (crp.confirmReturnTime <![CDATA[ > ]]> #{startTime} OR crp.confirmReturnTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (crp.confirmReturnTime <![CDATA[ < ]]> #{endTime} OR crp.confirmReturnTime = #{endTime})
- </if>
- AND crp.status= 2
- </where>
- ORDER BY crp.confirmReturnTime DESC
- </select>
- <select id="theOrder" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT d.receiptDate, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount, cof.bankAccount AS bankNameType, d.receiptType
- FROM cm_discern_receipt d
- LEFT JOIN cm_offline_collection cof ON d.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
- </if>
- AND d.receiptStatus = 2
- AND d.receiptType = 2
- AND d.delFlag = '0'
- </where>
- ORDER BY d.receiptDate DESC;
- </select>
- <select id="findDiscernReceipt" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
- SELECT
- cdr.*
- FROM
- cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror ON cror.receiptID = cdr.id
- WHERE
- cdr.receiptType = 1
- AND cror.relationType = 2
- AND cdr.receiptStatus = 3
- AND cror.delFlag = 0
- AND cdr.delFlag = 0
- AND cror.orderID = #{orderID}
- ORDER BY
- id DESC
- LIMIT
- 1
- </select>
- <select id="findPayType" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
- SELECT
- cdr.*
- FROM
- cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror ON cror.receiptID = cdr.id
- WHERE
- cdr.receiptType = 1
- AND cror.relationType = 2
- AND cdr.receiptStatus = 3
- AND cror.delFlag = 0
- AND cdr.delFlag = 0
- AND cror.orderID = #{orderID}
- ORDER BY
- payWay ASC
- LIMIT
- 1
- </select>
- <select id="findOrderLastReceiptDetailId" resultType="java.lang.Integer">
- select cdr.id
- from cm_discern_receipt cdr
- left join cm_receipt_order_relation cror on cdr.id = cror.receiptID
- where cdr.delFlag = '0'
- and cror.delFlag = '0'
- and cror.orderID = #{orderID}
- order by cdr.id desc
- limit 1
- </select>
- <select id="findSplitTime" resultType="date">
- SELECT
- splitTime
- FROM
- cm_split_account
- WHERE
- payStatus = 1
- AND orderId = #{orderID}
- ORDER BY
- splitTime DESC
- LIMIT
- 1
- </select>
- <select id="getVipRecordId" resultType="java.lang.Integer">
- select vipRecordId from cm_receipt_order_relation where receiptID=#{receiptId}
- </select>
- <select id="getVipUserId" resultType="java.lang.Integer">
- select userId from cm_svip_history where id=#{vipRecordId}
- </select>
- <select id="getUserNameByUserId" resultType="java.lang.String">
- select userName from user where userID = #{userId} LIMIT 1
- </select>
- <select id="getReceiptVipInfo" resultType="com.caimei.modules.order.entity.ReceiptVipInfoVo">
- select svipr.id,
- svipr.userId,
- svipr.packageId,
- svipr.beginTime,
- svipr.endTime,
- svipr.price,
- svipr.payTime,
- cror.orderRequestNo,
- cror.vipRecordId,
- svipp.duration,
- c.name as clubName
- from cm_svip_history svipr
- left join cm_receipt_order_relation cror on svipr.id = cror.vipRecordId
- left join club c on svipr.userId = c.userId
- left join cm_svip_package svipp on svipp.id = svipr.packageId
- where cror.receiptID=#{receiptID}
- LIMIT 1
- </select>
- <select id="svipReceipt" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT d.receiptDate, u.userName, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount, cof.bankAccount AS bankNameType, d.receiptType
- FROM cm_discern_receipt d
- left join cm_receipt_order_relation cror on d.id = cror.receiptID
- left join cm_svip_history csh on cror.vipRecordId = csh.id
- left join user u on csh.userId = u.userID
- LEFT JOIN cm_offline_collection cof ON d.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
- </if>
- AND d.receiptStatus = 3
- AND d.receiptType = 6
- AND d.delFlag = '0'
- </where>
- ORDER BY d.receiptDate DESC;
- </select>
- <select id="secondReceipt" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
- SELECT d.receiptDate, d.payType, IFNULL(d.receiptAmount, 0) AS associateAmount, cof.bankAccount AS bankNameType, d.receiptType
- FROM cm_discern_receipt d
- LEFT JOIN cm_offline_collection cof ON d.payType = cof.type
- <where>
- <if test="startTime != null and startTime != ''">
- AND (d.receiptDate <![CDATA[ > ]]> #{startTime} OR d.receiptDate = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (d.receiptDate <![CDATA[ < ]]> #{endTime} OR d.receiptDate = #{endTime})
- </if>
- AND d.receiptStatus = 3
- AND d.receiptType = 7
- AND d.delFlag = '0'
- </where>
- ORDER BY d.receiptDate DESC;
- </select>
- <select id="getCouponInfo" resultType="com.caimei.modules.order.entity.ReceipCouponInfoVo">
- SELECT c.name as clubName,cc.touchPrice,cc.couponAmount,cror.mborderId,cc.couponType,cdr.confirmDate
- FROM cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID=cdr.id
- LEFT JOIN cm_order co ON cror.orderId=co.orderID
- LEFT JOIN club c ON co.userID=c.userID
- LEFT JOIN cm_coupon_buyrecord ccb ON ccb.id=cror.couponRecordId
- LEFT JOIN cm_coupon cc ON ccb.couponId=cc.id
- WHERE receiptID = #{receiptID}
- </select>
- <select id="getShopOrderInfos" resultType="com.caimei.modules.order.entity.NewShopOrder">
- select cso.shopOrderNo,shopOrderID,cso.realPay,cso.receiptAmount,cso.receiptStatus as shopReceiptStatus from cm_order co left join cm_shop_order cso on co.orderID = cso.orderID
- <where>
- <if test="shopOrderId != null and shopOrderId != ''">
- and cso.shopOrderID = #{shopOrderId}
- </if>
- <if test="orderId != null and orderId != ''">
- and co.orderId = #{orderId}
- </if>
- </where>
- </select>
- </mapper>
|