|  |  | 
 |  |  |     { | 
 |  |  |         var result = await (await GetLifePayRefundOrderListFilter(input)).Select(x => new LifePayRefundOrderListTemplate | 
 |  |  |         { | 
 |  |  |             FinishTime = x.FinishTime, | 
 |  |  |             FinishTime = x.RefundTime, | 
 |  |  |             RefundPrice = x.RefundPrice, | 
 |  |  |             LifePayOrderType = x.LifePayOrderType, | 
 |  |  |             LifePayType = x.LifePayType, | 
 |  |  | 
 |  |  |             ChannelName = x.ChannelName, | 
 |  |  |             CreationTime = x.CreationTime, | 
 |  |  |             ACOOLYStatus = x.ACOOLYStatus, | 
 |  |  |             RefundApplyRemark = x.RefundApplyRemark, | 
 |  |  |             RechargeAmount = x.RechargeAmount, | 
 |  |  |             ActualReceivedAmount = x.ActualReceivedAmount.ToString("F2"), | 
 |  |  |             LifePayRefundStatus = x.LifePayRefundStatus, | 
 |  |  | 
 |  |  |                                                         CreationTime = x.CreationTime, | 
 |  |  |                                                         RefundCheckRemark = x.RefundCheckRemark, | 
 |  |  |                                                         RefundApplyRemark = x.RefundApplyRemark, | 
 |  |  |                                                         RefundApplyTime = x.RefundApplyTime, | 
 |  |  |                                                         RefundTime = x.RefundTime, | 
 |  |  |                                                         ACOOLYOrderNo = x.ACOOLYOrderNo, | 
 |  |  |                                                         LifePayRefundStatus = x.LifePayRefundStatus, | 
 |  |  | 
 |  |  |             ACOOLYStatus = x.ACOOLYStatus, | 
 |  |  |             //RefundApplyRemark = x.RefundApplyRemark, | 
 |  |  |             ChannelName = x.ChannelName, | 
 |  |  |             PlatformPrice = x.PlatformDeductionAmount.HasValue ? x.PlatformDeductionAmount.Value : 0 | 
 |  |  |             PlatformPrice = x.PlatformDeductionAmount.HasValue ? x.PlatformDeductionAmount.Value : 0.00m | 
 |  |  |         }).OrderByDescending(r => r.CreationTime).ToListAsync(); | 
 |  |  |         var i = 0; | 
 |  |  |         result.ForEach(s => | 
 |  |  |         { | 
 |  |  |             s.SerialNumber = ++i; | 
 |  |  |             s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription(); | 
 |  |  |             s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |             s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss); | 
 |  |  |             s.RechargeAmountStr = s.RechargeAmount.ToString("F2"); | 
 |  |  |             s.PayAmountStr = s.PayAmount.ToString("F2"); | 
 |  |  |             s.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |             s.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss); | 
 |  |  |             s.LifePayTypeStr = s.LifePayType.GetDescription(); | 
 |  |  |             s.PayStatusStr = s.PayStatus.GetDescription(); | 
 |  |  |             s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2"); | 
 |  |  |             s.LifePayRefundStatusStr = s.LifePayRefundStatusStr.GetDescription(); | 
 |  |  |             s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription(); | 
 |  |  |             //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription(); | 
 |  |  |             s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |             s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss); | 
 |  |  |         }); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  | 
 |  |  |  | 
 |  |  |         var rate = await GetRate(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |  | 
 |  |  |         //var rate = await GetLifePayRate(); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认话费折扣).Rate); | 
 |  |  |  | 
 |  |  | 
 |  |  |             order.ACOOLYOrderNo = acoolyOrderNo; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (status == LifePayOrderStatusEnum.待退款) | 
 |  |  |         { | 
 |  |  |             order.LifePayRefundStatus = LifePayRefundStatusEnum.待退款; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (refundApplyRemark.IsNotNullOrEmpty()) | 
 |  |  |         { | 
 |  |  |             order.RefundApplyRemark = refundApplyRemark; | 
 |  |  | 
 |  |  |         var order = await _lifePayOrderRepository.FirstOrDefaultAsync(x => x.Id == input.Id); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); | 
 |  |  |  | 
 |  |  |         if(order.LifePayRefundStatus == LifePayRefundStatusEnum.已退款) | 
 |  |  |         if (order.LifePayRefundStatus == LifePayRefundStatusEnum.已退款) | 
 |  |  |         { | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (order.LifePayOrderStatus == LifePayOrderStatusEnum.待退款) | 
 |  |  |         if (order.LifePayOrderStatus == LifePayOrderStatusEnum.待退款 || order.LifePayRefundStatus == LifePayRefundStatusEnum.待退款) | 
 |  |  |         { | 
 |  |  |             if (order.ACOOLYStatus == ACOOLYStatusEnum.已完成 || order.ACOOLYStatus == ACOOLYStatusEnum.部分充值成功) | 
 |  |  |             if (order.ACOOLYStatus == ACOOLYStatusEnum.已完成 || order.ACOOLYStatus == ACOOLYStatusEnum.充值成功 || order.ACOOLYStatus == ACOOLYStatusEnum.部分充值成功) | 
 |  |  |             { | 
 |  |  |                 order.LifePayOrderStatus = LifePayOrderStatusEnum.已完成; | 
 |  |  |             } | 
 |  |  |             else if (order.ACOOLYStatus == ACOOLYStatusEnum.充值失败) | 
 |  |  |             { | 
 |  |  |                 order.LifePayOrderStatus = LifePayOrderStatusEnum.退款失败; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             order.RefundCheckRemark = input.RefundCheckRemark; | 
 |  |  |             order.RefundCheckUserId = CurrentUser.Id; | 
 |  |  |             order.LifePayRefundStatus = LifePayRefundStatusEnum.退款驳回; | 
 |  |  |  | 
 |  |  |             await _lifePayOrderRepository.UpdateAsync(order); | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     private async Task<IQueryable<LifePayOrderListOutput>> GetLifePayOrderListFilter(QueryLifePayOrderListInput input) | 
 |  |  |     { | 
 |  |  |         var result = (from a in _lifePayOrderRepository.Where(x => x.PayStatus != LifePayStatusEnum.未支付) | 
 |  |  |                                             .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) | 
 |  |  |         var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync(); | 
 |  |  |         var result = (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) | 
 |  |  |                       .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) | 
 |  |  |                                             .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) | 
 |  |  |                                             .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime) | 
 |  |  |                                             .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType) | 
 |  |  |                                             .WhereIf(input.EndPayTime.HasValue, x => x.PayTime <= input.EndPayTime) | 
 |  |  |                                             .WhereIf(input.LifePayOrderStatus.HasValue, x => x.LifePayOrderStatus == input.LifePayOrderStatus.Value) | 
 |  |  |                                             .WhereIf(input.PayStatus.HasValue, x => x.PayStatus == input.PayStatus.Value) | 
 |  |  |                                             .WhereIf(input.ACOOLYStatus.HasValue, x => x.ACOOLYStatus == input.ACOOLYStatus.Value) | 
 |  |  |                                             .WhereIf(input.LifePayOrderType.HasValue, x => x.LifePayOrderType == input.LifePayOrderType.Value) | 
 |  |  |                                             .WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value) | 
 |  |  |                                             .WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.PhoneNumber.Contains(input.KeyWords) || x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords)) | 
 |  |  |                       join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp | 
 |  |  |                       from b in temp.DefaultIfEmpty() | 
 |  |  |                       select new LifePayOrderListOutput | 
 |  |  |                       { | 
 |  |  |                           DiscountAmount = a.DiscountAmount, | 
 |  |  |                           FinishTime = a.FinishTime, | 
 |  |  |                           Id = a.Id, | 
 |  |  |                           LifePayOrderStatus = a.LifePayOrderStatus, | 
 |  |  |                           LifePayOrderType = a.LifePayOrderType, | 
 |  |  |                           LifePayType = a.LifePayType, | 
 |  |  |                           OrderNo = a.OrderNo, | 
 |  |  |                           PayAmount = a.PayAmount, | 
 |  |  |                           PhoneNumber = a.PhoneNumber, | 
 |  |  |                           RechargeAmount = a.RechargeAmount, | 
 |  |  |                           UserId = a.UserId, | 
 |  |  |                           OutOrderNo = a.OutOrderNo, | 
 |  |  |                           PayStatus = a.PayStatus, | 
 |  |  |                           PayTime = a.PayTime, | 
 |  |  |                           ACOOLYOrderNo = a.ACOOLYOrderNo, | 
 |  |  |                           RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), | 
 |  |  |                           CreationTime = a.CreationTime, | 
 |  |  |                           RefundCheckRemark = a.RefundCheckRemark, | 
 |  |  |                           RefundApplyRemark = a.RefundApplyRemark, | 
 |  |  |                           RefundTime = a.RefundTime, | 
 |  |  |                           ChannelName = b.ChannlesName | 
 |  |  |                       }); | 
 |  |  |                                             .WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords) || channles.Contains(x.ChannelId)) | 
 |  |  |                             join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp | 
 |  |  |                             from b in temp.DefaultIfEmpty() | 
 |  |  |                             select new LifePayOrderListOutput | 
 |  |  |                             { | 
 |  |  |                                 DiscountAmount = a.DiscountAmount, | 
 |  |  |                                 FinishTime = a.FinishTime, | 
 |  |  |                                 Id = a.Id, | 
 |  |  |                                 LifePayOrderStatus = a.LifePayOrderStatus, | 
 |  |  |                                 LifePayOrderType = a.LifePayOrderType, | 
 |  |  |                                 LifePayType = a.LifePayType, | 
 |  |  |                                 OrderNo = a.OrderNo, | 
 |  |  |                                 PayAmount = a.PayAmount, | 
 |  |  |                                 PhoneNumber = a.PhoneNumber, | 
 |  |  |                                 RechargeAmount = a.RechargeAmount, | 
 |  |  |                                 UserId = a.UserId, | 
 |  |  |                                 OutOrderNo = a.OutOrderNo, | 
 |  |  |                                 PayStatus = a.PayStatus, | 
 |  |  |                                 PayTime = a.PayTime, | 
 |  |  |                                 ACOOLYOrderNo = a.ACOOLYOrderNo, | 
 |  |  |                                 RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), | 
 |  |  |                                 RefundPrice = a.RefundPrice, | 
 |  |  |                                 CreationTime = a.CreationTime, | 
 |  |  |                                 RefundCheckRemark = a.RefundCheckRemark, | 
 |  |  |                                 RefundApplyRemark = a.RefundApplyRemark, | 
 |  |  |                                 RefundTime = a.RefundTime, | 
 |  |  |                                 ChannelName = b.ChannlesName, | 
 |  |  |                                 ActualRechargeAmount = a.ActualRechargeAmount, | 
 |  |  |                                 PlatformDeductionAmount = a.PlatformDeductionAmount, | 
 |  |  |                                 ACOOLYStatus = a.ACOOLYStatus, | 
 |  |  |                                 LifePayRefundStatus = a.LifePayRefundStatus, | 
 |  |  |                             }); | 
 |  |  |  | 
 |  |  |          | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     { | 
 |  |  |         var result = (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) | 
 |  |  |      .Where(x => x.LifePayOrderStatus == LifePayOrderStatusEnum.待退款 || x.LifePayOrderStatus == LifePayOrderStatusEnum.已退款 || x.LifePayOrderStatus == LifePayOrderStatusEnum.退款中 | 
 |  |  |      || x.LifePayRefundStatus > LifePayRefundStatusEnum.无需退款) | 
 |  |  |      || (x.LifePayRefundStatus > LifePayRefundStatusEnum.无需退款 && x.LifePayRefundStatus != LifePayRefundStatusEnum.退款驳回)) | 
 |  |  |                                          .WhereIf(input.BeginRefundTime.HasValue, x => x.RefundTime >= input.BeginRefundTime) | 
 |  |  |                                          .WhereIf(input.EndRefundTime.HasValue, x => x.RefundTime <= input.EndRefundTime) | 
 |  |  |                                          .WhereIf(input.BeginRefundApplyTime.HasValue, x => x.RefundApplyTime >= input.BeginRefundApplyTime) | 
 |  |  | 
 |  |  |         }; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public async Task<decimal> GetLifePayRate(string channelId, LifePayRateTypeEnum lifePayRateType) | 
 |  |  |     { | 
 |  |  |         if (string.IsNullOrEmpty(channelId)) | 
 |  |  |         { | 
 |  |  |             var rate = await GetRate(); | 
 |  |  |             CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |             var result = rate.FirstOrDefault(x => x.RateType == lifePayRateType).Rate; | 
 |  |  |             return result; | 
 |  |  |         } | 
 |  |  |         else | 
 |  |  |         { | 
 |  |  |             var channel = await _lifePayChannlesRep.Where(x => x.ChannlesNum == channelId).FirstOrDefaultAsync(); | 
 |  |  |  | 
 |  |  |             CheckExtensions.IfTrueThrowUserFriendlyException(channel == null, "未找到对应渠道"); | 
 |  |  |             return channel.ChannlesRate; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     #endregion | 
 |  |  | } |