From a60c9afc1efed7f5a7eeaa673fa915ab79a775a8 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期五, 06 六月 2025 21:38:21 +0800 Subject: [PATCH] fix:订单完成时间赋值存在bug,只有在已完成或已退款时赋值 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 68 ++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 16 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 7155429..dbbcb41 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Linq.Dynamic.Core; using System.Threading.Tasks; @@ -49,10 +50,12 @@ 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, @@ -73,6 +76,7 @@ { _logger = logger; _aCOOLYManager = aCOOLYManager; + this.lifePayPromoterRepository = lifePayPromoterRepository; _lifePayRateRepository = lifePayRateRepository; _lifePayOrderRepository = lifePayOrderRepository; _lifePayUserRepository = lifePayUserRepository; @@ -933,7 +937,6 @@ var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环); - var orderInput = new CreateLifePayOrderInput { OrderNo = channle.ChannlesNum + CreateOrderNo(), @@ -1378,7 +1381,7 @@ return; } - // order.PlatformDeductionAmount = payAmount; + //order.PlatformDeductionAmount = payAmount; if (acoolyOrderNo.IsNotNullOrEmpty()) { @@ -1397,7 +1400,12 @@ order.LifePayOrderStatus = status; order.ACOOLYStatus = acoolyStatus; - order.FinishTime = DateTime.Now; + if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴� + || order.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆�) + { + order.FinishTime = DateTime.Now; + } + await _lifePayOrderRepository.UpdateAsync(order); if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�) @@ -1685,6 +1693,10 @@ { order.LifePayOrderStatus = LifePayOrderStatusEnum.宸插畬鎴�; } + else + { + order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆惧け璐�; + } order.RefundCheckRemark = input.RefundCheckRemark; order.RefundCheckUserId = CurrentUser.Id; @@ -1710,13 +1722,22 @@ { 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); @@ -1728,6 +1749,13 @@ 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 璁板綍鏃ュ織 @@ -2177,20 +2205,28 @@ }); 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, -- Gitblit v1.9.1