mirror of
https://gitee.com/qqtt-ah/ai-crm.git
synced 2026-11-24 13:09:20 +08:00
106 lines
3.7 KiB
XML
106 lines
3.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="top.xyquan.ecomdmbbackend.modules.ec.order.mapper.OrderMapper">
|
|
|
|
<sql id="orderListFrom">
|
|
ec_order o
|
|
<choose>
|
|
<when test="useShopTimeIndex">
|
|
FORCE INDEX (idx_ec_order_company_shop_time)
|
|
</when>
|
|
<otherwise>
|
|
FORCE INDEX (idx_ec_order_company_order_time)
|
|
</otherwise>
|
|
</choose>
|
|
</sql>
|
|
|
|
<sql id="orderListWhere">
|
|
WHERE o.company_id = #{companyId}
|
|
<if test="shopId != null">
|
|
AND o.shop_id = #{shopId}
|
|
</if>
|
|
<if test="platformCode != null and platformCode != ''">
|
|
AND o.platform_code = #{platformCode}
|
|
</if>
|
|
<if test="platformOrderNo != null and platformOrderNo != ''">
|
|
<choose>
|
|
<when test="platformOrderNoPrefix">
|
|
AND o.platform_order_no LIKE CONCAT(#{platformOrderNo}, '%')
|
|
</when>
|
|
<otherwise>
|
|
AND o.platform_order_no LIKE CONCAT('%', #{platformOrderNo}, '%')
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND o.status = #{status}
|
|
</if>
|
|
<if test="minPayAmount != null">
|
|
AND o.pay_amount >= #{minPayAmount}
|
|
</if>
|
|
<if test="maxPayAmount != null">
|
|
AND o.pay_amount <= #{maxPayAmount}
|
|
</if>
|
|
<if test="startOrderTime != null">
|
|
AND o.order_time >= #{startOrderTime}
|
|
</if>
|
|
<if test="endOrderTime != null">
|
|
AND o.order_time <= #{endOrderTime}
|
|
</if>
|
|
<if test="importTaskId != null">
|
|
AND o.import_task_id = #{importTaskId}
|
|
</if>
|
|
<if test="confirm != null">
|
|
AND o.confirm = #{confirm}
|
|
</if>
|
|
<if test="productId != null">
|
|
AND EXISTS (
|
|
SELECT 1 FROM ec_order_item i
|
|
INNER JOIN ec_product_sku s ON s.id = i.product_sku_id
|
|
WHERE i.order_id = o.id AND s.product_id = #{productId}
|
|
)
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="countOrderList" resultType="long">
|
|
SELECT COUNT(*)
|
|
FROM <include refid="orderListFrom"/>
|
|
<include refid="orderListWhere"/>
|
|
</select>
|
|
|
|
<select id="selectOrderListIds" resultType="long">
|
|
SELECT o.id
|
|
FROM <include refid="orderListFrom"/>
|
|
<include refid="orderListWhere"/>
|
|
ORDER BY ${orderByClause}
|
|
LIMIT #{limit} OFFSET #{offset}
|
|
</select>
|
|
|
|
<select id="selectMinOrderDateForSku" resultType="java.time.LocalDate">
|
|
SELECT MIN(DATE(o.order_time))
|
|
FROM ec_order o
|
|
INNER JOIN ec_order_item i ON i.order_id = o.id
|
|
WHERE o.company_id = #{companyId}
|
|
AND i.product_sku_id = #{skuId}
|
|
</select>
|
|
|
|
<select id="selectShopStatDatesForSku"
|
|
resultType="top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.dto.ShopStatDateRow">
|
|
SELECT DISTINCT o.shop_id AS shopId, DATE(o.order_time) AS statDate
|
|
FROM ec_order o
|
|
INNER JOIN ec_order_item i ON i.order_id = o.id
|
|
WHERE o.company_id = #{companyId}
|
|
AND i.product_sku_id = #{skuId}
|
|
AND o.order_time >= #{startTime}
|
|
AND o.order_time < #{endTime}
|
|
ORDER BY o.shop_id, statDate
|
|
</select>
|
|
|
|
<select id="selectShopIdsWithRecentActivity" resultType="long">
|
|
SELECT DISTINCT o.shop_id
|
|
FROM ec_order o
|
|
WHERE o.company_id = #{companyId}
|
|
AND o.update_time >= #{since}
|
|
</select>
|
|
</mapper>
|