194 lines
5.6 KiB
Java
194 lines
5.6 KiB
Java
package com.tenwa.customer.controller.address;
|
|
|
|
import java.util.List;
|
|
|
|
import jbo.app.tenwa.customer.CUSTOMER_ADDRESS;
|
|
|
|
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;
|
|
|
|
public class CustomerAddressController {
|
|
private String id="";
|
|
private String customer_id="";
|
|
private String addtype="";
|
|
|
|
public String getAddtype() {
|
|
return addtype;
|
|
}
|
|
|
|
public void setAddtype(String addtype) {
|
|
this.addtype = addtype;
|
|
}
|
|
|
|
public String getCustomer_id() {
|
|
return customer_id;
|
|
}
|
|
|
|
public void setCustomer_id(String customer_id) {
|
|
this.customer_id = customer_id;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
/**
|
|
* 设置为默认联系地址
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String setCommunicationAdd(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将所有地址设为非默认地址
|
|
BizObjectQuery boq1 = bom.createQuery("update O set isadd = 'no' where customerid=:customerid ");
|
|
boq1.setParameter("customerid", customer_id);
|
|
boq1.executeUpdate();
|
|
//将此地址设为默认联系地址
|
|
BizObjectQuery boq2 = bom.createQuery("update O set isadd = 'yes' where id=:id ").setParameter("id", id);
|
|
int i = boq2.executeUpdate();
|
|
String s = "";
|
|
if(i == 1){
|
|
s = "yes";
|
|
}
|
|
return s;
|
|
}
|
|
|
|
/**
|
|
* 查询当前客户有无联系地址
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String selectAddress(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//查询当前客户有无联系地址
|
|
List<BizObject> CUSTOMER_ADDRESSS = bom.createQuery("customerid=:customerid").setParameter("customerid",customer_id).getResultList(false);
|
|
if(CUSTOMER_ADDRESSS != null && CUSTOMER_ADDRESSS.size() > 0){
|
|
return "true";
|
|
}
|
|
return "false";
|
|
}
|
|
|
|
/**
|
|
* 查询当前客户有无联系地址
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String getAddress(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//查询当前客户有无联系地址
|
|
List<BizObject> CUSTOMER_ADDRESSS = bom.createQuery("customerid=:customerid and isadd='yes'").setParameter("customerid",customer_id).getResultList(false);
|
|
if(CUSTOMER_ADDRESSS != null && CUSTOMER_ADDRESSS.size() > 0){
|
|
return "true";
|
|
}
|
|
return "false";
|
|
}
|
|
|
|
/**
|
|
* 查询当前客户有无联系地址
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String selectEditAddress(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//查询当前客户有无除此条外的联系地址
|
|
List<BizObject> CUSTOMER_ADDRESSS = bom.createQuery("customerid=:customerid and id<>:id and isadd='yes'").setParameter("customerid",customer_id).setParameter("id",id).getResultList(false);
|
|
if(CUSTOMER_ADDRESSS != null && CUSTOMER_ADDRESSS.size() > 0){
|
|
return "true";
|
|
}
|
|
return "false";
|
|
}
|
|
|
|
/**
|
|
* 设置为最新
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String setNew(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将此类联系地址其它联系地址设为非最新
|
|
BizObjectQuery boq1 = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and addtype=:addtype");
|
|
boq1.setParameter("customerid", customer_id).setParameter("addtype",addtype);
|
|
boq1.executeUpdate();
|
|
//将此联系地址设为最新
|
|
BizObjectQuery boq2 = bom.createQuery("update O set isnew = 'yes' where id=:id ").setParameter("id", id);
|
|
int i = boq2.executeUpdate();
|
|
String s = "";
|
|
if(i == 1){
|
|
s = "yes";
|
|
}
|
|
return s;
|
|
}
|
|
|
|
/**
|
|
* 更新是否默认地址
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public void updateisadd(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将所有联系地址设为非最新
|
|
BizObjectQuery boq1 = bom.createQuery("update O set isadd = 'no' where customerid=:customerid");
|
|
boq1.setParameter("customerid", customer_id);
|
|
boq1.executeUpdate();
|
|
//将此联系地址设为最新
|
|
BizObjectQuery boq2 = bom.createQuery("update O set isadd = 'yes' where id=:id ").setParameter("id", id);
|
|
boq2.executeUpdate();
|
|
}
|
|
|
|
/**
|
|
* 更新是否最新
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public void updateisnew(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将所有联系地址设为非最新
|
|
BizObjectQuery boq1 = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and addtype=:addtype");
|
|
boq1.setParameter("customerid", customer_id).setParameter("addtype",addtype);
|
|
boq1.executeUpdate();
|
|
//将此联系地址设为最新
|
|
BizObjectQuery boq2 = bom.createQuery("update O set isnew = 'yes' where id=:id ").setParameter("id", id);
|
|
boq2.executeUpdate();
|
|
}
|
|
|
|
/**
|
|
* 取消最新
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String cancelNew(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME);
|
|
tx.join(bom);
|
|
//将此联系地址更新为非最新
|
|
BizObjectQuery boq = bom.createQuery("update O set isnew = 'no' where id=:id ").setParameter("id", id);
|
|
int i = boq.executeUpdate();
|
|
String s = "";
|
|
if(i == 1){
|
|
s = "yes";
|
|
}
|
|
return s;
|
|
}
|
|
}
|