Commit f10dddc2 authored by 胡建龙's avatar 胡建龙

Merge branch 'uat' of https://hel.hand-china.com/rl/hls-support-rlwx into uat

 Conflicts:
	core/src/main/java/com/cmb/service/impl/HclcCmbPolyServiceImpl.java
	core/src/main/java/com/hand/app/cmb/util/GenerateUtil.java
	core/src/main/java/com/hand/app/cmb/util/Pojo.java
parents 7b2af1cc 51e30f4b
......@@ -279,6 +279,15 @@
${project.basedir}/src/main/webapp/WEB-INF/lib/rfsp-api-1.6.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.chinapay.secss</groupId>
<artifactId>chinapaysecure1_5</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>
${project.basedir}/src/main/webapp/WEB-INF/lib/chinapaysecure1_5.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
......
......@@ -72,6 +72,14 @@ public class HlsEbankCcbTransaction extends BaseDTO {
private String fileFlag;
private String userId;
private String qrCode;
private String cmbOrderId;
private String txnTime;
public Long getTransactionId() {
return transactionId;
}
......@@ -239,4 +247,36 @@ public class HlsEbankCcbTransaction extends BaseDTO {
public void setFileFlag(String fileFlag) {
this.fileFlag = fileFlag;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getCmbOrderId() {
return cmbOrderId;
}
public void setCmbOrderId(String cmbOrderId) {
this.cmbOrderId = cmbOrderId;
}
public String getTxnTime() {
return txnTime;
}
public void setTxnTime(String txnTime) {
this.txnTime = txnTime;
}
}
\ No newline at end of file
package com.chinapay.service;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.dto.HclcCupSignInfo;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface IHlsEbankCcbTransactionService extends IBaseService<HlsEbankCcbTransaction>, ProxySelf<IHlsEbankCcbTransactionService> {
}
package com.chinapay.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.dto.HclcCupSignInfo;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.dto.HlsWsConfig;
import com.chinapay.mapper.HclcCupSignInfoMapper;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.mapper.HlsWsConfigMapper;
import com.chinapay.secss.SecssConstants;
import com.chinapay.secss.SecssUtil;
import com.chinapay.service.IHclcChinaPayService;
import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.util.HttpUtils;
import com.chinapay.util.StringUtil;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
import com.hand.hap.core.IRequest;
import com.hand.hap.intergration.service.IHapInterfaceHeaderService;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public class HlsEbankCcbTransactionServiceImpl extends BaseServiceImpl<HlsEbankCcbTransaction> implements IHlsEbankCcbTransactionService {
}
......@@ -9,9 +9,13 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.secss.SecssConstants;
import com.chinapay.secss.SecssUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hand.app.cmb.util.SM2Util;
import com.hand.app.cmb.util.SignatureUtil;
import com.hand.hap.system.dto.BaseDTO;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.time.DateUtils;
......@@ -140,34 +144,73 @@ public class StringUtil {
// String fileData = "6226 0912 1056 2371";
// fileData.trim();
String strCardTranData = null;
String path = String.format("%s%s.properties", "F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\", "000092112092486");
SecssUtil secssUtil = new SecssUtil(true);
secssUtil.init(path);
// String strCardTranData = null;
// String path = String.format("%s%s.properties", "F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\", "000092112092486");
// SecssUtil secssUtil = new SecssUtil(true);
// secssUtil.init(path);
// strCardTranData = "{\"AccName\":\"张博\",\"MobileNo\":\"18653352435\",\"CardNo\":\"6215686000014576697\",\"EntrstAuthNo\":\"370321199004060610\",\"EntrstAmtLmt\":\"50000000\",\"CertType\":\"01\",\"EntrstDtStp\":\"9999\",\"EntrstEndDtTm\":\"20320118202019\",\"CertNo\":\"370321199004060610\",\"EntrstStrDtTm\":\"20220118202019\",\"EntrstDtUnt\":\"07\"}";
// // 加密
// strCardTranData = Base64.encodeBase64String(strCardTranData.getBytes(Constants.ENCODING));
// secssUtil.encryptData(strCardTranData);
Map<String, String> sendMap=new HashMap<String, String>();
sendMap.put("TranType","0608");
sendMap.put("BusiType","0001");
sendMap.put("Version","20140728");
sendMap.put("TranDate","20220119");
sendMap.put("CardTranData","i4T9Hpt/Qmkhh/xSzULM39qft9MS4KhMi+MQ3dvxJtbihUTlrk/xR1U8DhIAxvzsTVjINd14GbxYuXdG/N8cFZ15bHhDp89gkk6hvK9A+7l0WWNDnVlJWcLag0ERgA0v0FhXgfheqrMWuWnr9zrVp7yN+9SOs6XzTEUpN/ejhLd/nDkRBEyzJcPtxEWDB+M2KWOWLEjZf4L0NO3UN93ir7IvzoZmwzmwvpEW3Y4+sW9X9VMP8riaGnYV5VtoUvzUr55uBR6mIeuoqrZApvs0Pj8mJ687AvOz/yeyhlPvm1WMzjsrjPeztx1C3hstwwAEk9i6K3VjNkD2KaFwgFK1jcdTzqE5IqvXh5jRVlmBHaVnRzmfhBaZiFVvSkqbGdY90icPfDFhPR843ZsQOvO6Xul1fKfl5oH8UfASwqkCmYRKSnVwmK1oAN/QrOgNmTLBRuKY6F2qKLvX4ZJ784aqRimWVYLVdIknAj224MHoSG4bWRDIvu7kw2+tI9+wne1ng4t6KZtEreAL8BpDpvIVUhApKapf5l4T9qWS7BC8EFMIGSl5qyxi686C+EFRXSp9J9m6H3cia1Pad5URvkFItvSIhwyulL8pcUEnr0uIJdohJUHbuevCRVQEJffA1MSY0MEbYSRaMBzPfqqsORfRjGI+XO1Qwtq2rQw+ShXirlc=");
sendMap.put("MerOrderNo","F38CE3A782984D21AD8584238D40C890");
sendMap.put("MerId","739412105210001");
sendMap.put("TranTime","224028");
sendMap.put("AccessType","0");
// Map<String, String> sendMap=new HashMap<String, String>();
// sendMap.put("TranType","0608");
// sendMap.put("BusiType","0001");
// sendMap.put("Version","20140728");
// sendMap.put("TranDate","20220119");
// sendMap.put("CardTranData","i4T9Hpt/Qmkhh/xSzULM39qft9MS4KhMi+MQ3dvxJtbihUTlrk/xR1U8DhIAxvzsTVjINd14GbxYuXdG/N8cFZ15bHhDp89gkk6hvK9A+7l0WWNDnVlJWcLag0ERgA0v0FhXgfheqrMWuWnr9zrVp7yN+9SOs6XzTEUpN/ejhLd/nDkRBEyzJcPtxEWDB+M2KWOWLEjZf4L0NO3UN93ir7IvzoZmwzmwvpEW3Y4+sW9X9VMP8riaGnYV5VtoUvzUr55uBR6mIeuoqrZApvs0Pj8mJ687AvOz/yeyhlPvm1WMzjsrjPeztx1C3hstwwAEk9i6K3VjNkD2KaFwgFK1jcdTzqE5IqvXh5jRVlmBHaVnRzmfhBaZiFVvSkqbGdY90icPfDFhPR843ZsQOvO6Xul1fKfl5oH8UfASwqkCmYRKSnVwmK1oAN/QrOgNmTLBRuKY6F2qKLvX4ZJ784aqRimWVYLVdIknAj224MHoSG4bWRDIvu7kw2+tI9+wne1ng4t6KZtEreAL8BpDpvIVUhApKapf5l4T9qWS7BC8EFMIGSl5qyxi686C+EFRXSp9J9m6H3cia1Pad5URvkFItvSIhwyulL8pcUEnr0uIJdohJUHbuevCRVQEJffA1MSY0MEbYSRaMBzPfqqsORfRjGI+XO1Qwtq2rQw+ShXirlc=");
// sendMap.put("MerOrderNo","F38CE3A782984D21AD8584238D40C890");
// sendMap.put("MerId","739412105210001");
// sendMap.put("TranTime","224028");
// sendMap.put("AccessType","0");
//
// secssUtil.sign(sendMap);
// sendMap.put("Signature",secssUtil.getSign());
//
//// sendMap.put("Signature","zJ0CnwrHFzSL8OcAXI1YudMCHXLkB98P78JSBcCTmV4zhJIcgpGcgiKkrIdI4PXi5NUtJsxZ8S5bYbNE8XkWGQocfgDqwvzFGuU64adxxW6yNMNPg0Ug7TX6GOZatmGenLPL9YyyRxsIpUhPN2nDBYc4jCpAtMKYE/mCZLIvXdXyUnUgRD7D5KiXTN5Ka0QClmNQcmbiG22lMYb63i9fCJtcXeIK8FW0XiCbN1dv9ZSeMUgeXQzQWNQSRb5R8+GpWTpaTO4vHv+MEne9fW3p7ud33jhfwo/Cap5CdFyLU9r5kvk1sBx6XdOjDHuN84rK1nvaVaxqm9EdSEeck64rXw==");
// secssUtil.verify(sendMap);
// System.out.println(secssUtil.getErrCode());
// System.out.println(secssUtil.getErrCode());
// System.out.println(secssUtil.getEncValue());
//对待加签内容进行排序拼接
Map<String, String> requestPublicParams = new TreeMap<>();
ObjectMapper mapper = new ObjectMapper();
//公共请求参数
requestPublicParams.put("version", "0.0.1"); //版本号,固定为0.0.1(必传字段)
requestPublicParams.put("encoding", "UTF-8"); //编码方式,固定为UTF-8(必传)
requestPublicParams.put("signMethod", "02"); //签名方法,固定为02,表示签名方式为国密(必传)
requestPublicParams.put("biz_content", "{\"tradeScene\":\"OFFLINE\",\"orderId\":\"2022042400000390\",\"notifyUrl\":\"http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen\",\"merId\":\"3089991701201D0\",\"body\":\"聚合支付测试\",\"userId\":\"N003574551\",\"payValidTime\":\"900\",\"currencyCode\":\"156\",\"txnAmt\":\"200000\"}");
String signContent = SignatureUtil.getSignContent(requestPublicParams);
System.out.println("签名signContent:"+signContent);
//加签
requestPublicParams.put("sign", SM2Util.sm2Sign(signContent, "D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38"));
secssUtil.sign(sendMap);
sendMap.put("Signature",secssUtil.getSign());
System.out.println(requestPublicParams.get("sign").toString());
// System.out.println(checkSign(JSONObject.parseObject(mapper.writeValueAsString(requestPublicParams)).toJSONString()));
}
// sendMap.put("Signature","zJ0CnwrHFzSL8OcAXI1YudMCHXLkB98P78JSBcCTmV4zhJIcgpGcgiKkrIdI4PXi5NUtJsxZ8S5bYbNE8XkWGQocfgDqwvzFGuU64adxxW6yNMNPg0Ug7TX6GOZatmGenLPL9YyyRxsIpUhPN2nDBYc4jCpAtMKYE/mCZLIvXdXyUnUgRD7D5KiXTN5Ka0QClmNQcmbiG22lMYb63i9fCJtcXeIK8FW0XiCbN1dv9ZSeMUgeXQzQWNQSRb5R8+GpWTpaTO4vHv+MEne9fW3p7ud33jhfwo/Cap5CdFyLU9r5kvk1sBx6XdOjDHuN84rK1nvaVaxqm9EdSEeck64rXw==");
secssUtil.verify(sendMap);
System.out.println(secssUtil.getErrCode());
System.out.println(secssUtil.getErrCode());
System.out.println(secssUtil.getEncValue());
private static Boolean checkSign(String string) {
System.out.println("要验签的报文内容:" + string);
try {
//验签
ObjectMapper objectMapper = new ObjectMapper();
Map<String, String> responseBodyMap = objectMapper.readValue(string, Map.class);
String sign = responseBodyMap.remove("sign");
String contentStr = SignatureUtil.getSignContent(responseBodyMap);
System.out.println("验签contentStr:"+contentStr);
boolean result = SM2Util.sm2Check(contentStr, sign, "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==");
if (result) {
System.out.println("报文验签成功!");
} else {
System.out.println("报文验签失败!");
}
return result;
} catch (Exception e) {
System.out.println("验签发生异常!");
e.printStackTrace();
return false;
}
}
/**
......
package com.cmb.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cmb.service.HclcCmbPolyService;
import com.cmb.util.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hand.hap.core.IRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
@Service
public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
private static final String url = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply"; //UAT
//需要补充域名加端口==================================================================
private static final String notifyUrl = "/cmb/poly/order/notify";
//uat环境商户国密私钥
public static final String privateKey = "D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38";
//uat环境招行国密公钥
public static final String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==";
public static final String appId = "8ab74856-8772-45c9-96db-54cb30ab9f74";
public static final String appSecret = "5b96f20a-011f-4254-8be8-9a5ceb2f317f";
@Value("${cmb.version}")
private String version;
@Value("${cmb.encoding}")
private String encoding;
@Value("${cmb.signMethod}")
private String signMethod;
/*币种,非必传,默认156人民币*/
@Value("${cmb.currencyCode}")
private String currencyCode;
@Override
public JSONObject getQrcode(IRequest iRequest, JSONObject params) {
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
签名 sign String(1024) 是
签名方法 signMethod String(2) 是 02:SM2
商户号 merId String(32) 是 商户在招行完成商户进件后分配的招行商户号
商户订单号 orderId String(32) 是 商户端生成,要求此订单号在整个商户下唯一
收银员 userId String(32) 是 招行系统生成的收银员,每个收银员均会对应到一个门店。若商户无门店、收银员概念则上送默认的虚拟收银员即可。
终端号 termId String(8) 否 原则是可以通过交易上送的终端编号准确定位商户每一个门店内每一台收银设备,建议按“门店编号+收银机编号”或“设备编号”组成8位终端编号在交易中上送
支付有效时间 payValidTime String(10) 否 二维码的有效时长,单位为秒,若商户上送,则以商户上送值为准,否则使用默认有效时长1200秒
交易通知地址 notifyUrl String(256) 是 支付结果将送到本通知
交易金额 txnAmt String(13) 是 单位为分
交易币种 currencyCode String(3) 否 默认156,目前只支持人民币(156)
商品描述 body String(128) 否 用于展示支付宝账单详情中的“商品说明”和微信账单详情中的“商品”字段,若不上送则默认显示商户简称。
商户保留域 mchReserved String(128) 否 用于传输商户自定义数据,在支付结果查询和支付结果通知时原样返回(不上送则不返回此字段)
交易场景 tradeScene String(13) 是 OFFLINE:线下
ONLINE:线上
INSURANCE:保险
CHARITY:公益
PAYMENT: 缴费
SCHOOL:校园
商户门店号 mchStoreId String(32) 否 商户门店号
终端信息 terminalInfo String(6000) 否 商户侧受理终端信息,字段说明详见终端信息terminalInfo。
*/
JSONObject result = new JSONObject();
Map<String, String> requestPublicParams = JSONObject.parseObject(params.toJSONString(),Map.class);
// 组装requestBody并加签
String signResult= signMethod(requestPublicParams);
try {
ObjectMapper mapper = new ObjectMapper();
Map<String,String> signResultMap = mapper.readValue(signResult, Map.class);
long currentTimeMills = System.currentTimeMillis() / 1000;
// 组apiSign加密Map
Map<String,String> apiSign = new TreeMap<>();
apiSign.put("appid", appId);
apiSign.put("secret", appSecret);
apiSign.put("sign", signResultMap.get("sign"));
apiSign.put("timestamp", "" + currentTimeMills);
// MD5加密
String MD5Content = SignatureUtil.getSignContent(apiSign);
String apiSignString = MD5Utils.getMD5Content(MD5Content).toLowerCase();
// 组request头部Map
Map<String, String> apiHeader = new HashMap<>();
apiHeader.put("appid", appId);
apiHeader.put("timestamp", "" + currentTimeMills);
apiHeader.put("apisign", apiSignString);
// 发送HTTP post请求
Map<String,String> response = Utils.postForEntity(url, signResult, apiHeader);
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
签名 sign String(1024) 是
签名方法 signMethod String(2) 是 02:SM2
返回码 returnCode String(7) 是 SUCCESS/FAIL,此字段是通信标识,非交易标识,交易是否成功需要查看respCode来判断。SUCCESS表示商户上送的报文符合规范,FAIL表示报文内的字段不符合规范,包括长度超长、非法字符、签名错误等
以下字段仅在returnCode为SUCCESS时返回
商户号 merId String(32) 是 请求报文中的商户号
商户订单号 orderId String(32) 是 请求报文中的商户订单号
响应码 respCode String(10) 是 业务错误码,成功为SUCCESS,失败为FAIL
以下字段仅在returnCode和respCode为SUCCESS时返回
二维码 qrCode String(300) 是
平台订单号 cmbOrderId String(32) 是 招行生成的订单号
订单发送时间 txnTime String(14) 是 订单生成时间,格式为yyyyMMddHHmmss
以下字段仅在returnCode或respCode为FAIL时返回
错误码 errCode String(32) 是 请求处理失败的错误码信息
应答信息 respMsg String(256) 是 请求处理失败的详细描述信息
*/
System.out.println(mapper.writeValueAsString(response));
// 返回结果验签,验证数据的正确性(安全性)
Boolean checkResult1 = checkSign(mapper.writeValueAsString(response));
if(!checkResult1){
//数据验签失败的处理,重发或者直接告诉前端发送失败
result.put("errCode",response.get("errCode"));
}
//获取响应结果内容
String success = response.get("returnCode");
System.out.println("返回结果:" + success);
result.put("qrcode",response.get("qrcode"));
result.put("respMsg",response.get("respMsg"));
//业务数据的封装。。。
return result;
} catch (Exception e) {
e.printStackTrace();
result.put("errCode","服务器问题");
return result;
}
}
private String signMethod(Map paramsMap){
Map<String, String> requestPublicParams = new TreeMap<>();
String requestStr = null;
try {
//公共请求参数
requestPublicParams.put("version", version); //版本号,固定为0.0.1(必传字段)
requestPublicParams.put("encoding", encoding); //编码方式,固定为UTF-8(必传)
requestPublicParams.put("signMethod", signMethod); //签名方法,固定为02,表示签名方式为国密(必传)
requestPublicParams.put("notifyUrl", notifyUrl);
// //业务要素
// Map<String, String> requestTransactionParams = new HashMap<>();
// requestTransactionParams.put("body", "聚合支付测试"); //商户号(必传)
// requestTransactionParams.put("currencyCode", "156"); //交易币种,默认156,目前只支持人民币(156)
// requestTransactionParams.put("merId", "3089991074200KV"); //商户号(必传)
// requestTransactionParams.put("notifyUrl", notifyUrl); //交易通知地址(必传)
// requestTransactionParams.put("orderId", "" + System.currentTimeMillis()); //商户订单号(必传)
// requestTransactionParams.put("payValidTime", "1200"); //支付有效时间
// requestTransactionParams.put("termId", "00774411"); //终端号
// requestTransactionParams.put("txnAmt", "1405"); //交易金额,单位为分(必传)
// requestTransactionParams.put("userId", "N003363806"); //收银员
// requestTransactionParams.put("tradeScene", "OFFLINE"); //交易场景
ObjectMapper mapper = new ObjectMapper();
requestPublicParams.put("biz_content", mapper.writeValueAsString(paramsMap));
System.out.println("加签前的报文内容:" + mapper.writeValueAsString(requestPublicParams));
//对待加签内容进行排序拼接
String signContent= SignatureUtil.getSignContent(requestPublicParams);
//加签
requestPublicParams.put("sign", SM2Util.sm2Sign(signContent, privateKey));
requestStr = mapper.writeValueAsString(requestPublicParams);
System.out.println("加签后的报文内容:" + requestStr);
return requestStr;
}catch (Exception e){
System.out.println("加签发生异常!");
e.printStackTrace();
return requestStr;
}
}
private Boolean checkSign(String string){
System.out.println("要验签的报文内容:" + string);
try {
//验签
ObjectMapper objectMapper = new ObjectMapper();
Map<String, String> responseBodyMap = objectMapper.readValue(string, Map.class);
String sign = responseBodyMap.remove("sign");
String contentStr = SignatureUtil.getSignContent(responseBodyMap);
boolean result = SM2Util.sm2Check(contentStr,sign, publicKey);
if (result) {
System.out.println("报文验签成功!");
} else {
System.out.println("报文验签失败!");
}
return result;
}catch (Exception e){
System.out.println("验签发生异常!");
e.printStackTrace();
return false;
}
}
@Override
public JSONObject queryOrderStatus(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
final String url = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/orderquery" ;
//初始化请求报文
//实体类为商户传过来的一些参数,会封装作为biz_content部分
Pojo pojo = new Pojo();
String requestString = GenerateUtil.initRequestParam(pojo);
try {
ObjectMapper objectMapper = new ObjectMapper();
Map<String,String> requestMap = objectMapper.readValue(requestString,Map.class);
long currentTimeMills = System.currentTimeMillis() / 1000;
//对请求报文进行加密
Map<String,String> apiEncMap = new HashMap<>();
apiEncMap.put("appid",appId);
apiEncMap.put("secret",appSecret);
apiEncMap.put("sign",requestMap.get("sign"));
apiEncMap.put("timestamp",""+currentTimeMills);
//MD5加密
String MD5Content = SignatureUtil.getSignContent(apiEncMap);
String apiEncString = MD5Utils.getMD5Content(MD5Content).toLowerCase();
//组请求报文头
Map<String,String> requstHeader = new HashMap<>();
requstHeader.put("appid",appId);
requstHeader.put("timestamp",""+currentTimeMills);
requstHeader.put("apisign",apiEncString);
//发送http请求
Map<String,String> responseMap = Utils.postForEntity(url,requestString,requstHeader);
//处理响应报文
GenerateUtil.handleResponse(responseMap);
}catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
@Override
public Map<String, String> orderNotify(IRequest iRequest, JSONObject params) {
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
签名 sign String(1024) 是
签名方法 signMethod String(2) 是 02:SM2
商户号 merId String(32) 是 商户在招行完成商户进件后分配的招行商户号
商户订单号 orderId String(32) 是 支付交易的商户订单号
平台订单号 cmbOrderId String(32) 是 招行生成的订单号
收银员 userId String(32) 否 支付交易的收银员信息,若有,则返回
交易金额 txnAmt String(13) 是 单位为分
优惠金额 dscAmt String(13) 是 单位为分
银联优惠信息 couponInfo String(500) 否 银联通道且有优惠活动时出现,字段说明详见2.6优惠信息字段说明
订单原始金额 orderOrigAmt String(13) 否 单位为分,请求上送orderOrigAmt则对应返回该内容
订单优惠金额 orderCouponAmt String(13) 否 单位为分,请求上送orderCouponAmt则对应返回该内容
优惠券信息 promotionDetail String 否 微信、支付宝优惠券信息,规则见2.6优惠信息字段说明
交易币种 currencyCode String(3) 是 目前只支持人民币(156)
支付方式 payType String(2) 是 目前支持:支付宝/微信/银联
ZF:支付宝
WX:微信
YL:银联
用户标识 openId String(128) 否 支付宝支付:用户在支付宝系统的唯一标识
微信支付:商户上送sub_appid时返回用户在sub_appid下的sub_openid
付款银行 payBank String(32) 否 支付宝支付:
ALIPAYACCOUNT 支付宝账户
PCREDIT 蚂蚁花呗
DEBIT_CARD 借记卡
CREDIT_CARD 信用卡
MIXED_CARD 借贷合一卡 等
微信支付:CMB_CREDIT 等
第三方订单号 thirdOrderId String(64) 否 支付宝、微信侧的订单号
支付宝账户 buyerLogonId String(64) 否 支付宝支付的交易返回,如:koh***@sandbox.com
订单发送时间 txnTime String(14) 是 支付订单生成的时间,格式为yyyyMMddHHmmss
订单完成日期 endDate String(8) 否 第三方系统返回的交易完成日期,此日期仅在交易成功是返回,不保证是实际清算日期,格式为yyyyMMdd
订单完成时间 endTime String(6) 否 第三方系统返回的交易完成时间,此时间仅在交易成功是返回,格式为HHmmss
支付宝和微信通道的成功交易返回此字段
银联通道的交易无论成功与否,均不返回此字段
商户保留域 mchReserved String(128) 否 若原交易有上送此字段,则返回此字段
*/
JSONObject result = new JSONObject();
System.out.println(params);
String requestBodyString = params.toJSONString();
Map<String, String> respData = new HashMap<>();
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
签名 sign String(1024) 是
签名方法 signMethod String(2) 是 02:SM2
返回码 returnCode String(7) 是 SUCCESS/FAIL,SUCCESS表示商户接收通知成功并校验成功
以下字段仅在returnCode为SUCCESS时返回
响应码 respCode String(10) 是 商户返回的业务错误码,成功为SUCCESS,失败为FAIL
应答信息 respMsg String(256) 否 请求处理失败的详细描述信息
*/
//设置响应数据
respData.put("version", "0.0.1");//版本号,固定为0.0.1(必传)
respData.put("encoding", "UTF-8");//编码方式,固定为UTF-8(必传)
respData.put("signMethod", "02");//签名方法,固定为02,国密
try {
respData.put("returnCode", "SUCCESS"); //SUCCESS表示商户接收通知成功并校验成功
//非空校验
if (requestBodyString == null || "".equals(requestBodyString.trim())) {
respData.put("returnCode", "FAIL");
return respData;
}
Map<String, String> requestBodyMap = str2Map(requestBodyString);
Map<String, String> resultMap = requestBodyMap.entrySet().stream().collect(Collectors.toMap(e -> SignatureUtil.decode(e.getKey()), e -> SignatureUtil.decode(e.getValue())));
if (resultMap == null) {
respData.put("returnCode", "FAIL");
return respData;
}
String sign = resultMap.remove("sign");
//对待加签内容进行排序拼接
String contentStr = SignatureUtil.getSignContent(resultMap);
//验证签名-使用招行公钥进行验签
boolean flag = SM2Util.sm2Check(contentStr,sign, publicKey);
if (!flag) {
//验签失败
System.out.println("验签失败");
respData.put("returnCode", "FAIL");
return respData;
}
System.out.println("验签成功");
//......(处理自身业务逻辑)
//......
//......
respData.put("respCode", "SUCCESS");//业务错误码,成功为SUCCESS,失败为FAIL
/*如果处理自身业务逻辑发生错误,返回
respData.put("respCode","FAIL");
respData.put("respMsg","error_msg");
*/
//对待加签内容进行排序拼接
String signContent = SignatureUtil.getSignContent(respData);
//加签-使用商户私钥加签
respData.put("sign", SM2Util.sm2Sign(signContent, privateKey));
System.out.println("加签成功");
return respData;
} catch (Exception e) {
e.printStackTrace();
respData.put("returnCode", "FAIL");
return respData;
}
}
private Map<String, String> str2Map(String str) {
Map<String, String> result = new HashMap<>();
String[] results = str.split("&");
if (results != null && results.length > 0) {
for (int var = 0; var < results.length; ++var) {
String pair = results[var];
String[] kv = pair.split("=", 2);
if (kv != null && kv.length == 2) {
result.put(kv[0], kv[1]);
}
}
}
return result;
}
}
package com.cmb.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
//构造请求报文工具类
public class GenerateUtil {
private static final Logger LOGGER = Logger.getLogger(GenerateUtil.class);
@Value("${cmb.version}")
private static String version;
@Value("${cmb.encoding}")
private static String encoding;
@Value("${cmb.signMethod}")
private static String signMethod;
public static final String privateKey = "D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38";
public static final String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==";
public static String initRequestParam(Pojo pojo){
//设置公共请求参数
Map<String,String> resultPublicParam = new HashMap<>();
resultPublicParam.put("version",version);
resultPublicParam.put("encoding",encoding);
resultPublicParam.put("sign_method", signMethod);
//初始化业务请求参数
try {
ObjectMapper objectMapper = new ObjectMapper();
String bizContent = objectMapper.writeValueAsString(pojo);
System.out.println(bizContent);
resultPublicParam.put("biz_content",bizContent);
//对待加签内容进行排序拼接
String signStr = SignatureUtil.getSignContent(resultPublicParam);
//加签
String sign = SM2Util.sm2Sign(signStr, privateKey);
resultPublicParam.put("sign",sign);
String requestStr = objectMapper.writeValueAsString(resultPublicParam);
LOGGER.info("加签后的报文内容:" + requestStr);
return requestStr;
}catch (Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 处理响应报文
* @param responseMap
* @return
*/
public static void handleResponse(Map<String,String> responseMap){
if( null == responseMap){
LOGGER.equals("响应的内容为空");
return ;
}
try {
ObjectMapper objectMapper = new ObjectMapper();
LOGGER.info("收到响应的内容为:" + objectMapper.writeValueAsString(responseMap));
//验签
String sign = responseMap.remove("sign");
//生成验签字符串
String signStr = SignatureUtil.getSignContent(responseMap);
boolean flag = SM2Util.sm2Check(signStr,sign, publicKey);
if( flag ){
LOGGER.info("验签成功!");
} else {
LOGGER.error("验签失败!");
}
return;
}catch (Exception ex){
LOGGER.equals("系统异常");
return;
}
}
}
package com.cmb.util;
public class Pojo {
public Pojo(){}
}
......@@ -8,11 +8,11 @@
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.cmb.controllers;
package com.hand.app.cmb.controllers;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.service.IHclcChinaPayService;
import com.cmb.service.HclcCmbPolyService;
import com.hand.app.cmb.service.HclcCmbPolyService;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,6 +32,7 @@ import java.util.Map;
* @since 1.0.0
*/
@Controller
@RequestMapping(value = {"/r/api", "/"})
public class HclcCmbPolyController extends BaseController {
@Autowired
......
package com.hand.app.cmb.controllers;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.esignHclc.service.ISignInfoHclcFaceService;
import com.hand.app.esignHclc.service.ISignInfoHclcService;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/25
* Time: 21:32
*/
@Controller
public class HclcCmbPolyListenController extends BaseController {
@Autowired
private ISignInfoHclcFaceService iSignInfoHclcFaceService;
@Autowired
private ISignInfoHclcService iSignInfoHclcService;
@ResponseBody
@RequestMapping(value = "/api/public/cmb/get/qr/code/listen", method = RequestMethod.POST)
public JSONObject chinaSignListen(HttpServletRequest request) {
JSONObject responseData = new JSONObject();
return responseData;
}
}
/**
* Copyright (C), 2018-2021
* FileName: HclcCupSignInfo
* Author: lsy
* Date: 2021/12/10 11:25
* Description:
* History:
* <author> <time> <version> <desc>
* lishuangyi 修改时间 版本号 描述
*/
package com.hand.app.cmb.dto;
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/*
* 〈〉
*
* @author 27214
* @create 2021/12/10
* @since 1.0.0
*/
@Table(name = "ld037")
@ExtensionAttribute(disable = true)
public class Ld037 {
@Id
@GeneratedValue
private Long id;
private String contractno;
private String times;
private Date generatedt;
private String recamtno;
private Date recduedt;
private String bankname;
private String accountid;
private String accountname;
private Double amount;
private String filestatus;
private String receiptstatus;
private String receiptcfmstatus;
private String errorcd;
private String dealercd;
private String branchcd;
private String customercd;
private String customername;
private String outfilename;
private String infilename;
private String characterid;
private String errormsg;
private String chargeaccountno;
private Double actdbtamount;
private String version;
private String ctino;
private String cupPin;
private String phone;
private Long transactionId;
private Long num;
private Date procdt;
private Date recdt;
private Date recbatchdt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getContractno() {
return contractno;
}
public void setContractno(String contractno) {
this.contractno = contractno;
}
public String getTimes() {
return times;
}
public void setTimes(String times) {
this.times = times;
}
public Date getGeneratedt() {
return generatedt;
}
public void setGeneratedt(Date generatedt) {
this.generatedt = generatedt;
}
public String getRecamtno() {
return recamtno;
}
public void setRecamtno(String recamtno) {
this.recamtno = recamtno;
}
public Date getRecduedt() {
return recduedt;
}
public void setRecduedt(Date recduedt) {
this.recduedt = recduedt;
}
public String getBankname() {
return bankname;
}
public void setBankname(String bankname) {
this.bankname = bankname;
}
public String getAccountid() {
return accountid;
}
public void setAccountid(String accountid) {
this.accountid = accountid;
}
public String getAccountname() {
return accountname;
}
public void setAccountname(String accountname) {
this.accountname = accountname;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getFilestatus() {
return filestatus;
}
public void setFilestatus(String filestatus) {
this.filestatus = filestatus;
}
public String getReceiptstatus() {
return receiptstatus;
}
public void setReceiptstatus(String receiptstatus) {
this.receiptstatus = receiptstatus;
}
public String getReceiptcfmstatus() {
return receiptcfmstatus;
}
public void setReceiptcfmstatus(String receiptcfmstatus) {
this.receiptcfmstatus = receiptcfmstatus;
}
public String getErrorcd() {
return errorcd;
}
public void setErrorcd(String errorcd) {
this.errorcd = errorcd;
}
public String getDealercd() {
return dealercd;
}
public void setDealercd(String dealercd) {
this.dealercd = dealercd;
}
public String getBranchcd() {
return branchcd;
}
public void setBranchcd(String branchcd) {
this.branchcd = branchcd;
}
public String getCustomercd() {
return customercd;
}
public void setCustomercd(String customercd) {
this.customercd = customercd;
}
public String getCustomername() {
return customername;
}
public void setCustomername(String customername) {
this.customername = customername;
}
public String getOutfilename() {
return outfilename;
}
public void setOutfilename(String outfilename) {
this.outfilename = outfilename;
}
public String getInfilename() {
return infilename;
}
public void setInfilename(String infilename) {
this.infilename = infilename;
}
public String getCharacterid() {
return characterid;
}
public void setCharacterid(String characterid) {
this.characterid = characterid;
}
public String getErrormsg() {
return errormsg;
}
public void setErrormsg(String errormsg) {
this.errormsg = errormsg;
}
public String getChargeaccountno() {
return chargeaccountno;
}
public void setChargeaccountno(String chargeaccountno) {
this.chargeaccountno = chargeaccountno;
}
public Double getActdbtamount() {
return actdbtamount;
}
public void setActdbtamount(Double actdbtamount) {
this.actdbtamount = actdbtamount;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getCtino() {
return ctino;
}
public void setCtino(String ctino) {
this.ctino = ctino;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Long getNum() {
return num;
}
public void setNum(Long num) {
this.num = num;
}
public Date getProcdt() {
return procdt;
}
public void setProcdt(Date procdt) {
this.procdt = procdt;
}
public Date getRecdt() {
return recdt;
}
public void setRecdt(Date recdt) {
this.recdt = recdt;
}
public Date getRecbatchdt() {
return recbatchdt;
}
public void setRecbatchdt(Date recbatchdt) {
this.recbatchdt = recbatchdt;
}
public Long getTransactionId() {
return transactionId;
}
public void setTransactionId(Long transactionId) {
this.transactionId = transactionId;
}
public String getCupPin() {
return cupPin;
}
public void setCupPin(String cupPin) {
this.cupPin = cupPin;
}
}
\ No newline at end of file
package com.hand.app.cmb.mapper;
import com.hand.app.cmb.dto.Ld037;
import com.hand.hap.mybatis.common.Mapper;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public interface Ld037Mapper extends Mapper<Ld037> {
void updateLd037Fail(Ld037 ld037);
}
package com.cmb.service;
package com.hand.app.cmb.service;
import com.alibaba.fastjson.JSONObject;
import com.hand.hap.core.IRequest;
......
package com.hand.app.cmb.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chinapay.comm.Constants;
import com.chinapay.dto.HlsEbankCcbTransaction;
import com.chinapay.mapper.HlsEbankCcbTransactionMapper;
import com.chinapay.secss.LogUtil;
import com.chinapay.service.IHlsEbankCcbTransactionService;
import com.chinapay.util.StringUtil;
import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.mapper.Ld037Mapper;
import com.hand.app.cmb.dto.Ld037;
import com.hand.app.cmb.mapper.Ld037Mapper;
import com.hand.app.cmb.service.HclcCmbPolyService;
import com.hand.app.cmb.util.MD5Utils;
import com.hand.app.cmb.util.SM2Util;
import com.hand.app.cmb.util.SignatureUtil;
import com.hand.app.cmb.util.Utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hand.app.zhongDengWang.dto.HlsWsRequests;
import com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper;
import com.hand.hap.core.IRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
private static final String url = "https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply"; //UAT
//uat环境商户国密私钥
public static final String privateKey = "D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38";
//uat环境招行国密公钥
public static final String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==";
public static final String appId = "8ab74856-8772-45c9-96db-54cb30ab9f74";
public static final String appSecret = "5b96f20a-011f-4254-8be8-9a5ceb2f317f";
/*接口区分*/
public static final String getQrCode = "GET_QR_CODE";
/*代扣交易状态*/
public static final String transNew = "NEW";
public static final String transDeal = "DEAL";
public static final String transFail = "FAIL";
/*交易结果状态*/
public static final String cmbSuccess = "SUCCESS";
public static final String cmbFail = "FAIL";
@Value("${cmb.version}")
private String version;
@Value("${cmb.encoding}")
private String encoding;
@Value("${cmb.signMethod}")
private String signMethod;
/*币种,非必传,默认156人民币*/
@Value("${cmb.currencyCode}")
private String currencyCode;
@Autowired
private HlsEbankCcbTransactionMapper hlsEbankCcbTransactionMapper;
@Autowired
private IHlsEbankCcbTransactionService hlsEbankCcbTransactionService;
@Autowired
private HlsWsRequestsMapper hlsWsRequestsMapper;
@Autowired
private Ld037Mapper ld037Mapper;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
public JSONObject getQrcode(IRequest iRequest, JSONObject params) {
JSONObject result = new JSONObject();
String resultType = null;
String errorCd = null;
if (Objects.isNull(params.get("recamt_id"))) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "请求必须参数recamt_id缺失,请检查!");
return result;
}
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
Long recamtId = params.getLong("recamt_id");
Ld037 ld037 = new Ld037();
ld037.setId(recamtId);
ld037 = ld037Mapper.selectByPrimaryKey(ld037);
if (Objects.nonNull(ld037.getReceiptstatus())) {
result.put(Constants.RESP_CODE, "E");
result.put("respMsg", "支付订单状态异常,请检查!");
return result;
}
HlsEbankCcbTransaction hlsEbankCcbTransaction = createTransaction(iRequest, ld037);
ld037.setTransactionId(hlsEbankCcbTransaction.getTransactionId());
//生成单据编号 日期+id
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(new Date());
hlsEbankCcbTransaction.setTransactionNumber(dateString + String.format("%08d", hlsEbankCcbTransaction.getTransactionId()));
// Map<String, String> requestPublicParams = JSONObject.parseObject(params.toJSONString(), Map.class);
// 组装requestBody并加签
String signResult = getQrRequestParams(hlsEbankCcbTransaction);
if (Objects.isNull(signResult)) {
result.put(Constants.RESP_CODE, "E");
result.put(Constants.RESP_MSG, "收款码申请加签发生异常,请检查!");
return result;
}
Map<String, String> response = null;
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, String> signResultMap = mapper.readValue(signResult, Map.class);
long currentTimeMills = System.currentTimeMillis() / 1000;
// 组apiSign加密Map
Map<String, String> apiSign = new TreeMap<>();
apiSign.put("appid", appId);
apiSign.put("secret", appSecret);
apiSign.put("sign", signResultMap.get("sign"));
apiSign.put("timestamp", "" + currentTimeMills);
// MD5加密
String MD5Content = SignatureUtil.getSignContent(apiSign);
String apiSignString = MD5Utils.getMD5Content(MD5Content).toLowerCase();
// 组request头部Map
Map<String, String> apiHeader = new HashMap<>();
apiHeader.put("appid", appId);
apiHeader.put("timestamp", "" + currentTimeMills);
apiHeader.put("apisign", apiSignString);
//初始化日志
HlsWsRequests hlsWsRequests = logInterfaceRequest(getQrCode, url, mapper.writeValueAsString(apiHeader), hlsEbankCcbTransaction.getTransactionId());
logger.info("发送收款码申请请求,请求参数: {}", mapper.writeValueAsString(apiHeader));
try {
// 发送HTTP post请求
response = Utils.postForEntity(url, signResult, apiHeader);
//处理接口日志
logger.info("收款码申请返回结果:" + mapper.writeValueAsString(response));
hlsWsRequests.setResponseClob(mapper.writeValueAsString(response));
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponsedDate(new Date());
// 返回结果验签,验证数据的正确性(安全性)
Boolean checkResult1 = checkSign(mapper.writeValueAsString(response));
//数据验签成功
if (checkResult1) {
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
String returnCode = response.get("returnCode");
if ("SUCCESS".equalsIgnoreCase(returnCode)) {
//响应码
String respCode = response.get("returnCode");
if ("SUCCESS".equalsIgnoreCase(respCode)) {
resultType = "1";
} else {
resultType = "2";
}
} else {
resultType = "3";
}
if (!"1".equalsIgnoreCase(resultType)) {
//更新现金事务表ld037失败处理
errorCd = response.get("errCode");
}
}
//数据验签失败
else {
//更新现金事务表ld037失败处理
errorCd = "SIGN_ERROR";
//直接返回前端验签失败信息,重发或者直接告诉前端发送失败
resultType = "4";
}
} catch (Exception e) {
e.printStackTrace();
logger.info("发送请求异常: {} ", e.getMessage());
//更新现金事务表ld037失败处理
errorCd = "SEND_ERROR";
//处理接口日志
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
//请求批次事务表状态更新失败处理
hlsEbankCcbTransaction.setReturnMsg(e.getMessage());
result.put(Constants.RESP_MSG, "发送请求异常:" + e.getMessage());
resultType = "5";
}
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
/*
版本号 version String(5) 是 固定为0.0.1
编码方式 encoding String(20) 是 固定为UTF-8
签名 sign String(1024) 是
签名方法 signMethod String(2) 是 02:SM2
返回码 returnCode String(7) 是 SUCCESS/FAIL,此字段是通信标识,非交易标识,交易是否成功需要查看respCode来判断。SUCCESS表示商户上送的报文符合规范,FAIL表示报文内的字段不符合规范,包括长度超长、非法字符、签名错误等
以下字段仅在returnCode为SUCCESS时返回
商户号 merId String(32) 是 请求报文中的商户号
商户订单号 orderId String(32) 是 请求报文中的商户订单号
响应码 respCode String(10) 是 业务错误码,成功为SUCCESS,失败为FAIL
以下字段仅在returnCode和respCode为SUCCESS时返回
二维码 qrCode String(300) 是
平台订单号 cmbOrderId String(32) 是 招行生成的订单号
订单发送时间 txnTime String(14) 是 订单生成时间,格式为yyyyMMddHHmmss
以下字段仅在returnCode或respCode为FAIL时返回
错误码 errCode String(32) 是 请求处理失败的错误码信息
应答信息 respMsg String(256) 是 请求处理失败的详细描述信息
*/
} catch (Exception e) {
e.printStackTrace();
logger.info("组装请求报文信息失败: {} ", e.getMessage());
//请求批次事务表状态更新失败处理
hlsEbankCcbTransaction.setReturnMsg("组装请求报文信息失败:" + e.getMessage());
result.put(Constants.RESP_MSG, "组装请求报文信息失败:" + e.getMessage());
errorCd = "MESSAGE_ERROR";
resultType = "5";
}
hlsEbankCcbTransaction = setEbankTransaction(hlsEbankCcbTransaction, response, resultType);
hlsEbankCcbTransactionMapper.updateByPrimaryKey(hlsEbankCcbTransaction);
//更新现金事务表ld037失败处理
if (Objects.nonNull(errorCd)) {
updateLd037Fail(ld037, errorCd);
}else {
ld037Mapper.updateByPrimaryKeySelective(ld037);
}
result = putResult(result, response, resultType);
return result;
}
private JSONObject putResult(JSONObject result, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
JSONObject bizContent = new JSONObject();
bizContent = JSONObject.parseObject(response.get("biz_content").toString());
result.put(Constants.RESP_CODE, response.get("returnCode"));
result.put(Constants.RESP_MSG, "请求成功");
//测试环境处理,生产需要还原
result.put("qrcode", bizContent.getString("qrCode").replace("https://qr.95516.com/","http://payment-uat.cs.cmburl.cn/"));
result.put("cmborderid", bizContent.getString("cmbOrderId"));
result.put("txnTime", bizContent.getString("txnTime"));
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, response.get("errCode"));
result.put(Constants.RESP_MSG, response.get("respMsg"));
}
//接口返回失败
else if ("3".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, response.get("errCode"));
result.put(Constants.RESP_MSG, response.get("respMsg"));
}
//验签失败
else if ("4".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, cmbFail);
result.put(Constants.RESP_MSG, "验签失败,请检查!");
}
//组装请求报文信息失败
else if ("5".equalsIgnoreCase(type)) {
result.put(Constants.RESP_CODE, cmbFail);
}
return result;
}
private HlsEbankCcbTransaction setEbankTransaction(HlsEbankCcbTransaction hlsEbankCcbTransaction, Map<String, String> response, String type) {
//接口请求成功
if ("1".equalsIgnoreCase(type)) {
JSONObject bizContent = new JSONObject();
bizContent = JSONObject.parseObject(response.get("biz_content").toString());
hlsEbankCcbTransaction.setStatus(transDeal);
hlsEbankCcbTransaction.setReturnCode(response.get("returnCode"));
hlsEbankCcbTransaction.setReturnMsg("获取二维码成功");
hlsEbankCcbTransaction.setQrCode(bizContent.getString("qrCode"));
hlsEbankCcbTransaction.setCmbOrderId(bizContent.getString("cmbOrderId"));
hlsEbankCcbTransaction.setTxnTime(bizContent.getString("txnTime"));
hlsEbankCcbTransaction.setOrderStatus("0000");
}
//接口返回成功,响应失败
else if ("2".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode(response.get("errCode"));
hlsEbankCcbTransaction.setReturnMsg(response.get("respMsg"));
hlsEbankCcbTransaction.setOrderStatus("0000");
}
//接口返回失败
else if ("3".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode(response.get("errCode"));
hlsEbankCcbTransaction.setReturnMsg(response.get("respMsg"));
hlsEbankCcbTransaction.setOrderStatus("0003");
}
//验签失败
else if ("4".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode("SIGN_ERROR");
hlsEbankCcbTransaction.setReturnMsg("接口请求验签失败");
hlsEbankCcbTransaction.setOrderStatus("0003");
}
//组装请求报文信息失败
else if ("5".equalsIgnoreCase(type)) {
hlsEbankCcbTransaction.setStatus(transFail);
hlsEbankCcbTransaction.setReturnCode("SEND_ERROR");
hlsEbankCcbTransaction.setOrderStatus("0003");
}
return hlsEbankCcbTransaction;
}
private void updateLd037Fail(Ld037 ld037, String errorCd) {
ld037.setErrorcd(errorCd);
ld037Mapper.updateLd037Fail(ld037);
}
//生成招行扫码交易业务批次数据
private HlsEbankCcbTransaction createTransaction(IRequest iRequest, Ld037 ld037) {
HlsEbankCcbTransaction ccbTransaction = new HlsEbankCcbTransaction();
ccbTransaction.setMerId("3089991701201D0");
ccbTransaction.setVersion("0.0.1");
ccbTransaction.setUserId("N003574551");
ccbTransaction.setStatus(transNew);
ccbTransaction.setBankType("CMB");
ccbTransaction.setCount(1L);
ccbTransaction.setAmount(ld037.getAmount());
ccbTransaction.setNewDate(new Date());
ccbTransaction.setCreatedBy(1L);
ccbTransaction.setCreationDate(new Date());
ccbTransaction.setLastUpdatedBy(1L);
ccbTransaction.setTranDate(StringUtil.getRelevantDate(new Date()));
ccbTransaction.setTranTime(StringUtil.getRelevantTime(new Date()));
ccbTransaction.setTranType("APPLY");
hlsEbankCcbTransactionMapper.insert(ccbTransaction);
// //生成单据编号 日期+id
// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
// String dateString = formatter.format(new Date());
// ccbTransaction.setTransactionNumber(dateString + String.format("%08d", ccbTransaction.getTransactionId()));
// ccbTransaction = hlsEbankCcbTransactionService.updateByPrimaryKeySelective(iRequest, ccbTransaction);
return hlsEbankCcbTransactionMapper.selectByPrimaryKey(ccbTransaction);
}
private String getQrRequestParams(HlsEbankCcbTransaction hlsEbankCcbTransaction) {
Map<String, String> requestPublicParams = new TreeMap<>();
String requestStr = null;
try {
//公共请求参数
requestPublicParams.put("version", version); //版本号,固定为0.0.1(必传字段)
requestPublicParams.put("encoding", encoding); //编码方式,固定为UTF-8(必传)
requestPublicParams.put("signMethod", signMethod); //签名方法,固定为02,表示签名方式为国密(必传)
//业务要素
Map<String, String> requestTransactionParams = new HashMap<>();
requestTransactionParams.put("merId", hlsEbankCcbTransaction.getMerId()); //商户号(必传)
requestTransactionParams.put("orderId", hlsEbankCcbTransaction.getTransactionNumber()); //商户订单号(必传)
requestTransactionParams.put("userId", hlsEbankCcbTransaction.getUserId()); //收银员
// requestTransactionParams.put("termId", "00774411"); //终端号
requestTransactionParams.put("payValidTime", "900"); //支付有效时间,默认15分钟
requestTransactionParams.put("notifyUrl", "http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen"); //交易通知地址(必传)
BigDecimal a1 = new BigDecimal(Double.toString(hlsEbankCcbTransaction.getAmount()));
BigDecimal b1 = new BigDecimal(Double.toString(100));
requestTransactionParams.put("txnAmt", a1.multiply(b1).stripTrailingZeros().toPlainString()); //交易金额,单位为分(必传)
requestTransactionParams.put("currencyCode", currencyCode); //交易币种,默认156,目前只支持人民币(156)
// requestTransactionParams.put("body", "聚合支付测试"); //商户号(必传)
//商户保留域
JSONObject mchReserved = new JSONObject();
mchReserved.put("transactionId", hlsEbankCcbTransaction.getTransactionId());
requestTransactionParams.put("tradeScene", "OFFLINE"); //交易场景
ObjectMapper mapper = new ObjectMapper();
requestPublicParams.put("biz_content", mapper.writeValueAsString(requestTransactionParams));
logger.info("收款码申请加签前的报文内容:" + mapper.writeValueAsString(requestPublicParams));
//对待加签内容进行排序拼接
String signContent = SignatureUtil.getSignContent(requestPublicParams);
//加签
requestPublicParams.put("sign", SM2Util.sm2Sign(signContent, privateKey));
requestStr = mapper.writeValueAsString(requestPublicParams);
logger.info("收款码申请加签后的报文内容:" + requestStr);
return requestStr;
} catch (Exception e) {
logger.info("收款码申请加签发生异常:" + e.getMessage());
e.printStackTrace();
return requestStr;
}
}
private Boolean checkSign(String string) {
System.out.println("要验签的报文内容:" + string);
try {
//验签
ObjectMapper objectMapper = new ObjectMapper();
Map<String, String> responseBodyMap = objectMapper.readValue(string, Map.class);
String sign = responseBodyMap.remove("sign");
String contentStr = SignatureUtil.getSignContent(responseBodyMap);
boolean result = SM2Util.sm2Check(contentStr, sign, publicKey);
if (result) {
System.out.println("报文验签成功!");
} else {
System.out.println("报文验签失败!");
}
return result;
} catch (Exception e) {
System.out.println("验签发生异常!");
e.printStackTrace();
return false;
}
}
private Properties loadProp(String propPath) {
Properties props = new Properties();
FileInputStream is = null;
try {
is = new FileInputStream(propPath);
props.load(is);
return props;
} catch (Exception var13) {
LogUtil.writeErrorLog("加载配置文件失败", var13);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException var12) {
;
}
}
}
return null;
}
public HlsWsRequests logInterfaceRequest(String functionName, String url, String request, Long pkValue) {
HlsWsRequests hlsWsRequests = new HlsWsRequests();
hlsWsRequests.setRequestDate(new Date());
hlsWsRequests.setRequestWsdlUrl(url);
hlsWsRequests.setFunctionName(functionName);
String tableName = getTableName(functionName);
hlsWsRequests.setTableName(tableName);
hlsWsRequests.setStatusCode("1");
hlsWsRequests.setStatusDate(new Date());
hlsWsRequests.setPkValue(pkValue);
hlsWsRequests.setRequestClob(request);
hlsWsRequestsMapper.insertSelective(hlsWsRequests);
return hlsWsRequests;
}
private String getTableName(String functionName) {
String tableName = "";
if ("GET_QR_CODE".equalsIgnoreCase(functionName)) {
tableName = "HLS_EBANK_CCB_TRANSACTION";
} else if ("QUERY_PAY_RESULT".equalsIgnoreCase(functionName)) {
tableName = "HLS_EBANK_CMB_QUERY";
}
return tableName;
}
}
package com.cmb.util;
package com.hand.app.cmb.util;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
......
package com.cmb.util;
package com.hand.app.cmb.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......
package com.cmb.util;
package com.hand.app.cmb.util;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
......
package com.cmb.util;
package com.hand.app.cmb.util;
public class Sm2Vo {
......
package com.cmb.util;
package com.hand.app.cmb.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.Map;
import java.util.*;
public class Utils {
......@@ -21,15 +36,16 @@ public class Utils {
}
private static void disableSslVerification() {
try
{
try {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
......@@ -56,13 +72,22 @@ public class Utils {
}
public static Map<String, String> postForEntity(String url,String requestBody, Map<String, String> apiHeader){
public static Map<String, String> postForEntity(String url, String requestBody, Map<String, String> apiHeader) {
RestTemplate client = getRestTemplate();
client.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
List<HttpMessageConverter<?>> httpMessageConverters = client.getMessageConverters();
httpMessageConverters.stream().forEach(httpMessageConverter -> {
if (httpMessageConverter instanceof StringHttpMessageConverter) {
StringHttpMessageConverter messageConverter = (StringHttpMessageConverter) httpMessageConverter;
messageConverter.setDefaultCharset(Charset.forName("UTF-8"));
}
});
HttpHeaders headers = getHttpHeaders();
// 以json的方式提交
headers.setContentType(MediaType.APPLICATION_JSON);
List<Charset> acceptCharset = Collections.singletonList(StandardCharsets.UTF_8);
headers.setAcceptCharset(acceptCharset);
headers.add("appid", apiHeader.get("appid"));
headers.add("timestamp", apiHeader.get("timestamp"));
headers.add("apisign", apiHeader.get("apisign"));
......@@ -70,17 +95,77 @@ public class Utils {
// 将请求头部和参数合成一个请求
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody, headers);
// 执行HTTP请求
Map<String,String> response = client.postForEntity(url,requestEntity,Map.class).getBody();
Map<String, String> response = client.postForEntity(url, requestEntity, Map.class).getBody();
return response;
}
public static RestTemplate getRestTemplate(){
/**
* 向指定URL发送POST方法的请求
*
* @param urls 发送请求的URL
* @param params 请求参数,请求参数应该是 JSON 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static Map<String, String> postString(String urls, String params, Map<String, String> headInfo) {
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(urls);
String result = "";
try {
if (Objects.nonNull(headInfo)) {
for (Map.Entry<String, String> entry : headInfo.entrySet()) {
post.setHeader(entry.getKey(), entry.getValue());
}
}
StringEntity s = new StringEntity(params, "utf-8");
s.setContentEncoding(new BasicHeader("Content-Type", "application/json"));
post.setHeader("Content-Type", "application/json");
post.setEntity(s);
HttpResponse httpResponse = client.execute(post);
InputStream inStream = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
strber.append(line + "\n");
}
inStream.close();
result = strber.toString();
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(result);
return JsonToMap(jsonResult);
} catch (Exception var12) {
var12.printStackTrace();
throw new RuntimeException(var12);
}
}
public static RestTemplate getRestTemplate() {
return new RestTemplate();
}
public static HttpHeaders getHttpHeaders(){
public static HttpHeaders getHttpHeaders() {
return new HttpHeaders();
}
public static Map<String, String> JsonToMap(JSONObject params) {
Map<String, String> paramMap = new HashMap<>();
//循环转换
for (Map.Entry<String, Object> entry : params.entrySet()) {
paramMap.put(entry.getKey(), entry.getValue().toString());
}
return paramMap;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hand.app.cmb.mapper.Ld037Mapper">
<!--获取角色下的模块-->
<resultMap id="AppLd037Map" type="com.hand.app.cmb.dto.Ld037">
<result column="ID" property="id" jdbcType="VARCHAR"/>
<result column="CONTRACTNO" property="contractno" jdbcType="VARCHAR"/>
<result column="TIMES" property="times" jdbcType="DECIMAL"/>
<result column="generatedt" property="generatedt" jdbcType="DATE"/>
<result column="recamtno" property="recamtno" jdbcType="VARCHAR"/>
<result column="recduedt" property="recduedt" jdbcType="DATE"/>
<result column="bankname" property="bankname" jdbcType="VARCHAR"/>
<result column="accountid" property="accountid" jdbcType="VARCHAR"/>
<result column="accountname" property="accountname" jdbcType="VARCHAR"/>
<result column="amount" property="amount" jdbcType="DECIMAL"/>
<result column="filestatus" property="filestatus" jdbcType="VARCHAR"/>
<result column="receiptstatus" property="receiptstatus" jdbcType="VARCHAR"/>
<result column="receiptcfmstatus" property="receiptcfmstatus" jdbcType="VARCHAR"/>
<result column="errorcd" property="errorcd" jdbcType="VARCHAR"/>
<result column="dealercd" property="dealercd" jdbcType="VARCHAR"/>
<result column="branchcd" property="branchcd" jdbcType="VARCHAR"/>
<result column="customercd" property="customercd" jdbcType="VARCHAR"/>
<result column="customername" property="customername" jdbcType="VARCHAR"/>
<result column="outfilename" property="outfilename" jdbcType="VARCHAR"/>
<result column="infilename" property="infilename" jdbcType="VARCHAR"/>
<result column="characterid" property="characterid" jdbcType="VARCHAR"/>
<result column="errormsg" property="errormsg" jdbcType="VARCHAR"/>
<result column="chargeaccountno" property="chargeaccountno" jdbcType="VARCHAR"/>
<result column="actdbtamount" property="actdbtamount" jdbcType="DECIMAL"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="ctino" property="ctino" jdbcType="VARCHAR"/>
<result column="cup_pin" property="cup_pin" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="transaction_id" property="transaction_id" jdbcType="DECIMAL"/>
<result column="num" property="num" jdbcType="DECIMAL"/>
<result column="procdt" property="procdt" jdbcType="DATE"/>
<result column="recdt" property="recdt" jdbcType="DATE"/>
<result column="recbatchdt" property="recbatchdt" jdbcType="DATE"/>
</resultMap>
<update id="updateLd037Fail" parameterType="com.hand.app.cmb.dto.Ld037">
UPDATE LD037 t
SET t.ProcDt = sysdate,
t.RecDt = sysdate,
t.RecBatchDt = sysdate,
t.ReceiptStatus = '0',
t.ReceiptCfmStatus = '1',
t.ERRORMSG = (select h.description from hls_ebank_cmb_recode h where h.code=#{errorcd,jdbcType=VARCHAR}),
t.ErrorCd = #{errorcd,jdbcType=VARCHAR},
t.UPDATEDDT = SYSDATE,
t.UPDATEDPERSON = 'CMB',
t.Actdbtamount = 0,
t.transaction_id = #{transactionId,jdbcType=DECIMAL}
WHERE t.id = #{id,jdbcType=DECIMAL}
</update>
</mapper>
......@@ -140,6 +140,12 @@ face.check.enable=false
#金格电子合同配置文件地址
electronic.signature.path=/Volumes/work/idea/APIconfig
zdw.login.clientKey=04593D186F5AB68871891C235A35ED90E6D5E8DC33414C89E05C29EBF5D19C3919F0D1956568619BA138AC724F4E5DC730266C8186F610D8CC85BFC0748F899695
zdw.login.userName=hclczhongdengwang1
zdw.login.password=zhongdengwang12345
zdw.login.authCode=7b7-f08f197fe2e5
#银联代扣
cup.mer.id=000092112092486
cup.upload.file.path=D:\\HCLC_FTP\\CUP_OUT\\
......@@ -147,7 +153,7 @@ cup.download.file.path=D:\\HCLC_FTP\\CUP_IN\\
cup.init.file.path=F:\\work\\workspace\\IdeaProjects\\hls-support-rlwx\\key\\
cmb.version = 0.0.1
cmb.encoding = UTF-8
cmb.signMethod = 02
cmb.currencyCode = 156
\ No newline at end of file
cmb.version=0.0.1
cmb.encoding=UTF-8
cmb.signMethod=02
cmb.currencyCode=156
\ No newline at end of file
......@@ -19,7 +19,8 @@
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
......@@ -54,7 +55,8 @@
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-cup-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
......@@ -64,6 +66,25 @@
</sift>
</appender>
<appender name="CMB-FILE" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>logName</key>
<defaultValue>default</defaultValue>
</discriminator>
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n
</pattern>
</encoder>
<file>${catalina.base}/logs/hls-cmb-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/%d{yyyy-MM-dd}/hls-cmb-${logName}.log</fileNamePattern>
</rollingPolicy>
</appender>
</sift>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT"/>
......@@ -119,4 +140,7 @@
<logger name="com.chinapay.util.HttpUtils" level="INFO" additivity="false">
<appender-ref ref="CUP-FILE"/>
</logger>
<logger name="com.hand.app.cmb.service.impl.HclcCmbPolyServiceImpl" level="INFO" additivity="false">
<appender-ref ref="CMB-FILE"/>
</logger>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment