| | |
| | | using System.Threading.Channels; |
| | | using ZeroD.Util; |
| | | using NPOI.SS.Formula.Functions; |
| | | using System.Security.Principal; |
| | | |
| | | namespace LifePayment.Application.LifePay |
| | | { |
| | |
| | | private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository; |
| | | private readonly IRepository<DallyStatistics, Guid> _dallyStatisticsRepository; |
| | | private readonly IRepository<LifePayChannlesRake, Guid> _lifePayChannlesRakeRepository; |
| | | private readonly IRepository<LifePayRechargeReceipts, Guid> _lifePayRechargeReceiptsRepository; |
| | | private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep; |
| | | |
| | | public StatisticsService( |
| | | IRepository<LifePayOrder, Guid> lifePayOrderRepository, |
| | | IRepository<LifePayUser, Guid> lifePayUserRepository, |
| | | IRepository<DallyStatistics, Guid> dallyStatisticsRepository, |
| | | IRepository<LifePayChannlesRake, Guid> lifePayChannlesRakeRepository, |
| | | IRepository<LifePayChannles, Guid> lifePayChannlesRep) |
| | | IRepository<DallyStatistics, Guid> dallyStatisticsRepository, |
| | | IRepository<LifePayChannlesRake, Guid> lifePayChannlesRakeRepository, |
| | | IRepository<LifePayRechargeReceipts, Guid> lifePayRechargeReceiptsRepository, |
| | | IRepository<LifePayChannles, Guid> lifePayChannlesRep) |
| | | { |
| | | _lifePayOrderRepository = lifePayOrderRepository; |
| | | _lifePayUserRepository = lifePayUserRepository; |
| | | _dallyStatisticsRepository = dallyStatisticsRepository; |
| | | _lifePayChannlesRakeRepository = lifePayChannlesRakeRepository; |
| | | _lifePayRechargeReceiptsRepository = lifePayRechargeReceiptsRepository; |
| | | _lifePayChannlesRep = lifePayChannlesRep; |
| | | } |
| | | |
| | |
| | | |
| | | private async Task<DallyStatistics> TopStatistics(string channleId, DateTime today) |
| | | { |
| | | var totalRechargeReceipts = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false && x.CreationTime < today).SumAsync(x => x.RechargeAmount); |
| | | var accountBalance = totalRechargeReceipts - await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.PayStatus == LifePayStatusEnum.已支付 |
| | | && (x.ACOOLYStatus == ACOOLYStatusEnum.充值成功 || x.ACOOLYStatus == ACOOLYStatusEnum.已完成 || x.ACOOLYStatus == ACOOLYStatusEnum.部分充值成功)) |
| | | .WhereIf(!string.IsNullOrWhiteSpace(channleId), x => x.ChannelId == channleId).SumAsync(x => x.PayAmount); |
| | | /// 累计收款:统计平台账户下订单创建时间在昨天及之前收到的【用户支付成功的金额-退款给用户的金额】; |
| | | var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.PayStatus != LifePayStatusEnum.未支付) |
| | | .WhereIf(!string.IsNullOrWhiteSpace(channleId), x => x.ChannelId == channleId).SumAsync(x => x.PayAmount) - |
| | |
| | | { |
| | | Id = GuidGenerator.Create(), |
| | | CreationTime = today, |
| | | Amount = 0, |
| | | Amount = accountBalance ?? 0, |
| | | AccumulatedReceipts = accumulatedReceipts ?? 0, |
| | | AccumulatedIncome = accumulatedIncome ?? 0, |
| | | IncomeYesterday = yesterdayIncome ?? 0, |