|
@@ -3,4 +3,168 @@
|
|
<mapper namespace="com.caimei365.manager.dao.hehe.HeHeOrderDao">
|
|
<mapper namespace="com.caimei365.manager.dao.hehe.HeHeOrderDao">
|
|
|
|
|
|
|
|
|
|
|
|
+ <select id="findOrderList" resultType="com.caimei365.manager.entity.order.CmOrder">
|
|
|
|
+ SELECT DISTINCT
|
|
|
|
+ co.orderID AS orderId,
|
|
|
|
+ co.orderNo AS orderNo,
|
|
|
|
+ co.organizeID AS organizeId,
|
|
|
|
+ co.userID AS userId,
|
|
|
|
+ co.orderType AS orderType,
|
|
|
|
+ co.secondHandOrderFlag AS secondHandOrderFlag,
|
|
|
|
+ co.onlinePayFlag AS onlinePayFlag,
|
|
|
|
+ bou.shouHuoRen AS receiver,
|
|
|
|
+ IFNULL(c.name,c.nickName) AS buyer,
|
|
|
|
+ co.orderSource AS orderSource,
|
|
|
|
+ co.orderTotalFee AS orderTotalFee,
|
|
|
|
+ co.payableAmount AS payableAmount,
|
|
|
|
+ co.orderTime AS orderTime,
|
|
|
|
+ co.confirmTime AS confirmTime,
|
|
|
|
+ co.payTotalFee AS payTotalFee,
|
|
|
|
+ co.payStatus AS payStatus,
|
|
|
|
+ co.refundType AS refundType,
|
|
|
|
+ co.sendOutStatus AS sendOutStatus,
|
|
|
|
+ co.receiptStatus AS receiptStatus,
|
|
|
|
+ co.productCount AS productCount,
|
|
|
|
+ (SELECT IFNULL(sum(cop.shouldPayFee),0) FROM cm_order_product cop WHERE cop.orderId=co.orderID) AS
|
|
|
|
+ "shouldPayProduct",
|
|
|
|
+ co.status AS status,
|
|
|
|
+ co.splitFlag AS splitFlag,
|
|
|
|
+ co.postageOrderFlag AS postageOrderFlag,
|
|
|
|
+ if(chcm.id is not null,1,0) as collageFlag,
|
|
|
|
+ chc.status as collageStatus
|
|
|
|
+ FROM cm_order co
|
|
|
|
+ LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
|
|
|
|
+ LEFT JOIN user u ON u.userID = co.userID
|
|
|
|
+ LEFT JOIN cm_hehe_user c ON u.userID = c.userId
|
|
|
|
+ LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
|
|
|
|
+ LEFT JOIN product p ON cop.productID = p.productID
|
|
|
|
+ LEFT JOIN cm_hehe_collage_member chcm on co.orderID = chcm.orderId
|
|
|
|
+ LEFT JOIN cm_hehe_collage chc on chcm.collageId = chc.id
|
|
|
|
+ <where>
|
|
|
|
+ co.orderType = 2
|
|
|
|
+ <if test="orderId != null and orderId != ''">
|
|
|
|
+ AND co.orderID = #{orderId}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderNo != null and orderNo != ''">
|
|
|
|
+ AND co.orderNo = #{orderNo}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="status != null and status != ''">
|
|
|
|
+ <choose>
|
|
|
|
+ <when test="status == '99'.toString()">
|
|
|
|
+ AND co.status in (11,12,13,21,22,23,31,32,33)
|
|
|
|
+ </when>
|
|
|
|
+ <otherwise>
|
|
|
|
+ AND co.status = #{status}
|
|
|
|
+ </otherwise>
|
|
|
|
+ </choose>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="buyer != null and buyer != ''">
|
|
|
|
+ AND (c.name LIKE concat('%',#{buyer},'%') or c.nickName LIKE concat('%',#{buyer},'%'))
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderTime != null and orderTime != ''">
|
|
|
|
+ AND co.orderTime = #{orderTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sendOutStatus != null and sendOutStatus != ''">
|
|
|
|
+ AND co.sendOutStatus = #{sendOutStatus}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
+ AND co.orderTime <![CDATA[ >= ]]> #{startTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
+ AND co.orderTime <![CDATA[ <= ]]> #{endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="receiver != null and receiver != ''">
|
|
|
|
+ AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
|
|
|
|
+ </if>
|
|
|
|
+
|
|
|
|
+ <if test="receiptStatus != null and receiptStatus != ''">
|
|
|
|
+ AND co.receiptStatus = #{receiptStatus}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="payStatus != null and payStatus != ''">
|
|
|
|
+ AND co.payStatus = #{payStatus}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sendOutStatus != null and sendOutStatus != ''">
|
|
|
|
+ AND co.sendOutStatus = #{sendOutStatus}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
|
|
|
|
+ AND
|
|
|
|
+ <if test="returnedPurchaseStatus == 1">
|
|
|
|
+ exists
|
|
|
|
+ </if>
|
|
|
|
+ <if test="returnedPurchaseStatus == 0">
|
|
|
|
+ not exists
|
|
|
|
+ </if>
|
|
|
|
+ (select 1 from cm_returned_purchase c3 where c3.status = '1' and c3.orderID = co.orderID and c3.delFlag
|
|
|
|
+ = 0)
|
|
|
|
+ </if>
|
|
|
|
+ <if test="refundType != null and refundType != ''">
|
|
|
|
+ AND
|
|
|
|
+ <if test="refundType == 0">
|
|
|
|
+ co.refundType is null
|
|
|
|
+ </if>
|
|
|
|
+ <if test="refundType == 1">
|
|
|
|
+ co.refundType = '1'
|
|
|
|
+ </if>
|
|
|
|
+ <if test="refundType == 2">
|
|
|
|
+ co.refundType = '2'
|
|
|
|
+ </if>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="productName != null and productName != ''">
|
|
|
|
+ and p.name like CONCAT('%',#{productName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderRefundType != null and orderRefundType != ''">
|
|
|
|
+ <if test="orderRefundType == 0">
|
|
|
|
+ AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
|
|
|
|
+ 0) = 0
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderRefundType == 1">
|
|
|
|
+ AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
|
|
|
|
+ 0) > 0
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderRefundType == 11">
|
|
|
|
+ AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 1
|
|
|
|
+ and crp.delFlag = 0) > 0
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderRefundType == 12">
|
|
|
|
+ AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 2
|
|
|
|
+ and crp.delFlag = 0
|
|
|
|
+ <if test="startRefundTime != null and startRefundTime != ''">
|
|
|
|
+ AND crp.confirmReturnTime <![CDATA[ >= ]]> #{startRefundTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="endRefundTime != null and endRefundTime != ''">
|
|
|
|
+ AND crp.confirmReturnTime <![CDATA[ <= ]]> #{endRefundTime}
|
|
|
|
+ </if>
|
|
|
|
+ ) > 0
|
|
|
|
+ </if>
|
|
|
|
+ <if test="orderRefundType == 13">
|
|
|
|
+ AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 3
|
|
|
|
+ and crp.delFlag = 0) > 0
|
|
|
|
+ </if>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="collageFlag != null">
|
|
|
|
+ <if test="collageFlag == 1">
|
|
|
|
+ and chcm.id is not null
|
|
|
|
+ </if>
|
|
|
|
+ <if test="collageFlag == 0">
|
|
|
|
+ and chcm.id is null
|
|
|
|
+ </if>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="collageStatus != null">
|
|
|
|
+ and chc.status = #{collageStatus}
|
|
|
|
+ </if>
|
|
|
|
+ AND co.delFlag = 0
|
|
|
|
+ </where>
|
|
|
|
+ ORDER BY co.orderID DESC, co.orderTime DESC
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="findOrderIdInReturnPurchase" resultType="java.lang.Integer">
|
|
|
|
+ select orderID from cm_returned_purchase where status = '1'
|
|
|
|
+ and orderID in
|
|
|
|
+ <foreach collection="orderIds" open="(" close=")" item="oId" separator=",">
|
|
|
|
+ #{oId}
|
|
|
|
+ </foreach>
|
|
|
|
+ and delFlag = 0
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+
|
|
</mapper>
|
|
</mapper>
|