123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?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.NewOrderProductDao">
- <sql id="orderProductColumns">
- a.`orderProductId` AS `orderProductId`,
- a.`orderNo` AS `orderNo`,
- a.`orderId` AS `orderId`,
- a.`shopOrderId` AS `shopOrderId`,
- a.`shopOrderNo` AS `shopOrderNo`,
- a.`shopId` AS `shopId`,
- a.`productId` AS `productId`,
- a.`num` AS `num`,
- a.`presentNum` AS `presentNum`,
- a.`outStoreType` AS `outStoreType`,
- a.`skuId` AS `skuId`,
- a.`productNo` AS `productNo`,
- a.`price` AS `price`,
- a.`normalPrice` AS `normalPrice`,
- a.`totalAmount` AS `totalAmount`,
- a.`totalFee` AS `totalFee`,
- a.`shouldPayFee` AS `shouldPayFee`,
- a.`discount` AS `discount`,
- a.`discountPrice` AS `discountPrice`,
- a.`taxRate` AS `taxRate`,
- a.`addedValueTax` AS `addedValueTax`,
- a.`totalAddedValueTax` AS `totalAddedValueTax`,
- IFNULL(a.`shouldPayTotalTax` ,0) AS `shouldPayTotalTax`,
- a.`shopFee` AS `shopFee`,
- a.`otherFee` AS `otherFee`,
- a.`cmFee` AS `cmFee`,
- a.`singleShopFee` AS `singleShopFee`,
- a.`singleOtherFee` AS `singleOtherFee`,
- a.`singleCmFee` AS `singleCmFee`,
- a.`status` AS `status`,
- a.`totalBeans` AS `totalBeans`,
- a.`useBalanceAmount` AS `useBalanceAmount`,
- a.`useBeanAmount` AS `useBeanAmount`,
- a.`notOutStore` AS `notOutStore`,
- a.`cmbeanPrice` AS `cmbeanPrice`,
- a.`isActProduct` AS `isActProduct`,
- a.`isGiftProduct` AS `isGiftProduct`,
- a.`productActInfo` AS `productActInfo`,
- a.`buyAgainFlag` AS `buyAgainFlag`,
- a.`confirmProductFlag` AS `confirmProductFlag`,
- a.`payStatus` AS `payStatus`,
- a.`name` AS `name`,
- cs.`unit` AS `unit`,
- cs.`organizeId` AS `organizeId`,
- a.`actType` AS `actType`,
- a.`actPreferential` AS `actPreferential`,
- a.`preferential` AS `preferential`,
- (select mainImage from product p where p.productId = a.productId) AS image,
- a.`discountFee` AS `discountFee`,
- a.`productUnit` AS `productUnit`,
- a.`productImage` AS `productImage`,
- a.`shopName` AS `shopName`,
- -- cs.costProportional AS costProportional,
- cs.stock AS stock,
- (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
- cs.costPrice AS costPrice,
- a.costPrice as newCostPrice,
- p.aliasName AS aliasName,
- a.singleShouldPayTotalTax AS singleShouldPayTotalTax
- </sql>
- <sql id="orderProductJoins">
- LEFT JOIN product p ON p.productId = a.productId
- left join cm_sku cs on a.skuId = cs.skuId and cs.organizeId= 4
- </sql>
- <select id="get" resultType="com.caimei.modules.order.entity.NewOrderProduct">
- SELECT
- <include refid="orderProductColumns"/>
- FROM cm_order_product a
- <include refid="orderProductJoins"/>
- WHERE a.orderProductId = #{orderProductId}
- </select>
- <select id="findListByShopOrderId" resultType="com.caimei.modules.order.entity.NewOrderProduct">
- SELECT
- <include refid="orderProductColumns"/>
- FROM cm_order_product a
- <include refid="orderProductJoins"/>
- WHERE a.shopOrderId = #{shopOrderId}
- </select>
- <select id="CountReturnedPurchaseProduct" resultType="java.lang.Integer">
- select SUM(crpp.actualReturnedNum) + SUM(crpp.actualCancelNum)
- from cm_returned_purchase_product crpp
- left join cm_returned_purchase rp on rp.id = crpp.returnedID
- where crpp.shopOrderID = #{shopOrderID}
- and crpp.orderProductID = #{orderProductID}
- and rp.status = '2'
- and rp.delFlag = '0'
- </select>
- <select id="getReturningNum" resultType="Integer">
- SELECT
- IFNULL(sum(a.actualReturnedNum+a.actualCancelNum),0)
- FROM cm_returned_purchase_product a
- right join cm_returned_purchase b on a.returnedId = b.id
- WHERE a.orderProductId = #{orderProductId}
- and b.status = 1
- and b.delFlag = 0
- </select>
- <select id="getReturnedNum" resultType="Integer">
- SELECT
- IFNULL(sum(a.actualReturnedNum+a.actualCancelNum),0)
- FROM cm_returned_purchase_product a
- right join cm_returned_purchase b on a.returnedId = b.id
- WHERE a.orderProductId = #{orderProductId}
- and b.status = 2
- and b.delFlag = 0
- </select>
- <select id="getReceivedNum" resultType="Integer">
- SELECT
- IFNULL(sum(a.num),0)
- FROM cm_logistics_record a
- right join cm_logistics_batch b on a.logisticsBatchId = b.id
- WHERE a.orderProductId = #{orderProductId}
- and b.status = 1
- </select>
- <select id="findListByOrderId" resultType="com.caimei.modules.order.entity.NewOrderProduct">
- SELECT
- <include refid="orderProductColumns"/>
- ,(SELECT ifnull(SUM(num),0)FROM cm_logistics_record WHERE orderproductId=a.orderproductId) as sendOutNum
- FROM cm_order_product a
- left join cm_logistics_record clr on a.orderProductId = clr.orderProductId
- <include refid="orderProductJoins"/>
- WHERE a.orderId = #{orderId}
- and clr.id is null
- and a.shopId != 998
- </select>
- <select id="getActualCancelNum" resultType="java.lang.Integer">
- select ifnull(SUM(crpp.actualCancelNum),0)
- from cm_returned_purchase_product crpp
- left join cm_returned_purchase rp on rp.id = crpp.returnedID
- where crpp.orderProductID = #{orderProductID}
- and rp.status = '2'
- and rp.delFlag = '0'
- </select>
- </mapper>
|