赛事记录

This commit is contained in:
马梓彭 2026-05-08 14:50:01 +08:00
parent 882516d836
commit 24296764bd
5 changed files with 70 additions and 28 deletions

View File

@ -913,6 +913,7 @@ public class UnifiedRegistrationService : ITransient
}
registration.PaymentStatus = 1;
registration.PaymentMethod = 1; // 免费赛事设置为线下支付方式(但实际不产生费用)
registration.PaymentTime = DateTime.Now;
registration.UpdatedTime = DateTime.Now;
registration.UpdatedUserId = operatorUserId;
@ -1923,11 +1924,26 @@ public class UnifiedRegistrationService : ITransient
{
if (eventProjectsDict.TryGetValue(item.ProjectId, out var ep))
{
pricingInput.Projects.Add(new ProjectPricingInfo
var projectInfo = new ProjectPricingInfo
{
ProjectId = ep.Id,
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);
}
var unifiedItems = items.Select(i => new UnifiedRegistrationItemInput
// 构建专门用于金额计算的 PricingInput,直接使用 CalculateAmountInputItem 的信息
var pricingInput = new PricingInput
{
ProjectId = i.ProjectId,
Persons = new List<UnifiedPersonInput>(new UnifiedPersonInput[i.PersonCount])
}).ToList();
var totalAmount = CalculateTotalAmount(feeConfig, eventProjects, unifiedItems, countForCalculation);
ChargeMode = feeConfig.ChargeMode,
ParticipantCount = countForCalculation,
EventPrice = feeConfig.Price
};
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);
foreach (var item in items)

View File

@ -103,9 +103,11 @@ public class UserEventRecordService : IDynamicApiController, ITransient
.LeftJoin<EventFeeConfig>((r, e, fc) => e.Id == fc.EventId)
.Where((r, e, fc) => r.CreatedUserId == userId && !r.DeleteMark)
// 支付状态筛选:
// - 免费赛事:直接显示
// - 线下支付时:显示未支付(0)和已支付(1)状态的数据
// - 线上支付时:仅显示已支付(1)状态的数据
.Where((r, e, fc) =>
(e.ChargeMode == ChargeMode.Free) ||
(r.PaymentMethod == 1 && (r.PaymentStatus == 0 || r.PaymentStatus == 1)) ||
(r.PaymentMethod == 2 && r.PaymentStatus == 1))
.WhereIF(input.EventId.HasValue, (r, e, fc) => r.EventId == input.EventId)

View File

@ -103,39 +103,29 @@ public static class EventPricingService
/// <summary>
/// 单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
/// 将每个报名项目的单价相加得到单人总费用,再乘以报名人数得出最终金额
/// 每个项目独立计算:项目单价 × 对应人数,然后累加所有项目的金额
/// </summary>
private static void CalculateUnitPriceProjectMode(PricingResult result, PricingInput input)
{
decimal totalProjectPrice = 0;
decimal totalAmount = 0;
foreach (var project in input.Projects)
{
totalProjectPrice += project.UnitPrice;
var subtotal = project.UnitPrice * project.Quantity;
totalAmount += subtotal;
result.Details.Add(new PricingDetailItem
{
ItemName = project.ProjectName,
UnitPrice = project.UnitPrice,
Quantity = 1,
Subtotal = project.UnitPrice,
Quantity = project.Quantity,
Subtotal = subtotal,
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.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} 元");
result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 单价(项目)模式: 总金额 {totalAmount:F2} 元");
}
}

View File

@ -19,4 +19,9 @@ public class ProjectPricingInfo
/// 项目单价(元)
/// </summary>
public decimal UnitPrice { get; set; }
/// <summary>
/// 项目报名人数
/// </summary>
public int Quantity { get; set; }
}

View File

@ -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)">
<summary>
单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。
将每个报名项目的单价相加得到单人总费用,再乘以报名人数得出最终金额
每个项目独立计算:项目单价 × 对应人数,然后累加所有项目的金额
</summary>
</member>
<member name="T:YD_Event.Core.Domain.Pricing.Models.PricingDetailItem">
@ -546,6 +546,11 @@
项目单价(元)
</summary>
</member>
<member name="P:YD_Event.Core.Domain.Pricing.Models.ProjectPricingInfo.Quantity">
<summary>
项目报名人数
</summary>
</member>
<member name="T:YD_Event.Core.Entities.Entity`1">
<summary>
表实体继承