提交代码
This commit is contained in:
parent
630f4fb37e
commit
b36a8ba030
|
|
@ -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 .
|
||||
```
|
||||
|
||||
### 项目说明
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证多租户
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证多租户
|
||||
|
|
|
|||
|
|
@ -35,11 +35,24 @@ namespace HuanMeng.MiaoYu.Code.Payment
|
|||
{
|
||||
|
||||
AddAlipay(builder.Configuration);
|
||||
weChatConfig = builder.Configuration.GetSection("Payment:WeChatConfig").Get<WeChatConfig>();
|
||||
AddWeChat(builder.Configuration);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载微信支付
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public static void AddWeChat(IConfiguration configuration)
|
||||
{
|
||||
var _weChatConfig = configuration.GetSection("Payment:WeChatConfig").Get<WeChatConfig>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static Config AlipayConfig { get; set; }
|
||||
/// <summary>
|
||||
/// 支付
|
||||
|
|
@ -63,31 +77,28 @@ namespace HuanMeng.MiaoYu.Code.Payment
|
|||
/// <param name="configuration"></param>
|
||||
public static void AddAlipay(IConfiguration configuration)
|
||||
{
|
||||
var x = configuration.GetSection("Payment:AlipayConfig").Get<Config>();
|
||||
var _config = configuration.GetSection("Payment:AlipayConfig").Get<Config>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
@ -11,5 +11,13 @@
|
|||
"nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
|
||||
"env": "DEV",
|
||||
"name": "PayClient"
|
||||
},
|
||||
//服务器配置
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://*:90"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,5 +56,13 @@
|
|||
"nodes": "http://10.0.12.5:94", //多个节点使用逗号分隔
|
||||
"env": "PROD",
|
||||
"name": "PayClient"
|
||||
},
|
||||
//服务器配置
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://*:80"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user