zhengyiming
2025-03-25 5c3f745cc2a9104e831115a4949e8543373f6105
merge
4个文件已修改
88 ■■■■■ 已修改文件
LifePayment/LifePayment.Application/LifePay/LifePayService.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/LifePay/StatisticsService.cs 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain.Shared/Extension/EnumExtension.cs 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Domain/Common/ChannelFilter.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -247,6 +247,7 @@
    {
        var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync();
        var result = await (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository)
                            .Where(x => x.PayStatus != LifePayStatusEnum.未支付)
                      .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime)
                                            .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime)
                                            .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime)
@@ -385,7 +386,7 @@
            s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription();
            s.RechargeAmountStr = s.RechargeAmount.ToString("F2");
            s.ActualReceivedAmount = s.ActualReceivedAmount;
            s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription();
            s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.无需退款 ? "" : s.LifePayRefundStatus.GetDescription();
            s.PayAmountStr = s.PayAmount.ToString("F2");
            s.LifePayTypeStr = s.LifePayType.GetDescription();
            s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
@@ -733,7 +734,7 @@
            LifePayType = x.LifePayType,
            OrderNo = x.OrderNo,
            PayAmount = x.PayAmount,
            ActualRechargeAmount = x.ActualRechargeAmount.HasValue ? x.ActualRechargeAmount.Value : 0,
            ActualRechargeAmount = x.RechargeAmount,
            PhoneNumber = x.PhoneNumber,
            RechargeAmount = x.RechargeAmount,
            OutOrderNo = x.OutOrderNo,
@@ -759,7 +760,7 @@
            s.LifePayTypeStr = s.LifePayType.GetDescription();
            s.PayStatusStr = s.PayStatus.GetDescription();
            s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2");
            s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription();
            s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.无需退款 ? "" : s.LifePayRefundStatus.GetDescription();
            s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription();
            //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription();
            s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss);
@@ -834,12 +835,12 @@
        var channle = await GetLifePayChannlesDtoByNum(input.ChannelId);
        CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在");
        var rate = await GetRate();
        CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        //var rate = await GetRate();
        //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        //var rate = await GetLifePayRate();
        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认话费折扣);
        var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认话费折扣).Rate);
        var amount = CalculateAmount(input.ProductData.ParValue, rate);
        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价);
@@ -860,7 +861,7 @@
            ChannelId = channle.ChannlesNum,
            PlatformRate = platformRate.Rate,
            PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100,
            ChannleRate = channle.ChannlesRate,
            ChannleRate = rate,
            ChannlesRakeRate = channle.ChannlesRakeRate,
            //ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100
        };
@@ -888,10 +889,13 @@
        CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在");
        CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.禁用, "渠道已被禁用");
        var rate = await GetRate();
        CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        //var rate = await GetRate();
        //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认电费折扣).Rate);
        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认电费折扣);
        var amount = CalculateAmount(input.ProductData.ParValue, rate);
        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价);
@@ -910,7 +914,7 @@
            RechargeAmount = amount.RechargeAmount,
            ChannelId = channle.ChannlesNum,
            PlatformRate = platformRate.Rate,
            ChannleRate = channle.ChannlesRate,
            ChannleRate = rate,
            ChannlesRakeRate = channle.ChannlesRakeRate,
        };
@@ -937,10 +941,13 @@
        CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "渠道不存在");
        CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.禁用, "渠道已被禁用");
        var rate = await GetRate();
        CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        //var rate = await GetRate();
        //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
        var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.默认燃气折扣).Rate);
        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.默认燃气折扣);
        var amount = CalculateAmount(input.ProductData.ParValue, rate);
        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.供应商折扣价);
