|
@@ -319,7 +319,126 @@
|
|
and a.delFlag = '0'
|
|
and a.delFlag = '0'
|
|
</where>
|
|
</where>
|
|
group by a.id
|
|
group by a.id
|
|
- )) as a order by a.id desc
|
|
|
|
|
|
+ )
|
|
|
|
+ union
|
|
|
|
+ (
|
|
|
|
+ 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_shop_order cso ON 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 is null
|
|
|
|
+ <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>
|
|
|
|
+ and a.delFlag = '0'
|
|
|
|
+ </where>
|
|
|
|
+ group by a.id
|
|
|
|
+ )
|
|
|
|
+) as a order by a.id desc
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findAllList" resultType="CmDiscernReceipt">
|
|
<select id="findAllList" resultType="CmDiscernReceipt">
|