PropertyOrderLists.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\property;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\property\PropertyHead;
  17. use app\common\model\property\PropertyOrder;
  18. use app\common\lists\ListsSearchInterface;
  19. use app\common\model\property\PropertyUser;
  20. /**
  21. * PropertyOrder列表
  22. * Class PropertyOrderLists
  23. * @package app\adminapi\lists
  24. */
  25. class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  26. {
  27. /**
  28. * @notes 设置搜索条件
  29. * @return \string[][]
  30. * @author likeadmin
  31. * @date 2024/09/19 14:48
  32. */
  33. public function setSearch(): array
  34. {
  35. return [
  36. '=' => ['property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id'],
  37. ];
  38. }
  39. public function queryWhere()
  40. {
  41. $where = [];
  42. if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
  43. $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
  44. $where[] = ['property_head_id','IN',$property_head_ids];
  45. }
  46. if(isset($this->params['householder_name']) && !empty($this->params['householder_name'])){
  47. $property_user_ids = PropertyUser::where('householder_name', 'like', '%'.$this->params['householder_name'].'%')->column('id');
  48. $where[] = ['property_user_id','IN',$property_user_ids];
  49. }
  50. return $where;
  51. }
  52. /**
  53. * @notes 获取列表
  54. * @return array
  55. * @throws \think\db\exception\DataNotFoundException
  56. * @throws \think\db\exception\DbException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @author likeadmin
  59. * @date 2024/09/19 14:48
  60. */
  61. public function lists(): array
  62. {
  63. return PropertyOrder::with(['propertyHead','propertyUser'])->where($this->searchWhere)->where($this->queryWhere())
  64. ->field(['id', 'property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id','address','create_time'])
  65. ->limit($this->limitOffset, $this->limitLength)
  66. ->order(['id' => 'desc'])
  67. ->select()
  68. ->toArray();
  69. }
  70. /**
  71. * @notes 获取数量
  72. * @return int
  73. * @author likeadmin
  74. * @date 2024/09/19 14:48
  75. */
  76. public function count(): int
  77. {
  78. return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
  79. }
  80. }