@@ -957,7 +964,10 @@
            PayAmount = amount.PayAmont,
            DiscountAmount = amount.DiscountAmount,
            RechargeAmount = amount.RechargeAmount,
            ChannelId = channle.ChannlesNum
            ChannelId = channle.ChannlesNum,
            PlatformRate = platformRate.Rate,
            ChannleRate = rate,
            ChannlesRakeRate = channle.ChannlesRakeRate,
        };
        await CreateLifePayOrder(orderInput);
@@ -1014,7 +1024,7 @@
    }
    /// <summary>
    /// 设置生活缴费支付类型
    /// 获取微信支付的JSAPI
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
@@ -1026,6 +1036,8 @@
        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 = "生活缴费-";
@@ -1997,6 +2009,7 @@
    {
        var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync();
        var result = (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository)
                            .Where(x => x.PayStatus != LifePayStatusEnum.未支付)
                      .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime)
                                            .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime)
                                            .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime)
@@ -2084,6 +2097,7 @@
                                RefundApplyRemark = a.RefundApplyRemark,
                                RefundApplyTime = a.RefundApplyTime,
                                RefundTime = a.RefundTime,
                                RefundOrderNo = a.RefundOrderNo,
                                RefundPrice = a.RefundPrice,
                                ChannelName = b.ChannlesName,
                                ActualRechargeAmount = a.ActualRechargeAmount,
@@ -2137,9 +2151,9 @@
        };
    }
    public async Task<decimal> GetLifePayRate(string channelId, LifePayRateTypeEnum lifePayRateType)
    public async Task<decimal> GetLifePayRate(CreateEditPayChannelsInput channel, LifePayRateTypeEnum lifePayRateType)
    {
        if (string.IsNullOrEmpty(channelId))
        if (channel == null)
        {
            var rate = await GetRate();
            CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "未配置折扣");
@@ -2148,9 +2162,6 @@
        }
        else
        {
            var channel = await _lifePayChannlesRep.Where(x => x.ChannlesNum == channelId).FirstOrDefaultAsync();
            CheckExtensions.IfTrueThrowUserFriendlyException(channel == null, "未找到对应渠道");
            return channel.ChannlesRate;
        }
    }
LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
@@ -41,21 +41,32 @@
            var statistics = await _dallyStatisticsRepository.Where(x => x.CreationTime.Date == today).FirstOrDefaultAsync();
            if (statistics == null)
            {
                var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.PayAmount);
                var receiptsYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).SumAsync(x => x.PayAmount);
                /// 累计收款:统计平台账户下订单创建时间在昨天及之前收到的【用户支付成功的金额-退款给用户的金额】;
                var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.PayStatus == LifePayStatusEnum.已支付).SumAsync(x => x.PayAmount) - await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.LifePayRefundStatus == LifePayRefundStatusEnum.已退款).SumAsync(x => x.RefundPrice);
                /// 昨日收款:统计平台账户下订单创建时间在昨天收到的【用户支付成功的金额-退款给用户的金额】;
                var receiptsYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.PayStatus == LifePayStatusEnum.已支付).SumAsync(x => x.PayAmount) - await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayRefundStatus == LifePayRefundStatusEnum.已退款).SumAsync(x => x.PayAmount);
                /// 累计收入:统计平台账户下订单状态为“已完成”且订单创建时间在昨天及之前收到的【用户实付金额-平台扣款金额-部分退款金额】;
                var accumulatedIncome = await _lifePayOrderRepository.Where(x => x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.已完成).SumAsync(x => x.PayAmount - x.PlatformDeductionAmount - x.RefundPrice);
                /// 累计下单:统计平台中订单下单时间在昨天及之前时间的订单记录;
                var accumulatedOrders = await _lifePayOrderRepository.Where(x => x.CreationTime < today).CountAsync();
                var accumulatedIncome = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.RechargeAmount);
                /// 昨日下单:统计平台中订单下单时间在昨天的订单记录;
                var ordersNumYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).CountAsync();
                /// 昨日成功:统计平台中订单状态为“已完成/部分充值成功”且订单下单时间在昨天的订单记录;
                var yesterdaySuccess = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.已完成).CountAsync();
                var yesterdayFail = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.退款失败).CountAsync();
                /// 昨日失败:统计平台中订单状态为“充值失败/已退款”且订单下单时间在昨天的订单记录;
                var yesterdayFail = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.已退款).CountAsync();
                /// 累计用户
                var accumulatedUsers = await _lifePayUserRepository.CountAsync();
                /// 昨日活跃用户
                var yesterdayActiveUsers = await _lifePayUserRepository.Where(x => x.LastLoginTime >= today.AddDays(-1)).CountAsync();
                var entity = new DallyStatistics()
                {
                    Id = GuidGenerator.Create(),
                    CreationTime = DateTime.Now,
                    Amount = 0,
                    AccumulatedReceipts = accumulatedReceipts,
                    AccumulatedReceipts = accumulatedReceipts.HasValue? accumulatedReceipts.Value:0,
                    AccumulatedIncome = accumulatedIncome.HasValue ? accumulatedIncome.Value : 0,
                    ReceiptsYesterday = receiptsYesterday,
                    AccumulatedOrders = accumulatedOrders,
                    OrdersNumYesterday = ordersNumYesterday,
@@ -70,13 +81,14 @@
                {
                    Amount = entity.Amount,
                    AccumulatedReceipts = entity.AccumulatedReceipts,
                    AccumulatedIncome = entity.AccumulatedIncome,
                    ReceiptsYesterday = entity.ReceiptsYesterday,
                    AccumulatedOrders = entity.AccumulatedOrders,
                    OrdersNumYesterday = entity.OrdersNumYesterday,
                    YesterdaySuccess = entity.YesterdaySuccess,
                    YesterdayFail = entity.YesterdayFail,
                    AccumulatedUsers = entity.AccumulatedUsers,
                    YesterdayActiveUsers = entity.AccumulatedUsers,
                    YesterdayActiveUsers = entity.YesterdayActiveUsers,
                };
                return topStatisticsOutput;
            }
@@ -86,12 +98,14 @@
                {
                    Amount = statistics.Amount,
                    AccumulatedReceipts = statistics.AccumulatedReceipts,
                    AccumulatedIncome = statistics.AccumulatedIncome,
                    ReceiptsYesterday = statistics.ReceiptsYesterday,
                    AccumulatedOrders = statistics.AccumulatedOrders,
                    OrdersNumYesterday = statistics.OrdersNumYesterday,
                    YesterdaySuccess = statistics.YesterdaySuccess,
                    YesterdayFail = statistics.YesterdayFail,
                    AccumulatedUsers = statistics.AccumulatedUsers,
                    YesterdayActiveUsers = statistics.YesterdayActiveUsers,
                };
                return topStatisticsOutput;
            }
LifePayment/LifePayment.Domain.Shared/Extension/EnumExtension.cs
LifePayment/LifePayment.Domain/Common/ChannelFilter.cs
@@ -23,8 +23,11 @@
            if (CurrentUser.ClientId == Constant.ClientType.Back && !CurrentUser.IsSystem)
            {
                var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList();
                if (queryUser.Count() > 0)
                {
                var queryResult = query.Where(s => (!string.IsNullOrEmpty(s.ChannelId) && queryUser.Contains(s.ChannelId)) || string.IsNullOrEmpty(s.ChannelId) || queryUser.Count() == 0);
                return queryResult;
                }
            }
            return query;
@@ -35,9 +38,13 @@
            if (CurrentUser.ClientId == Constant.ClientType.Back && !CurrentUser.IsSystem)
            {
                var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList();
                if (queryUser.Count() > 0)
                {
                var queryResult = query.Where(s => (!string.IsNullOrEmpty(s.CreationChannleNum) && queryUser.Contains(s.CreationChannleNum)) || string.IsNullOrEmpty(s.CreationChannleNum));
                return queryResult;
            }
            }
            return query;
        }