| | |
| | | using Nest; |
| | | using Volo.Abp.Domain.Entities; |
| | | using Volo.Abp.ObjectMapping; |
| | | using NPOI.SS.Formula.Functions; |
| | | |
| | | namespace LifePayment.Application; |
| | | |
| | |
| | | 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; |
| | | private readonly IAlipayInterfaceManager _alipayInterfaceManager; |
| | | private readonly IWxPayApi _wxPayApi; |
| | | private readonly WxPayOption _wxPayOptions; |
| | | |
| | |
| | | IRepository<LifePayPremium, Guid> lifePayPremiumRepository, |
| | | IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository, |
| | | IRepository<DallyStatistics, Guid> dallyStatisticsRepository, |
| | | IRepository<OperateHistory, Guid> operateHistory, |
| | | IAliPayApi aliPayApi, |
| | | IAlipayInterfaceManager aliPayInterfaceManager, |
| | | IWxPayApi wxPayApi, |
| | | IOptions<WxPayOption> wxPayOptions, |
| | | IRepository<LifePayChannles, Guid> lifePayChannlesRep, |
| | |
| | | _lifePayIntroInfoRepository = lifePayIntroInfoRepository; |
| | | _dallyStatisticsRepository = dallyStatisticsRepository; |
| | | _aliPayApi = aliPayApi; |
| | | _alipayInterfaceManager = aliPayInterfaceManager; |
| | | _wxPayApi = wxPayApi; |
| | | _wxPayOptions = wxPayOptions.Value; |
| | | _distributedEventBus = distributedEventBus; |
| | |
| | | _lifePayAccount = lifePayAccount; |
| | | this.dataFilter = dataFilter; |
| | | _channelFilter = channelFilter; |
| | | _operateHistory = operateHistory; |
| | | } |
| | | |
| | | #region 查询 |
| | |
| | | }); |
| | | return result; |
| | | } |
| | | public async Task<string> GetBillErceiptExport(string orderNo) |
| | | { |
| | | try |
| | | { |
| | | var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); |
| | | |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "未找到订单信息"); |
| | | if (order.LifePayType == LifePayTypeEnum.AliPay) |
| | | { |
| | | var elecInfoInput = new DataBillErceiptApplyInput |
| | | { |
| | | Type = "FUND_DETAIL", |
| | | Key = orderNo |
| | | }; |
| | | |
| | | var elecInfoOutput = await _alipayInterfaceManager.DataBillErceiptApply(elecInfoInput); |
| | | if (elecInfoOutput != null) |
| | | { |
| | | var elecFileInput = new DataBillEreceiptQueryInput |
| | | { |
| | | FileId = elecInfoOutput.FileId, |
| | | }; |
| | | var elecFileOutput = await _alipayInterfaceManager.DataBillEreceiptQuery(elecFileInput); |
| | | if (!string.IsNullOrEmpty(elecFileOutput.DownloadUrl)) |
| | | { |
| | | return elecFileOutput.DownloadUrl; |
| | | } |
| | | return ""; |
| | | } |
| | | return ""; |
| | | } |
| | | else |
| | | { |
| | | WxPayTradeBillApplyRequest req = new WxPayTradeBillApplyRequest |
| | | { |
| | | OutBillNo = order.OutOrderNo, |
| | | }; |
| | | |
| | | var res = await _wxPayApi.WxPayTradeBillApply(req); |
| | | return ""; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError("获取订单号为{0}电子回单出现错误:{1}", orderNo, ex.Message); |
| | | return ""; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 操作 |
| | |
| | | |
| | | #region 记录日志 |
| | | |
| | | await PublishLifePayOrderHistoryEvent("退款", "退款", order.Id); |
| | | await LifePayOrderHistory("退款", "退款", order.Id, (int)OperateHistoryTypeEnum.LifePayRefund); |
| | | |
| | | #endregion |
| | | |
| | |
| | | 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> |