|
@@ -497,6 +497,226 @@
|
|
|
|
|
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
+ <select id="findOrderIdsByCondition" resultType="java.lang.Long">
|
|
|
|
|
+ SELECT DISTINCT td.id
|
|
|
|
|
+ FROM trade_order td
|
|
|
|
|
+ INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
|
|
|
|
|
+ LEFT JOIN trade_detail tdl ON td.id = tdl.order_id AND tdl.deleted = 0
|
|
|
|
|
+ LEFT JOIN product_spu ps ON ps.id = tdl.product_id
|
|
|
|
|
+ LEFT JOIN ota_distributor od ON od.id = td.source_id
|
|
|
|
|
+ LEFT JOIN trade_order_room_model torm ON torm.order_id = td.id
|
|
|
|
|
+ WHERE td.deleted = 0
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
|
|
|
|
|
+ and td.order_status in
|
|
|
|
|
+ <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.tenantId!=null">
|
|
|
|
|
+ AND td.tenant_id = #{vo.tenantId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test="vo.orderNo != null and vo.orderNo.length() == 4">
|
|
|
|
|
+ AND td.order_no like concat('%',#{vo.orderNo})
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <when test="vo.orderNo != null and vo.orderNo != ''">
|
|
|
|
|
+ AND td.order_no = #{vo.orderNo}
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.memberId != null and vo.memberId != ''">
|
|
|
|
|
+ AND td.member_id = #{vo.memberId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.voyageId != null and vo.voyageId != ''">
|
|
|
|
|
+ AND td.voyage_id = #{vo.voyageId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.shipId != null and vo.shipId != ''">
|
|
|
|
|
+ AND td.ship_id = #{vo.shipId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.routeId != null and vo.routeId != ''">
|
|
|
|
|
+ AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.dispatchStatus != null">
|
|
|
|
|
+ AND td.dispatch_status = #{vo.dispatchStatus}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.payType != null">
|
|
|
|
|
+ AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.otaCateId != null and vo.otaCateId != ''">
|
|
|
|
|
+ AND od.ota_category_id = #{vo.otaCateId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
|
|
|
|
|
+ and od.ota_category_id in
|
|
|
|
|
+ <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.otaId != null and vo.otaId != ''">
|
|
|
|
|
+ AND td.source_id = #{vo.otaId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.otaIds != null and vo.otaIds.size()>0">
|
|
|
|
|
+ AND td.source_id IN
|
|
|
|
|
+ <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.storeId != null and vo.storeId != ''">
|
|
|
|
|
+ AND td.store_id = #{vo.storeId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.productTag != null and vo.productTag != ''">
|
|
|
|
|
+ AND ps.product_tag = #{vo.productTag}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.productTag2 != null and vo.productTag2 != ''">
|
|
|
|
|
+ AND ps.product_tag2 = #{vo.productTag2}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.productTag3 != null and vo.productTag3 != ''">
|
|
|
|
|
+ AND ps.product_tag3 = #{vo.productTag3}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.productTag4 != null and vo.productTag4 != ''">
|
|
|
|
|
+ AND ps.product_tag4 = #{vo.productTag4}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
|
|
|
|
|
+ AND tdl.product_id in
|
|
|
|
|
+ <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
|
|
|
|
|
+ AND td.external_order_no = #{vo.externalOrderNo}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.credentialNo != null and vo.credentialNo != ''">
|
|
|
|
|
+ AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userName != null and vo.userName != ''">
|
|
|
|
|
+ AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test="vo.mobile != null and vo.mobile.length() == 4">
|
|
|
|
|
+ AND tou.mobile like concat('%',#{vo.mobile})
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <when test="vo.mobile != null and vo.mobile != ''">
|
|
|
|
|
+ AND tou.mobile = #{vo.mobile}
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <if test="vo.contactName != null and vo.contactName != ''">
|
|
|
|
|
+ AND tou.contact_name = #{vo.contactName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.travelDate != null and vo.travelDate != ''">
|
|
|
|
|
+ AND td.travel_date = #{vo.travelDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
|
|
|
|
|
+ AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
|
|
|
|
|
+ AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
|
|
|
|
|
+ AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
|
|
|
|
|
+ AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.orderDate != null and vo.orderDate != ''">
|
|
|
|
|
+ AND td.create_time = #{vo.orderDate}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.sellerId != null and vo.sellerId != ''">
|
|
|
|
|
+ AND td.seller_id = #{vo.sellerId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.shareName != null and vo.shareName != ''">
|
|
|
|
|
+ AND td.share_name like concat('%',#{vo.shareName},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.voucherCode != null and vo.voucherCode != ''">
|
|
|
|
|
+ AND tdl.voucher_code = #{vo.voucherCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.sellMethod != null and vo.sellMethod != ''">
|
|
|
|
|
+ AND td.sell_method = #{vo.sellMethod}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.productName != null and vo.productName != ''">
|
|
|
|
|
+ AND tdl.product_name like concat('%',#{vo.productName}, '%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.isFullPay == 0">
|
|
|
|
|
+ AND td.is_full_pay = #{vo.isFullPay}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.isComment != null">
|
|
|
|
|
+ AND td.is_comment = #{vo.isComment}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.sourceId != null and vo.sourceId != ''">
|
|
|
|
|
+ AND td.source_id = #{vo.sourceId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.paymentStatus != null">
|
|
|
|
|
+ AND td.pay_status = #{vo.paymentStatus}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.distributorId != null and vo.distributorId != ''">
|
|
|
|
|
+ AND td.source_id = #{vo.distributorId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.sourceName != null and vo.sourceName != ''">
|
|
|
|
|
+ AND td.source_name like concat('%',#{vo.sourceName}, '%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.travelStatus != null">
|
|
|
|
|
+ AND td.travel_status = #{vo.travelStatus}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.roomModelId != null and vo.roomModelId != ''">
|
|
|
|
|
+ AND torm.room_model_id = #{vo.roomModelId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.floor != null and vo.floor != ''">
|
|
|
|
|
+ AND torm.floor = #{vo.floor}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.isInsure != null and vo.isInsure != ''">
|
|
|
|
|
+ AND td.is_insure = #{vo.isInsure}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
|
|
|
|
|
+ AND exists (select 1 from trade_refund tr where tr.order_id=td.id and tr.refund_status = 6 and tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ ORDER BY td.create_time DESC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="findOrderDetailByIds"
|
|
|
|
|
+ resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
|
|
|
|
|
+ SELECT td.*,
|
|
|
|
|
+ tins.res_msg,
|
|
|
|
|
+ toa.audit_time auditTime,
|
|
|
|
|
+ tou.contact_name,
|
|
|
|
|
+ tou.credential_no,
|
|
|
|
|
+ tou.mobile,
|
|
|
|
|
+ count(tdl.id) num,
|
|
|
|
|
+ sum(CASE WHEN tdl.voucher_status IN (1,2,3,4,6,8,9) THEN 1 ELSE 0 END) realnum,
|
|
|
|
|
+ (tr.origin_amount - tr.refund_amount) feeAmount,
|
|
|
|
|
+ tdl.product_name,
|
|
|
|
|
+ tdl.spec_type,
|
|
|
|
|
+ ifnull(tr.origin_amount - tr.refund_amount, 0) realAmount,
|
|
|
|
|
+ tr.refund_amount refundAmount,
|
|
|
|
|
+ ps.product_tag productTag,
|
|
|
|
|
+ ps.product_tag2 productTag2
|
|
|
|
|
+ FROM trade_order td
|
|
|
|
|
+ INNER JOIN trade_order_user tou ON td.id = tou.order_id
|
|
|
|
|
+ LEFT JOIN trade_detail tdl ON td.id = tdl.order_id AND tdl.deleted = 0
|
|
|
|
|
+ LEFT JOIN product_spu ps ON ps.id = tdl.product_id
|
|
|
|
|
+ LEFT JOIN trade_order_audit toa ON toa.order_id = td.id AND toa.audit_status = 1
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT order_id,
|
|
|
|
|
+ sum(refund_amount) refund_amount,
|
|
|
|
|
+ sum(origin_amount) origin_amount
|
|
|
|
|
+ FROM trade_refund
|
|
|
|
|
+ WHERE refund_status = 6 AND refund_method != 2
|
|
|
|
|
+ GROUP BY order_id
|
|
|
|
|
+ ) tr ON td.id = tr.order_id
|
|
|
|
|
+ LEFT JOIN trade_insurance tins ON tins.order_id = td.id
|
|
|
|
|
+ WHERE td.id IN
|
|
|
|
|
+ <foreach collection="ids" item="id" open="(" close=")" separator=",">
|
|
|
|
|
+ #{id}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ GROUP BY td.id
|
|
|
|
|
+ ORDER BY td.create_time DESC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<select id="getTradeOrderUserPage"
|
|
<select id="getTradeOrderUserPage"
|
|
|
resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
|
|
resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
|
|
|
SELECT td.*,tins.res_msg,toa.audit_time auditTime,tou.contact_name,tou.credential_no,tou.mobile,count(tdl.id) num,sum(CASE WHEN tdl.voucher_status in (1,2,3,4,6,8,9) THEN 1 ELSE 0 END) realnum,(tr.origin_amount-tr.refund_amount) feeAmount,tdl.product_name,tdl.spec_type,ifnull(tr.origin_amount-tr.refund_amount,0) realAmount
|
|
SELECT td.*,tins.res_msg,toa.audit_time auditTime,tou.contact_name,tou.credential_no,tou.mobile,count(tdl.id) num,sum(CASE WHEN tdl.voucher_status in (1,2,3,4,6,8,9) THEN 1 ELSE 0 END) realnum,(tr.origin_amount-tr.refund_amount) feeAmount,tdl.product_name,tdl.spec_type,ifnull(tr.origin_amount-tr.refund_amount,0) realAmount
|