123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863 |
- <?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.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.payWay AS payWay,
- a.orderSource AS orderSource,
- a.orderTime AS orderTime,
- a.confirmTime AS confirmTime,
- a.productCount AS productCount,
- a.presentCount AS presentCount,
- a.cooFreeFlag AS cooFreeFlag,
- a.cooFreeRate AS cooFreeRate,
- a.cooFreeAmount AS cooFreeAmount,
- 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,
- a.onlinePayFlag 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
- </sql>
- <select id="get" resultType="newOrder">
- SELECT <include refid="columns"/>
- FROM cm_order a
- 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="payWay" property="payWay"/>
- <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.payWay AS payWay,
- 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 linkMan1 end from serviceprovider where serviceProviderID = co.spID)
- else
- ''
- end) AS spName,
- co.rebateFlag AS rebateFlag
- 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
- <where>
- co.orderType != 2
- <if test="orderID != null and orderID != ''">
- AND co.orderID = #{orderID}
- </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>
- 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.status AS status,
- 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,
- cs.status AS status
- 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(
- orderNo,
- userID,
- buyUserID,
- shopOrderIDs,
- orderSubmitType,
- orderType,
- secondHandOrderFlag,
- status,
- payFlag,
- onlinePayFlag,
- productTotalFee,
- orderTotalFee,
- payTotalFee,
- balancePayFee,
- discountFee,
- spID,
- mainSpID,
- note,
- clubID,
- clubScanTime,
- payWay,
- orderSource,
- orderTime,
- productCount,
- cooFreeFlag,
- cooFreeRate,
- cooFreeAmount,
- confirmFlag,
- clauseID,
- clauseContent,
- clauseName,
- updateDate,
- freePostFlag,
- freight,
- delFlag,
- payTime,
- splitFlag,
- preferential,
- confirmTime,
- invoiceFlag,
- postageOrderFlag,
- sendOutStatus,
- payableAmount,
- promotionFullReduction,
- promotionalGiftsCount,
- affirmPaymentFlag,
- rebateFlag,
- payStatus,
- zeroCostFlag
- ) VALUES (
- #{orderNo},
- #{userID},
- #{buyUserID},
- #{shopOrderIDs},
- #{orderSubmitType},
- #{orderType},
- #{secondHandOrderFlag},
- #{status},
- #{payFlag},
- #{onlinePayFlag},
- #{productTotalFee},
- #{orderTotalFee},
- #{payTotalFee},
- #{balancePayFee},
- #{discountFee},
- #{spID},
- #{mainSpID},
- #{note},
- #{clubID},
- #{clubScanTime},
- #{payWay},
- #{orderSource},
- #{orderTime},
- #{productCount},
- #{cooFreeFlag},
- #{cooFreeRate},
- #{cooFreeAmount},
- #{confirmFlag},
- #{clauseID},
- #{clauseContent},
- #{clauseName},
- #{updateDate},
- #{freePostFlag},
- #{freight},
- #{delFlag},
- #{payTime},
- #{splitFlag},
- #{preferential},
- #{confirmTime},
- #{invoiceFlag},
- #{postageOrderFlag},
- #{sendOutStatus},
- #{payableAmount},
- #{promotionFullReduction},
- #{promotionalGiftsCount},
- #{affirmPaymentFlag},
- #{rebateFlag},
- #{payStatus},
- #{zeroCostFlag}
- )
- </insert>
- <update id="update">
- update cm_order
- <set >
- <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="payWay != null" >
- payWay = #{payWay,jdbcType=INTEGER},
- </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="cooFreeFlag != null" >
- cooFreeFlag = #{cooFreeFlag,jdbcType=CHAR},
- </if>
- <if test="cooFreeRate != null" >
- cooFreeRate = #{cooFreeRate,jdbcType=INTEGER},
- </if>
- <if test="cooFreeAmount != null" >
- cooFreeAmount = #{cooFreeAmount,jdbcType=DECIMAL},
- </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="zeroCostFlag != null">
- zeroCostFlag = #{zeroCostFlag}
- </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 cm_order_product SET
- confirmFlag = 1
- WHERE orderID = #{orderID}
- </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.linkMan1 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,
- status,
- beginTime,
- endTime
- ) VALUES (
- #{orderId},
- #{promotionsId},
- #{name},
- #{description},
- #{type},
- #{mode},
- #{touchPrice},
- #{reducedPrice},
- #{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="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>
- <insert id="insertShortLink">
- INSERT INTO `caimei`.`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>
- </mapper>
|