diff --git a/YD_Event.Application/Client/EventClientController.cs b/YD_Event.Application/Client/EventClientController.cs index 39fd551..09d9579 100644 --- a/YD_Event.Application/Client/EventClientController.cs +++ b/YD_Event.Application/Client/EventClientController.cs @@ -4,10 +4,12 @@ using Microsoft.Extensions.Logging; using YD_Event.Application.Client.Dtos; using YD_Event.Core.Entities; using YD_Event.Core.Enum; -using YD_Event.Core.Utils; +using Easy.Core; using YD_Event.Core.Infrastructure.WeChat; using YD_Event.Core.Infrastructure.WeChat.Dto; using YD_Event.Core.Options; +using YD_Event.Core.Domain.Pricing; +using YD_Event.Core.Domain.Pricing.Models; using SqlSugar; using Furion.DatabaseAccessor; using Microsoft.AspNetCore.Authorization; @@ -496,7 +498,7 @@ public class EventClientController : IDynamicApiController int totalParticipantCount = input.Items.Sum(i => i.PersonCount); // 构建定价服务输入 - var pricingInput = new YD_Event.Core.Domain.Pricing.EventPricingService.PricingInput + var pricingInput = new PricingInput { ChargeMode = evt.ChargeMode, ParticipantCount = totalParticipantCount, @@ -511,7 +513,7 @@ public class EventClientController : IDynamicApiController var bp = baseProjects.FirstOrDefault(p => p.Id == ep.ProjectId); - pricingInput.Projects.Add(new YD_Event.Core.Domain.Pricing.EventPricingService.ProjectPricingInfo + pricingInput.Projects.Add(new ProjectPricingInfo { ProjectId = ep.Id, ProjectName = bp?.Name ?? "", @@ -713,7 +715,7 @@ public class EventClientController : IDynamicApiController int totalPerson = input.Items.Sum(i => i.Persons!.Count); // 构建定价服务输入 - var pricingInput = new YD_Event.Core.Domain.Pricing.EventPricingService.PricingInput + var pricingInput = new PricingInput { ChargeMode = evt.ChargeMode, ParticipantCount = totalPerson, @@ -728,7 +730,7 @@ public class EventClientController : IDynamicApiController if (ep != null) { - pricingInput.Projects.Add(new YD_Event.Core.Domain.Pricing.EventPricingService.ProjectPricingInfo + pricingInput.Projects.Add(new ProjectPricingInfo { ProjectId = ep.Id, ProjectName = bp?.Name ?? "", diff --git a/YD_Event.Application/Event/EventService.cs b/YD_Event.Application/Event/EventService.cs index 60c2905..2691c26 100644 --- a/YD_Event.Application/Event/EventService.cs +++ b/YD_Event.Application/Event/EventService.cs @@ -2,7 +2,7 @@ using YD_Event.Application.Event.Dtos; using YD_Event.Application.Project.Dtos; using YD_Event.Core.Entities; using YD_Event.Core.Enum; -using YD_Event.Core.Utils; +using Easy.Core; using MiniExcelLibs; using SqlSugar; using Mapster; diff --git a/YD_Event.Application/Event/UserEventRecordService.cs b/YD_Event.Application/Event/UserEventRecordService.cs index a6b6cdd..7221237 100644 --- a/YD_Event.Application/Event/UserEventRecordService.cs +++ b/YD_Event.Application/Event/UserEventRecordService.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using YD_Event.Application.Event.Dtos; using YD_Event.Core.Entities; using YD_Event.Core.Enum; -using YD_Event.Core.Utils; +using Easy.Core; using SqlSugar; using Mapster; using YD_Event.Application.Auth; diff --git a/YD_Event.Application/Event/UserEventRegistrationService.cs b/YD_Event.Application/Event/UserEventRegistrationService.cs index d604b07..4bd0075 100644 --- a/YD_Event.Application/Event/UserEventRegistrationService.cs +++ b/YD_Event.Application/Event/UserEventRegistrationService.cs @@ -7,7 +7,8 @@ using YD_Event.Application.Project; using YD_Event.Core.Entities; using YD_Event.Core.Enum; using YD_Event.Core.Domain.Pricing; -using YD_Event.Core.Utils; +using YD_Event.Core.Domain.Pricing.Models; +using Easy.Core; using SqlSugar; using Mapster; using YD_Event.Application.Auth; @@ -1591,7 +1592,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient var baseProjects = await _projectRepository.GetListAsync(x => projectIds.Contains(x.Id)); // 构建统一计算服务的输入参数 - var pricingInput = new EventPricingService.PricingInput + var pricingInput = new PricingInput { ChargeMode = feeConfig.ChargeMode, ParticipantCount = input.ParticipantCount, @@ -1602,7 +1603,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient foreach (var eventProject in eventProjects) { var baseProject = baseProjects.FirstOrDefault(p => p.Id == eventProject.ProjectId); - pricingInput.Projects.Add(new EventPricingService.ProjectPricingInfo + pricingInput.Projects.Add(new ProjectPricingInfo { ProjectId = eventProject.ProjectId, ProjectName = baseProject?.Name ?? "未知项目", diff --git a/YD_Event.Application/GlobalUsings.cs b/YD_Event.Application/GlobalUsings.cs index c8b7534..7bd40a3 100644 --- a/YD_Event.Application/GlobalUsings.cs +++ b/YD_Event.Application/GlobalUsings.cs @@ -1,4 +1,4 @@ -global using Furion; +global using Furion; global using Furion.DataEncryption; global using Furion.DataValidation; global using Furion.DependencyInjection; @@ -28,4 +28,3 @@ global using System.Collections; global using Newtonsoft.Json; global using Newtonsoft.Json.Linq; global using System.Text.RegularExpressions; -global using YD_Event.Core.Config; \ No newline at end of file diff --git a/YD_Event.Application/YD_Event.Application.csproj b/YD_Event.Application/YD_Event.Application.csproj index 7c79515..6995eaf 100644 --- a/YD_Event.Application/YD_Event.Application.csproj +++ b/YD_Event.Application/YD_Event.Application.csproj @@ -37,7 +37,6 @@ - diff --git a/YD_Event.Core/Config/BlogSetting.cs b/YD_Event.Core/Config/BlogSetting.cs deleted file mode 100644 index 582d5fb..0000000 --- a/YD_Event.Core/Config/BlogSetting.cs +++ /dev/null @@ -1,67 +0,0 @@ - -using System; -using System.Collections.Generic; -namespace YD_Event.Core.Config; -public class BlogSetting -{ - /// - /// 网站Logo - /// - public string Logo { get; set; } - /// - /// 站点图标 - /// - public string Favicon { get; set; } - /// - /// 开启打赏 - /// - public bool? IsRewards { get; set; } - /// - /// 支付宝 - /// - public string AliPay { get; set; } - /// - /// 微信收款码 - /// - public string WxPay { get; set; } - /// - /// 允许留言 - /// - public bool? IsAllowMessage { get; set; } - /// - /// 允许评论 - /// - public bool? IsAllowComments { get; set; } - /// - /// 公告 - /// - public string Announcement { get; set; } - /// - /// 站点名称 - /// - public string SiteName { get; set; } - /// - /// 首页格言 - /// - public string Motto { get; set; } - /// - /// 网站运营时间 - /// - public DateTime RunTime { get; set; } - /// - /// 站点版权 - /// - public string Copyright { get; set; } - /// - /// 站点描述 - /// - public string Description { get; set; } - /// - /// 关键词 - /// - public string Keyword { get; set; } - /// - /// 备案号 - /// - public string Filing { get; set; } -} diff --git a/YD_Event.Core/Config/BloggerInfo.cs b/YD_Event.Core/Config/BloggerInfo.cs deleted file mode 100644 index a39ab0e..0000000 --- a/YD_Event.Core/Config/BloggerInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ - -using System; -using System.Collections.Generic; -namespace YD_Event.Core.Config; -public class BloggerInfo -{ - /// - /// 头像 - /// - public string Avatar { get; set; } - /// - /// 昵称 - /// - public string NikeName { get; set; } - /// - /// QQ - /// - public string QQ { get; set; } - /// - /// Github - /// - public string Github { get; set; } - /// - /// 码云 - /// - public string Gitee { get; set; } - /// - /// 个性签名 - /// - public string Motto { get; set; } - /// - /// 关于我 - /// - public string About { get; set; } -} diff --git a/YD_Event.Core/Config/SysSecuritySetting.cs b/YD_Event.Core/Config/SysSecuritySetting.cs deleted file mode 100644 index bb8effa..0000000 --- a/YD_Event.Core/Config/SysSecuritySetting.cs +++ /dev/null @@ -1,27 +0,0 @@ - -using System; -using System.Collections.Generic; -namespace YD_Event.Core.Config; -public class SysSecuritySetting -{ - /// - /// 用户默认密码 - /// - public string Password { get; set; } - /// - /// 密码错误次数 - /// - public int Times { get; set; } - /// - /// 密码规则 - /// - public string PasswordRule { get; set; } - /// - /// 密码规则提示语 - /// - public string RuleMessage { get; set; } - /// - /// Token有效期(分钟) - /// - public int? TokenExpired { get; set; } -} diff --git a/YD_Event.Core/Domain/Certificate/DocxTemplateParser.cs b/YD_Event.Core/Domain/Certificate/DocxTemplateParser.cs index c62d1ff..6c98193 100644 --- a/YD_Event.Core/Domain/Certificate/DocxTemplateParser.cs +++ b/YD_Event.Core/Domain/Certificate/DocxTemplateParser.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/YD_Event.Core/Domain/Certificate/DocxTemplateProcessor.cs b/YD_Event.Core/Domain/Certificate/DocxTemplateProcessor.cs index 313feb7..5b9e630 100644 --- a/YD_Event.Core/Domain/Certificate/DocxTemplateProcessor.cs +++ b/YD_Event.Core/Domain/Certificate/DocxTemplateProcessor.cs @@ -1,11 +1,9 @@ -using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; -using DocumentFormat.OpenXml.Drawing.Wordprocessing; using Furion.DependencyInjection; namespace YD_Event.Core.Domain.Certificate diff --git a/YD_Event.Core/Domain/Certificate/CertificateModel.cs b/YD_Event.Core/Domain/Certificate/Models/CertificateModel.cs similarity index 87% rename from YD_Event.Core/Domain/Certificate/CertificateModel.cs rename to YD_Event.Core/Domain/Certificate/Models/CertificateModel.cs index 681437e..d077a0b 100644 --- a/YD_Event.Core/Domain/Certificate/CertificateModel.cs +++ b/YD_Event.Core/Domain/Certificate/Models/CertificateModel.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace YD_Event.Core.Domain.Certificate; +namespace YD_Event.Core.Domain.Certificate.Models; /// /// 证书模型 diff --git a/YD_Event.Core/Domain/Certificate/QRCodeService.cs b/YD_Event.Core/Domain/Certificate/QRCodeService.cs index 13be5a6..8bd8e59 100644 --- a/YD_Event.Core/Domain/Certificate/QRCodeService.cs +++ b/YD_Event.Core/Domain/Certificate/QRCodeService.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using QRCoder; using Furion.DependencyInjection; diff --git a/YD_Event.Core/Domain/Pricing/EventPricingService.cs b/YD_Event.Core/Domain/Pricing/EventPricingService.cs index 44072ab..c98bdbc 100644 --- a/YD_Event.Core/Domain/Pricing/EventPricingService.cs +++ b/YD_Event.Core/Domain/Pricing/EventPricingService.cs @@ -1,4 +1,5 @@ using YD_Event.Core.Enum; +using YD_Event.Core.Domain.Pricing.Models; namespace YD_Event.Core.Domain.Pricing; @@ -8,110 +9,6 @@ namespace YD_Event.Core.Domain.Pricing; /// public static class EventPricingService { - /// - /// 定价计算输入参数 - /// - public class PricingInput - { - /// - /// 收费模式 - /// - public ChargeMode ChargeMode { get; set; } - - /// - /// 参赛人数 - /// - public int ParticipantCount { get; set; } - - /// - /// 赛事定价(用于定价(赛事)和单价(赛事)模式) - /// - public decimal EventPrice { get; set; } - - /// - /// 项目列表(单价项目模式使用) - /// - public List Projects { get; set; } = new List(); - } - - /// - /// 项目定价信息 - /// - public class ProjectPricingInfo - { - /// - /// 项目ID - /// - public long ProjectId { get; set; } - - /// - /// 项目名称 - /// - public string ProjectName { get; set; } = string.Empty; - - /// - /// 项目单价(元) - /// - public decimal UnitPrice { get; set; } - } - - /// - /// 定价计算结果 - /// - public class PricingResult - { - /// - /// 总金额(精确到分) - /// - public decimal TotalAmount { get; set; } - - /// - /// 总人数 - /// - public int TotalPersonCount { get; set; } - - /// - /// 费用明细 - /// - public List Details { get; set; } = new List(); - - /// - /// 计算日志(用于审计) - /// - public List CalculationLogs { get; set; } = new List(); - } - - /// - /// 费用明细项 - /// - public class PricingDetailItem - { - /// - /// 项目名称 - /// - public string ItemName { get; set; } = string.Empty; - - /// - /// 单价 - /// - public decimal UnitPrice { get; set; } - - /// - /// 数量 - /// - public int Quantity { get; set; } - - /// - /// 小计 - /// - public decimal Subtotal { get; set; } - - /// - /// 备注 - /// - public string? Remark { get; set; } - } - /// /// 计算赛事报名费用 /// @@ -142,7 +39,6 @@ public static class EventPricingService break; } - // 确保金额精确到分 result.TotalAmount = Math.Round(result.TotalAmount, 2, MidpointRounding.AwayFromZero); result.CalculationLogs.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 最终总金额: {result.TotalAmount:F2} 元"); @@ -230,7 +126,6 @@ public static class EventPricingService var totalAmount = totalProjectPrice * input.ParticipantCount; result.TotalAmount = totalAmount; - // 添加汇总项 result.Details.Add(new PricingDetailItem { ItemName = input.ParticipantCount == 1 ? "项目总价" : "项目总价 × 人数", diff --git a/YD_Event.Core/Domain/Pricing/Models/PricingDetailItem.cs b/YD_Event.Core/Domain/Pricing/Models/PricingDetailItem.cs new file mode 100644 index 0000000..a4ac496 --- /dev/null +++ b/YD_Event.Core/Domain/Pricing/Models/PricingDetailItem.cs @@ -0,0 +1,32 @@ +namespace YD_Event.Core.Domain.Pricing.Models; + +/// +/// 费用明细项 +/// +public class PricingDetailItem +{ + /// + /// 项目名称 + /// + public string ItemName { get; set; } = string.Empty; + + /// + /// 单价 + /// + public decimal UnitPrice { get; set; } + + /// + /// 数量 + /// + public int Quantity { get; set; } + + /// + /// 小计 + /// + public decimal Subtotal { get; set; } + + /// + /// 备注 + /// + public string? Remark { get; set; } +} diff --git a/YD_Event.Core/Domain/Pricing/Models/PricingInput.cs b/YD_Event.Core/Domain/Pricing/Models/PricingInput.cs new file mode 100644 index 0000000..41f727a --- /dev/null +++ b/YD_Event.Core/Domain/Pricing/Models/PricingInput.cs @@ -0,0 +1,29 @@ +using YD_Event.Core.Enum; + +namespace YD_Event.Core.Domain.Pricing.Models; + +/// +/// 定价计算输入参数 +/// +public class PricingInput +{ + /// + /// 收费模式 + /// + public ChargeMode ChargeMode { get; set; } + + /// + /// 参赛人数 + /// + public int ParticipantCount { get; set; } + + /// + /// 赛事定价(用于定价(赛事)和单价(赛事)模式) + /// + public decimal EventPrice { get; set; } + + /// + /// 项目列表(单价项目模式使用) + /// + public List Projects { get; set; } = new List(); +} diff --git a/YD_Event.Core/Domain/Pricing/Models/PricingResult.cs b/YD_Event.Core/Domain/Pricing/Models/PricingResult.cs new file mode 100644 index 0000000..66eca0a --- /dev/null +++ b/YD_Event.Core/Domain/Pricing/Models/PricingResult.cs @@ -0,0 +1,27 @@ +namespace YD_Event.Core.Domain.Pricing.Models; + +/// +/// 定价计算结果 +/// +public class PricingResult +{ + /// + /// 总金额(精确到分) + /// + public decimal TotalAmount { get; set; } + + /// + /// 总人数 + /// + public int TotalPersonCount { get; set; } + + /// + /// 费用明细 + /// + public List Details { get; set; } = new List(); + + /// + /// 计算日志(用于审计) + /// + public List CalculationLogs { get; set; } = new List(); +} diff --git a/YD_Event.Core/Domain/Pricing/Models/ProjectPricingInfo.cs b/YD_Event.Core/Domain/Pricing/Models/ProjectPricingInfo.cs new file mode 100644 index 0000000..cd1a6a7 --- /dev/null +++ b/YD_Event.Core/Domain/Pricing/Models/ProjectPricingInfo.cs @@ -0,0 +1,22 @@ +namespace YD_Event.Core.Domain.Pricing.Models; + +/// +/// 项目定价信息 +/// +public class ProjectPricingInfo +{ + /// + /// 项目ID + /// + public long ProjectId { get; set; } + + /// + /// 项目名称 + /// + public string ProjectName { get; set; } = string.Empty; + + /// + /// 项目单价(元) + /// + public decimal UnitPrice { get; set; } +} diff --git a/YD_Event.Core/Utils/AmountHelper.cs b/YD_Event.Core/Extensions/AmountHelper.cs similarity index 92% rename from YD_Event.Core/Utils/AmountHelper.cs rename to YD_Event.Core/Extensions/AmountHelper.cs index 24bc8d4..a99016f 100644 --- a/YD_Event.Core/Utils/AmountHelper.cs +++ b/YD_Event.Core/Extensions/AmountHelper.cs @@ -1,4 +1,4 @@ -namespace YD_Event.Core.Utils; +namespace Easy.Core; /// /// 金额处理工具类 @@ -18,8 +18,6 @@ public static class AmountHelper /// 金额(分) public static int YuanToFen(decimal amount) { - // 使用四舍五入到最近的整数,使用银行家舍入法(四舍六入五成双) - // 这里先确保精度,然后乘以100,再四舍五入 var roundedAmount = Math.Round(amount, DecimalPlaces, MidpointRounding.AwayFromZero); return (int)Math.Round(roundedAmount * 100, MidpointRounding.AwayFromZero); } diff --git a/YD_Event.Core/YD_Event.Core.csproj b/YD_Event.Core/YD_Event.Core.csproj index 19bd8fc..58d5b1f 100644 --- a/YD_Event.Core/YD_Event.Core.csproj +++ b/YD_Event.Core/YD_Event.Core.csproj @@ -20,8 +20,6 @@ - - @@ -31,7 +29,6 @@ - diff --git a/YD_Event.Core/YD_Event.Core.xml b/YD_Event.Core/YD_Event.Core.xml index 0acb848..65f5293 100644 --- a/YD_Event.Core/YD_Event.Core.xml +++ b/YD_Event.Core/YD_Event.Core.xml @@ -4,141 +4,6 @@ YD_Event.Core - - - 头像 - - - - - 昵称 - - - - - QQ - - - - - Github - - - - - 码云 - - - - - 个性签名 - - - - - 关于我 - - - - - 网站Logo - - - - - 站点图标 - - - - - 开启打赏 - - - - - 支付宝 - - - - - 微信收款码 - - - - - 允许留言 - - - - - 允许评论 - - - - - 公告 - - - - - 站点名称 - - - - - 首页格言 - - - - - 网站运营时间 - - - - - 站点版权 - - - - - 站点描述 - - - - - 关键词 - - - - - 备案号 - - - - - 用户默认密码 - - - - - 密码错误次数 - - - - - 密码规则 - - - - - 密码规则提示语 - - - - - Token有效期(分钟) - - 用户唯一ID @@ -179,36 +44,6 @@ 自定义配置缓存键 - - - 证书模型 - - - - - 证书名称 - - - - - 证书编号 - - - - - 背景图片URL - - - - - 宽度 - - - - - 高度 - - DOCX模板解析器 @@ -330,6 +165,36 @@ 模板验证结果 + + + 证书模型 + + + + + 证书名称 + + + + + 证书编号 + + + + + 背景图片URL + + + + + 宽度 + + + + + 高度 + + 二维码服务 @@ -494,134 +359,134 @@ 所有金额计算均以此服务为准,确保计算结果的一致性 - - - 定价计算输入参数 - - - - - 收费模式 - - - - - 参赛人数 - - - - - 赛事定价(用于定价(赛事)和单价(赛事)模式) - - - - - 项目列表(单价项目模式使用) - - - - - 项目定价信息 - - - - - 项目ID - - - - - 项目名称 - - - - - 项目单价(元) - - - - - 定价计算结果 - - - - - 总金额(精确到分) - - - - - 总人数 - - - - - 费用明细 - - - - - 计算日志(用于审计) - - - - - 费用明细项 - - - - - 项目名称 - - - - - 单价 - - - - - 数量 - - - - - 小计 - - - - - 备注 - - - + 计算赛事报名费用 定价计算输入 定价计算结果 - + 免费模式 - + 定价(赛事)模式:固定为赛事设定价格/场,无论参赛主体是个人还是单位,也无论参赛项目数量多少,均统一按固定价格计算 - + 单价(赛事)模式:按照赛事设定的单价乘以实际报名人数计算总金额 - + 单价(项目)模式:根据每个项目的单独定价和报名人数进行计算。 将每个报名项目的单价相加得到单人总费用,再乘以报名人数得出最终金额 + + + 费用明细项 + + + + + 项目名称 + + + + + 单价 + + + + + 数量 + + + + + 小计 + + + + + 备注 + + + + + 定价计算输入参数 + + + + + 收费模式 + + + + + 参赛人数 + + + + + 赛事定价(用于定价(赛事)和单价(赛事)模式) + + + + + 项目列表(单价项目模式使用) + + + + + 定价计算结果 + + + + + 总金额(精确到分) + + + + + 总人数 + + + + + 费用明细 + + + + + 计算日志(用于审计) + + + + + 项目定价信息 + + + + + 项目ID + + + + + 项目名称 + + + + + 项目单价(元) + + 表实体继承 @@ -5806,39 +5671,39 @@ 子选项 - + 金额处理工具类 统一处理货币单位转换、精度控制和四舍五入规则 - + 金额精度小数位数 - + 将元转换为分 金额(元) 金额(分) - + 将分转换为元 金额(分) 金额(元) - + 将分转换为元(可为空) 金额(分) 金额(元) - + 四舍五入金额到指定小数位 @@ -5846,14 +5711,14 @@ 小数位数,默认2位 四舍五入后的金额 - + 验证金额格式是否正确(最多保留2位小数) 金额 是否有效 - + 验证金额是否大于0且格式正确 diff --git a/YD_Event.Web.Core/Startup.cs b/YD_Event.Web.Core/Startup.cs index df175a1..31bfaab 100644 --- a/YD_Event.Web.Core/Startup.cs +++ b/YD_Event.Web.Core/Startup.cs @@ -10,19 +10,16 @@ using SqlSugar; using System.Text; using System.Threading.Tasks; using AspNetCoreRateLimit; +using Easy.Core; using YD_Event.Core.Logging; using YD_Event.Core.Options; -using Easy.Core; -using Furion.Logging; using Lazy.Captcha.Core; using Lazy.Captcha.Core.Generator; -using Mapster; using Microsoft.AspNetCore.Authentication.JwtBearer; using MrHuo.OAuth; using MrHuo.OAuth.QQ; using QuestPDF; using QuestPDF.Infrastructure; - using SkiaSharp; namespace YD_Event.Web.Core;