636 lines
31 KiB
Java
636 lines
31 KiB
Java
package com.tenwa.collectaudit.cache;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
import jbo.app.tenwa.calc.LC_RENT_INCOME;
|
||
import jbo.app.tenwa.calc.LC_RENT_PLAN;
|
||
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
|
||
import jbo.com.tenwa.lease.comm.COLLECT_RECORD_LOG;
|
||
import jbo.com.tenwa.lease.comm.COLLECT_RECORD_STATUS;
|
||
import jbo.com.tenwa.lease.comm.VI_LC_AUDIT_RENT_PLAN;
|
||
import jbo.sys.CODE_LIBRARY;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.amarsoft.app.awe.config.InitCollectConfig;
|
||
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.awe.util.SqlObject;
|
||
import com.amarsoft.awe.util.Transaction;
|
||
import com.tenwa.comm.util.date.DateAssistant;
|
||
import com.tenwa.util.SerialNumberUtil;
|
||
import com.zhongan.scorpoin.biz.common.CommonRequest;
|
||
import com.zhongan.scorpoin.biz.common.CommonResponse;
|
||
import com.zhongan.scorpoin.common.ZhongAnApiClient;
|
||
import com.zhongan.scorpoin.common.ZhongAnOpenException;
|
||
|
||
public class CollectAuditInfoCache {
|
||
|
||
|
||
private String id;
|
||
private String inputuserid;
|
||
private String inputorgid;
|
||
|
||
//УÑéÊÇ·ñÒѾÊÕ¿î
|
||
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);
|
||
List<BizObject> bolist = bm.createQuery("select v.getCustomerName(O.customer_id) as v.customer_name,O.contract_id,O.plan_list,O.plan_date,O.rent_over,crs.deduct_stata from O LEFT JOIN jbo.com.tenwa.lease.comm.COLLECT_RECORD_STATUS crs ON crs.contract_id = O.contract_id AND crs.rent_plan_id = O.id 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().trim();
|
||
String plan_date = bo.getAttribute("plan_date").toString().trim();
|
||
String deductstata = bo.getAttribute("deduct_stata").toString().trim();
|
||
String rent = bo.getAttribute("rent_over").toString();
|
||
if ("processing".equals(deductstata)) {//ÅжÏÊÇ·ñÔÚÅúÁ¿´¦ÀíÖÐ
|
||
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 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.rent from O where O.id in ("+parm.toString()+")").getResultList(false);
|
||
for (BizObject bo : bolist) {
|
||
String name = bo.getAttribute("customer_name").toString().trim();
|
||
BizObject ac = acc.createQuery("O.account=:account and O.acc_info = 'Debit' 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);
|
||
bmr.createQuery("update O set O.AUDIT_STATE = 'Y' 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 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);
|
||
BizObjectManager lrpbm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
List<BizObject> bolist = bm.createQuery("select O.contract_id,O.plan_date,O.id,ci.certid,ca.ACC_NUMBER,ca.mobile,ca.ACCOUNT,ca.BANK_NAME,O.rent from O , jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca,jbo.app.tenwa.customer.CUSTOMER_INFO ci where ci.customerid=ca.customerid and ca.customerid=O.customer_id and O.contract_id=ca.contract_id and ca.acc_type = 'Debit' and O.id in ("+parms.toString()+")").getResultList(false);
|
||
for (BizObject biz : bolist) {
|
||
String contract_id = biz.getAttribute("contract_id").toString();
|
||
String plan_id = biz.getAttribute("id").toString();
|
||
String bankname = biz.getAttribute("bank_name").toString();
|
||
String customer_name = biz.getAttribute("account").toString();
|
||
String certid = biz.getAttribute("certid").toString();
|
||
String mobile = biz.getAttribute("mobile").toString();
|
||
String acc_number = biz.getAttribute("ACC_NUMBER").toString();
|
||
String account = biz.getAttribute("ACCOUNT").toString();
|
||
String rent = biz.getAttribute("rent").toString();
|
||
BigDecimal rent_over = new BigDecimal(rent).setScale(2);
|
||
List<BizObject> codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'selectCollectBank' and O.isinuse = '1' and O.itemattribute is not null ").getResultList(false);
|
||
for (BizObject code : codelist) {
|
||
String itemname = code.getAttribute("itemname").toString().trim();
|
||
BigDecimal quota = new BigDecimal(code.getAttribute("itemattribute").toString()).setScale(2);
|
||
String collect_sn = "";//´ú¿ÛÁ÷Ë®ºÅ
|
||
if (bankname.indexOf(itemname) !=-1 && rent_over.compareTo(quota) == 1) {
|
||
int index_z = rent_over.divide(quota).intValue();
|
||
int index_y = rent_over.divideAndRemainder(quota)[1].compareTo(new BigDecimal(0)) == 1 ? 1 : 0;
|
||
for (int i = 0; i < index_z; i++) {
|
||
JBOTransaction tx1 = JBOFactory.createJBOTransaction();
|
||
collect_sn = SerialNumberUtil.getBatchSerialNumber(tx1);
|
||
//·¢Æð´ú¿Û
|
||
Map<String, Object> result = singleBatchCollectMoeny(tx, collect_sn,certid, bankname, acc_number, account, quota.toString());
|
||
if (result.containsKey("transStatus") && "3".equals(result.get("transStatus"))) {
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, quota.toString());
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_status = '1' where O.id =:plan_id ").setParameter("plan_id", plan_id).executeUpdate();
|
||
}else if (result.containsKey("transStatus") && "9".equals(result.get("transStatus"))) {
|
||
//²»×öÈκβÙ×÷
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_msg =:collect_msg where O.id =:plan_id ").setParameter("collect_msg", result.get("resMsg").toString()).setParameter("plan_id", plan_id).executeUpdate();
|
||
}else{
|
||
//ÆäËûÇé¿ö¾ùÈÏΪÊÇ ´¦ÀíÖР״̬
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, quota.toString());
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_status = '1' where O.id =:plan_id ").setParameter("plan_id", plan_id).executeUpdate();
|
||
}
|
||
//¼Ç¼·¢Æð´ú¿ÛÐÅÏ¢
|
||
archiveRedcodeLog(tx1, collect_sn, contract_id, plan_id, customer_name, certid, mobile, bankname, acc_number, account, quota.toString());
|
||
tx1.commit();
|
||
}
|
||
if (index_y == 1) {
|
||
//·¢Æð´ú¿Û
|
||
JBOTransaction tx1 = JBOFactory.createJBOTransaction();
|
||
collect_sn = SerialNumberUtil.getBatchSerialNumber(tx1);
|
||
Map<String, Object> result = singleBatchCollectMoeny(tx, collect_sn,certid, bankname, acc_number, account, rent_over.subtract(quota.multiply(new BigDecimal(index_z))).toString());
|
||
if (result.containsKey("transStatus") && "3".equals(result.get("transStatus"))) {
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, rent_over.subtract(quota.multiply(new BigDecimal(index_z))).toString());
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_status = '1' where O.id =:plan_id ").setParameter("plan_id", plan_id).executeUpdate();
|
||
}else if (result.containsKey("transStatus") && "9".equals(result.get("transStatus"))) {
|
||
//²»×öÈκβÙ×÷
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_msg =:collect_msg where O.id =:plan_id ").setParameter("collect_msg", result.get("resMsg").toString()).setParameter("plan_id", plan_id).executeUpdate();
|
||
}else{
|
||
//ÆäËûÇé¿ö¾ùÈÏΪÊÇ ´¦ÀíÖР״̬
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, rent_over.subtract(quota.multiply(new BigDecimal(index_z))).toString());
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
lrpbm.createQuery("update O set O.collect_status = '1' where O.id =:plan_id ").setParameter("plan_id", plan_id).executeUpdate();
|
||
}
|
||
//¼Ç¼·¢Æð´ú¿ÛÐÅÏ¢
|
||
archiveRedcodeLog(tx1, collect_sn, contract_id, plan_id, customer_name, certid, mobile, bankname, acc_number, account, rent_over.subtract(quota.multiply(new BigDecimal(index_z))).toString());
|
||
tx1.commit();
|
||
}
|
||
break;
|
||
}else if (bankname.indexOf(itemname) !=-1 && rent_over.compareTo(quota) == -1) {//Èç¹ûСÓÚÏ޶ÔòÖ±½Ó¿Û¿î
|
||
JBOTransaction tx1 = JBOFactory.createJBOTransaction();
|
||
collect_sn = SerialNumberUtil.getBatchSerialNumber(tx1);
|
||
//·¢Æð´ú¿Û
|
||
Map<String, Object> result = singleBatchCollectMoeny(tx, collect_sn, certid,bankname, acc_number, account, rent);
|
||
if (result.containsKey("transStatus") && "3".equals(result.get("transStatus"))) {
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, rent);
|
||
}else if (result.containsKey("transStatus") && "9".equals(result.get("transStatus"))) {
|
||
//²»×öÈκβÙ×÷
|
||
}else{
|
||
//ÆäËûÇé¿ö¾ùÈÏΪÊÇ ´¦ÀíÖР״̬
|
||
archiveRedcodeStatus(tx1, collect_sn, contract_id, plan_id, rent);
|
||
}
|
||
tx1.commit();
|
||
break;
|
||
}
|
||
}
|
||
|
||
}
|
||
return "ϵͳÕýÔÚ´¦ÀíÖУ¬ÇëÉÔºó";
|
||
}
|
||
|
||
/**
|
||
* ¼Ç¼ÇëÇóÈÕÖ¾
|
||
* @param tx1
|
||
* @param contract_id ºÏͬ±àºÅ
|
||
* @param plan_id ×â½ð¼Æ»®±àºÅ
|
||
* @param bankname ÒøÐÐÃû³Æ
|
||
* @param acc_number ÒøÐÐÕ˺Å
|
||
* @param account ¿ª»§»§Ãû
|
||
* @param rent ¿Û¿î½ð¶î
|
||
* @throws JBOException
|
||
*/
|
||
public void archiveRedcodeLog(JBOTransaction tx1,String collect_sn,String contract_id,String plan_id,String customer_name,String certid,String mobile,String bankname,String acc_number,String account,String rent) throws JBOException{
|
||
BizObjectManager crlbm = JBOFactory.getFactory().getManager(COLLECT_RECORD_LOG.CLASS_NAME);
|
||
BizObject crl = crlbm.newObject();
|
||
tx1.join(crlbm);
|
||
crl.setAttributeValue("contract_id", contract_id);
|
||
crl.setAttributeValue("customer_name", customer_name);
|
||
crl.setAttributeValue("collect_sn", collect_sn);
|
||
crl.setAttributeValue("certid", certid);
|
||
crl.setAttributeValue("mobile", mobile);
|
||
crl.setAttributeValue("acc_number", acc_number);
|
||
crl.setAttributeValue("money", new BigDecimal(rent).multiply(new BigDecimal(100)).intValue());
|
||
crl.setAttributeValue("inputorg", getInputorgid());
|
||
crl.setAttributeValue("inputuser", getInputuserid());
|
||
crl.setAttributeValue("inputdate", DateAssistant.getToday());
|
||
crlbm.saveObject(crl);
|
||
}
|
||
|
||
/**
|
||
* ¼Ç¼ÇëÇóÁ÷Ë®ºÅ±ê־λ
|
||
* @param tx1
|
||
* @param contract_id ºÏͬ±àºÅ
|
||
* @param plan_id ×â½ð¼Æ»®±àºÅ
|
||
* @param bankname ÒøÐÐÃû³Æ
|
||
* @param acc_number ÒøÐÐÕ˺Å
|
||
* @param account ¿ª»§»§Ãû
|
||
* @param rent ¿Û¿î½ð¶î
|
||
* @throws JBOException
|
||
*/
|
||
public void archiveRedcodeStatus(JBOTransaction tx1,String collect_sn,String contract_id,String plan_id,String rent) throws JBOException{
|
||
BizObjectManager crsbm = JBOFactory.getFactory().getManager(COLLECT_RECORD_STATUS.CLASS_NAME);
|
||
BizObject crs = crsbm.newObject();
|
||
tx1.join(crsbm);
|
||
crs.setAttributeValue("contract_id", contract_id);
|
||
crs.setAttributeValue("rent_plan_id", plan_id);
|
||
crs.setAttributeValue("collect_sn", collect_sn);
|
||
crs.setAttributeValue("money", rent);
|
||
//´¦ÀíÖÐ,processing/´¦ÀíÍê³É,success/´¦Àíʧ°Ü,failure
|
||
crs.setAttributeValue("deduct_stata", "processing");
|
||
crs.setAttributeValue("inputorg", getInputorgid());
|
||
crs.setAttributeValue("inputuser", getInputuserid());
|
||
crs.setAttributeValue("inputdate", DateAssistant.getToday());
|
||
crsbm.saveObject(crs);
|
||
}
|
||
|
||
/**
|
||
* ´úÊÕ-·¢ËÍÇëÇó
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public Map<String, Object> singleBatchCollectMoeny(JBOTransaction tx,String collect_sn,String certid,String bankName,String accNumber,String account,String rent) throws Exception{
|
||
int money = new BigDecimal(rent).setScale(2).multiply(new BigDecimal(100)).intValue();
|
||
String serviceName = "payacq.transInTrans";
|
||
ZhongAnApiClient client = new ZhongAnApiClient(InitCollectConfig.C_ENV, InitCollectConfig.C_APPKEY, InitCollectConfig.C_PRIVATEKEY, InitCollectConfig.C_VERSION);
|
||
CommonRequest request = new CommonRequest(serviceName);
|
||
JSONObject params = new JSONObject();
|
||
//´«ÈëÒµÎñ²ÎÊý
|
||
params.put("version", InitCollectConfig.C_VERSION);
|
||
params.put("bizCat", InitCollectConfig.C_BIZCAT);
|
||
params.put("bizSys", InitCollectConfig.C_BIZSYS);
|
||
//½»Ò×Á÷Ë®ºÅ
|
||
String outTradeNo = collect_sn;
|
||
params.put("outTradeNo", outTradeNo);
|
||
params.put("bizType", InitCollectConfig.C_BIZTYPE);//"1-Ïû·Ñ 8-É깺 30-×·³¥"
|
||
System.out.println(new Date());
|
||
params.put("subBusinessCode", InitCollectConfig.C_SUBBUSINESSCODE);
|
||
params.put("businessCode", InitCollectConfig.C_BUSINESSCODE);
|
||
params.put("reqTime", new Date());
|
||
params.put("chanAcctId", InitCollectConfig.C_CHANACCTID);
|
||
// params.put("ccy", "");
|
||
params.put("orderAmt", money);
|
||
/*
|
||
1:½è¼Ç¿¨,
|
||
2:ÐÅÓÃÕË»§
|
||
3:ÖÐÐŵç×ÓÕË»§
|
||
5:΢ÐÅÖ§¸¶
|
||
7:¶þÀà»§£¨±¸×¢ 2Àà»§£©
|
||
8:Óà¶îÖ§¸¶¹¤¾ß
|
||
*/
|
||
JSONObject values = new JSONObject();
|
||
values.put("payerTool", "1");
|
||
values.put("payerAcctId", "0");
|
||
values.put("payerName", account);//»§Ãû
|
||
values.put("payerIdType", "l");
|
||
values.put("payerIdNo", accNumber);//ÒøÐп¨ºÅ
|
||
values.put("payerCardNo", certid);
|
||
values.put("payAmt", money);
|
||
params.put("payerInfoList", new Object[]{values});
|
||
request.setParams(params);
|
||
CommonResponse response = (CommonResponse) client.call(request);
|
||
Map<String, Object> map = JSON.parseObject(response.getBizContent());
|
||
if (null == map) {
|
||
map = new HashMap<String, Object>();
|
||
}
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* ²éѯÅúÁ¿ÊÕ¿î״̬
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String queryBatchCollectStatus(JBOTransaction tx,StringBuffer parms) throws Exception{
|
||
BizObjectManager bc = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME);
|
||
List<BizObject> bolist = bc.createQuery("select crs.rent_plan_id,crs.collect_sn,crs.money from O left join jbo.com.tenwa.lease.comm.COLLECT_RECORD_STATUS crs on crs.rent_plan_id = O.id where crs.collect_sn in ("+parms.toString()+")").getResultList(false);
|
||
List<String> listId = new ArrayList<String>();
|
||
for (BizObject bo : bolist) {
|
||
String plan_id = bo.getAttribute("rent_plan_id").toString();
|
||
String collect_sn = bo.getAttribute("collect_sn").toString();
|
||
Map<String, Object> result = queryTransQry(collect_sn);
|
||
JBOTransaction transaction = JBOFactory.createJBOTransaction();
|
||
BizObjectManager crsbm = JBOFactory.getFactory().getManager(COLLECT_RECORD_STATUS.CLASS_NAME,transaction);
|
||
if (result.containsKey("transStatus") && "3".equals(result.get("transStatus"))) {
|
||
//»ØÁý×â½ð
|
||
querysingleCollectMoeny(transaction, bo);
|
||
//¸üÐÂÊÕ¿î״̬
|
||
crsbm.createQuery("update O set O.deduct_stata = 'success',O.deduct_msg = '"+result.get("transMsg")+"' where O.rent_plan_id=:plan_id and O.collect_sn=:collect_sn ")
|
||
.setParameter("plan_id", plan_id).setParameter("collect_sn", collect_sn).executeUpdate();
|
||
}else if (result.containsKey("transStatus") && "9".equals(result.get("transStatus"))) {
|
||
//Èç¹û¿Û¿îʧ°Ü£¬¸üÐÂ״̬£¬²»»ØÁý×â½ð//////´¦ÀíÖÐ,processing/´¦ÀíÍê³É,success/´¦Àíʧ°Ü,failure
|
||
crsbm.createQuery("update O set O.deduct_stata = 'failure',O.deduct_msg = '"+result.get("transMsg")+"' where O.rent_plan_id=:plan_id and O.collect_sn=:collect_sn ")
|
||
.setParameter("plan_id", plan_id).setParameter("collect_sn", collect_sn).executeUpdate();
|
||
} else{
|
||
//ÕýÔÚ´¦ÀíÖУ¬²»×öÈκβÙ×ö
|
||
}
|
||
transaction.commit();
|
||
if (!listId.contains(plan_id)) {
|
||
listId.add(plan_id);
|
||
}
|
||
|
||
}
|
||
Object[] arryId = listId.toArray();
|
||
StringBuffer arryparm = new StringBuffer();
|
||
for (Object string : arryId) {
|
||
if (arryparm.length() == 0) {
|
||
arryparm.append("'"+string+"'");
|
||
}else {
|
||
arryparm.append(",'"+string+"'");
|
||
}
|
||
}
|
||
BizObjectManager crsbm = JBOFactory.getFactory().getManager(COLLECT_RECORD_STATUS.CLASS_NAME);
|
||
List<BizObject> querylist = crsbm.createQuery("select v.GROUP_CONCAT(O.deduct_stata) AS v.debuct_statas,O.rent_plan_id from O where O.rent_plan_id in ("+arryparm.toString()+") ").getResultList(false);
|
||
for (BizObject biz : querylist) {
|
||
String deduct_stata = biz.getAttribute("debuct_statas").toString();
|
||
String plan_id = biz.getAttribute("rent_plan_id").toString();
|
||
//´¦ÀíÖÐ,processing/´¦ÀíÍê³É,success/´¦Àíʧ°Ü,failure
|
||
if (deduct_stata.contains("processing") && deduct_stata.contains("success") && deduct_stata.contains("failure")) {
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
bc.createQuery("update O set O.collect_status = '1' where id = '"+plan_id+"'").executeUpdate();
|
||
}else if (!deduct_stata.contains("processing") && deduct_stata.contains("success") && deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
bc.createQuery("update O set O.collect_status = '2' where id = '"+plan_id+"'").executeUpdate();
|
||
}else if (!deduct_stata.contains("processing") && deduct_stata.contains("success") && !deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
bc.createQuery("update O set O.collect_status = '3' where id = '"+plan_id+"'").executeUpdate();
|
||
}else if (!deduct_stata.contains("processing") && !deduct_stata.contains("success") && deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
bc.createQuery("update O set O.collect_status = '4' where id = '"+plan_id+"'").executeUpdate();
|
||
}
|
||
}
|
||
|
||
return "sucess";
|
||
|
||
}
|
||
|
||
public static String getDeductStata(String plan_id){
|
||
JBOTransaction tx = null;
|
||
StringBuffer result = new StringBuffer();
|
||
try {
|
||
tx = JBOFactory.createJBOTransaction();
|
||
BizObjectManager crsbm = JBOFactory.getFactory().getManager(COLLECT_RECORD_STATUS.CLASS_NAME,tx);
|
||
BizObject querybiz = crsbm.createQuery("select v.GROUP_CONCAT(O.deduct_stata) AS v.debuct_statas,v.GROUP_CONCAT(O.deduct_msg) AS v.debuct_msgs from O where O.rent_plan_id =:plan_id ").setParameter("plan_id", plan_id).getSingleResult(false);
|
||
if(null != querybiz) {
|
||
String deduct_stata = querybiz.getAttribute("debuct_statas").toString();
|
||
String[] deduct_statas = querybiz.getAttribute("debuct_statas").toString().trim().split(",");
|
||
String[] debuct_msgs = querybiz.getAttribute("debuct_msgs").toString().trim().split(",");
|
||
//´¦ÀíÖÐ,processing/´¦ÀíÍê³É,success/´¦Àíʧ°Ü,failure
|
||
if (deduct_stata.contains("processing") && deduct_stata.contains("success") && deduct_stata.contains("failure")) {
|
||
result.append("²¿·ÖÊÕ¿î >> ÊÕ¿îÖÐ >> ");
|
||
for (int i = 0; i < deduct_statas.length; i++) {
|
||
if (deduct_statas[i].contains("failure")) {
|
||
result.append(debuct_msgs[i]);
|
||
break;
|
||
}
|
||
}
|
||
}else if (deduct_stata.contains("processing") && !deduct_stata.contains("success") && !deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
result.append("ÊÕ¿îÖÐ ");
|
||
}else if (!deduct_stata.contains("processing") && deduct_stata.contains("success") && deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
result.append("²¿·ÖÊÕ¿î >>> ");
|
||
for (int i = 0; i < deduct_statas.length; i++) {
|
||
if (deduct_statas[i].contains("failure")) {
|
||
result.append(debuct_msgs[i]);
|
||
break;
|
||
}
|
||
}
|
||
|
||
}else if (!deduct_stata.contains("processing") && deduct_stata.contains("success") && !deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
result.append("ÊÕ¿î³É¹¦ ");
|
||
}else if (!deduct_stata.contains("processing") && !deduct_stata.contains("success") && deduct_stata.contains("failure")){
|
||
//¸üÐÂ״̬,1,´¦ÀíÖÐ,2,²¿·ÖÊÕ¿î,3,ÊÕ¿î³É¹¦,4,ÊÕ¿îʧ°Ü,5,δÊÕ¿î
|
||
result.append("ÊÕ¿îʧ°Ü >>> ");
|
||
for (int i = 0; i < deduct_statas.length; i++) {
|
||
if (deduct_statas[i].contains("failure")) {
|
||
result.append(debuct_msgs[i]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return result.toString().trim();
|
||
} catch (JBOException e) {
|
||
if (tx != null) {
|
||
try {
|
||
tx.rollback();
|
||
} catch (JBOException e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
}
|
||
}
|
||
}finally{
|
||
try {
|
||
tx.commit();
|
||
} catch (JBOException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
return result.toString().trim();
|
||
|
||
}
|
||
|
||
/**
|
||
* ²éѯ¿Û¿îÊÇ·ñ³É¹¦
|
||
* @param outTradeNo
|
||
* @return
|
||
*/
|
||
public Map<String, Object> queryTransQry(String outTradeNo) {
|
||
String serviceName = "payacq.transQry";
|
||
Map<String, Object> result = new HashMap<String, Object>();
|
||
try {
|
||
ZhongAnApiClient client = new ZhongAnApiClient(InitCollectConfig.C_ENV, InitCollectConfig.C_APPKEY, InitCollectConfig.C_PRIVATEKEY, InitCollectConfig.C_VERSION);
|
||
CommonRequest request = new CommonRequest(serviceName);
|
||
JSONObject params = new JSONObject();
|
||
//´«ÈëÒµÎñ²ÎÊý
|
||
params.put("version", InitCollectConfig.C_VERSION);
|
||
params.put("chanAcctId", InitCollectConfig.C_CHANACCTID);
|
||
params.put("outTradeNo", outTradeNo);
|
||
params.put("bizCat", InitCollectConfig.C_BIZCAT);
|
||
params.put("bizSys", InitCollectConfig.C_BIZSYS);
|
||
request.setParams(params);
|
||
CommonResponse response = (CommonResponse) client.call(request);
|
||
System.out.println(response);
|
||
result = JSON.parseObject(response.getBizContent());
|
||
} catch (ZhongAnOpenException e) {
|
||
e.printStackTrace();
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* ²éѯ½Ó¿Ú--»ØÁý×â½ð
|
||
* @param tx
|
||
* @param bc
|
||
* @param bo
|
||
* @param rent
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public void querysingleCollectMoeny(JBOTransaction tx,BizObject bo) throws Exception{
|
||
String cerrentDate = DateAssistant.getToday();
|
||
JBOTransaction transaction = tx;
|
||
int hire_index = JBOFactory.getBizObjectManager(LC_RENT_INCOME.CLASS_NAME, transaction).createQuery("select COUNT(O.plan_id) from O GROUP BY O.plan_id HAVING O.plan_id=:plan_id ").getResultList(false).size() + 1;
|
||
BigDecimal money_value = new BigDecimal(bo.getAttribute("moeny").toString()).setScale(2);
|
||
BizObjectManager bmi = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,transaction);
|
||
BizObject boi = bmi.createQuery("SELECT v.REPLACE(v.UUID(),'-','') AS id, O.QUOT_ID AS QUOT_ID, O.CUST_ID AS CUST_ID, O.PROJECT_ID AS PROJECT_ID, O.PROJECT_PLAN_NUMBER AS PROJECT_PLAN_NUMBER, "
|
||
+ "O.CONTRACT_ID AS CONTRACT_ID, O.CONTRACT_PLAN_NUMBER AS CONTRACT_PLAN_NUMBER, "
|
||
+ "O.PAYMENT_NUMBER AS PAYMENT_NUMBER, '' AS v.EBANK_NUMBER, O.id AS v.PLAN_ID, "
|
||
+ "O.PLAN_LIST AS PLAN_LIST, '0' AS v.INTEREST_ADJUST, 'settlemethod6' AS SETTLE_METHOD, "
|
||
+ " '"+hire_index+"' AS v.HIRE_LIST, '"+cerrentDate+"' AS HIRE_DATE, vl.rent_over AS RENT, "
|
||
+ "vl.corpus_over AS CORPUS, vl.interest_over AS INTEREST, vl.penalty_over AS PENALTY,"
|
||
+ " '0' AS CORPUS_ADJUST, '0' AS PENALTY_ADJUST, '0' AS ROLL_BACK, O.COIN AS 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 = "";
|
||
BigDecimal interest_value = new BigDecimal(boi.getAttribute("interest").toString()).setScale(2);
|
||
BigDecimal corpus_value = new BigDecimal(boi.getAttribute("corpus").toString()).setScale(2);
|
||
BigDecimal penalty_value = new BigDecimal(boi.getAttribute("penalty").toString()).setScale(2);
|
||
BigDecimal rent_value = new BigDecimal(boi.getAttribute("rent").toString()).setScale(2);
|
||
BigDecimal rent = new BigDecimal(0);
|
||
BigDecimal corpus = new BigDecimal(0);
|
||
BigDecimal interest = new BigDecimal(0);
|
||
BigDecimal penalty = new BigDecimal(0);
|
||
if (rent_value.add(penalty_value).compareTo(money_value) == 0) {//Èç¹û ×â½ð+·£Ï¢=±¾´Î¿Û¿î½ð¶î
|
||
rent = rent_value;
|
||
corpus = corpus_value;
|
||
interest = interest_value;
|
||
penalty = penalty_value;
|
||
}else if (interest_value.doubleValue() > 0 && (money_value.compareTo(interest_value) == -1 || money_value.compareTo(interest_value) == 0)) {//Ê£ÓàÀûÏ¢´óÓÚ0,±¾´Î¿Û¿î½ð¶îСÓÚ»òµÈÓÚÀûÏ¢
|
||
rent = money_value;
|
||
interest = money_value;
|
||
}else if (interest_value.doubleValue() > 0 && money_value.compareTo(interest_value) == 1) { //Ê£ÓàÀûÏ¢´óÓÚ0,±¾´Î¿Û¿î½ð¶î´óÓÚÀûÏ¢
|
||
rent = money_value;
|
||
corpus = money_value.subtract(interest_value).setScale(2);
|
||
interest = interest_value;
|
||
}else if (corpus_value.doubleValue() > 0 && (money_value.compareTo(corpus_value) == -1 || money_value.compareTo(corpus_value) == 0)) {//±¾½ð´óÓÚ0,±¾´Î¿Û¿î½ð¶îСÓÚ»òµÈÓÚ±¾½ð
|
||
rent = money_value;
|
||
corpus = money_value;
|
||
}else if (corpus_value.doubleValue() > 0 && money_value.compareTo(corpus_value) == 1) {//±¾½ð´óÓÚ0,±¾´Î¿Û¿î½ð¶î´óÓÚ±¾½ð
|
||
rent = money_value;
|
||
corpus = corpus_value;
|
||
penalty = money_value.subtract(corpus_value).setScale(2);
|
||
}else if (penalty_value.doubleValue() > 0 && (money_value.compareTo(penalty_value) == -1 || money_value.compareTo(penalty_value) == 0)) {//·£Ï¢´óÓÚ0,±¾´Î¿Û¿î½ð¶îСÓÚ»òµÈÓÚ·£Ï¢
|
||
rent = money_value;
|
||
penalty = money_value;
|
||
}else if (penalty_value.doubleValue() > 0 && money_value.compareTo(penalty_value) == 1) {//·£Ï¢´óÓÚ0,±¾´Î¿Û¿î½ð¶î´óÓÚ·£Ï¢
|
||
rent = money_value;
|
||
corpus = money_value.subtract(interest_value).subtract(corpus_value).setScale(2);
|
||
interest = money_value.subtract(interest_value).setScale(2);
|
||
penalty = penalty_value;
|
||
}
|
||
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")+"','"+rent.toString()+"','"+corpus.toString()+"',"
|
||
+ "'"+interest.toString()+"','"+penalty.toString()+"','"+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);
|
||
}
|
||
}
|
||
|
||
|
||
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 getId() {
|
||
return id;
|
||
}
|
||
|
||
public void setId(String id) {
|
||
this.id = id;
|
||
}
|
||
|
||
}
|