PropertyOrderLists.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. foreach ($lists as &$item){
  37. $item['householder_name'] = $item['propertyUser']?$item['propertyUser']['householder_name']:'';
  38. $item['householder_mobile'] = $item['propertyUser']?$item['propertyUser']['householder_name']:'';
  39. $item['work_address'] = $item['propertyWork']?$item['propertyWork']['address']:'';
  40. $item['work_create_time'] = $item['propertyWork']?$item['propertyWork']['create_time']:'';
  41. }
  42. return $lists;
  43. }
  44. /**
  45. * @notes 获取数量
  46. * @return int
  47. */
  48. public function count(): int
  49. {
  50. return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
  51. }
  52. }