服務中心

MemberManager.Action

 

//服務中心的顯示

 /**
  * 得到指定 地區 的服務中心 一個地區對應一個服務中心 如果沒有就往上一級找
  *
  * @param areaID
  * @return
  */
 public AgentAreaDepartment getDepartmentByArea(long areaID) {
  City root = (City) ApplicationContext.getAttribute("AREA");
  City c = root.find(areaID);
  String sql = "select * from shop_agentareadepartments  where areaid='"
    + areaID + "'";
  List<DbObject> l = super.query(AgentAreaDepartment.class, sql, -1, -1);
  if (l.size() != 0) {
   return (AgentAreaDepartment) l.get(0);
  } else {
   if (c.getParentid() != -1) {
    return this.getDepartmentByArea(c.bgetParent().getId());
   }
   return null;
  }
 }

 

 /**
  * 指定 地區 的服務中心
  *
  * @param areaID
  * @return
  */
 public AgentAreaDepartment getDepartmentByArea2(long areaID) {
  String sql = "select * from shop_agentareadepartments  where areaid='"
    + areaID + "'";
  List<DbObject> l = super.query(AgentAreaDepartment.class, sql, -1, -1);
  if (l.size() != 0) {
   return (AgentAreaDepartment) l.get(0);
  }
  return null;
 }

 

  // 按服務中心搜索
  else if (type == 4 && !key.equals("")) {
   String sql0 = "select areaid from shop_agentareadepartments where depname like '%"
     + key + "%'";
   List<String[]> areaids = super.queryDatasToArray(sql0, -1, -1);
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < areaids.size(); i++) {
    City root = (City) ApplicationContext.getAttribute("AREA");
    City c = root.find(new Long(areaids.get(i)[0]));
    List<Long> cl = null;
    cl = c.bgetAllChilds(true);
    for (int j = 1; j < cl.size(); j++) {
     if (this.getDepartmentByArea2(cl.get(j)) == null) {
      sb.append(cl.get(j)).append(",");
     }
    }
    sb.append(cl.get(0));
    if (i != areaids.size() - 1) {
     sb.append(",");
    }
   }
   if (startDate != null || endDate != null) {
    sql
      .append("select distinct (a.*) from user_agentinfos a,user_members b, user_accounts c,shop_orders e "
        + "where e.agentid=b.wid and a.areaid in ("
        + sb.toString()
        + ") and a.memberid=b.wid and c.memberid=b.wid");
    if (startDate != null) {
     sql.append(" and e.createDate >=" + startDate.getTime());
    }
    if (endDate != null) {
     sql.append(" and e.createDate <=" + endDate.getTime());
    }
   } else {
    sql
      .append("select distinct (a.*) from user_agentinfos a,user_members b, user_accounts c "
        + "where  a.areaid in ("
        + sb.toString()
        + ") and a.memberid=b.wid and c.memberid=b.wid");
   }
  }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章