PropertyOrderLists.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\PropertyCommission;
  6. use app\common\model\property\PropertyHead;
  7. use app\common\model\property\PropertyOrder;
  8. use app\common\model\property\PropertySurplusLog;
  9. /**
  10. * 订单列表
  11. */
  12. class PropertyOrderLists extends BaseApiDataLists implements ListsSearchInterface
  13. {
  14. public function setSearch(): array
  15. {
  16. return [
  17. '=' => ['id','order_status'],
  18. ];
  19. }
  20. public function queryWhere()
  21. {
  22. // 指定用户
  23. $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
  24. $where[] = ['property_head_id', '=', $propertyHeadId];
  25. return $where;
  26. }
  27. public function lists(): array
  28. {
  29. $lists = PropertyOrder::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
  30. ->where($this->queryWhere())
  31. ->limit($this->limitOffset, $this->limitLength)
  32. ->field(['id','property_head_id','property_user_id','remark','order_status','work_id','create_time','update_time'])
  33. ->order('create_time desc')
  34. ->select()
  35. ->toArray();
  36. $lists = array_merge($lists,$lists['propertyHead'],$lists['propertyUser'],$lists['propertyWork']);
  37. return $lists;
  38. }
  39. /**
  40. * @notes 获取数量
  41. * @return int
  42. */
  43. public function count(): int
  44. {
  45. return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
  46. }
  47. }