perf(订单): 列表分页走时间索引与延迟关联,批量组装 VO,前端默认 30 天下单时间范围

This commit is contained in:
小蟑螂
2026-06-04 14:54:45 +08:00
parent 6d3d8c699b
commit 5a2b98b727
8 changed files with 425 additions and 112 deletions
@@ -0,0 +1,73 @@
<?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.ecom.order.mapper.OrderMapper">
<sql id="orderListFrom">
ec_order
<choose>
<when test="useShopTimeIndex">
FORCE INDEX (idx_company_shop_time)
</when>
<otherwise>
FORCE INDEX (idx_company_order_time)
</otherwise>
</choose>
</sql>
<sql id="orderListWhere">
WHERE company_id = #{companyId}
<if test="shopId != null">
AND shop_id = #{shopId}
</if>
<if test="platformOrderNo != null and platformOrderNo != ''">
<choose>
<when test="platformOrderNoPrefix">
AND platform_order_no LIKE CONCAT(#{platformOrderNo}, '%')
</when>
<otherwise>
AND platform_order_no LIKE CONCAT('%', #{platformOrderNo}, '%')
</otherwise>
</choose>
</if>
<if test="statusId != null">
AND status_id = #{statusId}
</if>
<if test="minReceivedAmount != null">
AND received_amount &gt;= #{minReceivedAmount}
</if>
<if test="maxReceivedAmount != null">
AND received_amount &lt;= #{maxReceivedAmount}
</if>
<if test="startOrderTime != null">
AND order_time &gt;= #{startOrderTime}
</if>
<if test="endOrderTime != null">
AND order_time &lt;= #{endOrderTime}
</if>
<if test="importTaskId != null">
AND import_task_id = #{importTaskId}
</if>
<if test="confirm != null">
AND confirm = #{confirm}
</if>
<if test="productId != null">
AND product_spec_id IN (
SELECT id FROM ec_product_spec WHERE 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 id
FROM <include refid="orderListFrom"/>
<include refid="orderListWhere"/>
ORDER BY ${orderByClause}
LIMIT #{limit} OFFSET #{offset}
</select>
</mapper>