using System.Text.Json; using MAX.Framework.Commons; using MAX.Framework.Validation; using Microsoft.Extensions.Configuration; using Store.Shops.Dtos; using Store.Shops.Entities; namespace Store.Shops.Services; public sealed partial class ShopManagementService { public async Task> GetPddClients() { await Actor(); var clients = configuration.GetSection("Shops:PddClients").Get>() ?? []; if (clients.Count == 0 || clients.Any(c => string.IsNullOrWhiteSpace(c.ClientId) || string.IsNullOrWhiteSpace(c.ClientSecret) || string.IsNullOrWhiteSpace(c.RedirectUri))) throw new AppException("尚未完整配置拼多多应用信息"); return clients; } public async Task GetPddToken(PddTokenRequest request, CancellationToken ct = default) { RequestValidator.Validate(request); var actor = await Actor(); var name = actor.UserName; var member = "," + name + ","; if (!await db.Select().Where(s => s.MallId == request.MallId && (s.UserName == name || ("," + s.SubUserName + ",").Contains(member))).AnyAsync(ct)) throw new AppException("店铺不存在或无读取令牌权限"); return await e57.GetToken(request.MallId, ct); } }