dataLists(new UserLists()); } public function add() { try { $params = $this->request->param(); $userSn = User::createUserSn(); $passwordSalt = Config::get('project.unique_identification'); $password = create_password(123456, $passwordSalt); $avatar = ConfigService::get('default_image', 'user_avatar'); Db::transaction(function () use($userSn,$password,$avatar,$params) { $user = User::create([ 'sn' => $userSn, 'avatar' => env('project.project_url').'/'.$avatar, 'nickname' => '用户' . $userSn, 'account' => $params['mobile'], 'mobile' => $params['mobile'], 'password' => $password, 'channel' => 6, ]); $admin = Admin::create([ 'user_id' => $user->id, 'name' => '用户' . $userSn, 'avatar' => env('project.project_url').'/'.$avatar, 'account' => $params['mobile'], 'password' => $password ]); AdminRole::create([ 'admin_id' => $admin->id, 'role_id' => 1 ]); }); return $this->success(); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } public function datas() { $datas = (new UserLogic())->datas(input('')); return $this->success('', $datas); } /** * @notes 获取用户详情 * @return \think\response\Json * @author 段誉 * @date 2022/9/22 16:34 */ public function detail() { $params = (new UserValidate())->goCheck('detail'); $detail = UserLogic::detail($params['id']); return $this->success('', $detail); } /** * @notes 编辑用户信息 * @return \think\response\Json * @author 段誉 * @date 2022/9/22 16:34 */ public function edit() { $params = (new UserValidate())->post()->goCheck('setInfo'); UserLogic::setUserInfo($params); return $this->success('操作成功', [], 1, 1); } /** * @notes 调整用户余额 * @return \think\response\Json * @author 段誉 * @date 2023/2/23 14:33 */ public function adjustMoney() { $params = (new AdjustUserMoney())->post()->goCheck(); $res = UserLogic::adjustUserMoney($params); if (true === $res) { return $this->success('操作成功', [], 1, 1); } return $this->fail($res); } }