| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\extra\service\system;
- use app\extra\basic\Service;
- use app\extra\dao\system\SystemUserDao;
- use app\model\system\SystemUser;
- class UserService extends Service
- {
- /**
- * 设置模型
- * @return string
- */
- public function __construct()
- {
- $this->dao = new SystemUserDao();
- }
- /**
- * 列表
- * @param array $param
- */
- // public function getList(array $param = [])
- // {
- // $this->mode = new SystemUser();
- // return $this->searchVal($param,$this->searchFilter($param))->with(['account' => function ($query) {
- // $query->field("shop_id,shop_name");
- // }])->paginate([
- // "list_rows" => $param['pageSize'],
- // "page" => $param['page']
- // ]);
- // }
- /**
- * 列表
- * @param array $param
- */
- public function getList(array $param = [])
- {
- [$page,$limit] = $this->getPageValue();
- $list = $this->dao->getList($this->searchFilter($param)+[['id','>',1]],'*',$page,$limit,'id desc');
- $count = $this->dao->count($this->searchFilter($param)+[['id','>',1]]);
- return compact('list','count');
- }
- protected function searchFilter(array $param = []): array
- {
- $filter = [];
- !empty($param['agent']) && $filter[] = ["agent_id", '=', $param['agent']];
- !empty($param['store']) && $filter[] = ["store_id", '=', $param['store']];
- !empty($param['factory']) && $filter[] = ["factory_id", '=', $param['factory']];
- !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
- !empty($param['mobile']) && $filter[] = ["mobile", 'like', "%{$param['mobile']}%"];
- !empty($param['username']) && $filter[] = ["username", 'like', "%{$param['username']}%"];
- !empty($param['name']) && $filter[] = ["username", 'like', "%{$param['name']}%"];
- !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
- return $filter;
- }
- }
|