diff --git a/YD_Event.Application/Event/Dtos/UserCompetitionDtos.cs b/YD_Event.Application/Event/Dtos/UserCompetitionDtos.cs index 6e93843..20b6d2e 100644 --- a/YD_Event.Application/Event/Dtos/UserCompetitionDtos.cs +++ b/YD_Event.Application/Event/Dtos/UserCompetitionDtos.cs @@ -134,14 +134,14 @@ public class UserEventDetailOutput public string Status { get; set; } /// - /// 赛事类型 + /// 赛事类型 (int: 0-线上, 1-线下) /// - public string Type { get; set; } + public int Type { get; set; } /// - /// 报名方式 + /// 报名方式 (int: 0-个人报名, 1-团队报名, 2-个人/团队报名) /// - public string RegistrationType { get; set; } + public int RegistrationType { get; set; } /// /// 积分规则名称 @@ -189,7 +189,22 @@ public class UserEventDetailOutput public string Description { get; set; } /// - /// 地址 + /// 省份名称 + /// + public string ProvinceName { get; set; } + + /// + /// 城市名称 + /// + public string CityName { get; set; } + + /// + /// 区县名称 + /// + public string DistrictName { get; set; } + + /// + /// 详细地址 /// public string Address { get; set; } @@ -251,9 +266,9 @@ public class UserEventLimitOutput public class UserEventFeeOutput { /// - /// 收费模式 + /// 收费模式 (int: 0-免费, 1-定价(赛事), 2-单价(赛事), 3-单价(项目)) /// - public string ChargeMode { get; set; } + public int ChargeMode { get; set; } /// /// 价格 @@ -897,6 +912,7 @@ public class UploadVoucherInput /// 支付金额 /// [Required] + [Range(0.01, double.MaxValue, ErrorMessage = "支付金额必须大于0")] public decimal PayAmount { get; set; } /// @@ -904,13 +920,6 @@ public class UploadVoucherInput /// [Required] public DateTime PayTime { get; set; } - - - - /// - /// 交易流水号 (可选) - /// - public string? TransactionId { get; set; } } /// diff --git a/YD_Event.Application/Event/UnifiedRegistrationService.cs b/YD_Event.Application/Event/UnifiedRegistrationService.cs index 26f0777..cc2b73e 100644 --- a/YD_Event.Application/Event/UnifiedRegistrationService.cs +++ b/YD_Event.Application/Event/UnifiedRegistrationService.cs @@ -160,7 +160,7 @@ public class UnifiedRegistrationService : ITransient private async Task GetOrCreateRegistrationAsync(UnifiedRegistrationInput input) { var existingRegistration = await _registrationRepository.GetFirstAsync( - r => r.EventId == input.EventId && r.CreatedUserId == input.CreatedUserId && (r.PaymentStatus != 4 || r.PaymentStatus != 3)); + r => r.EventId == input.EventId && r.CreatedUserId == input.CreatedUserId && r.PaymentStatus != 4 && r.PaymentStatus != 3); if (existingRegistration != null) { diff --git a/YD_Event.Application/Event/UserEventRecordService.cs b/YD_Event.Application/Event/UserEventRecordService.cs index 8ed66a7..c9d15f0 100644 --- a/YD_Event.Application/Event/UserEventRecordService.cs +++ b/YD_Event.Application/Event/UserEventRecordService.cs @@ -273,7 +273,33 @@ public class UserEventRecordService : IDynamicApiController, ITransient var registration = await _registrationRepository.GetFirstAsync(x => x.Id == registrationId && x.CreatedUserId == userId); if (registration == null) throw Oops.Bah("报名记录不存在"); + // 允许的文件类型 + var allowedFileTypes = new[] { "image/jpeg", "image/jpg", "image/png", "application/pdf" }; + // 允许的文件扩展名 + var allowedFileExtensions = new[] { ".jpg", ".jpeg", ".png", ".pdf" }; + // 最大文件大小 5MB + const long maxFileSize = 5 * 1024 * 1024; + // 验证文件类型 + var fileName = input.File.FileName.ToLower(); + var hasValidExtension = allowedFileExtensions.Any(ext => fileName.EndsWith(ext)); + var hasValidType = allowedFileTypes.Contains(input.File.ContentType); + if (!hasValidExtension && !hasValidType) + { + throw Oops.Bah("仅支持jpg、jpeg、png、pdf格式的文件"); + } + + // 验证文件大小 + if (input.File.Length > maxFileSize) + { + throw Oops.Bah("文件大小不能超过5MB"); + } + + // 验证支付金额 + if (input.PayAmount <= 0) + { + throw Oops.Bah("支付金额必须大于0"); + } var uploadResult = await _fileService.Upload(input.File); var fileInfo = uploadResult.First(); diff --git a/YD_Event.Application/Event/UserEventRegistrationService.cs b/YD_Event.Application/Event/UserEventRegistrationService.cs index b52b755..5eb537c 100644 --- a/YD_Event.Application/Event/UserEventRegistrationService.cs +++ b/YD_Event.Application/Event/UserEventRegistrationService.cs @@ -209,11 +209,32 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient output.Description = eventInfo.EventIntroduction; output.Address = eventInfo.DetailAddress; output.EventVideo = eventInfo.EventVideo; - output.RegistrationType = eventInfo.RegistrationType.ToString(); + + // 直接赋值 int 类型 + output.Type = (int)eventInfo.EventType; + output.RegistrationType = (int)eventInfo.RegistrationType; + output.IsNeedMaterial = eventInfo.IsNeedMaterial; output.MaterialRemark = eventInfo.MaterialRemark; output.MaterialUploadEndTime = eventInfo.MaterialUploadEndTime; + // 查询省市区名称 + if (eventInfo.ProvinceId.HasValue) + { + var province = await _db.Queryable().FirstAsync(x => x.Id == eventInfo.ProvinceId.Value && !x.DeleteMark); + output.ProvinceName = province?.ProvinceName ?? ""; + } + if (eventInfo.CityId.HasValue) + { + var city = await _db.Queryable().FirstAsync(x => x.Id == eventInfo.CityId.Value && !x.DeleteMark); + output.CityName = city?.CityName ?? ""; + } + if (eventInfo.DistrictId.HasValue) + { + var district = await _db.Queryable().FirstAsync(x => x.Id == eventInfo.DistrictId.Value && !x.DeleteMark); + output.DistrictName = district?.DistrictName ?? ""; + } + if (eventInfo.PointsRuleId.HasValue) { var rule = await _pointsRuleRepository.GetByIdAsync(eventInfo.PointsRuleId.Value); @@ -238,7 +259,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient { var feeConfig = new UserEventFeeOutput { - ChargeMode = fee.ChargeMode.ToString(), + ChargeMode = (int)fee.ChargeMode, Price = fee.Price }; diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml index 5ccf366..7e6ee8a 100644 --- a/YD_Event.Application/YD_Event.Application.xml +++ b/YD_Event.Application/YD_Event.Application.xml @@ -6623,12 +6623,12 @@ - 赛事类型 + 赛事类型 (int: 0-线上, 1-线下) - 报名方式 + 报名方式 (int: 0-个人报名, 1-团队报名, 2-个人/团队报名) @@ -6676,9 +6676,24 @@ 赛事简介/规则 + + + 省份名称 + + + + + 城市名称 + + + + + 区县名称 + + - 地址 + 详细地址 @@ -6738,7 +6753,7 @@ - 收费模式 + 收费模式 (int: 0-免费, 1-定价(赛事), 2-单价(赛事), 3-单价(项目)) @@ -7366,11 +7381,6 @@ 支付时间 - - - 交易流水号 (可选) - - 支付凭证输出 diff --git a/YD_Event.Application/applicationsettings.json b/YD_Event.Application/applicationsettings.json index 00f7429..d2c81fb 100644 --- a/YD_Event.Application/applicationsettings.json +++ b/YD_Event.Application/applicationsettings.json @@ -37,8 +37,8 @@ { "ConfigId": 1, "DbType": "SqlServer", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom - //"ConnectionString": "Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=EventServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;Encrypt=True;TrustServerCertificate=True;", - "ConnectionString": "Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=EventServerDB;User ID=yd;Password=Admin@123456;Connect Timeout=500;Encrypt=True;TrustServerCertificate=True;", + "ConnectionString": "Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=EventServerDB_QA;User ID=qa;Password=Admin@123;Connect Timeout=500;Encrypt=True;TrustServerCertificate=True;", + //"ConnectionString": "Data Source=rm-uf64b8oxdt19pfyxfao.sqlserver.rds.aliyuncs.com;Database=EventServerDB;User ID=yd;Password=Admin@123456;Connect Timeout=500;Encrypt=True;TrustServerCertificate=True;", "IsAutoCloseConnection": true, "EnableInitDb": false // 启用数据库以及数据表初始化(首次运行项目时开启可以自动创建数据库和初始化项目运行的基础数据) } @@ -53,8 +53,8 @@ "SleepMs": 300, "dbconfig": { "ConnectionStrings": [ - //"8.153.108.90,Password=yd708090,SyncTimeout=15000,ConnectTimeout=15000,ResponseTimeout=15000,defaultDatabase=7,poolsize=100,ssl=false,writeBuffer=10240,idleTimeout=30000,connectRetry=3,asyncPipeline=false", - "8.153.108.90,Password=yd708090,SyncTimeout=15000,ConnectTimeout=15000,ResponseTimeout=15000,defaultDatabase=8,poolsize=100,ssl=false,writeBuffer=10240,idleTimeout=30000,connectRetry=3,asyncPipeline=false" + "8.153.108.90,Password=yd708090,SyncTimeout=15000,ConnectTimeout=15000,ResponseTimeout=15000,defaultDatabase=7,poolsize=100,ssl=false,writeBuffer=10240,idleTimeout=30000,connectRetry=3,asyncPipeline=false", + //"8.153.108.90,Password=yd708090,SyncTimeout=15000,ConnectTimeout=15000,ResponseTimeout=15000,defaultDatabase=8,poolsize=100,ssl=false,writeBuffer=10240,idleTimeout=30000,connectRetry=3,asyncPipeline=false" ], //"Sentinels": [ // "192.169.1.10:26379",