Merge branch 'uat_保证金天擎调用' into 'uat'
Uat 保证金天擎调用 See merge request eshop/biz_service_ebtp_extend!120
This commit is contained in:
@ -9,6 +9,9 @@ import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
|
|||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -21,8 +24,10 @@ import javax.annotation.Resource;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@Api(value = "区块链参数配置表")
|
@Api(value = "区块链参数配置表")
|
||||||
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/v1/crypconfigure")
|
@RequestMapping("/v1/crypconfigure")
|
||||||
public class CrypConfigureController{
|
public class CrypConfigureController{
|
||||||
|
|
||||||
@ -129,8 +134,10 @@ public class CrypConfigureController{
|
|||||||
@ApiOperation("调用天擎接口")
|
@ApiOperation("调用天擎接口")
|
||||||
@PostMapping("/callUniInterfaceJson")
|
@PostMapping("/callUniInterfaceJson")
|
||||||
public BaseResponse<String> callUniInterfaceJson(@RequestBody CrypBean bean) {
|
public BaseResponse<String> callUniInterfaceJson(@RequestBody CrypBean bean) {
|
||||||
|
String str = this.iCrypConfigureService.callUniInterfaceJson(bean);
|
||||||
return BaseResponse.success(this.iCrypConfigureService.callUniInterfaceJson(bean));
|
log.info("----调用天擎接口---callUniInterfaceJson-------:"+str);
|
||||||
|
System.out.println("----调用天擎接口---callUniInterfaceJson-------:"+str);
|
||||||
|
return BaseResponse.success(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,5 +31,15 @@ public class CrypBean {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "天擎接口地址")
|
@ApiModelProperty(value = "天擎接口地址")
|
||||||
public String url;
|
public String url;
|
||||||
|
/**
|
||||||
|
* 中信支付使用ClientId
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "clientId")
|
||||||
|
public String clientId;
|
||||||
|
/**
|
||||||
|
* 中信支付使用OperationCode
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "operationCode")
|
||||||
|
public String operationCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
|
|||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil;
|
||||||
import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
|
import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@ -36,8 +37,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -113,9 +115,10 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
|
|
||||||
map.put("SIGN", sign);
|
map.put("SIGN", sign);
|
||||||
|
|
||||||
json = getUniBss(bean.getReqName(), map);
|
json = getCiticUniBss(bean.getReqName(), map);
|
||||||
|
|
||||||
blockChainLog.setParam(json);//请求参数
|
blockChainLog.setParam(json);//请求参数
|
||||||
|
log.info("------请求天擎接口---json参数:---"+json);
|
||||||
str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
|
str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
|
||||||
blockChainLog.setResult(str);//返回参数
|
blockChainLog.setResult(str);//返回参数
|
||||||
UniBss uniBssRsp = JSONArray.parseObject(str, UniBss.class);
|
UniBss uniBssRsp = JSONArray.parseObject(str, UniBss.class);
|
||||||
@ -158,7 +161,6 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Async
|
|
||||||
public String callUniInterfaceJson(CrypBean bean) {
|
public String callUniInterfaceJson(CrypBean bean) {
|
||||||
log.info("天擎接口------callUniInterface:---入参-----" + JSON.toJSONString(bean));
|
log.info("天擎接口------callUniInterface:---入参-----" + JSON.toJSONString(bean));
|
||||||
BlockChainLog blockChainLog = new BlockChainLog();
|
BlockChainLog blockChainLog = new BlockChainLog();
|
||||||
@ -191,10 +193,13 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
|
|
||||||
json = getCiticUniBss(bean.getReqName(), map);
|
json = getCiticUniBss(bean.getReqName(), map);
|
||||||
|
|
||||||
str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
|
str = this.uniBssCiticHttpPost(bean.getUrl(), json,bean.getClientId(),bean.getOperationCode());
|
||||||
|
operationLogService.addOperationLog("中信支付天擎接口调用信息,请求地址{}"+bean.getUrl()+",参数{}"+json+",返回信息{}"+str,true, EbtpLogBusinessModule.PAY_PUSH, EbtpLogType.INSERT);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("区块链调用失败!~-----------------",e);
|
log.error("中信支付--天擎接口返回参数!~-----------------",e);
|
||||||
|
operationLogService.addOperationLog("中信支付天擎接口调用信息失败,请求地址{}"+bean.getUrl()+",参数{}"+json+",返回信息{}"+str,false, EbtpLogBusinessModule.PAY_PUSH, EbtpLogType.INSERT);
|
||||||
}
|
}
|
||||||
|
log.info("---中信支付--天擎接口返回参数-----"+str);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,7 +389,6 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
|
|
||||||
return JSON.toJSONString(uniBss);
|
return JSON.toJSONString(uniBss);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 中信天擎接口 数据格式 获取加密签名
|
* 中信天擎接口 数据格式 获取加密签名
|
||||||
* REQ:{
|
* REQ:{
|
||||||
@ -466,7 +470,57 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中信支付 请求头参数
|
||||||
|
* "ClientId", "com.unicom.hq.bid"
|
||||||
|
* "OperationCode", "com.unicom.fcp.uapService.registeredMembers.process"
|
||||||
|
* @param path
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String uniBssCiticHttpPost(String path, String data,String ClientId,String OperationCode) {
|
||||||
|
String str = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL url = new URL(path);
|
||||||
|
if("https".equals(url.getProtocol())){
|
||||||
|
SslUtil.ignoreSsl();
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
|
PrintWriter out = null;
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setRequestProperty("Accept-Encoding", "");
|
||||||
|
if(ClientId!=null&&!"".equals(ClientId)) {
|
||||||
|
conn.setRequestProperty("ClientId", ClientId);
|
||||||
|
}
|
||||||
|
if(OperationCode!=null&&!"".equals(OperationCode)){
|
||||||
|
conn.setRequestProperty("OperationCode", OperationCode);
|
||||||
|
}
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
out = new PrintWriter(conn.getOutputStream());
|
||||||
|
out.print(data);
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
|
||||||
|
for(String line = br.readLine(); line != null; line = br.readLine()) {
|
||||||
|
str = new String(line.getBytes(), "UTF-8");
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
is.close();
|
||||||
|
conn.disconnect();
|
||||||
|
} catch (Exception var9) {
|
||||||
|
var9.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, UnsupportedEncodingException {
|
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, UnsupportedEncodingException {
|
||||||
//String json = "{\"RESULT_ID\":\"1\",\"TP_ID\":\"2\",\"SECTION_ID\":\"3\",\"REPORT_ID\":\"4\",\"RESULTDETAIL\":[{\"RESULT_DETAIL_ID\":\"51\",\"RESULT_ID\":\"52\",\"TENDERER_ID\":\"53\",\"WINNER_CANDIDATE\":\"54\",\"PRICE\":\"55\",\"PRICE_REVIEW\":\"56\",\"BUSINESS_SCORE\":\"57\",\"TECHNICAL_SCORE\":\"58\",\"SERVICE_SCORE\":\"59\",\"PRICE_SCORE\":\"60\",\"TOTAL_SCORE\":\"61\",\"CONTRACTED_MONEY\":\"62\",\"TAX_RATE_PRICE\":\"63\",\"SCOREDETAIL\":[{\"RESULT_DETAIL_ID\":\"71\",\"TENDERER_ID\":\"72\",\"USER_ID\":\"73\",\"BUSINESS_SCORE\":\"74\",\"TECHNICAL_SCORE\":\"75\",\"SERVICE_SCORE\":\"76\",\"PRICE_SCORE\":\"77\"}]}]}";
|
//String json = "{\"RESULT_ID\":\"1\",\"TP_ID\":\"2\",\"SECTION_ID\":\"3\",\"REPORT_ID\":\"4\",\"RESULTDETAIL\":[{\"RESULT_DETAIL_ID\":\"51\",\"RESULT_ID\":\"52\",\"TENDERER_ID\":\"53\",\"WINNER_CANDIDATE\":\"54\",\"PRICE\":\"55\",\"PRICE_REVIEW\":\"56\",\"BUSINESS_SCORE\":\"57\",\"TECHNICAL_SCORE\":\"58\",\"SERVICE_SCORE\":\"59\",\"PRICE_SCORE\":\"60\",\"TOTAL_SCORE\":\"61\",\"CONTRACTED_MONEY\":\"62\",\"TAX_RATE_PRICE\":\"63\",\"SCOREDETAIL\":[{\"RESULT_DETAIL_ID\":\"71\",\"TENDERER_ID\":\"72\",\"USER_ID\":\"73\",\"BUSINESS_SCORE\":\"74\",\"TECHNICAL_SCORE\":\"75\",\"SERVICE_SCORE\":\"76\",\"PRICE_SCORE\":\"77\"}]}]}";
|
||||||
|
|
||||||
@ -509,6 +563,5 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
|||||||
// boolean isOk = crypService.verifyObject(bean);
|
// boolean isOk = crypService.verifyObject(bean);
|
||||||
// System.out.println("verify result of Map: "+ isOk);
|
// System.out.println("verify result of Map: "+ isOk);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.crypconfigure.util;
|
||||||
|
import javax.net.ssl.*;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
public class SslUtil {
|
||||||
|
|
||||||
|
private static void trustAllHttpsCertificates() throws Exception {
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[1];
|
||||||
|
TrustManager tm = new miTM();
|
||||||
|
trustAllCerts[0] = tm;
|
||||||
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
|
sc.init(null, trustAllCerts, null);
|
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class miTM implements TrustManager, X509TrustManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isServerTrusted(X509Certificate[] certs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClientTrusted(X509Certificate[] certs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] certs, String authType)
|
||||||
|
throws CertificateException {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
|
||||||
|
*/
|
||||||
|
public static void ignoreSsl() throws Exception{
|
||||||
|
HostnameVerifier hv = (urlHostName, session) -> true;
|
||||||
|
trustAllHttpsCertificates();
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(hv);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user