|  |  | 
 |  |  |                                 RefundApplyRemark = a.RefundApplyRemark, | 
 |  |  |                                 RefundTime = a.RefundTime, | 
 |  |  |                                 ChannelName = b.ChannlesName, | 
 |  |  |                                 ActualRechargeAmount = a.ActualRechargeAmount, | 
 |  |  |                                 ActualRechargeAmount = a.RechargeAmount, | 
 |  |  |                                 PlatformDeductionAmount = a.PlatformDeductionAmount, | 
 |  |  |                                 ACOOLYStatus = a.ACOOLYStatus, | 
 |  |  |                                 LifePayRefundStatus = a.LifePayRefundStatus, | 
 |  |  | 
 |  |  |  | 
 |  |  |         var result = await (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) | 
 |  |  |         .Where(x => x.LifePayOrderStatus == LifePayOrderStatusEnum.待退款 || x.LifePayOrderStatus == LifePayOrderStatusEnum.已退款 || x.LifePayOrderStatus == LifePayOrderStatusEnum.退款中 | 
 |  |  |         || x.LifePayRefundStatus > LifePayRefundStatusEnum.无需退款) | 
 |  |  |                                             .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) | 
 |  |  |                                             .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) | 
 |  |  |         || (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) | 
 |  |  |                                             .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType) | 
 |  |  |                                             .WhereIf(input.EndRefundApplyTime.HasValue, x => x.RefundApplyTime <= input.EndRefundApplyTime) | 
 |  |  | 
 |  |  |                                 RefundCheckRemark = a.RefundCheckRemark, | 
 |  |  |                                 RefundApplyRemark = a.RefundApplyRemark, | 
 |  |  |                                 RefundApplyTime = a.RefundApplyTime, | 
 |  |  |                                 RefundOrderNo = a.RefundOrderNo, | 
 |  |  |                                 RefundTime = a.RefundTime, | 
 |  |  |                                 RefundPrice = a.RefundPrice, | 
 |  |  |                                 ChannelName = b.ChannlesName, | 
 |  |  |                                 ActualRechargeAmount = a.ActualRechargeAmount, | 
 |  |  |                                 ActualRechargeAmount = a.RechargeAmount, | 
 |  |  |                                 PlatformDeductionAmount = a.PlatformDeductionAmount, | 
 |  |  |                                 ACOOLYStatus = a.ACOOLYStatus, | 
 |  |  |                                 LifePayRefundStatus = a.LifePayRefundStatus, | 
 |  |  | 
 |  |  |     { | 
 |  |  |         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, | 
 |  |  |             PayAmount = x.PayAmount, | 
 |  |  |             PhoneNumber = x.PhoneNumber, | 
 |  |  |             RefundOrderNo = x.RefundOrderNo, | 
 |  |  |             RefundApplyTime = x.RefundApplyTime, | 
 |  |  |             ChannelName = x.ChannelName, | 
 |  |  |             CreationTime = x.CreationTime, | 
 |  |  |             ACOOLYStatus = x.ACOOLYStatus, | 
 |  |  |             RefundApplyRemark = x.RefundApplyRemark, | 
 |  |  |             RechargeAmount = x.RechargeAmount, | 
 |  |  |             ActualReceivedAmount = x.ActualReceivedAmount.ToString("F2"), | 
 |  |  |             LifePayRefundStatus = x.LifePayRefundStatus, | 
 |  |  | 
 |  |  |             s.SerialNumber = ++i; | 
 |  |  |             s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription(); | 
 |  |  |             s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription(); | 
 |  |  |             s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |             s.RechargeAmountStr = s.RechargeAmount.ToString("F2"); | 
 |  |  |             s.ActualReceivedAmount = s.ActualReceivedAmount; | 
 |  |  |             s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription(); | 
 |  |  |             s.PayAmountStr = s.PayAmount.ToString("F2"); | 
 |  |  |             s.LifePayTypeStr = s.LifePayType.GetDescription(); | 
 |  |  |             s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |             s.RefundApplyTimeStr = !s.RefundApplyTime.HasValue? string.Empty:s.RefundApplyTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); | 
 |  |  |         }); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  | 
 |  |  |         var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId); | 
 |  |  |          CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); | 
 |  |  |         var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId); | 
 |  |  |          | 
 |  |  |         var channlesRakePrice = (order.PayAmount - (order.PlatformDeductionAmount == null ? 0 : order.PlatformDeductionAmount)) * channle.ChannlesRakeRate / 100; | 
 |  |  |         var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount,order.PlatformRate, order.ChannleRate, order.ChannlesRakeRate,order.PremiumRate); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         var result = new LifePayOrderOutput() | 
 |  |  |                 { | 
 |  |  |             UserName = user.Name, | 
 |  |  | 
 |  |  |             RefundTime = order.RefundTime, | 
 |  |  |             ACOOLYOrderNo = order.ACOOLYOrderNo, | 
 |  |  |             LifePayRefundStatus = order.LifePayRefundStatus, | 
 |  |  |             ActualRechargeAmount = order.ActualRechargeAmount, | 
 |  |  |             ActualRechargeAmount = order.RechargeAmount, | 
 |  |  |             RefundPrice = order.RefundPrice, | 
 |  |  |             PlatformRate = order.PlatformRate, | 
 |  |  |             PlatformPrice = order.PlatformDeductionAmount, | 
 |  |  |             ElecBillUrl = order.ElecBillUrl.GetOssPath(), | 
 |  |  |             RefundElecBillUrl = order.RefundElecBillUrl.GetOssPath(), | 
 |  |  |             ChannleRate = channle.ChannlesRate, | 
 |  |  |             ChannlesRakeRate = channle.ChannlesRakeRate, | 
 |  |  |             ChannlesRakePrice = channlesRakePrice.HasValue ? 0 : Math.Round(channlesRakePrice.Value, 2), | 
 |  |  |             ChannleRate = order.ChannleRate, | 
 |  |  |             ChannlesRakeRate = order.ChannlesRakeRate, | 
 |  |  |             ChannlesRakePrice = orderpirce.ChannlesRakePrice, | 
 |  |  |             PremiumRate = order.PremiumRate, | 
 |  |  |             PremiumPrice = Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value:0), 2), | 
 |  |  |             Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value : 0), 2) | 
 |  |  |             PremiumPrice = orderpirce.PremiumPrice, | 
 |  |  |             Profit = orderpirce.Profit | 
 |  |  |         }; | 
 |  |  |  | 
 |  |  |         return result; | 
 |  |  | 
 |  |  |                                                         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.LifePayRefundStatusStr = s.LifePayRefundStatus.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 channle = await GetLifePayChannlesDtoByNum(input.ChannelId); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在"); | 
 |  |  |  | 
 |  |  |         var rate = await GetRate(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |         //var rate = await GetRate(); | 
 |  |  |         //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认话费折扣).Rate); | 
 |  |  |         var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认话费折扣); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate); | 
 |  |  |  | 
 |  |  |         var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); | 
 |  |  |          | 
 |  |  | 
 |  |  |             RechargeAmount = amount.RechargeAmount, | 
 |  |  |             ChannelId = channle.ChannlesNum, | 
 |  |  |             PlatformRate = platformRate.Rate, | 
 |  |  |             ChannleRate = channle.ChannlesRate, | 
 |  |  |             PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate /100, | 
 |  |  |             ChannleRate = rate, | 
 |  |  |             ChannlesRakeRate = channle.ChannlesRakeRate, | 
 |  |  |             //ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100 | 
 |  |  |         }; | 
 |  |  |  | 
 |  |  |         await CreateLifePayOrder(orderInput); | 
 |  |  | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在"); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.禁用, "渠道已被禁用"); | 
 |  |  |  | 
 |  |  |         var rate = await GetRate(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |         //var rate = await GetRate(); | 
 |  |  |         //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认电费折扣).Rate); | 
 |  |  |  | 
 |  |  |         var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认电费折扣); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate); | 
 |  |  |  | 
 |  |  |         var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); | 
 |  |  |  | 
 |  |  | 
 |  |  |             RechargeAmount = amount.RechargeAmount, | 
 |  |  |             ChannelId = channle.ChannlesNum, | 
 |  |  |             PlatformRate = platformRate.Rate, | 
 |  |  |             ChannleRate = channle.ChannlesRate, | 
 |  |  |             ChannleRate = rate, | 
 |  |  |             ChannlesRakeRate = channle.ChannlesRakeRate, | 
 |  |  |         }; | 
 |  |  |  | 
 |  |  | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在"); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.禁用, "渠道已被禁用"); | 
 |  |  |  | 
 |  |  |         var rate = await GetRate(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |         //var rate = await GetRate(); | 
 |  |  |         //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认燃气折扣).Rate); | 
 |  |  |  | 
 |  |  |         var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认燃气折扣); | 
 |  |  |  | 
 |  |  |         var amount = CalculateAmount(input.ProductData.ParValue, rate); | 
 |  |  |  | 
 |  |  |         var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); | 
 |  |  |  | 
 |  |  | 
 |  |  |             PayAmount = amount.PayAmont, | 
 |  |  |             DiscountAmount = amount.DiscountAmount, | 
 |  |  |             RechargeAmount = amount.RechargeAmount, | 
 |  |  |             ChannelId = channle.ChannlesNum | 
 |  |  |             ChannelId = channle.ChannlesNum, | 
 |  |  |             PlatformRate = platformRate.Rate, | 
 |  |  |             ChannleRate = rate, | 
 |  |  |             ChannlesRakeRate = channle.ChannlesRakeRate, | 
 |  |  |         }; | 
 |  |  |  | 
 |  |  |         await CreateLifePayOrder(orderInput); | 
 |  |  | 
 |  |  |         await _lifePayOrderRepository.UpdateAsync(order); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public async Task WxPayDomesticRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus) | 
 |  |  |     { | 
 |  |  |         var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); | 
 |  |  |         order.LifePayRefundStatus = refundStatus; | 
 |  |  |         switch (refundStatus) | 
 |  |  |         { | 
 |  |  |             case LifePayRefundStatusEnum.已退款: | 
 |  |  |                 order.LifePayOrderStatus = LifePayOrderStatusEnum.已退款; | 
 |  |  |                 order.ACOOLYStatus = ACOOLYStatusEnum.已退款; | 
 |  |  |                 break; | 
 |  |  |             case LifePayRefundStatusEnum.退款中: | 
 |  |  |                 order.LifePayOrderStatus = LifePayOrderStatusEnum.退款中; | 
 |  |  |                 break; | 
 |  |  |             default:break; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /// <summary> | 
 |  |  |     /// ACOOLYO订单通知处理 | 
 |  |  |     /// </summary> | 
 |  |  | 
 |  |  |         { | 
 |  |  |             order.ACOOLYOrderNo = acoolyOrderNo; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (status == LifePayOrderStatusEnum.待退款) | 
 |  |  |         { | 
 |  |  |             order.LifePayRefundStatus = LifePayRefundStatusEnum.待退款; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (refundApplyRemark.IsNotNullOrEmpty()) | 
 |  |  |         { | 
 |  |  |             order.RefundApplyRemark = refundApplyRemark; | 
 |  |  | 
 |  |  |  | 
 |  |  |         order.LifePayOrderStatus = status; | 
 |  |  |         order.ACOOLYStatus = acoolyStatus; | 
 |  |  |  | 
 |  |  |         order.FinishTime = DateTime.Now; | 
 |  |  |         await _lifePayOrderRepository.UpdateAsync(order); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                     order.LifePayOrderStatus = LifePayOrderStatusEnum.待退款; | 
 |  |  |                     order.LifePayRefundStatus = LifePayRefundStatusEnum.待退款; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 break; | 
 |  |  |             case LifePayTypeEnum.AliPay: | 
 |  |  |                 var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = Convert.ToInt32(input.RefundPrice * 100).ToString() }); | 
 |  |  |                 var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = input.RefundPrice.ToString() }); | 
 |  |  |                 if (aliRefundResult.Code != AlipayResultCode.Success) | 
 |  |  |                 { | 
 |  |  |                     throw new UserFriendlyException("退款失败"); | 
 |  |  |                     throw new UserFriendlyException("退款失败:" + aliRefundResult.SubMsg); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 order.LifePayOrderStatus = LifePayOrderStatusEnum.已退款; | 
 |  |  |                 order.LifePayRefundStatus = LifePayRefundStatusEnum.已退款; | 
 |  |  |                 break; | 
 |  |  |             default: throw new UserFriendlyException("退款失败"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         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.无需退款) | 
 |  |  |                                          .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) | 
 |  |  |                                          .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) | 
 |  |  |      || (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) | 
 |  |  |                                          .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType) | 
 |  |  |                                          .WhereIf(input.EndRefundApplyTime.HasValue, x => x.RefundApplyTime <= input.EndRefundApplyTime) | 
 |  |  | 
 |  |  |                     }); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal? platformRate,decimal? channleRate, | 
 |  |  |         decimal? channlesRakeRate,decimal? premiumRate) | 
 |  |  |     { | 
 |  |  |         /// 毛利 | 
 |  |  |         var grossProfit = price * (channleRate - platformRate) / 100; | 
 |  |  |  | 
 |  |  |         /// 平台扣款金额  充值面额 * 平台折扣比例 | 
 |  |  |         var platformPrice = price * platformRate / 100; | 
 |  |  |  | 
 |  |  |         /// 手续费 | 
 |  |  |         var premiumPrice = priceAmount * premiumRate / 100; | 
 |  |  |  | 
 |  |  |         /// 渠道佣金  ((充值面额 * 渠道折扣比例)-(充值面额 * 平台折扣比例))* 佣金比例 | 
 |  |  |         var channlesRakePrice = grossProfit * channlesRakeRate / 100; | 
 |  |  |  | 
 |  |  |         /// 利润 | 
 |  |  |         var profit = grossProfit - channlesRakePrice - premiumPrice; | 
 |  |  |  | 
 |  |  |         return new OrderPriceReturn() | 
 |  |  |         { | 
 |  |  |             PlatformPrice = platformPrice.HasValue? platformPrice.Value :0, | 
 |  |  |             PremiumPrice = premiumPrice.HasValue ? premiumPrice.Value : 0, | 
 |  |  |             ChannlesRakePrice = channlesRakePrice.HasValue? channlesRakePrice.Value:0, | 
 |  |  |             Profit = profit.HasValue ? profit.Value : 0 | 
 |  |  |         }; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public async Task<decimal> GetLifePayRate(CreateEditPayChannelsInput channel, LifePayRateTypeEnum lifePayRateType) | 
 |  |  |     { | 
 |  |  |         if (channel == null) | 
 |  |  |         { | 
 |  |  |             var rate = await GetRate(); | 
 |  |  |             CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); | 
 |  |  |             var result = rate.FirstOrDefault(x => x.RateType == lifePayRateType).Rate; | 
 |  |  |             return result; | 
 |  |  |         } | 
 |  |  |         else | 
 |  |  |         { | 
 |  |  |             return channel.ChannlesRate; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     #endregion | 
 |  |  | } |