76 lines
2.0 KiB
Java
76 lines
2.0 KiB
Java
package com.tenwa.customer.controller.person;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import jbo.app.tenwa.customer.CUSTOMER_ATTRIBUTION;
|
|
import jbo.app.tenwa.customer.CUSTOMER_INFO;
|
|
|
|
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.tenwa.comm.util.jboutil.DataOperatorUtil;
|
|
|
|
public class CustomerPersonCommonAction {
|
|
private String userId="";
|
|
private String customerid="";
|
|
public String getUserId() {
|
|
return userId;
|
|
}
|
|
public void setUserId(String userId) {
|
|
this.userId = userId;
|
|
}
|
|
public String getCustomerid() {
|
|
return customerid;
|
|
}
|
|
public void setCustomerid(String customerid) {
|
|
this.customerid = customerid;
|
|
}
|
|
/**
|
|
* 检查是否主归属人
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String checkAttribution(JBOTransaction tx)throws Exception {
|
|
Map<String,String> cond=new HashMap<String, String>();
|
|
cond.put("customerid", customerid);
|
|
cond.put("userid", userId);
|
|
cond.put("isMain", "yes");
|
|
List<BizObject> list=DataOperatorUtil.getSetJBO(CUSTOMER_ATTRIBUTION.CLASS_NAME, cond, tx);
|
|
if(list.size()>0)
|
|
{
|
|
return "1";
|
|
}
|
|
return "0";
|
|
}
|
|
|
|
/**
|
|
* 将客户状态改为废弃
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String invalid (JBOTransaction tx)throws Exception {
|
|
String result = "NO";
|
|
BizObjectManager bm = JBOFactory.getBizObjectManager(CUSTOMER_INFO.CLASS_NAME);
|
|
tx.join(bm);
|
|
BizObject bo = bm.createQuery("select status from O where customerid=:customerid ").setParameter("customerid",customerid).getSingleResult(false);
|
|
if(bo!=null){
|
|
String isinvalid=bo.getAttribute("status").getString();
|
|
if(isinvalid.equals("status03")){
|
|
return "YES";
|
|
}
|
|
}
|
|
BizObjectQuery bq = bm.createQuery("update O set status='status03' where customerid=:customerid ");
|
|
bq.setParameter("customerid",customerid);
|
|
bq.executeUpdate();
|
|
return result;
|
|
}
|
|
|
|
}
|