| | |
| | | private readonly InitSetting _initSettingOptions; |
| | | |
| | | private readonly IACOOLYManager _aCOOLYManager; |
| | | private readonly IRepository<LifePayPromoter, Guid> lifePayPromoterRepository; |
| | | |
| | | public LifePayService(IDistributedEventBus distributedEventBus, |
| | | ILogger<LifePayService> logger, |
| | | IACOOLYManager aCOOLYManager, |
| | | IRepository<LifePayPromoter, Guid> lifePayPromoterRepository, |
| | | IRepository<LifePayRate, Guid> lifePayRateRepository, |
| | | IRepository<LifePayOrder, Guid> lifePayOrderRepository, |
| | | IRepository<LifePayUser, Guid> lifePayUserRepository, |
| | |
| | | { |
| | | _logger = logger; |
| | | _aCOOLYManager = aCOOLYManager; |
| | | this.lifePayPromoterRepository = lifePayPromoterRepository; |
| | | _lifePayRateRepository = lifePayRateRepository; |
| | | _lifePayOrderRepository = lifePayOrderRepository; |
| | | _lifePayUserRepository = lifePayUserRepository; |
| | |
| | | var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在"); |
| | | |
| | | if (order.LifePayOrderStatus == LifePayOrderStatusEnum.已完成) |
| | | { |
| | | return; |
| | | } |
| | | //if (order.LifePayOrderStatus == LifePayOrderStatusEnum.已完成) |
| | | //{ |
| | | // return; |
| | | //} |
| | | |
| | | // order.PlatformDeductionAmount = payAmount; |
| | | order.ActualReceivedAmount = actualParValue; |
| | | |
| | | if (acoolyOrderNo.IsNotNullOrEmpty()) |
| | | { |
| | |
| | | |
| | | order.LifePayOrderStatus = status; |
| | | order.ACOOLYStatus = acoolyStatus; |
| | | order.FinishTime = DateTime.Now; |
| | | if (order.LifePayOrderStatus == LifePayOrderStatusEnum.已完成 |
| | | || order.LifePayOrderStatus == LifePayOrderStatusEnum.已退款) |
| | | { |
| | | order.FinishTime = DateTime.Now; |
| | | order.PlatformDeductionAmount = order.ActualReceivedAmount * order.PlatformRate / 100; |
| | | order.RefundPrice = Math.Round((1 - ((order.ActualReceivedAmount ?? 0) / (order.RechargeAmount ?? 0))) * (order.PayAmount ?? 0), 2); |
| | | } |
| | | |
| | | await _lifePayOrderRepository.UpdateAsync(order); |
| | | |
| | | if (order.LifePayOrderStatus == LifePayOrderStatusEnum.已完成) |
| | |
| | | { |
| | | var dto = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.Id == input.Id.Value); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(dto == null, "未获取到渠道折扣数据"); |
| | | if (!string.IsNullOrWhiteSpace(input.PromoterIdNumber) || !string.IsNullOrWhiteSpace(input.PromoterName)) |
| | | { |
| | | var promoter = await lifePayPromoterRepository.FirstOrDefaultAsync(it => it.IdNumber == input.PromoterIdNumber && it.Name == input.PromoterName); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(promoter == null, "该推广人不存在"); |
| | | dto.PromoterId = promoter.Id; |
| | | } |
| | | |
| | | dto.ChannlesName = input.ChannlesName; |
| | | dto.ChannlesNum = input.ChannlesNum; |
| | | dto.ChannlesRate = input.ChannlesRate; |
| | | dto.ChannlesRakeRate = input.ChannlesRakeRate; |
| | | dto.SwitchType = input.SwitchType; |
| | | dto.ChannlesType = input.ChannlesType; |
| | | dto.Status = input.Status; |
| | | dto.AgentType = input.AgentType; |
| | | dto.AreaProvinceId = input.AreaProvinceId; |
| | | dto.AreaCityId = input.AreaCityId; |
| | | #region 记录日志 |
| | | |
| | | await LifePayOrderHistory("渠道管理", "编辑", input.Id.Value, TableType.LifePayChannles); |
| | |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(input.ChannlesRate < 0.01m, "渠道折扣设置错误"); |
| | | input.Id = Guid.NewGuid(); |
| | | var entity = ObjectMapper.Map<CreateEditPayChannelsInput, LifePayChannles>(input); |
| | | if (!string.IsNullOrWhiteSpace(input.PromoterIdNumber) || !string.IsNullOrWhiteSpace(input.PromoterName)) |
| | | { |
| | | var promoter = await lifePayPromoterRepository.FirstOrDefaultAsync(it => it.IdNumber == input.PromoterIdNumber && it.Name == input.PromoterName); |
| | | CheckExtensions.IfTrueThrowUserFriendlyException(promoter == null, "该推广人不存在"); |
| | | entity.PromoterId = promoter.Id; |
| | | } |
| | | |
| | | await _lifePayChannlesRep.InsertAsync(entity); |
| | | |
| | | #region 记录日志 |
| | |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | private IQueryable<CreateEditPayChannelsInput> GetLifePayChannlesListFilter() |
| | | { |
| | | return _lifePayChannlesRep.Select(x => |
| | | new CreateEditPayChannelsInput |
| | | { |
| | | Id = x.Id, |
| | | ChannlesRate = x.ChannlesRate, |
| | | ChannlesRakeRate = x.ChannlesRakeRate, |
| | | ChannlesName = x.ChannlesName, |
| | | ChannlesNum = x.ChannlesNum, |
| | | Status = x.Status, |
| | | SwitchType = x.SwitchType, |
| | | ChannlesType = x.ChannlesType, |
| | | }); |
| | | return from x in _lifePayChannlesRep |
| | | join p in lifePayPromoterRepository on x.PromoterId equals p.Id into pg |
| | | from pgd in pg.DefaultIfEmpty() |
| | | select new CreateEditPayChannelsInput |
| | | { |
| | | Id = x.Id, |
| | | ChannlesRate = x.ChannlesRate, |
| | | ChannlesRakeRate = x.ChannlesRakeRate, |
| | | ChannlesName = x.ChannlesName, |
| | | ChannlesNum = x.ChannlesNum, |
| | | Status = x.Status, |
| | | SwitchType = x.SwitchType, |
| | | ChannlesType = x.ChannlesType, |
| | | AgentType = x.AgentType, |
| | | AreaProvinceId = x.AreaProvinceId, |
| | | AreaCityId = x.AreaCityId, |
| | | PromoterIdNumber = pgd.IdNumber, |
| | | PromoterName = pgd.Name, |
| | | }; |
| | | } |
| | | |
| | | public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal platformRate, decimal channleRate, |