|
@@ -258,18 +258,26 @@ class Company extends BaseController
|
|
|
}
|
|
|
$companyName = isset($post['companyName'])&&$post['companyName']!="" ? trim($post['companyName']) :"";
|
|
|
if($companyName!=""){
|
|
|
- $condition[]=['company_name',"like","%$companyName%"];
|
|
|
+ $condition[]=['b.name',"like","%$companyName%"];
|
|
|
}
|
|
|
$status = isset($post['status'])&&$post['status']!=="" ? intval($post['status']) :"";
|
|
|
if($status!==""){
|
|
|
- $condition[]=['status',"=",$status];
|
|
|
+ $condition[]=['a.status',"=",$status];
|
|
|
}
|
|
|
$page = isset($post['page'])&& $post['page']!="" ? intval($post['page']) :1;
|
|
|
$size = isset($post['size'])&& $post['size']!="" ? intval($post['size']) :10;
|
|
|
- $count = Db::name("company_info")->where($condition)->count();
|
|
|
+ $count = Db::name("company_info")->alias("a")
|
|
|
+ ->leftJoin("supplier_info b","a.companyNo=b.code")
|
|
|
+ ->where($condition)->count();
|
|
|
$total = ceil($count/$size)>1 ? ceil($count/$size) : 1;
|
|
|
$page = $page>=$total?intval($total):$page;
|
|
|
- $list = Db::name("company_info")->where($condition)->page($page,$size)->order("id desc")->select();
|
|
|
+ $list = Db::name("company_info")->alias("a")
|
|
|
+ ->leftJoin("supplier_info b","a.companyNo=b.code")
|
|
|
+ ->where($condition)
|
|
|
+ ->field("a.*,b.name")
|
|
|
+ ->page($page,$size)
|
|
|
+ ->order("id desc")
|
|
|
+ ->select();
|
|
|
return app_show(0,"获取成功",['list'=>$list,"count"=>$count]);
|
|
|
}
|
|
|
|