apzl_leasing/src_tenwa/com/tenwa/util/MakeContractCheck.java
2021-03-03 14:49:50 +08:00

107 lines
5.7 KiB
Java

package com.tenwa.util;
import java.util.List;
import jbo.app.tenwa.calc.LC_CARD_TLSIGN;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT_HIS;
import jbo.app.tenwa.customer.LB_CARD_SIGN_STATUS_HIS;
import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
public class MakeContractCheck {
public static String checkSignStatus (String projectId){
JBOTransaction tx = null;
try {
tx = JBOFactory.createJBOTransaction();
BizObjectManager caManage = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME,tx);
BizObject ca = caManage.createQuery("PROJECT_ID=:projectid").setParameter("projectid", projectId).getSingleResult(true);
if(ca==null){
return "未查询到扣款信息,请联系管理员!" ;
}else{
String collect_type = ca.getAttribute("collect_type").getString();
String account = ca.getAttribute("account").getString();
String acc_number = ca.getAttribute("acc_number").getString();
String certId = ca.getAttribute("certId").getString();
String mobile = ca.getAttribute("mobile").getString();
BizObjectManager lpiManage = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME);
BizObject lpi = lpiManage.createQuery(" id=:projectid").setParameter("projectid", projectId).getSingleResult(false);
String subjectId= lpi.getAttribute("subjectid").toString();
if(collect_type.equals("YLcollect")){//广州银联
if(!"Y".equals(ca.getAttribute("SIGN_STATUS").getString())){
BizObjectManager cahManage = JBOFactory.getFactory().getManager(CUSTOMER_ACCOUNT_HIS.CLASS_NAME);
String sql ="select O.id from O left join jbo.com.tenwa.lease.comm.LB_PROJECT_INFO lpi on lpi.id=O.project_id where O.sign_status='Y' and O.account=:account and O.acc_number=:acc_number and O.certid=:certid and O.collect_type='YLcollect' and lpi.subjectid=:subjectid";
List<BizObject> cahs = cahManage.createQuery(sql).setParameter("account", account).setParameter("acc_number", acc_number).setParameter("certid", certId).setParameter("subjectid", subjectId).getResultList(false);
List<BizObject> cas = caManage.createQuery(sql).setParameter("account", account).setParameter("acc_number", acc_number).setParameter("certid", certId).setParameter("subjectid", subjectId).getResultList(false);
if( (cahs != null && cahs.size() > 0) || (cas != null && cas.size() > 0) ){
ca.setAttributeValue("sign_status", "Y");
caManage.saveObject(ca);
}else{
return "请提醒客户查看手机短信,完成广州银联扣款卡的签约验证!";
}
}
} else {//通联
BizObjectManager lctManage = JBOFactory.getBizObjectManager(LC_CARD_TLSIGN.CLASS_NAME, tx);
BizObject lct = lctManage.createQuery(" project_id=:project_id and sign_type=:signType ").setParameter("project_id", projectId).setParameter("signType", collect_type).getSingleResult(true);
if( lct==null || (!"sign_status2".equals(lct.getAttribute("sign_status").getString()) ) ){
//查询历史是否签约
BizObjectManager lcsshManage = JBOFactory.getFactory().getManager(LB_CARD_SIGN_STATUS_HIS.CLASS_NAME);
BizObject lcss = lcsshManage.createQuery("select O.AGRMNO from O left join jbo.com.tenwa.lease.comm.LB_PROJECT_INFO lpi on lpi.id=O.project_id where O.tl_status='sign_status2' and O.account=:account and O.acc_number=:acc_number and O.certid=:certid and O.mobile=:mobile and O.sign_type=:sign_type and lpi.subjectid=:subjectId ")
.setParameter("account", account).setParameter("acc_number", acc_number).setParameter("certid", certId).setParameter("mobile", mobile).setParameter("sign_type", collect_type).setParameter("subjectId", subjectId).getSingleResult(false);
//查看现有卡是否签约
BizObject caAgrmno = lctManage.createQuery("select O.AGRMNO from O left join jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca on ca.project_id=O.project_id left join jbo.com.tenwa.lease.comm.LB_PROJECT_INFO lpi on lpi.id=O.project_id where O.sign_status='sign_status2' and lpi.subjectid=:subjectid and O.sign_type=:sign_type and ca.acc_number=:acc_number and ca.certid=:certid and ca.mobile=:mobile ")
.setParameter("subjectId", subjectId).setParameter("sign_type", collect_type).setParameter("account", account).setParameter("acc_number", acc_number).setParameter("certid", certId).setParameter("mobile", mobile).getSingleResult(false);
if( lcss !=null || caAgrmno!=null){
lct = lctManage.createQuery(" project_id=:project_id ").setParameter("project_id", projectId).getSingleResult(true);
if(lct == null){
lct = lctManage.newObject();
lct.setAttributeValue("PROJECT_ID", projectId);
}
lct.setAttributeValue("SIGN_STATUS", "sign_status2");
lct.setAttributeValue("sign_type", collect_type);
lct.setAttributeValue("AGRMNO", lcss!=null ? lcss.getAttribute("agrmno").getString(): caAgrmno.getAttribute("agrmno").getString());
lctManage.saveObject(lct);
}else if (collect_type.equals("TLcollect")){
return "请提醒客户查看手机短信,完成通联扣款卡的签约验证!";
}else if(collect_type.equals("YCcollect")){
return "请提醒客户查看手机短信,完成邮储扣款卡的签约验证!";
}else{
return "未查询到对应的扣款渠道,请联系管理员!" ;
}
}
}
}
return "success" ;
} catch (Exception e) {
try {
if( tx != null){
tx.rollback();
}
} catch (JBOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
return "error" ;
}finally{
try {
if(tx != null){
tx.commit();
}
} catch (JBOException e) {
e.printStackTrace();
}
}
}
}