通联协议扣款

This commit is contained in:
changxuliang 2020-08-31 15:43:45 +08:00
parent 9b6ead085e
commit 5ffdde45f7
8 changed files with 4702 additions and 3884 deletions

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,8 @@ allinPayPathcer=20060400001164504.cer
#通联商户私钥路径(测试) (正式待定)
allinPayPathpfx=allinpay.p12
#通联收款类业务代码(测试)
allinBusinessCode=19900
#通联测试接口地址(测试)
allinPayUrl=https://test.allinpaygd.com/aipg/ProcessServlet
@ -28,5 +30,6 @@ sendMessageUrl=http://127.0.0.1:8081/apzl_leasing/allinpay/sign?method=allinPayS
#短信发送url(正式)
#sendMessageUrl=https://erp.zjmileasing.com/allinpay/sign?method=allinPaySign&con=
#通联文件保存地址
filePath=/data/files/tmp/allinpay/allinpay_{uuid}_{YYYYMMDD}.txt

View File

@ -0,0 +1,31 @@
package com.tenwa.lease.app.allinpay.service.impl;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
public class AllinpayPaymentQueryJob implements Job{
private Logger logger = Logger.getLogger(this.getClass());
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
try {
BizObjectManager manager = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_PAYMENT");
BizObject object = manager.createQuery("O.STATUS='正在处理'").getSingleResult(true);
if(object==null) {
logger.info("没有需要查询的通联卡扣信息");
return;
}
AllinpayPaymentQueryRun run = new AllinpayPaymentQueryRun();
run.run();
} catch (JBOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,251 @@
package com.tenwa.lease.app.allinpay.service.impl;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import com.allinpay.xml.XmlParser;
import com.allinpay.xstruct.common.AipgRsp;
import com.allinpay.xstruct.common.InfoRsp;
import com.allinpay.xstruct.trans.qry.QTDetail;
import com.allinpay.xstruct.trans.qry.QTransRsp;
import com.amarsoft.app.lc.util.DateAssistant;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.tenwa.lease.app.allinpay.util.AllinpayProperties;
import com.tenwa.lease.app.allinpay.util.ConfigConstant;
import com.tenwa.reckon.util.UUIDUtil;
public class AllinpayPaymentQueryRun implements Runnable{
@Override
public void run() {
this.allinpayPaymentQuerySt();
}
private AllinpayProperties allinpay;
private String localFilePath;
private Logger logger = Logger.getLogger(this.getClass());
public AllinpayPaymentQueryRun() {
this.allinpay = new AllinpayProperties();
}
/**
* 分页处理需要进行查询的扣款数据
* @param
* @return
*/
@SuppressWarnings({ "unchecked"})
public void allinpayPaymentQuerySt() {
logger.info(">>>>>>>>>>>开始通联支付结果查询>>>>>>>>");
Map<String, String> sqlMap = new HashMap<String, String>(0);
Map<String, String> mapXml = new HashMap<String, String>();
try {
BizObjectManager bomLCP = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_PAYMENT");
int start = 0;
int maxCount = 100;
List<BizObject> boLOEDs=null;
int size = bomLCP.createQuery("O.STATUS='正在处理' ").getTotalCount();
if (size == 0) {
logger.info("没有需要查询的通联支付信息");
return;
}
while (size > start) {
logger.info("开始第" + start + "" + (start + maxCount) + "次循环");
boLOEDs = bomLCP.createQuery("O.STATUS='正在处理' ").setFirstResult(start).setMaxResults(maxCount).getResultList(true);
if (boLOEDs == null || boLOEDs.size() == 0) {
logger.error("没有需要查询的通联支付信息>>>>>>>>>>:");
break;
}
for (BizObject boLCP : boLOEDs) {
try {
String quertSn= boLCP.getAttribute("REQ_SN").toString();
String num = boLCP.getAttribute("NUM").toString();
localFilePath = boLCP.getAttribute("FULLPATH").toString();
String time = DateAssistant.getTodayNow();
sqlMap.put("QUERYTIME", time);
sqlMap.put("NUM", Integer.parseInt(num) + "");
mapXml.put("quertSn", quertSn);
sqlMap = sendMessageByProxy(mapXml, sqlMap);
if (localFilePath == null) {
LocalDateTime ldt = LocalDateTime.now();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
localFilePath = ConfigConstant.filePath.replaceAll("\\{uuid\\}",UUIDUtil.getUUID()).replaceAll("\\{YYYYMMDD\\}", dtf.format(ldt));
sqlMap.put("FULLPATH", localFilePath);
}
saveRequestTxt(sqlMap);
updateMessage(bomLCP, boLCP, sqlMap);
localFilePath = null;
} catch (Exception e) {
logger.error(">>>>>>>>>>>通联支付结果查询失败>>>>>>>>id:" +boLCP.getAttribute("id").toString());
e.printStackTrace();
}finally {
sqlMap.clear();
mapXml.clear();
}
}
boLOEDs=null;
start +=100;
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>通联支付结果查询失败>>>>>>>>:");
e.printStackTrace();
}
logger.info(">>>>>>>>>>>结束通联支付结果查询>>>>>>>>");
}
/**
* 保存通联返回结果TXT文档
* @param sqlMap
* @return
*/
private void saveRequestTxt(Map<String, String> sqlMap) {
BufferedWriter bw = null;
try {
String fileStr = "通联支付查询请求:" + sqlMap.get("QUERYTIME") + System.getProperty("line.separator");
fileStr += sqlMap.get("REQUEST_CONTENT") + System.getProperty("line.separator");
fileStr += "通联支付查询响应:" + sqlMap.get("QUERYTIME") + System.getProperty("line.separator");
fileStr += sqlMap.get("RESPONSE_CONTENT") + System.getProperty("line.separator");
File file = new File(localFilePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
bw = new BufferedWriter(new FileWriter(localFilePath, true));
bw.write(fileStr);
bw.newLine();
bw.flush();
} catch (Exception e) {
logger.error("文件保存错误" + localFilePath);
e.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 通过代理给通联发送需要查询的扣款数据
* @param mapXmlsqlMap
* @return
*/
@SuppressWarnings("unchecked")
private Map<String, String> sendMessageByProxy(Map<String, String> mapXml, Map<String, String> sqlMap)
throws Exception {
logger.info(">>>>>>>>>>>开始调用代理>>>>>>>>");
Map<String, String> map = new HashMap<String, String>(0);
try {
map = allinpay.allinPaymentQuery(mapXml);
} catch (Exception e) {
logger.error(">>>>>>>>>>>调用代理失败>>>>>>>>>");
e.printStackTrace();
}
logger.info(">>>>>>>>>>>结束调用代理>>>>>>>>");
String requestContent = map.get("request");
sqlMap.put("REQUEST_CONTENT", requestContent);
if (map.size() < 1 || !"success".equals(map.get("message"))) {
logger.error("系统异常或通联反馈异常:" + map.get("msg"));
logger.error("请求报文:" + requestContent);
} else {
String responseContent = map.get("response");
sqlMap.put("RESPONSE_CONTENT", responseContent);
AipgRsp rsp = XmlParser.parseRsp(responseContent);
InfoRsp infoRsp = rsp.getINFO();
if ("|0000|4000|".indexOf(infoRsp.getRET_CODE()) > 0) {
QTransRsp ret = (QTransRsp) rsp.trxObj();
List<QTDetail> list = ret.getDetails();
for (QTDetail qtDetail : list) {
if (qtDetail != null && "|0000|4000|".indexOf(qtDetail.getRET_CODE()) > 0) {
logger.info(">>>>>>>>>>>处理成功>>>>>>>>");
logger.info("请求报文:" + requestContent);
logger.info("响应报文:" + responseContent);
sqlMap.put("FINISH_AMOUNT", new BigDecimal(qtDetail.getAMOUNT()).divide(new BigDecimal(100))
.setScale(2).toPlainString());
String fintime = qtDetail.getFINTIME().trim();
Date date = new SimpleDateFormat("yyyyMMddHHmmss").parse(fintime);
fintime = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(date);
sqlMap.put("FINTIME", fintime);
sqlMap.put("STATUS", "处理成功");
sqlMap.put("SN", qtDetail.getSN());
sqlMap.put("TRXDIR", qtDetail.getTRXDIR());
sqlMap.put("RET_CODE", qtDetail.getRET_CODE());
sqlMap.put("IS_ACCOUNTCHECK", "待对账");
} else {
String errMsg = qtDetail.getERR_MSG();
logger.error(">>>>>>>>>>>处理失败>>>>>>>>errMsg:" + errMsg);
logger.error("请求报文:" + requestContent);
logger.error("响应报文:" + responseContent);
sqlMap.put("STATUS", errMsg);
}
}
} else if ("|1000|1002|2000|2001|2003|2005|2007|2008|".indexOf(infoRsp.getRET_CODE()) > 0) {
logger.info(">>>>>>>>>>>处理中间状态需重新查询>>>>>>>>" + infoRsp.getRET_CODE());
logger.info("请求报文:" + requestContent);
logger.info("响应报文:" + responseContent);
int num = Integer.parseInt(sqlMap.get("NUM"));
if ("1002".equals(infoRsp.getRET_CODE())) {
//如果一直返回1002状态到达6次则此笔扣款失败
if (num > 6) {
sqlMap.put("STATUS", infoRsp.getERR_MSG());
}
sqlMap.put("RET_CODE", infoRsp.getRET_CODE());
sqlMap.put("NUM", num + 1 + "");
} else {
sqlMap.put("RET_CODE", infoRsp.getRET_CODE());
}
} else {
String errMsg = infoRsp.getERR_MSG();
logger.error(">>>>>>>>>>>处理失败>>>>>>>>errMsg:" + errMsg);
logger.error("请求报文:" + requestContent);
logger.error("响应报文:" + responseContent);
sqlMap.put("STATUS", errMsg);
}
}
return sqlMap;
}
/**
* 修改通联扣款数据汇总表
* @param map
* @return Exception
*/
private void updateMessage(BizObjectManager bomLCP, BizObject boLCP, Map<String, String> sqlMap) throws Exception {
Set<String> keySet = sqlMap.keySet();
for (String key : keySet) {
if ("|REQUEST_CONTENT|RESPONSE_CONTENT|".indexOf(key) > 0) {
continue;
}
boLCP.setAttributeValue(key, sqlMap.get(key));
}
bomLCP.saveObject(boLCP);
}
}

View File

@ -0,0 +1,225 @@
package com.tenwa.lease.app.allinpay.service.impl;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import com.allinpay.xml.XmlParser;
import com.allinpay.xstruct.common.AipgRsp;
import com.allinpay.xstruct.common.InfoRsp;
import com.allinpay.xstruct.quickpay.FASTTRXRET;
import com.amarsoft.app.lc.util.DateAssistant;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.tenwa.lease.app.allinpay.util.AllinpayProperties;
import com.tenwa.lease.app.allinpay.util.ConfigConstant;
import com.tenwa.reckon.util.UUIDUtil;
public class AllinpayPaymentRun implements Runnable {
private List<Map<String, String>> list;
private String localFilePath;
private AllinpayProperties allinpay;
private Logger logger = Logger.getLogger(this.getClass());
public AllinpayPaymentRun(List<Map<String, String>> list) {
this.allinpay = new AllinpayProperties();
this.list=list;
}
@Override
public void run() {
if(list==null||list.size()==0) {
logger.info(">>>>>>>>>>>没有需要扣款的通联卡扣信息>>>>>>>>");
return;
}
allinpayPayment();
}
private void allinpayPayment() {
logger.info(">>>>>>>>>>>通联卡扣协议支付开始执行>>>>>>>>");
Map<String, String> sqlMap = new HashMap<String, String>(0);
Map<String, String> mapXml = new HashMap<>();
try {
String time = DateAssistant.getTodayNow();
for (Map<String, String> map : list) {
try {
BizObject result = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_TLSIGN").createQuery("O.CONTRACT_NUMBER=:contractNumber and SIGN_STATUS='sign_status2'").setParameter("contractNumber", map.get("CONTRACT_NUMBER")).getSingleResult(false);
logger.info(">>>>>>>>>>>通联卡扣协议支付>>>>>>>>CONTRACT_NUMBER=" + map.get("CONTRACT_NUMBER"));
sqlMap.put("SUBMITTIME", time);
sqlMap.put("AGRMNO", result.getAttribute("AGRMNO").toString());
sqlMap.put("START_AMOUNT", map.get("AMOUNT"));
sqlMap.put("ACCOUNT_NAME", map.get("ACCOUNT_NAME"));
sqlMap.put("CONTRACT_NUMBER", map.get("CONTRACT_NUMBER"));
sqlMap.put("UUID", map.get("UUID"));
mapXml.put("AGRMNO", result.getAttribute("AGRMNO").toString());
mapXml.put("ACCOUNT_NAME", map.get("ACCOUNT_NAME"));
mapXml.put("AMOUNT", new BigDecimal(map.get("AMOUNT")).multiply(new BigDecimal("100"))
.stripTrailingZeros().toPlainString());
mapXml.put("CONTRACT_NUMBER", sqlMap.get("CONTRACT_NUMBER"));
mapXml.put("CUST_USERID", sqlMap.get("CONTRACT_NUMBER"));
sqlMap = sendMessageByProxy(mapXml, sqlMap);
saveRequestTxt(sqlMap);
sqlMap.put("FULLPATH", localFilePath);
saveMessage(sqlMap);
} catch (Exception e) {
logger.error(">>>>>>>>>>>通联卡扣协议支付失败>>>>>>>>");
e.printStackTrace();
}finally {
sqlMap.clear();
mapXml.clear();
}
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>通联卡扣协议支付失败>>>>>>>>");
e.printStackTrace();
}
logger.info(">>>>>>>>>>>通联卡扣协议支付执行结束>>>>>>>>");
}
/**
* 通过代理给通联发送需要扣款的数据
* @param
* @return
*/
private Map<String, String> sendMessageByProxy(Map<String, String> mapXml, Map<String, String> sqlMap)
throws Exception {
logger.info(">>>>>>>>>>>开始调用代理>>>>>>>>");
Map<String, String> map = new HashMap<String, String>(0);
try {
map = allinpay.allinPayment(mapXml);
} catch (Exception e) {
logger.error(">>>>>>>>>>>调用代理失败>>>>>>>>>");
e.printStackTrace();
}
logger.info(">>>>>>>>>>>结束调用代理>>>>>>>>");
String requestContent = map.get("request");
if (map.size() < 1 || !"success".equals(map.get("message"))) {
logger.error("系统异常或通联反馈异常:" + map.get("msg"));
logger.error("请求报文:" + requestContent);
sqlMap.put("REQUEST_CONTENT", requestContent);
String reqSn = map.get("reqSn");
if (reqSn == null) {
sqlMap.put("STATUS", "系统异常或通联反馈异常");
} else {
//对于没有反馈的通联扣款信息给与正在处理
sqlMap.put("REQ_SN", reqSn);
sqlMap.put("STATUS", "正在处理");
}
} else {
String responseContent = map.get("response");
sqlMap.put("REQUEST_CONTENT", requestContent);
sqlMap.put("RESPONSE_CONTENT", responseContent);
AipgRsp rsp = XmlParser.parseRsp(responseContent);
InfoRsp infoRsp = rsp.getINFO();
if ("|0000|2000|2001|2003|2005|2007|2008|1108|1000|".indexOf(infoRsp.getRET_CODE()) > 0) {
FASTTRXRET ret = (FASTTRXRET) rsp.trxObj();
if (ret == null || "|0000|2000|2007|2008|".indexOf(ret.getRET_CODE()) > 0) {
logger.info(">>>>>>>>>>>处理成功>>>>>>>>");
logger.info("请求报文:" + requestContent);
logger.info("响应报文:" + responseContent);
String reqSn = infoRsp.getREQ_SN();
sqlMap.put("REQ_SN", reqSn);
sqlMap.put("STATUS", "正在处理");
} else {
String errMsg = ret.getERR_MSG();
String reqSn = infoRsp.getREQ_SN();
logger.error(">>>>>>>>>>>处理失败>>>>>>>>errMsg:" + errMsg);
logger.error("请求报文:" + requestContent);
logger.error("响应报文:" + responseContent);
sqlMap.put("REQ_SN", reqSn);
sqlMap.put("STATUS", errMsg);
}
} else {
String errMsg = infoRsp.getERR_MSG();
logger.error(">>>>>>>>>>>处理失败>>>>>>>>errMsg:" + errMsg);
logger.error("请求报文:" + requestContent);
logger.error("响应报文:" + responseContent);
sqlMap.put("STATUS", errMsg);
}
}
return sqlMap;
}
/**
* 保存通联返回结果TXT文档
* @param map
* @return
*/
private void saveRequestTxt(Map<String, String> sqlMap) {
BufferedWriter bw = null;
LocalDateTime ldt = LocalDateTime.now();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
try {
if (localFilePath == null) {
localFilePath = ConfigConstant.filePath.replaceAll("\\{uuid\\}",UUIDUtil.getUUID()).replaceAll("\\{YYYYMMDD\\}", dtf.format(ldt));
}
String fileStr = "通联支付请求:" + sqlMap.get("SUBMITTIME") + System.getProperty("line.separator");
fileStr += sqlMap.get("REQUEST_CONTENT") + System.getProperty("line.separator");
fileStr += "通联支付响应:" + sqlMap.get("SUBMITTIME") + System.getProperty("line.separator");
fileStr += sqlMap.get("RESPONSE_CONTENT") + System.getProperty("line.separator");
File file = new File(localFilePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
bw = new BufferedWriter(new FileWriter(file, true));
bw.write(fileStr);
bw.newLine();
bw.flush();
} catch (Exception e) {
logger.error("文件保存错误" + localFilePath);
e.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 初始化通联扣款数据汇总表
* @param map
* @return Exception
*/
private void saveMessage(Map<String, String> map) throws Exception {
try {
BizObjectManager bomLCP = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_PAYMENT");
BizObject boLCP = bomLCP.newObject();
Set<String> keySet = map.keySet();
for (String key : keySet) {
if ("|REQUEST_CONTENT|RESPONSE_CONTENT|".indexOf(key) > 0) {
continue;
}
boLCP.setAttributeValue(key, map.get(key));
}
boLCP.setAttributeValue("NUM", "0");
bomLCP.saveObject(boLCP);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -116,4 +116,173 @@ public class AllinpayProperties {
return map;
}
/**
* 通联卡扣快捷协议查询(单个查询)
*
* @param mapXml
* @return
*/
public Map<String, String> allinPayQuery(Map<String, String> mapXml) {
logger.info("开始调用通联卡扣快捷协议查询接口");
Map<String, String> map = new HashMap<>();
map.put("message", "error");
try {
InfoReq infoReq = DemoUtil.makeReq("340009", ConfigConstant.allinPayMerchantId, ConfigConstant.allinPayUsername, ConfigConstant.allinPayUserpass);
QAGRINFO qagrInfo = new QAGRINFO();
qagrInfo.setACCOUNT_NO(mapXml.get("accountNo"));
qagrInfo.setMERCHANT_ID(ConfigConstant.allinPayMerchantId);
qagrInfo.setAGRTYPE("01");
qagrInfo.setQUERY_MODE("3");
AipgReq aipgReq = new AipgReq();
aipgReq.setINFO(infoReq);
aipgReq.addTrx(qagrInfo);
String xml = XmlParser.toXml(aipgReq);
String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
String signedXml = DemoUtil.buildSignedXml(xml, path + ConfigConstant.allinPayPathpfx, ConfigConstant.allinPayPfxpass);
String url = ConfigConstant.allinPayUrl + "?MERCHANT_ID=" + ConfigConstant.allinPayMerchantId + "&REQ_SN=" + infoReq.getREQ_SN();
String requestContent = signedXml + url;
map.put("request", requestContent);
logger.info("通联请求>>>>>>>>>>>" + signedXml);
logger.info("通联请求地址>>>>>>>>>>>" + url);
String respText = HttpUtil.post(signedXml, url);
logger.info("通联响应>>>>>>>>>>>" + respText);
map.put("response", respText);
map.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
map.put("msg", e.getMessage());
logger.error("调用通联卡扣快捷协议查询接口失败,系统异常或通联反馈异常:" + e.getMessage());
}
logger.info("结束调用通联卡扣快捷协议查询接口");
return map;
}
/**
* 通联卡扣协议支付(单笔)
*
* @param mapXml
* @return
*/
public Map<String, String> allinPayment(Map<String, String> mapXml) {
logger.info("开始调用通联卡扣协议支付接口");
Map<String, String> map = new HashMap<>();
map.put("message", "error");
try {
InfoReq infoReq = DemoUtil.makeReq("310011", ConfigConstant.allinPayMerchantId, ConfigConstant.allinPayUsername, ConfigConstant.allinPayUserpass);
FASTTRX ft = new FASTTRX();
ft.setMERCHANT_ID(ConfigConstant.allinPayMerchantId);
ft.setBUSINESS_CODE(ConfigConstant.allinBusinessCode);// 测试为19900 正是环境为10702
ft.setSUBMIT_TIME(DemoUtil.getNow());
ft.setAGRMNO(mapXml.get("AGRMNO").toString());//支付协议号
ft.setACCOUNT_NAME(mapXml.get("ACCOUNT_NAME"));//账户姓名
ft.setAMOUNT(mapXml.get("AMOUNT").toString()); //金额单位为分
ft.setREMARK(mapXml.get("CONTRACT_NUMBER").toString());//备注
ft.setCUST_USERID(mapXml.get("CUST_USERID").toString());//备注
AipgReq aipgReq = new AipgReq();
aipgReq.setINFO(infoReq);
aipgReq.addTrx(ft);
String xml = XmlParser.toXml(aipgReq);
String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
String signedXml = DemoUtil.buildSignedXml(xml, path + ConfigConstant.allinPayPathpfx, ConfigConstant.allinPayPfxpass);
String url = ConfigConstant.allinPayUrl + "?MERCHANT_ID=" + ConfigConstant.allinPayMerchantId + "&REQ_SN=" + infoReq.getREQ_SN();
String requestContent = signedXml + url;
map.put("request", requestContent);
String reqSn = infoReq.getREQ_SN();
map.put("reqSn", reqSn);
logger.info("通联请求>>>>>>>>>>>" + signedXml);
logger.info("通联请求地址>>>>>>>>>>>" + url);
String respText = HttpUtil.post(signedXml, url);
logger.info("通联响应>>>>>>>>>>>" + respText);
map.put("response", respText);
map.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
map.put("msg", e.getMessage());
logger.error("调用通联卡扣协议支付接口失败,系统异常或通联反馈异常:" + e.getMessage());
}
logger.info("结束调用通联卡扣协议支付接口");
return map;
}
/**
* 通联卡扣交易查询
*
* @param mapXml
* @return
*/
public Map<String, String> allinPaymentQuery(Map<String, String> mapXml) {
logger.info("开始调用通联卡扣交易查询接口");
Map<String, String> map = new HashMap<>();
map.put("message", "error");
try {
InfoReq infoReq = DemoUtil.makeReq("200004", ConfigConstant.allinPayMerchantId, ConfigConstant.allinPayUsername, ConfigConstant.allinPayUserpass);
TransQueryReq queryReq = new TransQueryReq();
queryReq.setQUERY_SN(mapXml.get("quertSn"));//支付时的流水
queryReq.setMERCHANT_ID(ConfigConstant.allinPayMerchantId);
AipgReq aipgReq = new AipgReq();
aipgReq.setINFO(infoReq);
aipgReq.addTrx(queryReq);
String xml = XmlParser.toXml(aipgReq);
String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
String signedXml = DemoUtil.buildSignedXml(xml, path + ConfigConstant.allinPayPathpfx, ConfigConstant.allinPayPfxpass);
String url = ConfigConstant.allinPayUrl + "?MERCHANT_ID=" + ConfigConstant.allinPayMerchantId + "&REQ_SN=" + infoReq.getREQ_SN();
String requestContent = signedXml + url;
map.put("request", requestContent);
logger.info("通联请求>>>>>>>>>>>" + signedXml);
logger.info("通联请求地址>>>>>>>>>>>" + url);
String respText = HttpUtil.post(signedXml, url);
logger.info("通联响应>>>>>>>>>>>" + respText);
map.put("response", respText);
map.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
map.put("msg", e.getMessage());
logger.error("调用通联卡扣交易查询接口失败,系统异常或通联反馈异常:" + e.getMessage());
}
logger.info("结束调用通联卡扣交易查询接口");
return map;
}
/**
* 通联卡扣对账文件下载
*
* @param settday需要查询的日期格式20180911只能查询40天之内的数据
* @return
*/
public Map<String, String> allinReconciliationFileDownload(String settday) {
logger.info("开始调用通联卡扣简单对账接口");
Map<String, String> map = new HashMap<>();
map.put("message", "error");
Provider prvd = null;
String url = ConfigConstant.allinUrlFileGet;
String reqtime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
String contfee = "1";
String sign = "";
contfee = settday + "|" + reqtime + "|" + ConfigConstant.allinPayMerchantId;
String fileSt = "";
try {
AIPGSignature signature = new AIPGSignature(prvd);
String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
sign = signature.signMsg(contfee, path + ConfigConstant.allinPayPathpfx, ConfigConstant.allinPayPfxpass);
url = url.replaceAll("@xxx", settday).replaceAll("@yyy", reqtime).replaceAll("@zzz", ConfigConstant.allinPayMerchantId)
.replaceAll("@sss", sign);
logger.info("通联请求地址>>>>>>>>>>>" + url);
fileSt = HttpUtil.post("", url);
map.put("msg",fileSt);
map.put("message","success");
} catch (Exception e) {
logger.error("调用通联卡扣简单对账接口失败,系统异常或通联反馈异常:" + e.getMessage());
e.printStackTrace();
map.put("msg", e.getMessage());
return map;
}
logger.info("结束调用通联卡扣简单对账接口");
return map;
}
}

View File

@ -31,6 +31,12 @@ public class ConfigConstant {
// 通联测试接口地址
public final static String allinPayUrl;
// 通联对账文件的接口地址
public final static String allinUrlFileGet;
// 通联收款类业务代码
public final static String allinBusinessCode;
//用户点击url
public final static String sendMessageUrl;
@ -52,6 +58,8 @@ public class ConfigConstant {
allinPayPathcer = prop.getProperty("allinPayPathcer");
allinPayPathpfx = prop.getProperty("allinPayPathpfx");
allinPayUrl = prop.getProperty("allinPayUrl");
allinUrlFileGet = prop.getProperty("allinUrlFileGet");
allinBusinessCode = prop.getProperty("allinBusinessCode");
sendMessageUrl = prop.getProperty("sendMessageUrl");
filePath = prop.getProperty("filePath");
}

View File

@ -0,0 +1,100 @@
package jbo.app.tenwa.calc;
import java.lang.String;
/**
* 通联卡扣信息表 - JBO命名常量类<br><br>
* Note: This file is generated by ADE tools, <em>dont</em> modify it.<br>
*/
public interface LC_CARD_PAYMENT{
/**
* 通联卡扣信息表<br><br>
* 代表本类映射的BizObjectClass
*/
public static final String CLASS_NAME = "jbo.app.tenwa.calc.LC_CARD_PAYMENT";
/**
* 标识 STRING(20)<br>
*/
public static final String ID = "ID";
/**
* 合同号 STRING(20)<br>
*/
public static final String CONTRACT_NUMBER = "CONTRACT_NUMBER";
/**
* 扣款状态 STRING(20)<br>
*/
public static final String STATUS = "STATUS";
/**
* 发起扣款时间 STRING(20)<br>
*/
public static final String SUBMITTIME = "SUBMITTIME";
/**
* 扣款时间 STRING(20)<br>
*/
public static final String FINTIME = "FINTIME";
/**
* 协议号 STRING(20)<br>
*/
public static final String AGRMNO = "AGRMNO";
/**
* 交易流水 STRING(20)<br>
*/
public static final String REQ_SN = "REQ_SN";
/**
* 账户名 STRING(20)<br>
*/
public static final String ACCOUNT_NAME = "ACCOUNT_NAME";
/**
* 发起的交易金额 STRING(20)<br>
*/
public static final String START_AMOUNT = "START_AMOUNT";
/**
* 最终的交易金额 STRING(20)<br>
*/
public static final String FINISH_AMOUNT = "FINISH_AMOUNT";
/**
* 备注 STRING(20)<br>
*/
public static final String REMARK = "REMARK";
/**
* 查询扣款时间 STRING(20)<br>
*/
public static final String QUERYTIME = "QUERYTIME";
/**
* 查询次数 STRING(20)<br>
*/
public static final String NUM = "NUM";
/**
* 文件路径 STRING(20)<br>
*/
public static final String FULLPATH = "FULLPATH";
/**
* 外键 STRING(20)<br>
*/
public static final String ACCOUNTCHECK_ID = "ACCOUNTCHECK_ID";
/**
* 交易序号 STRING(20)<br>
*/
public static final String SN = "SN";
/**
* 交易方向 STRING(20)<br>
*/
public static final String TRXDIR = "TRXDIR";
/**
* 返回码 STRING(20)<br>
*/
public static final String RET_CODE = "RET_CODE";
/**
* 是否对账 STRING(20)<br>
*/
public static final String IS_ACCOUNTCHECK = "IS_ACCOUNTCHECK";
/**
* 对账失败原因 STRING(20)<br>
*/
public static final String REASON = "REASON";
/**
* 扣款批次号 STRING(20)<br>
*/
public static final String UUID = "UUID";
}