|
@@ -237,9 +237,11 @@
|
|
|
FROM cm_pay_shop a
|
|
|
left join cm_mall_admin_user u1 on u1.id = a.applicant
|
|
|
left join cm_mall_admin_user u2 on u2.id = a.reviewer
|
|
|
+ left join cm_pay_shop_record cpr on a.id = cpr.payShopID
|
|
|
left join shop s on s.shopID = a.shopID
|
|
|
+ LEFT JOIN cm_order_product cop ON cpr.shopOrderId = cop.shopOrderId
|
|
|
<where>
|
|
|
- <if test="payShopId != null and payShopId != ''">
|
|
|
+ <if test="payShopId != null">
|
|
|
and a.id = #{payShopId}
|
|
|
</if>
|
|
|
<if test="shopName != null and shopName != ''">
|
|
@@ -260,21 +262,21 @@
|
|
|
<if test="payEndTime != null and payEndTime != ''">
|
|
|
AND a.payTime <![CDATA[ <= ]]> #{payEndTime}
|
|
|
</if>
|
|
|
- <if test="status != null and status != ''">
|
|
|
+ <if test="status != null">
|
|
|
AND a.status = #{status}
|
|
|
</if>
|
|
|
<if test="shopOrderNo != null and shopOrderNo != ''">
|
|
|
AND a.id in (select cpsr.payShopID from cm_pay_shop_record cpsr where cpsr.shopOrderNo like
|
|
|
concat('%',#{shopOrderNo},'%'))
|
|
|
</if>
|
|
|
- <if test="shopOrderId != null and shopOrderId != ''">
|
|
|
+ <if test="shopOrderId != null">
|
|
|
AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr WHERE cpsr.shopOrderID=#{shopOrderId})
|
|
|
</if>
|
|
|
- <if test="orderId != null and orderId != ''">
|
|
|
+ <if test="orderId != null">
|
|
|
AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON
|
|
|
so.shopOrderID=cpsr.shopOrderID WHERE so.orderID=#{orderId})
|
|
|
</if>
|
|
|
- <if test='organizeId != null and organizeId != ""'>
|
|
|
+ <if test='organizeId != null'>
|
|
|
AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON
|
|
|
so.shopOrderID=cpsr.shopOrderID WHERE so.organizeID = #{organizeId})
|
|
|
</if>
|
|
@@ -283,7 +285,7 @@
|
|
|
so.shopOrderID=cpsr.shopOrderID WHERE so.orderNo LIKE CONCAT('%',#{orderNo},'%'))
|
|
|
</if>
|
|
|
and a.delFlag = 0
|
|
|
- and a.shopID != 998
|
|
|
+ and cop.skuId != 4099
|
|
|
</where>
|
|
|
ORDER BY a.id desc
|
|
|
</select>
|
|
@@ -333,21 +335,27 @@
|
|
|
a.shopPostFee AS shopPostFee,
|
|
|
ifnull((select sum(payAmount)
|
|
|
from cm_pay_shop_record
|
|
|
- where shopOrderId = a.shopOrderId and status = 1 and delFlag = 0),
|
|
|
+ where shopOrderId = a.shopOrderId
|
|
|
+ and status = 1
|
|
|
+ and delFlag = 0),
|
|
|
0) as payedShopAmount,
|
|
|
ifnull((select sum(payCmAmount)
|
|
|
from cm_pay_shop_record
|
|
|
- where shopOrderId = a.shopOrderId and status = 1 and delFlag = 0),
|
|
|
+ where shopOrderId = a.shopOrderId
|
|
|
+ and status = 1
|
|
|
+ and delFlag = 0),
|
|
|
0) as payCmAmount,
|
|
|
a.payedShopAmount AS payedShopAmount,
|
|
|
co.payTotalFee AS payTotalFee,
|
|
|
s.name AS shopName,
|
|
|
s.shopId,
|
|
|
a.paying,
|
|
|
- co.receiptStatus AS orderReceiptStatus
|
|
|
+ co.receiptStatus AS orderReceiptStatus,
|
|
|
+ bou.name as buyer
|
|
|
FROM cm_shop_order a
|
|
|
LEFT JOIN cm_order co ON co.orderID = a.orderID
|
|
|
LEFT JOIN shop s ON s.shopID = a.shopID
|
|
|
+ left join bp_order_userinfo bou on bou.orderId = a.orderID
|
|
|
WHERE a.shopOrderID IN
|
|
|
(SELECT shoporderId
|
|
|
FROM cm_pay_shop_record
|
|
@@ -357,14 +365,14 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findPayOrderProducts" resultType="com.caimei.modules.order.entity.NewOrderProduct">
|
|
|
- select cop.name AS name,
|
|
|
- cop.orderProductID AS orderProductId,
|
|
|
- cop.productID AS productId,
|
|
|
- cop.productUnit AS unit,
|
|
|
- cop.num AS num,
|
|
|
- cop.totalFee AS totalFee,
|
|
|
- cop.costPrice AS costPrice,
|
|
|
- cop.productType AS productType,
|
|
|
+ select cop.name AS name,
|
|
|
+ cop.orderProductID AS orderProductId,
|
|
|
+ cop.productID AS productId,
|
|
|
+ cop.productUnit AS unit,
|
|
|
+ cop.num AS num,
|
|
|
+ cop.totalFee AS totalFee,
|
|
|
+ cop.costPrice AS costPrice,
|
|
|
+ cop.productType AS productType,
|
|
|
cop.price,
|
|
|
cop.shopPercent,
|
|
|
cop.organizePercent,
|
|
@@ -372,25 +380,26 @@
|
|
|
cop.totalAmount,
|
|
|
cop.notOutStore,
|
|
|
cop.presentNum,
|
|
|
- (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.orderProductID = cop.orderProductId
|
|
|
- AND rp.status = '2'
|
|
|
- AND rp.delFlag = '0') AS returnedNum
|
|
|
+ ifnull((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.orderProductID = cop.orderProductId
|
|
|
+ AND rp.status = '2'
|
|
|
+ AND rp.delFlag = '0'), 0) AS returnedNum
|
|
|
from cm_order_product cop
|
|
|
- left join cm_sku cs on cop.skuId = cs.skuId
|
|
|
- left join product p on p.productID = cop.productID
|
|
|
- left join cm_order co on co.orderID = cop.orderID
|
|
|
- left join user u on u.userID = co.userID
|
|
|
+ left join cm_sku cs on cop.skuId = cs.skuId
|
|
|
+ left join product p on p.productID = cop.productID
|
|
|
+ left join cm_order co on co.orderID = cop.orderID
|
|
|
+ left join user u on u.userID = co.userID
|
|
|
where cop.shopOrderID = #{shopOrderId}
|
|
|
</select>
|
|
|
|
|
|
<select id="findShopOrderNos" resultType="java.lang.String">
|
|
|
- SELECT CONCAT(shopOrderNo, '(', shopOrderID, ')') AS result
|
|
|
- FROM cm_shop_order
|
|
|
- WHERE orderID = #{orderId}
|
|
|
- and shopId != 998
|
|
|
+ SELECT CONCAT(cso.shopOrderNo, '(', cso.shopOrderID, ')') AS result
|
|
|
+ FROM cm_shop_order cso
|
|
|
+ left join cm_order_product cop on cso.orderID = cop.orderID
|
|
|
+ WHERE cso.orderID = #{orderId}
|
|
|
+ and cop.skuId != 4099
|
|
|
</select>
|
|
|
|
|
|
<select id="findPayShopRecords" resultType="com.caimei.modules.order.entity.OrderPayShopRecord">
|
|
@@ -414,18 +423,20 @@
|
|
|
<select id="findShopOrderNosByPayShop" resultType="java.lang.String">
|
|
|
SELECT distinct CONCAT(cso.shopOrderNo, '(', cso.shopOrderID, ')') AS result
|
|
|
FROM cm_shop_order cso
|
|
|
- left join cm_pay_shop_record cpsr on cso.shopOrderID = cpsr.shopOrderID
|
|
|
+ left join cm_pay_shop_record cpsr on cso.shopOrderID = cpsr.shopOrderID
|
|
|
+ left join cm_order_product cop on cpsr.shopOrderId = cop.shopOrderId
|
|
|
WHERE cpsr.payShopID = #{id}
|
|
|
- and cso.shopId != 998
|
|
|
+ and cop.skuId != 4099
|
|
|
</select>
|
|
|
|
|
|
<select id="findOrderNos" resultType="java.lang.String">
|
|
|
SELECT distinct CONCAT(co.orderNo, '(', co.orderID, ')') AS result
|
|
|
FROM cm_pay_shop_record cpsr
|
|
|
- left join cm_shop_order cso on cpsr.shopOrderID = cso.shopOrderID
|
|
|
- left join cm_order co on cso.orderID = co.orderID
|
|
|
+ left join cm_shop_order cso on cpsr.shopOrderID = cso.shopOrderID
|
|
|
+ left join cm_order co on cso.orderID = co.orderID
|
|
|
+ left join cm_order_product cop on co.orderId = cop.orderID
|
|
|
WHERE cpsr.payShopID = #{id}
|
|
|
- and cso.shopId != 998
|
|
|
+ and cop.skuId != 4099
|
|
|
</select>
|
|
|
|
|
|
<select id="findShouldPayShopAmount" resultType="java.lang.Double">
|
|
@@ -503,7 +514,7 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findOnlinePayCm" resultType="java.lang.Double">
|
|
|
- SELECT ifnull(SUM(splitAccount),0)
|
|
|
+ SELECT ifnull(SUM(splitAccount), 0)
|
|
|
FROM cm_split_account
|
|
|
WHERE productType = #{status}
|
|
|
AND shoporderid = #{shopOrderId}
|
|
@@ -531,8 +542,8 @@
|
|
|
a.payShopID AS "payShopID",
|
|
|
a.status AS "status"
|
|
|
FROM cm_pay_shop_record a
|
|
|
- LEFT JOIN cm_offline_collection f ON a.payType = f.type
|
|
|
- left join cm_pay_shop cps on a.shopID = cps.shopID
|
|
|
+ LEFT JOIN cm_offline_collection f ON a.payType = f.type
|
|
|
+ left join cm_pay_shop cps on a.shopID = cps.shopID
|
|
|
WHERE a.shopOrderID in (select shopOrderId from cm_shop_order where orderId = #{orderId})
|
|
|
and a.delFlag = 0
|
|
|
and cps.delFlag = 0
|
|
@@ -541,7 +552,35 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
|
|
|
- select settleAmount, settleType, shopOrderId, splitCode, settleTime
|
|
|
+ select settleAmount,
|
|
|
+ settleType,
|
|
|
+ shopOrderId,
|
|
|
+ splitCode,
|
|
|
+ settleTime
|
|
|
from cm_settle_record
|
|
|
+ where shopOrderId in (select shopOrderId from cm_shop_order where orderId = #{orderId})
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findPayShopRecordsByShopOrder" resultType="com.caimei.modules.order.entity.OrderPayShopRecord">
|
|
|
+ SELECT f.bankAccount AS "bankNameType",
|
|
|
+ a.id AS "id",
|
|
|
+ a.shopID AS "shopId",
|
|
|
+ a.shopOrderID AS "shopOrderId",
|
|
|
+ a.shopOrderNo AS "shopOrderNo",
|
|
|
+ a.payAmount AS "payAmount",
|
|
|
+ a.payCmAmount,
|
|
|
+ a.payType AS "payType",
|
|
|
+ a.payTime AS "payTime",
|
|
|
+ a.wipeTime AS "wipeTime",
|
|
|
+ a.payShopID AS "payShopID",
|
|
|
+ a.status AS "status"
|
|
|
+ FROM cm_pay_shop_record a
|
|
|
+ LEFT JOIN cm_offline_collection f ON a.payType = f.type
|
|
|
+ left join cm_pay_shop cps on a.shopID = cps.shopID
|
|
|
+ WHERE a.shopOrderID in (select shopOrderId from cm_shop_order where orderId = #{shopOrderId})
|
|
|
+ and a.delFlag = 0
|
|
|
+ and cps.delFlag = 0
|
|
|
+ and a.status = 1
|
|
|
+ and cps.status = 1
|
|
|
</select>
|
|
|
</mapper>
|