|
@@ -86,124 +86,126 @@
|
|
|
|
|
|
|
|
|
<select id="findList" resultType="CmDiscernReceipt">
|
|
|
- (SELECT
|
|
|
- <include refid="cmDiscernReceiptColumns"/>,
|
|
|
- cso.orderId AS orderID,
|
|
|
- cso.shopOrderNo as shopOrderNo,
|
|
|
- cso.shopOrderId as shopOrderId,
|
|
|
- cof.bankAccount AS bankNameType,
|
|
|
- s.checkMan,
|
|
|
- s.name AS shopName,
|
|
|
- u.userName AS "userName",
|
|
|
- u.name AS "name",
|
|
|
- IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",
|
|
|
- cr.organizeID AS organizeID
|
|
|
- FROM cm_discern_receipt a
|
|
|
+<!-- (SELECT-->
|
|
|
+<!-- <include refid="cmDiscernReceiptColumns"/>,-->
|
|
|
+<!-- cso.orderId AS orderID,-->
|
|
|
+<!-- cso.shopOrderNo as shopOrderNo,-->
|
|
|
+<!-- cso.shopOrderId as shopOrderId,-->
|
|
|
+<!-- cof.bankAccount AS bankNameType,-->
|
|
|
+<!-- s.checkMan,-->
|
|
|
+<!-- s.name AS shopName,-->
|
|
|
+<!-- u.userName AS "userName",-->
|
|
|
+<!-- u.name AS "name",-->
|
|
|
+<!-- IF(crr.relationType = '6',(SELECT NAME FROM USER mu WHERE mu.userId=ccb.userId),'') AS "backname",-->
|
|
|
+<!-- cr.organizeID AS organizeID-->
|
|
|
+<!-- FROM cm_discern_receipt a-->
|
|
|
|
|
|
- LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'
|
|
|
- LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
|
|
|
- LEFT JOIN cm_order cr ON cr.orderId = crr.orderId
|
|
|
- LEFT JOIN cm_shop_order cso ON cso.orderId = cr.orderId
|
|
|
- LEFT JOIN shop s ON s.shopID = cso.shopID
|
|
|
- left join user u on u.userID = cr.userID
|
|
|
- LEFT JOIN club c ON cr.userId = c.userId
|
|
|
- LEFT JOIN cm_offline_collection cof ON a.payType = cof.type
|
|
|
- <where>
|
|
|
- crr.relationType != 1
|
|
|
- <if test="id != null and id != '' and id != 0 ">
|
|
|
- AND a.id = #{id}
|
|
|
- </if>
|
|
|
- <if test="organizeID != null and organizeID != 9999 ">
|
|
|
- AND cr.organizeID = #{organizeID}
|
|
|
- </if>
|
|
|
- <if test="organizeID == 9999 ">
|
|
|
- AND cr.orderType = 2
|
|
|
- </if>
|
|
|
- <if test="startTime != null and startTime != ''">
|
|
|
- AND (a.receiptDate > #{startTime} OR a.receiptDate = #{startTime})
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND (a.receiptDate < #{endTime} OR a.receiptDate = #{endTime})
|
|
|
- </if>
|
|
|
- <if test="payWay != null and payWay != ''">
|
|
|
- AND a.payWay = #{payWay}
|
|
|
- </if>
|
|
|
- <if test="payType != null and payType != ''">
|
|
|
- AND a.payType = #{payType}
|
|
|
- </if>
|
|
|
- <if test="receiptType != null and receiptType != ''">
|
|
|
- <if test="receiptType==2 and newReceiptType==3">
|
|
|
- and (a.receiptType = 9)
|
|
|
- or a.receiptType = #{receiptType}
|
|
|
- </if>
|
|
|
- <if test="receiptType!=2">
|
|
|
- AND a.receiptType = #{receiptType}
|
|
|
- </if>
|
|
|
- AND a.receiptType = #{receiptType}
|
|
|
- </if>
|
|
|
- <if test="newReceiptType !=null">
|
|
|
- <if test="newReceiptType==3">
|
|
|
- and a.newReceiptType =3
|
|
|
- </if>
|
|
|
- <if test="newReceiptType != 3">
|
|
|
- and a.newReceiptType=#{newReceiptType}
|
|
|
- </if>
|
|
|
- </if>
|
|
|
+<!-- LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'-->
|
|
|
+<!-- LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id-->
|
|
|
+<!---- LEFT JOIN cm_order cr ON cr.orderId = crr.orderId-->
|
|
|
+<!---- LEFT JOIN cm_shop_order cso ON cso.orderId = cr.orderId-->
|
|
|
+<!-- LEFT JOIN cm_shop_order cso ON cso.shopOrderId = crr.shopOrderId or cso.orderId = crr.orderId-->
|
|
|
+<!-- LEFT JOIN cm_order cr ON cr.orderId = cso.orderId-->
|
|
|
+<!-- LEFT JOIN shop s ON s.shopID = cso.shopID-->
|
|
|
+<!-- left join user u on u.userID = cr.userID-->
|
|
|
+<!-- LEFT JOIN club c ON cr.userId = c.userId-->
|
|
|
+<!-- LEFT JOIN cm_offline_collection cof ON a.payType = cof.type-->
|
|
|
+<!-- <where>-->
|
|
|
+<!-- crr.relationType != 1-->
|
|
|
+<!-- <if test="id != null and id != '' and id != 0 ">-->
|
|
|
+<!-- AND a.id = #{id}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="organizeID != null and organizeID != 9999 ">-->
|
|
|
+<!-- AND cr.organizeID = #{organizeID}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="organizeID == 9999 ">-->
|
|
|
+<!-- AND cr.orderType = 2-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="startTime != null and startTime != ''">-->
|
|
|
+<!-- AND (a.receiptDate > #{startTime} OR a.receiptDate = #{startTime})-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="endTime != null and endTime != ''">-->
|
|
|
+<!-- AND (a.receiptDate < #{endTime} OR a.receiptDate = #{endTime})-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="payWay != null and payWay != ''">-->
|
|
|
+<!-- AND a.payWay = #{payWay}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="payType != null and payType != ''">-->
|
|
|
+<!-- AND a.payType = #{payType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="receiptType != null and receiptType != ''">-->
|
|
|
+<!-- <if test="receiptType==2 and newReceiptType==3">-->
|
|
|
+<!-- and (a.receiptType = 9)-->
|
|
|
+<!-- or a.receiptType = #{receiptType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="receiptType!=2">-->
|
|
|
+<!-- AND a.receiptType = #{receiptType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- AND a.receiptType = #{receiptType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="newReceiptType !=null">-->
|
|
|
+<!-- <if test="newReceiptType==3">-->
|
|
|
+<!-- and a.newReceiptType =3-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="newReceiptType != 3">-->
|
|
|
+<!-- and a.newReceiptType=#{newReceiptType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- </if>-->
|
|
|
|
|
|
- <if test="receiptStatus != null and receiptStatus != ''">
|
|
|
- AND a.receiptStatus = #{receiptStatus}
|
|
|
- </if>
|
|
|
- <if test="orderNo != null and orderNo != ''">
|
|
|
- AND ((cr.orderNo like concat('%',#{orderNo},'%')) OR (cso.shopOrderNo like concat('%',#{orderNo},'%')))
|
|
|
- </if>
|
|
|
- <if test="orderID != null and orderID != ''">
|
|
|
- AND (cr.orderID = #{orderID} )
|
|
|
- </if>
|
|
|
- <if test="shopOrderId != null and shopOrderId != ''">
|
|
|
- AND (cso.shopOrderId = #{shopOrderId} )
|
|
|
- </if>
|
|
|
- <if test="userName != null and userName != ''">
|
|
|
- AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
|
|
|
- </if>
|
|
|
- <if test="receiptProgress != null and receiptProgress != ''">
|
|
|
- and (case when crr.relationType = '1' then
|
|
|
- cso_cr.receiptStatus
|
|
|
- else
|
|
|
- cr.receiptStatus
|
|
|
- end) = #{receiptProgress}
|
|
|
- </if>
|
|
|
- <if test="receiptOrderType != null and receiptOrderType != ''">
|
|
|
- and (case when crr.relationType = '1' then
|
|
|
- cso.orderType
|
|
|
- else
|
|
|
- cr.orderType
|
|
|
- end) = #{receiptOrderType}
|
|
|
- </if>
|
|
|
- <if test="associationNum != null and associationNum != ''">
|
|
|
- <if test="associationNum == 1">
|
|
|
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1
|
|
|
- </if>
|
|
|
- <if test="associationNum == 2">
|
|
|
- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')
|
|
|
- <![CDATA[ > ]]> 1
|
|
|
- </if>
|
|
|
- </if>
|
|
|
- <if test="paYee !=null and paYee != ''">
|
|
|
- <if test="paYee == '采美'">
|
|
|
- and a.payWay = 3
|
|
|
- OR a.payWay = 2
|
|
|
- AND a.newReceiptType != 3 AND a.payWay = 2
|
|
|
- </if>
|
|
|
- <if test="payWay==1">
|
|
|
- and s.name=#{paYee}
|
|
|
- </if>
|
|
|
+<!-- <if test="receiptStatus != null and receiptStatus != ''">-->
|
|
|
+<!-- AND a.receiptStatus = #{receiptStatus}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="orderNo != null and orderNo != ''">-->
|
|
|
+<!-- AND ((cr.orderNo like concat('%',#{orderNo},'%')) OR (cso.shopOrderNo like concat('%',#{orderNo},'%')))-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="orderID != null and orderID != ''">-->
|
|
|
+<!-- AND (cr.orderID = #{orderID} )-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="shopOrderId != null and shopOrderId != ''">-->
|
|
|
+<!-- AND (cso.shopOrderId = #{shopOrderId} )-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="userName != null and userName != ''">-->
|
|
|
+<!-- AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="receiptProgress != null and receiptProgress != ''">-->
|
|
|
+<!-- and (case when crr.relationType = '1' then-->
|
|
|
+<!-- cso_cr.receiptStatus-->
|
|
|
+<!-- else-->
|
|
|
+<!-- cr.receiptStatus-->
|
|
|
+<!-- end) = #{receiptProgress}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="receiptOrderType != null and receiptOrderType != ''">-->
|
|
|
+<!-- and (case when crr.relationType = '1' then-->
|
|
|
+<!-- cso.orderType-->
|
|
|
+<!-- else-->
|
|
|
+<!-- cr.orderType-->
|
|
|
+<!-- end) = #{receiptOrderType}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="associationNum != null and associationNum != ''">-->
|
|
|
+<!-- <if test="associationNum == 1">-->
|
|
|
+<!-- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0') = 1-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="associationNum == 2">-->
|
|
|
+<!-- and (select count(1) from cm_receipt_order_relation where receiptID = a.id and delFlag = '0')-->
|
|
|
+<!-- <![CDATA[ > ]]> 1-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="paYee !=null and paYee != ''">-->
|
|
|
+<!-- <if test="paYee == '采美'">-->
|
|
|
+<!-- and a.payWay = 3-->
|
|
|
+<!-- OR a.payWay = 2-->
|
|
|
+<!-- AND a.newReceiptType != 3 AND a.payWay = 2-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="payWay==1">-->
|
|
|
+<!-- and s.name=#{paYee}-->
|
|
|
+<!-- </if>-->
|
|
|
+
|
|
|
+<!-- </if>-->
|
|
|
+<!-- and a.delFlag = '0'-->
|
|
|
+<!-- </where> group by a.id order by a.id desc -->
|
|
|
+<!-- )-->
|
|
|
+<!-- union-->
|
|
|
|
|
|
- </if>
|
|
|
- and a.delFlag = '0'
|
|
|
- </where>
|
|
|
- )
|
|
|
- union
|
|
|
- (
|
|
|
SELECT
|
|
|
<include refid="cmDiscernReceiptColumns"/>,
|
|
|
cso.orderId AS orderID,
|
|
@@ -220,14 +222,17 @@
|
|
|
|
|
|
LEFT JOIN cm_receipt_order_relation crr ON crr.receiptId = a.id AND crr.delFlag = '0'
|
|
|
LEFT JOIN cm_coupon_buyrecord ccb ON crr.couponRecordId=ccb.id
|
|
|
- LEFT JOIN cm_order cr ON cr.orderId = crr.orderId
|
|
|
- LEFT JOIN cm_shop_order cso ON cso.shopOrderId = cr.orderId
|
|
|
+-- LEFT JOIN cm_order cr ON cr.orderId = crr.orderId
|
|
|
+-- LEFT JOIN cm_shop_order cso ON cso.shopOrderId = cr.orderId
|
|
|
+ LEFT JOIN cm_shop_order cso ON cso.shopOrderId = crr.shopOrderId or cso.orderId = crr.orderId
|
|
|
+ LEFT JOIN cm_order cr ON cr.orderId = cso.orderId
|
|
|
LEFT JOIN shop s ON s.shopID = cso.shopID
|
|
|
left join user u on u.userID = cr.userID
|
|
|
LEFT JOIN club c ON cr.userId = c.userId
|
|
|
LEFT JOIN cm_offline_collection cof ON a.payType = cof.type
|
|
|
<where>
|
|
|
- crr.relationType = 1
|
|
|
+-- crr.relationType = 1
|
|
|
+ a.delFlag = '0'
|
|
|
<if test="id != null and id != '' and id != 0 ">
|
|
|
AND a.id = #{id}
|
|
|
</if>
|
|
@@ -317,9 +322,10 @@
|
|
|
</if>
|
|
|
|
|
|
</if>
|
|
|
- and a.delFlag = '0'
|
|
|
+
|
|
|
</where>
|
|
|
- )
|
|
|
+ group by a.id order by a.id desc
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="findAllList" resultType="CmDiscernReceipt">
|
|
@@ -740,14 +746,15 @@
|
|
|
co.payTotalFee AS orderAmount,
|
|
|
co.payableAmount AS payableAmount,
|
|
|
co.onlinePayFlag,
|
|
|
- (select
|
|
|
- sum(o.needPayAmount)
|
|
|
- from cm_receipt_order_relation cror
|
|
|
- left join cm_shop_order o on cror.orderID = o.shopOrderID
|
|
|
- left join cm_discern_receipt cdr on cdr.id = cror.receiptID
|
|
|
- where o.orderID = cso.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
|
|
|
- and cdr.receiptStatus = '2'
|
|
|
- ) AS receiptAmount,
|
|
|
+ cso.receiptAmount AS receiptAmount,
|
|
|
+-- (select
|
|
|
+-- sum(o.needPayAmount)
|
|
|
+-- from cm_receipt_order_relation cror
|
|
|
+-- left join cm_shop_order o on cror.orderID = o.shopOrderID
|
|
|
+-- left join cm_discern_receipt cdr on cdr.id = cror.receiptID
|
|
|
+-- where o.orderID = cso.orderID and cror.delFlag = '0' and cdr.delFlag = '0'
|
|
|
+-- and cdr.receiptStatus = '2'
|
|
|
+-- ) AS receiptAmount,
|
|
|
bou.name AS customerName,
|
|
|
cso.orderStatusFlag AS orderStatusFlag,
|
|
|
cso.receiptStatus AS receiptStatus,
|
|
@@ -970,6 +977,12 @@
|
|
|
where cror.orderID = #{orderID} and cror.delFlag = '0' and cror.relationType = '2'
|
|
|
and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay != '3'
|
|
|
</select>
|
|
|
+ <select id="findShoOrderIDReceipt" resultType="double">
|
|
|
+ select sum(associateAmount) from cm_receipt_order_relation cror
|
|
|
+ left join cm_discern_receipt cdr on cror.receiptID = cdr.id
|
|
|
+ where cror.shopOrderID = #{shopOrderID} and cror.delFlag = '0' and cror.relationType = '2'
|
|
|
+ and cdr.delFlag = '0' and cdr.receiptStatus = '3' and cdr.payWay != '3'
|
|
|
+ </select>
|
|
|
|
|
|
<select id="gathering" resultType="com.caimei.modules.order.entity.CmMainReceiptExport">
|
|
|
SELECT
|