OrderConveyLis.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\Db;
  5. class OrderConveyLis extends Auth
  6. {
  7. public function __construct(App $app = null) {
  8. parent::__construct($app);
  9. $this->table = 'order_convey_lis';
  10. }
  11. public function index(){
  12. if(request()->isAjax()){
  13. //分页参数
  14. $length = input('rows',10,'intval'); //每页条数
  15. $page = input('page',1,'intval'); //第几页
  16. $start = ($page - 1) * $length; //分页开始位置
  17. //排序
  18. $sortRow = input('sidx','id','trim'); //排序列
  19. $sort = input('sord','desc','trim'); //排序方式
  20. $order = $sortRow.' '.$sort;
  21. $barcode = input('barcode','','trim');
  22. if($barcode){
  23. $map[] = ['barcode','=',$barcode];
  24. }
  25. $s = input('start','','trim');
  26. if($s){
  27. $ss = date('Ymd',strtotime($s));
  28. $map[] = ['create_yyyymmdd','>=',$ss];
  29. }
  30. $e = input('end','','trim');
  31. if($e){
  32. $ee = date('Ymd',strtotime($e));
  33. $map[] = ['create_yyyymmdd','<=',$ee];
  34. }
  35. $map[] = ['org_id','=',$this->orgId];
  36. $map= empty($map) ? true: $map;
  37. //数据查询
  38. $lists = db($this->table)->where($map)->limit($start,$length)->order($order)->select();
  39. foreach ($lists as $k=>$v){
  40. $lists[$k]['real_name'] = Db::name('user')
  41. ->where('id',$v['user_id'])
  42. ->value('real_name');
  43. $lists[$k]['address_title'] = Db::name('address')
  44. ->where('id',$v['addr_id'])
  45. ->value('title');
  46. }
  47. //数据返回
  48. $totalCount = db($this->table)->where($map)->count();
  49. $totalPage = ceil($totalCount/$length);
  50. $result['page'] = $page;
  51. $result['total'] = $totalPage;
  52. $result['records'] = $totalCount;
  53. $result['rows'] = $lists;
  54. return json($result);
  55. }else{
  56. return $this->fetch();
  57. }
  58. }
  59. }