OrderInfoAsw.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\admin;
  4. use library\basic\BaseModel;
  5. use think\Model;
  6. /**
  7. * @mixin \think\Model
  8. */
  9. class OrderInfoAsw 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 = 'mo.id desc')
  19. {
  20. $data = $this
  21. ->field(
  22. "mo.id,mo.msg_mono,mo.msg_img,mo.admin_id,mo.mono,mo.status,mo.time as cl_time,mo.admin_time as cl_admin_time,(select order_id from table_order where id = of.o_id) as order_id,"
  23. . "mo.o_id,of.name,of.out_order_id,of.mobile,of.address,of.time,of.send_time,(SELECT title from table_express where id = of.exp_id) as exp_name,of.exp_number"
  24. )
  25. ->alias("mo")
  26. ->join('order_info of', "mo.of_id=of.id")
  27. ->when(!empty($where), function ($query) use ($where) {
  28. //订单类型
  29. if(is_numeric($where['aswStatus'])) {
  30. $query->where('mo.status',$where['aswStatus']);
  31. }
  32. //订单类型
  33. if(is_numeric($where['sassid'])) {
  34. $query->where('mo.sassid',$where['sassid']);
  35. }
  36. //timeType[今日,昨日,最近7天,最近30天]
  37. if(!empty($where['timeType'])) {
  38. if($where['timeType'] == 'day') {
  39. $query->whereDay('mo.time');
  40. }
  41. if($where['timeType'] == 'yesterday') {
  42. $query->whereDay('mo.time','yesterday');
  43. }
  44. if($where['timeType'] == 'last7') {
  45. $query->whereTime('mo.time','-7 day');
  46. }
  47. if($where['timeType'] == 'last30') {
  48. $query->whereTime('mo.time','-30 day');
  49. }
  50. }
  51. })
  52. ->order($desc)
  53. ->paginate(['list_rows' => $pageCount, 'page' => $page])
  54. ->toArray();
  55. return [$data['total'], $data['data']];
  56. }
  57. }