Express.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use think\App;
  5. use think\facade\Db;
  6. //物流信息
  7. class Express extends \app\BaseController
  8. {
  9. public $post='';
  10. public function __construct(App $app)
  11. {
  12. parent::__construct($app);
  13. $this->post = request()->post();
  14. }
  15. public function list(){
  16. $page = isset($this->post['page']) &&$this->post['page'] !=="" ? intval($this->post['page']):1;
  17. $size = isset($this->post['size']) &&$this->post['size'] !=="" ? intval($this->post['size']):10;
  18. $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'0';
  19. $where = [["type","=",$type]];
  20. $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
  21. if($name!=''){
  22. $where[]=["name|shortName","like","%{$name}%"];
  23. }
  24. $plat_type = isset($this->post['plat_type']) &&$this->post['plat_type'] !="" ? trim($this->post['plat_type']):'';
  25. if($plat_type!=''){
  26. $where[]=["plat_type","=",$plat_type];
  27. }
  28. $count = Db::name("express")->where($where)->count();
  29. $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
  30. $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,plat_type,shortName,shortNameEn,shortNumber,canOrder')
  31. ->page($page,$size)->select();
  32. return app_show(0,'获取成功',['list'=>$list,"count"=>$count]);
  33. }
  34. public function SetUse(){
  35. $id = isset($this->post['id']) &&$this->post['id'] !="" ? intval($this->post['id']):'';
  36. if($id==''){
  37. return error_show(1004,"参数id不能为空");
  38. }
  39. $express = Db::name("express")->where(["id"=>$id])->find();
  40. if(empty($express)){
  41. return error_show(1004,"未找到数据");
  42. }
  43. $express['canOrder'] = $express['canOrder']==0 ?1:0;
  44. $up = Db::name("express")->save($express);
  45. $orde = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
  46. ActionLog::logAdd($this->post['token'],$orde,'express',0,$orde);
  47. return $up?app_show(0,"更新成功"):error_show(1005,"更新失败");
  48. }
  49. public function GetExpress(){
  50. $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'';
  51. $where[] = ['canOrder',"=",1];
  52. if($type===0){
  53. $where[]=["type","=",$type];
  54. }
  55. $order_source = isset($this->post['order_source']) &&$this->post['order_source'] !=="" ? intval($this->post['order_source']):'1';
  56. $plat_type=1;
  57. if( $order_source==5){
  58. $plat_type=2;
  59. }
  60. $where[]=["plat_type","=",$plat_type];
  61. $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
  62. if($name!=''){
  63. $where[]=["name|shortName","like","%{$name}%"];
  64. }
  65. $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,shortName,shortNameEn,shortNumber,canOrder')
  66. ->select();
  67. return app_show(0,'获取成功',$list);
  68. }
  69. }