PropertyOrderLists.php 4.5 KB

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