diff --git a/README.md b/README.md
index 5c9ec6c..6f059e8 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,13 @@ docker run -d -p 90:90 -v E://disk/output:/app/output --name webapi miaoyu:dev-0
docker build -t miaoyuapi:dev-1.2.9 -t miaoyuapi:latest -t 123.207.203.228:92/miaoyuapi:dev-1.2.9 -t 123.207.203.228:92/miaoyuapi:latest --build-arg VERSION=1.2.9 --build-arg TARGET=dev -f src/2-api/HuanMeng.MiaoYu.WebApi/Dockerfile .
+
docker push 123.207.203.228:92/miaoyuapi:latest
docker push 123.207.203.228:92/miaoyuapi:dev-1.2.9
+docker push 123.207.203.228:92/hm-payapi:latest
+docker push 123.207.203.228:92/hm-payapi:dev-1.0.0
+docker build -t hm-payapi:dev-1.0.0 -t hm-payapi:latest -t 123.207.203.228:92/hm-payapi:dev-1.0.0 -t 123.207.203.228:92/hm-payapi:latest --build-arg VERSION=1.0.0 --build-arg TARGET=dev -f src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile .
+docker build -t hmpay:dev-1.0.0 --build-arg VERSION=1.0.0 --build-arg TARGET=dev -f src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile .
```
### 项目说明
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs
index f8da067..9f4cfc6 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs
@@ -15,6 +15,8 @@ using System.Threading.Tasks;
using XLib.DotNetCore.CacheHelper;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Protocols;
+using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models;
+using HuanMeng.MiaoYu.Code.Payment;
namespace HuanMeng.MiaoYu.Code.AppExtend
{
@@ -82,7 +84,15 @@ namespace HuanMeng.MiaoYu.Code.AppExtend
}
}
VerifyTenant(args);
+ if (VerifyTenant(args, "Payment:WeChatConfig"))
+ {
+ PaymentExtend.AddWeChat(ConfigurationManager);
+ }
+ if (VerifyTenant(args, "Payment:AlipayConfig"))
+ {
+ PaymentExtend.AddAlipay(ConfigurationManager);
+ }
}
@@ -144,7 +154,24 @@ namespace HuanMeng.MiaoYu.Code.AppExtend
newAppConfig.RedisConnectionString = appConfig.RedisConnectionString;
return newAppConfig;
}
-
+ ///
+ /// 验证多租户
+ ///
+ ///
+ private static bool VerifyTenant(ConfigReloadedArgs args, string key)
+ {
+ var newTenant = args.NewConfigs.Where(it => it.Key.Contains(key)).ToDictionary();
+ var oldTenant = args.OldConfigs.Where(it => it.Key.Contains(key)).ToDictionary();
+ bool areEqual = newTenant.Count == oldTenant.Count &&
+ !newTenant.Except(oldTenant).Any();
+ if (!areEqual)
+ {
+ //更新缓存
+ //AppConfigInit(ConfigurationManager);
+ return true;
+ }
+ return false;
+ }
///
/// 验证多租户
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
index 84c8e07..d2ad74c 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
@@ -35,11 +35,24 @@ namespace HuanMeng.MiaoYu.Code.Payment
{
AddAlipay(builder.Configuration);
- weChatConfig = builder.Configuration.GetSection("Payment:WeChatConfig").Get();
+ AddWeChat(builder.Configuration);
+ return builder;
+ }
+
+ ///
+ /// 加载微信支付
+ ///
+ ///
+ public static void AddWeChat(IConfiguration configuration)
+ {
+ var _weChatConfig = configuration.GetSection("Payment:WeChatConfig").Get();
if (weChatConfig == null)
{
- throw new Exception("微信支付失败");
+ Console.WriteLine("微信支付失败");
+ //throw new Exception("微信支付失败");
+ return;
}
+ weChatConfig = _weChatConfig;
var manager = new InMemoryCertificateManager();
/* 仅列出必须配置项。也包含一些诸如超时时间、UserAgent 等的配置项 */
wechatTenpayClientOptions = new WechatTenpayClientOptions()
@@ -52,10 +65,11 @@ namespace HuanMeng.MiaoYu.Code.Payment
PlatformCertificateManager = manager
};
wxClient = new WechatTenpayClient(wechatTenpayClientOptions);
-
- return builder;
}
+ ///
+ ///
+ ///
public static Config AlipayConfig { get; set; }
///
/// 支付
@@ -63,31 +77,28 @@ namespace HuanMeng.MiaoYu.Code.Payment
///
public static void AddAlipay(IConfiguration configuration)
{
- var x = configuration.GetSection("Payment:AlipayConfig").Get();
+ var _config = configuration.GetSection("Payment:AlipayConfig").Get();
- if (x != null)
- {
- var config = new Config()
- {
- Protocol = "https",
- GatewayHost = "openapi.alipay.com",
- SignType = "RSA2",
- AppId = x.AppId,
- // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
- MerchantPrivateKey = x.MerchantPrivateKey,
- // 如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
- AlipayPublicKey = x.AlipayPublicKey,
- //可设置异步通知接收服务地址(可选)
- NotifyUrl = x.NotifyUrl,
- };
- AlipayConfig = config;
- Factory.SetOptions(config);
-
- }
- else
+ if (_config == null)
{
Console.WriteLine("接入支付失败");
+ return;
}
+ var config = new Config()
+ {
+ Protocol = "https",
+ GatewayHost = "openapi.alipay.com",
+ SignType = "RSA2",
+ AppId = _config.AppId,
+ // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
+ MerchantPrivateKey = _config.MerchantPrivateKey,
+ // 如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
+ AlipayPublicKey = _config.AlipayPublicKey,
+ //可设置异步通知接收服务地址(可选)
+ NotifyUrl = _config.NotifyUrl,
+ };
+ AlipayConfig = config;
+ Factory.SetOptions(config);
}
///
diff --git a/src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile b/src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile
index 745d2ce..7a4e8bd 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile
+++ b/src/2-api/HuanMeng.MiaoYu.WebPayApi/Dockerfile
@@ -2,23 +2,33 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
-WORKDIR /app
-EXPOSE 8080
+WORKDIR /app/disk
+EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+# һòĬΪ Release
+ARG BUILD_CONFIGURATION=Release
+#
+ARG VERSION=1.0.0
+ARG TARGET=dev
+
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
+COPY ["src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.csproj", "2-api/HuanMeng.MiaoYu.WebApi/"]
+COPY ["src/0-core/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj", "0-core/HuanMeng.DotNetCore/"]
+COPY ["src/0-core/HuanMeng.MiaoYu.Code/HuanMeng.MiaoYu.Code.csproj", "0-core/HuanMeng.MiaoYu.Code/"]
+COPY ["src/0-core/HuanMeng.MiaoYu.Model/HuanMeng.MiaoYu.Model.csproj", "0-core/HuanMeng.MiaoYu.Model/"]
COPY ["src/2-api/HuanMeng.MiaoYu.WebPayApi/HuanMeng.MiaoYu.WebPayApi.csproj", "src/2-api/HuanMeng.MiaoYu.WebPayApi/"]
RUN dotnet restore "./src/2-api/HuanMeng.MiaoYu.WebPayApi/HuanMeng.MiaoYu.WebPayApi.csproj"
COPY . .
WORKDIR "/src/src/2-api/HuanMeng.MiaoYu.WebPayApi"
-RUN dotnet build "./HuanMeng.MiaoYu.WebPayApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
+RUN dotnet build "./HuanMeng.MiaoYu.WebPayApi.csproj" -c $BUILD_CONFIGURATION -o /app/disk/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
-RUN dotnet publish "./HuanMeng.MiaoYu.WebPayApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+RUN dotnet publish "./HuanMeng.MiaoYu.WebPayApi.csproj" -c $BUILD_CONFIGURATION -o /app/disk/publish /p:UseAppHost=false /p:VERSION=$VERSION /p:FileVersion=$TARGET /p:Description="ʹdocker"
FROM base AS final
-WORKDIR /app
-COPY --from=publish /app/publish .
+WORKDIR /app/disk
+COPY --from=publish /app/disk/publish .
ENTRYPOINT ["dotnet", "HuanMeng.MiaoYu.WebPayApi.dll"]
\ No newline at end of file
diff --git a/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.Development.json b/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.Development.json
index a2020fc..5caf626 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.Development.json
+++ b/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.Development.json
@@ -11,5 +11,13 @@
"nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
"env": "DEV",
"name": "PayClient"
+ },
+ //服务器配置
+ "Kestrel": {
+ "Endpoints": {
+ "Http": {
+ "Url": "http://*:90"
+ }
+ }
}
}
diff --git a/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.json b/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.json
index e682769..e916e18 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.json
+++ b/src/2-api/HuanMeng.MiaoYu.WebPayApi/appsettings.json
@@ -56,5 +56,13 @@
"nodes": "http://10.0.12.5:94", //多个节点使用逗号分隔
"env": "PROD",
"name": "PayClient"
+ },
+ //服务器配置
+ "Kestrel": {
+ "Endpoints": {
+ "Http": {
+ "Url": "http://*:80"
+ }
+ }
}
}