Express.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 Base
  8. {
  9. //获取快递公司列表
  10. public function list(){
  11. $page = isset($this->post['page']) &&$this->post['page'] !=="" ? intval($this->post['page']):1;
  12. $size = isset($this->post['size']) &&$this->post['size'] !=="" ? intval($this->post['size']):10;
  13. $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'0';
  14. $where = [["type","=",$type]];
  15. $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
  16. if($name!=''){
  17. $where[]=["name|shortName","like","%{$name}%"];
  18. }
  19. $plat_type = isset($this->post['plat_type']) &&$this->post['plat_type'] !="" ? trim($this->post['plat_type']):'';
  20. if($plat_type!=''){
  21. $where[]=["plat_type","=",$plat_type];
  22. }
  23. $count = Db::name("express")->where($where)->count();
  24. $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
  25. $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,plat_type,shortName,shortNameEn,shortNumber,canOrder')
  26. ->page($page,$size)->select();
  27. return app_show(0,'获取成功',['list'=>$list,"count"=>$count]);
  28. }
  29. //快递公司启禁用
  30. public function SetUse(){
  31. $id = isset($this->post['id']) &&$this->post['id'] !="" ? intval($this->post['id']):'';
  32. if($id==''){
  33. return error_show(1004,"参数id不能为空");
  34. }
  35. $express = Db::name("express")->where(["id"=>$id])->find();
  36. if(empty($express)){
  37. return error_show(1004,"未找到数据");
  38. }
  39. $express['canOrder'] = $express['canOrder']==0 ?1:0;
  40. $up = Db::name("express")->save($express);
  41. $orde = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
  42. ActionLog::logAdd($this->post['token'],$orde,'express',0,$orde);
  43. return $up?app_show(0,"更新成功"):error_show(1005,"更新失败");
  44. }
  45. //获取可用的快递公司列表
  46. public function GetExpress(){
  47. $type = isset($this->post['type']) &&$this->post['type'] !=="" ? intval($this->post['type']):'';
  48. $where[] = ['canOrder',"=",1];
  49. if($type===0){
  50. $where[]=["type","=",$type];
  51. }
  52. $order_source = isset($this->post['order_source']) &&$this->post['order_source'] !=="" ? intval($this->post['order_source']):'1';
  53. $plat_type=1;
  54. if( $order_source==5){
  55. $plat_type=2;
  56. }
  57. $where[]=["plat_type","=",$plat_type];
  58. $name = isset($this->post['name']) &&$this->post['name'] !="" ? trim($this->post['name']):'';
  59. if($name!=''){
  60. $where[]=["name|shortName","like","%{$name}%"];
  61. }
  62. $list= Db::name("express")->where($where)->field('id,type,comTypeName,name,shortName,shortNameEn,shortNumber,canOrder')
  63. ->select();
  64. return app_show(0,'获取成功',$list);
  65. }
  66. }