|
|
@@ -189,6 +189,245 @@
|
|
|
SELECT id,parent_id parentId,cate_name cateName,sort_num sortNum from product_category WHERE type = 1 AND use_status = 1 AND deleted = 0
|
|
|
</select>
|
|
|
|
|
|
+ <select id="selectTouristExportHead"
|
|
|
+ resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(a.num) AS totalOrders,
|
|
|
+ SUM(a.num1) AS adultNum,
|
|
|
+ SUM(a.num2) AS childBabyNum,
|
|
|
+ SUM(a.num3) AS withNum,
|
|
|
+ SUM(a.num4) AS leaderNum,
|
|
|
+ SUM(a.payAmount) AS totalPayAmount,
|
|
|
+ SUM(a.actual_amount) AS totalActualAmount,
|
|
|
+ IFNULL((
|
|
|
+ SELECT GROUP_CONCAT(CONCAT( nationalityName, '(', num, ')') SEPARATOR ' ')
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ IFNULL(NULLIF(tv.nationality, ''), 1) AS nationalityCode,
|
|
|
+ IFNULL(NULLIF(ar.name, ''), '中国') AS nationalityName,
|
|
|
+ COUNT(1) AS num
|
|
|
+ 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 trade_visitor tv ON tdl.id = tv.detail_id AND tv.deleted = 0
|
|
|
+ LEFT JOIN area ar ON tv.nationality = ar.id
|
|
|
+ WHERE td.deleted = 0
|
|
|
+ AND tou.deleted = 0
|
|
|
+ AND tv.type IS NOT NULL
|
|
|
+ <include refid="commonWhereConditions"/>
|
|
|
+ GROUP BY nationalityCode
|
|
|
+ ) nationality_stats
|
|
|
+ ), '') AS nationalityStats,
|
|
|
+ IFNULL((
|
|
|
+ SELECT GROUP_CONCAT(CONCAT(roomName, '(', roomNum, ')') SEPARATOR ',')
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ CONCAT(rrm.name, tm.floor, 'F') AS roomName,
|
|
|
+ tm.floor AS floor,
|
|
|
+ COUNT(DISTINCT tm.room_index_id) AS roomNum
|
|
|
+ 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 trade_visitor tv ON tdl.id = tv.detail_id AND tv.deleted = 0
|
|
|
+ LEFT JOIN trade_order_room_model tm ON tv.room_index_id = tm.room_index_id AND tm.deleted = 0 AND td.id = tm.order_id
|
|
|
+ LEFT JOIN resource_room_model rrm ON tm.room_model_id = rrm.id
|
|
|
+ WHERE td.deleted = 0
|
|
|
+ AND tou.deleted = 0
|
|
|
+ AND tv.type IS NOT NULL
|
|
|
+ <include refid="commonWhereConditions"/>
|
|
|
+ GROUP BY rrm.name, tm.floor
|
|
|
+ ORDER BY tm.floor
|
|
|
+ ) room_stats
|
|
|
+ ), '') AS roomStats
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ COUNT(1) AS num,
|
|
|
+ SUM(CASE WHEN tv.type IN ('adultPlus', 'adultTake') THEN 1 ELSE 0 END) AS num1,
|
|
|
+ SUM(CASE WHEN tv.type IN ('babyTake','babyPlus','babyNonTake','childTake','childPlus','childNonTake') THEN 1 ELSE 0 END) AS num2,
|
|
|
+ SUM(CASE WHEN tv.type = 'with' THEN 1 ELSE 0 END) AS num3,
|
|
|
+ SUM(CASE WHEN tv.type = 'leader' THEN 1 ELSE 0 END) AS num4,
|
|
|
+ td.pay_amount AS payAmount,
|
|
|
+ IFNULL(topay.actual_amount, 0) AS actual_amount
|
|
|
+ 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 trade_visitor tv ON tdl.id = tv.detail_id AND tv.deleted = 0
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT order_id, SUM(pay_amount) AS actual_amount
|
|
|
+ FROM trade_order_pay
|
|
|
+ WHERE pay_status = 1
|
|
|
+ GROUP BY order_id
|
|
|
+ ) topay ON td.id = topay.order_id
|
|
|
+ WHERE
|
|
|
+ td.deleted = 0
|
|
|
+ AND tv.type IS NOT NULL
|
|
|
+ <include refid="commonWhereConditions"/>
|
|
|
+ GROUP BY td.id, td.pay_amount) a
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 公共查询条件 -->
|
|
|
+ <sql id="commonWhereConditions">
|
|
|
+ <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.externalOriginOrderNo != null and vo.externalOriginOrderNo != ''">
|
|
|
+ AND td.external_origin_order_no = #{vo.externalOriginOrderNo}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <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.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.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.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>
|
|
|
+ </sql>
|
|
|
+
|
|
|
<select id="getTradeOrderUserPage"
|
|
|
resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
|
|
|
SELECT td.*,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
|