| | |
| | | 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) |
| | | .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) |
| | |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<LifePayOrderListTemplate>> GetLifePayRefudOrderPageExport(QueryLifePayRefundOrderListInput input) |
| | | public async Task<List<LifePayRefundOrderListTemplate>> GetLifePayRefudOrderPageExport(QueryLifePayRefundOrderListInput input) |
| | | { |
| | | |
| | | |
| | | var result = await (await GetLifePayRefundOrderListFilter(input)).Select(x => new LifePayOrderListTemplate |
| | | var result = await (await GetLifePayRefundOrderListFilter(input)).Select(x => new LifePayRefundOrderListTemplate |
| | | { |
| | | DiscountAmount = x.DiscountAmount, |
| | | FinishTime = x.FinishTime, |
| | | LifePayOrderStatus = x.LifePayOrderStatus, |
| | | RefundPrice = x.RefundPrice, |
| | | LifePayOrderType = x.LifePayOrderType, |
| | | LifePayType = x.LifePayType, |
| | | OrderNo = x.OrderNo, |
| | | PayAmount = x.PayAmount, |
| | | PhoneNumber = x.PhoneNumber, |
| | | RechargeAmount = x.RechargeAmount, |
| | | OutOrderNo = x.OutOrderNo, |
| | | PayStatus = x.PayStatus, |
| | | PayTime = x.PayTime, |
| | | ACOOLYOrderNo = x.ACOOLYOrderNo, |
| | | RefundOrderNo = x.RefundOrderNo, |
| | | ChannelName = x.ChannelName, |
| | | CreationTime = x.CreationTime, |
| | | RefundApplyRemark = x.RefundApplyRemark, |
| | | ChannelName = x.ChannelName |
| | | ACOOLYStatus = x.ACOOLYStatus, |
| | | RechargeAmount = x.RechargeAmount, |
| | | ActualReceivedAmount = x.ActualReceivedAmount.ToString("F2"), |
| | | LifePayRefundStatus = x.LifePayRefundStatus, |
| | | |
| | | }).OrderByDescending(r => r.CreationTime).ToListAsync(); |
| | | var i = 0; |
| | | result.ForEach(s => |
| | | { |
| | | 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.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); |
| | | s.LifePayTypeStr = s.LifePayType.GetDescription(); |
| | | s.PayStatusStr = s.PayStatus.GetDescription(); |
| | | s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription(); |
| | | s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.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, |
| | |
| | | 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; |
| | |
| | | { |
| | | DiscountAmount = x.DiscountAmount, |
| | | FinishTime = x.FinishTime, |
| | | LifePayOrderStatus = x.LifePayOrderStatus, |
| | | //LifePayOrderStatus = x.LifePayOrderStatus, |
| | | LifePayOrderType = x.LifePayOrderType, |
| | | LifePayType = x.LifePayType, |
| | | OrderNo = x.OrderNo, |
| | | PayAmount = x.PayAmount, |
| | | ActualRechargeAmount = x.ActualRechargeAmount.HasValue?x.ActualRechargeAmount.Value:0, |
| | | PhoneNumber = x.PhoneNumber, |
| | | RechargeAmount = x.RechargeAmount, |
| | | OutOrderNo = x.OutOrderNo, |
| | |
| | | PayTime = x.PayTime, |
| | | ACOOLYOrderNo = x.ACOOLYOrderNo, |
| | | CreationTime = x.CreationTime, |
| | | RefundApplyRemark = x.RefundApplyRemark, |
| | | ChannelName = x.ChannelName |
| | | LifePayRefundStatus = x.LifePayRefundStatus, |
| | | ACOOLYStatus = x.ACOOLYStatus, |
| | | //RefundApplyRemark = x.RefundApplyRemark, |
| | | ChannelName = x.ChannelName, |
| | | PlatformPrice = x.PlatformDeductionAmount.HasValue ? x.PlatformDeductionAmount.Value : 0 |
| | | }).OrderByDescending(r => r.CreationTime).ToListAsync(); |
| | | var i = 0; |
| | | result.ForEach(s => |
| | |
| | | s.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); |
| | | s.LifePayTypeStr = s.LifePayType.GetDescription(); |
| | | s.PayStatusStr = s.PayStatus.GetDescription(); |
| | | s.LifePayOrderStatusStr = s.LifePayOrderStatus.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); |
| | | }); |
| | | return result; |
| | |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate /100, |
| | | ChannleRate = channle.ChannlesRate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | //ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100 |
| | | }; |
| | | |
| | | 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> |
| | | /// <param name="orderNo"></param> |
| | | /// <param name="outOrderNo"></param> |
| | | /// <returns></returns> |
| | | public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount) |
| | | public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount,string refundApplyRemark) |
| | | { |
| | | var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); |
| | |
| | | order.ACOOLYOrderNo = acoolyOrderNo; |
| | | } |
| | | |
| | | 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() }); |
| | |
| | | { |
| | | throw new UserFriendlyException("退款失败"); |
| | | } |
| | | |
| | | order.LifePayOrderStatus = LifePayOrderStatusEnum.已退款; |
| | | order.LifePayRefundStatus = LifePayRefundStatusEnum.已退款; |
| | | break; |
| | | default: throw new UserFriendlyException("退款失败"); |
| | | } |
| | |
| | | && order.LifePayOrderStatus != LifePayOrderStatusEnum.待退款 && order.LifePayOrderStatus != LifePayOrderStatusEnum.已退款) |
| | | { |
| | | order.LifePayOrderStatus = LifePayOrderStatusEnum.待退款; |
| | | order.LifePayRefundStatus = LifePayRefundStatusEnum.待退款; |
| | | order.RefundApplyRemark = input.RefundApplyRemark; |
| | | order.RefundApplyTime = DateTime.Now; |
| | | |
| | | await _lifePayOrderRepository.UpdateAsync(order); |
| | | } |
| | | else if (order.LifePayOrderStatus == LifePayOrderStatusEnum.已退款 || order.LifePayRefundStatus == LifePayRefundStatusEnum.已退款) |
| | | else if (order.LifePayOrderStatus == LifePayOrderStatusEnum.待退款 || order.LifePayRefundStatus == LifePayRefundStatusEnum.待退款 || |
| | | order.LifePayOrderStatus == LifePayOrderStatusEnum.退款中 || order.LifePayRefundStatus == LifePayRefundStatusEnum.退款中 || |
| | | order.LifePayOrderStatus == LifePayOrderStatusEnum.已退款 || order.LifePayRefundStatus == LifePayRefundStatusEnum.已退款) |
| | | { |
| | | throw new UserFriendlyException("当前订单无法重复申请退款"); |
| | | } |
| | |
| | | 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) |
| | | .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) |
| | |
| | | PlatformDeductionAmount = a.PlatformDeductionAmount, |
| | | ACOOLYStatus = a.ACOOLYStatus, |
| | | LifePayRefundStatus = a.LifePayRefundStatus, |
| | | ActualReceivedAmount = a.ActualReceivedAmount.HasValue? a.ActualReceivedAmount.Value : 0 |
| | | }); |
| | | return result; |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | 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 |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | } |