1789 lines
81 KiB
Java
1789 lines
81 KiB
Java
package com.tenwa.collectaudit.cache;
|
||
|
||
import java.io.File;
|
||
import java.math.BigDecimal;
|
||
import java.sql.SQLException;
|
||
import java.text.DecimalFormat;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.regex.Matcher;
|
||
import java.util.regex.Pattern;
|
||
|
||
import com.amarsoft.app.awe.config.InitCollectConfig;
|
||
import com.amarsoft.app.util.StringUtil;
|
||
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.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 jbo.app.tenwa.calc.LC_RENT_PLAN;
|
||
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
|
||
import jbo.app.tenwa.customer.DISTRIBUTOR_INFO;
|
||
import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO;
|
||
import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO;
|
||
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.sys.CODE_LIBRARY;
|
||
|
||
public class CollectAuditInfoCache {
|
||
|
||
private String id;
|
||
private String fileSavePath = "d:/tmp/als/InterFace";
|
||
private String inputuserid;
|
||
private String inputorgid;
|
||
private String clearDate;
|
||
private String distributor_id;
|
||
private String penaltys;
|
||
|
||
/**
|
||
* 经销商保证金代偿后红冲
|
||
* 租金计划表ID,在保证金收取表中为depositcharge_id,在退回表中为RENT_PLAN_ID
|
||
* @param depositcharge_id,tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public void writeBackDistributor(String RENT_PLAN_ID,Transaction Sqlca) throws JBOException{
|
||
BizObjectManager bmDCI = JBOFactory.getFactory().getManager(D_DEPOSITCHARGE_INFO.CLASS_NAME);
|
||
BizObjectManager bmDRI = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME);
|
||
BizObjectManager bmDI = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME);
|
||
BizObject bDRI= bmDRI.createQuery("RENT_PLAN_ID=:RENT_PLAN_ID").setParameter("RENT_PLAN_ID", RENT_PLAN_ID).getSingleResult(false);
|
||
String distributorId = bDRI.getAttribute("DISTRIBUTOR_ID").toString();
|
||
String cautionMoney = bDRI.getAttribute("CAUTION_MONEY").toString();
|
||
//D_DEPOSITCHARGE_INFO插入新数据
|
||
BizObject bDCI_N = bmDCI.newObject();
|
||
bDCI_N.setAttributeValue("DISTRIBUTOR_ID", distributorId);
|
||
bDCI_N.setAttributeValue("CAUTION_MONEY", cautionMoney);
|
||
bDCI_N.setAttributeValue("MONEY_TYPE","bondBack");
|
||
bDCI_N.setAttributeValue("INPUTTIME",StringFunction.getTodayNow());
|
||
bDCI_N.setAttributeValue("INPUTUSERID",inputuserid);
|
||
bDCI_N.setAttributeValue("INPUTORGID",inputorgid);
|
||
bDCI_N.setAttributeValue("RENT_PLAN_ID",RENT_PLAN_ID);
|
||
bmDCI.saveObject(bDCI_N);
|
||
//修改经销商信息表里的金额
|
||
BizObject bDI = bmDI.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributorId).getSingleResult(false);
|
||
BigDecimal sum = new BigDecimal(bDI.getAttribute("sums").getString());
|
||
double account_balance = sum.add(new BigDecimal(cautionMoney)).doubleValue();
|
||
bmDI.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributorId).executeUpdate();
|
||
System.out.println("红冲成功");
|
||
}
|
||
|
||
//获取存盘文件
|
||
public static String getCollectIntface(String id) throws Exception{
|
||
|
||
String sql="select lr.filename from LB_INTFACE_FILE_RECORD lr "
|
||
+ "where lr.id=:id";
|
||
Map<String,String> map=new HashMap<String, String>();
|
||
map.put("id", id);
|
||
JBOTransaction tx = null;
|
||
String filename="";
|
||
tx=JBOFactory.createJBOTransaction();
|
||
List<Map<String,String>> list=DataOperatorUtil.getDataBySql(tx, sql, map);
|
||
if(list.size()>0){
|
||
filename=StringUtil.nullToString(list.get(0).get("FILENAME")) ;
|
||
}
|
||
tx.commit();
|
||
return filename;
|
||
}
|
||
//校验是否已经收款
|
||
public String checkRentIsIncome(JBOTransaction tx) throws JBOException{
|
||
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,tx);
|
||
List<BizObject> bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false);
|
||
for (BizObject bo : bolist) {
|
||
String name = bo.getAttribute("customer_name").toString().trim();
|
||
String plan_list = bo.getAttribute("plan_list").toString();
|
||
String plan_date = bo.getAttribute("plan_date").toString();
|
||
String batchstatus = bo.getAttribute("BATCH_STATUS").toString();
|
||
String rent = bo.getAttribute("rent").toString();
|
||
if ("process".equals(batchstatus)) {//判断是否在批量处理中
|
||
return "error@"+name+"的"+plan_list+"日期为"+plan_date+"的租金正在进行批量扣款处理中".trim();
|
||
}
|
||
if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//判断剩余收款金额
|
||
return "error@"+name+"的"+plan_list+"日期为"+plan_date+"的租金已经全部收取,无法再次扣款".trim();
|
||
}
|
||
}
|
||
return "sucess";
|
||
}
|
||
//上传清算文件
|
||
public String uploadClearFile(JBOTransaction tx) throws JBOException{
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currenttime=currentDateTime.replaceAll("/", "");
|
||
currenttime=currenttime.replaceAll(":", "");
|
||
currenttime=currenttime.replaceAll(" ", "");
|
||
//String SETT_DATE = "20170920";
|
||
String SETT_DATE = this.getClearDate() != null ? this.getClearDate().replace("/", "") : "";
|
||
String SETT_NO = "01";
|
||
String SF_TYPE = InitCollectConfig.FLAG;
|
||
String USER_NAME = InitCollectConfig.USERNAME;
|
||
String MERCHANT_ID = InitCollectConfig.MERCHANTID;
|
||
String REQ_TIME = currenttime;
|
||
//String URL = "http://59.41.103.98:333/gzdsf/GetSettFile.do?";
|
||
String URL = InitCollectConfig.CLEARREQUESTURL+"?";
|
||
String SIGNED_MSG = "";
|
||
try {
|
||
Crypt crypt = new Crypt("gbk");
|
||
String pathPfx = InitCollectConfig.PRIVATEKEYURL;
|
||
//"D:\\BaiduNetdisk\\Download\\代收付系统接口文档和JAVA版测试demo及测试相关参数\\JAVA版测试DEMO及测试参数_20170825\\测试商户证书\\ORA@TEST1.p12";
|
||
SIGNED_MSG = SETT_DATE+"|"+SETT_NO+"|"+USER_NAME+"|"+MERCHANT_ID+"|"+REQ_TIME;
|
||
SIGNED_MSG = crypt.sign(SIGNED_MSG, pathPfx, "123456");
|
||
URL += "SETT_DATE="+SETT_DATE+"&SETT_NO="+SETT_NO+"&SF_TYPE="+SF_TYPE+"&USER_NAME="+USER_NAME+"&MERCHANT_ID="+MERCHANT_ID+"&REQ_TIME="+REQ_TIME+"&SIGNED_MSG="+SIGNED_MSG;
|
||
System.out.println(URL);
|
||
} catch (CryptException e) {
|
||
e.printStackTrace();
|
||
}
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LB_CLEAR_FILE_RECORD.CLASS_NAME);
|
||
bm.createQuery("update O set O.FULLPATH=:FULLPATH where O.id=:id").setParameter("FULLPATH", URL)
|
||
.setParameter("id", this.getId()).executeUpdate();
|
||
return "sucess";
|
||
}
|
||
//初审
|
||
public String fristCollectAudit(JBOTransaction tx) throws JBOException{
|
||
String[] ids = id.split("@");
|
||
StringBuffer buff = new StringBuffer();
|
||
for (String str : ids) {
|
||
if (buff.length() == 0) {
|
||
buff.append("'"+str+"'");
|
||
}else{
|
||
buff.append(",'"+str+"'");
|
||
}
|
||
}
|
||
String parm = buff.toString();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
|
||
BizObjectManager acc = JBOFactory.getFactory().getManager(CUSTOMER_ACCOUNT.CLASS_NAME);
|
||
List<BizObject> bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parm.toString()+")").getResultList(false);
|
||
for (BizObject bo : bolist) {
|
||
System.out.println("银行账户:"+bo.getAttribute("account")+",银行卡号:"+bo.getAttribute("acc_number")
|
||
+",手机号:"+bo.getAttribute("mobile")+"合同ID:"+bo.getAttribute("contract_id"));
|
||
String name = bo.getAttribute("customer_name").toString().trim();
|
||
BizObject ac = acc.createQuery("O.account=:account and O.acc_type = 'Debit' and O.sign_status ='Y' and O.acc_number=:acc_number and O.mobile=:mobile and O.contract_id=:contract_id")
|
||
.setParameter("account", bo.getAttribute("account").toString())
|
||
.setParameter("acc_number", bo.getAttribute("acc_number").toString())
|
||
.setParameter("mobile", bo.getAttribute("mobile").toString())
|
||
.setParameter("contract_id", bo.getAttribute("contract_id").toString())
|
||
.getSingleResult(false);
|
||
if (ac == null) {
|
||
return "error@客户"+name+"尚未签约,请先进行签约".trim();
|
||
}
|
||
}
|
||
BizObjectManager bmr = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
//String today=DateTool.getToday();
|
||
bmr.createQuery("update O set O.AUDIT_STATE = 'Y' where id in ("+parm+")").executeUpdate();
|
||
//bmr.createQuery("update O set O.AUDIT_STATE = 'Y',CollectTime='"+today+"' where id in ("+parm+")").executeUpdate();
|
||
return "success";
|
||
}
|
||
|
||
//复审退回
|
||
public String rebackCollectAudit(JBOTransaction tx) throws JBOException{
|
||
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 v.getCustomerName(O.customer_id) as v.customer_name,O.fact_rent,O.account,O.acc_number,O.mobile,O.contract_id,O.plan_list,O.plan_date,O.COLLECT_STATUS,O.BATCH_STATUS,O.rent from O where O.id in ("+parms.toString()+")").getResultList(false);
|
||
for (BizObject bo : bolist) {
|
||
String name = bo.getAttribute("customer_name").toString().trim();
|
||
String plan_list = bo.getAttribute("plan_list").toString();
|
||
String plan_date = bo.getAttribute("plan_date").toString();
|
||
String batchstatus = bo.getAttribute("BATCH_STATUS").toString();
|
||
String rent = bo.getAttribute("rent").toString();
|
||
double fact_rent = bo.getAttribute("fact_rent").getDouble();//实际租金
|
||
double income_rent = bo.getAttribute("rent").getDouble();//已收租金
|
||
if ("process".equals(batchstatus)) {//判断是否在批量处理中
|
||
return "error@"+name+"的"+plan_list+"日期为"+plan_date+"的租金正在进行批量扣款处理中,无法退回初审".trim();
|
||
}
|
||
if ("".equals(rent) || "0".equals(rent) || "0.0".equals(rent)) {//判断剩余收款金额
|
||
return "error@"+name+"的"+plan_list+"日期为"+plan_date+"的租金已经全部收取,无法退回初审".trim();
|
||
}
|
||
if (income_rent > 0 && (fact_rent > income_rent)) {//部分收款
|
||
return "error@"+name+"的"+plan_list+"日期为"+plan_date+"的租金已经部分收取,无法退回初审".trim();
|
||
}
|
||
}
|
||
BizObjectManager bmlrp = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
bmlrp.createQuery("update O set O.AUDIT_STATE = 'N' where id in ("+parms.toString()+")").executeUpdate();
|
||
|
||
return "success";
|
||
}
|
||
|
||
/**
|
||
* 实时代收
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String barchCollectManage(JBOTransaction tx) throws Exception{
|
||
int i = 0,j = 0;
|
||
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);
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_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,ca.ACCOUNT_PROVINCE,ca.BANK_DEPOSIT,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca where O.contract_id=ca.contract_id and ca.acc_info = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false);
|
||
for (BizObject bo : bolist) {
|
||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false);
|
||
for (BizObject code : codelist) {
|
||
String itemname = code.getAttribute("itemname").toString().trim();
|
||
double itemdescribe = code.getAttribute("itemdescribe").getDouble();
|
||
if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) {
|
||
BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString());
|
||
int rent = m.multiply(new BigDecimal(100)).intValue();
|
||
BigDecimal mi = new BigDecimal(itemdescribe);
|
||
long divide = mi.multiply(new BigDecimal(100)).longValue();
|
||
int k = (int) Math.floor(rent/divide);
|
||
int l = (int) Math.ceil(rent%divide);
|
||
int im = 0;
|
||
for (int k2 = 1; k2 <= k; k2++) {
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,itemdescribe+"",k2+"");
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
im++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}
|
||
if (l != 0) {
|
||
String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*itemdescribe));
|
||
String hire_list = (k+1)+"";
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,surprent,hire_list);
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
im++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}
|
||
if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "部分收款")
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
}
|
||
}else {
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1");
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}
|
||
}
|
||
/*if (bo.getAttribute("BANK_NAME") != null && bo.getAttribute("bank_name").toString().indexOf("建设银行") !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > 5000) {
|
||
BigDecimal m = new BigDecimal(bo.getAttribute("rent").toString());
|
||
int rent = m.multiply(new BigDecimal(100)).intValue();
|
||
int k = (int) Math.floor(rent/500000);
|
||
int l = (int) Math.ceil(rent%500000);
|
||
int im = 0;
|
||
for (int k2 = 1; k2 <= k; k2++) {
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,"5000.00",k2+"");
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
im++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}
|
||
if (l != 0) {
|
||
String surprent = String.valueOf(new DecimalFormat("#.00").format(bo.getAttribute("rent").getDouble() - k*5000));
|
||
String hire_list = (k+1)+"";
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,surprent,hire_list);
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
im++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}
|
||
if(im > 1 && ((l != 0 && im != (k+1))||(l == 0 && im != k))){
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "部分收款")
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
}
|
||
}else {
|
||
Map<String, String> map = singleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1");
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
}else{
|
||
j++;
|
||
}
|
||
}*/
|
||
}
|
||
|
||
return "总共有 "+i+" 笔租金收款成功\n"+j+" 笔租金收款失败";
|
||
}
|
||
|
||
/**
|
||
* 接口代付
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> singleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{
|
||
CollectAuditProcess cp = new CollectAuditProcess();
|
||
//创建文件名称
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currentYear = currentDateTime.substring(0,4);
|
||
String month = currentDateTime.substring(5,7);
|
||
String day = currentDateTime.substring(8,10);
|
||
String merchantNumber = InitCollectConfig.MERCHANTID;
|
||
String flag = InitCollectConfig.FLAG;
|
||
String version = InitCollectConfig.C_VERSION;
|
||
String date = currentYear+month+day;//提交日期
|
||
String batch_title = "";
|
||
int i = 0,j = 0;
|
||
//创建文件路径
|
||
String rootDir = this.fileSavePath;
|
||
File file = new File(rootDir + File.separator + currentYear
|
||
+ File.separator + month + File.separator
|
||
+ day);
|
||
System.out.println(file.getAbsolutePath());
|
||
if(!file.exists()){//目录不存在则直接创建
|
||
file.mkdirs();
|
||
}
|
||
String req_sn = System.currentTimeMillis()+"";//当日批次号
|
||
batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn;
|
||
BigDecimal m = new BigDecimal(rent);
|
||
String fact_rent = String.valueOf(m.multiply(new BigDecimal(100)).intValue());
|
||
String acc_number = bo.getAttribute("ACC_NUMBER").toString();
|
||
String account = bo.getAttribute("ACCOUNT").toString();
|
||
String bank_code = bo.getAttribute("BANK_DEPOSIT").toString();
|
||
String province = bo.getAttribute("ACCOUNT_PROVINCE").toString();
|
||
StringBuffer strbuff = collectTimely(fact_rent, acc_number, account,bank_code,province, req_sn);
|
||
//响应报文
|
||
String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title);
|
||
Map<String, String> map = getRetAndCode(strResp);
|
||
if ("0000".equals(map.get("RET_CODE"))) {
|
||
i++;
|
||
}else{
|
||
j++;
|
||
}
|
||
if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) {
|
||
Transaction Sqlca =null;
|
||
String cerrentDate = DateAssistant.getToday();
|
||
JBOTransaction transaction = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction);
|
||
BizObject boi = bmi.createQuery("select v.sys_guid() as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER,"
|
||
+ "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST,"
|
||
+ "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,'"+rent+"' as v.RENT,case when ("+rent+" - vl.interest_over) > 0 then ("+rent+" - vl.interest_over) else 0 end as v.CORPUS,case when ("+rent+" - vl.interest_over) > 0 then (vl.interest_over) else "+rent+" end as v.INTEREST,vl.penalty_over as v.PENALTY,"
|
||
+ "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id"
|
||
+ " and vl.contract_id =:contract_id and vl.plan_date =:plan_date")
|
||
.setParameter("contract_id", bo.getAttribute("contract_id").toString())
|
||
.setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false);
|
||
if (boi != null) {
|
||
//插入数据
|
||
String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST,"
|
||
+ " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)"
|
||
+ "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"',"
|
||
+ "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"',"
|
||
+ "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"',"
|
||
+ "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')";
|
||
Sqlca = Transaction.createTransaction(transaction);
|
||
SqlObject asql = new SqlObject(sql);
|
||
Sqlca.executeSQL(asql);
|
||
}
|
||
transaction.commit();
|
||
Sqlca.commit();
|
||
}
|
||
BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
String batch_number = bco.getAttribute("batch_number").toString();
|
||
if ("0000".equals(map.get("RET_CODE"))){
|
||
if (batch_number.length() == 0) {
|
||
batch_number += "交易成功流水为:"+req_sn;
|
||
}else{
|
||
batch_number += ";交易成功流水为:"+req_sn;
|
||
}
|
||
}else{
|
||
if (batch_number.length() == 0) {
|
||
batch_number += "交易失败流水为:"+req_sn;
|
||
}else{
|
||
batch_number += ";交易失败流水为:"+req_sn;
|
||
}
|
||
}
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_NUMBER=:BATCH_NUMBER where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "0000".equals(map.get("RET_CODE")) ? "收款成功" : "未收款")
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("BATCH_NUMBER", batch_number)
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
//生成存盘、回盘文件
|
||
savaFile(tx, strResp,batch_title,bo);
|
||
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 手动回笼租金
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws JBOException
|
||
* @throws SQLException
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> handcraftsingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException {
|
||
String cerrentDate = DateAssistant.getToday();//获取当前日期,格式为:yyyy/MM/dd
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
//改为存储过程实现
|
||
/*JBOTransaction transaction = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction);
|
||
BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER,"
|
||
+ "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST,"
|
||
+ "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY,"
|
||
+ "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id"
|
||
+ " and vl.contract_id =:contract_id and vl.plan_date =:plan_date")
|
||
.setParameter("contract_id", bo.getAttribute("contract_id").toString())
|
||
.setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false);
|
||
if (boi != null) {
|
||
//插入数据
|
||
String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST,"
|
||
+ " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)"
|
||
+ "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"',"
|
||
+ "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"',"
|
||
+ "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"',"
|
||
+ "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')";
|
||
Transaction Sqlca =null;
|
||
Sqlca = Transaction.createTransaction(transaction);
|
||
SqlObject asql = new SqlObject(sql);
|
||
Sqlca.executeSQL(asql);
|
||
Sqlca.commit();
|
||
}
|
||
transaction.commit();*/
|
||
|
||
Transaction Sqlca =null;
|
||
ASResultSet rs = null;
|
||
try {
|
||
|
||
Sqlca = Transaction.createTransaction(tx);
|
||
String ln_contract_id = bo.getAttribute("contract_id").toString();
|
||
String ln_plan_date = bo.getAttribute("plan_date").toString();
|
||
String in_rent = rent;
|
||
String in_hire_list = hire_list;
|
||
String in_type = "1";
|
||
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();
|
||
}
|
||
|
||
|
||
|
||
/*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
String batch_number = bco.getAttribute("BATCH_NO").toString();
|
||
if (batch_number.length() == 0) {
|
||
batch_number += "手工付款金额:"+rent;
|
||
}else{
|
||
batch_number += ";手工付款金额:"+rent;
|
||
}*/
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "收款成功")
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
map.put("RET_CODE", "0000");
|
||
return map;
|
||
}
|
||
/**
|
||
* 手动回笼租金
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws JBOException
|
||
* @throws SQLException
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> handcraftsingleCollectMoenyDistrbutor(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws JBOException, SQLException {
|
||
String cerrentDate = DateAssistant.getToday();//获取当前日期,格式为:yyyy/MM/dd
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
//改为存储过程实现
|
||
/*JBOTransaction transaction = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction);
|
||
BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER,"
|
||
+ "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST,"
|
||
+ "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.corpus_over-vl.interest_over) as v.PENALTY,"
|
||
+ "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id"
|
||
+ " and vl.contract_id =:contract_id and vl.plan_date =:plan_date")
|
||
.setParameter("contract_id", bo.getAttribute("contract_id").toString())
|
||
.setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false);
|
||
if (boi != null) {
|
||
//插入数据
|
||
String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST,"
|
||
+ " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)"
|
||
+ "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"',"
|
||
+ "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"',"
|
||
+ "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"',"
|
||
+ "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')";
|
||
Transaction Sqlca =null;
|
||
Sqlca = Transaction.createTransaction(transaction);
|
||
SqlObject asql = new SqlObject(sql);
|
||
Sqlca.executeSQL(asql);
|
||
Sqlca.commit();
|
||
}
|
||
transaction.commit();*/
|
||
|
||
Transaction Sqlca =null;
|
||
ASResultSet rs = null;
|
||
try {
|
||
|
||
Sqlca = Transaction.createTransaction(tx);
|
||
String ln_contract_id = bo.getAttribute("contract_id").toString();
|
||
String ln_plan_date = bo.getAttribute("plan_date").toString();
|
||
String in_rent = rent;
|
||
String in_hire_list = hire_list;
|
||
String in_type = "3";
|
||
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();
|
||
}
|
||
|
||
|
||
|
||
/*BizObject bco = bc.createQuery("id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
String batch_number = bco.getAttribute("BATCH_NO").toString();
|
||
if (batch_number.length() == 0) {
|
||
batch_number += "手工付款金额:"+rent;
|
||
}else{
|
||
batch_number += ";手工付款金额:"+rent;
|
||
}*/
|
||
//更新收付状态
|
||
/*bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "收款成功")
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();*/
|
||
map.put("RET_CODE", "0000");
|
||
return map;
|
||
}
|
||
/**
|
||
* 手动收款修改状态,回笼租金
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String afterCollectManage(JBOTransaction tx) throws Exception{
|
||
int i = 0,j = 0;
|
||
String[] ids = id.split("@");
|
||
StringBuffer parms = new StringBuffer();
|
||
for (String str : ids) {
|
||
if (parms.length()==0) {
|
||
parms.append("'"+str+"'");
|
||
}else{
|
||
parms.append(",'"+str+"'");
|
||
}
|
||
}
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
List<BizObject> bolist = bm.createQuery("select distinct O.contract_id,O.id,O.plan_date,O.id,ca.ACC_NUMBER,ca.ACCOUNT,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);
|
||
for (BizObject bo : bolist) {
|
||
Map<String, String> map = handcraftsingleCollectMoeny(tx,bc,bo,bo.getAttribute("rent").toString(),"1");
|
||
i++;
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "手工收款")
|
||
.setParameter("COLLECT_MSG", "手工扣款")
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
if(boDDI!=null){
|
||
this.writeBackDistributor(bo.getAttribute("id").toString(), Sqlca);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
return "总共有 "+i+" 笔租金收款成功\n"+j+" 笔租金收款失败";
|
||
}
|
||
/**
|
||
* 手动收款修改状态,回笼租金,经销商保证金代偿
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String afterCollectManageDistributor(JBOTransaction tx) throws Exception{
|
||
int i = 0,j = 0;
|
||
String[] ids = id.split("@");
|
||
String[] penaltyArray = penaltys.split("@");
|
||
String COMPENSATORY_CON=null;
|
||
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME,tx);
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,tx);
|
||
BizObjectManager bd = JBOFactory.getFactory().getManager(D_DEPOSITRETURN_INFO.CLASS_NAME,tx);
|
||
BizObjectManager bdi = JBOFactory.getFactory().getManager(DISTRIBUTOR_INFO.CLASS_NAME,tx);
|
||
|
||
for(int c=0;c<ids.length;c++){
|
||
BizObject bom = bm.createQuery("select distinct O.contract_id,O.plan_list,O.plan_date,O.id,O.corpus,O.interest,ca.ACC_NUMBER,ca.ACCOUNT,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 ='"+ids[c]+"'").getSingleResult(false);
|
||
BigDecimal corpus =new BigDecimal(bom.getAttribute("corpus").getString());
|
||
BigDecimal interest =new BigDecimal(bom.getAttribute("interest").getString());
|
||
BigDecimal penalty = new BigDecimal(penaltyArray[c]);
|
||
String t_rent = corpus.add(interest).add(penalty).toString();
|
||
|
||
/**
|
||
* 获取上一期是否有代偿记录
|
||
*/
|
||
String contract_id = bom.getAttribute("contract_id").toString();
|
||
int plan_list=Integer.parseInt(bom.getAttribute("plan_list").toString())-1;
|
||
// 查询当前要代偿期次的上一期代偿记录, 有数据则联系代偿记录加1,没有数据则默认为1;
|
||
BizObject ddi = bd.createQuery("SELECT O.COMPENSATORY_CON FROM O WHERE O.MONEY_TYPE='bondRepay' AND O.CONTRACT_ID='"+contract_id+"' AND O.PLAN_LIST='"+plan_list+"'").getSingleResult(false);
|
||
if(ddi!=null && !"".equals(ddi)) {
|
||
COMPENSATORY_CON=String.valueOf(Integer.parseInt(ddi.getAttribute("COMPENSATORY_CON").getString())+1);
|
||
}else {
|
||
COMPENSATORY_CON="1";
|
||
}
|
||
|
||
//handcraftsingleCollectMoeny方法的最后一个参数原为hire_list,现改为客户输入核销罚息参数(周亚辉)
|
||
//代偿不再往租金实收表插入数据
|
||
// Map<String, String> map = handcraftsingleCollectMoenyDistrbutor(tx,bc,bom,rent,penaltyArray[c]);
|
||
i++;
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.PENALTY=:PENALTY where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "代偿")
|
||
.setParameter("COLLECT_MSG", "经销商保证金代偿")
|
||
.setParameter("PENALTY", penaltyArray[c])
|
||
.setParameter("id", bom.getAttribute("id").toString()).executeUpdate();
|
||
//在这里插入经销商保证金退回表的数据
|
||
BizObject bobdi = bdi.createQuery("distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).getSingleResult(false);
|
||
BigDecimal sum = new BigDecimal(bobdi.getAttribute("sums").getString());
|
||
double account_balance = sum.subtract(new BigDecimal(t_rent)).doubleValue();
|
||
BizObject bod = bd.newObject();
|
||
bod.setAttributeValue("DISTRIBUTOR_ID", distributor_id);
|
||
bod.setAttributeValue("CAUTION_MONEY", t_rent);
|
||
bod.setAttributeValue("ACCOUNT_BALANCE", account_balance);
|
||
bod.setAttributeValue("MONEY_TYPE","bondRepay");
|
||
bod.setAttributeValue("INPUTTIME",StringFunction.getTodayNow());
|
||
bod.setAttributeValue("INPUTUSERID",inputuserid);
|
||
bod.setAttributeValue("INPUTORGID",inputorgid);
|
||
bod.setAttributeValue("CONTRACT_ID",bom.getAttribute("contract_id").toString());
|
||
bod.setAttributeValue("PLAN_LIST",bom.getAttribute("plan_list").toString());
|
||
bod.setAttributeValue("RENT_PLAN_ID",bom.getAttribute("id").toString());
|
||
bod.setAttributeValue("COMPENSATORY_CON",COMPENSATORY_CON);
|
||
bd.saveObject(bod);
|
||
//修改经销商信息表里的金额
|
||
bdi.createQuery("update O set O.sums='"+account_balance+"' where O.distributor_no=:distributor_id").setParameter("distributor_id", distributor_id).executeUpdate();
|
||
}
|
||
return "总共有 "+i+" 笔租金收款成功\n"+j+" 笔租金收款失败";
|
||
}
|
||
private BigDecimal BigDecimal(String string) {
|
||
// TODO Auto-generated method stub
|
||
return null;
|
||
}
|
||
|
||
private Double Double(String string) {
|
||
// TODO Auto-generated method stub
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 实时代收
|
||
* @param rent 租金
|
||
* @param acc_number 银行卡号
|
||
* @param account 开户名
|
||
* @param bankcode 银行代码
|
||
* @param province 银行卡所属省份
|
||
* @param req_sn 请求流水号
|
||
* @return
|
||
*/
|
||
public StringBuffer collectTimely(String rent,String acc_number,String account,String bankcode,String province,String req_sn){
|
||
//拼接XML报文
|
||
String req = System.currentTimeMillis()+"";
|
||
StringBuffer strbuff = new StringBuffer();
|
||
strbuff.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
|
||
strbuff.append("<GZELINK>");
|
||
strbuff.append("<INFO>");
|
||
Info info = new Info();
|
||
info.setTRX_CODE(InitCollectConfig.C_TRXCODE);
|
||
info.setVERSION(InitCollectConfig.C_VERSION);
|
||
info.setDATA_TYPE(InitCollectConfig.C_DATATYPE);
|
||
info.setLEVEL(InitCollectConfig.C_LEVEL);
|
||
info.setUSER_NAME(InitCollectConfig.USERNAME);
|
||
info.setUSER_PASS(InitCollectConfig.USERPASS);
|
||
info.setREQ_SN(req_sn);
|
||
info.setSIGNED_MSG("");
|
||
strbuff.append(EntityTransform.toXml(info));
|
||
strbuff.append("</INFO>");
|
||
strbuff.append("<BODY>");
|
||
strbuff.append("<TRANS_SUM>");
|
||
Trans_Sum trans_sum = new Trans_Sum();
|
||
trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE);
|
||
trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID);
|
||
trans_sum.setEXPECT_SEND_TIME("");
|
||
trans_sum.setTOTAL_ITEM("1");
|
||
trans_sum.setTOTAL_SUM(rent);
|
||
strbuff.append(EntityTransform.toXml(trans_sum));
|
||
strbuff.append("</TRANS_SUM>");
|
||
strbuff.append("<TRANS_DETAILS><TRANS_DETAIL>");
|
||
Trans_Detail trans_detail = new Trans_Detail();
|
||
trans_detail.setSN("0001");
|
||
trans_detail.setBANK_CODE(bankcode);//银行代码
|
||
trans_detail.setACCOUNT_TYPE("00");
|
||
trans_detail.setACCOUNT_NO(acc_number);
|
||
trans_detail.setACCOUNT_NAME(account);
|
||
trans_detail.setPROVINCE(province);//银行卡所属省份
|
||
trans_detail.setACCOUNT_PROP("0");
|
||
trans_detail.setAMOUNT(rent);
|
||
trans_detail.setCURRENCY("CNY");
|
||
trans_detail.setRECKON_ACCOUNT("");
|
||
strbuff.append(EntityTransform.toXmlByLotCollect(trans_detail));
|
||
strbuff.delete(strbuff.lastIndexOf("<TRANS_DETAIL>"), strbuff.length());
|
||
strbuff.append("</TRANS_DETAILS>");
|
||
strbuff.append("</BODY>");
|
||
strbuff.append("</GZELINK>");
|
||
|
||
return strbuff;
|
||
}
|
||
|
||
/**
|
||
* 批量代收-发送请求
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String batchCollectManage(JBOTransaction tx) throws Exception{
|
||
int i = 0,j = 0;
|
||
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);
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_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) {
|
||
singleBatchCollectMoeny(tx, bolist);
|
||
}
|
||
return "系统正在处理中,请稍后";
|
||
}
|
||
|
||
/**
|
||
* 查询批量收款状态
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String queryBatchCollectStatus(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(VI_LC_AUDIT_RENT_PLAN.CLASS_NAME);
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
String[] ids = id.split("@");
|
||
StringBuffer parms = new StringBuffer();
|
||
for (String str : ids) {
|
||
if (parms.length()==0) {
|
||
parms.append("'"+str+"'");
|
||
}else{
|
||
parms.append(",'"+str+"'");
|
||
}
|
||
}
|
||
List<BizObject> bolist = bm.createQuery("select distinct O.BATCH_NO,O.BATCH_SN,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);
|
||
for (BizObject bo : bolist) {
|
||
String query_sn = bo.getAttribute("BATCH_NO").toString();
|
||
String sn = bo.getAttribute("BATCH_SN").toString();
|
||
String rent = bo.getAttribute("rent").toString();
|
||
String bank_name = bo.getAttribute("BANK_NAME").toString();
|
||
int m = 0;
|
||
String[] singleRent = null;
|
||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false);
|
||
for (BizObject code : codelist) {
|
||
String itemname = code.getAttribute("itemname").toString().trim();
|
||
double itemdescribe = code.getAttribute("itemdescribe").getDouble();
|
||
if (bank_name.indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) {
|
||
BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString());
|
||
int singlerent = mi.multiply(new BigDecimal(100)).intValue();
|
||
BigDecimal mj = new BigDecimal(itemdescribe);
|
||
long divide = mj.multiply(new BigDecimal(100)).longValue();
|
||
if(divide!=0){
|
||
int k = (int) Math.floor(singlerent/divide);
|
||
int l = (int) Math.ceil(singlerent%divide);
|
||
for (int j = 0; j < k; j++) {
|
||
m++;
|
||
}
|
||
if (l!=0) {
|
||
m++;
|
||
}
|
||
singleRent = new String[m];
|
||
for (int i = 0; i < k; i++) {
|
||
singleRent[i] = itemdescribe+"";
|
||
}
|
||
singleRent[m-1] = String.format("%.2f",bo.getAttribute("rent").getDouble() - k*itemdescribe);
|
||
break;//如果匹配到,则跳出循环
|
||
}
|
||
}
|
||
}
|
||
String[] snArray = sn.split(",");
|
||
int n = 0;//拆分租金,扣款成功记录
|
||
BizObject bolrp = bc.createQuery("O.id=:id").setParameter("id", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
String collectStatus = "未收款";
|
||
String collectStatusPart = "部分收款";
|
||
//防止报空指针
|
||
if(bolrp.getAttribute("COLLECT_STATUS")!=null){
|
||
//判断如果为空或为null等则跳过(如果是“代偿”则为“代偿”状态)
|
||
if(bolrp.getAttribute("COLLECT_STATUS").toString().length()>1){
|
||
collectStatus = bolrp.getAttribute("COLLECT_STATUS").toString();
|
||
collectStatusPart = bolrp.getAttribute("COLLECT_STATUS").toString();
|
||
}
|
||
}
|
||
for (int i = 1; i <= snArray.length; i++) {
|
||
Map<String, String> map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]);
|
||
if (snArray.length == 1) {
|
||
if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) {
|
||
querysingleCollectMoeny(tx, bc, bo, rent,i+"");
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "批量收款")
|
||
.setParameter("COLLECT_MSG", "批量代收,收款成功")
|
||
.setParameter("BATCH_STATUS", "complete")//更新批量处理状态-完成
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
if(boDDI!=null){
|
||
this.writeBackDistributor(bo.getAttribute("id").toString(),Sqlca);
|
||
}
|
||
bo.setAttributeValue("COLLECT_STATUS", "批量收款");
|
||
bo.setAttributeValue("COLLECT_MSG", "批量代收,收款成功");
|
||
bo.setAttributeValue("BATCH_STATUS", "complete");
|
||
//bo.setAttributeValue("rent", bo.getAttribute("rent").toString());
|
||
saveBuckle(bo,tx,sn,rent);
|
||
}else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){
|
||
//更新银联处理中的反馈信息
|
||
bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
|
||
saveBuckle(bo,tx,sn,"0.00");
|
||
}else{
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", collectStatus)
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("BATCH_STATUS", "")//清空批量处理状态
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
bo.setAttributeValue("COLLECT_STATUS", "未收款");
|
||
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
|
||
bo.setAttributeValue("BATCH_STATUS", "");
|
||
saveBuckle(bo,tx,sn,"0.00");
|
||
}
|
||
}else if (snArray.length > 1) {
|
||
if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) {
|
||
querysingleCollectMoeny(tx, bc, bo, singleRent[i-1],i+"");
|
||
n++;
|
||
if (n == snArray.length) {
|
||
n = 0;//将扣款成功项 置为 0
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", "批量收款")
|
||
.setParameter("COLLECT_MSG", "批量代收,收款成功")
|
||
.setParameter("BATCH_STATUS", "complete")//更新批量处理状态-完成
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
BizObject boDDI=JBOFactory.createBizObjectQuery(D_DEPOSITRETURN_INFO.CLASS_NAME,"RENT_PLAN_ID=:rentPlanId").setParameter("rentPlanId", bo.getAttribute("id").toString()).getSingleResult(false);
|
||
if(boDDI!=null){
|
||
this.writeBackDistributor( bo.getAttribute("id").toString(),Sqlca);
|
||
}
|
||
bo.setAttributeValue("COLLECT_STATUS", "批量收款");
|
||
bo.setAttributeValue("COLLECT_MSG", "批量代收,收款成功");
|
||
bo.setAttributeValue("BATCH_STATUS", "complete");
|
||
//bo.setAttributeValue("rent", bo.getAttribute("rent").toString());
|
||
saveBuckle(bo,tx,i+"",rent);
|
||
}else{
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", collectStatusPart)
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("BATCH_STATUS", "complete")//清空批量处理状态-完成
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
bo.setAttributeValue("COLLECT_STATUS", "部分收款");
|
||
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
|
||
bo.setAttributeValue("BATCH_STATUS", "complete");
|
||
saveBuckle(bo,tx,i+"","0.00");
|
||
}
|
||
}else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){
|
||
//更新银联处理中的反馈信息
|
||
bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id")
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
|
||
saveBuckle(bo,tx,i+"","0.00");
|
||
}else{//批量拆分多笔扣款,如果扣款成功条数未 0 ,则更新扣款状态为 未扣款
|
||
if (i == snArray.length && n == 0) {
|
||
//更新收付状态
|
||
bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id")
|
||
.setParameter("COLLECT_STATUS", collectStatus)
|
||
.setParameter("COLLECT_MSG", map.get("ERR_MSG"))
|
||
.setParameter("BATCH_STATUS", "")//清空批量处理状态
|
||
.setParameter("id", bo.getAttribute("id").toString()).executeUpdate();
|
||
bo.setAttributeValue("COLLECT_STATUS", "未收款");
|
||
bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG"));
|
||
bo.setAttributeValue("BATCH_STATUS", "");
|
||
saveBuckle(bo,tx,i+"","0.00");
|
||
}
|
||
}
|
||
}
|
||
if (i == snArray.length) {//循环结束,将n置为 0
|
||
n = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
return "success";
|
||
|
||
}
|
||
public void saveBuckle(BizObject bo,JBOTransaction tx,String batch_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());
|
||
}
|
||
blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_SN, batch_sn);
|
||
blbo.setAttributeValue(LB_BUCKLE_LOG.BATCH_NO, bo.getAttribute("BATCH_NO").getString());
|
||
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);
|
||
}
|
||
|
||
/**
|
||
* 批量代收查询接口
|
||
* @param tx
|
||
* @param bo
|
||
* @param list
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> querySingleBatchCollect(JBOTransaction tx,BizObject bo,String query_sn,String sn) throws Exception{
|
||
CollectAuditProcess cp = new CollectAuditProcess();
|
||
//创建文件名称
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currentYear = currentDateTime.substring(0,4);
|
||
String month = currentDateTime.substring(5,7);
|
||
String day = currentDateTime.substring(8,10);
|
||
String merchantNumber = InitCollectConfig.MERCHANTID;
|
||
String flag = InitCollectConfig.FLAG;
|
||
String version = InitCollectConfig.C_VERSION;
|
||
String date = currentYear+month+day;//提交日期
|
||
String batch_title = "";
|
||
int i = 0,j = 0;
|
||
//创建文件路径
|
||
String rootDir = this.fileSavePath;
|
||
File file = new File(rootDir + File.separator + currentYear
|
||
+ File.separator + month + File.separator
|
||
+ day);
|
||
System.out.println(file.getAbsolutePath());
|
||
if(!file.exists()){//目录不存在则直接创建
|
||
file.mkdirs();
|
||
}
|
||
String req_sn = System.currentTimeMillis()+"";//当日批次号
|
||
batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn;
|
||
StringBuffer strbuff = queryBatchXML(req_sn, query_sn,sn);
|
||
// queryBatchXML(req_sn, query_sn, sn);
|
||
//响应报文
|
||
String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title);
|
||
Map<String, String> map = getRetAndCode(strResp);
|
||
//生成存盘、回盘文件
|
||
savaFile(tx, strResp,batch_title,bo);
|
||
|
||
return map;
|
||
}
|
||
|
||
|
||
/**
|
||
* 批量查询接口--回笼租金
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> querysingleCollectMoeny(JBOTransaction tx,BizObjectManager bc,BizObject bo,String rent,String hire_list) throws Exception{
|
||
String cerrentDate = DateAssistant.getToday();
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
//改为存储过程实现
|
||
/*JBOTransaction transaction = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction);
|
||
BizObject boi = bmi.createQuery("select v.replace(v.uuid(),'-','') as v.id,O.QUOT_ID as v.QUOT_ID,O.CUST_ID as v.CUST_ID,O.PROJECT_ID as v.PROJECT_ID,O.PROJECT_PLAN_NUMBER as v.PROJECT_PLAN_NUMBER,"
|
||
+ "O.CONTRACT_ID as v.CONTRACT_ID,O.CONTRACT_PLAN_NUMBER as v.CONTRACT_PLAN_NUMBER,O.PAYMENT_NUMBER as v.PAYMENT_NUMBER,'' as v.EBANK_NUMBER,O.id as v.PLAN_ID,O.PLAN_LIST as v.PLAN_LIST,"
|
||
+ "'0' as v.INTEREST_ADJUST,'settlemethod6' as v.SETTLE_METHOD,'"+hire_list+"' as v.HIRE_LIST,'"+cerrentDate+"' as v.HIRE_DATE,vl.rent_over as v.RENT,vl.corpus_over as v.CORPUS,vl.interest_over as v.INTEREST,("+rent+"-vl.rent_over) as v.PENALTY,"
|
||
+ "'0' as v.CORPUS_ADJUST,'0' as v.PENALTY_ADJUST,'0' as v.ROLL_BACK,O.COIN as v.COIN from O, jbo.app.tenwa.calc.VI_LC_RENT_PLAN vl where O.id = vl.id"
|
||
+ " and vl.contract_id =:contract_id and vl.plan_date =:plan_date")
|
||
.setParameter("contract_id", bo.getAttribute("contract_id").toString())
|
||
.setParameter("plan_date", bo.getAttribute("plan_date").toString()).getSingleResult(false);
|
||
if (boi != null) {
|
||
//插入数据
|
||
String sql = "insert into LC_RENT_INCOME (ID, QUOT_ID, CUST_ID, PROJECT_ID, PROJECT_PLAN_NUMBER, CONTRACT_ID, CONTRACT_PLAN_NUMBER, PAYMENT_NUMBER,EBANK_NUMBER,PLAN_ID, PLAN_LIST,"
|
||
+ " INTEREST_ADJUST,SETTLE_METHOD,HIRE_LIST,HIRE_DATE, RENT,CORPUS,INTEREST,PENALTY,CORPUS_ADJUST,PENALTY_ADJUST,ROLL_BACK,COIN)"
|
||
+ "values ('"+boi.getAttribute("id")+"','"+boi.getAttribute("QUOT_ID")+"','"+boi.getAttribute("CUST_ID")+"','"+boi.getAttribute("PROJECT_ID")+"','"+boi.getAttribute("PROJECT_PLAN_NUMBER")+"',"
|
||
+ "'"+boi.getAttribute("CONTRACT_ID")+"','"+boi.getAttribute("CONTRACT_PLAN_NUMBER")+"','"+boi.getAttribute("PAYMENT_NUMBER")+"','"+boi.getAttribute("EBANK_NUMBER")+"','"+boi.getAttribute("PLAN_ID")+"',"
|
||
+ "'"+boi.getAttribute("PLAN_LIST")+"','"+boi.getAttribute("INTEREST_ADJUST")+"','"+boi.getAttribute("SETTLE_METHOD")+"','"+boi.getAttribute("HIRE_LIST")+"','"+boi.getAttribute("HIRE_DATE")+"','"+boi.getAttribute("RENT")+"','"+boi.getAttribute("CORPUS")+"',"
|
||
+ "'"+boi.getAttribute("INTEREST")+"','"+boi.getAttribute("PENALTY")+"','"+boi.getAttribute("CORPUS_ADJUST")+"','"+boi.getAttribute("PENALTY_ADJUST")+"','"+boi.getAttribute("ROLL_BACK")+"','"+boi.getAttribute("COIN")+"')";
|
||
Transaction Sqlca =null;
|
||
Sqlca = Transaction.createTransaction(transaction);
|
||
SqlObject asql = new SqlObject(sql);
|
||
Sqlca.executeSQL(asql);
|
||
}
|
||
transaction.commit();*/
|
||
|
||
Transaction Sqlca =null;
|
||
ASResultSet rs = null;
|
||
try {
|
||
|
||
Sqlca = Transaction.createTransaction(tx);
|
||
String ln_contract_id = bo.getAttribute("contract_id").toString();
|
||
String ln_plan_date = bo.getAttribute("plan_date").toString();
|
||
String in_rent = rent;
|
||
String in_hire_list = hire_list;
|
||
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();
|
||
}
|
||
|
||
return map;
|
||
}
|
||
/**
|
||
* 批量查询接口报文-xml
|
||
* @param req_sn 请求流水号
|
||
* @param query_sn 查询流水号
|
||
* @param sn 查询明细项
|
||
* @return
|
||
*/
|
||
public StringBuffer queryBatchXML(String req_sn,String query_sn,String sn){
|
||
StringBuffer strbuff = new StringBuffer();
|
||
strbuff.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
|
||
strbuff.append("<GZELINK>");
|
||
strbuff.append("<INFO>");
|
||
Info info = new Info();
|
||
info.setTRX_CODE("200001");
|
||
info.setVERSION(InitCollectConfig.C_VERSION);
|
||
info.setDATA_TYPE(InitCollectConfig.C_DATATYPE);
|
||
info.setREQ_SN(req_sn);
|
||
info.setUSER_NAME(InitCollectConfig.USERNAME);
|
||
info.setUSER_PASS(InitCollectConfig.USERPASS);
|
||
info.setSIGNED_MSG("");
|
||
strbuff.append(EntityTransform.toXml(info));
|
||
strbuff.append("</INFO>");
|
||
strbuff.append("<BODY>");
|
||
strbuff.append("<QUERY_TRANS>");
|
||
strbuff.append("<QUERY_SN>");
|
||
strbuff.append(query_sn);//要查询的交易流水
|
||
strbuff.append("</QUERY_SN>");
|
||
strbuff.append("<QUERY_REMARK/>");
|
||
strbuff.append("<RET_TYPE/>");
|
||
strbuff.append("</QUERY_TRANS>");
|
||
strbuff.append("<QUERY_DETAILS>");
|
||
strbuff.append("<QUERY_DETAIL>");
|
||
strbuff.append("<QUERY_DETAIL_SN>");
|
||
strbuff.append(sn);//交易明细号
|
||
strbuff.append("</QUERY_DETAIL_SN>");
|
||
strbuff.append("</QUERY_DETAIL>");
|
||
strbuff.append("</QUERY_DETAILS>");
|
||
strbuff.append("</BODY>");
|
||
strbuff.append("</GZELINK>");
|
||
return strbuff;
|
||
}
|
||
/**
|
||
* 批量代收-发送请求
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, String> singleBatchCollectMoeny(JBOTransaction tx,List<BizObject> list) throws Exception{
|
||
CollectAuditProcess cp = new CollectAuditProcess();
|
||
//创建文件名称
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currentYear = currentDateTime.substring(0,4);
|
||
String month = currentDateTime.substring(5,7);
|
||
String day = currentDateTime.substring(8,10);
|
||
String merchantNumber = InitCollectConfig.MERCHANTID;
|
||
String flag = InitCollectConfig.FLAG;
|
||
String version = InitCollectConfig.C_VERSION;
|
||
String date = currentYear+month+day;//提交日期
|
||
String batch_title = "";
|
||
int i = 0,j = 0;
|
||
//创建文件路径
|
||
String rootDir = this.fileSavePath;
|
||
File file = new File(rootDir + File.separator + currentYear
|
||
+ File.separator + month + File.separator
|
||
+ day);
|
||
System.out.println(file.getAbsolutePath());
|
||
if(!file.exists()){//目录不存在则直接创建
|
||
file.mkdirs();
|
||
}
|
||
String req_sn = System.currentTimeMillis()+"";//当日批次号
|
||
batch_title = merchantNumber+"_"+flag+version+date+"_"+req_sn;
|
||
StringBuffer strbuff = collectBatch(req_sn,list);
|
||
//响应报文
|
||
String strResp = cp.CollectAuditPayReq(strbuff,file.getAbsolutePath(), batch_title);
|
||
for (BizObject bo : list) {
|
||
//生成存盘、回盘文件
|
||
savaFile(tx, strResp,batch_title,bo);
|
||
}
|
||
Map<String, String> map = getRetAndCodeByBatch(strResp);
|
||
if (map.containsKey("RET_CODE")) {//清空批量代收状态
|
||
for (BizObject biz : list) {
|
||
//清空批量处理状态
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id")
|
||
.setParameter("BATCH_STATUS", "")//处理中
|
||
.setParameter("BATCH_NO", req_sn)
|
||
.setParameter("BATCH_SN", "")
|
||
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
|
||
trans.commit();
|
||
}
|
||
}else{
|
||
int m = 0;//统计发送的代收的批数
|
||
for (int n = 1; n <= map.size(); n++) {
|
||
if (map.containsKey("SN"+n)) {
|
||
m++;
|
||
}
|
||
}
|
||
for (int k = 1; k <= m; k++) {
|
||
if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE"+k) && "0000".equals(map.get("RET_CODE"+k))) {
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false);
|
||
if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) {
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ")
|
||
.setParameter("BATCH_STATUS", "process")//处理状态标记为--处理中
|
||
.setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate();
|
||
trans.commit();
|
||
}else{
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ")
|
||
.setParameter("BATCH_STATUS", "process")//处理状态标记为--处理中
|
||
.setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate();
|
||
trans.commit();
|
||
}
|
||
}else{
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false);
|
||
if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) {
|
||
//不做任何操作
|
||
}else{
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ")
|
||
.setParameter("BATCH_STATUS", "")//清空批量处理状态
|
||
.setParameter("BATCH_NO", map.get("REQ_SN")).executeUpdate();
|
||
trans.commit();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 批量代收--报文拼接
|
||
* @param rent
|
||
* @param acc_number
|
||
* @param account
|
||
* @param req_sn
|
||
* @return
|
||
* @throws JBOException
|
||
*/
|
||
public StringBuffer collectBatch(String req_sn,List<BizObject> list) throws JBOException{
|
||
//拼接XML报文
|
||
//String req = System.currentTimeMillis()+"";
|
||
StringBuffer strbuff = new StringBuffer();
|
||
strbuff.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
|
||
strbuff.append("<GZELINK>");
|
||
strbuff.append("<INFO>");
|
||
Info info = new Info();
|
||
info.setTRX_CODE(InitCollectConfig.BATCH_TRXCODE);
|
||
info.setVERSION(InitCollectConfig.C_VERSION);
|
||
info.setDATA_TYPE(InitCollectConfig.C_DATATYPE);
|
||
info.setLEVEL(InitCollectConfig.C_LEVEL);
|
||
info.setUSER_NAME(InitCollectConfig.USERNAME);
|
||
info.setUSER_PASS(InitCollectConfig.USERPASS);
|
||
info.setREQ_SN(req_sn);
|
||
info.setSIGNED_MSG("");
|
||
strbuff.append(EntityTransform.toXml(info));
|
||
strbuff.append("</INFO>");
|
||
strbuff.append("<BODY>");
|
||
strbuff.append("<TRANS_SUM>");
|
||
BigDecimal mutly = new BigDecimal("0");
|
||
int i = 0;
|
||
for (BizObject bo : list) {
|
||
String single = bo.getAttribute("rent").toString();
|
||
BigDecimal m = new BigDecimal(single);
|
||
mutly = mutly.add(m);
|
||
String bank_name = bo.getAttribute("BANK_NAME").toString();
|
||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false);
|
||
//数据字典中的itemdescribe字段代表银行单笔限
|
||
double itemdescribe = 0;
|
||
boolean flag = false;
|
||
for (BizObject code : codelist) {
|
||
String itemnameTmp = code.getAttribute("itemname").toString().trim();
|
||
double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble();
|
||
String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString();
|
||
if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) {
|
||
itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||
flag = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (flag == true && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) {
|
||
BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString());
|
||
int singlerent = mi.multiply(new BigDecimal(100)).intValue();
|
||
int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue();
|
||
int k = (int) Math.floor(singlerent/singleitem);
|
||
int l = (int) Math.ceil(singlerent%singleitem);
|
||
for (int j = 0; j < k; j++) {
|
||
i++;
|
||
}
|
||
if (l!=0) {
|
||
i++;
|
||
}
|
||
}else{
|
||
i++;
|
||
}
|
||
|
||
}
|
||
String totalSum = String.valueOf(mutly.multiply(new BigDecimal(100)).longValue());
|
||
String totalItem = String.valueOf(i);
|
||
Trans_Sum trans_sum = new Trans_Sum();
|
||
trans_sum.setBUSINESS_CODE(InitCollectConfig.BUSSINESSCODE);
|
||
trans_sum.setMERCHANT_ID(InitCollectConfig.MERCHANTID);
|
||
trans_sum.setEXPECT_SEND_TIME("");
|
||
trans_sum.setTOTAL_ITEM(totalItem);
|
||
trans_sum.setTOTAL_SUM(totalSum);
|
||
strbuff.append(EntityTransform.toXml(trans_sum));
|
||
strbuff.append("</TRANS_SUM>");
|
||
strbuff.append("<TRANS_DETAILS><TRANS_DETAIL>");
|
||
int item = 0;
|
||
for (BizObject biz : list) {
|
||
BigDecimal m = new BigDecimal(biz.getAttribute("rent").toString());
|
||
String rent = String.valueOf(m.multiply(new BigDecimal(100)).longValue());
|
||
String acc_number = biz.getAttribute("acc_number").toString();
|
||
String account = biz.getAttribute("account").toString();
|
||
String bank_name = biz.getAttribute("BANK_NAME").toString();
|
||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'bankType' and O.itemdescribe is not null ").getResultList(false);
|
||
double itemdescribe = 0;
|
||
boolean flag = false;
|
||
for (BizObject code : codelist) {
|
||
String itemnameTmp = code.getAttribute("itemname").toString().trim();
|
||
double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble();
|
||
String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString();
|
||
if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) {
|
||
itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||
flag = true;
|
||
break;
|
||
}
|
||
}
|
||
if (flag == true && Double.parseDouble(biz.getAttribute("rent").toString()) > itemdescribe) {
|
||
BigDecimal mi = new BigDecimal(biz.getAttribute("rent").toString());
|
||
int singlerent = mi.multiply(new BigDecimal(100)).intValue();
|
||
int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue();
|
||
int k = (int) Math.floor(singlerent/singleitem);
|
||
int l = (int) Math.ceil(singlerent%singleitem);
|
||
for (int k2 = 1; k2 <= k; k2++) {
|
||
Trans_Detail trans_detail = new Trans_Detail();
|
||
String sn = "";
|
||
if (item >= 9&&item<99) {
|
||
sn = "000"+ (++item);
|
||
}else if(item >= 99){
|
||
sn = "00"+ (++item);
|
||
}else{
|
||
sn = "0000"+ (++item);
|
||
}
|
||
//追加批量处理状态
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false);
|
||
String itemsn0 = "";
|
||
if (bo !=null) {
|
||
String itemsn = bo.getAttribute("batch_sn").toString();
|
||
if (itemsn.length() == 0) {
|
||
itemsn0 += sn;
|
||
}else{
|
||
itemsn0 += itemsn+","+sn;
|
||
}
|
||
}
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id")
|
||
.setParameter("BATCH_STATUS", "")//处理状态-为空
|
||
.setParameter("BATCH_NO", req_sn)
|
||
.setParameter("BATCH_SN", itemsn0)
|
||
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
|
||
trans.commit();
|
||
trans_detail.setSN(sn);
|
||
trans_detail.setACCOUNT_TYPE("");
|
||
trans_detail.setACCOUNT_NO(acc_number);
|
||
trans_detail.setACCOUNT_NAME(account);
|
||
trans_detail.setACCOUNT_PROP("0");
|
||
trans_detail.setAMOUNT(String.valueOf(singleitem));
|
||
trans_detail.setCURRENCY("CNY");
|
||
trans_detail.setRECKON_ACCOUNT("");
|
||
strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail));
|
||
}
|
||
if (l != 0) {
|
||
String surprent = String.format("%.2f", biz.getAttribute("rent").getDouble() - k*itemdescribe);
|
||
BigDecimal mj = new BigDecimal(surprent);
|
||
String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue());
|
||
Trans_Detail trans_detail = new Trans_Detail();
|
||
String sn = "";
|
||
if (item >= 9&&item<99) {
|
||
sn = "000"+ (++item);
|
||
}else if(item >= 99){
|
||
sn = "00"+ (++item);
|
||
}else{
|
||
sn = "0000"+ (++item);
|
||
}
|
||
//追加批量处理状态
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
BizObject bo = bm.createQuery("O.id=:id").setParameter("id", biz.getAttribute("id").toString()).getSingleResult(false);
|
||
String itemsn0 = "";
|
||
if (bo !=null) {
|
||
String itemsn = bo.getAttribute("batch_sn").toString();
|
||
if (itemsn.length() == 0) {
|
||
itemsn0 += sn;
|
||
}else{
|
||
itemsn0 += itemsn+","+sn;
|
||
}
|
||
}
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id")
|
||
.setParameter("BATCH_STATUS", "")//处理状态-为空
|
||
.setParameter("BATCH_NO", req_sn)
|
||
.setParameter("BATCH_SN", itemsn0)
|
||
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
|
||
trans.commit();
|
||
trans_detail.setSN(sn);
|
||
trans_detail.setACCOUNT_TYPE("");
|
||
trans_detail.setACCOUNT_NO(acc_number);
|
||
trans_detail.setACCOUNT_NAME(account);
|
||
trans_detail.setACCOUNT_PROP("0");
|
||
trans_detail.setAMOUNT(singlerent0);
|
||
trans_detail.setCURRENCY("CNY");
|
||
trans_detail.setRECKON_ACCOUNT("");
|
||
strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail));
|
||
}
|
||
}else{
|
||
Trans_Detail trans_detail = new Trans_Detail();
|
||
String sn = "";
|
||
if (item >= 9&&item<99) {
|
||
sn = "000"+ (++item);
|
||
}else if(item >= 99){
|
||
sn = "00"+ (++item);
|
||
}else{
|
||
sn = "0000"+ (++item);
|
||
}
|
||
//追加批量处理状态
|
||
JBOTransaction trans = JBOFactory.createJBOTransaction();
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans);
|
||
bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO=:BATCH_NO,O.BATCH_SN=:BATCH_SN where O.id=:id")
|
||
.setParameter("BATCH_STATUS", "")//处理状态-为空
|
||
.setParameter("BATCH_NO", req_sn)
|
||
.setParameter("BATCH_SN", sn)
|
||
.setParameter("id", biz.getAttribute("id").toString()).executeUpdate();
|
||
trans.commit();
|
||
trans_detail.setSN(sn);
|
||
trans_detail.setACCOUNT_TYPE("");
|
||
trans_detail.setACCOUNT_NO(acc_number);
|
||
trans_detail.setACCOUNT_NAME(account);
|
||
trans_detail.setACCOUNT_PROP("0");
|
||
trans_detail.setAMOUNT(rent);
|
||
trans_detail.setCURRENCY("CNY");
|
||
trans_detail.setRECKON_ACCOUNT("");
|
||
strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail));
|
||
}
|
||
}
|
||
strbuff.delete(strbuff.lastIndexOf("<TRANS_DETAIL>"), strbuff.length());
|
||
strbuff.append("</TRANS_DETAILS>");
|
||
strbuff.append("</BODY>");
|
||
strbuff.append("</GZELINK>");
|
||
|
||
|
||
return strbuff;
|
||
}
|
||
|
||
/**
|
||
* 保存存盘、回盘文件
|
||
* @param tx
|
||
* @param strResp
|
||
* @param batch_title
|
||
* @throws Exception
|
||
*/
|
||
public void savaFile(JBOTransaction tx,String strResp,String batch_title,BizObject bo) throws Exception{
|
||
//创建文件名称
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currentYear = currentDateTime.substring(0,4);
|
||
String month = currentDateTime.substring(5,7);
|
||
String day = currentDateTime.substring(8,10);
|
||
//创建文件路径
|
||
String rootDir = this.fileSavePath;
|
||
File file = new File(rootDir + File.separator + currentYear
|
||
+ File.separator + month + File.separator
|
||
+ day);
|
||
System.out.println(file.getAbsolutePath());
|
||
if(!file.exists()){//目录不存在则直接创建
|
||
file.mkdirs();
|
||
}
|
||
//保存存盘文件
|
||
BizObjectManager bm = JBOFactory.getFactory().getManager(LB_INTFACE_FILE_RECORD.CLASS_NAME);
|
||
BizObject send = bm.newObject();
|
||
send.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".txt").replace("\\", "/"));
|
||
send.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".txt").replace("\\", "/"));
|
||
send.setAttributeValue("filename", batch_title+".txt");
|
||
send.setAttributeValue("FILE_TYPE", "S");
|
||
send.setAttributeValue("RELA_ID", bo.getAttribute("id"));
|
||
send.setAttributeValue("inputuserid", this.inputuserid);
|
||
send.setAttributeValue("inputorgid", this.inputorgid);
|
||
send.setAttributeValue("inputtime", currentDateTime);
|
||
bm.saveObject(send);
|
||
//筛选响应信息
|
||
Map<String, String> map = getRetAndCode(strResp);
|
||
//getMsgAndCode(strResp);
|
||
|
||
//保存回盘文件
|
||
BizObject reply = bm.newObject();
|
||
reply.setAttributeValue("filepath", (file.getAbsoluteFile().toString().substring(rootDir.length())+"/"+batch_title+".rnt").replace("\\", "/"));
|
||
reply.setAttributeValue("fullpath", (file.getAbsoluteFile().toString()+"/"+batch_title+".rnt").replace("\\", "/"));
|
||
reply.setAttributeValue("filename", batch_title+".rnt");
|
||
reply.setAttributeValue("feedback_code", map.get("RET_CODE"));
|
||
reply.setAttributeValue("feedback_message", map.get("ERR_MSG"));
|
||
reply.setAttributeValue("FILE_TYPE", "B");
|
||
reply.setAttributeValue("RELA_ID", bo.getAttribute("id"));
|
||
reply.setAttributeValue("inputuserid", this.inputuserid);
|
||
reply.setAttributeValue("inputorgid", this.inputorgid);
|
||
reply.setAttributeValue("inputtime", currentDateTime);
|
||
bm.saveObject(reply);
|
||
}
|
||
|
||
/**
|
||
* 实时代收,响应文件处理
|
||
* @param strXML
|
||
* @return
|
||
*/
|
||
public Map<String, String> getRetAndCode(String strXML){
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
Map<String, String> res = new HashMap<String, String>();
|
||
Pattern pm = Pattern.compile("(?<=<RET_CODE>)([\\S\\s]*?)(?=</RET_CODE>)");
|
||
Matcher mm = pm.matcher(strXML);
|
||
int i = 0;
|
||
while (mm.find())
|
||
{
|
||
map.put("RET_CODE"+i++, mm.group());
|
||
}
|
||
Pattern pc = Pattern.compile("(?<=<ERR_MSG>)([\\S\\s]*?)(?=</ERR_MSG>)");
|
||
Matcher mc = pc.matcher(strXML);
|
||
int j = 0;
|
||
while (mc.find())
|
||
{
|
||
map.put("ERR_MSG"+j++, mc.group());
|
||
}
|
||
if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) {
|
||
if (map.containsKey("RET_CODE1") && "0000".equals(map.get("RET_CODE1"))) {
|
||
res.put("RET_CODE", map.get("RET_CODE1"));
|
||
res.put("ERR_MSG", map.get("ERR_MSG1"));
|
||
}else{
|
||
res.put("RET_CODE", map.get("RET_CODE1"));
|
||
res.put("ERR_MSG", map.get("ERR_MSG1"));
|
||
}
|
||
}else{
|
||
res.put("RET_CODE", map.get("RET_CODE0"));
|
||
res.put("ERR_MSG", map.get("ERR_MSG0"));
|
||
}
|
||
return res;
|
||
}
|
||
|
||
/**
|
||
* 批量代收-返回报文处理
|
||
* @param strXML
|
||
* @return
|
||
*/
|
||
public Map<String, String> getRetAndCodeByBatch(String strXML){
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
Map<String, String> res = new HashMap<String, String>();
|
||
System.out.println(1);
|
||
int iStart = strXML.indexOf("<ERR_MSG>");
|
||
if (iStart != -1) {
|
||
int end = strXML.indexOf("</ERR_MSG>");
|
||
String errMsg = strXML.substring(iStart+9, end);
|
||
map.put("ERR_MSG", errMsg);
|
||
}
|
||
int kStart = strXML.indexOf("<REQ_SN>");
|
||
if (kStart != -1) {
|
||
int end = strXML.indexOf("</REQ_SN>");
|
||
String reqSn = strXML.substring(kStart+8, end);
|
||
map.put("REQ_SN", reqSn);
|
||
}
|
||
|
||
Pattern pm = Pattern.compile("(?<=<RET_CODE>)([\\S\\s]*?)(?=</RET_CODE>)");
|
||
Matcher mm = pm.matcher(strXML);
|
||
int i = 0;
|
||
while (mm.find())
|
||
{
|
||
map.put("RET_CODE"+i++, mm.group());
|
||
}
|
||
Pattern pc = Pattern.compile("(?<=<SN>)([\\S\\s]*?)(?=</SN>)");
|
||
Matcher mc = pc.matcher(strXML);
|
||
int j = 1;
|
||
while (mc.find())
|
||
{
|
||
map.put("SN"+j++, mc.group());
|
||
}
|
||
if (map.containsKey("RET_CODE0") && "0000".equals(map.get("RET_CODE0"))) {
|
||
res.putAll(map);
|
||
res.remove("RET_CODE0");
|
||
res.remove("ERR_MSG");
|
||
}else{
|
||
res.put("RET_CODE", map.get("RET_CODE0"));
|
||
res.put("ERR_MSG", map.get("ERR_MSG0"));
|
||
}
|
||
return res;
|
||
}
|
||
|
||
public Map<String, String> getMsgAndCode(String strXML){
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
int iStart = strXML.indexOf("<ERR_MSG>");
|
||
if (iStart != -1) {
|
||
int end = strXML.indexOf("</ERR_MSG>");
|
||
String strMsg = strXML.substring(iStart+9, end);
|
||
map.put("ERR_MSG", strMsg);
|
||
}
|
||
int jStart = strXML.indexOf("<RET_CODE>");
|
||
if (jStart != -1) {
|
||
int end = strXML.indexOf("</RET_CODE>");
|
||
String strMsg = strXML.substring(jStart+10, end);
|
||
map.put("RET_CODE", strMsg);
|
||
}
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 获取响应码
|
||
* @param strXML
|
||
* @return
|
||
*/
|
||
public Map<String, String> getInfoAndStatus(String strXML){
|
||
Map<String, String> map = new HashMap<String, String>();
|
||
Map<String, String> res = new HashMap<String, String>();
|
||
|
||
int jStart = strXML.indexOf("<RET_CODE>");
|
||
if (jStart != -1) {
|
||
int end = strXML.indexOf("</RET_CODE>");
|
||
String retCode = strXML.substring(jStart+10, end);
|
||
map.put("RET_CODE", retCode);
|
||
}
|
||
int iStart = strXML.indexOf("<ERR_MSG>");
|
||
if (iStart != -1) {
|
||
int end = strXML.indexOf("</ERR_MSG>");
|
||
String errMsg = strXML.substring(iStart+9, end);
|
||
map.put("ERR_MSG", errMsg);
|
||
}
|
||
|
||
int kStart = strXML.indexOf("<TRANS_STATUS>");
|
||
if (kStart != -1) {
|
||
int end = strXML.indexOf("</TRANS_STATUS>");
|
||
String errMsg = strXML.substring(kStart+14, end);
|
||
map.put("TRANS_STATUS", errMsg);
|
||
}
|
||
int lStart = strXML.indexOf("<TRANS_INFO>");
|
||
if (lStart != -1) {
|
||
int end = strXML.indexOf("</TRANS_INFO>");
|
||
String retCode = strXML.substring(lStart+12, end);
|
||
map.put("TRANS_INFO", retCode);
|
||
}
|
||
if (map.containsKey("RET_CODE") && map.get("RET_CODE").equals("0000")) {
|
||
if (map.containsKey("TRANS_STATUS") && map.get("TRANS_STATUS").equals("0000")) {
|
||
res.put("RET_CODE", map.get("TRANS_STATUS"));
|
||
res.put("ERR_MSG", map.get("TRANS_INFO"));
|
||
}else{
|
||
res.put("RET_CODE", map.get("TRANS_STATUS"));
|
||
res.put("ERR_MSG", map.get("TRANS_INFO"));
|
||
}
|
||
}else{
|
||
res.put("RET_CODE", map.get("RET_CODE"));
|
||
res.put("ERR_MSG", map.get("ERR_MSG"));
|
||
}
|
||
return res;
|
||
}
|
||
//验证银行卡四要素
|
||
public Map<String, String> vitfyCollectManage(Map<String, String> map) throws CryptException{
|
||
CollectAuditProcess cp = new CollectAuditProcess();
|
||
String currentDateTime = DateAssistant.getTodayNow();
|
||
String currenttime=currentDateTime.replaceAll("/", "");
|
||
currenttime=currenttime.replaceAll(":", "");
|
||
//发送时间
|
||
currenttime=currenttime.replaceAll(" ", "");
|
||
//验证银行卡二、三、四要素
|
||
//流水号
|
||
String req = System.currentTimeMillis()+"";
|
||
StringBuffer strbuff = new StringBuffer();
|
||
strbuff.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
|
||
strbuff.append("<GZELINK>");
|
||
strbuff.append("<INFO>");
|
||
Info info = new Info();
|
||
/*info.setTRX_CODE("100039");
|
||
info.setVERSION("03");
|
||
info.setDATA_TYPE("2");
|
||
info.setLEVEL("5");
|
||
info.setUSER_NAME("00019140020764901");
|
||
info.setUSER_PASS("TPSHauto123.");*/
|
||
info.setTRX_CODE(InitCollectConfig.B_TRXCODE);
|
||
info.setVERSION(InitCollectConfig.B_VERSION);
|
||
info.setDATA_TYPE(InitCollectConfig.B_DATATYPE);
|
||
info.setLEVEL(InitCollectConfig.B_LEVEL);
|
||
info.setUSER_NAME(InitCollectConfig.USERNAME);
|
||
info.setUSER_PASS(InitCollectConfig.USERPASS);
|
||
info.setREQ_SN(req);
|
||
info.setSIGNED_MSG("");
|
||
strbuff.append(EntityTransform.toXml(info));
|
||
strbuff.append("</INFO>");
|
||
strbuff.append("<BODY>");
|
||
strbuff.append("<TRANS_SUM>");
|
||
strbuff.append("<SUBMIT_TIME>");
|
||
strbuff.append(currenttime);//请求时间
|
||
strbuff.append("</SUBMIT_TIME>");
|
||
strbuff.append("<MERCHANT_ID>");
|
||
strbuff.append(InitCollectConfig.MERCHANTID);//商户号
|
||
/*strbuff.append("000191400207649");//商户号
|
||
*/ strbuff.append("</MERCHANT_ID>");
|
||
strbuff.append("<BANK_CODE/>");
|
||
strbuff.append("<ACCOUNT_NO>");
|
||
strbuff.append(map.get("ACCOUNT_NO"));//卡号
|
||
strbuff.append("</ACCOUNT_NO>");
|
||
strbuff.append("<ACCOUNT_NAME>");
|
||
strbuff.append(map.get("ACCOUNT_NAME"));//户名
|
||
strbuff.append("</ACCOUNT_NAME>");
|
||
//判断是否存在
|
||
if (map.containsKey("ID_TYPE")) {
|
||
strbuff.append("<ID_TYPE>");
|
||
strbuff.append(map.get("ID_TYPE"));//开户证件类型
|
||
strbuff.append("</ID_TYPE>");
|
||
}
|
||
if (map.containsKey("ID")) {
|
||
strbuff.append("<ID>");
|
||
strbuff.append(map.get("ID"));//证件号
|
||
strbuff.append("</ID>");
|
||
}
|
||
if (map.containsKey("TEL")) {
|
||
strbuff.append("<TEL>");
|
||
strbuff.append(map.get("TEL"));//手机号
|
||
strbuff.append("</TEL>");
|
||
}
|
||
strbuff.append("<CRE_VAL_DATE>");
|
||
strbuff.append("");//贷记卡有效期
|
||
strbuff.append("</CRE_VAL_DATE>");
|
||
strbuff.append("<CRE_CVN2>");
|
||
strbuff.append("");//贷记卡CV2
|
||
strbuff.append("</CRE_CVN2>");
|
||
strbuff.append("</TRANS_SUM>");
|
||
strbuff.append("</BODY>");
|
||
strbuff.append("</GZELINK>");
|
||
String strResp = cp.CollectAuditVerifyReq(strbuff);
|
||
return getInfoAndStatus(strResp);
|
||
}
|
||
|
||
|
||
public String getInputuserid() {
|
||
return inputuserid;
|
||
}
|
||
|
||
public void setInputuserid(String inputuserid) {
|
||
this.inputuserid = inputuserid;
|
||
}
|
||
|
||
public String getInputorgid() {
|
||
return inputorgid;
|
||
}
|
||
|
||
public void setInputorgid(String inputorgid) {
|
||
this.inputorgid = inputorgid;
|
||
}
|
||
|
||
public String getFileSavePath() {
|
||
return fileSavePath;
|
||
}
|
||
|
||
public void setFileSavePath(String fileSavePath) {
|
||
this.fileSavePath = fileSavePath;
|
||
}
|
||
|
||
public String getId() {
|
||
return id;
|
||
}
|
||
|
||
public void setId(String id) {
|
||
this.id = id;
|
||
}
|
||
public String getClearDate() {
|
||
return clearDate;
|
||
}
|
||
public void setClearDate(String clearDate) {
|
||
this.clearDate = clearDate;
|
||
}
|
||
public String getDistributor_id() {
|
||
return distributor_id;
|
||
}
|
||
public void setDistributor_id(String distributor_id) {
|
||
this.distributor_id = distributor_id;
|
||
}
|
||
public String getPenaltys() {
|
||
return penaltys;
|
||
}
|
||
public void setPenaltys(String penaltys) {
|
||
this.penaltys = penaltys;
|
||
}
|
||
|
||
|
||
}
|