| | |
| | | using static LifePayment.Domain.Shared.LifePaymentConstant; |
| | | using ZeroD.Util.Fadd; |
| | | using Nest; |
| | | using Volo.Abp.Domain.Entities; |
| | | using Volo.Abp.ObjectMapping; |
| | | |
| | | namespace LifePayment.Application; |
| | | |
| | |
| | | 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; |
| | |
| | | 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, |
| | |
| | | _lifePayUserRepository = lifePayUserRepository; |
| | | _lifePayPremiumRepository = lifePayPremiumRepository; |
| | | _lifePayIntroInfoRepository = lifePayIntroInfoRepository; |
| | | _dallyStatisticsRepository = dallyStatisticsRepository; |
| | | _aliPayApi = aliPayApi; |
| | | _wxPayApi = wxPayApi; |
| | | _wxPayOptions = wxPayOptions.Value; |
| | |
| | | _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> |
| | | /// 获取电费面值 |
| | |
| | | Id = order.Id, |
| | | OutOrderNo = order.OutOrderNo, |
| | | LifePayChannle = channle.ChannlesName, |
| | | LifePayOrderStatus = order.LifePayOrderStatus, |
| | | Status = order.LifePayOrderStatus, |
| | | LifePayOrderType = order.LifePayOrderType, |
| | | LifePayType = order.LifePayType, |
| | | OrderNo = order.OrderNo, |
| | |
| | | Id = order.Id, |
| | | OutOrderNo = order.OutOrderNo, |
| | | LifePayChannle = channle.ChannlesName, |
| | | LifePayOrderStatus = order.LifePayOrderStatus, |
| | | Status = order.LifePayOrderStatus, |
| | | LifePayOrderType = order.LifePayOrderType, |
| | | LifePayType = order.LifePayType, |
| | | OrderNo = order.OrderNo, |
| | |
| | | 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, |
| | |
| | | |
| | | #region 记录日志 |
| | | |
| | | await PublishLifePayOrderHistoryEvent("退款", "退款", order.Id); |
| | | await LifePayOrderHistory("退款", "退款", order.Id, (int)OperateHistoryTypeEnum.LifePayRefund); |
| | | |
| | | #endregion |
| | | |
| | |
| | | private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate) |
| | | { |
| | | /// 正常支付 |
| | | //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, "支付金额错误"); |
| | | |
| | |
| | | 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> |