OrderInfo.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\warehouse;
  4. use library\basic\BaseModel;
  5. use think\Model;
  6. /**
  7. * @mixin \think\Model
  8. */
  9. class OrderInfo extends BaseModel
  10. {
  11. /**
  12. * 获取列表数据
  13. * @param $page
  14. * @param $where
  15. * @param $pageCount
  16. * @param $desc
  17. */
  18. public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = 'id desc'){
  19. $data = $this
  20. ->field("of.*,(SELECT title from table_express where id = of.exp_id) as exp_name")
  21. ->alias("of")
  22. ->when(!empty($where),function ($query) use($where){
  23. if(!empty($where['warehouse_id'])) {
  24. $query->where('of.warehouse_id',$where['warehouse_id']);
  25. }
  26. if(!empty($where['id'])) {
  27. $query->where('of.o_id',$where['id']);
  28. }
  29. //查询日期
  30. if(!empty($where['data']) && !empty($where['data'][0]) && !empty($where['data'][1])) {
  31. $query->whereTime('of.send_time','>=',strtotime($where['data'][0]));
  32. $query->whereTime('of.send_time','<',strtotime($where['data'][1]) + 3600 * 24);
  33. }
  34. if(!empty($where['name'])) {
  35. $query->whereLike('of.name',"%{$where['name']}%");
  36. }
  37. if(!empty($where['mobile'])) {
  38. $query->whereLike('of.mobile',"%{$where['mobile']}%");
  39. }
  40. if(!empty($where['status'])) {
  41. $query->where('of.status',$where['status']);
  42. } else {
  43. $query->where('of.status','>',0);
  44. }
  45. })
  46. ->order($desc)
  47. ->paginate(['list_rows'=>$pageCount,'page'=>$page])
  48. ->toArray();
  49. return [$data['total'],$data['data']];
  50. }
  51. }