예제 #1
0
        public async Task <BaseApiResponse> IncentiveBenevolence([FromBody] IncentiveBenevolenceRequest request)
        {
            request.CheckNotNull(nameof(request));
            if (request.BenevolenceIndex <= 0 || request.BenevolenceIndex >= 1)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "善心指数异常"
                });
            }
            //遍历所有的钱包发送激励指令
            var wallets = _walletQueryService.ListPage();

            if (wallets.Any())
            {
                var totalBenevolenceAmount = wallets.Where(x => x.Benevolence > 1).Sum(x => x.Benevolence);
                //创建激励记录
                await ExecuteCommandAsync(new CreateBenevolenceIndexCommand(
                                              GuidUtil.NewSequentialId(),
                                              request.BenevolenceIndex,
                                              totalBenevolenceAmount
                                              ));

                foreach (var wallet in wallets)
                {
                    if (wallet.Benevolence > 1)
                    {
                        var command = new IncentiveBenevolenceCommand(wallet.Id, request.BenevolenceIndex);
                        await ExecuteCommandAsync(command);
                    }
                }
            }

            return(new BaseApiResponse());
        }
예제 #2
0
        public async Task <BaseApiResponse> IncentiveBenevolence(IncentiveBenevolenceRequest request)
        {
            request.CheckNotNull(nameof(request));
            if (request.BenevolenceIndex <= 0 || request.BenevolenceIndex >= 1)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "善心指数异常"
                });
            }
            //遍历所有的钱包发送激励指令
            var wallets = _walletQueryService.ListPage();

            if (wallets.Any())
            {
                var totalBenevolenceAmount = wallets.Where(x => x.Benevolence > 1).Sum(x => x.Benevolence);
                //创建激励记录
                await ExecuteCommandAsync(new CreateBenevolenceIndexCommand(
                                              GuidUtil.NewSequentialId(),
                                              request.BenevolenceIndex,
                                              totalBenevolenceAmount
                                              ));

                foreach (var wallet in wallets)
                {
                    if (wallet.Benevolence > 1)
                    {
                        var command = new IncentiveBenevolenceCommand(wallet.Id, request.BenevolenceIndex);
                        await ExecuteCommandAsync(command);
                    }
                }
            }
            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "激励福豆", Guid.Empty, "指数:{0}".FormatWith(request.BenevolenceIndex));

            return(new BaseApiResponse());
        }
예제 #3
0
        public void ResetTodayStatistic()
        {
            //遍历所有的钱包发送指令
            var wallets = _walletQueryService.ListPage().Where(x => x.YesterdayEarnings > 0 || x.TodayBenevolenceAdded > 0);

            if (wallets.Any())
            {
                foreach (var wallet in wallets)
                {
                    var command = new ResetTodayStatisticCommand
                    {
                        AggregateRootId = wallet.Id
                    };
                    _commandService.SendAsync(command);
                }
            }
        }
예제 #4
0
        public void Incentive()
        {
            var benevolenceIndex = RandomArray.BenevolenceIndex();

            if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                //周日两倍激励
                benevolenceIndex = benevolenceIndex * 2;
            }

            //善心指数判断
            if (benevolenceIndex <= 0 || benevolenceIndex >= 1)
            {
                throw new Exception("善心指数异常");
            }
            //所有待激励的钱包 福豆>1  钱包未锁定
            var wallets = _walletQueryService.ListPage().Where(x => x.Benevolence > 1 && x.IsFreeze == Common.Enums.Freeze.UnFreeze);

            //遍历所有的钱包发送激励指令
            if (wallets.Any())
            {
                var totalBenevolenceAmount = wallets.Sum(x => x.Benevolence);
                //创建激励记录
                _commandService.SendAsync(new CreateBenevolenceIndexCommand(
                                              GuidUtil.NewSequentialId(),
                                              benevolenceIndex,
                                              totalBenevolenceAmount
                                              ));

                foreach (var wallet in wallets)
                {
                    if (wallet.Benevolence > 1)
                    {
                        var command = new IncentiveBenevolenceCommand(wallet.Id, benevolenceIndex);
                        _commandService.SendAsync(command);
                    }
                }
            }
        }