From 8b2d9bc383267457a4e99c1bfb047c9ba9d76d29 Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Tue, 21 Jan 2025 00:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E5=8D=A1=E6=8B=89=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 1 + mall-pay/pom.xml | 5 + .../pay/service/impl/LakalaServiceImpl.java | 95 +++++++++++-------- .../service/impl/PayUserPayServiceImpl.java | 7 +- mall-pay/src/main/resources/bootstrap-dev.yml | 21 ++-- .../src/main/resources/bootstrap-local.yml | 25 +++-- .../src/main/resources/bootstrap-prod.yml | 25 +++-- .../src/main/resources/bootstrap-test.yml | 21 ++-- mall-pay/src/main/resources/bootstrap-uat.yml | 21 ++-- .../payKey/lakala/prod/OP00000003_cert.cer | 21 ---- .../lakala/prod/OP00000003_private_key.pem | 28 ------ .../resources/payKey/lakala/prod/api_cert.cer | 22 +++++ .../payKey/lakala/prod/api_private_key.pem | 28 ++++++ .../payKey/lakala/prod/lkl_notify_cert_v2.cer | 25 ----- .../payKey/lakala/prod/lkl_platform.cer | 25 +++++ 15 files changed, 213 insertions(+), 157 deletions(-) delete mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/OP00000003_cert.cer delete mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/OP00000003_private_key.pem create mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/api_cert.cer create mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/api_private_key.pem delete mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/lkl_notify_cert_v2.cer create mode 100644 mall-pay/src/main/resources/payKey/lakala/prod/lkl_platform.cer diff --git a/mall-gateway/src/main/resources/application.yml b/mall-gateway/src/main/resources/application.yml index fb7cf8f5..321a87a4 100644 --- a/mall-gateway/src/main/resources/application.yml +++ b/mall-gateway/src/main/resources/application.yml @@ -89,6 +89,7 @@ secure: - "/admin/account/open/**" - "/esProduct/**" - "/admin/oss/upload/**" + - "/mobile/**/**/test/case" universal: urls: - "/admin/account/account-user-base/info" diff --git a/mall-pay/pom.xml b/mall-pay/pom.xml index cd7f53e2..9923af8f 100644 --- a/mall-pay/pom.xml +++ b/mall-pay/pom.xml @@ -137,7 +137,9 @@ true **/*.crt + **/*.pem **/*.p12 + **/*.cer **/*.properties application.yml bootstrap.yml @@ -151,6 +153,9 @@ org.springframework.boot spring-boot-maven-plugin + + true + com.spotify diff --git a/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/LakalaServiceImpl.java b/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/LakalaServiceImpl.java index a15d199f..ac372963 100644 --- a/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/LakalaServiceImpl.java +++ b/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/LakalaServiceImpl.java @@ -11,7 +11,7 @@ package com.suisung.mall.pay.service.impl; import cn.hutool.json.JSONUtil; import com.ijpay.core.kit.IpKit; -import com.lkl.laop.sdk.Config; +import com.lkl.laop.sdk.Config2; import com.lkl.laop.sdk.LKLSDK; import com.lkl.laop.sdk.exception.SDKException; import com.lkl.laop.sdk.request.V3LabsTransPreorderRequest; @@ -20,50 +20,51 @@ import com.lkl.laop.sdk.request.model.V3LabsTradePreorderWechatBus; import com.suisung.mall.pay.service.LakalaService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; @Slf4j @Service public class LakalaServiceImpl implements LakalaService { private static volatile boolean init = false; - @Value("${lakala.term_no}") - private String termNo; - @Value("${lakala.app_id}") - private String appId; // 拉卡拉appId - @Value("${lakala.serial_no}") - private String serialNo; // 你的证书序列号 - @Value("${lakala.merchant_no}") - private String merchantNo; - /** - * 商户私钥信息地址 - */ - @Value("${lakala.pri_key_path}") - private String priKeyPath; - /** - * 拉卡拉支付平台证书地址 - */ -// @Value("${lakala.lkl_cer_path}") - @Value("${lakala.lkl_notify_cer_path}") - private String lklCerPath; - /** - * 拉卡拉支付平台证书地址2(用于拉卡拉通知验签) - */ - @Value("${lakala.lkl_notify_cer_path}") - private String lklNotifyCerPath; - /** - * 拉卡拉报文加密对称性密钥 - */ - @Value("${lakala.sm4_key}") - private String sm4Key; + /** * 服务地址 */ @Value("${lakala.server_url}") private String serverUrl; + @Value("${lakala.app_id}") + private String appId; // 拉卡拉appId + @Value("${lakala.merchant_no}") + private String merchantNo; + @Value("${lakala.serial_no}") + private String serialNo; // 你的证书序列号 + @Value("${lakala.term_no}") + private String termNo; + /** + * 商户私钥信息地址 + */ + @Value("${lakala.api_pri_key_path}") + private String priKeyPath; + /** + * 拉卡拉支付平台证书地址 + */ + @Value("${lakala.lkl_platform_cer_path}") + private String lklCerPath; + /** + * 拉卡拉支付平台证书地址2(用于拉卡拉通知验签) + */ + @Value("${lakala.lkl_platform_cer_path}") + private String lklNotifyCerPath; + /*** * @Description: 初始化设置商户公共参数(全局只需设置一次) @@ -75,26 +76,38 @@ public class LakalaServiceImpl implements LakalaService { } } + private String getResourceFile(String fileName) { + StringBuilder stringBuilder = new StringBuilder(); + try (InputStream inputStream = new ClassPathResource(fileName).getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { + String line; + while ((line = bufferedReader.readLine()) != null) { + stringBuilder.append(line).append("\n"); + } + } catch (IOException e) { + // 记录异常信息 + log.error(e.getMessage()); + } + String content = stringBuilder.toString(); + log.info("证书内容:{}", content); + return content; + } + /** * 初始化 拉卡拉 SDK * * @return */ public boolean initLKLSDK() { - Config config = new Config(); + Config2 config = new Config2(); config.setAppId(appId); config.setSerialNo(serialNo); - config.setPriKeyPath(priKeyPath); - config.setLklCerPath(lklCerPath); - config.setLklNotifyCerPath(lklNotifyCerPath); + config.setPriKey(getResourceFile(priKeyPath)); + config.setLklCer(getResourceFile(lklCerPath)); + config.setLklNotifyCer(getResourceFile(lklNotifyCerPath)); config.setServerUrl(serverUrl); - config.setSm4Key(sm4Key); - try { - return LKLSDK.init(config); - } catch (SDKException e) { - log.error("doInit error", e); - throw new RuntimeException(e); - } + return LKLSDK.init(config); } @Override diff --git a/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/PayUserPayServiceImpl.java b/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/PayUserPayServiceImpl.java index 252f1838..dced6c35 100644 --- a/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/PayUserPayServiceImpl.java +++ b/mall-pay/src/main/java/com/suisung/mall/pay/service/impl/PayUserPayServiceImpl.java @@ -195,7 +195,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl 0 && !StrUtil.equals(payment_channel_code, "offline")) { - + // 金额大于0且不是线下交易的情况 BigDecimal trade_payment_recharge_card = (BigDecimal) requestParams.get("trade_payment_recharge_card"); BigDecimal trade_payment_points = (BigDecimal) requestParams.get("trade_payment_points"); BigDecimal trade_payment_sp = (BigDecimal) requestParams.get("trade_payment_sp"); @@ -253,7 +253,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl