2018-06-03 22:26:41 +08:00

79 lines
3.2 KiB
Java

package com.tenwa.flow.fund.flowpayment;
import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP;
import jbo.com.tenwa.lease.comm.LC_PAY_CONDTION_TEMP;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
public class CancelFundPayment {
private String planids;
private String flowunid;
private String equipAmtIDs;
public String getEquipAmtIDs() {
return equipAmtIDs;
}
public void setEquipAmtIDs(String equipAmtIDs) {
this.equipAmtIDs = equipAmtIDs;
}
public String getPlanids() {
return planids;
}
public void setPlanids(String planids) {
this.planids = planids;
}
public String getFlowunid() {
return flowunid;
}
public void setFlowunid(String flowunid) {
this.flowunid = flowunid;
}
public String cancelFundPayment(JBOTransaction tx) throws Exception{
try{
BizObjectManager boLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME);
BizObjectManager boLPCT = JBOFactory.getBizObjectManager(LC_PAY_CONDTION_TEMP.CLASS_NAME);
tx.join(boLFIT);
tx.join(boLPCT);
if(planids != null){
String[] ids = planids.split("@");
for(int i=0;i<ids.length;i++){
BizObject bo = boLFIT.createQuery("id=:ID").setParameter("ID", ids[i]).getSingleResult(false);
boLPCT.createQuery("delete from O where payment_number=:paymentNumber and fee_type=:feeType and plan_list=:planList and flowunid=:FlowUnid")
.setParameter("paymentNumber", bo.getAttribute("payment_number").getString())
.setParameter("feeType", bo.getAttribute("fee_type").getString())
.setParameter("planList", bo.getAttribute("plan_list").getString())
.setParameter("FlowUnid", flowunid)
.executeUpdate();
boLFIT.createQuery("delete from O where id=:ID and flowunid=:FlowUnid").setParameter("ID", ids[i]).setParameter("FlowUnid", flowunid).executeUpdate();
if(bo.getAttribute("SETTLE_METHOD").getString().equals("settlemethod11")){
boLFIT.createQuery("delete from O where plan_id=:ID and flowunid=:FlowUnid").setParameter("ID",bo.getAttribute("plan_id").getString()).setParameter("FlowUnid", flowunid).executeUpdate();
}
}
}
if(equipAmtIDs != null){
String[] eaids = equipAmtIDs.split("@");
for(int i=0;i<eaids.length;i++){
BizObject bo = boLFIT.createQuery("id=:ID").setParameter("ID", eaids[i]).getSingleResult(false);
boLPCT.createQuery("delete from O where payment_number=:paymentNumber and fee_type=:feeType and plan_list=:planList and flowunid=:FlowUnid")
.setParameter("paymentNumber", bo.getAttribute("payment_number").getString())
.setParameter("feeType", bo.getAttribute("fee_type").getString())
.setParameter("planList", bo.getAttribute("plan_list").getString())
.setParameter("FlowUnid", flowunid)
.executeUpdate();
boLFIT.createQuery("delete from O where id=:ID and flowunid=:FlowUnid").setParameter("ID", eaids[i]).setParameter("FlowUnid", flowunid).executeUpdate();
boLFIT.createQuery("delete from O where relative_id=:ID and flowunid=:FlowUnid").setParameter("ID", eaids[i]).setParameter("FlowUnid", flowunid).executeUpdate();
}
}
}catch(Exception e){
e.printStackTrace();
return "ERROR";
}
return "SUCCESS";
}
}