12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127 |
- <?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.NewShopOrderDao">
- <sql id="shopOrderColumns">
- co.couponAmount as couponAmount,
- co.userBeans as userBeans,
- a.shopOrderID AS shopOrderID,
- a.orderID AS orderID,
- a.organizeID AS organizeID,
- a.shopOrderNo AS shopOrderNo,
- a.orderNo AS orderNo,
- a.userID AS userID,
- a.shopID AS shopID,
- a.itemCount AS itemCount,
- a.townID AS townID,
- a.productAmount AS productAmount,
- a.discountAmount AS discountAmount,
- a.accountAmount AS accountAmount,
- a.totalAmount AS totalAmount,
- a.payFlag AS payFlag,
- a.payTime AS payTime,
- a.finishTime AS finishTime,
- a.refundStatus AS refundStatus,
- a.needPayAmount AS needPayAmount,
- a.canRefundAmount AS canRefundAmount,
- a.refundAmount AS refundAmount,
- a.clubID AS clubID,
- a.spID AS spID,
- a.mainSpID AS mainSpID,
- a.orderBeanAmount AS orderBeanAmount,
- a.useBeanAmount AS useBeanAmount,
- a.useBeanFlag AS useBeanFlag,
- a.canRefundFlag AS canRefundFlag,
- a.useBalanceFlag AS useBalanceFlag,
- a.canRefundBeans AS canRefundBeans,
- a.freePostageFee AS freePostageFee,
- a.freePostageTicketID AS freePostageTicketID,
- a.brokerage AS brokerage,
- a.delFlag AS delFlag,
- a.refundsAmount AS refundsAmount,
- a.orderStatusFlag AS orderStatusFlag,
- a.buyStatus AS buyStatus,
- a.orderSubmitType AS orderSubmitType,
- a.orderType AS orderType,
- a.orderTime AS orderTime,
- a.deliveryTimeMills AS deliveryTimeMills,
- a.presentNum AS presentNum,
- a.preferential AS preferential,
- a.outStoreNum AS outStoreNum,
- IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
- a.splitFlag AS splitFlag,
- a.autoReceiveTimeMills AS autoReceiveTimeMills,
- a.autoOverTimeMills AS autoOverTimeMills,
- a.receiveGoodsTime AS receiveGoodsTime,
- a.totalAddedValueTax AS totalAddedValueTax,
- a.note AS note,
- a.payStatus AS payStatus,
- a.sendOutStatus AS sendOutStatus,
- a.shopProductAmount AS shopProductAmount,
- a.shopPostFee AS shopPostFee,
- a.shopTaxFee AS shopTaxFee,
- a.shouldPayShopAmount AS shouldPayShopAmount,
- a.payedShopAmount AS payedShopAmount,
- a.shopOtherFee AS shopOtherFee,
- a.paying AS paying,
- a.costType AS costType,
- a.modifyShouldPayNote AS modifyShouldPayNote,
- a.orderPromotionsId AS orderPromotionsId,
- a.differenceType AS differenceType,
- a.differencePrice AS differencePrice,
- a.proportional AS proportional,
- a.promotionFullReduction As promotionFullReduction,
- a.zeroCostFlag AS zeroCostFlag
- </sql>
- <select id="get" resultType="NewShopOrder" useCache="false" flushCache="true">
- select
- <include refid="shopOrderColumns"/>
- from cm_shop_order a
- left join cm_order co on co.orderID = a.orderID
- where a.shopOrderID = #{shopOrderID}
- </select>
- <delete id="deleteByOrderID">
- DELETE
- FROM cm_shop_order
- WHERE orderID = #{orderID}
- </delete>
- <insert id="insert" parameterType="NewShopOrder" keyProperty="shopOrderID" useGeneratedKeys="true">
- INSERT INTO cm_shop_order(orderID,
- shopOrderNo,
- orderNo,
- userID,
- shopID,
- itemCount,
- townID,
- productAmount,
- discountAmount,
- accountAmount,
- totalAmount,
- payFlag,
- payTime,
- finishTime,
- refundStatus,
- needPayAmount,
- canRefundAmount,
- refundAmount,
- clubID,
- spID,
- mainSpID,
- orderBeanAmount,
- useBeanAmount,
- useBeanFlag,
- canRefundFlag,
- useBalanceFlag,
- canRefundBeans,
- freePostageFee,
- freePostageTicketID,
- brokerage,
- delFlag,
- refundsAmount,
- orderStatusFlag,
- buyStatus,
- orderSubmitType,
- orderType,
- orderTime,
- deliveryTimeMills,
- presentNum,
- preferential,
- splitFlag,
- autoReceiveTimeMills,
- autoOverTimeMills,
- totalAddedValueTax,
- receiveGoodsTime,
- sendOutStatus,
- payStatus,
- costType,
- orderPromotionsId,
- promotionFullReduction,
- zeroCostFlag,
- svipShopReduction)
- VALUES (#{orderID},
- #{shopOrderNo},
- #{orderNo},
- #{userID},
- #{shopID},
- #{itemCount},
- #{townID},
- #{productAmount},
- #{discountAmount},
- #{accountAmount},
- #{totalAmount},
- #{payFlag},
- #{payTime},
- #{finishTime},
- #{refundStatus},
- #{needPayAmount},
- #{canRefundAmount},
- #{refundAmount},
- #{clubID},
- #{spID},
- #{mainSpID},
- #{orderBeanAmount},
- #{useBeanAmount},
- #{useBeanFlag},
- #{canRefundFlag},
- #{useBalanceFlag},
- #{canRefundBeans},
- #{freePostageFee},
- #{freePostageTicketID},
- #{brokerage},
- #{delFlag},
- #{refundsAmount},
- #{orderStatusFlag},
- #{buyStatus},
- #{orderSubmitType},
- #{orderType},
- #{orderTime},
- #{deliveryTimeMills},
- #{presentNum},
- #{preferential},
- #{splitFlag},
- #{autoReceiveTimeMills},
- #{autoOverTimeMills},
- #{totalAddedValueTax},
- #{receiveGoodsTime},
- #{sendOutStatus},
- #{payStatus},
- #{costType},
- #{orderPromotionsId},
- #{promotionFullReduction},
- #{zeroCostFlag},
- #{svipShopReduction})
- </insert>
- <select id="findByShopOrderID" resultType="newShopOrder">
- select
- <include refid="shopOrderColumns"/>
- from cm_shop_order a
- left join cm_order co on co.orderID = a.orderID
- where a.shopOrderID = #{shopOrderID}
- </select>
- <select id="findList" resultType="newShopOrder">
- SELECT
- <include refid="shopOrderColumns"/>
- FROM cm_shop_order a
- left join cm_order co on co.orderID = a.orderID
- <where>
- <if test="shopOrderNo != null and itemCount != ''">
- AND a.shopOrderNo = #{shopOrderNo}
- </if>
- <if test="orderNo != null and itemCount != ''">
- AND a.orderNo = #{orderNo}
- </if>
- <if test="orderID != null and itemCount != ''">
- AND a.orderID = #{orderID}
- </if>
- <if test="userID != null and itemCount != ''">
- AND a.userID = #{userID}
- </if>
- <if test="shopID != null and itemCount != ''">
- AND a.shopID = #{shopID}
- </if>
- <if test="payFlag != null and itemCount != ''">
- AND a.payFlag = #{payFlag}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findListByOrderID" resultType="newShopOrder">
- SELECT<include refid="shopOrderColumns"/>,
- b.name as shopName,
- oa.id as orderArchiveId,
- co.receiptStatus
- FROM cm_shop_order a
- left join shop b on a.shopID = b.shopID
- left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
- left join cm_order co on co.orderID = a.orderID
- WHERE a.orderID = #{orderID} ORDER BY a.shopOrderNo DESC
- </select>
- <update id="update" parameterType="newShopOrder">
- update cm_shop_order
- <set>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- shopOrderNo = #{shopOrderNo},
- </if>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- orderID = #{orderID},
- </if>
- <if test="orderNo != null and orderNo != ''">
- orderNo = #{orderNo},
- </if>
- <if test="userID != null and userID != ''">
- userID = #{userID},
- </if>
- <if test="shopID != null and shopID != ''">
- shopID = #{shopID},
- </if>
- <if test="itemCount != null and itemCount != ''">
- itemCount = #{itemCount},
- </if>
- <if test="townID != null and itemCount != ''">
- townID = #{townID,jdbcType=INTEGER},
- </if>
- <if test="productAmount != null and productAmount != ''">
- productAmount = #{productAmount},
- </if>
- <if test="discountAmount != null and discountAmount != ''">
- discountAmount = #{discountAmount},
- </if>
- <if test="accountAmount != null and accountAmount != ''">
- accountAmount = #{accountAmount},
- </if>
- <if test="totalAmount != null and totalAmount != ''">
- totalAmount = #{totalAmount},
- </if>
- <if test="payFlag != null and payFlag != ''">
- payFlag = #{payFlag},
- </if>
- <if test="payTime != null and payTime != ''">
- payTime = #{payTime},
- </if>
- <if test="finishTime != null and finishTime != ''">
- finishTime = #{finishTime},
- </if>
- <if test="refundStatus != null and refundStatus != ''">
- refundStatus = #{refundStatus},
- </if>
- <if test="needPayAmount != null and needPayAmount != ''">
- needPayAmount = #{needPayAmount},
- </if>
- <if test="canRefundAmount != null and canRefundAmount != ''">
- canRefundAmount = #{canRefundAmount},
- </if>
- <if test="refundAmount != null and refundAmount != ''">
- refundAmount = #{refundAmount},
- </if>
- <if test="clubID != null and clubID != ''">
- clubID = #{clubID},
- </if>
- <if test="spID != null and itemCount != ''">
- spID = #{spID,jdbcType=INTEGER},
- </if>
- <if test="mainSpID != null and mainSpID != ''">
- mainSpID = #{mainSpID},
- </if>
- <if test="orderBeanAmount != null and orderBeanAmount != ''">
- orderBeanAmount = #{orderBeanAmount},
- </if>
- <if test="useBeanAmount != null and useBeanAmount != ''">
- useBeanAmount = #{useBeanAmount},
- </if>
- <if test="useBeanFlag != null and useBeanFlag != ''">
- useBeanFlag = #{useBeanFlag},
- </if>
- <if test="canRefundFlag != null and canRefundFlag != ''">
- canRefundFlag = #{canRefundFlag},
- </if>
- <if test="useBalanceFlag != null and useBalanceFlag != ''">
- useBalanceFlag = #{useBalanceFlag},
- </if>
- <if test="canRefundBeans != null and canRefundBeans != ''">
- canRefundBeans = #{canRefundBeans},
- </if>
- <if test="freePostageFee != null and freePostageFee != ''">
- freePostageFee = #{freePostageFee},
- </if>
- <if test="freePostageTicketID != null and freePostageTicketID != ''">
- freePostageTicketID = #{freePostageTicketID},
- </if>
- <if test="brokerage != null and brokerage != ''">
- brokerage = #{brokerage},
- </if>
- <if test="delFlag != null and delFlag != ''">
- delFlag = #{delFlag},
- </if>
- <if test="refundsAmount != null and refundsAmount != ''">
- refundsAmount = #{refundsAmount},
- </if>
- <if test="orderStatusFlag != null and orderStatusFlag != ''">
- orderStatusFlag = #{orderStatusFlag},
- </if>
- <if test="buyStatus != null and buyStatus != ''">
- buyStatus = #{buyStatus},
- </if>
- <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
- deliveryTimeMills = #{deliveryTimeMills},
- </if>
- <if test="orderSubmitType != null and orderSubmitType != ''">
- orderSubmitType = #{orderSubmitType},
- </if>
- <if test="orderType != null and orderType != ''">
- orderType = #{orderType},
- </if>
- <if test="orderTime != null and orderTime != ''">
- orderTime = #{orderTime},
- </if>
- <if test="presentNum != null and presentNum != ''">
- presentNum = #{presentNum},
- </if>
- <if test="preferential != null and preferential != ''">
- preferential = #{preferential},
- </if>
- <if test="outStoreNum != null and outStoreNum != ''">
- outStoreNum = #{outStoreNum},
- </if>
- <if test="outStoreTimes != null and outStoreTimes != ''">
- outStoreTimes = #{outStoreTimes},
- </if>
- <if test="splitFlag != null and splitFlag != ''">
- splitFlag = #{splitFlag},
- </if>
- <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
- autoReceiveTimeMills = #{autoReceiveTimeMills},
- </if>
- <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
- autoOverTimeMills = #{autoOverTimeMills},
- </if>
- <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
- receiveGoodsTime = #{receiveGoodsTime},
- </if>
- <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
- totalAddedValueTax = #{totalAddedValueTax},
- </if>
- <if test="note != null and note != ''">
- note = #{note},
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- sendOutStatus = #{sendOutStatus},
- </if>
- <if test="paying != null and paying != ''">
- paying = #{paying},
- </if>
- <if test="shopProductAmount != null">
- shopProductAmount = #{shopProductAmount},
- </if>
- <if test="shopPostFee != null">
- shopPostFee = #{shopPostFee},
- </if>
- <if test="shopTaxFee != null">
- shopTaxFee = #{shopTaxFee},
- </if>
- <if test="shouldPayShopAmount != null">
- shouldPayShopAmount = #{shouldPayShopAmount},
- </if>
- <if test="payedShopAmount != null">
- payedShopAmount = #{payedShopAmount},
- </if>
- <if test="shopOtherFee != null">
- shopOtherFee = #{shopOtherFee},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus},
- </if>
- <if test="costType != null">
- costType = #{costType},
- </if>
- <if test="proportional != null">
- proportional = #{proportional},
- </if>
- <if test="modifyShouldPayNote != null">
- modifyShouldPayNote = #{modifyShouldPayNote},
- </if>
- <if test="modifyShouldPayUserID != null">
- modifyShouldPayUserID = #{modifyShouldPayUserID},
- </if>
- <if test="modifyShouldPayDate != null">
- modifyShouldPayDate = #{modifyShouldPayDate},
- </if>
- <if test="orderPromotionsId != null">
- orderPromotionsId = #{orderPromotionsId},
- </if>
- <if test="promotionFullReduction != null">
- promotionFullReduction = #{promotionFullReduction},
- </if>
- <if test="zeroCostFlag != null">
- zeroCostFlag = #{zeroCostFlag},
- </if>
- <if test="svipShopReduction != null">
- svipShopReduction = #{svipShopReduction}
- </if>
- </set>
- <where>
- <if test="shopOrderID != null and shopOrderID != ''">
- AND shopOrderID = #{shopOrderID}
- </if>
- <if test="orderID != null and orderID != ''">
- AND orderID = #{orderID}
- </if>
- </where>
- </update>
- <delete id="delete">
- DELETE
- FROM cm_shop_order
- WHERE shopOrderID = #{shopOrderID}
- </delete>
- <insert id="shopOrderBak" parameterType="NewShopOrder" keyProperty="shopOrderBakID" useGeneratedKeys="true">
- INSERT INTO cm_shop_order_bak(orderID,
- shopOrderNo,
- orderNo,
- userID,
- shopID,
- itemCount,
- townID,
- productAmount,
- discountAmount,
- accountAmount,
- totalAmount,
- payFlag,
- payTime,
- finishTime,
- refundStatus,
- needPayAmount,
- canRefundAmount,
- refundAmount,
- clubID,
- spID,
- mainSpID,
- orderBeanAmount,
- useBeanAmount,
- useBeanFlag,
- canRefundFlag,
- useBalanceFlag,
- canRefundBeans,
- freePostageFee,
- freePostageTicketID,
- brokerage,
- delFlag,
- refundsAmount,
- orderStatusFlag,
- buyStatus,
- orderSubmitType,
- orderType,
- orderTime,
- deliveryTimeMills,
- presentNum,
- preferential)
- VALUES (#{orderID},
- #{shopOrderNo},
- #{orderNo},
- #{userID},
- #{shopID},
- #{itemCount},
- #{townID},
- #{productAmount},
- #{discountAmount},
- #{accountAmount},
- #{totalAmount},
- #{payFlag},
- #{payTime},
- #{finishTime},
- #{refundStatus},
- #{needPayAmount},
- #{canRefundAmount},
- #{refundAmount},
- #{clubID},
- #{spID},
- #{mainSpID},
- #{orderBeanAmount},
- #{useBeanAmount},
- #{useBeanFlag},
- #{canRefundFlag},
- #{useBalanceFlag},
- #{canRefundBeans},
- #{freePostageFee},
- #{freePostageTicketID},
- #{brokerage},
- #{delFlag},
- #{refundsAmount},
- #{orderStatusFlag},
- #{buyStatus},
- #{orderSubmitType},
- #{orderType},
- #{orderTime},
- #{deliveryTimeMills},
- #{presentNum},
- #{preferential})
- </insert>
- <update id="updateOrderStatus">
- UPDATE bp_order
- SET status = #{orderStatus}
- WHERE id = #{orderId}
- </update>
- <select id="findIDsByOrderID" resultType="int">
- select shopOrderID
- from cm_shop_order
- where orderID = #{orderID}
- </select>
- <update id="updateNote">
- UPDATE cm_shop_order
- SET note = #{note}
- WHERE shopOrderID = #{shopOrderID}
- </update>
- <select id="findShopOrderNum" resultType="int">
- select count(1)
- from cm_shop_order
- where orderID = #{orderID}
- </select>
- <update id="updateByShopOrderID" parameterType="newShopOrder">
- update cm_shop_order
- <set>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- shopOrderNo = #{shopOrderNo},
- </if>
- <if test="orderID != null and orderID != ''">
- orderID = #{orderID},
- </if>
- <if test="orderNo != null and orderNo != ''">
- orderNo = #{orderNo},
- </if>
- <if test="userID != null and userID != ''">
- userID = #{userID},
- </if>
- <if test="shopID != null and shopID != ''">
- shopID = #{shopID},
- </if>
- <if test="itemCount != null and itemCount != ''">
- itemCount = #{itemCount},
- </if>
- <if test="townID != null and itemCount != ''">
- townID = #{townID,jdbcType=INTEGER},
- </if>
- <if test="productAmount != null and productAmount != ''">
- productAmount = #{productAmount},
- </if>
- <if test="discountAmount != null and discountAmount != ''">
- discountAmount = #{discountAmount},
- </if>
- <if test="accountAmount != null and accountAmount != ''">
- accountAmount = #{accountAmount},
- </if>
- <if test="totalAmount != null and totalAmount != ''">
- totalAmount = #{totalAmount},
- </if>
- <if test="payFlag != null and payFlag != ''">
- payFlag = #{payFlag},
- </if>
- <if test="payTime != null and payTime != ''">
- payTime = #{payTime},
- </if>
- <if test="finishTime != null and finishTime != ''">
- finishTime = #{finishTime},
- </if>
- <if test="refundStatus != null and refundStatus != ''">
- refundStatus = #{refundStatus},
- </if>
- <if test="needPayAmount != null and needPayAmount != ''">
- needPayAmount = #{needPayAmount},
- </if>
- <if test="canRefundAmount != null and canRefundAmount != ''">
- canRefundAmount = #{canRefundAmount},
- </if>
- <if test="refundAmount != null and refundAmount != ''">
- refundAmount = #{refundAmount},
- </if>
- <if test="clubID != null and clubID != ''">
- clubID = #{clubID},
- </if>
- <if test="spID != null and itemCount != ''">
- spID = #{spID,jdbcType=INTEGER},
- </if>
- <if test="mainSpID != null and mainSpID != ''">
- mainSpID = #{mainSpID},
- </if>
- <if test="orderBeanAmount != null and orderBeanAmount != ''">
- orderBeanAmount = #{orderBeanAmount},
- </if>
- <if test="useBeanAmount != null and useBeanAmount != ''">
- useBeanAmount = #{useBeanAmount},
- </if>
- <if test="useBeanFlag != null and useBeanFlag != ''">
- useBeanFlag = #{useBeanFlag},
- </if>
- <if test="canRefundFlag != null and canRefundFlag != ''">
- canRefundFlag = #{canRefundFlag},
- </if>
- <if test="useBalanceFlag != null and useBalanceFlag != ''">
- useBalanceFlag = #{useBalanceFlag},
- </if>
- <if test="canRefundBeans != null and canRefundBeans != ''">
- canRefundBeans = #{canRefundBeans},
- </if>
- <if test="freePostageFee != null and freePostageFee != ''">
- freePostageFee = #{freePostageFee},
- </if>
- <if test="freePostageTicketID != null and freePostageTicketID != ''">
- freePostageTicketID = #{freePostageTicketID},
- </if>
- <if test="brokerage != null and brokerage != ''">
- brokerage = #{brokerage},
- </if>
- <if test="delFlag != null and delFlag != ''">
- delFlag = #{delFlag},
- </if>
- <if test="refundsAmount != null and refundsAmount != ''">
- refundsAmount = #{refundsAmount},
- </if>
- <if test="orderStatusFlag != null and orderStatusFlag != ''">
- orderStatusFlag = #{orderStatusFlag},
- </if>
- <if test="buyStatus != null and buyStatus != ''">
- buyStatus = #{buyStatus},
- </if>
- <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
- deliveryTimeMills = #{deliveryTimeMills},
- </if>
- <if test="orderSubmitType != null and orderSubmitType != ''">
- orderSubmitType = #{orderSubmitType},
- </if>
- <if test="orderType != null and orderType != ''">
- orderType = #{orderType},
- </if>
- <if test="orderTime != null and orderTime != ''">
- orderTime = #{orderTime},
- </if>
- <if test="presentNum != null and presentNum != ''">
- presentNum = #{presentNum},
- </if>
- <if test="preferential != null and preferential != ''">
- preferential = #{preferential},
- </if>
- <if test="outStoreNum != null and outStoreNum != ''">
- outStoreNum = #{outStoreNum},
- </if>
- <if test="outStoreTimes != null and outStoreTimes != ''">
- outStoreTimes = #{outStoreTimes},
- </if>
- <if test="splitFlag != null and splitFlag != ''">
- splitFlag = #{splitFlag},
- </if>
- <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
- autoReceiveTimeMills = #{autoReceiveTimeMills},
- </if>
- <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
- autoOverTimeMills = #{autoOverTimeMills},
- </if>
- <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
- receiveGoodsTime = #{receiveGoodsTime},
- </if>
- <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
- totalAddedValueTax = #{totalAddedValueTax},
- </if>
- <if test="note != null and note != ''">
- note = #{note},
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- sendOutStatus = #{sendOutStatus}
- </if>
- </set>
- where shopOrderID = #{shopOrderID}
- </update>
- <select id="findPayOrderList" resultType="newShopOrder">
- select<include refid="shopOrderColumns"/>,
- co.payTotalFee AS payTotalFee,
- co.status AS status,
- bou.name AS buyer,
- s.name AS shopName,
- c.name AS clubName
- from cm_shop_order a
- left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
- left join bp_order_userinfo bou on bou.orderId = a.orderID
- left join cm_order co on co.orderID = a.orderID
- left join shop s on s.shopID = a.shopID
- LEFT JOIN club c ON c.userID = a.userID
- <where>
- <if test="startTime != null and startTime != ''">
- AND (a.orderTime > #{startTime} OR a.orderTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (a.orderTime < #{endTime} OR a.orderTime = #{endTime})
- </if>
- <if test="orderID != null and orderID != ''">
- AND a.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 a.orderNo like concat('%', #{orderNo} ,'%')
- </if>
- <if test="ps != null and ps.length>0 ">
- AND a.payStatus in
- <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </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="shopOrderID != null and shopOrderID != ''">
- AND a.shopOrderID = #{shopOrderID}
- </if>
- <if test="shopOrderNo != null and shopOrderNo != ''">
- AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
- </if>
- and (co.confirmFlag = '1' or co.confirmFlag = '2')
- <if test="operatingMode != null and operatingMode == '1'.toString()">
- and a.payStatus != 3 and co.status NOT IN (6,7)
- </if>
- <if test="operatingMode != null and operatingMode == '2'.toString()">
- and a.payStatus != 1 and co.status != 6
- </if>
- <if test="operatingMode != null and operatingMode == '3'.toString()">
- and a.payStatus = 3 and co.status NOT IN (6,7)
- </if>
- and co.delFlag = 0
- and a.delFlag = 0
- and a.shopID != 998
- and co.orderID not in (
- SELECT orderID FROM cm_order_product WHERE productID IN
- (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
- )
- </where>
- group by a.shopOrderID
- ORDER BY a.shopOrderID DESC
- </select>
- <select id="findPayOrderListByIDs" resultType="newShopOrder">
- select distinct<include refid="shopOrderColumns"/>,
- co.payTotalFee AS payTotalFee,
- bou.name AS buyer,
- s.name AS shopName
- from cm_shop_order a
- left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
- left join bp_order_userinfo bou on bou.orderId = a.orderID
- left join cm_order co on co.orderID = a.orderID
- left join shop s on s.shopID = a.shopID
- <where>
- <if test="ids != null and ids != ''">
- and a.shopOrderID in
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- ORDER BY a.shopOrderID DESC
- </select>
- <select id="findByRefundID" resultType="newShopOrder">
- select distinct<include refid="shopOrderColumns"/>,
- co.payTotalFee AS payTotalFee,
- bou.name AS buyer,
- s.name AS shopName
- from cm_shop_order a
- left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
- left join bp_order_userinfo bou on bou.orderId = a.orderID
- left join cm_order co on co.orderID = a.orderID
- left join shop s on s.shopID = a.shopID
- where a.shopOrderID in
- (select crsr.shopOrderID
- from cm_refund_shop_record crsr
- left join cm_refund_shop crs on crsr.refundShopID = crs.id
- where crs.id = #{refundShopID} and crsr.shopOrderID is not null)
- ORDER BY a.shopOrderID DESC
- </select>
- <select id="updatePayShopAmount">
- UPDATE cm_shop_order
- <set>
- <if test="shopProductAmount != null">
- shopProductAmount = #{shopProductAmount},
- </if>
- <if test="shopPostFee != null">
- shopPostFee = #{shopPostFee},
- </if>
- <if test="shopTaxFee != null">
- shopTaxFee = #{shopTaxFee},
- </if>
- <if test="shouldPayShopAmount != null">
- shouldPayShopAmount = #{shouldPayShopAmount},
- </if>
- <if test="shopOtherFee != null">
- shopOtherFee = #{shopOtherFee},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus},
- </if>
- <if test="payedShopAmount != null">
- payedShopAmount = #{payedShopAmount}
- </if>
- </set>
- WHERE shopOrderID = #{shopOrderID}
- </select>
- <select id="findByShopOrderIDs" resultType="newShopOrder">
- select distinct<include refid="shopOrderColumns"/>,
- co.payTotalFee AS payTotalFee,
- bou.name AS buyer,
- s.name AS shopName,
- c.name AS clubName
- from cm_shop_order a
- left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
- left join bp_order_userinfo bou on bou.orderId = a.orderID
- left join cm_order co on co.orderID = a.orderID
- left join shop s on s.shopID = a.shopID
- left join club c on c.userID = a.userID
- <if test="shopOrderIDs != null and shopOrderIDs.size() > 0">
- where a.shopOrderID in
- <foreach collection="shopOrderIDs" separator="," item="shopOrderID" open="(" close=")">
- #{shopOrderID}
- </foreach>
- </if>
- </select>
- <update id="updatePaying">
- update cm_shop_order
- set paying = #{paying}
- where shopOrderID = #{shopOrderID}
- </update>
- <update id="outPaying">
- update cm_shop_order
- set paying = '0'
- where shopOrderID in
- (select cpsr.shopOrderID
- from cm_pay_shop_record cpsr
- left join cm_pay_shop cps on cps.id = cpsr.payShopID
- where cps.id = #{payShopID}
- and cps.delFlag = '0'
- and cpsr.delFlag = '0'
- and cpsr.shopOrderID is not null)
- </update>
- <update id="inPaying">
- update cm_shop_order
- set paying = '1'
- where shopOrderID in
- (select cpsr.shopOrderID
- from cm_pay_shop_record cpsr
- left join cm_pay_shop cps on cps.id = cpsr.payShopID
- where cps.id = #{payShopID}
- and cps.delFlag = '0'
- and cpsr.delFlag = '0'
- and cpsr.shopOrderID is not null)
- </update>
- <update id="updatePayStatus">
- update cm_shop_order
- set payStatus = #{payStatus}
- where shopOrderID = #{shopOrderID}
- </update>
- <select id="findPayStatusByOrderID" resultType="string">
- select payStatus
- from cm_shop_order
- where orderID = #{orderID}
- </select>
- <select id="getPayingStatus" resultType="string">
- select ifnull(paying, '0')
- from cm_shop_order
- where shopOrderID in
- (select cpsr.shopOrderID
- from cm_pay_shop_record cpsr
- left join cm_pay_shop cps on cps.id = cpsr.payShopID
- where cps.id = #{payShopID}
- and cps.delFlag = '0'
- and cpsr.delFlag = '0'
- and cpsr.shopOrderID is not null)
- </select>
- <select id="findSiblingPostFeeOrder" resultType="newShopOrder">
- select
- <include refid="shopOrderColumns"/>
- from cm_shop_order a
- left join cm_order co on co.orderID = a.orderID
- where a.orderID = #{orderID} and a.shopID = 998
- </select>
- <select id="findShopOrderNos" resultType="java.lang.String">
- SELECT CONCAT(shopOrderNo, '(', shopOrderID, ')') AS result
- FROM cm_shop_order
- WHERE orderID = #{orderID}
- and shopId != 998
- </select>
- <select id="findIncome" resultType="java.lang.Double">
- SELECT ROUND(IFNULL((
- co.payTotalFee - (IFNULL((
- SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
- (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
- IFNULL(op.shouldPayTotalTax, 0)),
- 2)
- FROM cm_order_product op
- LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
- WHERE cso.orderID = co.orderID
- AND op.productID != 999
- GROUP BY cso.orderID
- ), 0))
- - (SELECT IFNULL(SUM(cso.shopOtherFee), 0)
- FROM cm_shop_order cso
- WHERE cso.orderID = co.orderID)
- - IFNULL((SELECT SUM(shopPostFee + IF(differenceType = 1, differencePrice, 0) -
- IF(differenceType = 2, differencePrice, 0))
- FROM cm_shop_order
- WHERE orderID = co.orderID), 0)
- + IFNULL((SELECT SUM(cpsr.wipePayment)
- FROM cm_pay_shop_record cpsr
- WHERE cpsr.shopOrderID IN (SELECT cso.shopOrderID
- FROM cm_shop_order cso
- WHERE cso.orderID = co.orderID)
- AND cpsr.delFlag = 0
- AND (cpsr.`status` = 1 OR cpsr.`status` = 0)), 0)
- ), 0), 2) AS "采美总佣金"
- FROM cm_order co
- WHERE co.orderID = #{orderID}
- </select>
- <update id="updateByShopOtherFee">
- UPDATE cm_shop_order
- SET shopOtherFee = #{shopOtherFee}
- WHERE shopOrderID = #{shopOrderId}
- </update>
- <update id="updateByDifferencePrice">
- UPDATE cm_shop_order
- SET differenceType = #{type},
- differencePrice = #{differencePrice}
- WHERE shopOrderID = #{shopOrderId}
- </update>
- <select id="findSplitList" resultType="newShopOrder">
- SELECT
- co.couponAmount AS couponAmount,
- co.userBeans AS userBeans,
- a.shopOrderID AS shopOrderID,
- a.orderID AS orderID,
- a.organizeID AS organizeID,
- a.shopOrderNo AS shopOrderNo,
- a.orderNo AS orderNo,
- a.userID AS userID,
- a.shopID AS shopID,
- a.itemCount AS itemCount,
- a.townID AS townID,
- a.productAmount AS productAmount,
- a.discountAmount AS discountAmount,
- a.accountAmount AS accountAmount,
- a.totalAmount AS totalAmount,
- a.payFlag AS payFlag,
- a.payTime AS payTime,
- a.finishTime AS finishTime,
- a.refundStatus AS refundStatus,
- a.needPayAmount AS needPayAmount,
- a.canRefundAmount AS canRefundAmount,
- a.refundAmount AS refundAmount,
- a.clubID AS clubID,
- a.spID AS spID,
- a.mainSpID AS mainSpID,
- a.orderBeanAmount AS orderBeanAmount,
- a.useBeanAmount AS useBeanAmount,
- a.useBeanFlag AS useBeanFlag,
- a.canRefundFlag AS canRefundFlag,
- a.useBalanceFlag AS useBalanceFlag,
- a.canRefundBeans AS canRefundBeans,
- a.freePostageFee AS freePostageFee,
- a.freePostageTicketID AS freePostageTicketID,
- a.brokerage AS brokerage,
- a.delFlag AS delFlag,
- a.refundsAmount AS refundsAmount,
- a.orderStatusFlag AS orderStatusFlag,
- a.buyStatus AS buyStatus,
- a.orderSubmitType AS orderSubmitType,
- a.orderType AS orderType,
- a.orderTime AS orderTime,
- a.deliveryTimeMills AS deliveryTimeMills,
- a.presentNum AS presentNum,
- a.preferential AS preferential,
- a.outStoreNum AS outStoreNum,
- IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
- a.splitFlag AS splitFlag,
- a.autoReceiveTimeMills AS autoReceiveTimeMills,
- a.autoOverTimeMills AS autoOverTimeMills,
- a.receiveGoodsTime AS receiveGoodsTime,
- a.totalAddedValueTax AS totalAddedValueTax,
- a.note AS note,
- a.payStatus AS payStatus,
- a.sendOutStatus AS sendOutStatus,
- a.shopProductAmount AS shopProductAmount,
- a.shopPostFee AS shopPostFee,
- a.shopTaxFee AS shopTaxFee,
- a.shouldPayShopAmount AS shouldPayShopAmount,
- a.payedShopAmount AS payedShopAmount,
- a.shopOtherFee AS shopOtherFee,
- a.paying AS paying,
- a.costType AS costType,
- a.modifyShouldPayNote AS modifyShouldPayNote,
- a.orderPromotionsId AS orderPromotionsId,
- a.differenceType AS differenceType,
- a.differencePrice AS differencePrice,
- a.proportional AS proportional,
- a.promotionFullReduction AS promotionFullReduction,
- a.zeroCostFlag AS zeroCostFlag,
- co.payTotalFee AS payTotalFee,
- co.status AS STATUS,
- bou.name AS buyer,
- s.name AS shopName,
- c.name AS clubName
- FROM cm_shop_order a
- LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
- LEFT JOIN cm_order co ON co.orderID = a.orderID
- LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- LEFT JOIN shop s ON s.shopID = a.shopID
- LEFT JOIN club c ON c.userID = a.userID
- WHERE
- co.organizeID = 0
- AND co.orderType != 2
- AND co.refundType != 2
- AND co.delFlag = 0
- AND a.delFlag = 0
- AND a.shopID != 998
- AND cdr.payWay = 1
- AND cdr.receiptDate <![CDATA[ <= ]]> NOW()
- AND cror.relationType = 2
- AND cror.delFlag = 0
- AND cror.mbOrderId IS NOT NULL
- AND cror.splitStatus = 0
- AND co.orderID NOT IN (
- SELECT orderID FROM cm_order_product WHERE productID IN
- (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
- )
- GROUP BY a.shopOrderID
- ORDER BY a.shopOrderID DESC
- </select>
- <select id="getOpenidListByPermission" resultType="java.lang.String">
- SELECT DISTINCT cm.crmopenid FROM `cm_mall_operation_user` cm
- LEFT JOIN `user` u ON u.userID = cm.userID
- WHERE u.userID=#{userid} AND cm.unionId= #{unionid}
- </select>
- <select id="getOpenidunionId" resultType="java.lang.String">
- SELECT DISTINCT cm.unionId FROM `cm_mall_operation_user` cm
- LEFT JOIN `user` u ON u.userID = cm.userID
- WHERE u.userID=#{userid} AND cm.id=1068
- </select>
- <select id="getProductOrder" resultType="java.lang.String">
- SELECT productID FROM `cm_order_product` WHERE orderId=#{orderid}
- </select>
- </mapper>
|