apzl_leasing/src_tenwa/com/tenwa/customer/handler/account/CustomerAccountHandler.java
2018-06-03 22:26:41 +08:00

62 lines
2.2 KiB
Java

package com.tenwa.customer.handler.account;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
public class CustomerAccountHandler extends CommonHandler{
@Override
protected void beforeUpdate(JBOTransaction tx, BizObject bo)throws Exception {
//修改前判断是否主账户,若为主账户则其它账户都设为非主账户
//获取当前客户ID
String customer_id=this.asPage.getAttribute("customer_id").toString();
//获取当前修改账户ID
String id=this.asPage.getAttribute("id").toString();
//如果是否主账户为是
if(bo.getAttribute("is_main").toString().equals("yes")){
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME);
tx.join(bom);
//先将当前客户所有账户设置为非主账户
BizObjectQuery boq = bom.createQuery("update O set is_main = 'no' where customerid=:customerid ").setParameter("customerid",customer_id);
boq.executeUpdate();
//然后将当前账户设置为主账户
BizObjectQuery boq1 = bom.createQuery("update O set is_main = 'yes' where id=:id ").setParameter("id",id);
boq1.executeUpdate();
}
super.beforeUpdate(tx, bo);
}
@Override
protected void beforeInsert(JBOTransaction tx, BizObject bo)throws Exception {
//新增之前判断是否主账户,若为主账户则其它账户都设为非主账户
//获取当前客户ID
String customer_id=this.asPage.getAttribute("customer_id").toString();
//如果是否主账户为是
if(bo.getAttribute("is_main").toString().equals("yes")){
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT.CLASS_NAME);
tx.join(bom);
//将当前客户之前所有账户设置为非主账户
BizObjectQuery boq = bom.createQuery("update O set is_main = 'no' where customerid=:customerid ").setParameter("customerid",customer_id);
boq.executeUpdate();
}
super.initDisplayForAdd(bo);
}
@Override
protected void initDisplayForAdd(BizObject bo) throws Exception {
//获取当前客户ID
String customer_id=this.asPage.getAttribute("customer_id").toString();
//新增时初始化客户ID
bo.setAttributeValue("customerid", customer_id);
super.initDisplayForAdd(bo);
}
}