From 4b9f845fae9cd2fe0565560ee992d70ae3772e06 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sun, 28 Dec 2025 17:44:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=BF=80=E6=B4=BB=E7=A0=81=E4=B8=8EVIP?= =?UTF-8?q?=E5=85=85=E5=80=BC=E6=94=AF=E6=8C=81=E6=8C=89=E5=A4=A9=E8=AE=A1?= =?UTF-8?q?=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 VIP 天数概念,支持月数与天数组合计算过期时间 - 激活码商品新增 VipDays 配置,并新增 1 天会员试用组合包 - VIP 充值统一按天数计算(1 个月 = 31 天),兼容原有逻辑 - 激活码兑换时支持仅天数或天月组合的 VIP 充值 --- .../Dtos/Recharge/RechargeCreateInput.cs | 8 +++++++- .../Services/ActivationCodeService.cs | 3 ++- .../Services/RechargeService.cs | 19 +++++++++++++++---- .../Enums/ActivationCodeGoodsTypeEnum.cs | 18 +++++++++++++----- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Recharge/RechargeCreateInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Recharge/RechargeCreateInput.cs index 96aa06ce..505a691f 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Recharge/RechargeCreateInput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Recharge/RechargeCreateInput.cs @@ -25,11 +25,17 @@ public class RechargeCreateInput public string Content { get; set; } = string.Empty; /// - /// VIP月数(为空或0表示永久VIP) + /// VIP月数(为空或0表示永久VIP,1个月按31天计算) /// [Range(0, int.MaxValue, ErrorMessage = "月数必须大于等于0")] public int? Months { get; set; } + /// + /// VIP天数(为空或0表示不使用天数充值) + /// + [Range(0, int.MaxValue, ErrorMessage = "天数必须大于等于0")] + public int? Days { get; set; } + /// /// 备注 /// diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs index 799e8764..0a869d4f 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/ActivationCodeService.cs @@ -92,7 +92,7 @@ public class ActivationCodeService : ApplicationService, IActivationCodeService isCreateRechargeRecord: !goods.IsCombo); } - if (goods.VipMonths > 0) + if (goods.VipMonths > 0 || goods.VipDays > 0) { await _rechargeService.RechargeVipAsync(new RechargeCreateInput { @@ -100,6 +100,7 @@ public class ActivationCodeService : ApplicationService, IActivationCodeService RechargeAmount = totalAmount, Content = packageName, Months = goods.VipMonths, + Days = goods.VipDays, Remark = "激活码兑换", ContactInfo = null }); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/RechargeService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/RechargeService.cs index 2894b909..312dac87 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/RechargeService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/RechargeService.cs @@ -55,13 +55,24 @@ namespace Yi.Framework.AiHub.Application.Services /// /// 充值输入参数 /// - [HttpPost("recharge/vip")] + [RemoteService(isEnabled:false)] public async Task RechargeVipAsync(RechargeCreateInput input) { DateTime? expireDateTime = null; - // 如果传入了月数,计算过期时间 + // 计算总天数(1个月 = 31天) + int totalDays = 0; if (input.Months.HasValue && input.Months.Value > 0) + { + totalDays += input.Months.Value * 31; + } + if (input.Days.HasValue && input.Days.Value > 0) + { + totalDays += input.Days.Value; + } + + // 如果有天数,计算过期时间 + if (totalDays > 0) { // 直接查询该用户最大的过期时间 var maxExpireTime = await _repository._DbQueryable @@ -75,9 +86,9 @@ namespace Yi.Framework.AiHub.Application.Services ? maxExpireTime.Value : DateTime.Now; // 计算新的过期时间 - expireDateTime = baseDateTime.AddMonths(input.Months.Value); + expireDateTime = baseDateTime.AddDays(totalDays); } - // 如果月数为空或0,表示永久VIP,ExpireDateTime保持为null + // 如果总天数为0,表示永久VIP,ExpireDateTime保持为null // 创建充值记录 var rechargeRecord = new AiRechargeAggregateRoot diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/ActivationCodeGoodsTypeEnum.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/ActivationCodeGoodsTypeEnum.cs index 70dd8769..f32ef82a 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/ActivationCodeGoodsTypeEnum.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/ActivationCodeGoodsTypeEnum.cs @@ -12,6 +12,7 @@ public class ActivationCodeGoodsAttribute : Attribute public decimal Price { get; } public long TokenAmount { get; } public int VipMonths { get; } + public int VipDays { get; } public bool IsCombo { get; } public bool IsReusable { get; } public bool IsSameTypeOnce { get; } @@ -26,11 +27,13 @@ public class ActivationCodeGoodsAttribute : Attribute bool isReusable, bool isSameTypeOnce, string displayName, - string content) + string content, + int vipDays = 0) { Price = (decimal)price; TokenAmount = tokenAmount; VipMonths = vipMonths; + VipDays = vipDays; IsCombo = isCombo; IsReusable = isReusable; IsSameTypeOnce = isSameTypeOnce; @@ -85,9 +88,14 @@ public enum ActivationCodeGoodsTypeEnum [ActivationCodeGoods(price: 198.90, tokenAmount: 100000000, vipMonths: 0, isCombo: false, isReusable: false, isSameTypeOnce: false, displayName: "1亿 尊享Token", content: "特价包")] Premium1Yi = 6, - - - + + /// + /// 1【意心Ai会员1天+50w 尊享Token】新人试用首单组合包 + /// + [ActivationCodeGoods(price: 1, tokenAmount: 500000, vipMonths: 0, vipDays: 1, isCombo: true, isReusable: false, + isSameTypeOnce: true, displayName: "意心Ai会员1天+50w 尊享Token", content: "新人首单组合包")] + Vip1DayTest = 7, + /// /// 0【10w 尊享Token】免费包 /// @@ -103,4 +111,4 @@ public static class ActivationCodeGoodsTypeEnumExtensions var fieldInfo = goodsType.GetType().GetField(goodsType.ToString()); return fieldInfo?.GetCustomAttribute(); } -} +} \ No newline at end of file