fix: 修复服务号回调处理返回用户ID及缓存更新逻辑

This commit is contained in:
ccnetcore
2025-08-29 21:55:07 +08:00
parent 1fbd521d1a
commit d90e24f9ed
2 changed files with 11 additions and 8 deletions

View File

@@ -112,14 +112,13 @@ public class FuwuhaoService : ApplicationService
//根据操作类型,进行业务处理,返回处理结果,再写入缓存,10s过去相当于用户10s扫完app后轮询要在10秒内完成
var scenResult =
await _fuwuhaoManager.CallBackHandlerAsync(cache.SceneType, body.FromUserName, cache.UserId);
cache.SceneResult = scenResult;
cache.SceneResult = scenResult.SceneResult;
cache.UserId = scenResult.UserId;
await _sceneCache.SetAsync($"{FuwuhaoConst.SceneCacheKey}{scene}", cache,
new DistributedCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(50) });
//如果是注册将OpenId与Scene进行绑定代表用户有30分钟进行注册
if (scenResult == SceneResultEnum.Register)
if (scenResult.SceneResult == SceneResultEnum.Register)
{
await _openIdToSceneCache.SetAsync($"{FuwuhaoConst.OpenIdToSceneCacheKey}{body.FromUserName}", scene,
new DistributedCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) });
@@ -176,6 +175,10 @@ public class FuwuhaoService : ApplicationService
switch (output.SceneResult)
{
case SceneResultEnum.Login:
if (cache.UserId is null)
{
throw new ApplicationException("获取用户id异常请重试");
}
var loginInfo = await _accountService.PostLoginAsync(cache.UserId!.Value);
output.Token = loginInfo.Token;
output.RefreshToken = loginInfo.RefreshToken;