123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500 |
- <?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">
- <resultMap id="cmOrderPaymentVoucherVoResult" type="com.caimei.modules.order.entity.CmOrderPaymentVoucherVo">
- <id property="id" column="id" />
- <result property="orderId" column="orderId" />
- <result property="remarks" column="remarks" />
- <result property="addTime" column="addTime" />
- <collection property="images" javaType="java.util.List" resultMap="cmVoucherImageResult" />
- </resultMap>
- <resultMap id="cmVoucherImageResult" type="com.caimei.modules.order.entity.CmVoucherImage">
- <id property="id" column="i.id" />
- <result property="voucherId" column="v.id"/>
- <result property="image" column="image" />
- </resultMap>
- <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.closeTime AS closeTime,
- 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.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,
- c.clubID AS clubID,
- 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,
- p.returnGoodsStutas as returnGoodsStutas,
- (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.closeTime AS closeTime,
- co.closeReason AS closeReason,
- 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="clubID == 0">
- AND c.clubID = #{clubID}
- </if>
- <if test="userID != null and userID != ''">
- AND u.userID = #{userID}
- </if>
- <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 != ''">
- <if test="rebateOrder == 1">
- AND co.rebateFlag = '1'
- </if>
- <if test="rebateOrder == 0">
- AND co.rebateFlag = '0'
- </if>
- </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>
- GROUP BY co.orderID
- <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},
- closeTime = NOW(),
- closeReason = #{closeReason}
- 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,co.rebateFlag AS rebateOrder
- 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 co.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
- left join cm_shop_order cso on cso.orderId = cror.orderID
- LEFT JOIN cm_order_product cop ON co.shopOrderIDs = cop.shopOrderID
- LEFT JOIN product p ON cop.productID = p.productID
- WHERE cror.relationType = 2
- <if test="shopOrderIds !=null and shopOrderIds !=''">
- and cror.shopOrderId=#{shopOrderIds}
- </if>
- AND cso.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
- AND p.splitCode != 'E1807059160'
- </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 = #{shopOrderId}
- </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 = #{shopOrderId}
- </select>
- <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
- select distinct csr.settleAmount,
- csr.shopOrderId,
- csr.settleTime,
- csr.settleType
- from cm_settle_record csr
- left join cm_shop_order cso on csr.shopOrderId = cso.shopOrderID
- where cso.orderID = #{orderID}
- </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>
- <select id="findSplitCount" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM cm_split_account
- WHERE orderid = #{orderID}
- </select>
- <select id="getSplitRecord" resultType="com.caimei.modules.order.entity.SplitAccountPo">
- select orderId, shopOrderId, splitTime, productType, splitAccount
- from cm_split_account
- where orderId = #{orderId}
- </select>
- <select id="getSplitTime" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM cm_split_account WHERE shopOrderId=#{shopOrderId}
- AND DATE_ADD(splitTime,INTERVAL 1 DAY) <![CDATA[ < ]]> now()
- </select>
- <select id="findVoucherVoOrderID" resultMap="cmOrderPaymentVoucherVoResult">
- -- SELECT * from cm_order_payment_voucher v
- SELECT v.*,i.* from cm_order_payment_voucher v
- LEFT JOIN cm_voucher_image i on i.voucherId=v.id
- where orderId = #{orderId}
- </select>
- <select id="findCmVoucherImageoOrderID" resultType="com.caimei.modules.order.entity.CmVoucherImage">
- SELECT * from cm_voucher_image
- where voucherId = #{id}
- </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>
|