TaxCategory.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\user\controller;
  3. use think\App;
  4. class TaxCategory extends Base{
  5. public function __construct(App $app) {
  6. parent::__construct($app);
  7. $this->model = new \app\user\model\TaxCategory();
  8. }
  9. public function list(){
  10. $params=$this->request->param(["cat_name"=>"","cat_code"=>"","status"=>[],"page"=>1,"size"=>15],"post","trim");
  11. $where=[];
  12. if($params["cat_name"]!='') $where[]=["cat_name|short_name","like","%".$params["cat_name"]."%"];
  13. if($params["cat_code"]!='') $where[]=["cat_code|merge_code","like","%".$params["cat_code"]."%"];
  14. if(!empty($params["status"])) $where[]=["status","in",$params["status"]];
  15. $list=$this->model->where($where)->order("status asc,id desc")->paginate(["page"=>$params["page"],"list_rows"=>$params["size"]]);
  16. return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
  17. }
  18. public function query(){
  19. $params=$this->request->param(["cat_name"=>"","cat_code"=>"","status"=>[]],"post","trim");
  20. $where=[["tax","<>",""]];
  21. if($params["cat_name"]!='') $where[]=["cat_name|short_name","like","%".$params["cat_name"]."%"];
  22. if($params["cat_code"]!='') $where[]=["cat_code|merge_code","like","%".$params["cat_code"]."%"];
  23. if(!empty($params["status"])) $where[]=["status","in",$params["status"]];
  24. $list=$this->model->where($where)
  25. ->field('cat_name,cat_code,status,tax,addtax,sumitem,`desc`,short_name,merge_code,LENGTH(cat_name) as weight')
  26. ->order("weight asc,id desc")
  27. ->limit(30)->select()->toArray();
  28. return success("获取成功",$list);
  29. }
  30. public function listByCompany(){
  31. $params=$this->request->param([
  32. "cat_name"=>"",
  33. "short_name"=>"",
  34. "relation_status"=>"",
  35. "cat_code"=>"",
  36. "use_status"=>"",
  37. "companyNo"=>"",
  38. "page"=>1,"size"=>15],"post","trim");
  39. $where=[];
  40. if($params["cat_name"]!='') $where[]=["cat_name","like","%".$params["cat_name"]."%"];
  41. if($params["short_name"]!='') $where[]=["short_name","like","%".$params["short_name"]."%"];
  42. if($params["relation_status"]!='') {
  43. }
  44. }
  45. }