fix: 修复场景缓存为空时的处理逻辑并调整注册成功缓存写入方式

This commit is contained in:
chenchun
2025-08-29 11:34:57 +08:00
parent 6bd561b094
commit f9843c13d4

View File

@@ -101,6 +101,10 @@ public class FuwuhaoService : ApplicationService
}
var cache = await _sceneCache.GetAsync($"{FuwuhaoConst.SceneCacheKey}{scene}");
if (cache == null)
{
return "success"; // 跳过直接返回成功
}
//根据操作类型,进行业务处理,返回处理结果,再写入缓存,10s过去相当于用户10s扫完app后轮询要在10秒内完成
var scenResult =
@@ -228,10 +232,10 @@ public class FuwuhaoService : ApplicationService
Nick = userInfo.Nickname,
Icon = result.FirstOrDefault()?.Id.ToString()
});
var sceneCache = await _sceneCache.GetAsync($"{FuwuhaoConst.SceneCacheKey}{scene}");
sceneCache.SceneResult = SceneResultEnum.Login;
await _sceneCache.SetAsync($"{FuwuhaoConst.SceneCacheKey}:{scene}", sceneCache,
await _sceneCache.SetAsync($"{FuwuhaoConst.SceneCacheKey}:{scene}", new SceneCacheDto
{
SceneResult = SceneResultEnum.Register
},
new DistributedCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(50) });
return "恭喜你已注册成功意社区账号!";