| | |
| | | using Volo.Abp.Domain.Entities; |
| | | using Volo.Abp.ObjectMapping; |
| | | using NPOI.SS.Formula.Functions; |
| | | using StackExchange.Redis; |
| | | |
| | | namespace LifePayment.Application; |
| | | |
| | |
| | | public async Task<LifePayOrderOutput> GetLifePayOrderDetail(string orderNo) |
| | | { |
| | | var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId); |
| | | var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); |
| | | 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; |
| | |
| | | LifePayRefundStatus = order.LifePayRefundStatus, |
| | | ActualRechargeAmount = order.ActualRechargeAmount, |
| | | RefundPrice = order.RefundPrice, |
| | | PlatformRate = platformRate.Rate, |
| | | 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), |
| | | PremiumRate = premium == null ? 0 : premium.Rate, |
| | | PremiumPrice = premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2), |
| | | Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - (premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2)) |
| | | PremiumRate = order.PremiumRate, |
| | | PremiumPrice = Math.Round(order.PayAmount * order.PremiumRate, 2), |
| | | Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - Math.Round(order.PayAmount * order.PremiumRate, 2) |
| | | }; |
| | | |
| | | return result; |
| | |
| | | |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认话费折扣).Rate); |
| | | |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | | OrderNo = channle.ChannlesNum + CreateOrderNo(), |
| | |
| | | PayAmount = amount.PayAmont, |
| | | DiscountAmount = amount.DiscountAmount, |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | ChannleRate = channle.ChannlesRate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | }; |
| | | |
| | | await CreateLifePayOrder(orderInput); |
| | |
| | | |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认电费折扣).Rate); |
| | | |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | | OrderNo = channle.ChannlesNum + CreateOrderNo(), |
| | |
| | | PayAmount = amount.PayAmont, |
| | | DiscountAmount = amount.DiscountAmount, |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | ChannleRate = channle.ChannlesRate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | }; |
| | | |
| | | await CreateLifePayOrder(orderInput); |
| | |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); |
| | | |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认燃气折扣).Rate); |
| | | |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayType.HasValue, "当前订单已选择支付类型"); |
| | | |
| | | order.LifePayType = input.LifePayType; |
| | | |
| | | var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync(); |
| | | order.PremiumRate = premium == null ? 0 : premium.Rate; |
| | | await _lifePayOrderRepository.UpdateAsync(order); |
| | | |
| | | var desc = "生活缴费-"; |
| | |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (input.RefundPrice > order.PayAmount) |
| | | { |
| | | throw new UserFriendlyException("退款的金额不能大于实付金额"); |
| | | } |
| | | if (input.LifePayRefundType == LifePayRefundTypeEnum.全额退款 && input.RefundPrice != order.PayAmount) |
| | | |
| | | if (input.LifePayRefundType == LifePayRefundTypeEnum.全额退款) |
| | | { |
| | | throw new UserFriendlyException("全额退款的金额与实付金额不一致"); |
| | | input.RefundPrice = order.PayAmount; |
| | | } |
| | | |
| | | if (order.LifePayOrderStatus != LifePayOrderStatusEnum.已失败 && order.PayStatus != LifePayStatusEnum.待退款 && order.LifePayOrderStatus != LifePayOrderStatusEnum.退款待审核) |