예제 #1
0
        public async Task <BodyResponse <BankruptcyInfoVM> > Handle(QueryBankruptcyCommand request, CancellationToken cancellationToken)
        {
            //查询当天redis记录
            DateTime tnow           = DateTime.Now;
            var      bankruptcyInfo = await _redis.GetBankruptcyInfo(tnow, request.Id);

            int totalTimes = _bankruptcyConfig.BankruptcyRewards.Count;
            int curTimes   = 0;

            if (bankruptcyInfo == null)
            {
                curTimes = 0;
            }
            else
            {
                curTimes = bankruptcyInfo.CurTimes;
            }
            return(new BodyResponse <BankruptcyInfoVM>(StatusCodeDefines.Success, null,
                                                       new BankruptcyInfoVM(BankruptcyInfoVM.BankruptcyRewardType.Day, totalTimes, curTimes,
                                                                            _bankruptcyConfig.BankruptcyRewards)));
        }
        public async Task <WrappedResponse <BankruptcyInfoVm> > Handle(QueryBankruptcyCommand request, CancellationToken cancellationToken)
        {
            //查询当天redis记录
            DateTime tnow           = DateTime.Now;
            var      bankruptcyInfo = await _rewardRedis.GetBankruptcyInfo(tnow, request.Id);

            int totalTimes = RewardManager.BankruptcyConf.BankruptcyRewards.Count;
            int curTimes;

            if (bankruptcyInfo == null)
            {
                curTimes = 0;
            }
            else
            {
                curTimes = bankruptcyInfo.CurTimes;
            }
            var getMoneyResponse = await _getMoneyClient.
                                   GetResponseExt <GetMoneyMqCmd, WrappedResponse <MoneyMqResponse> >
                                       (new GetMoneyMqCmd(request.Id));

            var  moneyInfo   = getMoneyResponse.Message;
            bool isAvailable = false;

            if (moneyInfo.ResponseStatus == ResponseStatus.Success)
            {
                if (moneyInfo.Body.CurCoins < RewardManager.BankruptcyConf.BankruptcyLimit)
                {
                    isAvailable = true;
                }
            }

            return(new WrappedResponse <BankruptcyInfoVm>(ResponseStatus.Success, null,
                                                          new BankruptcyInfoVm(BankruptcyInfoVm.BankruptcyRewardType.Day, totalTimes, curTimes,
                                                                               RewardManager.BankruptcyConf.BankruptcyRewards, isAvailable)));
        }