apzl_leasing/src_tenwa/com/tenwa/loan/action/LoanBillAction.java
2018-06-03 22:26:41 +08:00

65 lines
2.4 KiB
Java

package com.tenwa.loan.action;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import jbo.loan.LOAN_BILL_INFO;
import jbo.loan.LOAN_CORPUS_PLAN;
import jbo.loan.LOAN_FUND_RENT_INCOME;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.loan.calc.FinancingCalculateServiceImpl;
public class LoanBillAction {
public String billid;
public String lastdate;
@SuppressWarnings("unchecked")
public String calculationIntesert(JBOTransaction tx) throws Exception{
List<BizObject> list=JBOFactory.createBizObjectQuery(LOAN_CORPUS_PLAN.CLASS_NAME,"bill_id=:billid").setParameter("billid", this.billid).getResultList(false);
BizObject billinfo=JBOFactory.createBizObjectQuery(LOAN_BILL_INFO.CLASS_NAME,"id=:id").setParameter("id", this.billid).getSingleResult(false);
BigDecimal billAmount=new BigDecimal( billinfo.getAttribute("LOAN_AMOUNT").getString());
BigDecimal corpus=BigDecimal.ZERO;
for(BizObject plan:list){
corpus=corpus.add(new BigDecimal(plan.getAttribute("CORPUS").getString()));
}
if(billAmount.compareTo(corpus)!=0){
return "本金总和不等借款金额,请检查";
}
FinancingCalculateServiceImpl fc=new FinancingCalculateServiceImpl();
fc.updateLoanInterestPlan(billinfo, this.lastdate,UUID.randomUUID().toString().replaceAll("-", ""), "his_plan_change", tx);
return "操作成功";
}
public String chackDelete(JBOTransaction tx) throws Exception{
BizObject bill=JBOFactory.createBizObjectQuery(LOAN_BILL_INFO.CLASS_NAME,"id=:id").setParameter("id", this.billid).getSingleResult(false);
if("已核销".equals(bill.getAttribute("AUDIT_STATUS").getString())){
return "提款单已核销,不能删除!";
}
String sql="select sum(rent) RENT from loan_fund_rent_income where bill_id='"+this.billid+"'";
List<Map<String,String>> list=DataOperatorUtil.getDataBySql(tx, sql, null);
if(list.size()>0&&list.get(0).get("RENT")!=null&&new BigDecimal(list.get(0).get("RENT")).compareTo(BigDecimal.ZERO)!=0){
return "还款计划有核销记录,不能删除";
}
return "true";
}
public String getBillid() {
return billid;
}
public void setBillid(String billid) {
this.billid = billid;
}
public String getLastdate() {
return lastdate;
}
public void setLastdate(String lastdate) {
this.lastdate = lastdate;
}
}