| | |
| | | using Alipay.EasySDK.Payment.Common.Models; |
| | | using LifePayment.Application.Contracts; |
| | | using LifePayment.Application.LifePay; |
| | | using LifePayment.Domain; |
| | | using LifePayment.Domain.LifePay; |
| | | using LifePayment.Domain.Models; |
| | |
| | | private readonly IAliPayApi _aliPayApi; |
| | | private readonly IAlipayInterfaceManager _alipayInterfaceManager; |
| | | private readonly IWxPayApi _wxPayApi; |
| | | private readonly ILifePayRateService _lifePayRateService; |
| | | private readonly WxPayOption _wxPayOptions; |
| | | private readonly InitSetting _initSettingOptions; |
| | | |
| | |
| | | IRepository<LifePayAccount, Guid> lifePayAccount, |
| | | IDataFilter dataFilter, |
| | | IChannelFilter channelFilter, |
| | | ILifePayRateService lifePayRateService, |
| | | IAbpDistributedLock distributedLock) |
| | | { |
| | | _logger = logger; |
| | |
| | | _channelFilter = channelFilter; |
| | | this.distributedLock = distributedLock; |
| | | _operateHistory = operateHistory; |
| | | _lifePayRateService = lifePayRateService; |
| | | } |
| | | |
| | | #region 查询 |
| | |
| | | && x.OrderParamDetailJsonStr.Contains(input.ProductData.Phone)).AnyAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "您有同户号订单正在充值中,请勿重复充值"); |
| | | |
| | | var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认话费折扣); |
| | | var rateChannel = await GetLifePayRate(channle,input.ProductData.IspCode); |
| | | //平台折扣 |
| | | var rate = rateChannel.Rate; |
| | | |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate); |
| | | |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | //供应商折扣价 |
| | | var platformRate = rateChannel.SupplierRate; |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | |
| | | DiscountAmount = amount.DiscountAmount, |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100, |
| | | PlatformRate = platformRate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100, |
| | | ChannleRate = rate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | }; |
| | |
| | | && x.OrderParamDetailJsonStr.Contains(input.ProductData.ElectricAccount)).AnyAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "您有同户号订单正在充值中,请勿重复充值"); |
| | | |
| | | var rateChannel = await GetLifePayRate(channle, input.ProductData.ElectricType); |
| | | //平台折扣 |
| | | var rate = rateChannel.Rate; |
| | | |
| | | var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认电费折扣); |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate); |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | |
| | | //TODO 相关单项折扣调节功能未上线 目前针对情况临时写死 |
| | | if (input.ProductData.ElectricType == "guowang") |
| | | { |
| | | platformRate.Rate = 95; |
| | | } |
| | | //供应商折扣价 |
| | | var platformRate = rateChannel.SupplierRate; |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | |
| | | DiscountAmount = amount.DiscountAmount, |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100, |
| | | PlatformRate = platformRate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100, |
| | | ChannleRate = rate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | }; |
| | |
| | | && x.OrderParamDetailJsonStr.Contains(input.ProductData.GasAccount)).AnyAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "您有同户号订单正在充值中,请勿重复充值"); |
| | | |
| | | |
| | | var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认燃气折扣); |
| | | var rateChannel = await GetLifePayRate(channle, input.ProductData.GasOrgType); |
| | | //平台折扣 |
| | | var rate = rateChannel.Rate; |
| | | |
| | | var amount = CalculateAmount(input.ProductData.ParValue, rate); |
| | | |
| | | var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | //供应商折扣价 |
| | | var platformRate = rateChannel.SupplierRate; |
| | | |
| | | var orderInput = new CreateLifePayOrderInput |
| | | { |
| | |
| | | DiscountAmount = amount.DiscountAmount, |
| | | RechargeAmount = amount.RechargeAmount, |
| | | ChannelId = channle.ChannlesNum, |
| | | PlatformRate = platformRate.Rate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100, |
| | | PlatformRate = platformRate, |
| | | PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100, |
| | | ChannleRate = rate, |
| | | ChannlesRakeRate = channle.ChannlesRakeRate, |
| | | }; |
| | |
| | | dto.PromoterId = promoter.Id; |
| | | } |
| | | |
| | | //TODO 后续需要修改 现在的供应商折扣价根据运营商不同 配置不同 不是统一配置了 |
| | | var rate = await _lifePayRateRepository.FirstOrDefaultAsync(it => it.RateType == LifePayRateTypeEnum.供应商折扣价); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(rate != null && input.ChannlesRate < rate.Rate, "渠道折扣无法低于供应商折扣"); |
| | | |
| | |
| | | }; |
| | | } |
| | | |
| | | public async Task<decimal> GetLifePayRate(CreateEditPayChannelsInput channel, LifePayRateTypeEnum lifePayRateType) |
| | | public async Task<GetLifePayRateOutput> GetLifePayRate(CreateEditPayChannelsInput channel, string code) |
| | | { |
| | | var rateChannel = await _lifePayRateService.GetRateChannelByCode(code); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(rateChannel.Id.IsEmpty(), "未配置折扣"); |
| | | if (channel == null) |
| | | { |
| | | var rate = await GetRate(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣"); |
| | | var result = rate.FirstOrDefault(x => x.RateType == lifePayRateType).Rate; |
| | | return result; |
| | | return new GetLifePayRateOutput |
| | | { |
| | | Rate = rateChannel.PlatformRate, |
| | | SupplierRate = rateChannel.SupplierRate |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | return channel.ChannlesRate; |
| | | return new GetLifePayRateOutput { |
| | | Rate= channel.ChannlesRate, |
| | | SupplierRate = rateChannel.SupplierRate |
| | | }; |
| | | } |
| | | } |
| | | |