Listcustomer.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class Listcustomer extends BaseController
  7. {
  8. public $post = "";
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->post = $this->request->post();
  13. $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  14. if($token ==""){
  15. return error_show(101,'token不能为空');
  16. }
  17. $effetc = VerifyTokens($token);
  18. if(!empty($effetc) && $effetc['code']!=0){
  19. return error_show($effetc['code'],$effetc['message']);
  20. }
  21. }
  22. public function list(){
  23. $page = isset($this->post['page'])&& $this->post['page'] !=="" ? intval($this->post['page']) :"1";
  24. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
  25. $where []= ['is_del',"=",0];
  26. $companyNo= isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):"";
  27. if($companyNo!=""){
  28. $where[]=["companyNo","like","%$companyNo%"];
  29. }
  30. $companyName= isset($this->post['companyName'])&&$this->post['companyName']!=="" ? trim($this->post['companyName']):"";
  31. if($companyName!=""){
  32. $where[]=["companyName","like","%$companyName%"];
  33. }
  34. $itemid = isset($this->post['itemid']) && $this->post['itemid'] !=="" ? intval($this->post['itemid']):"";
  35. if($itemid!=""){
  36. $where[]=["itemid","=",$itemid];
  37. }
  38. $count = Db::name('customer_info')->where($where)->count();
  39. $total = ceil($count/$size);
  40. $page = $page >= $total ? $total : $page;
  41. $item = Db::name('customer_info')->where($where)->order("addtime desc")->page($page,$size)->select();
  42. return app_show(0,"获取成功",['item'=>$item,'count'=>$count]);
  43. }
  44. }