From 48150b712acbf58c4010ed83f130550defd5f467 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 15 Oct 2025 19:49:33 +0800 Subject: [PATCH 1/6] =?UTF-8?q?refactor:=20=E4=BC=9A=E8=AF=9DID=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E4=B8=8D=E5=AD=98=E5=82=A8=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E5=B9=B6=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Managers/AiGateWayManager.cs | 50 ++++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs index 5fd0c875..e7e4216e 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs @@ -139,7 +139,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = request.Messages?.LastOrDefault().Content ?? string.Empty, + Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault().Content ?? string.Empty, ModelId = request.Model, TokenUsage = data.Usage, }); @@ -147,7 +147,8 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateSystemMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = data.Choices?.FirstOrDefault()?.Delta.Content, + Content = + sessionId is null ? "不予存储" : data.Choices?.FirstOrDefault()?.Delta.Content ?? string.Empty, ModelId = request.Model, TokenUsage = data.Usage }); @@ -271,7 +272,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId, sessionId, new MessageInputDto { - Content = request.Messages?.LastOrDefault()?.Content ?? string.Empty, + Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault()?.Content ?? string.Empty, ModelId = request.Model, TokenUsage = tokenUsage, }); @@ -279,7 +280,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, new MessageInputDto { - Content = backupSystemContent.ToString(), + Content = sessionId is null ? "不予存储" : backupSystemContent.ToString(), ModelId = request.Model, TokenUsage = tokenUsage }); @@ -333,7 +334,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId, sessionId, new MessageInputDto { - Content = request.Prompt, + Content = sessionId is null ? "不予存储" : request.Prompt, ModelId = model, TokenUsage = response.Usage, }); @@ -341,13 +342,13 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, new MessageInputDto { - Content = response.Results?.FirstOrDefault()?.Url, + Content = sessionId is null ? "不予存储" : response.Results?.FirstOrDefault()?.Url, ModelId = model, TokenUsage = response.Usage }); await _usageStatisticsManager.SetUsageAsync(userId, model, response.Usage); - + // 扣减尊享token包用量 if (userId is not null && PremiumPackageConst.ModeIds.Contains(request.Model)) { @@ -528,7 +529,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = request.Messages?.FirstOrDefault()?.Content ?? string.Empty, + Content = sessionId is null ? "不予存储" : request.Messages?.FirstOrDefault()?.Content ?? string.Empty, ModelId = request.Model, TokenUsage = data.TokenUsage, }); @@ -536,7 +537,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateSystemMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = data.content?.FirstOrDefault()?.text, + Content = sessionId is null ? "不予存储" : data.content?.FirstOrDefault()?.text, ModelId = request.Model, TokenUsage = data.TokenUsage }); @@ -601,35 +602,12 @@ public class AiGateWayManager : DomainService _logger.LogError(e, $"Ai对话异常"); var errorContent = $"对话Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}"; throw new UserFriendlyException(errorContent); - // var model = new AnthropicStreamDto - // { - // Message = new AnthropicChatCompletionDto - // { - // content = - // [ - // new AnthropicChatCompletionDtoContent - // { - // text = errorContent, - // } - // ], - // }, - // Error = new AnthropicStreamErrorDto - // { - // Type = null, - // Message = errorContent - // } - // }; - // var message = JsonConvert.SerializeObject(model, new JsonSerializerSettings - // { - // ContractResolver = new CamelCasePropertyNamesContractResolver() - // }); - // await response.WriteAsJsonAsync(message, ThorJsonSerializer.DefaultOptions); } await _aiMessageManager.CreateUserMessageAsync(userId, sessionId, new MessageInputDto { - Content = request.Messages?.LastOrDefault()?.Content ?? string.Empty, + Content = sessionId is null ? "不予存储" : request.Messages?.LastOrDefault()?.Content ?? string.Empty, ModelId = request.Model, TokenUsage = tokenUsage, }); @@ -637,7 +615,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, new MessageInputDto { - Content = backupSystemContent.ToString(), + Content = sessionId is null ? "不予存储" : backupSystemContent.ToString(), ModelId = request.Model, TokenUsage = tokenUsage }); @@ -648,9 +626,9 @@ public class AiGateWayManager : DomainService if (userId.HasValue && tokenUsage is not null) { var totalTokens = tokenUsage.TotalTokens ?? 0; - if (totalTokens > 0) + if (tokenUsage.TotalTokens > 0) { - await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); + await PremiumPackageManager.TryConsumeTokensAsync(userId.Value, totalTokens); } } } From acb2db839731fb8533345ef6dbee253ac77fcaac Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 15 Oct 2025 23:00:42 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Pay/GoodsListOutput.cs | 12 ++++++++---- .../Services/PayService.cs | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Pay/GoodsListOutput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Pay/GoodsListOutput.cs index 7a25970f..e2602dab 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Pay/GoodsListOutput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Pay/GoodsListOutput.cs @@ -21,7 +21,7 @@ public class GoodsListOutput /// 商品参考价格 /// public decimal ReferencePrice { get; set; } - + /// /// 商品实际价格(折扣后的价格) /// @@ -31,7 +31,7 @@ public class GoodsListOutput /// 折扣金额(仅尊享包) /// public decimal? DiscountAmount { get; set; } - + /// /// 商品类别 /// @@ -43,9 +43,13 @@ public class GoodsListOutput public string Remark { get; set; } - /// /// 折扣说明(仅尊享包) /// public string? DiscountDescription { get; set; } -} + + /// + /// 商品类型 + /// + public GoodsTypeEnum GoodsType { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs index 7e38d42b..f40a46c3 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs @@ -261,7 +261,8 @@ public class PayService : ApplicationService, IPayService GoodsCategory = goodsType.GetGoodsCategory().ToString(), Remark = goodsType.GetRemark(), DiscountAmount = discountAmount, - DiscountDescription = discountDescription + DiscountDescription = discountDescription, + GoodsType = goodsType }; goodsList.Add(goodsItem); From 375dd4f797352317eed71ef41c730eba50544ad8 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 15 Oct 2025 23:04:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=94=AF=E4=BB=98?= =?UTF-8?q?3=E4=BD=8D=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enums/GoodsTypeEnum.cs | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs index 73d5f752..b06dba6f 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs @@ -10,11 +10,11 @@ namespace Yi.Framework.AiHub.Domain.Shared.Enums; public class PriceAttribute : Attribute { public decimal Price { get; } - + public decimal ReferencePrice { get; } - + public int ValidMonths { get; } - + public PriceAttribute(double price, int validMonths, double referencePrice) { Price = (decimal)price; @@ -93,39 +93,32 @@ public class TokenAmountAttribute : Attribute public enum GoodsTypeEnum { // VIP服务 - [Price(29.9, 1,29.9)] - [DisplayName("YiXinVip 1 month", "1个月", "灵活选择")] - [GoodsCategory(GoodsCategoryType.Vip)] + [Price(29.9, 1, 29.9)] [DisplayName("YiXinVip 1 month", "1个月", "灵活选择")] [GoodsCategory(GoodsCategoryType.Vip)] YiXinVip1 = 1, - [Price(83.7, 3,27.9)] - [DisplayName("YiXinVip 3 month", "3个月", "短期体验")] - [GoodsCategory(GoodsCategoryType.Vip)] + [Price(83.7, 3, 27.9)] [DisplayName("YiXinVip 3 month", "3个月", "短期体验")] [GoodsCategory(GoodsCategoryType.Vip)] YiXinVip3 = 3, - [Price(155.4, 6,25.9)] - [DisplayName("YiXinVip 6 month", "6个月", "年度热销")] - [GoodsCategory(GoodsCategoryType.Vip)] + [Price(155.4, 6, 25.9)] [DisplayName("YiXinVip 6 month", "6个月", "年度热销")] [GoodsCategory(GoodsCategoryType.Vip)] YiXinVip6 = 6, - [Price(183.2, 8,22.9)] + [Price(183.2, 8, 22.9)] [DisplayName("YiXinVip 8 month", "8个月(推荐)", "限时活动,超高性价比")] [GoodsCategory(GoodsCategoryType.Vip)] YiXinVip8 = 8, // 尊享包服务 - 需要VIP资格才能购买 - [Price(188.9, 0,1750)] + [Price(188.9, 0, 1750)] [DisplayName("YiXinPremiumPackage 5000W Tokens", "5000万Tokens", "简单尝试")] [GoodsCategory(GoodsCategoryType.PremiumPackage)] [TokenAmount(5000)] PremiumPackage5000W = 101, - [Price(248.9, 0,3500)] + [Price(248.9, 0, 3500)] [DisplayName("YiXinPremiumPackage 10000W Tokens", "1亿Tokens(推荐)", "极致性价比")] [GoodsCategory(GoodsCategoryType.PremiumPackage)] [TokenAmount(10000)] PremiumPackage10000W = 102, - } public static class GoodsTypeEnumExtensions @@ -304,6 +297,6 @@ public static class GoodsTypeEnumExtensions var discountedPrice = originalPrice - discount; // 确保价格不为负数,至少为0.01元 - return Math.Max(discountedPrice, 0.01m); + return Math.Round(discountedPrice, 2); } -} +} \ No newline at end of file From 2dae47e85cc60fa7bc17695e438ec8bb2f3c42f6 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 15 Oct 2025 23:18:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs index b06dba6f..98060f58 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/GoodsTypeEnum.cs @@ -111,13 +111,13 @@ public enum GoodsTypeEnum [Price(188.9, 0, 1750)] [DisplayName("YiXinPremiumPackage 5000W Tokens", "5000万Tokens", "简单尝试")] [GoodsCategory(GoodsCategoryType.PremiumPackage)] - [TokenAmount(5000)] + [TokenAmount(50000000)] PremiumPackage5000W = 101, [Price(248.9, 0, 3500)] [DisplayName("YiXinPremiumPackage 10000W Tokens", "1亿Tokens(推荐)", "极致性价比")] [GoodsCategory(GoodsCategoryType.PremiumPackage)] - [TokenAmount(10000)] + [TokenAmount(100000000)] PremiumPackage10000W = 102, } From c5c22224cf9c958eb69c786b5a3cad62053c2fdc Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Wed, 15 Oct 2025 23:43:59 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=202.0=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Ai.Vue3/index.html | 2 +- Yi.Ai.Vue3/src/api/pay/index.ts | 1 + Yi.Ai.Vue3/src/components/ProductPackage/index.vue | 5 ++++- .../userPersonalCenter/components/RechargeLog.vue | 3 --- .../src/layouts/components/Header/components/Avatar.vue | 2 ++ Yi.Ai.Vue3/src/pages/payResult/index.vue | 7 ++++--- Yi.Ai.Vue3/types/components.d.ts | 2 -- Yi.Ai.Vue3/types/import_meta.d.ts | 1 + 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Yi.Ai.Vue3/index.html b/Yi.Ai.Vue3/index.html index eb48f78d..5c1b414b 100644 --- a/Yi.Ai.Vue3/index.html +++ b/Yi.Ai.Vue3/index.html @@ -112,7 +112,7 @@
-
意心Ai
+
意心Ai 2.0
海外地址,仅首次访问预计加载约10秒