通联签约查询

This commit is contained in:
changxuliang 2020-09-09 14:17:03 +08:00
parent 0b164ebb93
commit 0ab0e6f4a1

View File

@ -0,0 +1,105 @@
package com.tenwa.lease.app.allinpay.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.stdagr.QAGRDETAIL;
import com.allinpay.xstruct.stdagr.QAGRRSP;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.lease.app.allinpay.util.AllinpayProperties;
/**
* 通联协议签约查询
*/
public class AllinpaySignService {
public String contractNumber;
public String accountNo;
public Logger logger = Logger.getLogger(this.getClass());
@SuppressWarnings({ "unchecked" })
public String allinPayQuery(JBOTransaction tx) throws Exception {
AllinpayProperties allinpay = new AllinpayProperties();
String message = contractNumber;
try {
BizObjectManager bomLCT = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_TLSIGN", tx);
List<BizObject> boLCTs = bomLCT.createQuery("O.CONTRACT_NUMBER=:contractNumber").setParameter("contractNumber", contractNumber).getResultList(true);
BizObject boLCT;
if(boLCTs==null||boLCTs.size()==0) {
message = "success";
return message;
}
boLCT = boLCTs.get(0);
Map<String,String> mapXml =new HashMap<String, String>();
mapXml.put("accountNo", accountNo);
Map<String, String> map = allinpay.allinPayQuery(mapXml);
String requestContent = map.get("request");
String responseContent = map.get("response");
if (!"success".equals(map.get("message"))) {
logger.info("系统异常或通联反馈异常:" + map.get("msg"));
} else {
message = "success";
AipgRsp rsp = XmlParser.parseRsp(responseContent);
InfoRsp infoRsp = rsp.getINFO();
String status = "sign_status1";//签约失败
if("0000".equals(infoRsp.getRET_CODE())){
QAGRRSP ret = (QAGRRSP)rsp.trxObj();
List<QAGRDETAIL> list = ret.getDetails();
QAGRDETAIL qagrdetail = list.get(0);
if("2".equals(qagrdetail.getSTATUS())) {
// 完成签约
status = "sign_status2";
}else if("1".equals(qagrdetail.getSTATUS())){
// 签约失效
status = "sign_status4";
}
boLCT.setAttributeValue("SIGN_STATUS", status);
boLCT.setAttributeValue("AGRMNO", qagrdetail.getAGRMNO());
boLCT.setAttributeValue("REQUEST_CONTENT", requestContent);
boLCT.setAttributeValue("RESPONSE_CONTENT", responseContent);
}else {
boLCT.setAttributeValue("SIGN_STATUS", status);
boLCT.setAttributeValue("REQUEST_CONTENT", requestContent);
boLCT.setAttributeValue("RESPONSE_CONTENT", responseContent);
}
bomLCT.saveObject(boLCT);
}
} catch (Exception e) {
if (tx != null)
try {
tx.rollback();
} catch (Exception e1) {
e1.printStackTrace();
}
message=contractNumber;
e.printStackTrace();
}
return message;
}
public String getContractNumber() {
return contractNumber;
}
public void setContractNumber(String contractNumber) {
this.contractNumber = contractNumber;
}
public String getAccountNo() {
return accountNo;
}
public void setAccountNo(String accountNo) {
this.accountNo = accountNo;
}
}