From 0ab0e6f4a1cfcbfd0b361319fc53fc51c8579aee Mon Sep 17 00:00:00 2001 From: changxuliang Date: Wed, 9 Sep 2020 14:17:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=81=94=E7=AD=BE=E7=BA=A6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AllinpaySignService.java | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/com/tenwa/lease/app/allinpay/service/impl/AllinpaySignService.java diff --git a/src/com/tenwa/lease/app/allinpay/service/impl/AllinpaySignService.java b/src/com/tenwa/lease/app/allinpay/service/impl/AllinpaySignService.java new file mode 100644 index 000000000..3c0cb1be2 --- /dev/null +++ b/src/com/tenwa/lease/app/allinpay/service/impl/AllinpaySignService.java @@ -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 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 mapXml =new HashMap(); + mapXml.put("accountNo", accountNo); + Map 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 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; + } +}