This commit is contained in:
2026-04-09 14:53:48 +08:00
parent 0627ffec42
commit ff7e749bf2
12 changed files with 182 additions and 0 deletions

View File

@@ -316,3 +316,24 @@ func RedisAgentWalletLockKey(shopID uint, walletType string) string
- **THEN** 系统使用 Redis 分布式锁 `agent_wallet:lock:10:main`,第一个请求获得锁,第二个请求等待或失败
---
### Requirement: 批量查询店铺主钱包余额
系统 SHALL 在 `AgentWalletStore` 中提供 `GetShopMainWalletBatch(ctx, shopIDs []uint) map[uint]*AgentWallet` 方法,一次查询多个店铺的主钱包(`wallet_type=main`)记录,返回以 `shop_id` 为 key 的 map。
**实现要求**
- 使用 `WHERE shop_id IN (?) AND wallet_type = 'main'` 单次查询,不得逐条查询
- 不在 map 中的 shop_id 表示该店铺暂无主钱包,调用方按零值处理
- 与现有 `GetShopCommissionSummaryBatch` 对称设计
#### Scenario: 批量查询多个店铺的主钱包
- **WHEN** 传入 shopIDs `[1, 2, 3]`,其中 shop 3 无主钱包记录
- **THEN** 返回 map `{1: &wallet1, 2: &wallet2}`shop 3 不在 map 中
#### Scenario: 传入空列表
- **WHEN** 传入空 `shopIDs`
- **THEN** 直接返回空 map不执行 DB 查询
---