Listcustomer.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. //客户信息
  7. class Listcustomer extends Base
  8. {
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. }
  13. public function list(){
  14. $page = isset($this->post['page'])&& $this->post['page'] !=="" ? intval($this->post['page']) :"1";
  15. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
  16. $where []= ['is_del',"=",0];
  17. $companyNo= isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):"";
  18. if($companyNo!=""){
  19. $where[]=["companyNo","like","%$companyNo%"];
  20. }
  21. $companyName= isset($this->post['companyName'])&&$this->post['companyName']!=="" ? trim($this->post['companyName']):"";
  22. if($companyName!=""){
  23. $where[]=["companyName","like","%$companyName%"];
  24. }
  25. $itemid = isset($this->post['itemid']) && $this->post['itemid'] !=="" ? intval($this->post['itemid']):"";
  26. if($itemid!=""){
  27. $where[]=["itemid","=",$itemid];
  28. }
  29. $count = Db::name('customer_info')->where($where)->count();
  30. $total = ceil($count/$size);
  31. $page = $page >= $total ? $total : $page;
  32. $item = Db::name('customer_info')->where($where)
  33. ->field("*,LENGTH(companyName) as weight")->order("weight asc")->page($page,$size)->select();
  34. return app_show(0,"获取成功",['item'=>$item,'count'=>$count]);
  35. }
  36. }