PropertySurplusLogLists.php 1.3 KB

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