优化支付、短信的配置内容
This commit is contained in:
@@ -14,23 +14,23 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class ApiProperties {
|
||||
|
||||
|
||||
/**
|
||||
* 买家api
|
||||
*/
|
||||
private String buyer;
|
||||
// /**
|
||||
// * 买家api
|
||||
// */
|
||||
// private String buyer;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String store;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String manager;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String common;
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String store;
|
||||
//
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String manager;
|
||||
//
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String common;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import cn.lili.modules.connect.request.BaseAuthWeChatPCRequest;
|
||||
import cn.lili.modules.connect.request.BaseAuthWeChatRequest;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.connect.ConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.QQConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.QQConnectSettingItem;
|
||||
@@ -70,8 +71,8 @@ public class ConnectUtil {
|
||||
* @param connectAuthEnum 用户枚举
|
||||
* @return 回调地址
|
||||
*/
|
||||
String getRedirectUri(ConnectAuthEnum connectAuthEnum) {
|
||||
return apiProperties.getBuyer() + prefix + connectAuthEnum.getName();
|
||||
String getRedirectUri(ConnectAuthEnum connectAuthEnum,String callbackUrl) {
|
||||
return callbackUrl + prefix + connectAuthEnum.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,10 +107,13 @@ public class ConnectUtil {
|
||||
//缓存写入登录结果,300秒有效
|
||||
cache.put(CachePrefix.CONNECT_RESULT.getPrefix() + callback.getCode(), resultMessage, 300L);
|
||||
|
||||
Setting setting = settingService.get(SettingEnum.CONNECT_SUPPORT.name());
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(setting.getSettingValue(), ConnectSetting.class);
|
||||
|
||||
//跳转地址
|
||||
String url = this.check(httpServletRequest.getHeader("user-agent")) ?
|
||||
domainProperties.getWap() + "/pages/passport/login?state=" + callback.getCode() :
|
||||
domainProperties.getPc() + "/login?state=" + callback.getCode();
|
||||
connectSetting.getWap() + "/pages/passport/login?state=" + callback.getCode() :
|
||||
connectSetting.getPc() + "/login?state=" + callback.getCode();
|
||||
|
||||
try {
|
||||
httpServletResponse.sendRedirect(url);
|
||||
@@ -151,13 +155,15 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.H5.name())) {
|
||||
authRequest = new BaseAuthWeChatRequest(AuthConfig.builder()
|
||||
.clientId(wechatConnectSettingItem.getAppId())
|
||||
.clientSecret(wechatConnectSettingItem.getAppSecret())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
.build(), cache);
|
||||
}
|
||||
}
|
||||
@@ -167,13 +173,14 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthWeChatPCRequest(AuthConfig.builder()
|
||||
.clientId(wechatConnectSettingItem.getAppId())
|
||||
.clientSecret(wechatConnectSettingItem.getAppSecret())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
.build(), cache);
|
||||
}
|
||||
}
|
||||
@@ -184,13 +191,14 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.QQ_CONNECT.name());
|
||||
QQConnectSetting qqConnectSetting = JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class);
|
||||
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
for (QQConnectSettingItem qqConnectSettingItem : qqConnectSetting.getQqConnectSettingItemList()) {
|
||||
if (qqConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthQQRequest(AuthConfig.builder()
|
||||
.clientId(qqConnectSettingItem.getAppId())
|
||||
.clientSecret(qqConnectSettingItem.getAppKey())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
//这里qq获取unionid 需要配置为true,详情可以查阅属性说明,内部有帮助文档
|
||||
.unionId(true)
|
||||
.build(), cache);
|
||||
|
||||
@@ -72,11 +72,6 @@ public class AliPayPlugin implements Payment {
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
/**
|
||||
* API域名
|
||||
*/
|
||||
@Autowired
|
||||
private ApiProperties apiProperties;
|
||||
/**
|
||||
* 域名配置
|
||||
*/
|
||||
@@ -87,6 +82,7 @@ public class AliPayPlugin implements Payment {
|
||||
public ResultMessage<Object> h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) {
|
||||
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
AlipayPaymentSetting alipayPaymentSetting = alipayPaymentSetting();
|
||||
//请求订单编号
|
||||
String outTradeNo = SnowFlake.getIdStr();
|
||||
//准备支付参数
|
||||
@@ -102,8 +98,8 @@ public class AliPayPlugin implements Payment {
|
||||
payModel.setProductCode("QUICK_WAP_PAY");
|
||||
try {
|
||||
log.info("支付宝H5支付:{}", JSONUtil.toJsonStr(payModel));
|
||||
AliPayRequest.wapPay(response, payModel, callbackUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY),
|
||||
notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY));
|
||||
AliPayRequest.wapPay(response, payModel, callbackUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY),
|
||||
notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY));
|
||||
} catch (Exception e) {
|
||||
log.error("H5支付异常", e);
|
||||
throw new ServiceException(ResultCode.ALIPAY_EXCEPTION);
|
||||
@@ -122,6 +118,7 @@ public class AliPayPlugin implements Payment {
|
||||
try {
|
||||
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
AlipayPaymentSetting alipayPaymentSetting = alipayPaymentSetting();
|
||||
//请求订单编号
|
||||
String outTradeNo = SnowFlake.getIdStr();
|
||||
|
||||
@@ -139,7 +136,7 @@ public class AliPayPlugin implements Payment {
|
||||
payModel.setProductCode("QUICK_MSECURITY_PAY");
|
||||
|
||||
log.info("支付宝APP支付:{}", payModel);
|
||||
String orderInfo = AliPayRequest.appPayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody();
|
||||
String orderInfo = AliPayRequest.appPayToResponse(payModel, notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY)).getBody();
|
||||
log.info("支付宝APP支付返回内容:{}", orderInfo);
|
||||
return ResultUtil.data(orderInfo);
|
||||
} catch (AlipayApiException e) {
|
||||
@@ -156,6 +153,7 @@ public class AliPayPlugin implements Payment {
|
||||
|
||||
try {
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
AlipayPaymentSetting alipayPaymentSetting = alipayPaymentSetting();
|
||||
|
||||
AlipayTradePrecreateModel payModel = new AlipayTradePrecreateModel();
|
||||
|
||||
@@ -172,7 +170,7 @@ public class AliPayPlugin implements Payment {
|
||||
payModel.setOutTradeNo(outTradeNo);
|
||||
log.info("支付宝扫码:{}", payModel);
|
||||
String resultStr =
|
||||
AliPayRequest.tradePrecreatePayToResponse(payModel, notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.ALIPAY)).getBody();
|
||||
AliPayRequest.tradePrecreatePayToResponse(payModel, notifyUrl(alipayPaymentSetting.getCallbackUrl(), PaymentMethodEnum.ALIPAY)).getBody();
|
||||
|
||||
log.info("支付宝扫码交互返回:{}", resultStr);
|
||||
JSONObject jsonObject = JSONObject.parseObject(resultStr);
|
||||
@@ -338,7 +336,7 @@ public class AliPayPlugin implements Payment {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信支付配置
|
||||
* 获取支付宝配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -93,11 +93,6 @@ public class WechatPlugin implements Payment {
|
||||
*/
|
||||
@Autowired
|
||||
private RefundLogService refundLogService;
|
||||
/**
|
||||
* API域名
|
||||
*/
|
||||
@Autowired
|
||||
private ApiProperties apiProperties;
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
@@ -151,7 +146,7 @@ public class WechatPlugin implements Payment {
|
||||
.setOut_trade_no(outOrderNo)
|
||||
.setTime_expire(timeExpire)
|
||||
.setAttach(attach)
|
||||
.setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
||||
.setNotify_url(notifyUrl(wechatPaymentSetting().getCallbackUrl(),PaymentMethodEnum.WECHAT))
|
||||
.setAmount(new Amount().setTotal(fen)).setScene_info(sceneInfo);
|
||||
|
||||
log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
||||
@@ -210,7 +205,7 @@ public class WechatPlugin implements Payment {
|
||||
.setOut_trade_no(outOrderNo)
|
||||
.setTime_expire(timeExpire)
|
||||
.setAttach(attach)
|
||||
.setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
||||
.setNotify_url(notifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT))
|
||||
.setAmount(new Amount().setTotal(fen))
|
||||
.setPayer(payer);
|
||||
|
||||
@@ -275,7 +270,7 @@ public class WechatPlugin implements Payment {
|
||||
.setOut_trade_no(outOrderNo)
|
||||
.setTime_expire(timeExpire)
|
||||
.setAttach(attach)
|
||||
.setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
||||
.setNotify_url(notifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT))
|
||||
.setAmount(new Amount().setTotal(fen));
|
||||
|
||||
|
||||
@@ -344,7 +339,7 @@ public class WechatPlugin implements Payment {
|
||||
.setTime_expire(timeExpire)
|
||||
//回传参数
|
||||
.setAttach(attach)
|
||||
.setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
||||
.setNotify_url(notifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT))
|
||||
.setAmount(new Amount().setTotal(fen));
|
||||
|
||||
log.info("统一下单参数 {}", JSONUtil.toJsonStr(unifiedOrderModel));
|
||||
@@ -417,7 +412,7 @@ public class WechatPlugin implements Payment {
|
||||
.setOut_trade_no(outOrderNo)
|
||||
.setTime_expire(timeExpire)
|
||||
.setAttach(attach)
|
||||
.setNotify_url(notifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT))
|
||||
.setNotify_url(notifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT))
|
||||
.setAmount(new Amount().setTotal(fen))
|
||||
.setPayer(payer);
|
||||
|
||||
@@ -618,7 +613,7 @@ public class WechatPlugin implements Payment {
|
||||
.setOut_refund_no(refundLog.getOutOrderNo())
|
||||
.setReason(refundLog.getRefundReason())
|
||||
.setAmount(amount)
|
||||
.setNotify_url(refundNotifyUrl(apiProperties.getBuyer(), PaymentMethodEnum.WECHAT));
|
||||
.setNotify_url(refundNotifyUrl(wechatPaymentSetting().getCallbackUrl(), PaymentMethodEnum.WECHAT));
|
||||
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class SmsUtilAliImplService implements SmsUtil {
|
||||
return;
|
||||
}
|
||||
//如果是测试模式 默认验证码 6个1
|
||||
if (systemSettingProperties.getIsTestModel()) {
|
||||
if (smsSetting.getIsTestModel()) {
|
||||
code = "111111";
|
||||
log.info("测试模式 - 接收手机:{},验证码:{}", mobile, code);
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,30 @@ public class SmsSetting implements Serializable {
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 是否测试模式
|
||||
*/
|
||||
private Boolean isTestModel;
|
||||
/**
|
||||
* 登录短信模板CODE
|
||||
*/
|
||||
private String loginTemplateCode;
|
||||
/**
|
||||
* 注册短信模板CODE
|
||||
*/
|
||||
private String registerTemplateCode;
|
||||
/**
|
||||
* 找回密码短信模板CODE
|
||||
*/
|
||||
private String findPasswordTemplateCode;
|
||||
/**
|
||||
* 设置密码短信模板CODE
|
||||
*/
|
||||
private String walletPasswordTemplateCode;
|
||||
/**
|
||||
* 支付密码短信模板CODE
|
||||
*/
|
||||
private String payPasswordTemplateCode;
|
||||
|
||||
/**
|
||||
* key
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.lili.modules.system.entity.dto.connect;
|
||||
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 登录设置
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 8:00 下午
|
||||
*/
|
||||
@Data
|
||||
public class ConnectSetting {
|
||||
|
||||
|
||||
/**
|
||||
* 买家PC端域名
|
||||
*/
|
||||
private String pc;
|
||||
|
||||
/**
|
||||
* 买家WAP端域名
|
||||
*/
|
||||
private String wap;
|
||||
|
||||
/**
|
||||
* 回调域名
|
||||
*/
|
||||
private String callbackUrl;
|
||||
}
|
||||
@@ -38,4 +38,9 @@ public class AlipayPaymentSetting {
|
||||
*/
|
||||
private String rootCertPath;
|
||||
|
||||
/**
|
||||
* 回调API地址
|
||||
*/
|
||||
private String callbackUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,8 @@ public class WechatPaymentSetting {
|
||||
* apiv3私钥
|
||||
*/
|
||||
private String apiKey3;
|
||||
/**
|
||||
* 回调API地址
|
||||
*/
|
||||
private String callbackUrl;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,14 @@ public enum SettingEnum {
|
||||
//IM 配置
|
||||
IM_SETTING,
|
||||
|
||||
//登录设置
|
||||
CONNECT_SUPPORT,
|
||||
//微信 联合登陆设置
|
||||
WECHAT_CONNECT,
|
||||
//QQ 浏览器 联合登录设置
|
||||
QQ_CONNECT,
|
||||
//登录设置
|
||||
CONNECT_SETTING,
|
||||
|
||||
//各端支持支付设置
|
||||
PAYMENT_SUPPORT,
|
||||
|
||||
Reference in New Issue
Block a user