diff --git a/src/CloudGaming/Api/CloudGaming.Api/CloudGaming.Api.csproj b/src/CloudGaming/Api/CloudGaming.Api/CloudGaming.Api.csproj index 1f6d4e5..6552e11 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/CloudGaming.Api.csproj +++ b/src/CloudGaming/Api/CloudGaming.Api/CloudGaming.Api.csproj @@ -20,6 +20,7 @@ + diff --git a/src/CloudGaming/Api/CloudGaming.PayApi/CloudGaming.PayApi.csproj b/src/CloudGaming/Api/CloudGaming.PayApi/CloudGaming.PayApi.csproj index 1632ffa..c540a3d 100644 --- a/src/CloudGaming/Api/CloudGaming.PayApi/CloudGaming.PayApi.csproj +++ b/src/CloudGaming/Api/CloudGaming.PayApi/CloudGaming.PayApi.csproj @@ -10,6 +10,7 @@ + diff --git a/src/CloudGaming/CloudGaming.sln b/src/CloudGaming/CloudGaming.sln index 556ab14..8bd7ca8 100644 --- a/src/CloudGaming/CloudGaming.sln +++ b/src/CloudGaming/CloudGaming.sln @@ -38,6 +38,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.Test", "Console EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.PayApi", "Api\CloudGaming.PayApi\CloudGaming.PayApi.csproj", "{452D87B5-A7E0-4EBD-9CF2-1AFF5941065B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.AppConfigModel", "Model\CloudGaming.AppConfigModel\CloudGaming.AppConfigModel.csproj", "{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -80,6 +82,10 @@ Global {452D87B5-A7E0-4EBD-9CF2-1AFF5941065B}.Debug|Any CPU.Build.0 = Debug|Any CPU {452D87B5-A7E0-4EBD-9CF2-1AFF5941065B}.Release|Any CPU.ActiveCfg = Release|Any CPU {452D87B5-A7E0-4EBD-9CF2-1AFF5941065B}.Release|Any CPU.Build.0 = Release|Any CPU + {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -94,6 +100,7 @@ Global {96CD0865-0AD5-41B3-89A2-374FF17CDD16} = {A3F00FB0-49D6-48B1-99D9-4619634DF8D9} {830841B9-E013-4FD5-8D31-D85545870C1C} = {9F7EF36C-17BB-4F93-927E-F462FE3C9337} {452D87B5-A7E0-4EBD-9CF2-1AFF5941065B} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6} + {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE} = {A3F00FB0-49D6-48B1-99D9-4619634DF8D9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D299D92-FA27-47A0-8D78-43D1FAFE7628} diff --git a/src/CloudGaming/Code/CloudGaming.Code/AppExtend/ConfigModel/WeChatConfig.cs b/src/CloudGaming/Code/CloudGaming.Code/AppExtend/ConfigModel/WeChatConfig.cs index ed53567..6994888 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/AppExtend/ConfigModel/WeChatConfig.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/AppExtend/ConfigModel/WeChatConfig.cs @@ -33,12 +33,12 @@ public class WeChatConfig public string NotifyUrl { get; set; } /// - /// + /// 微信支付序列号 /// public string MerchantCertificateSerialNumber { get; set; } /// - /// + /// 微信支付私钥 /// public string MerchantCertificatePrivateKey { get; set; } } diff --git a/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj b/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj index e676297..73e7bee 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj +++ b/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/AliyunConfig.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/AliyunConfig.cs new file mode 100644 index 0000000..30fd0f1 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/AliyunConfig.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.AppConfigModel +{ + + /// + /// 阿里云配置 + /// + public class AliyunConfig + { + /// + /// + /// + public string AccessKeyId { get; set; } + /// + /// 配置环境变量 + /// + public string AccessKeySecret { get; set; } + + #region 阿里云OSS配置 + /// + /// 替换为Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 + /// + public string EndPoint { get; set; } + /// + /// Bucket名称。 + /// + public string BucketName { get; set; } + + /// + /// 上传路径 + /// + public string UploadPath { get; set; } + + /// + /// 域名 + /// + public string? DomainName { get; set; } + + /// + /// 前缀 + /// + public string ImagePrefix + { + get + { + return this.DomainName; //+ this.UploadPath + } + } + + #endregion + + /// + /// 短信签名名称 + /// + public string SmsSignName { get; set; } + + /// + /// string 短信模板配置 + /// + public string SmsTemplateCode { get; set; } + + } +} diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/AppConfig.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/AppConfig.cs new file mode 100644 index 0000000..d2777ef --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/AppConfig.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CloudGaming.AppConfigModel +{ + + /// + /// 项目配置 + /// + public class AppConfig + { + public AppConfig() { } + /// + /// 用户数据库连接字符串 + /// + public string UserConnectionString { get; set; } + /// + /// 游戏 + /// + public string GameConnectionString { get; set; } + /// + /// 扩展 + /// + public string ExtConnectionString { get; set; } + + /// + /// 手机app配置 + /// + public string PhoneConnectionString { get; set; } + + /// + /// redis连接字符串 + /// + public string RedisConnectionString { get; set; } + + /// + /// 域名 + /// + public string DomainName { get; set; } + /// + /// 标识 + /// + public string Identifier { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 默认语言 + /// + public string DefaultLanguage { get; set; } + /// + /// 租户 + /// + public Guid TenantId { get; set; } + /// + /// 项目支付数据 + /// + public PaymentModel? Payment { get; set; } + + /// + /// oss阿里云配置 + /// + public AliyunConfig AliyunConfig { get; set; } + + /// + /// 用户默认配置 + /// + public UserConfig UserConfig { get; set; } + + /// + /// 游戏配置 + /// + public GameConfig GameConfig { get; set; } + + /// + /// 获取数据库连接字符串 + /// + /// user,game,ext,phone + /// + /// + public string GetConnectionString(AppDataBaseType appDataBaseType) + { + switch (appDataBaseType) + { + case AppDataBaseType.User: + return UserConnectionString; + case AppDataBaseType.Game: + return GameConnectionString; + case AppDataBaseType.Ext: + return ExtConnectionString; + case AppDataBaseType.App: + return PhoneConnectionString; + default: + throw new NotImplementedException("数据库连接字符串不存在"); + } + } + } + + /// + /// 数据库选项 + /// + + public enum AppDataBaseType + { + /// + /// 用户数据库 + /// + User, + /// + /// 游戏数据库 + /// + Game, + /// + /// 扩展数据库 + /// + Ext, + /// + /// app数据库 + /// + App + } + +} diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/CloudGaming.AppConfigModel.csproj b/src/CloudGaming/Model/CloudGaming.AppConfigModel/CloudGaming.AppConfigModel.csproj new file mode 100644 index 0000000..9927730 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/CloudGaming.AppConfigModel.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.1 + enable + + + + + + + + + diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/GameConfig.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/GameConfig.cs new file mode 100644 index 0000000..b4d3835 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/GameConfig.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.AppConfigModel +{ + /// + /// + /// + public class GameConfig + { + /// + /// 客户渠道Id,如:edb684859b848362ec56904286947614 + /// + public string ChannelId { get; set; } + + /// + /// 客户渠道key,加密使用 + /// + public string SignKey { get; set; } + + /// + /// 客户渠道地址 + /// + public string BsUrl { get; set; } + } +} diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/PaymentModel.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/PaymentModel.cs new file mode 100644 index 0000000..fa4097b --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/PaymentModel.cs @@ -0,0 +1,78 @@ +using Newtonsoft.Json; + +using SKIT.FlurlHttpClient.Wechat.TenpayV3; +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings; +namespace CloudGaming.AppConfigModel +{ + + /// + /// + /// + public class PaymentModel + { + /// + /// 微信支付数据 + /// + public WeChatConfig? WeChatConfig { get; set; } + + /// + /// 支付宝支付数据 + /// + public Alipay.EasySDK.Kernel.Config? AlipayConfig { get; set; } + + /// + /// + /// + private WechatTenpayClient _wxClient; + /// + /// 微信支付客户端 + /// + [JsonIgnore] + public WechatTenpayClient? WxClient + { + get + { + if (_wxClient == null) + { + if (WeChatConfig == null) + { + return null; + } + var manager = new InMemoryCertificateManager(); + /* 仅列出必须配置项。也包含一些诸如超时时间、UserAgent 等的配置项 */ + var wechatTenpayClientOptions = new WechatTenpayClientOptions() + { + + MerchantId = WeChatConfig.MchId, + MerchantV3Secret = WeChatConfig.Key, + MerchantCertificateSerialNumber = WeChatConfig.MerchantCertificateSerialNumber, + MerchantCertificatePrivateKey = WeChatConfig.MerchantCertificatePrivateKey, + PlatformCertificateManager = manager + }; + _wxClient = new WechatTenpayClient(wechatTenpayClientOptions); + } + return _wxClient; + } + } + + private Alipay.EasySDK.Kernel.Context _aliPayContext; + /// + /// 支付宝支付 + /// + [JsonIgnore] + public Alipay.EasySDK.Kernel.Context AliPayContext + { + get + { + if (_aliPayContext == null) + { + if (AlipayConfig != null) + { + _aliPayContext = new Alipay.EasySDK.Kernel.Context(AlipayConfig, "alipay-easysdk-net-2.1.0"); + } + } + return _aliPayContext; + } + } + } +} diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/UserConfig.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/UserConfig.cs new file mode 100644 index 0000000..4c21965 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/UserConfig.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.AppConfigModel +{ + + /// + /// 用户默认配置 + /// + public class UserConfig + { + /// + /// 用户默认头像 + /// + public string UserIconUrl { get; set; } + /// + /// 用户默认昵称 + /// + public string NickName { get; set; } + + /// + /// 用户最大登录设备 + /// + public int MaxDeviceCount { get; set; } + } +} diff --git a/src/CloudGaming/Model/CloudGaming.AppConfigModel/WeChatConfig.cs b/src/CloudGaming/Model/CloudGaming.AppConfigModel/WeChatConfig.cs new file mode 100644 index 0000000..916cdd0 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.AppConfigModel/WeChatConfig.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.AppConfigModel +{ + /// + /// + /// + public class WeChatConfig + { + /// + /// appId + /// + public string AppId { get; set; } + /// + /// appkey + /// + public string AppSecret { get; set; } + /// + /// + /// + public string Key { get; set; } + /// + /// 商户id + /// + public string MchId { get; set; } + /// + /// 回调地址 + /// + public string NotifyUrl { get; set; } + + /// + /// 微信支付序列号 + /// + public string MerchantCertificateSerialNumber { get; set; } + + /// + /// 微信支付私钥 + /// + public string MerchantCertificatePrivateKey { get; set; } + } +} + + +