From 7b1de9565e68debff4b77906f453acbcbf358a55 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 21 三月 2025 16:19:18 +0800
Subject: [PATCH] fix:提交
---
LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs | 5 +
LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs | 1
LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs | 15 +++
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 74 +-----------------
LifePayment/LifePayment.Application/LifePay/StatisticsService.cs | 98 ++++++++++++++++++++++++
5 files changed, 121 insertions(+), 72 deletions(-)
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
index 00e1bc6..8fd6eb2 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -10,7 +10,6 @@
public interface ILifePayService : IApplicationService
{
- Task<TopStatisticsOutput> GetTopStatistics();
/// <summary>
/// 鑾峰彇鐢佃垂闈㈠��
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs
new file mode 100644
index 0000000..2ba6f51
--- /dev/null
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/IStatisticsService.cs
@@ -0,0 +1,15 @@
+锘縰sing LifePayment.Domain.Shared;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Application.Services;
+using ZeroD.Util;
+
+namespace LifePayment.Application.Contracts;
+
+public interface IStatisticsService : IApplicationService
+{
+ Task<TopStatisticsOutput> GetTopStatistics();
+
+}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 577dd86..2b08ff7 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -61,7 +61,6 @@
IRepository<LifePayUser, Guid> lifePayUserRepository,
IRepository<LifePayPremium, Guid> lifePayPremiumRepository,
IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository,
- IRepository<DallyStatistics, Guid> dallyStatisticsRepository,
IRepository<OperateHistory, Guid> operateHistory,
IAliPayApi aliPayApi,
IAlipayInterfaceManager aliPayInterfaceManager,
@@ -79,7 +78,6 @@
_lifePayUserRepository = lifePayUserRepository;
_lifePayPremiumRepository = lifePayPremiumRepository;
_lifePayIntroInfoRepository = lifePayIntroInfoRepository;
- _dallyStatisticsRepository = dallyStatisticsRepository;
_aliPayApi = aliPayApi;
_alipayInterfaceManager = aliPayInterfaceManager;
_wxPayApi = wxPayApi;
@@ -94,65 +92,6 @@
#region 鏌ヨ
- public async Task<TopStatisticsOutput> GetTopStatistics()
- {
- var today = DateTime.Now.Date;
- var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.Date == today).FirstOrDefaultAsync();
- if (statistics == null)
- {
- var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.PayAmount);
- var receiptsYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).SumAsync(x => x.PayAmount);
- var accumulatedOrders = await _lifePayOrderRepository.Where(x => x.CreationTime < today).CountAsync();
- var accumulatedIncome = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.ActualRechargeAmount);
- var ordersNumYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).CountAsync();
- var yesterdaySuccess = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).CountAsync();
- var yesterdayFail = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插け璐�).CountAsync();
- var accumulatedUsers = await _lifePayUserRepository.CountAsync();
-
- var entity = new DallyStatistics()
- {
- Id = GuidGenerator.Create(),
- CreationTime = DateTime.Now,
- Amount = 0,
- AccumulatedReceipts = accumulatedReceipts,
- ReceiptsYesterday = receiptsYesterday,
- AccumulatedOrders = accumulatedOrders,
- OrdersNumYesterday = ordersNumYesterday,
- YesterdaySuccess = yesterdaySuccess,
- YesterdayFail = yesterdayFail,
- AccumulatedUsers = accumulatedUsers,
- };
- await _dallyStatisticsRepository.InsertAsync(entity);
-
- TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
- {
- Amount = entity.Amount,
- AccumulatedReceipts = entity.AccumulatedReceipts,
- ReceiptsYesterday = entity.ReceiptsYesterday,
- AccumulatedOrders = entity.AccumulatedOrders,
- OrdersNumYesterday = entity.OrdersNumYesterday,
- YesterdaySuccess = entity.YesterdaySuccess,
- YesterdayFail = entity.YesterdayFail,
- AccumulatedUsers = entity.AccumulatedUsers,
- };
- return topStatisticsOutput;
- }
- else
- {
- TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
- {
- Amount = statistics.Amount,
- AccumulatedReceipts = statistics.AccumulatedReceipts,
- ReceiptsYesterday = statistics.ReceiptsYesterday,
- AccumulatedOrders = statistics.AccumulatedOrders,
- OrdersNumYesterday = statistics.OrdersNumYesterday,
- YesterdaySuccess = statistics.YesterdaySuccess,
- YesterdayFail = statistics.YesterdayFail,
- AccumulatedUsers = statistics.AccumulatedUsers,
- };
- return topStatisticsOutput;
- }
- }
/// <summary>
/// 鑾峰彇鐢佃垂闈㈠��
@@ -1293,7 +1232,7 @@
if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插け璐� && order.PayStatus != LifePayStatusEnum.宸查��娆�)
{
- order.PayStatus = LifePayStatusEnum.寰呴��娆�;
+ order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�;
}
order.LifePayOrderStatus = status;
@@ -1313,7 +1252,7 @@
var order = await _lifePayOrderRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
- if (order.PayStatus == LifePayStatusEnum.宸查��娆�)
+ if (order.LifePayRefundStatus == LifePayRefundStatusEnum.宸查��娆�)
{
return;
}
@@ -1341,19 +1280,16 @@
var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 100), Convert.ToInt32(order.PayAmount * 100));
if (wxRefundResult.Status == "SUCCESS")
{
- order.PayStatus = LifePayStatusEnum.宸查��娆�;
order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
order.LifePayRefundStatus = LifePayRefundStatusEnum.宸查��娆�;
}
else if (wxRefundResult.Status == "PROCESSING")
{
- order.PayStatus = LifePayStatusEnum.閫�娆句腑;
order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆句腑;
order.LifePayRefundStatus = LifePayRefundStatusEnum.閫�娆句腑;
}
else
{
- order.PayStatus = LifePayStatusEnum.寰呴��娆�;
order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆惧け璐�;
order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�;
}
@@ -1365,8 +1301,6 @@
{
throw new UserFriendlyException("閫�娆惧け璐�");
}
-
- order.PayStatus = LifePayStatusEnum.宸查��娆�;
order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
break;
default: throw new UserFriendlyException("閫�娆惧け璐�");
@@ -1403,7 +1337,7 @@
throw new UserFriendlyException("闈炵敤鎴锋湰浜洪��娆�");
}
- if (order.PayStatus == LifePayStatusEnum.宸查��娆�)
+ if (order.LifePayRefundStatus == LifePayRefundStatusEnum.宸查��娆�)
{
return;
}
@@ -1537,7 +1471,7 @@
var order = await _lifePayOrderRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
- if (order.PayStatus == LifePayStatusEnum.宸查��娆�)
+ if(order.LifePayRefundStatus == LifePayRefundStatusEnum.宸查��娆�)
{
return;
}
diff --git a/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
new file mode 100644
index 0000000..d6b7fad
--- /dev/null
+++ b/LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
@@ -0,0 +1,98 @@
+锘縰sing LifePayment.Application.Contracts;
+using LifePayment.Domain.LifePay;
+using LifePayment.Domain.Models;
+using LifePayment.Domain.Shared;
+using LifePayment.Domain;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Data;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.EventBus.Distributed;
+using static Nest.FileSystemStats;
+using Microsoft.EntityFrameworkCore;
+
+namespace LifePayment.Application.LifePay
+{
+ public class StatisticsService : ApplicationService, IStatisticsService
+ {
+ private readonly IRepository<LifePayOrder, Guid> _lifePayOrderRepository;
+ private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository;
+ private readonly IRepository<DallyStatistics, Guid> _dallyStatisticsRepository;
+
+ public StatisticsService(
+ IRepository<LifePayOrder, Guid> lifePayOrderRepository,
+ IRepository<LifePayUser, Guid> lifePayUserRepository,
+ IRepository<DallyStatistics, Guid> dallyStatisticsRepository)
+ {
+ _lifePayOrderRepository = lifePayOrderRepository;
+ _lifePayUserRepository = lifePayUserRepository;
+ _dallyStatisticsRepository = dallyStatisticsRepository;
+ }
+
+ public async Task<TopStatisticsOutput> GetTopStatistics()
+ {
+ var today = DateTime.Now.Date;
+ var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.Date == today).FirstOrDefaultAsync();
+ if (statistics == null)
+ {
+ var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.PayAmount);
+ var receiptsYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).SumAsync(x => x.PayAmount);
+ var accumulatedOrders = await _lifePayOrderRepository.Where(x => x.CreationTime < today).CountAsync();
+ var accumulatedIncome = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.ActualRechargeAmount);
+ var ordersNumYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).CountAsync();
+ var yesterdaySuccess = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).CountAsync();
+ var yesterdayFail = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插け璐�).CountAsync();
+ var accumulatedUsers = await _lifePayUserRepository.CountAsync();
+
+ var entity = new DallyStatistics()
+ {
+ Id = GuidGenerator.Create(),
+ CreationTime = DateTime.Now,
+ Amount = 0,
+ AccumulatedReceipts = accumulatedReceipts,
+ ReceiptsYesterday = receiptsYesterday,
+ AccumulatedOrders = accumulatedOrders,
+ OrdersNumYesterday = ordersNumYesterday,
+ YesterdaySuccess = yesterdaySuccess,
+ YesterdayFail = yesterdayFail,
+ AccumulatedUsers = accumulatedUsers,
+ };
+ await _dallyStatisticsRepository.InsertAsync(entity);
+
+ TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+ {
+ Amount = entity.Amount,
+ AccumulatedReceipts = entity.AccumulatedReceipts,
+ ReceiptsYesterday = entity.ReceiptsYesterday,
+ AccumulatedOrders = entity.AccumulatedOrders,
+ OrdersNumYesterday = entity.OrdersNumYesterday,
+ YesterdaySuccess = entity.YesterdaySuccess,
+ YesterdayFail = entity.YesterdayFail,
+ AccumulatedUsers = entity.AccumulatedUsers,
+ };
+ return topStatisticsOutput;
+ }
+ else
+ {
+ TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+ {
+ Amount = statistics.Amount,
+ AccumulatedReceipts = statistics.AccumulatedReceipts,
+ ReceiptsYesterday = statistics.ReceiptsYesterday,
+ AccumulatedOrders = statistics.AccumulatedOrders,
+ OrdersNumYesterday = statistics.OrdersNumYesterday,
+ YesterdaySuccess = statistics.YesterdaySuccess,
+ YesterdayFail = statistics.YesterdayFail,
+ AccumulatedUsers = statistics.AccumulatedUsers,
+ };
+ return topStatisticsOutput;
+ }
+ }
+ }
+}
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
index 845b691..a7d2889 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -20,15 +20,18 @@
public class LifePayController : AbpController
{
private readonly ILifePayService _lifePayService;
+ private readonly IStatisticsService _statisticsService;
private readonly IWebClientInfoProvider _webClientInfoProvider;
private readonly ILogger<LifePayController> _logger;
public LifePayController(
ILifePayService lifePayService,
+ IStatisticsService statisticsService,
IWebClientInfoProvider webClientInfoProvider
, ILogger<LifePayController> logger
)
{
_lifePayService = lifePayService;
+ _statisticsService = statisticsService;
_webClientInfoProvider = webClientInfoProvider;
_logger = logger;
}
@@ -43,7 +46,7 @@
[AllowAnonymous]
public async Task<TopStatisticsOutput> GetTopStatistics()
{
- return await _lifePayService.GetTopStatistics();
+ return await _statisticsService.GetTopStatistics();
}
/// <summary>
--
Gitblit v1.9.1