经销商分类,一个经销商只能关联一个集团

This commit is contained in:
tangfutang 2018-07-24 16:23:01 +08:00
parent f5c041496f
commit 2c0d8d6dbc

View File

@ -1,5 +1,8 @@
package com.tenwa.customer.handler.group;
import jbo.app.tenwa.customer.CUSTOMER_GROUP_RELATION;
import java.util.List;
import jbo.app.tenwa.customer.CUSTOMER_GROUP_RELATION;
import jbo.app.tenwa.customer.DISTRIBUTOR_GROUP_COMPANY;
import jbo.app.tenwa.customer.DISTRIBUTOR_GROUP_RELATION;
import com.amarsoft.are.jbo.BizObject;
@ -23,6 +26,7 @@ import com.amarsoft.awe.dw.handler.impl.CommonHandler;
String distributor_id = bo.getAttribute("distributor_id").getString();
String groupId = bo.getAttribute("group_id").getString();
BizObjectManager bom = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_RELATION.CLASS_NAME);
BizObjectManager dgcManage = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_COMPANY.CLASS_NAME);
if("".equals(Id)){
BizObject cgr = bom.createQuery("group_id=:group_id and distributor_id=:distributor_id ").setParameter("group_id",groupId).setParameter("distributor_id",distributor_id).getSingleResult(false);
@ -30,7 +34,18 @@ import com.amarsoft.awe.dw.handler.impl.CommonHandler;
this.errors="¸Ã¼¯ÍÅÒÑ´æÔڴ˿ͻ§£¡";
return false;
}
}else{
List<BizObject> cgrList = bom.createQuery("distributor_id=:distributor_id ").setParameter("distributor_id",distributor_id).getResultList(false);
if(cgrList!=null){
for(BizObject cgrs:cgrList){
BizObject dgc = dgcManage.createQuery("id=:groupId and tyle='01'").setParameter("groupId", cgrs.getAttribute("group_id").getString()).getSingleResult(false);
if(dgc!=null){
this.errors="该经销商已存在"+dgc.getAttribute("group_name").getString()+"集团中!";
return false;
}
}
}
}else{
BizObject b=bom.createQuery("id=:id").setParameter("id", Id).getSingleResult(false);
String bdistributor_id=b.getAttribute("distributor_id").toString();
if(!(bdistributor_id.equals(distributor_id))){