1
0

PropertyGroupOrderLists.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\api\lists\property;
  3. use app\api\lists\BaseApiDataLists;
  4. use app\common\lists\ListsSearchInterface;
  5. use app\common\model\property\PropertyHead;
  6. use app\common\model\group_activity\GroupUserOrder;
  7. /**
  8. * 代理人拼团订单列表
  9. * Class PropertyGroupOrderLists
  10. * @package app\api\lists\property
  11. */
  12. class PropertyGroupOrderLists extends BaseApiDataLists implements ListsSearchInterface
  13. {
  14. /**
  15. * @notes 设置搜索条件
  16. * @return \string[][]
  17. * @author likeadmin
  18. * @date 2024/07/07 18:37
  19. */
  20. public function setSearch(): array
  21. {
  22. return [
  23. '=' => [],
  24. ];
  25. }
  26. public function queryWhere()
  27. {
  28. // 指定用户
  29. $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
  30. $where[] = ['b.property_head_id', '=', $propertyHeadId];
  31. if (isset($this->params['status'])) {
  32. if ($this->params['status'] == 0) {
  33. $where[] = ['a.status', '=', 0];
  34. } elseif ($this->params['status'] == 1) {
  35. $where[] = ['a.status', '=', 1];
  36. } else {
  37. $where[] = ['a.status', '>', 1];
  38. }
  39. }
  40. if (isset($this->params['start_time']) && !empty($this->params['start_time'])) {
  41. $monthStart = strtotime(date("Y-m-01",strtotime($this->params['start_time'])));
  42. $monthEnd = strtotime(date("Y-m-t 23:59:59",strtotime($this->params['start_time'])));
  43. $where[] = ['a.create_time', 'between', [$monthStart, $monthEnd]];
  44. }
  45. return $where;
  46. }
  47. /**
  48. * @notes 获取列表
  49. * @return array
  50. */
  51. public function lists(): array
  52. {
  53. $lists = GroupUserOrder::alias('a')
  54. ->leftJoin('group_order b','a.group_order_id=b.id')
  55. ->leftJoin('group_activity c','a.group_activity_id=c.id')
  56. ->field('a.id,a.sn,a.group_activity_id,a.status,a.order_amount,a.paid_amount,a.pay_status,a.refund_status,a.create_time,b.goods_id,b.num,b.origin_price,b.end_time,c.title,c.image')
  57. ->where($this->queryWhere())
  58. ->limit($this->limitOffset, $this->limitLength)
  59. ->order('a.create_time', 'desc')
  60. ->select()
  61. ->toArray();
  62. return $lists;
  63. }
  64. /**
  65. * @notes 获取数量
  66. * @return int
  67. */
  68. public function count(): int
  69. {
  70. return GroupUserOrder::alias('a')
  71. ->leftJoin('group_order b','a.group_order_id=b.id')
  72. ->leftJoin('group_activity c','a.group_activity_id=c.id')
  73. ->where($this->queryWhere())
  74. ->count();
  75. }
  76. }