PropertySurplusLogLists.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\PropertySurplusLog;
  18. use app\common\lists\ListsSearchInterface;
  19. use app\common\model\property\PropertyUser;
  20. /**
  21. * PropertySurplusLog列表
  22. * Class PropertySurplusLogLists
  23. * @package app\adminapi\lists
  24. */
  25. class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchInterface
  26. {
  27. /**
  28. * @notes 设置搜索条件
  29. * @return \string[][]
  30. * @author likeadmin
  31. * @date 2024/09/20 16:31
  32. */
  33. public function setSearch(): array
  34. {
  35. return [
  36. '=' => ['in_out', 'property_commission_id', 'amount', 'status', 'remark', 'property_head_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. return $where;
  47. }
  48. /**
  49. * 获取数据权限
  50. * $this->adminInfo['data_rules']
  51. * province city admin_id sale_group_id sale_id property_head_id
  52. */
  53. public function queryDataWhere(){
  54. $where = [];
  55. $data_rules = $this->adminInfo['data_rules'];
  56. if (isset($data_rules['province']) && !empty($data_rules['province'])) {
  57. $where[] = ['province','in' ,$data_rules['province']];
  58. }
  59. if (isset($data_rules['city']) && !empty($data_rules['city'])) {
  60. $where[] = ['city','in' ,$data_rules['city']];
  61. }
  62. if(!empty($where)){
  63. $head_ids = PropertyHead::where($where)->column('id')??[0];
  64. $where = [['property_head_id','in' ,$head_ids]];
  65. }
  66. return $where;
  67. }
  68. /**
  69. * @notes 获取列表
  70. * @return array
  71. * @throws \think\db\exception\DataNotFoundException
  72. * @throws \think\db\exception\DbException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. * @author likeadmin
  75. * @date 2024/09/20 16:31
  76. */
  77. public function lists(): array
  78. {
  79. return PropertySurplusLog::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())
  80. ->field(['id', 'in_out', 'property_commission_id', 'amount', 'status', 'remark', 'property_head_id','create_time', 'update_time'])
  81. ->limit($this->limitOffset, $this->limitLength)
  82. ->order(['id' => 'desc'])
  83. ->select()
  84. ->toArray();
  85. }
  86. /**
  87. * @notes 获取数量
  88. * @return int
  89. * @author likeadmin
  90. * @date 2024/09/20 16:31
  91. */
  92. public function count(): int
  93. {
  94. return PropertySurplusLog::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
  95. }
  96. }