1.通联卡扣
This commit is contained in:
parent
ac2a4fef94
commit
f4b8687566
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
||||
#安鹏国际融资租赁(深圳)有限公司(SZ)
|
||||
#通联商户号 (测试) (正式待定)
|
||||
SZ_allinPayMerchantId=200604000011645
|
||||
SZ_allinPayMerchantId= 200604000011814
|
||||
|
||||
#通联用户名(测试) (正式待定)
|
||||
SZ_allinPayUsername=20060400001164504
|
||||
SZ_allinPayUsername= 20060400001181404
|
||||
|
||||
#通联用户密码 (测试) (正式待定)
|
||||
SZ_allinPayUserpass=111111
|
||||
|
||||
@ -0,0 +1,112 @@
|
||||
package com.tenwa.lease.app.allinpay.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
||||
import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN;
|
||||
import jbo.sys.CODE_LIBRARY;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.BizObjectManager;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
|
||||
|
||||
public class AllinpayPaymentDo {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 批量代收-发送请求
|
||||
* @param tx
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String batchCollectManage(JBOTransaction tx) throws Exception{
|
||||
|
||||
String[] ids = id.split("@");
|
||||
StringBuffer parms = new StringBuffer();
|
||||
for (String str : ids) {
|
||||
if (parms.length()==0) {
|
||||
parms.append("'"+str+"'");
|
||||
}else{
|
||||
parms.append(",'"+str+"'");
|
||||
}
|
||||
}
|
||||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
|
||||
List<BizObject> bolist = bm.createQuery("select distinct O.contract_id,O.project_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and O.id in ("+parms.toString()+")").getResultList(false);
|
||||
if (bolist.size() != 0) {
|
||||
BatchCollectMoeny(tx, bolist);
|
||||
}
|
||||
return "系统正在处理中,请稍后";
|
||||
}
|
||||
|
||||
public void BatchCollectMoeny(JBOTransaction tx,List<BizObject> bolist) throws JBOException{
|
||||
ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
||||
for(BizObject bo : bolist){
|
||||
String projectId = bo.getAttribute("project_id").toString();
|
||||
String accountName = bo.getAttribute("account").toString();
|
||||
String bankName = bo.getAttribute("BANK_NAME").toString();
|
||||
String rent = bo.getAttribute("rent").toString();
|
||||
String uuid = bo.getAttribute("id").toString();
|
||||
BigDecimal rentTotal = new BigDecimal(rent);
|
||||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'collect_limit'").getResultList(false);
|
||||
BigDecimal limitMoney = new BigDecimal("0");
|
||||
boolean flag = false;
|
||||
for(BizObject bocl : codelist){
|
||||
String limitBankName = bocl.getAttribute("itemname").getString();
|
||||
if(bankName.indexOf(limitBankName)!=-1){
|
||||
limitMoney = new BigDecimal(bocl.getAttribute("attribute1").getString());
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(flag&&rentTotal.compareTo(limitMoney)==1){
|
||||
int rent_int = rentTotal.multiply(new BigDecimal("100")).intValue();
|
||||
int limit_int = limitMoney.multiply(new BigDecimal("100")).intValue();
|
||||
int rent_count = rent_int/limit_int;
|
||||
int i=1;
|
||||
for(;i<=rent_count;i++){
|
||||
uuid=String.format(uuid+"-"+"%03d",i);
|
||||
Map<String, String> boMap = new HashMap<String, String>();
|
||||
boMap.put("PROJECT_ID", projectId);
|
||||
boMap.put("ACCOUNT_NAME", accountName);
|
||||
boMap.put("AMOUNT", limitMoney.toString());
|
||||
boMap.put("UUID", uuid);
|
||||
list.add(boMap);
|
||||
}
|
||||
int rent_end = rent_int%limit_int;
|
||||
if(rent_end!=0){
|
||||
i++;
|
||||
uuid=String.format(uuid+"-"+"%03d",i);
|
||||
Map<String, String> boMap = new HashMap<String, String>();
|
||||
boMap.put("PROJECT_ID", projectId);
|
||||
boMap.put("ACCOUNT_NAME", accountName);
|
||||
boMap.put("AMOUNT", new BigDecimal(rent_end).divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||||
boMap.put("UUID", uuid);
|
||||
list.add(boMap);
|
||||
}
|
||||
}else{
|
||||
Map<String, String> boMap = new HashMap<String, String>();
|
||||
boMap.put("PROJECT_ID", projectId);
|
||||
boMap.put("ACCOUNT_NAME", accountName);
|
||||
boMap.put("AMOUNT", rent);
|
||||
boMap.put("UUID", uuid);
|
||||
list.add(boMap);
|
||||
}
|
||||
}
|
||||
AllinpayPaymentRun run = new AllinpayPaymentRun(list);
|
||||
new Thread(run).start();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@ -1,254 +1,368 @@
|
||||
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() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页处理需要进行查询的扣款数据
|
||||
* @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 {
|
||||
BizObject object = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.LB_PROJECT_INFO").createQuery("O.id=:id").setParameter("id", boLCP.getAttribute("PROJECT_ID").toString()).getSingleResult(false);
|
||||
|
||||
allinpay = new AllinpayProperties(object.getAttribute("subjectid").toString());
|
||||
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 mapXml,sqlMap
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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.DecimalFormat;
|
||||
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 jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG;
|
||||
|
||||
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.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.are.util.StringFunction;
|
||||
import com.amarsoft.awe.util.ASResultSet;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
|
||||
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() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页处理需要进行查询的扣款数据
|
||||
* @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 {
|
||||
|
||||
BizObject object = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.LB_PROJECT_INFO").createQuery("O.id=:id").setParameter("id", boLCP.getAttribute("PROJECT_ID").toString()).getSingleResult(false);
|
||||
|
||||
allinpay = new AllinpayProperties(object.getAttribute("subjectid").toString());
|
||||
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);
|
||||
|
||||
Transaction Sqlca =null;
|
||||
ASResultSet rs = null;
|
||||
Sqlca = Transaction.createTransaction("als");
|
||||
JBOTransaction tx = Sqlca.getTransaction();
|
||||
BizObjectManager bomLRP = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_RENT_PLAN",tx);
|
||||
boolean partFlag = false;
|
||||
String plan_id = boLCP.getAttribute("UUID").toString();
|
||||
String sn = "";
|
||||
String finishAmount= "0.00";
|
||||
if(plan_id.indexOf("-")!=-1){
|
||||
plan_id = plan_id.substring(0, plan_id.indexOf("-"));
|
||||
sn = plan_id.substring(plan_id.length()-3);
|
||||
partFlag = true;
|
||||
}
|
||||
BizObject boLRP = bomLRP.createQuery("id=:id").setParameter("id", plan_id).getSingleResult(true);
|
||||
String batchStatus = boLRP.getAttribute("batch_status")==null?"":boLRP.getAttribute("batch_status").toString();
|
||||
String collectStatus = boLRP.getAttribute("batch_status")==null?"":boLRP.getAttribute("collect_status").toString();
|
||||
String collectMsg = boLRP.getAttribute("batch_status")==null?"":boLRP.getAttribute("collect_msg").toString();
|
||||
boolean status = false;
|
||||
|
||||
if("处理成功".equals(sqlMap.get("STATUS"))){
|
||||
//添加实收表的插入
|
||||
finishAmount = sqlMap.get("FINISH_AMOUNT");
|
||||
try {
|
||||
String ln_contract_id = boLRP.getAttribute("contract_id").toString();
|
||||
String ln_plan_date = boLRP.getAttribute("plan_date").toString();
|
||||
String in_rent = sqlMap.get("FINISH_AMOUNT");
|
||||
String in_hire_list = boLRP.getAttribute("plan_list").toString();
|
||||
String in_type = "2";
|
||||
String SQL="{call proc_insert_hexiao('"+ln_contract_id+"','"+ln_plan_date+"','"+in_rent+"','"+in_hire_list+"','"+in_type+"')}";
|
||||
SqlObject asql = new SqlObject(SQL);
|
||||
rs = Sqlca.getASResultSet(asql);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(rs != null) rs.close();
|
||||
if(Sqlca!=null)Sqlca.commit();
|
||||
}
|
||||
// 代偿红冲处理
|
||||
CollectAuditInfoCache caic = new CollectAuditInfoCache();
|
||||
caic.writeBackDistributor(plan_id, finishAmount, Sqlca);
|
||||
//租金计划表状态处理
|
||||
if(partFlag){
|
||||
BizObjectManager bomVRC = JBOFactory.getBizObjectManager("jbo.loan.VI_RENT_COLLECT",tx);
|
||||
BizObject vrc = bomVRC.createQuery("id=:id").setParameter("id", plan_id).getSingleResult(false);
|
||||
double rentOver = vrc.getAttribute("rent_over").getDouble();
|
||||
double penaltyOver = vrc.getAttribute("penalty_over").getDouble();
|
||||
if(rentOver>0 || penaltyOver>0){
|
||||
batchStatus = "complete";
|
||||
collectStatus = "部分收款";
|
||||
collectMsg = "通联收款";
|
||||
}
|
||||
}else{
|
||||
batchStatus = "complete";
|
||||
collectStatus = "批量收款";
|
||||
collectMsg = "批量收款,通联收款";
|
||||
}
|
||||
}else{
|
||||
String retStatus = sqlMap.get("RET_STATUS");
|
||||
//扣款失败
|
||||
if("5000".equals(retStatus)){
|
||||
batchStatus = "complete";
|
||||
collectMsg = sqlMap.get("STATUS");
|
||||
//银行正在处理中
|
||||
}else if("1000".equals(retStatus)){
|
||||
status = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//保存状态到日志表
|
||||
if(!status){
|
||||
boLRP.setAttributeValue("batch_status", batchStatus);
|
||||
boLRP.setAttributeValue("collect_status", collectStatus);
|
||||
boLRP.setAttributeValue("collect_msg", collectMsg);
|
||||
bomLRP.saveObject(boLRP);
|
||||
saveBuckle(boLRP,tx,sn,finishAmount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 mapXml,sqlMap
|
||||
* @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) {
|
||||
sqlMap.put("RET_STATUS", "0000");
|
||||
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) {
|
||||
sqlMap.put("RET_STATUS", "1000");
|
||||
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 {
|
||||
sqlMap.put("RET_STATUS", "5000");
|
||||
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);
|
||||
}
|
||||
public void saveBuckle(BizObject bo,JBOTransaction tx,String sn,String rent) throws JBOException{
|
||||
BizObjectManager blog = JBOFactory.getBizObjectManager(LB_BUCKLE_LOG.CLASS_NAME, tx);
|
||||
BizObject blbo = blog.newObject();
|
||||
String collect = bo.getAttribute("COLLECT_STATUS").getString();
|
||||
if(collect!=""){
|
||||
blbo.setAttributeValue("COLLECT_STATUS", bo.getAttribute("COLLECT_STATUS").getString());
|
||||
blbo.setAttributeValue("COLLECT_MSG", bo.getAttribute("COLLECT_MSG").getString());
|
||||
blbo.setAttributeValue("BATCH_STATUS", bo.getAttribute("BATCH_STATUS").getString());
|
||||
}
|
||||
DecimalFormat format = new DecimalFormat("0.00");
|
||||
rent = format.format(new BigDecimal(rent ));
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_SN, "TL");
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_NO, sn);
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.RENT_ID, bo.getAttribute("ID").getString());
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.cut_money,rent);
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.inputuserid, "syetem");
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.inputorgid, "system");
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.inputtime, StringFunction.getTodayNow());
|
||||
blbo.setAttributeValue(LB_BUCKLE_LOG.updatetime, System.currentTimeMillis());
|
||||
blog.saveObject(blbo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,228 +1,234 @@
|
||||
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.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 object = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.LB_PROJECT_INFO").createQuery("O.id=:id").setParameter("id", map.get("PROJECT_ID")).getSingleResult(false);
|
||||
allinpay = new AllinpayProperties(object.getAttribute("subjectid").toString());
|
||||
|
||||
BizObject result = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_TLSIGN").createQuery("O.PROJECT_ID=:projectId and SIGN_STATUS='sign_status2'").setParameter("projectId", map.get("PROJECT_ID")).getSingleResult(false);
|
||||
|
||||
logger.info(">>>>>>>>>>>通联卡扣协议支付>>>>>>>>PROJECT_ID=" + map.get("PROJECT_ID"));
|
||||
|
||||
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("PROJECT_ID", map.get("PROJECT_ID"));
|
||||
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("PROJECT_ID", sqlMap.get("PROJECT_ID"));
|
||||
mapXml.put("CUST_USERID", sqlMap.get("PROJECT_ID"));
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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.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 object = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.LB_PROJECT_INFO").createQuery("O.id=:id").setParameter("id", map.get("PROJECT_ID")).getSingleResult(false);
|
||||
allinpay = new AllinpayProperties(object.getAttribute("subjectid").toString());
|
||||
|
||||
BizObject result = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_CARD_TLSIGN").createQuery("O.PROJECT_ID=:projectId and SIGN_STATUS='sign_status2'").setParameter("projectId", map.get("PROJECT_ID")).getSingleResult(false);
|
||||
|
||||
logger.info(">>>>>>>>>>>通联卡扣协议支付>>>>>>>>PROJECT_ID=" + map.get("PROJECT_ID"));
|
||||
|
||||
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("PROJECT_ID", map.get("PROJECT_ID"));
|
||||
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("PROJECT_ID", sqlMap.get("PROJECT_ID"));
|
||||
mapXml.put("CUST_USERID", sqlMap.get("PROJECT_ID"));
|
||||
sqlMap = sendMessageByProxy(mapXml, sqlMap);
|
||||
if("正在处理".equals(sqlMap.get("STATUS"))){
|
||||
BizObjectManager bomLRP = JBOFactory.getBizObjectManager("jbo.app.tenwa.calc.LC_RENT_PLAN");
|
||||
BizObject boLRP = bomLRP.createQuery("id=:id").setParameter("id", map.get("UUID")).getSingleResult(true);
|
||||
boLRP.setAttributeValue("batch_status", "process");
|
||||
bomLRP.saveObject(boLRP);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,10 @@ public interface VI_LC_AUDIT_RENT_PLAN{
|
||||
*/
|
||||
public static final String id = "id";
|
||||
/**
|
||||
* ÏîÄ¿id STRING(20)<br>
|
||||
*/
|
||||
public static final String project_id = "project_id";
|
||||
/**
|
||||
* ºÏͬ±àºÅ STRING(20)<br>
|
||||
*/
|
||||
public static final String contract_id = "contract_id";
|
||||
@ -141,4 +145,8 @@ public interface VI_LC_AUDIT_RENT_PLAN{
|
||||
* Ͷ·Å±àºÅ STRING(20)<br>
|
||||
*/
|
||||
public static final String payment_number = "payment_number";
|
||||
/**
|
||||
* ǩԼÀàÐÍ STRING(20)<br>
|
||||
*/
|
||||
public static final String collect_type = "collect_type";
|
||||
}
|
||||
108
src_jbo/jbo/loan/VI_RENT_COLLECT.java
Normal file
108
src_jbo/jbo/loan/VI_RENT_COLLECT.java
Normal file
@ -0,0 +1,108 @@
|
||||
package jbo.loan;
|
||||
|
||||
import java.lang.String;
|
||||
|
||||
/**
|
||||
* 扣款信息 - JBO命名常量类<br><br>
|
||||
* Note: This file is generated by ADE tools, <em>dont</em> modify it.<br>
|
||||
|
||||
*/
|
||||
public interface VI_RENT_COLLECT{
|
||||
/**
|
||||
* 扣款信息<br><br>
|
||||
* 代表本类映射的BizObjectClass
|
||||
*/
|
||||
public static final String CLASS_NAME = "jbo.loan.VI_RENT_COLLECT";
|
||||
/**
|
||||
* 标识 STRING(32)<br>
|
||||
*/
|
||||
public static final String ID = "ID";
|
||||
/**
|
||||
* 合同id STRING(32)<br>
|
||||
*/
|
||||
public static final String contract_id = "contract_id";
|
||||
/**
|
||||
* 业务类型 STRING(32)<br>
|
||||
*/
|
||||
public static final String businesstype = "businesstype";
|
||||
/**
|
||||
* 主体id STRING(32)<br>
|
||||
*/
|
||||
public static final String subjectid = "subjectid";
|
||||
/**
|
||||
* 主体名称 STRING(32)<br>
|
||||
*/
|
||||
public static final String subjectname = "subjectname";
|
||||
/**
|
||||
* 经销商id STRING(32)<br>
|
||||
*/
|
||||
public static final String distributor_id = "distributor_id";
|
||||
/**
|
||||
* 合同编号 STRING(32)<br>
|
||||
*/
|
||||
public static final String contract_number = "contract_number";
|
||||
/**
|
||||
* payment_number STRING(32)<br>
|
||||
*/
|
||||
public static final String payment_number = "payment_number";
|
||||
/**
|
||||
* 客户名称 STRING(32)<br>
|
||||
*/
|
||||
public static final String customername = "customername";
|
||||
/**
|
||||
* 客户账号 STRING(32)<br>
|
||||
*/
|
||||
public static final String acc_number = "acc_number";
|
||||
/**
|
||||
* 期次 STRING(32)<br>
|
||||
*/
|
||||
public static final String plan_list = "plan_list";
|
||||
/**
|
||||
* 计划日期 STRING(32)<br>
|
||||
*/
|
||||
public static final String plan_date = "plan_date";
|
||||
/**
|
||||
* 扣款状态 STRING(32)<br>
|
||||
*/
|
||||
public static final String collect_status = "collect_status";
|
||||
/**
|
||||
* 扣款状态信息 STRING(32)<br>
|
||||
*/
|
||||
public static final String collect_msg = "collect_msg";
|
||||
/**
|
||||
* 处理状态信息 STRING(32)<br>
|
||||
*/
|
||||
public static final String batch_status = "batch_status";
|
||||
/**
|
||||
* 租金 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String rent = "rent";
|
||||
/**
|
||||
* 本金 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String corpus = "corpus";
|
||||
/**
|
||||
* 利息 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String interest = "interest";
|
||||
/**
|
||||
* 罚息 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String penalty = "penalty";
|
||||
/**
|
||||
* 租金余额 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String rent_over = "rent_over";
|
||||
/**
|
||||
* 本金余额 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String corpus_over = "corpus_over";
|
||||
/**
|
||||
* 利息余额 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String interest_over = "interest_over";
|
||||
/**
|
||||
* 罚息余额 DOUBLE(32)<br>
|
||||
*/
|
||||
public static final String penalty_over = "penalty_over";
|
||||
}
|
||||
@ -32,6 +32,7 @@ import com.gnete.security.crypt.Crypt;
|
||||
import com.gnete.security.crypt.CryptException;
|
||||
import com.tenwa.comm.util.date.DateAssistant;
|
||||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||||
import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo;
|
||||
import com.tenwa.quartz.DateUtil;
|
||||
|
||||
import jbo.app.tenwa.calc.LC_COLLECT_MANUAL_INFO;
|
||||
@ -45,6 +46,7 @@ import jbo.com.tenwa.lease.comm.LB_BUCKLE_LOG;
|
||||
import jbo.com.tenwa.lease.comm.LB_CLEAR_FILE_RECORD;
|
||||
import jbo.com.tenwa.lease.comm.LB_INTFACE_FILE_RECORD;
|
||||
import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN;
|
||||
import jbo.loan.VI_RENT_COLLECT;
|
||||
import jbo.sys.CODE_LIBRARY;
|
||||
|
||||
public class CollectAuditInfoCache {
|
||||
@ -851,15 +853,24 @@ public class CollectAuditInfoCache {
|
||||
}
|
||||
}
|
||||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
|
||||
|
||||
List<BizObject> bolist = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false);
|
||||
if (bolist.size() != 0) {
|
||||
for(BizObject bo:bolist){
|
||||
List<BizObject> bolistTL = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and collect_type='TLcollect' and O.id in ("+parms.toString()+")").getResultList(false);
|
||||
List<BizObject> bolistYL = bm.createQuery("select distinct O.contract_id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and collect_type='YLcollect' and O.id in ("+parms.toString()+")").getResultList(false);
|
||||
if (bolistTL.size() != 0) {
|
||||
AllinpayPaymentDo apd = new AllinpayPaymentDo();
|
||||
for(BizObject bo:bolistTL){
|
||||
String plan_id = bo.getAttribute("id").toString();
|
||||
bo.setAttributeValue("rent", object.get(plan_id));
|
||||
}
|
||||
singleBatchCollectMoeny(tx, bolist);
|
||||
apd.BatchCollectMoeny(tx, bolistTL);
|
||||
}
|
||||
if (bolistYL.size() != 0) {
|
||||
for(BizObject bo:bolistYL){
|
||||
String plan_id = bo.getAttribute("id").toString();
|
||||
bo.setAttributeValue("rent", object.get(plan_id));
|
||||
}
|
||||
singleBatchCollectMoeny(tx, bolistYL);
|
||||
}
|
||||
|
||||
return "·¢Æð¿Û¿îÉêÇë³É¹¦£¡";
|
||||
}
|
||||
/**
|
||||
|
||||
@ -253,6 +253,7 @@ public class RentIncomeMethod {
|
||||
boLORL.setAttributeValue("ID", UUIDUtil.getUUID());
|
||||
boLORL.setAttributeValue("PAYMENT_NUMBER", boVLRP.getAttribute("PAYMENT_NUMBER").getString());
|
||||
boLORL.setAttributeValue("PLAN_LIST", boVLRP.getAttribute("PLAN_LIST").getString());
|
||||
boLORL.setAttributeValue("PLAN_ID", boVLRP.getAttribute("ID").getString());
|
||||
boLORL.setAttributeValue("FLOW_NAME", "ÍøÒøÊÕ¿î");
|
||||
boLORL.setAttributeValue("FLOWUNID", flowunid);
|
||||
bomLORL.saveObject(boLORL);
|
||||
|
||||
@ -20,6 +20,7 @@ import com.base.util.QuartzUtil;
|
||||
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
|
||||
import com.tenwa.collectaudit.cache.CollectAuditInfoCacheTj;
|
||||
import com.tenwa.comm.util.date.DateAssistant;
|
||||
import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentDo;
|
||||
|
||||
public class AutoBuckle implements Job {
|
||||
private JobInitUserName jboName;
|
||||
@ -30,54 +31,19 @@ public class AutoBuckle implements Job {
|
||||
String plan_date = DateAssistant.getToday();
|
||||
Object userId = arg0.getTrigger().getJobDataMap().get("CurUserId");
|
||||
String curUserId = userId == null? "system" : userId.toString();
|
||||
String sql = "O.plan_list=(select min(t.plan_list) from jbo.loan.VI_RENT_COLLECT t where t.contract_id=O.contract_id and t.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and t.SUBJECTID=:subjectId and t.collect_type=:collectType and t.PLAN_DATE <= '" + plan_date + "' and ( t.BATCH_STATUS<>'process' or t.BATCH_STATUS IS NULL ) and (t.contract_number NOT IN ('BQAP(AH)201908060003','BQAP(AH)201908070002','BQAP(AH)201908070003')) and (t.distributor_id not in (select dw.distributor_id from jbo.app.tenwa.customer.DEDUCTIONS_WAY dw where dw.Whether_to_enable='Y'))) GROUP BY contract_id";
|
||||
|
||||
//获取租金占用表里的数据有哪些是网银收款占用的
|
||||
List<String> planIDs = new ArrayList<String>();
|
||||
// 获取传递过来的参数
|
||||
try {
|
||||
|
||||
tx = JBOFactory.createJBOTransaction();
|
||||
List<BizObject> bosSz = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN", tx).createQuery("O.plan_list=(select min(t.plan_list) from jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN t where t.contract_id=O.contract_id and t.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and t.SUBJECTID='aa740e4111c111eaaa0000163e0e11e6' and t.PLAN_DATE <= '" + plan_date + "' and ( t.BATCH_STATUS<>'process' or t.BATCH_STATUS IS NULL ) and (t.contract_number NOT IN ('BQAP(AH)201908060003','BQAP(AH)201908070002','BQAP(AH)201908070003')) and (t.distributor_id not in (select dw.distributor_id from jbo.app.tenwa.customer.DEDUCTIONS_WAY dw where dw.Whether_to_enable='Y'))) GROUP BY contract_id").getResultList(true);
|
||||
List<BizObject> bol = JBOFactory.createBizObjectQuery(LC_OCCUPY_RENT_LIST.CLASS_NAME,"FLOW_NAME in ('网银收款','微信银联收款','微信支付收款','合同中途终止')").getResultList(false);
|
||||
if(bol.size()>0){
|
||||
for(int i=0;i<bol.size();i++){
|
||||
String flowName = bol.get(i).getAttribute("FLOW_NAME").toString();
|
||||
if("网银收款".equals(flowName)){
|
||||
//暂时没有让更新
|
||||
String flowunid = bol.get(i).getAttribute("FLOWUNID").toString();
|
||||
List<BizObject> bof = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME,"FLOWUNID=:flowunid").setParameter("flowunid", flowunid).getResultList(false);
|
||||
if(bof.size()>0){
|
||||
for(int j=0;j<bof.size();j++){
|
||||
String planID = bof.get(j).getAttribute("PLAN_ID").toString();
|
||||
planIDs.add(planID);
|
||||
}
|
||||
}
|
||||
}else if ("微信银联收款".equals(flowName) || "微信支付收款".equals(flowName)){
|
||||
planIDs.add(bol.get(i).getAttribute("PLAN_ID").toString());
|
||||
}else if("合同中途终止".equals(flowName)){
|
||||
String PAYMENT_NUMBER = bol.get(i).getAttribute("PAYMENT_NUMBER").toString();
|
||||
List<BizObject> bop = JBOFactory.createBizObjectQuery(LC_RENT_PLAN.CLASS_NAME,"PAYMENT_NUMBER=:PAYMENT_NUMBER").setParameter("PAYMENT_NUMBER", PAYMENT_NUMBER).getResultList(false);
|
||||
if(bop.size()>0){
|
||||
for(int k=0;k<bop.size();k++){
|
||||
String planID = bop.get(k).getAttribute("ID").toString();
|
||||
planIDs.add(planID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String subjectId = "aa740e4111c111eaaa0000163e0e11e6";
|
||||
String collectType = "YLcollect";
|
||||
List<BizObject> bosSz = JBOFactory.getBizObjectManager("jbo.loan.VI_RENT_COLLECT", tx).createQuery(sql).setParameter("subjectId", subjectId).setParameter("collectType", collectType).getResultList(false);
|
||||
StringBuffer ids = new StringBuffer();
|
||||
if(bosSz!=null&&bosSz.size()>0){
|
||||
a:for(BizObject bo : bosSz){
|
||||
for(BizObject bo : bosSz){
|
||||
String pid = bo.getAttribute("id").getString();
|
||||
if(planIDs.size()>0){
|
||||
for(int i=0;i<planIDs.size();i++){
|
||||
if(pid.equals(planIDs.get(i))){
|
||||
continue a;
|
||||
}
|
||||
}
|
||||
}
|
||||
ids.append(pid+"@");
|
||||
}
|
||||
System.out.println("本次扣款的plan_id:"+ids.toString());
|
||||
@ -118,18 +84,13 @@ public class AutoBuckle implements Job {
|
||||
try {
|
||||
txTj = JBOFactory.createJBOTransaction();
|
||||
CollectAuditInfoCacheTj caTj = new CollectAuditInfoCacheTj();
|
||||
List<BizObject> bosTj = JBOFactory.getBizObjectManager("jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN", txTj).createQuery(" O.plan_list=(select min(t.plan_list) from jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN t where t.contract_id=O.contract_id and t.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and t.SUBJECTID='d989246c11c111eaaa0000163e0e11e6' and t.PLAN_DATE <= '" + plan_date + "' and ( t.BATCH_STATUS<>'process' or t.BATCH_STATUS IS NULL ) and (t.contract_number NOT IN ('BQAP(AH)201908060003','BQAP(AH)201908070002','BQAP(AH)201908070003')) and (t.distributor_id not in (select dw.distributor_id from jbo.app.tenwa.customer.DEDUCTIONS_WAY dw where dw.Whether_to_enable='Y'))) GROUP BY contract_id").getResultList(true);
|
||||
String subjectId = "d989246c11c111eaaa0000163e0e11e6";
|
||||
String collectType = "YLcollect";
|
||||
List<BizObject> bosTj = JBOFactory.getBizObjectManager("jbo.loan.VI_RENT_COLLECT", txTj).createQuery(sql).setParameter("subjectId", subjectId).setParameter("collectType", collectType).getResultList(false);
|
||||
StringBuffer idsTj = new StringBuffer();
|
||||
if(bosTj!=null && bosTj.size()>0){
|
||||
a:for(BizObject bo : bosTj){
|
||||
for(BizObject bo : bosTj){
|
||||
String pid = bo.getAttribute("id").getString();
|
||||
if(planIDs.size()>0){
|
||||
for(int i=0;i<planIDs.size();i++){
|
||||
if(pid.equals(planIDs.get(i))){
|
||||
continue a;
|
||||
}
|
||||
}
|
||||
}
|
||||
idsTj.append(pid+"@");
|
||||
}
|
||||
System.out.println("本次扣款的plan_id:"+idsTj.toString());
|
||||
@ -162,6 +123,45 @@ public class AutoBuckle implements Job {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//通联扣款(主体区分在内部)
|
||||
JBOTransaction txTL = null;
|
||||
try {
|
||||
txTL = JBOFactory.createJBOTransaction();
|
||||
String collectType = "TLcollect";
|
||||
String TLsql = "O.plan_list=(select min(t.plan_list) from jbo.loan.VI_RENT_COLLECT t where t.contract_id=O.contract_id and t.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and t.collect_type=:collectType and t.PLAN_DATE <= '" + plan_date + "' and ( t.BATCH_STATUS<>'process' or t.BATCH_STATUS IS NULL ) and (t.contract_number NOT IN ('BQAP(AH)201908060003','BQAP(AH)201908070002','BQAP(AH)201908070003')) and (t.distributor_id not in (select dw.distributor_id from jbo.app.tenwa.customer.DEDUCTIONS_WAY dw where dw.Whether_to_enable='Y'))) GROUP BY contract_id";
|
||||
List<BizObject> bos = JBOFactory.getBizObjectManager("jbo.loan.VI_RENT_COLLECT", txTL).createQuery(TLsql).setParameter("collectType", collectType).getResultList(false);
|
||||
StringBuffer ids = new StringBuffer();
|
||||
if(bos!=null && bos.size()>0){
|
||||
for(BizObject bo : bos){
|
||||
String pid = bo.getAttribute("id").getString();
|
||||
ids.append(pid+"@");
|
||||
}
|
||||
AllinpayPaymentDo apd = new AllinpayPaymentDo();
|
||||
apd.setId(ids.toString());
|
||||
apd.batchCollectManage(txTL);
|
||||
|
||||
}
|
||||
QuartzUtil.insertLog(plan_date,"com.tenwa.lease.app.quartzmession.AutoBuckle", "success", "通联成功", curUserId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
QuartzUtil.insertLog(plan_date,"com.tenwa.lease.app.quartzmession.AutoBuckle", "error", "通联失败", curUserId);
|
||||
if (txTL != null) {
|
||||
try {
|
||||
txTL.rollback();
|
||||
txTL=null;
|
||||
} catch (JBOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
} finally{
|
||||
try {
|
||||
if(txTL !=null){
|
||||
txTL.commit();
|
||||
}
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.base.util.QuartzUtil;
|
||||
import com.tenwa.collectaudit.cache.CollectAuditInfoCache;
|
||||
import com.tenwa.collectaudit.cache.CollectAuditInfoCacheTj;
|
||||
import com.tenwa.comm.util.date.DateAssistant;
|
||||
import com.tenwa.lease.app.allinpay.service.impl.AllinpayPaymentQueryRun;
|
||||
|
||||
public class AutoRefresh implements Job{
|
||||
|
||||
@ -29,7 +30,7 @@ public class AutoRefresh implements Job{
|
||||
String curUserId = userId == null? "system" : userId.toString();
|
||||
try {
|
||||
tx = JBOFactory.createJBOTransaction();
|
||||
List<BizObject> bos = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and O.SUBJECTID='aa740e4111c111eaaa0000163e0e11e6' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '"+plan_date+"'").getResultList(true);
|
||||
List<BizObject> bos = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and O.SUBJECTID='aa740e4111c111eaaa0000163e0e11e6' and collect_type='YLcollect' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '"+plan_date+"'").getResultList(true);
|
||||
StringBuffer ids = new StringBuffer();
|
||||
if(bos!=null && bos.size()>0){
|
||||
for (BizObject bo : bos) {
|
||||
@ -44,7 +45,7 @@ public class AutoRefresh implements Job{
|
||||
}
|
||||
//Ìì½ò×Ô¶¯»ØÅÌ
|
||||
CollectAuditInfoCacheTj caTj = new CollectAuditInfoCacheTj();
|
||||
List<BizObject> bosTj = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and O.SUBJECTID='d989246c11c111eaaa0000163e0e11e6' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '"+plan_date+"'").getResultList(true);
|
||||
List<BizObject> bosTj = JBOFactory.getBizObjectManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME, tx).createQuery("O.COLLECT_STATUS IN ('未收款', '部分收款','代偿') and O.SUBJECTID='d989246c11c111eaaa0000163e0e11e6' and collect_type='YLcollect' and O.BATCH_STATUS='process' and O.PLAN_DATE <= '"+plan_date+"'").getResultList(true);
|
||||
StringBuffer idsTj = new StringBuffer();
|
||||
if(bosTj!=null && bosTj.size()>0){
|
||||
for (BizObject bo : bosTj) {
|
||||
@ -68,5 +69,7 @@ public class AutoRefresh implements Job{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
AllinpayPaymentQueryRun run = new AllinpayPaymentQueryRun();
|
||||
new Thread(run).start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.tenwa.lease.flow.rent.rentreback;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
||||
import jbo.app.tenwa.calc.VI_LC_RENT_PLAN;
|
||||
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
|
||||
|
||||
public class VILCRentCollectHandler extends CommonHandler{
|
||||
|
||||
@Override
|
||||
protected void initDisplayForEdit(BizObject bo) throws Exception {
|
||||
double rent_over = bo.getAttribute("rent_over").getDouble();
|
||||
double penalty_over = bo.getAttribute("penalty_over").getDouble();
|
||||
double back_rent = rent_over+penalty_over;
|
||||
back_rent = new BigDecimal(String.valueOf(back_rent)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
bo.setAttributeValue("back_rent", back_rent);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user