赛事记录
This commit is contained in:
parent
882516d836
commit
24296764bd
@ -913,6 +913,7 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
}
|
}
|
||||||
|
|
||||||
registration.PaymentStatus = 1;
|
registration.PaymentStatus = 1;
|
||||||
|
registration.PaymentMethod = 1; // 免费赛事设置为线下支付方式(但实际不产生费用)
|
||||||
registration.PaymentTime = DateTime.Now;
|
registration.PaymentTime = DateTime.Now;
|
||||||
registration.UpdatedTime = DateTime.Now;
|
registration.UpdatedTime = DateTime.Now;
|
||||||
registration.UpdatedUserId = operatorUserId;
|
registration.UpdatedUserId = operatorUserId;
|
||||||
@ -1923,11 +1924,26 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
{
|
{
|
||||||
if (eventProjectsDict.TryGetValue(item.ProjectId, out var ep))
|
if (eventProjectsDict.TryGetValue(item.ProjectId, out var ep))
|
||||||
{
|
{
|
||||||
pricingInput.Projects.Add(new ProjectPricingInfo
|
var projectInfo = new ProjectPricingInfo
|
||||||
{
|
{
|
||||||
ProjectId = ep.Id,
|
ProjectId = ep.Id,
|
||||||
UnitPrice = ep.Price
|
UnitPrice = ep.Price
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// 仅在单价项目模式时设置项目人数
|
||||||
|
if (feeConfig.ChargeMode == ChargeMode.UnitPriceProject)
|
||||||
|
{
|
||||||
|
if (item.Teams != null && item.Teams.Any())
|
||||||
|
{
|
||||||
|
projectInfo.Quantity = item.Teams.Sum(t => t.Persons?.Count ?? 0);
|
||||||
|
}
|
||||||
|
else if (item.Persons != null && item.Persons.Any())
|
||||||
|
{
|
||||||
|
projectInfo.Quantity = item.Persons.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pricingInput.Projects.Add(projectInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1973,15 +1989,39 @@ public class UnifiedRegistrationService : ITransient
|
|||||||
countForCalculation = items.Sum(i => i.PersonCount);
|
countForCalculation = items.Sum(i => i.PersonCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
var unifiedItems = items.Select(i => new UnifiedRegistrationItemInput
|
// 构建专门用于金额计算的 PricingInput,直接使用 CalculateAmountInputItem 的信息
|
||||||
|
var pricingInput = new PricingInput
|
||||||
{
|
{
|
||||||
ProjectId = i.ProjectId,
|
ChargeMode = feeConfig.ChargeMode,
|
||||||
Persons = new List<UnifiedPersonInput>(new UnifiedPersonInput[i.PersonCount])
|
ParticipantCount = countForCalculation,
|
||||||
}).ToList();
|
EventPrice = feeConfig.Price
|
||||||
|
};
|
||||||
var totalAmount = CalculateTotalAmount(feeConfig, eventProjects, unifiedItems, countForCalculation);
|
|
||||||
|
|
||||||
var eventProjectsDict = eventProjects.ToDictionary(p => p.Id);
|
var eventProjectsDict = eventProjects.ToDictionary(p => p.Id);
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (eventProjectsDict.TryGetValue(item.ProjectId, out var ep))
|
||||||
|
{
|
||||||
|
var projectInfo = new ProjectPricingInfo
|
||||||
|
{
|
||||||
|
ProjectId = ep.Id,
|
||||||
|
UnitPrice = ep.Price
|
||||||
|
};
|
||||||
|
|
||||||
|
// 仅在单价项目模式时设置项目人数
|
||||||
|
if (feeConfig.ChargeMode == ChargeMode.UnitPriceProject)
|
||||||
|
{
|
||||||
|
projectInfo.Quantity = item.PersonCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
pricingInput.Projects.Add(projectInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pricingResult = EventPricingService.Calculate(pricingInput);
|
||||||
|
var totalAmount = pricingResult.TotalAmount;
|
||||||
|
|
||||||
var baseProjectsDict = baseProjects.ToDictionary(p => p.Id);
|
var baseProjectsDict = baseProjects.ToDictionary(p => p.Id);
|
||||||
|
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
|
|||||||
@ -103,9 +103,11 @@ public class UserEventRecordService : IDynamicApiController, ITransient
|
|||||||
.LeftJoin<EventFeeConfig>((r, e, fc) => e.Id == fc.EventId)
|
.LeftJoin<EventFeeConfig>((r, e, fc) => e.Id == fc.EventId)
|
||||||
.Where((r, e, fc) => r.CreatedUserId == userId && !r.DeleteMark)
|
.Where((r, e, fc) => r.CreatedUserId == userId && !r.DeleteMark)
|
||||||
// 支付状态筛选:
|
// 支付状态筛选:
|
||||||
|
// - 免费赛事:直接显示
|
||||||
// - 线下支付时:显示未支付(0)和已支付(1)状态的数据
|
// - 线下支付时:显示未支付(0)和已支付(1)状态的数据
|
||||||
// - 线上支付时:仅显示已支付(1)状态的数据
|
// - 线上支付时:仅显示已支付(1)状态的数据
|
||||||
.Where((r, e, fc) =>
|
.Where((r, e, fc) =>
|
||||||
|
(e.ChargeMode == ChargeMode.Free) ||
|
||||||
(r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)) ||
|
(r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)) ||
|
||||||
(r.PaymentMethod == 2 && r.PaymentStatus == 1))
|
(r.PaymentMethod == 2 && r.PaymentStatus == 1))
|
||||||
.WhereIF(input.EventId.HasValue, (r, e, fc) => r.EventId == input.EventId)
|
.WhereIF(input.EventId.HasValue, (r, e, fc) => r.EventId == input.EventId)
|
||||||
|
|||||||
@ -103,39 +103,29 @@ public static class EventPricingService
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
|
/// 单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
|
||||||
/// 将每个报名项目的单价相加得到单人总费用,再乘以报名人数得出最终金额
|
/// 每个项目独立计算:项目单价 × 对应人数,然后累加所有项目的金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void CalculateUnitPriceProjectMode(PricingResult result, PricingInput input)
|
private static void CalculateUnitPriceProjectMode(PricingResult result, PricingInput input)
|
||||||
{
|
{
|
||||||
decimal totalProjectPrice = 0;
|
decimal totalAmount = 0;
|
||||||
|
|
||||||
foreach (var project in input.Projects)
|
foreach (var project in input.Projects)
|
||||||
{
|
{
|
||||||
totalProjectPrice += project.UnitPrice;
|
var subtotal = project.UnitPrice * project.Quantity;
|
||||||
|
totalAmount += subtotal;
|
||||||
|
|
||||||
result.Details.Add(new PricingDetailItem
|
result.Details.Add(new PricingDetailItem
|
||||||
{
|
{
|
||||||
ItemName = project.ProjectName,
|
ItemName = project.ProjectName,
|
||||||
UnitPrice = project.UnitPrice,
|
UnitPrice = project.UnitPrice,
|
||||||
Quantity = 1,
|
Quantity = project.Quantity,
|
||||||
Subtotal = project.UnitPrice,
|
Subtotal = subtotal,
|
||||||
Remark = "项目单价"
|
Remark = "项目单价"
|
||||||
});
|
});
|
||||||
result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 项目: {project.ProjectName}, 单价: {project.UnitPrice:F2} 元");
|
result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 项目: {project.ProjectName}, 单价: {project.UnitPrice:F2} 元, 人数: {project.Quantity}, 小计: {subtotal:F2} 元");
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalAmount = totalProjectPrice * input.ParticipantCount;
|
|
||||||
result.TotalAmount = totalAmount;
|
result.TotalAmount = totalAmount;
|
||||||
|
result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 单价(项目)模式: 总金额 {totalAmount:F2} 元");
|
||||||
result.Details.Add(new PricingDetailItem
|
|
||||||
{
|
|
||||||
ItemName = input.ParticipantCount == 1 ? "项目总价" : "项目总价 × 人数",
|
|
||||||
UnitPrice = totalProjectPrice,
|
|
||||||
Quantity = input.ParticipantCount,
|
|
||||||
Subtotal = totalAmount,
|
|
||||||
Remark = input.ParticipantCount == 1
|
|
||||||
? $"个人参赛,项目总价 {totalProjectPrice:F2} 元"
|
|
||||||
: $"团队参赛,({totalProjectPrice:F2} 元) × {input.ParticipantCount} 人"
|
|
||||||
});
|
|
||||||
result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 单价(项目)模式: 项目总价 {totalProjectPrice:F2} 元 × {input.ParticipantCount} 人 = {totalAmount:F2} 元");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,4 +19,9 @@ public class ProjectPricingInfo
|
|||||||
/// 项目单价(元)
|
/// 项目单价(元)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal UnitPrice { get; set; }
|
public decimal UnitPrice { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 项目报名人数
|
||||||
|
/// </summary>
|
||||||
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -443,7 +443,7 @@
|
|||||||
<member name="M:YD_Event.Core.Domain.Pricing.EventPricingService.CalculateUnitPriceProjectMode(YD_Event.Core.Domain.Pricing.Models.PricingResult,YD_Event.Core.Domain.Pricing.Models.PricingInput)">
|
<member name="M:YD_Event.Core.Domain.Pricing.EventPricingService.CalculateUnitPriceProjectMode(YD_Event.Core.Domain.Pricing.Models.PricingResult,YD_Event.Core.Domain.Pricing.Models.PricingInput)">
|
||||||
<summary>
|
<summary>
|
||||||
单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
|
单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
|
||||||
将每个报名项目的单价相加得到单人总费用,再乘以报名人数得出最终金额
|
每个项目独立计算:项目单价 × 对应人数,然后累加所有项目的金额
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:YD_Event.Core.Domain.Pricing.Models.PricingDetailItem">
|
<member name="T:YD_Event.Core.Domain.Pricing.Models.PricingDetailItem">
|
||||||
@ -546,6 +546,11 @@
|
|||||||
项目单价(元)
|
项目单价(元)
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:YD_Event.Core.Domain.Pricing.Models.ProjectPricingInfo.Quantity">
|
||||||
|
<summary>
|
||||||
|
项目报名人数
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:YD_Event.Core.Entities.Entity`1">
|
<member name="T:YD_Event.Core.Entities.Entity`1">
|
||||||
<summary>
|
<summary>
|
||||||
表实体继承
|
表实体继承
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user