项目完成人数改为范围值和单值均可
This commit is contained in:
parent
82c000e3f5
commit
a09be1975d
@ -451,6 +451,31 @@ public class EventProjectDto
|
||||
/// </summary>
|
||||
public int? ProjectLimitCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数模式(0=单一值,1=范围值)
|
||||
/// </summary>
|
||||
public int CompletionCountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数(单一值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数显示文本(如"5人"或"3-7人")
|
||||
/// </summary>
|
||||
public string? CompletionCountDisplay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组别列表
|
||||
/// </summary>
|
||||
|
||||
@ -342,7 +342,11 @@ public class EventClientController : IDynamicApiController
|
||||
.Select(p => new {
|
||||
p.Id,
|
||||
p.Name,
|
||||
p.ProjectType
|
||||
p.ProjectType,
|
||||
p.CompletionCountType,
|
||||
p.CompletionCount,
|
||||
p.CompletionCountMin,
|
||||
p.CompletionCountMax
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
@ -496,6 +500,23 @@ public class EventClientController : IDynamicApiController
|
||||
var bp = baseProjects.FirstOrDefault(b => b.Id == ep.ProjectId);
|
||||
var pl = projectLimits.FirstOrDefault(x => x.ProjectId == ep.Id);
|
||||
var epGroups = eventProjectGroups.Where(g => g.EventProjectId == ep.Id).ToList();
|
||||
|
||||
// 生成完成人数显示文本
|
||||
string completionCountDisplay = "";
|
||||
if (bp != null)
|
||||
{
|
||||
if (bp.CompletionCountType == 1)
|
||||
{
|
||||
var min = bp.CompletionCountMin ?? 0;
|
||||
var max = bp.CompletionCountMax ?? 0;
|
||||
completionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
else
|
||||
{
|
||||
completionCountDisplay = $"{bp.CompletionCount}人";
|
||||
}
|
||||
}
|
||||
|
||||
return new EventProjectDto
|
||||
{
|
||||
Id = ep.Id,
|
||||
@ -504,6 +525,11 @@ public class EventClientController : IDynamicApiController
|
||||
ProjectType = (long)(bp?.ProjectType ?? 0),
|
||||
Fee = ep.Price,
|
||||
ProjectLimitCount = pl?.LimitCount,
|
||||
CompletionCountType = bp?.CompletionCountType ?? 0,
|
||||
CompletionCount = bp?.CompletionCount,
|
||||
CompletionCountMin = bp?.CompletionCountMin,
|
||||
CompletionCountMax = bp?.CompletionCountMax,
|
||||
CompletionCountDisplay = completionCountDisplay,
|
||||
Groups = epGroups.Select(eg =>
|
||||
{
|
||||
var baseGroup = baseGroups.FirstOrDefault(bg => bg.Id == eg.ProjectGroupId);
|
||||
|
||||
@ -364,6 +364,31 @@ public class EventProjectInput
|
||||
/// 比赛时长(秒) (显示用)
|
||||
/// </summary>
|
||||
public int? DurationSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数模式 (显示用) 0=单一值, 1=范围值
|
||||
/// </summary>
|
||||
public int CompletionCountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数 (显示用) 单一值模式时有效
|
||||
/// </summary>
|
||||
public int? CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值 (显示用) 范围值模式时有效
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值 (显示用) 范围值模式时有效
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数显示文本 (显示用) 如:5人 或 3-5人
|
||||
/// </summary>
|
||||
public string? CompletionCountDisplay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目费用(Step 4)
|
||||
|
||||
@ -397,6 +397,26 @@ public class UserEventProjectListOutput
|
||||
/// </summary>
|
||||
public int CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数模式 (0=单一值, 1=范围值)
|
||||
/// </summary>
|
||||
public int CompletionCountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值(范围值模式)
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值(范围值模式)
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数显示文本(如"5人"或"3-7人")
|
||||
/// </summary>
|
||||
public string? CompletionCountDisplay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目类型
|
||||
/// </summary>
|
||||
|
||||
@ -207,12 +207,28 @@ public class EventService : BaseService<EventInfo>, ITransient
|
||||
Name = baseProj?.Name,
|
||||
ProjectTypeId = (long?)baseProj?.ProjectType,
|
||||
DurationMinutes = baseProj?.DurationMinutes,
|
||||
DurationSeconds = baseProj?.DurationSeconds
|
||||
DurationSeconds = baseProj?.DurationSeconds,
|
||||
// 填充完成人数相关字段
|
||||
CompletionCountType = baseProj?.CompletionCountType ?? 0,
|
||||
CompletionCount = baseProj?.CompletionCount,
|
||||
CompletionCountMin = baseProj?.CompletionCountMin,
|
||||
CompletionCountMax = baseProj?.CompletionCountMax
|
||||
};
|
||||
|
||||
if (baseProj != null)
|
||||
{
|
||||
dto.ProjectTypeName = baseProj.ProjectType.Description();
|
||||
// 生成完成人数显示文本
|
||||
if (baseProj.CompletionCountType == 0)
|
||||
{
|
||||
dto.CompletionCountDisplay = baseProj.CompletionCount > 0 ? $"{baseProj.CompletionCount}人" : "0人";
|
||||
}
|
||||
else
|
||||
{
|
||||
var min = baseProj.CompletionCountMin ?? 0;
|
||||
var max = baseProj.CompletionCountMax ?? 0;
|
||||
dto.CompletionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
}
|
||||
|
||||
var epGroups = eventProjectGroups.Where(g => g.EventProjectId == ep.Id).ToList();
|
||||
|
||||
@ -1543,7 +1543,8 @@ public class UnifiedRegistrationService : ITransient
|
||||
|
||||
// 获取项目限报配置
|
||||
var projectLimit = projectLimits.FirstOrDefault(pl => pl.ProjectId == eventProject.Id);
|
||||
if (projectLimit == null) continue;
|
||||
// 限报数量 <= 0 表示不限制,跳过验证
|
||||
if (projectLimit == null || projectLimit.LimitCount <= 0) continue;
|
||||
|
||||
if (isTeamProject)
|
||||
{
|
||||
@ -2026,19 +2027,36 @@ public class UnifiedRegistrationService : ITransient
|
||||
var project = projects.FirstOrDefault(p => p.Id == eventProject.ProjectId);
|
||||
if (project == null) continue;
|
||||
|
||||
// 判断是否为团队项目
|
||||
var isTeamProject = project.IsTeamProject();
|
||||
|
||||
// ==================== 项目组别条件判断逻辑 ====================
|
||||
// 当且仅当某个项目组别中已选择至少一名人员时,才对该项目组别执行后续条件判断流程
|
||||
// 个人项目不进行完成人数限制,仅适用项目报名限制规则
|
||||
if (!isTeamProject)
|
||||
// ==================== 项目完成人数验证 ====================
|
||||
// 只要项目配置了完成人数(单一值或范围值),就进行验证
|
||||
// 不再依赖 isTeamProject 判断,确保所有类型的项目都能正确验证
|
||||
bool hasValidCompletionConfig = false;
|
||||
int completionMin = 0;
|
||||
int completionMax = 0;
|
||||
|
||||
if (project.CompletionCountType == 0)
|
||||
{
|
||||
continue;
|
||||
// 单一值模式
|
||||
if (project.CompletionCount > 0)
|
||||
{
|
||||
hasValidCompletionConfig = true;
|
||||
completionMin = project.CompletionCount;
|
||||
completionMax = project.CompletionCount;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 团队项目完成人数验证 ====================
|
||||
if (project.CompletionCount <= 0)
|
||||
else
|
||||
{
|
||||
// 范围值模式
|
||||
if (project.CompletionCountMin.HasValue && project.CompletionCountMax.HasValue &&
|
||||
project.CompletionCountMin.Value > 0 && project.CompletionCountMax.Value > 0)
|
||||
{
|
||||
hasValidCompletionConfig = true;
|
||||
completionMin = project.CompletionCountMin.Value;
|
||||
completionMax = project.CompletionCountMax.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasValidCompletionConfig)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -2047,20 +2065,36 @@ public class UnifiedRegistrationService : ITransient
|
||||
if (teams.Count > 0)
|
||||
{
|
||||
// ========== 多团队模式 ==========
|
||||
// 对每个团队单独验证人数是否等于 CompletionCount
|
||||
// 对每个团队单独验证人数是否在范围内(或等于单一值)
|
||||
foreach (var team in teams)
|
||||
{
|
||||
var teamMemberCount = team.Persons?.Count ?? 0;
|
||||
if (teamMemberCount != project.CompletionCount)
|
||||
if (teamMemberCount < completionMin || teamMemberCount > completionMax)
|
||||
{
|
||||
string errorMessage;
|
||||
if (teamMemberCount < project.CompletionCount)
|
||||
if (completionMin == completionMax)
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(少{project.CompletionCount - teamMemberCount}人)";
|
||||
// 单一值模式
|
||||
if (teamMemberCount < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(少{completionMin - teamMemberCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(多{teamMemberCount - completionMax}人)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(多{teamMemberCount - project.CompletionCount}人)";
|
||||
// 范围值模式
|
||||
if (teamMemberCount < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(最少{completionMin}人,当前{teamMemberCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}{GetTeamNumber(team.TeamIndex)}参赛人数错误(最多{completionMax}人,当前{teamMemberCount}人)";
|
||||
}
|
||||
}
|
||||
|
||||
result.HasLimit = true;
|
||||
@ -2082,16 +2116,32 @@ public class UnifiedRegistrationService : ITransient
|
||||
.Distinct()
|
||||
.Count();
|
||||
|
||||
if (totalAssignedMembers != project.CompletionCount)
|
||||
if (totalAssignedMembers < completionMin || totalAssignedMembers > completionMax)
|
||||
{
|
||||
string errorMessage;
|
||||
if (totalAssignedMembers < project.CompletionCount)
|
||||
if (completionMin == completionMax)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(少{project.CompletionCount - totalAssignedMembers}人)";
|
||||
// 单一值模式
|
||||
if (totalAssignedMembers < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(少{completionMin - totalAssignedMembers}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(多{totalAssignedMembers - completionMax}人)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(多{totalAssignedMembers - project.CompletionCount}人)";
|
||||
// 范围值模式
|
||||
if (totalAssignedMembers < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(最少{completionMin}人,当前{totalAssignedMembers}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(最多{completionMax}人,当前{totalAssignedMembers}人)";
|
||||
}
|
||||
}
|
||||
|
||||
result.HasLimit = true;
|
||||
|
||||
@ -330,12 +330,32 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
{
|
||||
var p = baseProjects.FirstOrDefault(b => b.Id == ep.ProjectId);
|
||||
|
||||
// 生成完成人数显示文本
|
||||
string completionCountDisplay = "";
|
||||
if (p != null)
|
||||
{
|
||||
if (p.CompletionCountType == 1)
|
||||
{
|
||||
var min = p.CompletionCountMin ?? 0;
|
||||
var max = p.CompletionCountMax ?? 0;
|
||||
completionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
else
|
||||
{
|
||||
completionCountDisplay = $"{p.CompletionCount}人";
|
||||
}
|
||||
}
|
||||
|
||||
var dto = new UserEventProjectListOutput
|
||||
{
|
||||
Id = ep.Id,
|
||||
Name = p?.Name ?? "",
|
||||
Fee = ep.Price,
|
||||
CompletionCount = p?.CompletionCount ?? 0
|
||||
CompletionCount = p?.CompletionCount ?? 0,
|
||||
CompletionCountType = p?.CompletionCountType ?? 0,
|
||||
CompletionCountMin = p?.CompletionCountMin,
|
||||
CompletionCountMax = p?.CompletionCountMax,
|
||||
CompletionCountDisplay = completionCountDisplay
|
||||
};
|
||||
|
||||
if (p != null)
|
||||
@ -399,13 +419,33 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
{
|
||||
var p = baseProjects.FirstOrDefault(b => b.Id == ep.ProjectId);
|
||||
|
||||
// 生成完成人数显示文本
|
||||
string completionCountDisplay = "";
|
||||
if (p != null)
|
||||
{
|
||||
if (p.CompletionCountType == 1)
|
||||
{
|
||||
var min = p.CompletionCountMin ?? 0;
|
||||
var max = p.CompletionCountMax ?? 0;
|
||||
completionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
else
|
||||
{
|
||||
completionCountDisplay = $"{p.CompletionCount}人";
|
||||
}
|
||||
}
|
||||
|
||||
var dto = new UserEventProjectListOutput
|
||||
{
|
||||
Id = ep.Id,
|
||||
Name = p?.Name ?? "",
|
||||
Fee = ep.Price,
|
||||
TeamSize = 1,
|
||||
CompletionCount = p?.CompletionCount ?? 0
|
||||
CompletionCount = p?.CompletionCount ?? 0,
|
||||
CompletionCountType = p?.CompletionCountType ?? 0,
|
||||
CompletionCountMin = p?.CompletionCountMin,
|
||||
CompletionCountMax = p?.CompletionCountMax,
|
||||
CompletionCountDisplay = completionCountDisplay
|
||||
};
|
||||
|
||||
if (p != null)
|
||||
@ -1350,10 +1390,37 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
// 检查是多团队模式还是单团队模式
|
||||
var hasMultipleTeams = groupMemberAssignment.Teams != null && groupMemberAssignment.Teams.Count > 0;
|
||||
|
||||
// ========== 获取完成人数配置 ==========
|
||||
int completionMin = 0;
|
||||
int completionMax = 0;
|
||||
bool hasValidCompletionConfig = false;
|
||||
|
||||
if (project.CompletionCountType == 0)
|
||||
{
|
||||
// 单一值模式
|
||||
if (project.CompletionCount > 0)
|
||||
{
|
||||
hasValidCompletionConfig = true;
|
||||
completionMin = project.CompletionCount;
|
||||
completionMax = project.CompletionCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 范围值模式
|
||||
if (project.CompletionCountMin.HasValue && project.CompletionCountMax.HasValue &&
|
||||
project.CompletionCountMin.Value > 0 && project.CompletionCountMax.Value > 0)
|
||||
{
|
||||
hasValidCompletionConfig = true;
|
||||
completionMin = project.CompletionCountMin.Value;
|
||||
completionMax = project.CompletionCountMax.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMultipleTeams && isTeamProject)
|
||||
{
|
||||
// ========== 多团队模式验证 ==========
|
||||
// 验证每个团队的人数是否等于 CompletionCount
|
||||
// 验证每个团队的人数是否在范围内(或等于单一值)
|
||||
foreach (var team in groupMemberAssignment.Teams)
|
||||
{
|
||||
var teamMemberCount = team.MemberIds?.Distinct().Count() ?? 0;
|
||||
@ -1361,17 +1428,33 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
// 如果该团队没有选择任何人员,跳过验证
|
||||
if (teamMemberCount == 0) continue;
|
||||
|
||||
// 验证该团队的人数是否等于 CompletionCount
|
||||
if (project.CompletionCount > 0 && teamMemberCount != project.CompletionCount)
|
||||
// 验证该团队的人数是否在有效范围内
|
||||
if (hasValidCompletionConfig && (teamMemberCount < completionMin || teamMemberCount > completionMax))
|
||||
{
|
||||
string errorMessage;
|
||||
if (teamMemberCount < project.CompletionCount)
|
||||
if (completionMin == completionMax)
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(少{project.CompletionCount - teamMemberCount}人)";
|
||||
// 单一值模式
|
||||
if (teamMemberCount < completionMin)
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(少{completionMin - teamMemberCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(多{teamMemberCount - completionMax}人)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(多{teamMemberCount - project.CompletionCount}人)";
|
||||
// 范围值模式
|
||||
if (teamMemberCount < completionMin)
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(最少{completionMin}人,当前{teamMemberCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"团队{team.TeamIndex}参赛人数错误(最多{completionMax}人,当前{teamMemberCount}人)";
|
||||
}
|
||||
}
|
||||
|
||||
result.HasError = true;
|
||||
@ -1379,7 +1462,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
{
|
||||
ProjectId = eventProject.Id,
|
||||
ProjectName = project.Name ?? "未知项目",
|
||||
ErrorType = teamMemberCount < project.CompletionCount ? "Insufficient" : "Excessive",
|
||||
ErrorType = teamMemberCount < completionMin ? "Insufficient" : "Excessive",
|
||||
ErrorMessage = errorMessage
|
||||
});
|
||||
}
|
||||
@ -1394,17 +1477,33 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
// 如果该组别没有选择任何人员,跳过验证
|
||||
if (assignedCount == 0) continue;
|
||||
|
||||
// 只对团队项目进行完成人数验证
|
||||
if (isTeamProject && project.CompletionCount > 0 && assignedCount != project.CompletionCount)
|
||||
// 验证人数是否在有效范围内
|
||||
if (isTeamProject && hasValidCompletionConfig && (assignedCount < completionMin || assignedCount > completionMax))
|
||||
{
|
||||
string errorMessage;
|
||||
if (assignedCount < project.CompletionCount)
|
||||
if (completionMin == completionMax)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(少{project.CompletionCount - assignedCount}人)";
|
||||
// 单一值模式
|
||||
if (assignedCount < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(少{completionMin - assignedCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(多{assignedCount - completionMax}人)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(多{assignedCount - project.CompletionCount}人)";
|
||||
// 范围值模式
|
||||
if (assignedCount < completionMin)
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(最少{completionMin}人,当前{assignedCount}人)";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage = $"{project.Name}参赛人数错误(最多{completionMax}人,当前{assignedCount}人)";
|
||||
}
|
||||
}
|
||||
|
||||
result.HasError = true;
|
||||
@ -1412,7 +1511,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
{
|
||||
ProjectId = eventProject.Id,
|
||||
ProjectName = project.Name ?? "未知项目",
|
||||
ErrorType = assignedCount < project.CompletionCount ? "Insufficient" : "Excessive",
|
||||
ErrorType = assignedCount < completionMin ? "Insufficient" : "Excessive",
|
||||
ErrorMessage = errorMessage
|
||||
});
|
||||
}
|
||||
|
||||
@ -194,10 +194,19 @@ public class OrderService : BaseService<YD_Event.Core.Entities.Order>, ITransien
|
||||
.WhereIF(input.EndTime.HasValue, (o, e, m, r, ro) => o.PaymentTime <= input.EndTime)
|
||||
.OrderByDescending((o, e, m, r, ro) => o.CreatedTime);
|
||||
|
||||
// 权限判断:如果是单位认证用户,只能查看自己单位认证的订单
|
||||
if (certification != null && !_authManager.IsSuperAdmin)
|
||||
// 权限判断:非超级管理员必须过滤订单
|
||||
if (!_authManager.IsSuperAdmin)
|
||||
{
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
if (certification != null)
|
||||
{
|
||||
// 有单位认证的用户,按单位认证ID过滤(只能看自己单位的订单)
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 无单位认证的用户(包括新注册用户),只能查看自己创建的订单
|
||||
query = query.Where((o, e, m, r, ro) => o.CreatedUserId == userId);
|
||||
}
|
||||
}
|
||||
|
||||
var result = await query.Select((o, e, m, r, ro) => new OrderListOutput
|
||||
@ -593,10 +602,19 @@ public class OrderService : BaseService<YD_Event.Core.Entities.Order>, ITransien
|
||||
.WhereIF(input.EndTime.HasValue, (o, e, m, r, ro) => o.CreatedTime <= input.EndTime)
|
||||
.OrderByDescending((o, e, m, r, ro) => o.CreatedTime);
|
||||
|
||||
// 权限判断:如果是单位认证用户,只能查看自己单位认证的订单
|
||||
if (certification != null && !_authManager.IsSuperAdmin)
|
||||
// 权限判断:非超级管理员必须过滤订单
|
||||
if (!_authManager.IsSuperAdmin)
|
||||
{
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
if (certification != null)
|
||||
{
|
||||
// 有单位认证的用户,按单位认证ID过滤(只能看自己单位的订单)
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 无单位认证的用户(包括新注册用户),只能查看自己创建的订单
|
||||
query = query.Where((o, e, m, r, ro) => o.CreatedUserId == userId);
|
||||
}
|
||||
}
|
||||
|
||||
var list = await query.Select((o, e, m, r, ro) => new OrderListOutput
|
||||
@ -846,10 +864,19 @@ public class OrderService : BaseService<YD_Event.Core.Entities.Order>, ITransien
|
||||
.WhereIF(input.StartTime.HasValue, (o, e, m, r, ro) => o.CreatedTime >= input.StartTime)
|
||||
.WhereIF(input.EndTime.HasValue, (o, e, m, r, ro) => o.CreatedTime <= input.EndTime);
|
||||
|
||||
// 权限判断:如果是单位认证用户,只能查看自己单位认证的订单
|
||||
if (certification != null && !_authManager.IsSuperAdmin)
|
||||
// 权限判断:非超级管理员必须过滤订单
|
||||
if (!_authManager.IsSuperAdmin)
|
||||
{
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
if (certification != null)
|
||||
{
|
||||
// 有单位认证的用户,按单位认证ID过滤(只能看自己单位的订单)
|
||||
query = query.Where((o, e, m, r, ro) => o.MerchantCertificationId == certification.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 无单位认证的用户(包括新注册用户),只能查看自己创建的订单
|
||||
query = query.Where((o, e, m, r, ro) => o.CreatedUserId == userId);
|
||||
}
|
||||
}
|
||||
|
||||
var list = await query.Select((o, e, m, r, ro) => new OrderListOutput
|
||||
|
||||
@ -36,9 +36,24 @@ public class AddProjectInput
|
||||
public long ProjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数
|
||||
/// 完成人数模式(0=单一值, 1=范围值)
|
||||
/// </summary>
|
||||
public int CompletionCount { get; set; }
|
||||
public int CompletionCountType { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数(单一值模式时必填)
|
||||
/// </summary>
|
||||
public int? CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值(范围值模式时必填)
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值(范围值模式时必填)
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用(元)
|
||||
@ -130,9 +145,29 @@ public class ProjectDto
|
||||
public string ProjectTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数
|
||||
/// 完成人数模式(0=单一值, 1=范围值)
|
||||
/// </summary>
|
||||
public int CompletionCount { get; set; }
|
||||
public int CompletionCountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数(单一值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数显示文本(用于前端显示,如 "5人" 或 "3-5人")
|
||||
/// </summary>
|
||||
public string CompletionCountDisplay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用(元)
|
||||
|
||||
@ -52,7 +52,10 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
ProjectType = (long)p.ProjectType,
|
||||
CompletionCountType = p.CompletionCountType,
|
||||
CompletionCount = p.CompletionCount,
|
||||
CompletionCountMin = p.CompletionCountMin,
|
||||
CompletionCountMax = p.CompletionCountMax,
|
||||
Fee = p.Fee,
|
||||
DurationMinutes = p.DurationMinutes,
|
||||
DurationSeconds = p.DurationSeconds,
|
||||
@ -70,6 +73,17 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
||||
foreach (var item in list.Rows)
|
||||
{
|
||||
item.ProjectTypeName = ((ProjectTypeEnum)item.ProjectType).Description();
|
||||
// 生成完成人数显示文本
|
||||
if (item.CompletionCountType == 0)
|
||||
{
|
||||
item.CompletionCountDisplay = item.CompletionCount.HasValue ? $"{item.CompletionCount.Value}人" : "0人";
|
||||
}
|
||||
else
|
||||
{
|
||||
var min = item.CompletionCountMin ?? 0;
|
||||
var max = item.CompletionCountMax ?? 0;
|
||||
item.CompletionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -82,11 +96,37 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
||||
[UnitOfWork]
|
||||
public async Task Add(AddProjectInput input)
|
||||
{
|
||||
// 验证完成人数字段
|
||||
if (input.CompletionCountType == 0)
|
||||
{
|
||||
// 单一值模式
|
||||
if (!input.CompletionCount.HasValue || input.CompletionCount.Value < 0)
|
||||
{
|
||||
throw Oops.Bah("请填写有效的完成人数");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 范围值模式
|
||||
if (!input.CompletionCountMin.HasValue || !input.CompletionCountMax.HasValue)
|
||||
{
|
||||
throw Oops.Bah("请填写完成人数最小值和最大值");
|
||||
}
|
||||
if (input.CompletionCountMin.Value < 0 || input.CompletionCountMax.Value < 0)
|
||||
{
|
||||
throw Oops.Bah("完成人数不能为负数");
|
||||
}
|
||||
if (input.CompletionCountMin.Value > input.CompletionCountMax.Value)
|
||||
{
|
||||
throw Oops.Bah("完成人数最小值不能大于最大值");
|
||||
}
|
||||
}
|
||||
|
||||
var entity = input.Adapt<YD_Event.Core.Entities.Project>();
|
||||
entity.Id = _idGenerator.NewLong();
|
||||
entity.CreatedTime = DateTime.Now;
|
||||
entity.Status = Core.Enum.AvailabilityStatus.Enable;
|
||||
|
||||
|
||||
await _repository.InsertAsync(entity);
|
||||
|
||||
if (input.Groups != null && input.Groups.Any())
|
||||
@ -112,6 +152,32 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
||||
var entity = await _repository.GetByIdAsync(input.Id);
|
||||
if (entity == null) throw new InvalidOperationException("项目不存在");
|
||||
|
||||
// 验证完成人数字段
|
||||
if (input.CompletionCountType == 0)
|
||||
{
|
||||
// 单一值模式
|
||||
if (!input.CompletionCount.HasValue || input.CompletionCount.Value < 0)
|
||||
{
|
||||
throw Oops.Bah("请填写有效的完成人数");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 范围值模式
|
||||
if (!input.CompletionCountMin.HasValue || !input.CompletionCountMax.HasValue)
|
||||
{
|
||||
throw Oops.Bah("请填写完成人数最小值和最大值");
|
||||
}
|
||||
if (input.CompletionCountMin.Value < 0 || input.CompletionCountMax.Value < 0)
|
||||
{
|
||||
throw Oops.Bah("完成人数不能为负数");
|
||||
}
|
||||
if (input.CompletionCountMin.Value > input.CompletionCountMax.Value)
|
||||
{
|
||||
throw Oops.Bah("完成人数最小值不能大于最大值");
|
||||
}
|
||||
}
|
||||
|
||||
input.Adapt(entity);
|
||||
entity.UpdatedTime = DateTime.Now;
|
||||
await _repository.UpdateAsync(entity);
|
||||
@ -185,7 +251,19 @@ public class ProjectService : BaseService<YD_Event.Core.Entities.Project>, ITran
|
||||
var dto = p.Adapt<ProjectDto>();
|
||||
dto.ProjectType = (long)p.ProjectType;
|
||||
dto.ProjectTypeName = p.ProjectType.Description();
|
||||
|
||||
|
||||
// 生成完成人数显示文本
|
||||
if (dto.CompletionCountType == 0)
|
||||
{
|
||||
dto.CompletionCountDisplay = dto.CompletionCount.HasValue ? $"{dto.CompletionCount.Value}人" : "0人";
|
||||
}
|
||||
else
|
||||
{
|
||||
var min = dto.CompletionCountMin ?? 0;
|
||||
var max = dto.CompletionCountMax ?? 0;
|
||||
dto.CompletionCountDisplay = $"{min}-{max}人";
|
||||
}
|
||||
|
||||
var groups = await _groupRepository.GetListAsync(x => x.ProjectId == id);
|
||||
dto.Groups = groups.Adapt<List<ProjectGroupDto>>();
|
||||
|
||||
|
||||
@ -2204,6 +2204,31 @@
|
||||
项目限报数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式(0=单一值,1=范围值)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.CompletionCount">
|
||||
<summary>
|
||||
完成人数(单一值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.CompletionCountDisplay">
|
||||
<summary>
|
||||
完成人数显示文本(如"5人"或"3-7人")
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Client.Dtos.EventProjectDto.Groups">
|
||||
<summary>
|
||||
组别列表
|
||||
@ -4795,6 +4820,31 @@
|
||||
比赛时长(秒) (显示用)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式 (显示用) 0=单一值, 1=范围值
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.CompletionCount">
|
||||
<summary>
|
||||
完成人数 (显示用) 单一值模式时有效
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值 (显示用) 范围值模式时有效
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值 (显示用) 范围值模式时有效
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.CompletionCountDisplay">
|
||||
<summary>
|
||||
完成人数显示文本 (显示用) 如:5人 或 3-5人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.EventProjectInput.Fee">
|
||||
<summary>
|
||||
项目费用(Step 4)
|
||||
@ -7688,6 +7738,26 @@
|
||||
完成人数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventProjectListOutput.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式 (0=单一值, 1=范围值)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventProjectListOutput.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值(范围值模式)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventProjectListOutput.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值(范围值模式)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventProjectListOutput.CompletionCountDisplay">
|
||||
<summary>
|
||||
完成人数显示文本(如"5人"或"3-7人")
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventProjectListOutput.ProjectType">
|
||||
<summary>
|
||||
项目类型
|
||||
@ -11979,9 +12049,24 @@
|
||||
项目类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.AddProjectInput.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式(0=单一值, 1=范围值)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.AddProjectInput.CompletionCount">
|
||||
<summary>
|
||||
完成人数
|
||||
完成人数(单一值模式时必填)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.AddProjectInput.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值(范围值模式时必填)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.AddProjectInput.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值(范围值模式时必填)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.AddProjectInput.Fee">
|
||||
@ -12064,9 +12149,29 @@
|
||||
项目类型名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式(0=单一值, 1=范围值)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.CompletionCount">
|
||||
<summary>
|
||||
完成人数
|
||||
完成人数(单一值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.CompletionCountDisplay">
|
||||
<summary>
|
||||
完成人数显示文本(用于前端显示,如 "5人" 或 "3-5人")
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Project.Dtos.ProjectDto.Fee">
|
||||
|
||||
@ -22,10 +22,25 @@ public class Project : Entity<long>, ISoftDelete, ICreatedUserId, ICreatedTime,
|
||||
public ProjectTypeEnum ProjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数
|
||||
/// 完成人数模式(0=单一值, 1=范围值)
|
||||
/// </summary>
|
||||
public int CompletionCountType { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数(单一值模式时有效)
|
||||
/// </summary>
|
||||
public int CompletionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最小值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成人数最大值(范围值模式时有效)
|
||||
/// </summary>
|
||||
public int? CompletionCountMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用(元)
|
||||
/// </summary>
|
||||
|
||||
@ -3043,9 +3043,24 @@
|
||||
项目类型(枚举)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Project.CompletionCountType">
|
||||
<summary>
|
||||
完成人数模式(0=单一值, 1=范围值)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Project.CompletionCount">
|
||||
<summary>
|
||||
完成人数
|
||||
完成人数(单一值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Project.CompletionCountMin">
|
||||
<summary>
|
||||
完成人数最小值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Project.CompletionCountMax">
|
||||
<summary>
|
||||
完成人数最大值(范围值模式时有效)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Project.Fee">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user