|
|
@@ -20,6 +20,35 @@ use App\Models\UserLogin;
|
|
|
|
|
|
class User extends Controller
|
|
|
{
|
|
|
+
|
|
|
+ //修改用户密码/资金密码
|
|
|
+ function setPassword()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $params = request()->validate([
|
|
|
+ 'member_id' => ['required', 'string', 'min:1'],
|
|
|
+ 'password' => ['nullable'],
|
|
|
+ 'payment_password' => ['nullable'],
|
|
|
+ ]);
|
|
|
+ $user = UserModel::where('member_id', $params['member_id'])->first();
|
|
|
+ if (!$user) throw new Exception("用户不存在", HttpStatus::CUSTOM_ERROR);
|
|
|
+
|
|
|
+ if (!empty($params['password'])) {
|
|
|
+ $user->password = password_hash($params['password'], PASSWORD_DEFAULT);
|
|
|
+ $user->save();
|
|
|
+ }
|
|
|
+ if (!empty($params['payment_password'])) {
|
|
|
+ $user->payment_password = password_hash($params['payment_password'], PASSWORD_DEFAULT);
|
|
|
+ $user->save();
|
|
|
+ }
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
|
|
|
+ }
|
|
|
+ return $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
function banned()
|
|
|
{
|
|
|
try {
|