From a042e0e63f86a0880d20e57c14ec4a60b65801fb Mon Sep 17 00:00:00 2001 From: wanghc <2466022993@qq.com> Date: Tue, 04 Jul 2023 09:07:47 +0800 Subject: [PATCH] 浦发分行受托支付 --- cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java | 60 ++++++++++++++++++++++++------------------------------------ 1 files changed, 24 insertions(+), 36 deletions(-) diff --git a/cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java b/cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java index 18d7037..dad0f6c 100644 --- a/cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java +++ b/cmci-pfcs-gateway/src/main/java/com/jttech/pfcs/services/impl/TradeServiceImpl.java @@ -1,16 +1,13 @@ package com.jttech.pfcs.services.impl; -import com.jttech.pfcs.services.ITradeService; -import com.jttech.pfcs.services.wsdl.ESBServerPortType; -import com.jttech.pfcs.services.wsdl.S080030795; -import com.jttech.pfcs.vo.req.ReqEPCSnglTranType; -import com.jttech.pfcs.vo.req.ReqTranQryType; -import com.jttech.pfcs.vo.resp.RspEPCSnglTranType; -import com.jttech.pfcs.vo.resp.RspTranQryType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Service; + +import com.jttech.pfcs.services.ITradeService; +import com.jttech.pfcs.util.OkHttpUtil; + +import okhttp3.*; /** * @author wanghc @@ -18,42 +15,33 @@ * @date 2023-03-07 */ @Service -public class TradeServiceImpl implements ITradeService, InitializingBean { +public class TradeServiceImpl implements ITradeService { private Logger mLogger = LoggerFactory.getLogger(getClass()); - private ESBServerPortType mESBServerPortType; - - @Override - public void afterPropertiesSet() throws Exception { - mESBServerPortType = new S080030795().getESBServerSoapEndpoint(); - } - /** - * 单笔交易 + * excute * - * @param reqVo + * @param content * @return */ @Override - public RspEPCSnglTranType epcSnglTran(ReqEPCSnglTranType reqVo) { - mLogger.info("TradeServiceImpl.epcSnglTran req={}", reqVo); - RspEPCSnglTranType result = mESBServerPortType.epcSnglTran(reqVo); - mLogger.info("TradeServiceImpl.epcSnglTran resp={}", result); - return result; - } - - /** - * 交易查询 - * - * @param req - * @return - */ - @Override - public RspTranQryType tranQry(ReqTranQryType req) { - mLogger.info("TradeServiceImpl.tranQry req={}", req); - RspTranQryType result = mESBServerPortType.tranQry(req); - mLogger.info("TradeServiceImpl.tranQry resp={}", result); + public String excute(String url, String content) { + mLogger.info("TradeServiceImpl.excute req={}", content); + String result = ""; + try { + OkHttpClient.Builder builder = new OkHttpClient.Builder() + .sslSocketFactory(OkHttpUtil.getIgnoreInitedSslContext().getSocketFactory(), OkHttpUtil.IGNORE_SSL_TRUST_MANAGER_X509) + .hostnameVerifier(OkHttpUtil.getIgnoreSslHostnameVerifier()); + RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), content); + Request request = new Request.Builder().url(url).post(requestBody).build(); + Response response = builder.build().newCall(request).execute(); + result = response.body().string(); + } catch (Exception e) { + mLogger.error("TradeServiceImpl.excute error={}", e); + throw new RuntimeException(e.getMessage()); + } + mLogger.info("TradeServiceImpl.excute resp={}", result); return result; } } -- Gitblit v1.8.0