UserService.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\extra\service\system;
  3. use app\extra\basic\Service;
  4. use app\extra\dao\system\SystemUserDao;
  5. use app\model\system\SystemUser;
  6. class UserService extends Service
  7. {
  8. /**
  9. * 设置模型
  10. * @return string
  11. */
  12. public function __construct()
  13. {
  14. $this->dao = new SystemUserDao();
  15. }
  16. /**
  17. * 列表
  18. * @param array $param
  19. */
  20. // public function getList(array $param = [])
  21. // {
  22. // $this->mode = new SystemUser();
  23. // return $this->searchVal($param,$this->searchFilter($param))->with(['account' => function ($query) {
  24. // $query->field("shop_id,shop_name");
  25. // }])->paginate([
  26. // "list_rows" => $param['pageSize'],
  27. // "page" => $param['page']
  28. // ]);
  29. // }
  30. /**
  31. * 列表
  32. * @param array $param
  33. */
  34. public function getList(array $param = [])
  35. {
  36. [$page,$limit] = $this->getPageValue();
  37. $list = $this->dao->getList($this->searchFilter($param)+[['id','>',1]],'*',$page,$limit,'id desc');
  38. $count = $this->dao->count($this->searchFilter($param)+[['id','>',1]]);
  39. return compact('list','count');
  40. }
  41. protected function searchFilter(array $param = []): array
  42. {
  43. $filter = [];
  44. !empty($param['agent']) && $filter[] = ["agent_id", '=', $param['agent']];
  45. !empty($param['store']) && $filter[] = ["store_id", '=', $param['store']];
  46. !empty($param['factory']) && $filter[] = ["factory_id", '=', $param['factory']];
  47. !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
  48. !empty($param['mobile']) && $filter[] = ["mobile", 'like', "%{$param['mobile']}%"];
  49. !empty($param['username']) && $filter[] = ["username", 'like', "%{$param['username']}%"];
  50. !empty($param['name']) && $filter[] = ["username", 'like', "%{$param['name']}%"];
  51. !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
  52. return $filter;
  53. }
  54. }