|
@@ -1123,12 +1123,103 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findByShopOrderIDs" resultType="newShopOrder">
|
|
|
- select distinct<include refid="shopOrderColumns"/>,
|
|
|
+ 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.cmShopOtherFee,0) as cmShopOtherFee,
|
|
|
+ ifnull(IF(cpsr.status!=1 AND paymentType=3,cpsr.payAmount,a.shopOtherFee), 0) AS shopOtherFee,
|
|
|
+ ifnull(IF(cpsr.status!=1 AND paymentType=3,cpsr.payCmAmount,a.cmShopOtherFee),0) AS cmShopOtherFee,
|
|
|
ifnull(a.supplierFreight,0) as supplierFreight,
|
|
|
ifnull(a.rebateOrder,0) as rebateOrder,
|
|
|
bou.name AS buyer,
|
|
@@ -2577,6 +2668,123 @@
|
|
|
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="shopOrderIDs != null and shopOrderIDs.size() > 0">
|
|
|
+ where a.shopOrderID in
|
|
|
+ <foreach collection="shopOrderIDs" separator="," item="shopOrderID" open="(" close=")">
|
|
|
+ #{shopOrderID}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
<insert id="addCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder" useGeneratedKeys="true"
|
|
|
keyProperty="shopOrderID">
|
|
|
insert into cm_shop_order
|