From 87095b4a2d3e342f4374423b22d90f0ed6557a7d Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期三, 02 四月 2025 14:45:32 +0800 Subject: [PATCH] fix:bug修复 --- LifePayment/LifePayment.Application/LifePay/StatisticsService.cs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 50 insertions(+), 10 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs index 4998753..be6e9e8 100644 --- a/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs +++ b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs @@ -19,6 +19,7 @@ using System.Threading.Channels; using ZeroD.Util; using NPOI.SS.Formula.Functions; +using System.Security.Principal; namespace LifePayment.Application.LifePay { @@ -28,19 +29,22 @@ 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; } @@ -125,12 +129,12 @@ { ReceiptsDetail receive = new ReceiptsDetail() { - CreationTime = item.CreationTime.ToString("yyyy-MM-dd"), + CreationTime = item.CreationTime.AddDays(-1).ToString("yyyy-MM-dd"), Amount = item.TotalReceiptsYesterday }; ReceiptsDetail income = new ReceiptsDetail() { - CreationTime = item.CreationTime.ToString("yyyy-MM-dd"), + CreationTime = item.CreationTime.AddDays(-1).ToString("yyyy-MM-dd"), Amount = item.TotalIncomeYesterday }; receiptsListOutPut.ReceiveList.Add(receive); @@ -138,6 +142,38 @@ } return receiptsListOutPut; + } + + public async Task<ChannlesRakeListOutPut> GetChannlesRakeList(List<string> channleList) + { + var today = DateTime.Now.Date; + var statistics = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false && + x.FinishTime.Date <= today && x.FinishTime.Date >= today.AddDays(-30)) + .WhereIf(channleList.Count() > 0, x => channleList.Contains(x.ChannelId)) + .ToListAsync(); + var groupedStatistics = statistics + .GroupBy(x => x.FinishTime.ToString("yyyy-MM-dd")) + .Select(g => new + { + FinishTime = g.Key, + ChannlesRakePrice = g.Sum(x => x.ChannlesRakePrice), + }) + .ToList(); + + ChannlesRakeListOutPut channlesRakeListOutPut = new ChannlesRakeListOutPut(); + + foreach (var item in groupedStatistics) + { + ReceiptsDetail receive = new ReceiptsDetail() + { + CreationTime = item.FinishTime, + Amount = item.ChannlesRakePrice + }; + + channlesRakeListOutPut.ChannlesRakeList.Add(receive); + } + + return channlesRakeListOutPut; } @@ -164,7 +200,7 @@ { ChannelDataReceive receive = new ChannelDataReceive() { - ChannelId = item.ChannelId, + ChannelName = _lifePayChannlesRep.Where(x => x.ChannlesNum == item.ChannelId).FirstOrDefault().ChannlesName, ReceivePrice = item.ReceivePrice, ChannlesRakePrice = item.ChannlesRakePrice, }; @@ -190,7 +226,7 @@ { ChannelDataUserNumber usernumber = new ChannelDataUserNumber() { - ChannelId = item.ChannelId, + ChannelName = _lifePayChannlesRep.Where(x => x.ChannlesNum == item.ChannelId).FirstOrDefault().ChannlesName, Number = item.Number, }; if (channelDataList.UserNumberList.Count() < 5) @@ -202,12 +238,15 @@ return channelDataList; - } 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) - @@ -245,7 +284,7 @@ { Id = GuidGenerator.Create(), CreationTime = today, - Amount = 0, + Amount = accountBalance ?? 0, AccumulatedReceipts = accumulatedReceipts ?? 0, AccumulatedIncome = accumulatedIncome ?? 0, IncomeYesterday = yesterdayIncome ?? 0, @@ -256,7 +295,8 @@ YesterdayFail = yesterdayFail, AccumulatedUsers = accumulatedUsers, YesterdayActiveUsers = yesterdayActiveUsers, - ChannelId = channleId + ChannelId = channleId, + Date = today.AddDays(-1) }; await _dallyStatisticsRepository.InsertAsync(entity); return entity; -- Gitblit v1.9.1