fix: ERP统计查询在多租户关闭时的NullPointerException问题

- 修复ErpSaleStatisticsMapper.xml中硬编码使用getRequiredTenantId()导致的空指针异常
- 修复ErpPurchaseStatisticsMapper.xml中硬编码使用getRequiredTenantId()导致的空指针异常
- 使用条件判断getTenantId() != null来决定是否添加租户条件
- 添加单元测试验证多租户开启和关闭时的统计查询功能
- 确保向后兼容,多租户开启时正常工作,关闭时不报错
This commit is contained in:
芋道源码
2025-06-09 06:36:11 +00:00
parent 837f155668
commit 3b2a3dd0ea
3 changed files with 167 additions and 4 deletions

View File

@@ -10,7 +10,9 @@
<if test="endTime != null">
AND out_time &lt; #{endTime}
</if>
AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getRequiredTenantId()}
<if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null">
AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
</if>
AND deleted = 0) -
(SELECT IFNULL(SUM(total_price), 0)
FROM erp_sale_return
@@ -18,7 +20,9 @@
<if test="endTime != null">
AND return_time &lt; #{endTime}
</if>
AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getRequiredTenantId()}
<if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null">
AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
</if>
AND deleted = 0)
</select>