username = $username; $user->password = Hash::make($password); $user->status2 = STATUS2::Normal; $res = $user->save(); if(\App\Module\Sys\User::isSysUid($user->id)){ $user->delete(); throw new \LogicException("错误34"); } if ($res === false) { return 'create-error'; } User::infoinfo($user->id,true); return $user; } /** * 使用手机号码注册 * * @param $phone * @param $password * @return Models\User|string|true * @throws LogicException */ static public function createPhone($phone, $password) { $user = self::create($phone, $password); if ($user === false) { throw new LogicException("create error"); } $b = Phone::bind($user->id, $phone); if ($user === false) { throw new LogicException("create bind error"); } return $user; } /** * 更改密码 * * @param $id * @param $password * @return string|true */ static public function resetPassword($id, $password) { $user = \App\Module\User\Models\User::query()->find($id); if (!$user) { return 'user-notfind'; } $user->password = Hash::make($password); $res = $user->save(); if ($res === false) { return 'update-error'; } return true; } /** * 列表 * * @param $page * @param $limit * @param $where * @return \Illuminate\Pagination\LengthAwarePaginator */ static public function lisss($page, $limit, $where) { $q = \App\Module\User\Models\User::query()->with([ 'fund', 'merchant', 'info' ]); $wArr = new Arr($where, $q); $wArr->queryNumber('user_id') ->queryString('mobile'); return $q->paginate($limit, [ 'user_id', 'nick_name' ], '', $page); } /** * @param $id * @return Models\User|null */ static public function info($id, $create = false) { $info = \App\Module\User\Logic\User::info($id, $create); return $info; } /** * * @param $id * @param $create * @return Models\UserInfo|null */ static public function infoinfo($id, $create = false) { $info = \App\Module\User\Logic\User::infoinfo($id, $create); return $info; } /** * 获取用户公共信息 * * @param $ids * @return array */ static public function pinfos($ids = []) { if(empty($ids)){ return []; } $ids2 = []; foreach ($ids as $id) { if(empty($id)){ continue; } if(\App\Module\Sys\User::isSysUid($id)){ continue; } $ids2[$id] = $id; } $res = self::pinfoCaches($ids2); if ($ids2) { /** * @var \App\Module\User\Models\UserInfo[] $users */ $users = \App\Module\User\Models\UserInfo::query()->whereIn('user_id', $ids2)->with([ 'merchant' ])->get(); foreach ($users as $user) { $userp = new UserPublic(); $userp->avatar = $user->avatar; $userp->user_id = $user->user_id; $userp->nick_name = $user->nickname; $userp->status = $user->status->value(); $res[$userp->user_id] = $userp; \Illuminate\Support\Facades\Cache::put(self::publicInfoKey($user->user_id), $userp); unset($ids2[$userp->user_id]); } } if (count($ids2)) { foreach ($ids2 as $id) { $userp = new UserPublic(); $userp->avatar = ''; $userp->user_id = $id; $userp->nick_name = '已注销'; $res[$userp->user_id] = $userp; \Illuminate\Support\Facades\Cache::put(self::publicInfoKey($userp->user_id), $userp); unset($ids2[$userp->user_id]); } } return $res; } /** * * @param $ids * @return void */ static public function pinfoCaches(&$ids) { $res = []; return $res; foreach ($ids as $id) { $c = \Illuminate\Support\Facades\Cache::get(self::publicInfoKey($id)); if ($c) { $res[$id] = $c; unset($ids[$id]); } } return $res; } /** * 用户公共数据缓存key * * @param $uid * @return string */ static public function publicInfoKey($uid) { return 'lan_userpublic_' . $uid; } static public function getPhone() { } }