|
@@ -4,7 +4,7 @@
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.caimei.modules.order.dao.CmReturnedPurchaseProductDao">
|
|
<mapper namespace="com.caimei.modules.order.dao.CmReturnedPurchaseProductDao">
|
|
<sql id="cmReturnedPurchaseProductColumns">
|
|
<sql id="cmReturnedPurchaseProductColumns">
|
|
- a.id AS "id",
|
|
|
|
|
|
+ a.id AS "id",
|
|
a.returnedId AS "returnedId",
|
|
a.returnedId AS "returnedId",
|
|
a.productId AS "productId",
|
|
a.productId AS "productId",
|
|
a.orderProductId AS "orderProductId",
|
|
a.orderProductId AS "orderProductId",
|
|
@@ -14,28 +14,65 @@
|
|
a.applicationCancelNum AS "applicationCancelNum",
|
|
a.applicationCancelNum AS "applicationCancelNum",
|
|
a.actualReturnedNum AS "actualReturnedNum",
|
|
a.actualReturnedNum AS "actualReturnedNum",
|
|
a.actualCancelNum AS "actualCancelNum"
|
|
a.actualCancelNum AS "actualCancelNum"
|
|
- </sql>
|
|
|
|
|
|
+ </sql>
|
|
|
|
|
|
<select id="findList" resultType="com.caimei.modules.order.entity.CmReturnedPurchaseProduct">
|
|
<select id="findList" resultType="com.caimei.modules.order.entity.CmReturnedPurchaseProduct">
|
|
- SELECT
|
|
|
|
- <include refid="cmReturnedPurchaseProductColumns"/>,
|
|
|
|
- b.price as price,b.discount as discount,b.discountPrice as discountPrice,b.num as num,b.presentNum as presentNum,
|
|
|
|
- b.totalFee as totalFee,b.totalAddedValueTax as totalAddedValueTax,
|
|
|
|
- b.taxRate as taxRate,b.addedValueTax as addedValueTax,c.mainImage as mainImage,
|
|
|
|
- c.name as name,d.name as shopName,
|
|
|
|
- c.unit as unit
|
|
|
|
|
|
+ SELECT a.id AS "id",
|
|
|
|
+ a.returnedId AS "returnedId",
|
|
|
|
+ a.productId AS "productId",
|
|
|
|
+ a.orderProductId AS "orderProductId",
|
|
|
|
+ a.shopId AS "shopId",
|
|
|
|
+ a.shopOrderId as "shopOrderId",
|
|
|
|
+ a.applicationReturnedNum AS "applicationReturnedNum",
|
|
|
|
+ a.applicationCancelNum AS "applicationCancelNum",
|
|
|
|
+ a.actualReturnedNum AS "actualReturnedNum",
|
|
|
|
+ a.actualCancelNum AS "actualCancelNum",
|
|
|
|
+ b.price as price,
|
|
|
|
+ b.discount as discount,
|
|
|
|
+ b.discountPrice as discountPrice,
|
|
|
|
+ b.num as num,
|
|
|
|
+ b.presentNum as presentNum,
|
|
|
|
+ b.totalFee as totalFee,
|
|
|
|
+ b.totalAddedValueTax as totalAddedValueTax,
|
|
|
|
+ b.taxRate as taxRate,
|
|
|
|
+ b.addedValueTax as addedValueTax,
|
|
|
|
+ c.mainImage as mainImage,
|
|
|
|
+ c.name as name,
|
|
|
|
+ d.name as shopName,
|
|
|
|
+ b.totalAmount,
|
|
|
|
+ (select IFNULL(SUM(clr.num), 0)
|
|
|
|
+ from cm_logistics_record clr
|
|
|
|
+ where clr.orderProductID = b.orderProductID) as
|
|
|
|
+ sendOutNum,
|
|
|
|
+ (b.num - (select IFNULL(SUM(clr.num), 0)
|
|
|
|
+ from cm_logistics_record clr
|
|
|
|
+ where clr.orderProductID =
|
|
|
|
+ a.orderProductID)) as waitSendOutNum,
|
|
|
|
+ ifnull((select sum(ca.actualReturnedNum)
|
|
|
|
+ from cm_returned_purchase_product ca
|
|
|
|
+ left join cm_returned_purchase cb
|
|
|
|
+ on ca.returnedId = cb.id
|
|
|
|
+ where ca.orderProductId = a.orderProductId
|
|
|
|
+ and cb.status = 2
|
|
|
|
+ and cb.delFlag = 0), 0) as returnedPurchaseProductNum,
|
|
|
|
+ ifnull((select sum(da.actualCancelNum)
|
|
|
|
+ from cm_returned_purchase_product da
|
|
|
|
+ left join cm_returned_purchase db
|
|
|
|
+ on da.returnedId = db.id
|
|
|
|
+ where da.orderProductId = a.orderProductId
|
|
|
|
+ and db.status = 2
|
|
|
|
+ and db.delFlag = 0), 0)
|
|
|
|
+ as cancelProductNum,
|
|
|
|
+ b.productUnit as unit
|
|
FROM cm_returned_purchase_product a
|
|
FROM cm_returned_purchase_product a
|
|
- left join cm_order_product b on a.orderProductId = b.orderProductId
|
|
|
|
- left join product c on c.productId = a.productId
|
|
|
|
- left join shop d on d.shopId = a.shopId
|
|
|
|
- <where>
|
|
|
|
- <if test="returnedId != null">
|
|
|
|
- AND a.returnedId = #{returnedId}
|
|
|
|
- </if>
|
|
|
|
- </where>
|
|
|
|
|
|
+ left join cm_order_product b on a.orderProductId = b.orderProductId
|
|
|
|
+ left join product c on c.productId = a.productId
|
|
|
|
+ left join shop d on d.shopId = a.shopId
|
|
|
|
+ where a.returnedId = #{returnedId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
- <select id="getCmReturnedPurchaseProductList" resultType="com.caimei.modules.order.entity.CmReturnedPurchaseProduct">
|
|
|
|
|
|
+ <select id="getCmReturnedPurchaseProductList"
|
|
|
|
+ resultType="com.caimei.modules.order.entity.CmReturnedPurchaseProduct">
|
|
SELECT
|
|
SELECT
|
|
<include refid="cmReturnedPurchaseProductColumns"/>,
|
|
<include refid="cmReturnedPurchaseProductColumns"/>,
|
|
b.status as status
|
|
b.status as status
|
|
@@ -77,43 +114,43 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findProductByShopOrder" resultType="com.caimei.modules.order.entity.NewOrderProduct">
|
|
<select id="findProductByShopOrder" resultType="com.caimei.modules.order.entity.NewOrderProduct">
|
|
- SELECT
|
|
|
|
- a.orderProductId AS "orderProductId",
|
|
|
|
- a.shopId AS "shopId",
|
|
|
|
- a.shopOrderId as "shopOrderId",
|
|
|
|
- a.actualReturnedNum AS "actualReturnedNum",
|
|
|
|
- a.actualCancelNum AS "actualCancelNum",
|
|
|
|
- b.status as status,
|
|
|
|
- cop.productImage,
|
|
|
|
- cop.name,
|
|
|
|
- cop.productUnit as unit,
|
|
|
|
- cop.num,
|
|
|
|
- cop.totalAmount,
|
|
|
|
- cop.
|
|
|
|
- cop.price,
|
|
|
|
- (select sum(ca.actualReturnedNum)
|
|
|
|
- from cm_returned_purchase_product ca
|
|
|
|
- left join cm_returned_purchase cb
|
|
|
|
- on ca.returnedId = cb.id
|
|
|
|
- where ca.orderProductId = a.orderProductId
|
|
|
|
- and cb.status=2
|
|
|
|
- and cb.delFlag=0) as returnedPurchaseProductNum,
|
|
|
|
- (select sum(da.actualCancelNum)
|
|
|
|
- from cm_returned_purchase_product da
|
|
|
|
- left join cm_returned_purchase db
|
|
|
|
- on da.returnedId = db.id
|
|
|
|
- where da.orderProductId = a.orderProductId
|
|
|
|
- and db.status=2
|
|
|
|
- and db.delFlag=0)
|
|
|
|
- as cancelProductNum,
|
|
|
|
- (select IFNULL(SUM(clr.num),0) from cm_logistics_record clr where clr.orderProductID = a.orderProductID) as sendOutNum,
|
|
|
|
- (cop.num-(select IFNULL(SUM(clr.num),0) from cm_logistics_record clr where clr.orderProductID = a.orderProductID)) as notOutStore
|
|
|
|
|
|
+ SELECT a.orderProductId AS "orderProductId",
|
|
|
|
+ a.shopId AS "shopId",
|
|
|
|
+ a.shopOrderId as "shopOrderId",
|
|
|
|
+ ifnull(if(b.status != 2, a.applicationReturnedNum, a.actualReturnedNum), 0) AS "actualReturnedNum",
|
|
|
|
+ ifnull(if(b.status != 2, a.applicationCancelNum, a.actualCancelNum), 0) AS "actualCancelNum",
|
|
|
|
+ b.status as status,
|
|
|
|
+ cop.productImage,
|
|
|
|
+ cop.name,
|
|
|
|
+ cop.productUnit as unit,
|
|
|
|
+ cop.num,
|
|
|
|
+ cop.totalAmount,
|
|
|
|
+ cop.price,
|
|
|
|
+ ifnull((select sum(ca.actualReturnedNum)
|
|
|
|
+ from cm_returned_purchase_product ca
|
|
|
|
+ left join cm_returned_purchase cb
|
|
|
|
+ on ca.returnedId = cb.id
|
|
|
|
+ where ca.orderProductId = a.orderProductId
|
|
|
|
+ and cb.status = 2
|
|
|
|
+ and cb.delFlag = 0), 0) as returnedPurchaseProductNum,
|
|
|
|
+ ifnull((select sum(da.actualCancelNum)
|
|
|
|
+ from cm_returned_purchase_product da
|
|
|
|
+ left join cm_returned_purchase db
|
|
|
|
+ on da.returnedId = db.id
|
|
|
|
+ where da.orderProductId = a.orderProductId
|
|
|
|
+ and db.status = 2
|
|
|
|
+ and db.delFlag = 0), 0) as cancelProductNum,
|
|
|
|
+ (select IFNULL(SUM(clr.num), 0)
|
|
|
|
+ from cm_logistics_record clr
|
|
|
|
+ where clr.orderProductID = a.orderProductID) as sendOutNum,
|
|
|
|
+ (cop.num - (select IFNULL(SUM(clr.num), 0)
|
|
|
|
+ from cm_logistics_record clr
|
|
|
|
+ where clr.orderProductID = a.orderProductID)) as notOutStore
|
|
FROM cm_returned_purchase_product a
|
|
FROM cm_returned_purchase_product a
|
|
- left join cm_returned_purchase b on a.returnedId = b.id
|
|
|
|
- left join cm_order_product cop on a.orderProductId = cop.orderProductId
|
|
|
|
|
|
+ left join cm_returned_purchase b on a.returnedId = b.id
|
|
|
|
+ left join cm_order_product cop on a.orderProductId = cop.orderProductId
|
|
where a.shopOrderId = #{shopOrderId}
|
|
where a.shopOrderId = #{shopOrderId}
|
|
- AND a.returnedID = #{returnId}
|
|
|
|
- AND b.status = 2
|
|
|
|
- AND b.delFlag = 0
|
|
|
|
|
|
+ AND a.returnedID = #{returnId}
|
|
|
|
+ AND b.delFlag = 0
|
|
</select>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|