Files
java-10584/.workbuddy/memory/2026-04-21.md
赵忠林 47ae81ca9f fix(wxlogin): 修复scene参数解析与多租户用户查询异常问题
- 修改UserMapper接口,selectByIdIgnoreTenant由返回单用户改为返回用户列表,避免多结果异常
- UserService新增listByIdIgnoreTenant方法,兼容多条用户记录查询
- WxLoginController优先从scene参数直接解析tenantId,兼容旧格式时使用list接口查询用户
- 调整website.getRunning判空,避免空指针异常
- 多处调用处修改获取用户信息的逻辑,防止因多租户导致的查询失败
- 前端三处vue组件调整scene格式为uid_userId_tenantId,确保tenantId正确传递
2026-04-21 12:44:25 +08:00

19 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2026-04-21 日志
## WxLoginController.getOrderQRCodeUnlimited 修复(完整)
### 根因
1. `extractTenantIdFromScene` 通过 `selectByIdIgnoreTenant` 反查用户获取 tenantIduserId=35280 在多租户下有2条记录 → `TooManyResultsException`
2. 异常被 catch 后 fallback 到默认租户 10550Redis 中无 `mp-weixin:10550` 缓存 → 最终失败
3. 第 452 行 `website.getRunning().equals(2)` 存在 NPE 风险
### 修复内容
- **后端 WxLoginController**: scene 格式改为 `uid_userId_tenantId`,优先从 scene 直接解析 tenantId兼容旧 `uid_userId` 格式时改用 `selectList` 避免多条记录异常
- **后端 UserMapper/UserService**: `selectByIdIgnoreTenant` 返回类型从 `User` 改为 `List<User>`;新增 `listByIdIgnoreTenant` 方法
- **后端 NPE 修复**: `website.getRunning().equals(2)``website != null && Integer.valueOf(2).equals(website.getRunning())`
- **前端 3 个 vue**: scene 从 `uid_${userId}` 改为 `uid_${userId}_${tenantId}`(从 tenantStore.company.tenantId 获取)
- shopDealerUser/index.vue
- shopDealerUserShop/index.vue
- shopDealerUserDelivery/index.vue