12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\Admin\controller;
- use think\Db;
- class Express extends Base
- {
- #public $post="";
- public function __construct()
- {
- parent::__construct();
- #$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;
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- $where = [];
- if ($status !== "") {
- $where['status'] = $status;
- }
- $code = isset($this->post['code']) && $this->post['code'] !== "" ? trim($this->post['code']) : "";
- if ($code !== "") {
- $where['express_code'] = ["like","%$code%"];
- }
- $express_name = isset($this->post['express_name']) && $this->post['express_name'] !== "" ? trim($this->post['express_name']) : "";
- if ($express_name !== "") {
- $where['express_name'] = ["like","%$express_name%"];
- }
- $count = Db::name("express")->where($where)->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list= Db::name("express")->where($where)->page($page,$size)->select();
- return app_show(0, "获取成功", ["list" => $list, "count" => $count]);
- }
- public function qureylist(){
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- $where = ["status"=>1];
- if ($status !== "") {
- $where['status'] = $status;
- }
- $code = isset($this->post['code']) && $this->post['code'] !== "" ? trim($this->post['code']) : "";
- if ($code !== "") {
- $where['express_code'] = ["like","%$code%"];
- }
- $express_name = isset($this->post['express_name']) && $this->post['express_name'] !== "" ? trim($this->post['express_name']) : "";
- if ($express_name !== "") {
- $where['express_name'] = ["like","%$express_name%"];
- }
- $list= Db::name("express")->where($where)->select();
- return app_show(0, "获取成功", $list);
- }
- public function status(){
- $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
- if($id==""){
- return error_show(1004,"参数id不能为空");
- }
- $info= Db::name("express")->where(["id"=>$id])->find();
- if($info==false){
- return error_show(1004,"未找到快递数据");
- }
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if($status===""){
- return error_show(1004,"参数status不能为空");
- }
- $msg=$status==0?"禁用":"启用";
- $info['status']=$status;
- $up =Db::name("express")->update($info);
- return $up? app_show(0,"{$msg}成功"):error_show(1004,"{$msg}失败");
- }
- }
|