多租户层级查询优化

This commit is contained in:
2025-10-09 14:33:15 +08:00
parent da9bf97667
commit 6bfc01d2fc
25 changed files with 581 additions and 309 deletions
@@ -8,6 +8,7 @@
FROM orders o
LEFT JOIN tourisms t ON o.tourism_id = t.id
<where>
<!-- 业务筛选条件 -->
<if test="p.orderNo != null and p.orderNo != ''">
AND o.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
</if>
@@ -20,15 +21,33 @@
<if test="p.deviceSn != null and p.deviceSn != ''">
AND o.device_sn LIKE CONCAT('%', #{p.deviceSn}, '%')
</if>
<!-- 兼容 dashboard 透传的 qrcodeId 与现有 codeId 参数名 -->
<if test="p.codeId != null and p.codeId != ''">
AND o.code_id LIKE CONCAT('%', #{p.codeId}, '%')
</if>
<if test="p.qrcodeId != null and p.qrcodeId != ''">
AND o.code_id LIKE CONCAT('%', #{p.qrcodeId}, '%')
</if>
<if test="p.userId != null and p.userId != ''">
AND o.user_id LIKE CONCAT('%', #{p.userId}, '%')
</if>
<if test="p.mobile != null and p.mobile != ''">
AND o.mobile LIKE CONCAT('%', #{p.mobile}, '%')
</if>
<!-- 时间范围(与仪表盘统计口径一致) -->
<if test="p.startTime != null and p.startTime != ''">
AND o.create_time &gt;= #{p.startTime}
</if>
<if test="p.endTime != null and p.endTime != ''">
AND o.create_time &lt;= #{p.endTime}
</if>
<!-- 景区集合过滤(由租户+子孙→景区ID集合的去重结果提供) -->
<if test="p.tourismIds != null and p.tourismIds.size > 0">
AND o.tourism_id IN
<foreach collection="p.tourismIds" item="tid" open="(" separator="," close=")">#{tid}</foreach>
</if>
</where>
ORDER BY o.create_time DESC
</select>