1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426 |
- <?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.NewOrderDao">
- <sql id="columns">
- a.orderSeen AS orderSeen,
- a.orderID AS orderID,
- a.orderNo AS orderNo,
- a.organizeID AS organizeID,
- a.userID AS userID,
- a.buyUserID AS buyUserID,
- a.shopOrderIDs AS shopOrderIDs,
- a.orderSubmitType AS orderSubmitType,
- a.orderType AS orderType,
- a.secondHandOrderFlag AS secondHandOrderFlag,
- a.status AS status,
- a.productTotalFee AS productTotalFee,
- a.orderTotalFee AS orderTotalFee,
- a.payTotalFee AS payTotalFee,
- a.payableAmount AS payableAmount,
- a.balancePayFee AS balancePayFee ,
- a.discountFee AS discountFee,
- a.spID AS spID,
- a.mainSpID AS mainSpID,
- a.note AS note,
- a.clubID AS clubID,
- a.clubScanTime AS clubScanTime,
- a.orderSource AS orderSource,
- a.orderTime AS orderTime,
- a.confirmTime AS confirmTime,
- a.productCount AS productCount,
- a.presentCount AS presentCount,
- a.confirmFlag AS confirmFlag,
- a.clauseID AS clauseID,
- a.clauseContent AS clauseContent,
- a.clauseName AS clauseName,
- a.updateDate AS updateDate,
- a.freePostFlag AS freePostFlag,
- a.freight AS freight,
- a.userBeans AS userBeans,
- a.delFlag AS delFlag,
- ifnull(a.onlinePayFlag,1) AS onlinePayFlag,
- a.payTime AS payTime,
- a.splitFlag AS splitFlag,
- (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = a.orderID) AS totalAddedValueTax,
- a.preferential AS preferential,
- a.closeReason AS closeReason,
- a.receiptStatus as receiptStatus,
- a.payStatus as payStatus,
- a.sendOutStatus as sendOutStatus,
- a.refundType as refundType,
- a.postageOrderFlag AS postageOrderFlag,
- a.promotionFullReduction AS promotionFullReduction,
- a.promotionalGiftsCount AS promotionalGiftsCount,
- a.affirmPaymentFlag AS affirmPaymentFlag,
- a.rebateFlag AS rebateFlag,
- a.zeroCostFlag AS zeroCostFlag,
- a.organizeStoreId as organizeStoreId,
- a.couponAmount as couponAmount,
- a.svipFullReduction as svipFullReduction,
- (a.discountFee + a.promotionFullReduction + a.couponAmount) as discountAmount,
- a.rebateFee,
- if(chcm.id is not null,1,0) as collageFlag,
- chc.status as collageStatus
- </sql>
- <select id="get" resultType="newOrder">
- SELECT
- <include refid="columns"/>
- FROM cm_order a
- LEFT JOIN cm_hehe_collage_member chcm on a.orderID = chcm.orderId
- LEFT JOIN cm_hehe_collage chc on chcm.collageId = chc.id
- WHERE a.orderID = #{id}
- </select>
- <resultMap id="orderDisplayList" type="com.caimei.modules.order.entity.NewOrder">
- <id column="orderID" property="orderID"/>
- <result column="orderNo" property="orderNo"/>
- <result column="organizeID" property="organizeID"/>
- <result column="orderType" property="orderType"/>
- <result column="shopName" property="shopName"/>
- <result column="receiver" property="receiver"/>
- <result column="buyer" property="buyer"/>
- <result column="orderSource" property="orderSource"/>
- <result column="orderTotalFee" property="orderTotalFee"/>
- <result column="orderTime" property="orderTime"/>
- <result column="productCount" property="productCount"/>
- <result column="alreadyReceipt" property="alreadyReceipt"/>
- <result column="unReceipt" property="unReceipt"/>
- <result column="payTotalFee" property="payTotalFee"/>
- <result column="status" property="status"/>
- <collection property="newShopOrders" ofType="com.caimei.modules.order.entity.NewShopOrder"
- select="loadShopOrders" column="orderNo" fetchType="eager">
- </collection>
- </resultMap>
- <select id="findList" resultMap="orderDisplayList" parameterType="NewOrder">
- SELECT DISTINCT
- co.orderID AS orderID,
- co.orderNo AS orderNo,
- co.organizeID AS organizeID,
- co.userID AS userID,
- co.orderType AS orderType,
- co.secondHandOrderFlag AS secondHandOrderFlag,
- co.onlinePayFlag AS onlinePayFlag,
- bou.shouHuoRen AS receiver,
- u.name AS buyer,
- co.orderSource AS orderSource,
- co.orderTotalFee AS orderTotalFee,
- co.payableAmount AS payableAmount,
- co.orderTime AS orderTime,
- co.confirmTime AS confirmTime,
- co.payTotalFee AS payTotalFee,
- co.payStatus AS payStatus,
- co.refundType AS refundType,
- co.sendOutStatus AS sendOutStatus,
- co.receiptStatus AS receiptStatus,
- co.productCount AS productCount,
- (SELECT IFNULL(sum(cop.shouldPayFee),0) FROM cm_order_product cop WHERE cop.orderId=co.orderID) AS
- "shouldPayProduct",
- co.status AS status,
- co.splitFlag AS splitFlag,
- co.postageOrderFlag AS postageOrderFlag,
- (case when co.orderType = '0' then
- (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end from serviceprovider where serviceProviderID
- = co.spID)
- else
- ''
- end) AS spName,
- co.rebateFlag AS rebateFlag,
- co.rebateFee AS rebateFee
- FROM cm_order co
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
- LEFT JOIN user u ON u.userID = co.userID
- LEFT JOIN club c ON u.userID = c.userID
- LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID and sp.status = 90
- LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
- LEFT JOIN product p ON cop.productID = p.productID
- left join cm_shop_order cso on co.orderid=cso.orderID
- <where>
- co.orderType != 2
- <if test="orderID != null and orderID != ''">
- AND co.orderID = #{orderID}
- </if>
- <if test="settleStatus != null">
- AND cso.settleStatus = #{settleStatus}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND co.orderNo = #{orderNo}
- </if>
- <if test="organizeID != null">
- AND co.organizeID = #{organizeID}
- </if>
- <if test="status != null and status != ''">
- <choose>
- <when test="status == '99'.toString()">
- AND co.status in (11,12,13,21,22,23,31,32,33)
- </when>
- <otherwise>
- AND co.status = #{status}
- </otherwise>
- </choose>
- </if>
- <if test="buyer != null and buyer != ''">
- AND u.name LIKE concat('%',#{buyer},'%')
- </if>
- <if test="orderType != null and orderType != ''">
- AND co.orderType = #{orderType}
- </if>
- <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">
- AND co.secondHandOrderFlag = #{secondHandOrderFlag}
- </if>
- <if test="orderSource != null and orderSource != ''">
- AND co.orderSource = #{orderSource}
- </if>
- <if test="orderTime != null and orderTime != ''">
- AND co.orderTime = #{orderTime}
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- AND co.sendOutStatus = #{sendOutStatus}
- </if>
- <if test="startTime != null and startTime != ''">
- AND co.orderTime <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND co.orderTime <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="startConfirmTime != null and startConfirmTime != ''">
- AND co.confirmTime <![CDATA[ >= ]]> #{startConfirmTime}
- </if>
- <if test="endConfirmTime != null and endConfirmTime != ''">
- AND co.confirmTime <![CDATA[ <= ]]> #{endConfirmTime}
- </if>
- <if test="receiver != null and receiver != ''">
- AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
- </if>
- <if test="receiptStatus != null and receiptStatus != ''">
- AND co.receiptStatus = #{receiptStatus}
- </if>
- <if test="payStatus != null and payStatus != ''">
- AND co.payStatus = #{payStatus}
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- AND co.sendOutStatus = #{sendOutStatus}
- </if>
- <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
- AND
- <if test="returnedPurchaseStatus == 1">
- exists
- </if>
- <if test="returnedPurchaseStatus == 0">
- not exists
- </if>
- (select 1 from cm_returned_purchase c3 where c3.status = '1' and c3.orderID = co.orderID and c3.delFlag
- = 0)
- </if>
- <if test="refundType != null and refundType != ''">
- AND
- <if test="refundType == 0">
- co.refundType is null
- </if>
- <if test="refundType == 1">
- co.refundType = '1'
- </if>
- <if test="refundType == 2">
- co.refundType = '2'
- </if>
- </if>
- <if test="orderRefundType != null and orderRefundType != ''">
- <if test="orderRefundType == 0">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
- 0) = 0
- </if>
- <if test="orderRefundType == 1">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
- 0) > 0
- </if>
- <if test="orderRefundType == 11">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 1
- and crp.delFlag = 0) > 0
- </if>
- <if test="orderRefundType == 12">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 2
- and crp.delFlag = 0
- <if test="startRefundTime != null and startRefundTime != ''">
- AND crp.confirmReturnTime <![CDATA[ >= ]]> #{startRefundTime}
- </if>
- <if test="endRefundTime != null and endRefundTime != ''">
- AND crp.confirmReturnTime <![CDATA[ <= ]]> #{endRefundTime}
- </if>
- ) > 0
- </if>
- <if test="orderRefundType == 13">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 3
- and crp.delFlag = 0) > 0
- </if>
- </if>
- <if test="rebateOrder != null and rebateOrder != ''">
- AND
- (
- <if test="rebateOrder == 1">
- co.rebateFlag = '1'
- OR exists
- </if>
- <if test="rebateOrder == 0">
- co.rebateFlag = '0'
- AND not exists
- </if>
- (select 1 from cm_receipt_order_relation c1
- left join cm_discern_receipt cdr ON c1.receiptID = cdr.id
- where c1.relationType = '1'
- and c1.orderID in (select c2.shopOrderID from cm_shop_order c2 where c2.orderID = co.orderID)
- and c1.delFlag = '0'
- and cdr.receiptStatus = '2'))
- </if>
- <if test="serviceProviderId != null and serviceProviderId != 0">
- and (co.spID = #{serviceProviderId}
- or sp.serviceProviderID = #{serviceProviderId})
- </if>
- <if test="productName != null and productName != ''">
- and p.name like CONCAT('%',#{productName},'%')
- </if>
- <if test="productCategory == 2">
- and p.productCategory=2
- </if>
- <if test="productCategory == null || productCategory == 1">
- and p.productCategory=1
- </if>
- AND co.delFlag = 0
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY co.orderID DESC, co.orderTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="loadShopOrders" parameterType="string" resultType="NewShopOrder">
- SELECT cs.shopOrderID AS shopOrderID,
- cs.shopOrderNo AS shopOrderNo,
- cs.shopOrderNo AS shopOrderNo,
- cs.itemCount AS itemCount,
- cs.needPayAmount AS needPayAmount,
- s.name AS shopName,
- cs.shopID AS shopID
- FROM cm_shop_order cs
- LEFT JOIN shop s ON cs.shopID = s.shopID
- WHERE cs.orderNo = #{orderNo}
- AND cs.delFlag = 0
- </select>
- <select id="getShopOrders" parameterType="string" resultType="NewShopOrder">
- SELECT (SELECT IFNULL(sum(shouldPayFee), 0)
- FROM cm_order_product
- WHERE shopOrderID = cs.shopOrderID AND payStatus = 2) AS
- alreadyReceipt,
- (SELECT IFNULL(sum(shouldPayFee), 0)
- FROM cm_order_product
- WHERE shopOrderID = cs.shopOrderID AND payStatus != 2) AS unReceipt,
- cs.shopOrderID AS shopOrderID,
- co.orderID AS orderID,
- cs.shopOrderNo AS shopOrderNo,
- co.orderNo AS orderNo,
- cs.shopOrderNo AS shopOrderNo,
- cs.itemCount AS itemCount,
- cs.needPayAmount AS needPayAmount,
- co.orderType AS orderType,
- s.name AS shopName,
- bou.shouHuoRen AS receiver,
- u.name AS buyer,
- co.orderSource AS orderSource,
- co.orderTotalFee AS orderTotalFee,
- co.orderTime AS orderTime
- FROM cm_shop_order cs
- LEFT JOIN cm_order co ON cs.orderNo = co.orderNo
- LEFT JOIN shop s ON cs.shopID = s.shopID
- LEFT JOIN user u ON cs.userID = u.userID
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
- WHERE cs.orderNo = #{orderNo}
- AND cs.delFlag = 0
- </select>
- <update id="updateClauseContent">
- UPDATE cm_order
- SET clauseContent = #{clauseContent},
- clauseName= #{clauseName}WHERE orderID = #{orderID}
- </update>
- <insert id="insert" parameterType="NewOrder" keyProperty="orderID" useGeneratedKeys="true">
- INSERT INTO cm_order(orderSeen,
- orderNo,
- userID,
- buyUserID,
- shopOrderIDs,
- orderSubmitType,
- orderType,
- secondHandOrderFlag,
- status,
- payFlag,
- onlinePayFlag,
- productTotalFee,
- orderTotalFee,
- payTotalFee,
- balancePayFee,
- discountFee,
- spID,
- mainSpID,
- note,
- clubID,
- clubScanTime,
- orderSource,
- orderTime,
- productCount,
- confirmFlag,
- clauseID,
- clauseContent,
- clauseName,
- updateDate,
- freePostFlag,
- freight,
- delFlag,
- payTime,
- splitFlag,
- preferential,
- confirmTime,
- invoiceFlag,
- postageOrderFlag,
- sendOutStatus,
- payableAmount,
- promotionFullReduction,
- promotionalGiftsCount,
- affirmPaymentFlag,
- rebateFlag,
- rebateFee,
- payStatus,
- zeroCostFlag,
- couponAmount,
- svipFullReduction)
- VALUES (#{orderSeen},
- #{orderNo},
- #{userID},
- #{buyUserID},
- #{shopOrderIDs},
- #{orderSubmitType},
- #{orderType},
- #{secondHandOrderFlag},
- #{status},
- #{payFlag},
- #{onlinePayFlag},
- #{productTotalFee},
- #{orderTotalFee},
- #{payTotalFee},
- #{balancePayFee},
- #{discountFee},
- #{spID},
- #{mainSpID},
- #{note},
- #{clubID},
- #{clubScanTime},
- #{orderSource},
- #{orderTime},
- #{productCount},
- #{confirmFlag},
- #{clauseID},
- #{clauseContent},
- #{clauseName},
- #{updateDate},
- #{freePostFlag},
- #{freight},
- #{delFlag},
- #{payTime},
- #{splitFlag},
- #{preferential},
- #{confirmTime},
- #{invoiceFlag},
- #{postageOrderFlag},
- #{sendOutStatus},
- #{payableAmount},
- #{promotionFullReduction},
- #{promotionalGiftsCount},
- #{affirmPaymentFlag},
- #{rebateFlag},
- #{rebateFee},
- #{payStatus},
- #{zeroCostFlag},
- #{couponAmount},
- #{svipFullReduction})
- </insert>
- <update id="update">
- update cm_order
- <set>
- <if test="orderSeen != null">
- orderSeen = #{orderSeen},
- </if>
- <if test="orderNo != null">
- orderNo = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="userID != null">
- userID = #{userID,jdbcType=BIGINT},
- </if>
- <if test="organizeID != null">
- organizeID = #{organizeID,jdbcType=INTEGER},
- </if>
- <if test="buyUserID != null">
- buyUserID = #{buyUserID,jdbcType=INTEGER},
- </if>
- <if test="shopOrderIDs != null">
- shopOrderIDs = #{shopOrderIDs,jdbcType=VARCHAR},
- </if>
- <if test="orderSubmitType != null">
- orderSubmitType = #{orderSubmitType,jdbcType=CHAR},
- </if>
- <if test="orderType != null">
- orderType = #{orderType,jdbcType=CHAR},
- </if>
- <if test="secondHandOrderFlag != null">
- secondHandOrderFlag = #{secondHandOrderFlag,jdbcType=CHAR},
- </if>
- <if test="status != null">
- status = #{status,jdbcType=CHAR},
- </if>
- <if test="productTotalFee != null">
- productTotalFee = #{productTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="orderTotalFee != null">
- orderTotalFee = #{orderTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="payTotalFee != null">
- payTotalFee = #{payTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="payableAmount != null">
- payableAmount = #{payableAmount,jdbcType=DECIMAL},
- </if>
- <if test="balancePayFee != null">
- balancePayFee = #{balancePayFee,jdbcType=DECIMAL},
- </if>
- <if test="discountFee != null">
- discountFee = #{discountFee,jdbcType=DECIMAL},
- </if>
- <if test="spID != null">
- spID = #{spID,jdbcType=BIGINT},
- </if>
- <if test="mainSpID != null">
- mainSpID = #{mainSpID,jdbcType=BIGINT},
- </if>
- <if test="clubID != null">
- clubID = #{clubID,jdbcType=BIGINT},
- </if>
- <if test="clubScanTime != null">
- clubScanTime = #{clubScanTime,jdbcType=VARCHAR},
- </if>
- <if test="orderSource != null">
- orderSource = #{orderSource,jdbcType=CHAR},
- </if>
- <if test="orderTime != null">
- orderTime = #{orderTime,jdbcType=TIMESTAMP},
- </if>
- <if test="productCount != null">
- productCount = #{productCount,jdbcType=INTEGER},
- </if>
- <if test="presentCount != null">
- presentCount = #{presentCount,jdbcType=INTEGER},
- </if>
- <if test="confirmFlag != null">
- confirmFlag = #{confirmFlag,jdbcType=CHAR},
- </if>
- <if test="clauseID != null">
- clauseID = #{clauseID,jdbcType=BIGINT},
- </if>
- <if test="clauseName != null">
- clauseName = #{clauseName,jdbcType=VARCHAR},
- </if>
- <if test="freePostFlag != null">
- freePostFlag = #{freePostFlag,jdbcType=CHAR},
- </if>
- <if test="freight != null">
- freight = #{freight,jdbcType=DECIMAL},
- </if>
- <if test="delFlag != null">
- delFlag = #{delFlag,jdbcType=CHAR},
- </if>
- <if test="note != null">
- note = #{note,jdbcType=LONGVARCHAR},
- </if>
- <if test="clauseContent != null">
- clauseContent = #{clauseContent,jdbcType=LONGVARCHAR},
- </if>
- <if test="payTime != null">
- payTime = #{payTime,jdbcType=LONGVARCHAR},
- </if>
- <if test="preferential != null">
- preferential = #{preferential ,jdbcType=DECIMAL},
- </if>
- <if test="discountFee != null">
- discountFee = #{discountFee},
- </if>
- <if test="payFlag != null">
- payFlag = #{payFlag},
- </if>
- <if test="onlinePayFlag != null">
- onlinePayFlag = #{onlinePayFlag},
- </if>
- <if test="splitFlag != null">
- splitFlag = #{splitFlag},
- </if>
- <if test="closeReason != null">
- closeReason = #{closeReason},
- </if>
- <if test="confirmTime != null">
- confirmTime = #{confirmTime},
- </if>
- <if test="invoiceFlag != null">
- invoiceFlag = #{invoiceFlag},
- </if>
- <if test="postageOrderFlag != null">
- postageOrderFlag = #{postageOrderFlag},
- </if>
- <if test="sendOutStatus != null">
- sendOutStatus = #{sendOutStatus},
- </if>
- <if test="receiptStatus != null">
- receiptStatus = #{receiptStatus},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus},
- </if>
- <if test="refundType != null">
- refundType = #{refundType},
- </if>
- <if test="promotionFullReduction != null">
- promotionFullReduction = #{promotionFullReduction},
- </if>
- <if test="promotionalGiftsCount != null">
- promotionalGiftsCount = #{promotionalGiftsCount},
- </if>
- <if test="affirmPaymentFlag != null">
- affirmPaymentFlag = #{affirmPaymentFlag},
- </if>
- <if test="rebateFlag != null">
- rebateFlag = #{rebateFlag},
- </if>
- <if test="rebateFee != null">
- rebateFee = #{rebateFee},
- </if>
- <if test="zeroCostFlag != null">
- zeroCostFlag = #{zeroCostFlag},
- </if>
- <if test="couponAmount != null">
- couponAmount = #{couponAmount},
- </if>
- <if test="svipFullReduction != null">
- svipFullReduction = #{svipFullReduction}
- </if>
- </set>
- where orderID = #{orderID,jdbcType=BIGINT}
- </update>
- <select id="findByOrderID" resultType="NewOrder">
- select *
- from cm_order
- where orderID = #{orderID}
- </select>
- <update id="confirmOrder">
- </update>
- <update id="updateStatus" parameterType="NewOrder">
- UPDATE cm_order
- SET status = #{status}
- WHERE orderID = #{orderID}
- </update>
- <select id="getOrderByShopOrderID" resultType="NewOrder">
- select *
- from cm_order co
- left join cm_shop_order cso on cso.orderID = co.orderID
- where cso.shopOrderID = #{shopOrderID}
- </select>
- <update id="updatePayStatus">
- update cm_order
- set payStatus = #{payStatus}
- where orderID = #{orderID}
- </update>
- <select id="findOrderList" resultType="NewOrder" parameterType="NewOrder">
- SELECT co.*, bou.name AS buyer,s.name AS shopName,c.name AS clubName
- FROM cm_order co
- LEFT JOIN cm_shop_order cso ON co.orderID = cso.orderID
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
- LEFT JOIN shop s ON s.shopID = cso.shopID
- LEFT JOIN club c ON c.userID = co.userID
- <where>
- <if test="startTime != null and startTime != ''">
- AND co.orderTime <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND co.orderTime <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="orderID != null and orderID != ''">
- AND co.orderID = #{orderID}
- </if>
- <if test="organizeID != null and organizeID != 9999">
- AND co.organizeID = #{organizeID}
- </if>
- <if test="organizeID == 9999">
- AND co.orderType = 2
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND co.orderNo like concat('%', #{orderNo} ,'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name like concat('%', #{shopName} ,'%')
- </if>
- <if test="buyer != null and buyer != ''">
- AND bou.name like concat('%', #{buyer} ,'%')
- </if>
- <if test="clubName != null and clubName != ''">
- AND c.name like concat('%', #{clubName} ,'%')
- </if>
- <if test="shopOrderIDs != null and shopOrderIDs != ''">
- AND cso.shopOrderID = #{shopOrderIDs}
- </if>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- AND cso.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
- </if>
- <if test="ps != null and ps.length>0 ">
- AND co.payStatus IN
- <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="receiptStatus != null and receiptStatus!= ''">
- AND receiptStatus = #{receiptStatus}
- </if>
- <if test="refundType !=null and refundType != ''">
- <if test="refundType == 1 or refundType == 2">
- AND refundType = #{refundType}
- </if>
- <if test="refundType == 0">
- AND refundType NOT IN (1,2)
- </if>
- </if>
- <if test="rebateOrder != null and rebateOrder !=''">
- <if test="rebateOrder == 0">
- AND cso.shopOrderID NOT IN (
- SELECT orderID FROM cm_receipt_order_relation
- WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
- </if>
- <if test="rebateOrder == 1">
- AND cso.shopOrderID IN (
- SELECT orderID FROM cm_receipt_order_relation
- WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
- </if>
- </if>
- AND co.delFlag = '0'
- AND cso.delFlag = '0'
- </where>
- GROUP BY co.orderID
- ORDER BY co.orderID DESC
- </select>
- <select id="findPaidOrderID" resultType="Double">
- SELECT SUM(payAmount)
- FROM cm_pay_shop_record cosr
- LEFT JOIN cm_shop_order cso ON cosr.shopOrderID = cso.shopOrderID
- WHERE cso.orderID = #{orderID}
- AND cosr.delFlag = '0'
- AND cosr.status = '1'
- AND cosr.paymentType IN (1, 2)
- GROUP BY cso.orderID
- </select>
- <select id="findPromotionsByIds" resultType="com.caimei.modules.product.entity.CmPromotion">
- select * from cm_promotions
- where id in
- <foreach collection="promotionsIds" item="promotionsId" index="index" open="(" separator="," close=")">
- #{promotionsId}
- </foreach>
- </select>
- <select id="getDbPromotionsByOrderId" resultType="com.caimei.modules.product.entity.CmPromotion">
- select *
- from cm_promotions_order
- where promotionsId = #{promotionsId}
- and orderId = #{orderId}
- </select>
- <select id="findServiceProviderList" resultType="com.caimei.modules.user.entity.NewCmSp">
- select s.serviceProviderID, s.linkMan
- from serviceprovider s
- join user u on s.userID = u.userID
- where s.status = 90
- and s.serviceProviderID != 1342
- </select>
- <insert id="insertPromotionsRecord" parameterType="com.caimei.modules.product.entity.CmPromotion" keyProperty="id"
- useGeneratedKeys="true">
- INSERT INTO cm_promotions_order(orderId,
- promotionsId,
- name,
- description,
- type,
- mode,
- touchPrice,
- reducedPrice,
- discount,
- status,
- beginTime,
- endTime)
- VALUES (#{orderId},
- #{promotionsId},
- #{name},
- #{description},
- #{type},
- #{mode},
- #{touchPrice},
- #{reducedPrice},
- #{discount},
- #{status},
- #{beginTime},
- #{endTime})
- </insert>
- <update id="updatePromotionsRecord">
- update cm_promotions_order
- <set>
- <if test="orderId != null and orderId !=''">
- orderId = #{orderId},
- </if>
- <if test="promotionsId != null and promotionsId !=''">
- promotionsId = #{promotionsId},
- </if>
- <if test="name != null and name !=''">
- name = #{name},
- </if>
- <if test="description != null and description !=''">
- description = #{description},
- </if>
- <if test="type != null and type !=''">
- type = #{type},
- </if>
- <if test="mode != null and mode !=''">
- mode = #{mode},
- </if>
- <if test="touchPrice != null and touchPrice !=''">
- touchPrice = #{touchPrice},
- </if>
- <if test="reducedPrice != null and reducedPrice !=''">
- reducedPrice = #{reducedPrice},
- </if>
- <if test="status != null and status !=''">
- status = #{status},
- </if>
- <if test="beginTime != null and beginTime !=''">
- beginTime = #{beginTime},
- </if>
- <if test="endTime != null and endTime !=''">
- endTime = #{endTime}
- </if>
- </set>
- where id = #{id}
- </update>
- <update id="updatePayAndReceipt">
- update cm_order
- set status = concat('3', sendOutStatus),
- payStatus= 3,
- receiptStatus= 3
- where orderID = #{orderId}
- </update>
- <update id="updateOrderStatus">
- update cm_order
- set payStatus = #{payStatus},
- zeroCostFlag = #{zeroCostFlag}
- where orderID = #{orderID}
- </update>
- <delete id="deleterPomotionsOrder">
- DELETE
- FROM cm_promotions_order
- WHERE orderId = #{orderId}
- </delete>
- <update id="updateByRebateFlag">
- UPDATE cm_order
- SET rebateFlag = 1
- WHERE orderID = #{orderId}
- </update>
- <select id="findQualificationFile" resultType="com.caimei.modules.order.entity.CmFile">
- SELECT fileName,
- ossName
- FROM cm_qualification_file
- WHERE recordId = #{recordId}
- </select>
- <select id="findQualificationImage" resultType="string">
- SELECT image
- FROM cm_qualification_image
- WHERE recordId = #{recordId}
- ORDER BY id
- </select>
- <delete id="deleteQualificationImage">
- DELETE
- FROM cm_qualification_image
- WHERE recordId = #{recordId}
- </delete>
- <insert id="insertQualificationImage">
- INSERT INTO `cm_qualification_image` (`recordId`, `image`)
- VALUES (#{recordId}, #{image});
- </insert>
- <delete id="deleteQualificationFile">
- DELETE
- FROM cm_qualification_file
- WHERE recordId = #{recordId}
- </delete>
- <insert id="insertQualificationFile">
- INSERT INTO `cm_qualification_file` (`recordId`, `fileName`, `ossName`)
- VALUES (#{recordId}, #{fileName}, #{ossName})
- </insert>
- <select id="findBYShortLink" resultType="integer">
- SELECT id
- FROM cm_short_link
- WHERE shortLink = #{shortLink}
- </select>
- <select id="getDepositOrderProductId" resultType="java.lang.Integer">
- SELECT productID
- FROM cm_order_product
- WHERE orderID = #{orderID}
- LIMIT 1
- </select>
- <insert id="insertShortLink">
- INSERT INTO cm_short_link (`markId`, `shortLink`, `jumpLink`,
- `createTime`)
- VALUES (#{markId}, #{shortLink}, #{url},
- NOW())
- </insert>
- <update id="updateSendNum">
- UPDATE cm_sms_statistics
- SET sendNum = (sendNum + #{num})
- WHERE markId = #{markId}
- </update>
- <update id="updateUserMoneyByUserId">
- UPDATE USER
- SET userMoney=(userMoney - #{payTotalFee}),
- ableUserMoney = (ableUserMoney - #{payTotalFee})
- WHERE userID = #{userID}
- </update>
- <select id="findOrderCouponRecord" resultType="com.caimei.modules.coupon.entity.CmCouponOrderRecord">
- SELECT `id`,
- `orderId`,
- `clubCouponId`,
- `couponType`,
- `couponAmount`,
- `touchPrice`,
- `createDate`
- FROM cm_coupon_order_record
- WHERE orderId = #{orderID}
- </select>
- <select id="findClubCouponById" resultType="com.caimei.modules.coupon.entity.CmCoupon">
- SELECT cc.`id`,
- cc.`couponAmount`,
- cc.`touchPrice`,
- cc.`couponType`,
- cc.`userId`,
- cc.`shopId`,
- cc.`productType`,
- cc.`categoryType`,
- cc.`couponsMode`
- FROM cm_coupon_club a
- LEFT JOIN cm_coupon cc ON a.couponId = cc.id
- WHERE a.id = #{clubCouponId}
- AND a.status = 1
- </select>
- <insert id="insertCouponOrderRecord">
- INSERT INTO `cm_coupon_order_record` (`orderId`,
- `clubCouponId`,
- `couponType`,
- `couponAmount`,
- `touchPrice`,
- `createDate`)
- VALUES (#{orderId},
- #{clubCouponId},
- #{couponType},
- #{couponAmount},
- #{touchPrice},
- #{createDate})
- </insert>
- <update id="updateCouponOrderRecord">
- UPDATE
- `cm_coupon_order_record`
- SET `clubCouponId` = #{clubCouponId},
- `couponType` = #{couponType},
- `couponAmount` = #{couponAmount},
- `touchPrice` = #{touchPrice}
- WHERE orderId = #{orderId}
- </update>
- <update id="updatePayStatusSon">
- UPDATE cm_shop_order
- SET payStatus=3
- WHERE orderID = #{orderId}
- </update>
- <update id="updateOnlinePayFlag">
- update cm_order set onlinePayFlag = #{onlinePayFlag} where orderID = #{orderId}
- </update>
- <update id="updateShopOrderByPayStatus">
- UPDATE cm_shop_order SET
- payStatus = #{payStatus}, payedShopAmount = #{paidShop}
- WHERE shopOrderID = #{shopOrderId}
- </update>
- <update id="updateOrderByPayStatus">
- UPDATE cm_order SET
- payStatus = #{payStatus}
- WHERE orderID = #{orderId}
- </update>
- <update id="updateBySplitStatus">
- UPDATE cm_receipt_order_relation SET splitStatus = 1 WHERE mbOrderId = #{mbOrderId}
- </update>
- <update id="updateSettleStatus">
- update cm_split_account
- set settleStatus = 1
- where shopOrderId = #{shopOrderId}
- and productType = #{productType}
- </update>
- <update id="updateShopOrderSettleStatus">
- update cm_shop_order set settleStatus = #{settleStatus}
- where shopOrderId = #{shopOrderId}
- </update>
- <delete id="deleteCouponOrderRecord">
- DELETE
- FROM cm_coupon_order_record
- WHERE id = #{id}
- </delete>
- <select id="getUndividedPaidReceipt" resultType="com.caimei.modules.order.entity.OrderReceiptRelationPo">
- SELECT cror.id,
- cror.relationType,
- cror.receiptId,
- cror.associateAmount,
- cror.orderId,
- cror.delFlag,
- cror.mbOrderId,
- cror.orderRequestNo,
- cror.splitStatus,
- cror.shopOrderId,
- cdr.payType
- 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
- WHERE cror.relationType = 2
- AND a.receiptStatus=3
- AND cror.delFlag = 0
- AND cror.mbOrderId IS NOT NULL
- AND cror.splitStatus = 0
- AND cdr.payWay = 1
- AND cdr.receiptDate <![CDATA[ <= ]]> #{currentTime}
- AND co.organizeID = 0
- AND co.orderType != 2
- AND co.refundType != 2
- </select>
- <select id="getOnlineBalance" resultType="com.caimei.modules.order.entity.OrderReceiptRelationPo">
- SELECT DISTINCT cror.id,
- cror.relationType,
- cror.receiptId,
- cror.associateAmount,
- cror.orderId,
- cror.delFlag,
- cror.mbOrderId,
- cror.orderRequestNo,
- cror.splitStatus,
- cdr.payType
- 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 cm_user_balance_record cubr ON cubr.orderId = cror.orderID
- WHERE cror.relationType = 2
- AND cror.delFlag = 0
- AND cror.splitStatus = 0
- AND cdr.delFlag = 0
- AND cdr.payWay = 3
- AND cdr.receiptDate <![CDATA[ <= ]]> #{currentTime}
- AND co.organizeID = 0
- AND co.orderType != 2
- AND co.refundType != 2
- AND cubr.balanceType = 10
- AND cror.associateAmount > 0.01
- </select>
- <select id="getOrderProductByOrderId" resultType="com.caimei.modules.order.entity.OrderProductVo">
- SELECT cop.orderProductID AS orderProductId,
- cop.orderID AS orderId,
- cop.orderNo,
- cop.shopOrderID AS shopOrderId,
- cop.shopOrderNo,
- cop.orderPromotionsId,
- cop.productId,
- cop.shopId,
- cop.name,
- cop.productImage AS image,
- cop.price,
- cop.shopName,
- IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
- cop.normalPrice,
- cop.ladderPriceFlag,
- cop.discountPrice,
- cop.discount,
- cop.totalAmount,
- cop.totalFee,
- cop.shouldPayFee,
- cop.productUnit,
- cop.num,
- cop.presentNum,
- cop.discountFee,
- cop.includedTax,
- cop.invoiceType,
- cop.taxRate,
- cop.addedValueTax,
- cop.totalAddedValueTax,
- cop.singleShouldPayTotalTax,
- cop.shouldPayTotalTax,
- cop.shopProductAmount,
- cop.singleShopFee,
- cop.shopFee,
- cop.singleOtherFee,
- cop.otherFee,
- cop.singleCmFee,
- cop.cmFee,
- cop.payStatus,
- cop.buyAgainFlag,
- cop.notOutStore,
- cop.isActProduct AS actProduct,
- cop.productType,
- p.productCategory as productCategory,
- p.splitCode
- FROM cm_order_product cop
- LEFT JOIN product p ON cop.productID = p.productID
- LEFT JOIN cm_order co ON cop.orderId = co.orderId
- WHERE co.orderID = #{orderId}
- AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
- ORDER BY cop.discountPrice DESC
- </select>
- <select id="getOrderProductPaidAmount" resultType="java.lang.Double">
- SELECT SUM(splitAccount)
- FROM cm_split_account
- WHERE orderProductId = #{orderProductId}
- AND payStatus = 1
- AND productType = 1
- </select>
- <select id="getShopOrderListByOrderId" resultType="com.caimei.modules.order.entity.ShopOrderVo">
- SELECT shopOrderID AS shopOrderId,
- shopOrderNo,
- orderID AS orderId,
- orderNo,
- shopID AS shopId,
- note,
- userID AS userId,
- clubID AS clubId,
- spID AS spId,
- orderPromotionsId,
- promotionFullReduction,
- brokerage,
- canRefundAmount,
- itemCount,
- totalAmount,
- productAmount,
- needPayAmount,
- shopProductAmount,
- shopPostFee,
- shopTaxFee,
- shouldPayShopAmount,
- orderTime,
- orderSubmitType,
- payStatus,
- sendOutStatus,
- splitFlag,
- splitCode
- FROM cm_shop_order
- WHERE delFlag = 0
- AND shopOrderID = #{shopOrderId}
- </select>
- <select id="getPaidShipping" resultType="java.lang.Double">
- SELECT SUM(splitAccount)
- FROM cm_split_account
- WHERE orderId = #{orderId}
- AND shopId = #{shopId}
- AND productType = 2
- AND payStatus = 1
- </select>
- <select id="getShopCommercialCode" resultType="java.lang.String">
- SELECT commercialCode
- FROM cm_shop_splitcode
- WHERE shopID = #{shopId}
- limit 1
- </select>
- <select id="getOrderByOrderId" resultType="com.caimei.modules.order.entity.OrderVo">
- SELECT orderID AS orderId,
- shopOrderIds,
- orderSource,
- orderNo,
- organizeID AS organizeId,
- userID AS userId,
- clubID AS clubId,
- buyUserID AS buyUserId,
- orderTime AS orderTime,
- updateDate AS updateDate,
- delFlag,
- userBeans,
- orderType,
- orderSubmitType,
- confirmFlag,
- onlinePayFlag,
- splitFlag,
- payFlag,
- receiptStatus,
- payStatus,
- zeroCostFlag,
- sendOutStatus,
- refundType,
- affirmPaymentFlag,
- productCount,
- presentCount,
- promotionalGiftsCount,
- hasActProduct,
- promotionFullReduction,
- secondHandOrderFlag,
- invoiceFlag,
- freePostFlag AS postageFlag,
- freight AS postage,
- productTotalFee,
- orderTotalFee,
- payTotalFee,
- payableAmount,
- balancePayFee,
- discountFee,
- status,
- paySuccessCounter,
- confirmTime,
- payTime,
- rebateFlag,
- clauseID AS clauseId,
- clauseName
- FROM cm_order
- WHERE orderID = #{orderId}
- </select>
- <select id="findSplitTime" resultType="java.util.Date">
- SELECT splitTime
- FROM cm_split_account
- WHERE splitTime IS NOT NULL
- AND splitTime > DATE_ADD(NOW(), INTERVAL -2 MINUTE)
- LIMIT 1
- </select>
- <select id="findSupport" resultType="java.lang.Integer">
- SELECT s.chargeSupport FROM shop s
- LEFT JOIN cm_shop_order cso ON cso.shopId= s.shopId
- WHERE cso.shopOrderId=25059
- </select>
- <select id="getOrderProductByShopOrderId" resultType="com.caimei.modules.order.entity.OrderProductVo">
- SELECT cop.orderProductID AS orderProductId,
- cop.orderID AS orderId,
- cop.orderNo,
- cop.shopOrderID AS shopOrderId,
- cop.shopOrderNo,
- cop.orderPromotionsId,
- cop.productId,
- cop.shopId,
- cop.name,
- cop.productImage AS image,
- cop.price,
- cop.shopName,
- IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
- cop.normalPrice,
- cop.ladderPriceFlag,
- cop.discountPrice,
- cop.discount,
- cop.totalAmount,
- cop.totalFee,
- cop.shouldPayFee,
- cop.productUnit,
- cop.num,
- cop.presentNum,
- cop.discountFee,
- cop.includedTax,
- cop.invoiceType,
- cop.taxRate,
- cop.addedValueTax,
- cop.totalAddedValueTax,
- cop.singleShouldPayTotalTax,
- cop.shouldPayTotalTax,
- cop.shopProductAmount,
- cop.singleShopFee,
- cop.shopFee,
- cop.singleOtherFee,
- cop.otherFee,
- cop.singleCmFee,
- cop.cmFee,
- cop.payStatus,
- cop.buyAgainFlag,
- cop.notOutStore,
- cop.isActProduct AS actProduct,
- cop.productType,
- p.productCategory as productCategory,
- p.splitCode
- FROM cm_order_product cop
- LEFT JOIN product p ON cop.productID = p.productID
- left join cm_order co on co.orderID = cop.orderID
- WHERE cop.shopOrderID = #{shopOrderId}
- AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
- ORDER BY cop.discountPrice DESC
- </select>
- <select id="getShopOrderByOrderId" resultType="com.caimei.modules.order.entity.ShopOrderVo">
- SELECT shopOrderID AS shopOrderId,
- shopOrderNo,
- orderID AS orderId,
- orderNo,
- shopID AS shopId,
- note,
- userID AS userId,
- clubID AS clubId,
- spID AS spId,
- orderPromotionsId,
- promotionFullReduction,
- brokerage,
- canRefundAmount,
- itemCount,
- totalAmount,
- productAmount,
- needPayAmount,
- shopProductAmount,
- shopPostFee,
- shopTaxFee,
- shouldPayShopAmount,
- orderTime,
- orderSubmitType,
- payStatus,
- sendOutStatus,
- splitFlag,
- splitCode
- FROM cm_shop_order
- WHERE delFlag = 0
- AND orderID = #{orderId}
- </select>
- <select id="getSplitAccountList" resultType="com.caimei.modules.order.entity.SplitAccountPo">
- SELECT
- id,
- orderId,
- productId,
- orderProductId,
- shopId,
- type,
- subUserNo,
- SUM(splitAccount) AS splitAccount,
- mbOrderId,
- orderRequestNo,
- payStatus,
- productType
- FROM cm_split_account
- WHERE type = 4 AND payStatus = 1 AND splitAccount > 0
- AND mbOrderId = #{mbOrderId}
- GROUP BY shopId
- </select>
- <select id="getPaidShopAmount" resultType="java.lang.Double">
- SELECT SUM(payAmount)
- FROM cm_pay_shop_record
- WHERE STATUS = 1 AND delFlag = 0 AND shopOrderID = #{shopOrderId}
- </select>
- <select id="findOnlinePay" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM
- cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cdr.id = receiptID
- LEFT JOIN cm_order co ON cror.orderId = co.orderId
- WHERE cdr.payWay=1
- AND co.orderType != 2
- AND cror.orderID=#{orderID}
- </select>
- <select id="findSplitCode" resultType="java.lang.String">
- select splitCode from cm_shop_order where shopOrderID = #{shopOrderId}
- </select>
- <select id="findPayAmount" resultType="java.lang.Double">
- SELECT SUM(splitAccount) FROM cm_split_account csa
- LEFT JOIN cm_receipt_order_relation cror ON csa.shopOrderId=cror.shopOrderId
- WHERE csa.shopOrderId = #{shopOrderId}
- AND csa.type=5
- AND csa.settleStatus = 0
- AND csa.productType = 3
- AND cror.splitStatus =1
- AND cror.delflag=0
- </select>
- <select id="findShouldPayShopAmount" resultType="java.lang.Double">
- select shouldPayShopAmount from cm_shop_order where shopOrderID = #{shopOrderId}
- </select>
- <select id="findSettleSum" resultType="java.lang.Double">
- SELECT IFNULL(SUM(settleAmount),0) FROM cm_settle_record
- WHERE settleType = 1
- AND shopOrderId = 24665
- </select>
- <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
- select distinct
- csr.settleAmount,csr.shopOrderId,csr.settleTime from cm_settle_record csr
- left join cm_shop_order cso on csr.shopOrderId = cso.shopOrderID
- where cso.orderID=#{orderID}
- and settleType = 2
- </select>
- <select id="findSettleAmount" resultType="java.lang.Double">
- SELECT ifnull(SUM(settleAmount),0)
- FROM cm_settle_record csr
- LEFT JOIN cm_shop_order cso ON csr.shopOrderId = cso.shopOrderId
- WHERE settleType=1
- AND cso.orderId=#{orderID}
- </select>
- <select id="findShopOrderSize" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM cm_shop_order WHERE orderId=#{orderID}
- AND shopId!=998
- </select>
- <insert id="insertSplitAccount">
- INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
- authVipRecordId, type, subUserNo, splitAccount,
- mbOrderId, orderRequestNo, payStatus, productType, shopOrderId ,splitTime)
- VALUES (#{orderId}, #{productId}, #{orderProductId}, #{shopId}, #{couponRecordId}, #{vipRecordId},
- #{authVipRecordId}, #{type}, #{subUserNo}, #{splitAccount},
- #{mbOrderId}, #{orderRequestNo}, #{payStatus}, #{productType},#{shopOrderId}, NOW());
- </insert>
- <insert id="insertPayShop" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_pay_shop (shopID, name, bankAccountName, bankAccount, bankName, type, totalAmount, balancePayFee,
- transferPayFee, payType, wipePayment, wipeRemarks, wipeRemarkImages, wipeTime, applicant,
- applyTime, reviewer, reviewTime, payTime, status, reason, delFlag)
- VALUES (#{shopId}, #{name}, #{bankAccountName}, #{bankAccount}, #{bankName}, #{type}, #{totalAmount}, #{balancePayFee},
- #{transferPayFee}, #{payType}, #{wipePayment}, #{wipeRemarks}, #{wipeRemarkImages}, #{wipeTime}, #{applicant},
- #{applyTime}, #{reviewer}, #{reviewTime}, #{payTime}, #{status}, #{reason}, #{delFlag})
- </insert>
- <insert id="insertPayShopRecord" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_pay_shop_record (shopID, shopOrderID, shopOrderNo, payAmount, wipePayment, payType, payTime, payShopID, status, delFlag)
- VALUES (#{shopId}, #{shopOrderId}, #{shopOrderNo}, #{payAmount}, #{wipePayment}, #{payType}, #{payTime}, #{payShopId}, #{status}, #{delFlag})
- </insert>
- <insert id="insertSettleRecord">
- INSERT INTO cm_settle_record(settleamount, settletype, shoporderid, splitcode, settletime)
- VALUES (#{settleAmount},#{settleType},#{shopOrderId},#{splitCode},now())
- </insert>
- <update id="updateBrokerage">
- UPDATE cm_shop_order SET
- brokerage = #{brokerage}
- WHERE shopOrderID = #{shopOrderID}
- </update>
- </mapper>
|