From 02f5cf149ac0fecd8c7ee67bf57fb814d8464ba4 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期三, 02 四月 2025 16:31:09 +0800
Subject: [PATCH] fix:统计bug修复
---
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs | 5 ++
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 5 ++
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs | 13 ++++++
LifePayment/LifePayment.Domain/LifePay/DallyStatistics.cs | 5 ++
LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs | 2 +
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml | 7 +++
LifePayment/LifePayment.Application/LifePay/StatisticsService.cs | 54 +++++++++++++++++++++++---
7 files changed, 83 insertions(+), 8 deletions(-)
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs
index bf9259c..cc5dd39 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs
@@ -12,6 +12,8 @@
{
Task<TopStatisticsOutput> GetTopStatistics(List<string>? channleList = null);
+ Task StatisticsByDate(int days);
+
Task<ReceiptsListOutPut> GetReceiptsList(List<string>? channleList = null);
Task<ChannelDataListOutPut> GetChannelDataList(List<string>? channleList = null);
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
index 3ef7c0e..f2ab0af 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -1096,7 +1096,10 @@
/// </summary>
public int YesterdayActiveUsers { get; set; }
-
+ /// <summary>
+ /// 绱浣i噾
+ /// </summary>
+ public decimal AccumulatedChannlesRakePrice { get; set; }
}
public class ChannelRateOutput
diff --git a/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
index be6e9e8..6869c94 100644
--- a/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
@@ -59,6 +59,7 @@
var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.Date == today)
.WhereIf(channleList.Count() > 0, x => channleList.Contains(x.ChannelId))
.ToListAsync();
+ var totalRechargeReceipts = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false && x.CreationTime < today).SumAsync(x => x.RechargeAmount);
if (statistics == null || statistics.Count() == 0)
{
TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput() { };
@@ -68,7 +69,6 @@
var entity = await TopStatistics(item.ChannlesNum, today);
if (channleList.Count() == 0 || channleList.Contains(item.ChannlesNum))
{
- topStatisticsOutput.Amount += entity.Amount;
topStatisticsOutput.AccumulatedReceipts += entity.AccumulatedReceipts;
topStatisticsOutput.AccumulatedIncome += entity.AccumulatedIncome;
topStatisticsOutput.ReceiptsYesterday += entity.ReceiptsYesterday;
@@ -78,15 +78,26 @@
topStatisticsOutput.YesterdayFail += entity.YesterdayFail;
topStatisticsOutput.AccumulatedUsers += entity.AccumulatedUsers;
topStatisticsOutput.YesterdayActiveUsers += entity.YesterdayActiveUsers;
+ topStatisticsOutput.AccumulatedChannlesRakePrice += entity.AccumulatedChannlesRakePrice;
}
}
+
+ if (channleList.Count() == 0)
+ {
+ /// 璐︽埛浣欓
+ var accountBalance = totalRechargeReceipts - await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.PayStatus == LifePayStatusEnum.宸叉敮浠�
+ && (x.ACOOLYStatus == ACOOLYStatusEnum.鍏呭�兼垚鍔� || x.ACOOLYStatus == ACOOLYStatusEnum.宸插畬鎴� || x.ACOOLYStatus == ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�))
+ .SumAsync(x => x.PayAmount);
+ topStatisticsOutput.Amount = accountBalance ?? 0;
+
+ }
+
return topStatisticsOutput;
}
else
{
TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
{
- Amount = statistics.Sum(s => s.Amount),
AccumulatedReceipts = statistics.Sum(s => s.AccumulatedReceipts),
AccumulatedIncome = statistics.Sum(s => s.AccumulatedIncome),
ReceiptsYesterday = statistics.Sum(s => s.ReceiptsYesterday),
@@ -96,7 +107,17 @@
YesterdayFail = statistics.Sum(s => s.YesterdayFail),
AccumulatedUsers = statistics.Sum(s => s.AccumulatedUsers),
YesterdayActiveUsers = statistics.Sum(s => s.YesterdayActiveUsers),
+ AccumulatedChannlesRakePrice = statistics.Sum(s => s.AccumulatedChannlesRakePrice)
};
+ if (channleList.Count() == 0)
+ {
+ /// 璐︽埛浣欓
+ var accountBalance = totalRechargeReceipts - await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.PayStatus == LifePayStatusEnum.宸叉敮浠�
+ && (x.ACOOLYStatus == ACOOLYStatusEnum.鍏呭�兼垚鍔� || x.ACOOLYStatus == ACOOLYStatusEnum.宸插畬鎴� || x.ACOOLYStatus == ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�))
+ .SumAsync(x => x.PayAmount);
+ topStatisticsOutput.Amount = accountBalance ?? 0;
+
+ }
return topStatisticsOutput;
}
}
@@ -240,13 +261,30 @@
return channelDataList;
}
+ public async Task StatisticsByDate(int days)
+ {
+ var today = DateTime.Now.Date;
+ for (var i = 0; i < days; i++)
+ {
+ var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.Date == today)
+ .ToListAsync();
+
+ if (statistics == null || statistics.Count() == 0)
+ {
+ TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput() { };
+ var allChannle = await _lifePayChannlesRep.Where(x => x.IsDeleted == false).ToListAsync();
+ foreach (var item in allChannle)
+ {
+ var entity = await TopStatistics(item.ChannlesNum, today);
+ }
+ }
+
+ today = today.AddDays(-1);
+ }
+ }
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) -
@@ -279,12 +317,13 @@
/// 鏄ㄦ棩娲昏穬鐢ㄦ埛
var yesterdayActiveUsers = await _lifePayUserRepository.Where(x => x.IsDeleted == false).WhereIf(!string.IsNullOrWhiteSpace(channleId), x => x.CreationChannleNum == channleId).Where(x => x.LastLoginTime >= today.AddDays(-1)).CountAsync();
+ var accumulatedChannlesRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false && x.FinishTime < today)
+ .WhereIf(!string.IsNullOrWhiteSpace(channleId), x => x.ChannelId == channleId).SumAsync(x => x.ChannlesRakePrice);
var entity = new DallyStatistics()
{
Id = GuidGenerator.Create(),
CreationTime = today,
- Amount = accountBalance ?? 0,
AccumulatedReceipts = accumulatedReceipts ?? 0,
AccumulatedIncome = accumulatedIncome ?? 0,
IncomeYesterday = yesterdayIncome ?? 0,
@@ -296,6 +335,7 @@
AccumulatedUsers = accumulatedUsers,
YesterdayActiveUsers = yesterdayActiveUsers,
ChannelId = channleId,
+ AccumulatedChannlesRakePrice = accumulatedChannlesRakePrice,
Date = today.AddDays(-1)
};
await _dallyStatisticsRepository.InsertAsync(entity);
diff --git a/LifePayment/LifePayment.Domain/LifePay/DallyStatistics.cs b/LifePayment/LifePayment.Domain/LifePay/DallyStatistics.cs
index 919e81b..6318f6f 100644
--- a/LifePayment/LifePayment.Domain/LifePay/DallyStatistics.cs
+++ b/LifePayment/LifePayment.Domain/LifePay/DallyStatistics.cs
@@ -79,4 +79,9 @@
/// 缁熻鏃ユ湡
/// </summary>
public DateTime Date { get; set; }
+
+ /// <summary>
+ /// 绱浣i噾
+ /// </summary>
+ public decimal AccumulatedChannlesRakePrice { get; set; }
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
index e908e5a..64d0581 100644
--- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -70,6 +70,13 @@
<param name="input"></param>
<returns></returns>
</member>
+ <member name="M:LifePayment.HttpApi.LifePayController.StatisticsByDate(System.Int32)">
+ <summary>
+ 鑾峰彇鎸囧畾澶╂暟鐨勭粺璁℃暟鎹�
+ </summary>
+ <param name="days"></param>
+ <returns></returns>
+ </member>
<member name="M:LifePayment.HttpApi.LifePayController.GetReceiptsList(LifePayment.Application.Contracts.TopStatisticsInput)">
<summary>
鑾峰彇30鏃ユ敹娆剧粺璁�
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 1b32623..0d6aa37 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -1789,6 +1789,11 @@
鏄ㄦ棩娲昏穬鐢ㄦ埛
</summary>
</member>
+ <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.AccumulatedChannlesRakePrice">
+ <summary>
+ 绱浣i噾
+ </summary>
+ </member>
<member name="P:LifePayment.Application.Contracts.OnlineServiceInput.Link">
<summary>
鍦ㄧ嚎瀹㈡湇閾炬帴
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
index 5d60713..f060b43 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -61,6 +61,19 @@
}
/// <summary>
+ /// 鑾峰彇鎸囧畾澶╂暟鐨勭粺璁℃暟鎹�
+ /// </summary>
+ /// <param name="days"></param>
+ /// <returns></returns>
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task<int> StatisticsByDate(int days)
+ {
+ await _statisticsService.StatisticsByDate(days);
+ return Constant.SUCCESS;
+ }
+
+ /// <summary>
/// 鑾峰彇30鏃ユ敹娆剧粺璁�
/// </summary>
/// <param name="input"></param>
--
Gitblit v1.9.1