12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\admin\controller;
- use think\App;
- use think\facade\Db;
- class Express extends \app\BaseController
- {
- public $post='';
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->post = request()->post();
- }
- 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;
- $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'0';
- $where = [["type","=",$type]];
- $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
- if($name!=''){
- $where[]=["name|shortName","like","%{$name}%"];
- }
- $count = Db::name("express")->where($where)->count();
- $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
- $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,shortName,shortNameEn,shortNumber,canOrder')
- ->page($page,$size)->select();
- return app_show(0,'获取成功',['list'=>$list,"count"=>$count]);
- }
- public function SetUse(){
- $id = isset($this->post['id']) &&$this->post['id'] !="" ? intval($this->post['id']):'';
- if($id==''){
- return error_show(1004,"参数id不能为空");
- }
- $express = Db::name("express")->where(["id"=>$id])->find();
- if(empty($express)){
- return error_show(1004,"未找到数据");
- }
- $express['canOrder'] = $express['canOrder']==0 ?1:0;
- $up = Db::name("express")->save($express);
- return $up?app_show(0,"更新成功"):error_show(1005,"更新失败");
- }
- public function GetExpress(){
- $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'0';
- $where = [["type","=",$type],['canOrder',"=",1]];
- $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
- if($name!=''){
- $where[]=["name|shortName","like","%{$name}%"];
- }
- $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,shortName,shortNameEn,shortNumber,canOrder')
- ->select();
- return app_show(0,'获取成功',$list);
- }
- }
|