zhengyuxuan
2025-03-24 e896cbc0f5d5483d4661918556f45b7b9a6c31c2
fix:手续费、利润等计算
3个文件已修改
85 ■■■■■ 已修改文件
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/LifePay/LifePayService.cs 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -537,4 +537,29 @@
    public string Phone { get; set; }
    public string Remark { get; set; }
}
public class OrderPriceReturn
{
    /// <summary>
    /// 平台扣款金额
    /// </summary>
    public decimal PlatformPrice { get; set; }
    /// <summary>
    /// 手续费
    /// </summary>
    public decimal PremiumPrice { get; set; }
    /// <summary>
    /// 渠道佣金
    /// </summary>
    public decimal ChannlesRakePrice { get; set; }
    /// <summary>
    /// 利润
    /// </summary>
    public decimal Profit { get; set; }
}
LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -398,6 +398,9 @@
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "订单不存在");
        var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId);
        var channlesRakePrice = (order.PayAmount - (order.PlatformDeductionAmount == null ? 0 : order.PlatformDeductionAmount)) * channle.ChannlesRakeRate / 100;
        var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount,order.PlatformRate, order.ChannleRate, order.ChannlesRakeRate,order.PremiumRate);
        var result = new LifePayOrderOutput()
                {
            UserName = user.Name,
@@ -429,12 +432,12 @@
            PlatformPrice = order.PlatformDeductionAmount,
            ElecBillUrl = order.ElecBillUrl.GetOssPath(),
            RefundElecBillUrl = order.RefundElecBillUrl.GetOssPath(),
            ChannleRate = channle.ChannlesRate,
            ChannlesRakeRate = channle.ChannlesRakeRate,
            ChannlesRakePrice = channlesRakePrice.HasValue ? 0 : Math.Round(channlesRakePrice.Value, 2),
            ChannleRate = order.ChannleRate,
            ChannlesRakeRate = order.ChannlesRakeRate,
            ChannlesRakePrice = orderpirce.ChannlesRakePrice,
            PremiumRate = order.PremiumRate,
            PremiumPrice = Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value:0), 2),
            Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value : 0), 2)
            PremiumPrice = orderpirce.PremiumPrice,
            Profit = orderpirce.Profit
        };
        return result;
@@ -2069,5 +2072,32 @@
                    });
    }
    public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal? platformRate,decimal? channleRate,
        decimal? channlesRakeRate,decimal? premiumRate)
    {
        /// 毛利
        var grossProfit = price * (channleRate - platformRate) / 100;
        /// 平台扣款金额  充值面额 * 平台折扣比例
        var platformPrice = price * platformRate / 100;
        /// 手续费
        var premiumPrice = priceAmount * premiumRate / 100;
        /// 渠道佣金  ((充值面额 * 渠道折扣比例)-(充值面额 * 平台折扣比例))* 佣金比例
        var channlesRakePrice = grossProfit * channlesRakeRate / 100;
        /// 利润
        var profit = grossProfit - channlesRakePrice - premiumPrice;
        return new OrderPriceReturn()
        {
            PlatformPrice = platformPrice.HasValue? platformPrice.Value:0,
            PremiumPrice = premiumPrice.HasValue ? premiumPrice.Value : 0,
            ChannlesRakePrice = channlesRakePrice.HasValue? channlesRakePrice.Value:0,
            Profit = profit.HasValue ? profit.Value : 0
        };
    }
    #endregion
}
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -636,6 +636,26 @@
            注册时间
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.OrderPriceReturn.PlatformPrice">
            <summary>
            平台扣款金额
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.OrderPriceReturn.PremiumPrice">
            <summary>
            手续费
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.OrderPriceReturn.ChannlesRakePrice">
            <summary>
            渠道佣金
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.OrderPriceReturn.Profit">
            <summary>
            利润
            </summary>
        </member>
        <member name="P:LifePayment.Application.Contracts.LifePayIntroInfoInput.LifePayType">
            <summary>
            生活缴费类型