|
@@ -21,9 +21,9 @@ class Customer extends Base
|
|
|
$pid = isset($this->post['pid']) &&$this->post['pid']!=="" ?intval($this->post['pid']): "0";
|
|
|
$where =[];
|
|
|
$where []= ['ci.is_del',"=",0];
|
|
|
- $condition = [['is_del',"=",0]];
|
|
|
+ $condition = [['co.is_del',"=",0]];
|
|
|
if($pid!==""){
|
|
|
- $condition[]=["pid","=",$pid];
|
|
|
+ $condition[]=["co.pid","=",$pid];
|
|
|
}
|
|
|
$companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']):"";
|
|
|
if($companyNo !==""){
|
|
@@ -35,7 +35,7 @@ class Customer extends Base
|
|
|
}
|
|
|
$name= isset($this->post['name'])&&$this->post['name']!=="" ? trim($this->post['name']):"";
|
|
|
if($name!=""){
|
|
|
- $condition[]=["name","like","%{$this->post['name']}%"];
|
|
|
+ $condition[]=["co.name","like","%{$this->post['name']}%"];
|
|
|
}
|
|
|
$start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
|
|
|
if ($start != "") {
|
|
@@ -53,28 +53,36 @@ class Customer extends Base
|
|
|
// $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
|
|
|
$creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
|
|
|
if($creater !==""){
|
|
|
- $condition[] = ['creater',"like","%$creater%"];
|
|
|
+ $condition[] = ['co.creater',"like","%$creater%"];
|
|
|
}
|
|
|
$name= isset($this->post['name'])&&$this->post['name']!=="" ? trim($this->post['name']):"";
|
|
|
if($name!=""){
|
|
|
- $condition[]=["name","like","%{$this->post['name']}%"];
|
|
|
+ $condition[]=["co.name","like","%{$this->post['name']}%"];
|
|
|
}
|
|
|
$start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
|
|
|
if ($start != "") {
|
|
|
- $condition[] = ["addtime", '>=', $start];
|
|
|
+ $condition[] = ["co.addtime", '>=', $start];
|
|
|
}
|
|
|
$end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
|
|
|
if ($end != "") {
|
|
|
- $condition[] = ["addtime", '<=', $end];
|
|
|
+ $condition[] = ["co.addtime", '<=', $end];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
if($status!==""){
|
|
|
- $condition[] = ['status',"=",$status];
|
|
|
+ $condition[] = ['co.status',"=",$status];
|
|
|
}
|
|
|
$company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
- if ($company_name !== "") $where[] = ["u.uid", 'in', get_company_item_user_by_name($company_name)];
|
|
|
+ if ($company_name !== "") {
|
|
|
+ $company_ids = get_company_item_user_by_name($company_name);
|
|
|
+ $where[] = ["u.uid", 'in', $company_ids];
|
|
|
+ $condition[] = ['u.uid',"in",$company_ids];
|
|
|
+ }
|
|
|
|
|
|
- $pidlist = Db::name("customer_org1")->where($condition)->order("addtime desc")->column("pid");
|
|
|
+ $pidlist = Db::name("customer_org1")
|
|
|
+ ->alias('co')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=co.createrid AND u.is_del=0")
|
|
|
+ ->where($condition)
|
|
|
+ ->order("co.addtime desc")->column("co.pid");
|
|
|
if(!empty($pidlist)){
|
|
|
$where[]=[["ci.itemid","in",$pidlist]];
|
|
|
|
|
@@ -85,7 +93,12 @@ class Customer extends Base
|
|
|
$where[]=['ci.itemid','=',$pid];
|
|
|
}
|
|
|
}
|
|
|
- $list = Db::name('customer_org1')->where($condition)->order("addtime desc")->column("id,pid,name,level,depart_link,creater,addtime,status");
|
|
|
+ $list = Db::name('customer_org1')
|
|
|
+ ->alias('co')
|
|
|
+ ->where($condition)
|
|
|
+ ->order("co.addtime",'desc')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=co.createrid AND u.is_del=0")
|
|
|
+ ->column("co.id,co.pid,co.name,co.level,co.depart_link,co.creater,co.addtime,co.status,u.itemid");
|
|
|
$var=[];
|
|
|
foreach ($list as $item) {
|
|
|
$iten=[];
|
|
@@ -96,6 +109,7 @@ class Customer extends Base
|
|
|
$iten['status']=$item['status'];
|
|
|
$iten['addtime']=$item['addtime'];
|
|
|
$iten['kh']=0;//组织架构
|
|
|
+ $iten['company_name'] = implode('/', array_column(GetPart($item['itemid']), 'name'));
|
|
|
$var[]=$iten;
|
|
|
}
|
|
|
$itm = Db::name('customer_info')
|