From 8e1ade5423b42b8e43a10f18b2d1be18526e24da Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 20 Jan 2022 09:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=8F=82=E6=95=B0=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kit/plugin/wechat/WechatPlugin.java | 10 ------- .../dto/payment/WechatPaymentSetting.java | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java index a6e0972b..e4145c41 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/plugin/wechat/WechatPlugin.java @@ -258,9 +258,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -326,9 +323,6 @@ public class WechatPlugin implements Payment { WechatPaymentSetting setting = wechatPaymentSetting(); String appid = setting.getServiceAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel() .setAppid(appid) .setMchid(setting.getMchId()) @@ -397,10 +391,6 @@ public class WechatPlugin implements Payment { //微信小程序,appid 需要单独获取,这里读取了联合登陆配置的appid ,实际场景小程序自动登录,所以这个appid是最为保险的做法 //如果有2开需求,这里需要调整,修改这个appid的获取途径即可 String appid = wechatPaymentSetting().getMpAppId(); - if (appid == null) { - throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); - } - String attach = URLEncoder.createDefault().encode(JSONUtil.toJsonStr(payParam), StandardCharsets.UTF_8); WechatPaymentSetting setting = wechatPaymentSetting(); diff --git a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java index 9dc4a73d..b3d8e9f9 100644 --- a/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java +++ b/framework/src/main/java/cn/lili/modules/system/entity/dto/payment/WechatPaymentSetting.java @@ -1,5 +1,8 @@ package cn.lili.modules.system.entity.dto.payment; +import cn.lili.common.enums.ResultCode; +import cn.lili.common.exception.ServiceException; +import com.alibaba.druid.util.StringUtils; import lombok.Data; import lombok.experimental.Accessors; @@ -14,7 +17,7 @@ import lombok.experimental.Accessors; public class WechatPaymentSetting { /** - * APP应用id + * APP应用id */ private String appId; /** @@ -49,4 +52,26 @@ public class WechatPaymentSetting { * apiv3私钥 */ private String apiKey3; + + public String getAppId() { + + if (StringUtils.isEmpty(appId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return appId; + } + + public String getMpAppId() { + if (StringUtils.isEmpty(mpAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return mpAppId; + } + + public String getServiceAppId() { + if (StringUtils.isEmpty(serviceAppId)) { + throw new ServiceException(ResultCode.WECHAT_PAYMENT_NOT_SETTING); + } + return serviceAppId; + } }