From d7399b083de823860a56b68c79f8e36603fb4ea3 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期一, 31 三月 2025 13:37:19 +0800 Subject: [PATCH] fix:获取渠道分佣分页列表 --- LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs | 155 +++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 111 insertions(+), 44 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs index 0ad8d61..fc61849 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs @@ -21,6 +21,7 @@ { private readonly IRepository<LifePayRechargeReceipts, Guid> _lifePayRechargeReceiptsRepository; private readonly IRepository<LifePayExpensesReceipts, Guid> _lifePayExpensesReceiptsRepository; + private readonly IRepository<LifePayChannlesRake, Guid> _lifePayChannlesRakeRepository; private readonly IRepository<LifePayOrder, Guid> _lifePayOrderRepository; private readonly IAliPayApi _aliPayApi; private readonly IWxPayApi _wxPayApi; @@ -28,23 +29,26 @@ public LifePayOrderService( IRepository<LifePayRechargeReceipts, Guid> lifePayRechargeReceiptsRepository, IRepository<LifePayExpensesReceipts, Guid> lifePayExpensesReceiptsRepository, + IRepository<LifePayChannlesRake, Guid> lifePayChannlesRakeRepository, IRepository<LifePayOrder, Guid> lifePayOrderRepository, IAliPayApi aliPayApi, IWxPayApi wxPayApi) { _lifePayRechargeReceiptsRepository = lifePayRechargeReceiptsRepository; _lifePayExpensesReceiptsRepository = lifePayExpensesReceiptsRepository; + _lifePayChannlesRakeRepository = lifePayChannlesRakeRepository; _lifePayOrderRepository = lifePayOrderRepository; _aliPayApi = aliPayApi; _wxPayApi = wxPayApi; } + #region 鏌ヨ /// <summary> /// 鑾峰彇鍏呭�兼祦姘� /// </summary> /// <param name="input"></param> /// <returns></returns> - public async Task<LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput>> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input) + public async Task<PageOutput<LifePayRechargeReceiptsListOutput>> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input) { var list = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false) .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord)) @@ -62,11 +66,87 @@ .GetPageResult(input.PageModel); var total = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount); - LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput> result = new LifePayRechargeReceiptsPageOutput<LifePayRechargeReceiptsListOutput>(); - result.Data = list.Data; - result.TotalRechargeAmount = total; - return result; + LifePayRechargeReceiptsStatistics objectData = new LifePayRechargeReceiptsStatistics(); + objectData.TotalRechargeAmount = total; + list.ObjectData = objectData; + return list; } + + /// <summary> + /// 鑾峰彇鏀舵敮娴佹按 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<PageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input) + { + var list = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false) + .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord) || x.OutOrderNo.Contains(input.KeyWord)) + .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType) + .WhereIf(input.ExpensesReceiptsType.HasValue, x => x.ExpensesReceiptsType == input.ExpensesReceiptsType) + .WhereIf(input.TimeBegin.HasValue, x => x.FinishTime >= input.TimeBegin) + .WhereIf(input.TimeEnd.HasValue, x => x.FinishTime <= input.TimeEnd) + + .Select(x => new LifePayExpensesReceiptsListOutput() + { + Id = x.Id, + OrderNo = x.OrderNo, + OutOrderNo = x.OutOrderNo, + LifePayType = x.LifePayType, + ExpensesReceiptsType = x.ExpensesReceiptsType.Value, + Amount = x.Amount, + FinishTime = x.FinishTime + }) + .GetPageResult(input.PageModel); + + var totalIncome = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses).SumAsync(x => x.Amount); + var totalRefund = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Receipts).SumAsync(x => x.Amount); + + LifePayExpensesReceiptsStatistics objectData = new LifePayExpensesReceiptsStatistics(); + objectData.TotalIncome = totalIncome; + objectData.TotalRefund = totalRefund; + objectData.RealIncome = totalIncome - totalRefund; + list.ObjectData = objectData; + return list; + } + + /// <summary> + /// 鑾峰彇娓犻亾鍒嗕剑 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<PageOutput<LifePayChannlesRakeListOutput>> GetLifePayChannlesRakePage(LifePayChannlesRakePageInput input) + { + var list = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false) + .WhereIf(input.ChannelId != null, x => x.ChannelId == input.ChannelId) + .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin) + .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd) + .WhereIf(input.FinishTimeBegin.HasValue, x => x.FinishTime >= input.FinishTimeBegin) + .WhereIf(input.FinishTimeEnd.HasValue, x => x.FinishTime <= input.FinishTimeEnd) + + .Select(x => new LifePayChannlesRakeListOutput() + { + Id = x.Id, + OrderNo = x.OrderNo, + PayAmount = x.PayAmount, + ChannlesRakeRate = x.ChannlesRakeRate, + ChannlesRakePrice = x.ChannlesRakePrice, + ChannelId = x.ChannelId, + FinishTime = x.FinishTime, + CreationTime = x.CreationTime, + }) + .GetPageResult(input.PageModel); + + var totalRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.ChannlesRakePrice); + + LifePayLifePayChannlesRakeStatistics objectData = new LifePayLifePayChannlesRakeStatistics(); + objectData.TotalRakePrice = totalRakePrice; + list.ObjectData = objectData; + return list; + } + + #endregion + + @@ -104,43 +184,7 @@ } } - /// <summary> - /// 鑾峰彇鏀舵敮娴佹按 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - public async Task<LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input) - { - var list = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false) - .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord) || x.OutOrderNo.Contains(input.KeyWord)) - .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType) - .WhereIf(input.ExpensesReceiptsType.HasValue, x => x.ExpensesReceiptsType == input.ExpensesReceiptsType) - .WhereIf(input.TimeBegin.HasValue, x => x.FinishTime >= input.TimeBegin) - .WhereIf(input.TimeEnd.HasValue, x => x.FinishTime <= input.TimeEnd) - - .Select(x => new LifePayExpensesReceiptsListOutput() - { - Id = x.Id, - OrderNo = x.OrderNo, - OutOrderNo = x.OutOrderNo, - LifePayType = x.LifePayType, - ExpensesReceiptsType = x.ExpensesReceiptsType.Value, - Amount = x.Amount, - FinishTime = x.FinishTime - }) - .GetPageResult(input.PageModel); - - var totalIncome = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses).SumAsync(x => x.Amount); - var totalRefund = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Receipts).SumAsync(x => x.Amount); - - LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput> result = new LifePayExpensesReceiptsPageOutput<LifePayExpensesReceiptsListOutput>(); - result.Data = list.Data; - result.TotalIncome = totalIncome; - result.TotalRefund = totalRefund; - result.RealIncome = totalIncome - totalRefund; - return result; - } - + /// <summary> /// 鎻掑叆鏀舵敮娴佹按 /// </summary> @@ -256,10 +300,33 @@ await AddLifePayExpensesReceipts(input); } - } } - + } + + public async Task GetAllChannlesRake() + { + var orderlist = await _lifePayOrderRepository.Where(x => x.IsDeleted == false && x.PayStatus == LifePayStatusEnum.宸叉敮浠� && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).ToListAsync(); + foreach (var item in orderlist) + { + /// 姣涘埄 + var grossProfit = item.RechargeAmount * (item.ChannleRate - item.PlatformRate) / 100; + /// 娓犻亾浣i噾 锛�(鍏呭�奸潰棰� * 娓犻亾鎶樻墸姣斾緥)-(鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥)锛�* 浣i噾姣斾緥 + var channlesRakePrice = grossProfit * (item.ChannlesRakeRate) / 100; + if (channlesRakePrice.HasValue) + { + LifePayChannlesRake lifePayChannlesRake = new LifePayChannlesRake() + { + OrderNo = item.OrderNo, + PayAmount = item.PayAmount.Value, + ChannlesRakeRate = item.ChannlesRakeRate.Value, + ChannlesRakePrice = channlesRakePrice.Value, + FinishTime = item.FinishTime.Value, + ChannelId = item.ChannelId, + }; + await _lifePayChannlesRakeRepository.InsertAsync(lifePayChannlesRake); + } + } } } } -- Gitblit v1.9.1