暂时提交

This commit is contained in:
chfei committed 2026-10-29 16:34:25 +08:00
1 parent 5d017740c6
commit b35f816a87
7 files changed
+96 -2

No files matched your search

+8
View File
@@ -8,6 +8,14 @@
模块内部类型、文件及方法统一不带平台前缀,后续平台通过模块区分。核心服务为 `ShopService`;扩展查询、详情响应和映射分别为 `ShopQueryRequest`、`ShopDetailsInfo`、`ShopDetailsMapper`。`PddLoginShopEntity` 表示导入的拼多多登录记录,`PddShopEntity` 保留 bxx 店铺映射。
原带平台标记的 Action 统一为 `SavePddShop`、`UpdatePddShopLogin`、`DeletePddShop`、`GetPddShops`、`GetTokens`、`GetShopToken`,客户端需同步更新路由。数据库映射、上游协议及已部署的 `Shops:E57WxAccounts` 配置键保持兼容。
## 仓储查询入口
当前仓储不使用内存缓存或 Redis。单店到期时间经 `ShopQueryService → IShopRepository.GetExpireTime` 读取;列表到期信息经 `ShopService → IShopRepository.GetExpireTimes` 一次批量查询数据库,不逐店查询。
空集合返回空结果,列表缺失到期记录按 0 处理,永久有效店铺由 Service 覆盖到期时间。列表的数据范围和跨月额度重置仍在 Service。续费沿用原有事务内 ORM 读写,不包含缓存失效管道。
本次只集中上述公共查询,没有将模块内全部 SQL 迁入 Repository。后续确需缓存时,再按查询的实时性要求实现,并覆盖事务提交后的失效路径。
## 调用方式
所有接口使用当前宿主认证,路由为 `POST /api/v1/shop/{Action}`,Action采用PascalCase业务命名。
@@ -17,6 +17,9 @@ namespace Store.Shops.Repositories
/// <param name="ShopId"></param>
/// <returns></returns>
DateTime GetExpireTime(string ShopId);
/// <summary>批量读取店铺到期记录;未找到的店铺不返回记录,供列表补充到期信息。</summary>
Task<List<ShopExpireEntity>> GetExpireTimes(string[] shopIds, CancellationToken cancellationToken = default);
}
internal class ShopRepository : BaseRepository<ShopEntity>, IShopRepository, ITransientDependency
{
@@ -27,6 +30,10 @@ namespace Store.Shops.Repositories
_freeSql = freeSql;
}
/// <summary>集中列表使用的到期查询,保持一次批量读取;续费事务仍使用事务内 ORM。</summary>
public Task<List<ShopExpireEntity>> GetExpireTimes(string[] shopIds, CancellationToken cancellationToken = default)
=> _freeSql.Select<ShopExpireEntity>().Where(e => shopIds.Contains(e.ShopId)).ToListAsync(cancellationToken);
/// <summary>
/// 获取用户商铺过期时间
/// </summary>
+4 -2
View File
@@ -7,6 +7,7 @@ using MAX.Framework.Validation;
using Store.Shops.Dtos;
using Store.Shops.Entities;
using Store.Shops.Mappers;
using Store.Shops.Repositories;
using Store.Users.Contracts;
using Store.Users.Contracts.Dtos;
using Store.Users.Contracts.Enums;
@@ -17,7 +18,8 @@ namespace Store.Shops.Services;
/// <summary>微信店铺业务;账号身份来自服务端,普通子账号只能访问主账号明确分配的店铺。</summary>
public sealed partial class ShopService(IFreeSql db, ICurrentUser currentUser, IUserQueryService users,
PddTokenClient tokens, Microsoft.Extensions.Configuration.IConfiguration configuration) : ITransientDependency
PddTokenClient tokens, Microsoft.Extensions.Configuration.IConfiguration configuration,
IShopRepository shops) : ITransientDependency
{
/// <summary>读取当前数据库账户,避免相信客户端传来的身份或管理员标志。</summary>
private async Task<UserInfo> Actor()
@@ -118,7 +120,7 @@ public sealed partial class ShopService(IFreeSql db, ICurrentUser currentUser, I
var mapper = new ShopDetailsMapper();
var result = rows.Select(mapper.Map).ToList();
var ids = rows.Select(s => s.ShopId).Where(s => !string.IsNullOrEmpty(s)).Distinct().ToArray();
var expires = await db.Select<ShopExpireEntity>().Where(e => ids.Contains(e.ShopId)).ToListAsync(ct);
var expires = await shops.GetExpireTimes(ids, ct);
var paid = actor.Authority?.Contains("充值用户") == true;
if (!admin && !string.IsNullOrEmpty(actor.ParentUserName))
paid |= (await users.GetUser(actor.ParentUserName)).Authority?.Contains("充值用户") == true;