SaleLists.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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\sale;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\sale\Sale;
  17. use app\common\lists\ListsSearchInterface;
  18. /**
  19. * Sale列表
  20. * Class SaleLists
  21. * @package app\adminapi\lists
  22. */
  23. class SaleLists extends BaseAdminDataLists implements ListsSearchInterface
  24. {
  25. /**
  26. * @notes 设置搜索条件
  27. * @return \string[][]
  28. * @author likeadmin
  29. * @date 2024/12/15 10:53
  30. */
  31. public function setSearch(): array
  32. {
  33. return [
  34. '=' => ['sale_group_id', 'sale_name', 'mobile'],
  35. ];
  36. }
  37. /**
  38. * 获取数据权限
  39. * $this->adminInfo['data_rules']
  40. * province city admin_id sale_group_id sale_id property_head_id
  41. */
  42. public function queryDataWhere(){
  43. $where = [];
  44. $data_rules = $this->adminInfo['data_rules'];
  45. /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
  46. $where[] = ['province','in' ,$data_rules['province']];
  47. }
  48. if (isset($data_rules['city']) && !empty($data_rules['city'])) {
  49. $where[] = ['city','in' ,$data_rules['city']];
  50. }*/
  51. if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
  52. $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
  53. }
  54. if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
  55. $where[] = ['sale_id','in' ,$data_rules['sale_id']];
  56. }
  57. return $where;
  58. }
  59. /**
  60. * @notes 获取列表
  61. * @return array
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\DbException
  64. * @throws \think\db\exception\ModelNotFoundException
  65. * @author likeadmin
  66. * @date 2024/12/15 10:53
  67. */
  68. public function lists(): array
  69. {
  70. return Sale::with(['saleGroupInfo'])->where($this->searchWhere)
  71. ->where($this->queryDataWhere())
  72. ->field(['id', 'sale_group_id', 'sale_name', 'mobile'])
  73. ->limit($this->limitOffset, $this->limitLength)
  74. ->order(['id' => 'desc'])
  75. ->select()
  76. ->toArray();
  77. }
  78. /**
  79. * @notes 获取数量
  80. * @return int
  81. * @author likeadmin
  82. * @date 2024/12/15 10:53
  83. */
  84. public function count(): int
  85. {
  86. return Sale::where($this->searchWhere)->where($this->queryDataWhere())->count();
  87. }
  88. }