public async Task <BodyResponse <RewardInfoVM> > Handle(GetLoginRewardCommand request, CancellationToken cancellationToken)
        {
            DateTime tnow      = DateTime.Now;
            int      dayOfWeek = (int)tnow.DayOfWeek;

            using (var locker = _redis.Locker(KeyGenHelper.GenUserWeekKey(tnow, request.Id, LoginRewardInfo.className)))
            {
                var rewardInfo = await _redis.GetLoginReward(tnow, request.Id);

                long rewardCoins = 0;
                if (rewardInfo == null || !rewardInfo.GettedDays.Contains(dayOfWeek))
                {
                    rewardCoins = _loginConfig.DayRewards[dayOfWeek];
                    if (rewardInfo == null)
                    {
                        rewardInfo = new LoginRewardInfo(request.Id, new List <int>());
                    }
                    rewardInfo.GettedDays.Add(dayOfWeek);
                    await _redis.SetUserLoginReward(tnow, rewardInfo);

                    _ = _mqBus.Publish(new AddMoneyMqCommand(request.Id, rewardCoins, 0, AddReason.LoginReward));
                }
                else
                {
                    return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.RewardGetted));
                }

                return(new BodyResponse <RewardInfoVM>(StatusCodeDefines.Success, null, new RewardInfoVM(rewardCoins)));
            }
        }
 public Task SetUserLoginReward(DateTime date, LoginRewardInfo info)
 {
     return(_redis.SetStringAsync(KeyGenHelper.GenUserWeekKey(date, info.Id, LoginRewardInfo.className), info, TimeSpan.FromDays(8)));
 }
 public Task <LoginRewardInfo> GetLoginReward(DateTime date, long id)
 {
     return(_redis.GetStringAsync <LoginRewardInfo>
                (KeyGenHelper.GenUserWeekKey(date, id, LoginRewardInfo.className)));
 }