PropertyOrderLists.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. use app\common\model\sale\Sale;
  21. /**
  22. * PropertyOrder列表
  23. * Class PropertyOrderLists
  24. * @package app\adminapi\lists
  25. */
  26. class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterface
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @return \string[][]
  31. * @author likeadmin
  32. * @date 2024/09/19 14:48
  33. */
  34. public function setSearch(): array
  35. {
  36. return [
  37. '=' => ['property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id'],
  38. ];
  39. }
  40. public function queryWhere()
  41. {
  42. $where = [];
  43. if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
  44. $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
  45. $where[] = ['property_head_id','IN',$property_head_ids];
  46. }
  47. if(isset($this->params['householder_name']) && !empty($this->params['householder_name'])){
  48. $property_user_ids = PropertyUser::where('householder_name', 'like', '%'.$this->params['householder_name'].'%')->column('id');
  49. $where[] = ['property_user_id','IN',$property_user_ids];
  50. }
  51. return $where;
  52. }
  53. /**
  54. * 获取数据权限
  55. * $this->adminInfo['data_rules']
  56. * province city admin_id sale_group_id sale_id property_head_id
  57. */
  58. public function queryDataWhere(){
  59. $where = [];
  60. $data_rules = $this->adminInfo['data_rules'];
  61. /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
  62. $where[] = ['province','in' ,$data_rules['province']];
  63. }
  64. if (isset($data_rules['city']) && !empty($data_rules['city'])) {
  65. $where[] = ['city','in' ,$data_rules['city']];
  66. }*/
  67. if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
  68. $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
  69. }
  70. if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
  71. $where[] = ['sale_id','in' ,$data_rules['sale_id']];
  72. }
  73. if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
  74. $where[] = ['property_head_id','in' ,$data_rules['property_head_id']];
  75. }
  76. return $where;
  77. }
  78. /**
  79. * @notes 获取列表
  80. * @return array
  81. * @throws \think\db\exception\DataNotFoundException
  82. * @throws \think\db\exception\DbException
  83. * @throws \think\db\exception\ModelNotFoundException
  84. * @author likeadmin
  85. * @date 2024/09/19 14:48
  86. */
  87. public function lists(): array
  88. {
  89. return PropertyOrder::with(['propertyHead','propertyUser','propertyOrderCustomerLog'])->where($this->searchWhere)->where($this->queryWhere())
  90. ->field(['id', 'property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id','address','create_time'])
  91. ->where($this->queryDataWhere())
  92. ->limit($this->limitOffset, $this->limitLength)
  93. ->order(['id' => 'desc'])
  94. ->select()
  95. ->toArray();
  96. }
  97. /**
  98. * @notes 获取数量
  99. * @return int
  100. * @author likeadmin
  101. * @date 2024/09/19 14:48
  102. */
  103. public function count(): int
  104. {
  105. return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
  106. }
  107. }