1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\App;
- use think\facade\Db;
- //客户信息
- class Listcustomer extends Base
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- }
- public function list(){
- $page = isset($this->post['page'])&& $this->post['page'] !=="" ? intval($this->post['page']) :"1";
- $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
- $where []= ['is_del',"=",0];
- $companyNo= isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):"";
- if($companyNo!=""){
- $where[]=["companyNo","like","%$companyNo%"];
- }
- $companyName= isset($this->post['companyName'])&&$this->post['companyName']!=="" ? trim($this->post['companyName']):"";
- if($companyName!=""){
- $where[]=["companyName","like","%$companyName%"];
- }
- $itemid = isset($this->post['itemid']) && $this->post['itemid'] !=="" ? intval($this->post['itemid']):"";
- if($itemid!=""){
- $where[]=["itemid","=",$itemid];
- }
- $count = Db::name('customer_info')->where($where)->count();
- $total = ceil($count/$size);
- $page = $page >= $total ? $total : $page;
- $item = Db::name('customer_info')->where($where)
- ->field("*,LENGTH(companyName) as weight")->order("weight asc")->page($page,$size)->select();
- return app_show(0,"获取成功",['item'=>$item,'count'=>$count]);
- }
- }
|