SelectUserLists.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\lists\user;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\lists\ListsSearchInterface;
  22. use app\common\model\User;
  23. /**
  24. * 选择用户列表
  25. * Class SelectUserLists
  26. * @package app\adminapi\lists\user
  27. */
  28. class SelectUserLists extends BaseAdminDataLists implements ListsSearchInterface
  29. {
  30. /**
  31. * @notes 设置搜索
  32. * @return \string[][]
  33. * @author Tab
  34. * @date 2021/9/14 11:18
  35. */
  36. public function setSearch(): array
  37. {
  38. return [
  39. '=' => ['d.is_distribution'],
  40. '%like%' => ['u.sn', 'u.nickname']
  41. ];
  42. }
  43. /**
  44. * @notes 搜索
  45. * @return array
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\DbException
  48. * @throws \think\db\exception\ModelNotFoundException
  49. * @author Tab
  50. * @date 2021/9/14 11:18
  51. */
  52. public function lists(): array
  53. {
  54. $field = [
  55. 'u.id',
  56. 'u.sn',
  57. 'u.nickname',
  58. 'u.mobile',
  59. 'u.avatar',
  60. 'u.create_time',
  61. 'u.user_money',
  62. 'u.user_delete',
  63. 'd.is_distribution'
  64. ];
  65. $lists = User::alias('u')
  66. ->leftJoin('distribution d', 'd.user_id = u.id')
  67. ->field($field)
  68. ->where($this->searchWhere)
  69. ->where('user_delete', 0)
  70. ->limit($this->limitOffset, $this->limitLength)
  71. ->select()
  72. ->toArray();
  73. return $lists;
  74. }
  75. /**
  76. * @notes 记录数
  77. * @return int
  78. * @author Tab
  79. * @date 2021/9/14 11:19
  80. */
  81. public function count(): int
  82. {
  83. $count = User::alias('u')
  84. ->leftJoin('distribution d', 'd.user_id = u.id')
  85. ->where($this->searchWhere)
  86. ->where('user_delete', 0)
  87. ->count();
  88. return $count;
  89. }
  90. }