🎨 #2040 【微信支付】增加多商户切换的支持

This commit is contained in:
cloudX
2021-03-15 11:40:53 +08:00
committed by GitHub
parent eb46a10fd9
commit 488706b2df
3 changed files with 153 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
package com.github.binarywang.wxpay.config;
/**
* 微信支付配置策略.
*
* @author zenghao
* @date 2021/3/12
*/
public class WxPayConfigHolder {
private static final ThreadLocal<String> THREAD_LOCAL = ThreadLocal.withInitial(() -> "default");
/**
* 获取当前微信支付配置策略.
* @return 当前微信支付配置策略
*/
public static String get() {
return THREAD_LOCAL.get();
}
/**
* 设置当前微信支付配置策略.
* @param label 策略名称
*/
public static void set(final String label) {
THREAD_LOCAL.set(label);
}
/**
* 此方法需要用户根据自己程序代码在适当位置手动触发调用本SDK里无法判断调用时机.
*/
public static void remove() {
THREAD_LOCAL.remove();
}
}