From c2ff291b6f7c747e171d2d2155282c310503d169 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期四, 20 三月 2025 18:19:05 +0800 Subject: [PATCH] fix:新增日志 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 66 ++++++++++++++++++++++++++++++-- 1 files changed, 61 insertions(+), 5 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index c6e55a9..00a0bf7 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -23,6 +23,8 @@ using static LifePayment.Domain.Shared.LifePaymentConstant; using ZeroD.Util.Fadd; using Nest; +using Volo.Abp.Domain.Entities; +using Volo.Abp.ObjectMapping; namespace LifePayment.Application; @@ -36,8 +38,10 @@ private readonly IRepository<LifePayOrder, Guid> _lifePayOrderRepository; private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository; private readonly IRepository<LifePayIntroInfo, Guid> _lifePayIntroInfoRepository; + private readonly IRepository<DallyStatistics, Guid> _dallyStatisticsRepository; private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep; private readonly IRepository<LifePayAccount, Guid> _lifePayAccount; + private readonly IRepository<OperateHistory, Guid> _operateHistory; private readonly IDataFilter dataFilter; private readonly IChannelFilter _channelFilter; private readonly IAliPayApi _aliPayApi; @@ -54,6 +58,8 @@ IRepository<LifePayUser, Guid> lifePayUserRepository, IRepository<LifePayPremium, Guid> lifePayPremiumRepository, IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository, + IRepository<DallyStatistics, Guid> dallyStatisticsRepository, + IRepository<OperateHistory, Guid> operateHistory, IAliPayApi aliPayApi, IWxPayApi wxPayApi, IOptions<WxPayOption> wxPayOptions, @@ -69,6 +75,7 @@ _lifePayUserRepository = lifePayUserRepository; _lifePayPremiumRepository = lifePayPremiumRepository; _lifePayIntroInfoRepository = lifePayIntroInfoRepository; + _dallyStatisticsRepository = dallyStatisticsRepository; _aliPayApi = aliPayApi; _wxPayApi = wxPayApi; _wxPayOptions = wxPayOptions.Value; @@ -77,9 +84,42 @@ _lifePayAccount = lifePayAccount; this.dataFilter = dataFilter; _channelFilter = channelFilter; + _operateHistory = operateHistory; } #region 鏌ヨ + + public async Task<TopStatisticsOutput> GetTopStatistics() + { + var today = DateTime.Now.ToString("yyyy-MM-dd"); + var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.ToString("yyyy-MM-dd") == today).FirstOrDefaultAsync(); + if (statistics == null) + { + //var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.PayAmount); + + var entity = new DallyStatistics() + { + Id = GuidGenerator.Create(), + CreationTime = DateTime.Now, + Amount = "0", + AccumulatedReceipts = "0", + ReceiptsYesterda = "0", + AccumulatedOrders = "0", + OrdersNumYesterda = "0", + YesterdaSuccess = "0", + YesterdaFail = "0", + AccumulatedUsers = "0", + }; + + return new TopStatisticsOutput(); + } + else + { + var result = ObjectMapper.Map<DallyStatistics,TopStatisticsOutput>(statistics); + return result; + } + + } /// <summary> /// 鑾峰彇鐢佃垂闈㈠�� @@ -286,7 +326,7 @@ Id = order.Id, OutOrderNo = order.OutOrderNo, LifePayChannle = channle.ChannlesName, - LifePayOrderStatus = order.LifePayOrderStatus, + Status = order.LifePayOrderStatus, LifePayOrderType = order.LifePayOrderType, LifePayType = order.LifePayType, OrderNo = order.OrderNo, @@ -336,7 +376,7 @@ Id = order.Id, OutOrderNo = order.OutOrderNo, LifePayChannle = channle.ChannlesName, - LifePayOrderStatus = order.LifePayOrderStatus, + Status = order.LifePayOrderStatus, LifePayOrderType = order.LifePayOrderType, LifePayType = order.LifePayType, OrderNo = order.OrderNo, @@ -348,7 +388,9 @@ CreationTime = order.CreationTime, RefundCheckRemark = order.RefundCheckRemark, RefundApplyRemark = order.RefundApplyRemark, + RefundApplyTime = order.RefundApplyTime, RefundTime = order.RefundTime, + RefundOrderNo = order.RefundOrderNo, ACOOLYOrderNo = order.ACOOLYOrderNo, LifePayRefundStatus = order.LifePayRefundStatus, ActualRechargeAmount = order.ActualRechargeAmount, @@ -1169,7 +1211,7 @@ #region 璁板綍鏃ュ織 - await PublishLifePayOrderHistoryEvent("閫�娆�", "閫�娆�", order.Id); + await LifePayOrderHistory("閫�娆�", "閫�娆�", order.Id, (int)OperateHistoryTypeEnum.LifePayRefund); #endregion @@ -1512,10 +1554,10 @@ private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate) { /// 姝e父鏀粯 - //var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); + var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); /// 1鍒嗛挶鏀粯 - decimal payAmount = 0.01m; + //decimal payAmount = 0.01m; CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒"); @@ -1557,6 +1599,20 @@ await _distributedEventBus.PublishAsync(recordEto, false); } + private async Task LifePayOrderHistory(string operateContent, string operateName, Guid relationId, int? tableType = (int)OperateHistoryTypeEnum.LifePayRefund) + { + var operateHistory = new OperateHistory + { + CreatorName = CurrentUser.Name, + OperateContent = operateName, + OperateName = operateName, + RelationId = relationId, + TableType = tableType + + }; + await _operateHistory.InsertAsync(operateHistory); + } + /// <summary> /// 鑾峰彇鏀粯浜岀淮鐮� /// </summary> -- Gitblit v1.9.1