|
@@ -99,7 +99,7 @@
|
|
|
<select id="get" resultType="NewShopOrder" useCache="false" flushCache="true">
|
|
|
select
|
|
|
<include refid="shopOrderColumns"/>
|
|
|
- ,ifnull(a.cmAccountType,0) as cmAccountType,
|
|
|
+ ,ifnull(a.cmAccountType,0) as cmAccountType,
|
|
|
ifnull(a.rebateOrder,0) as rebateOrder,
|
|
|
ifnull(a.supplierFreight,0) as supplierFreight
|
|
|
from cm_shop_order a
|
|
@@ -897,7 +897,7 @@
|
|
|
<if test="shopOrderNo != null and shopOrderNo != ''">
|
|
|
AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
|
|
|
</if>
|
|
|
--- and (co.confirmFlag = '1' or co.confirmFlag = '2')
|
|
|
+ -- and (co.confirmFlag = '1' or co.confirmFlag = '2')
|
|
|
and a.shopStatus = '1'
|
|
|
<if test="operatingMode != null and operatingMode == '1'.toString()">
|
|
|
and a.payStatus != 3 and co.status NOT IN (6,7)
|
|
@@ -1024,11 +1024,17 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="payShopAmountShopOrderId" resultType="java.lang.Double">
|
|
|
- SELECT IFNULL(SUM(cpsr.payCmAmount), 0)
|
|
|
+ SELECT IF(EXISTS(SELECT splitStatus
|
|
|
+ FROM cm_receipt_order_relation
|
|
|
+ WHERE shopOrderId = #{shopOrderId} AND splitStatus = 1),
|
|
|
+ (SELECT SUM(csa.splitAccount)
|
|
|
+ FROM cm_split_account csa
|
|
|
+ WHERE csa.type = 4 AND csa.shopOrderId = #{shopOrderId}),
|
|
|
+ IFNULL(SUM(cpsr.payCmAmount), 0))
|
|
|
FROM cm_pay_shop cps
|
|
|
LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
|
|
|
WHERE cpsr.delFlag = 0
|
|
|
- AND cpsr.shopOrderID = 29478
|
|
|
+ AND cpsr.shopOrderID = #{shopOrderId}
|
|
|
</select>
|
|
|
|
|
|
<select id="returnedPurchaseFeeByShopOrderId" resultType="java.lang.Double">
|
|
@@ -1131,22 +1137,22 @@
|
|
|
a.shopPostFlag AS shopPostFlag,
|
|
|
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.isColdChina AS isColdChina,
|
|
|
- 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.shopOrderNo AS shopOrderNo,
|
|
|
+ a.orderNo AS orderNo,
|
|
|
+ a.userID AS userID,
|
|
|
+ a.shopID AS shopID,
|
|
|
+ a.isColdChina AS isColdChina,
|
|
|
+ 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.refundStatus AS refundStatus,
|
|
|
+ a.needPayAmount AS needPayAmount,
|
|
|
a.splitCode,
|
|
|
ifnull(a.realPay, a.needPayAmount) AS realPay,
|
|
|
a.eachDiscount AS eachDiscount,
|
|
@@ -1164,23 +1170,23 @@
|
|
|
(ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
|
|
|
a.receiptStatus as shopReceiptStatus,
|
|
|
a.receiptStatus as ReceiptStatus,
|
|
|
- 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.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,
|
|
@@ -1345,7 +1351,7 @@
|
|
|
|
|
|
<update id="updateByShopOtherFee">
|
|
|
UPDATE cm_shop_order
|
|
|
- SET shopOtherFee = #{shopOtherFee},
|
|
|
+ SET shopOtherFee = #{shopOtherFee},
|
|
|
cmShopOtherFee = #{profit}
|
|
|
WHERE shopOrderID = #{shopOrderId}
|
|
|
</update>
|
|
@@ -1358,83 +1364,83 @@
|
|
|
</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,
|
|
|
+ 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,
|
|
|
a.onlinePayWays,
|
|
|
- ifnull(a.cmShopOtherFee,0) as cmShopOtherFee,
|
|
|
- ifnull(a.cmAccountType,0) as cmAccountType
|
|
|
+ ifnull(a.cmShopOtherFee, 0) as cmShopOtherFee,
|
|
|
+ ifnull(a.cmAccountType, 0) as cmAccountType
|
|
|
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
|
|
@@ -2644,145 +2650,145 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findCmProfit" resultType="com.caimei.modules.order.entity.OtherFeeDto">
|
|
|
- select IF((SELECT SUM(cdr.receiptAmount)
|
|
|
- FROM cm_discern_receipt cdr
|
|
|
- LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptId
|
|
|
- WHERE cdr.receiptType IN (10, 11)
|
|
|
- AND cdr.receiptStatus NOT IN (1, 4, 5)
|
|
|
- AND cdr.delflag = 0
|
|
|
- AND cror.shopOrderId = acso.shopOrderId) > 0, 0,
|
|
|
- (SELECT acso.needpayAmount
|
|
|
- - SUM(IFNULL(op.costprice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
- - SUM(IFNULL(op.organizeCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
- - SUM(IFNULL(op.cmCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
- - (IFNULL(SUM(acso.supplierFreight +
|
|
|
- IF(acso.differenceType = 1, acso.differencePrice, 0) -
|
|
|
- IF(acso.differenceType = 2, acso.differencePrice, 0)),
|
|
|
- 0))
|
|
|
- + IFNULL(acso.shopPostFee,0)
|
|
|
- FROM cm_order_product op
|
|
|
- WHERE op.shopOrderId = acso.shopOrderId)) as cmProfit,
|
|
|
- acso.onlinePayWays,
|
|
|
- ifnull(acso.cmAccountType,0) as cmAccountType
|
|
|
+ select IF((SELECT SUM(cdr.receiptAmount)
|
|
|
+ FROM cm_discern_receipt cdr
|
|
|
+ LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptId
|
|
|
+ WHERE cdr.receiptType IN (10, 11)
|
|
|
+ AND cdr.receiptStatus NOT IN (1, 4, 5)
|
|
|
+ AND cdr.delflag = 0
|
|
|
+ AND cror.shopOrderId = acso.shopOrderId) > 0, 0,
|
|
|
+ (SELECT acso.needpayAmount
|
|
|
+ - SUM(IFNULL(op.costprice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
+ - SUM(IFNULL(op.organizeCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
+ - SUM(IFNULL(op.cmCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
|
|
|
+ - (IFNULL(SUM(acso.supplierFreight +
|
|
|
+ IF(acso.differenceType = 1, acso.differencePrice, 0) -
|
|
|
+ IF(acso.differenceType = 2, acso.differencePrice, 0)),
|
|
|
+ 0))
|
|
|
+ + IFNULL(acso.shopPostFee, 0)
|
|
|
+ FROM cm_order_product op
|
|
|
+ WHERE op.shopOrderId = acso.shopOrderId)) as cmProfit,
|
|
|
+ acso.onlinePayWays,
|
|
|
+ ifnull(acso.cmAccountType, 0) as cmAccountType
|
|
|
from cm_shop_order acso
|
|
|
where acso.shopOrderId = #{shopOrderId}
|
|
|
</select>
|
|
|
|
|
|
<select id="findByShopOrderIDsNot" resultType="com.caimei.modules.order.entity.NewShopOrder">
|
|
|
- select distinct
|
|
|
- co.rebateFee as rebateFee,
|
|
|
- co.userBeans as userBeans,
|
|
|
- a.shopOrderID AS shopOrderID,
|
|
|
- a.shopStatus AS status,
|
|
|
- a.shopPostFlag AS shopPostFlag,
|
|
|
- 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.isColdChina AS isColdChina,
|
|
|
- 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.splitCode,
|
|
|
- ifnull(a.realPay, a.needPayAmount) AS realPay,
|
|
|
- a.eachDiscount AS eachDiscount,
|
|
|
- IFNULL((SELECT SUM(cror.associateAmount)
|
|
|
- FROM cm_receipt_order_relation cror
|
|
|
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
|
|
|
- WHERE cror.shopOrderId = a.shopOrderId
|
|
|
- AND cror.relationType = '2'
|
|
|
- AND cdr.receiptType = 1
|
|
|
- AND cdr.delFlag = 0
|
|
|
- AND cror.delFlag = 0
|
|
|
- AND cdr.receiptStatus IN (2, 3)
|
|
|
- AND cdr.payWay != 3)
|
|
|
- , 0) AS receiptAmount,
|
|
|
- (ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
|
|
|
- a.receiptStatus as shopReceiptStatus,
|
|
|
- a.receiptStatus as ReceiptStatus,
|
|
|
- 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,
|
|
|
- ifnull(a.shopPostFee, 0) AS shopPostFee,
|
|
|
- ifnull(a.shopTaxFee,0) AS shopTaxFee,
|
|
|
- a.shouldPayShopAmount AS shouldPayShopAmount,
|
|
|
- a.payedShopAmount AS payedShopAmount,
|
|
|
- a.paying AS paying,
|
|
|
- a.costType AS costType,
|
|
|
- a.settleStatus AS settleStatus,
|
|
|
- a.modifyShouldPayNote AS modifyShouldPayNote,
|
|
|
- a.orderPromotionsId AS orderPromotionsId,
|
|
|
- a.differenceType AS differenceType,
|
|
|
- a.differencePrice AS differencePrice,
|
|
|
- a.proportional AS proportional,
|
|
|
- ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
|
|
|
- ifnull(a.couponAmount, 0) As couponAmount,
|
|
|
- a.zeroCostFlag AS zeroCostFlag,
|
|
|
- co.payTotalFee AS payTotalFee,
|
|
|
- co.promotionFullReduction AS promotionFullReduction,
|
|
|
- a.onlinePayWays,
|
|
|
- ifnull(a.cmAccountType,0) as cmAccountType,
|
|
|
- ifnull(a.shopOtherFee, 0) AS shopOtherFee,
|
|
|
- ifnull(a.cmShopOtherFee,0) AS cmShopOtherFee,
|
|
|
- ifnull(a.supplierFreight,0) as supplierFreight,
|
|
|
- ifnull(a.rebateOrder,0) as rebateOrder,
|
|
|
- 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="ids != null and ids.size() > 0">
|
|
|
- where a.shopOrderID in
|
|
|
- <foreach collection="ids" separator="," item="shopOrderID" open="(" close=")">
|
|
|
- #{shopOrderID}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
+ select distinct
|
|
|
+ co.rebateFee as rebateFee,
|
|
|
+ co.userBeans as userBeans,
|
|
|
+ a.shopOrderID AS shopOrderID,
|
|
|
+ a.shopStatus AS status,
|
|
|
+ a.shopPostFlag AS shopPostFlag,
|
|
|
+ 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.isColdChina AS isColdChina,
|
|
|
+ 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.splitCode,
|
|
|
+ ifnull(a.realPay, a.needPayAmount) AS realPay,
|
|
|
+ a.eachDiscount AS eachDiscount,
|
|
|
+ IFNULL((SELECT SUM(cror.associateAmount)
|
|
|
+ FROM cm_receipt_order_relation cror
|
|
|
+ LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
|
|
|
+ WHERE cror.shopOrderId = a.shopOrderId
|
|
|
+ AND cror.relationType = '2'
|
|
|
+ AND cdr.receiptType = 1
|
|
|
+ AND cdr.delFlag = 0
|
|
|
+ AND cror.delFlag = 0
|
|
|
+ AND cdr.receiptStatus IN (2, 3)
|
|
|
+ AND cdr.payWay != 3)
|
|
|
+ , 0) AS receiptAmount,
|
|
|
+ (ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
|
|
|
+ a.receiptStatus as shopReceiptStatus,
|
|
|
+ a.receiptStatus as ReceiptStatus,
|
|
|
+ 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,
|
|
|
+ ifnull(a.shopPostFee, 0) AS shopPostFee,
|
|
|
+ ifnull(a.shopTaxFee,0) AS shopTaxFee,
|
|
|
+ a.shouldPayShopAmount AS shouldPayShopAmount,
|
|
|
+ a.payedShopAmount AS payedShopAmount,
|
|
|
+ a.paying AS paying,
|
|
|
+ a.costType AS costType,
|
|
|
+ a.settleStatus AS settleStatus,
|
|
|
+ a.modifyShouldPayNote AS modifyShouldPayNote,
|
|
|
+ a.orderPromotionsId AS orderPromotionsId,
|
|
|
+ a.differenceType AS differenceType,
|
|
|
+ a.differencePrice AS differencePrice,
|
|
|
+ a.proportional AS proportional,
|
|
|
+ ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
|
|
|
+ ifnull(a.couponAmount, 0) As couponAmount,
|
|
|
+ a.zeroCostFlag AS zeroCostFlag,
|
|
|
+ co.payTotalFee AS payTotalFee,
|
|
|
+ co.promotionFullReduction AS promotionFullReduction,
|
|
|
+ a.onlinePayWays,
|
|
|
+ ifnull(a.cmAccountType,0) as cmAccountType,
|
|
|
+ ifnull(a.shopOtherFee, 0) AS shopOtherFee,
|
|
|
+ ifnull(a.cmShopOtherFee,0) AS cmShopOtherFee,
|
|
|
+ ifnull(a.supplierFreight,0) as supplierFreight,
|
|
|
+ ifnull(a.rebateOrder,0) as rebateOrder,
|
|
|
+ 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="ids != null and ids.size() > 0">
|
|
|
+ where a.shopOrderID in
|
|
|
+ <foreach collection="ids" separator="," item="shopOrderID" open="(" close=")">
|
|
|
+ #{shopOrderID}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<insert id="addCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder" useGeneratedKeys="true"
|