Ken 2 weeks ago
parent
commit
dd5887515e

+ 19 - 1
app/Models/User.php

@@ -13,6 +13,9 @@ use Illuminate\Database\Eloquent\Builder;
 /**
  * @mixin Builder
  * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
+ * @property mixed $member_id
+ * @property mixed $username
+ * @property mixed $first_name
  */
 class User extends Authenticatable
 {
@@ -20,13 +23,28 @@ class User extends Authenticatable
 
     protected $table = 'users';
     protected $hidden = ['created_at', 'updated_at'];
-    protected $fillable = ['usdt', 'member_id', 'first_name', 'game_id', 'username'];
+    protected $fillable = ['usdt', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass'];
 
     public function wallet()
     {
         return $this->belongsTo(Wallet::class, 'id', 'user_id');
     }
 
+
+    public function getMemberId()
+    {
+        return $this->member_id;
+    }
+
+    public function getUsername()
+    {
+        return $this->username;
+    }
+
+    public function getFirstName(){
+        return $this->first_name;
+    }
+
     protected function getCreatedAtAttribute($value)
     {
         return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');

+ 26 - 1
app/Services/SecretService.php

@@ -3,6 +3,8 @@
 namespace App\Services;
 
 use App\Constants\StepStatus;
+use App\Models\User;
+use App\Models\Wallet;
 use Illuminate\Support\Facades\Cache;
 use Telegram\Bot\Api;
 use Telegram\Bot\Exceptions\TelegramSDKException;
@@ -43,10 +45,33 @@ class SecretService
 
     private static function inputOldSecret($chatId, $secret, $messageId): array
     {
-        $text = "";
+        $user = User::where(['secret_key' => $secret])->first();
+        if (!$user) {
+            return [
+                'chat_id' => $chatId,
+                'text' => "输入错误,请重新输入",
+                'reply_to_message_id' => $messageId
+            ];
+        }
+        $wallet = Wallet::where('member_id', $user->getMemberId())->first();
+
+        $keyboard = [
+            [
+                ['text' => '确认', 'callback_data' => 'secret@@confirm'],
+            ]
+        ];
+        $text = "原账号信息:\n";
+        $text .= "用户ID:{$user->getMemberId()}\n";
+        $text .= "用户名:{$user->getUsername()}\n}";
+        $text .= "昵称:{$user->getFirstName()}\n";
+        $text .= "余额:{$wallet->available_balance}\n";
+
+        $text .= "\n-------------------------------\n\n";
+        $text .= "注意:请确认原账号信息,点击确认后,原账号将注销,原账号的余额以及其他信息将同步到新账号中!此操作不可撤销";
         return [
             'chat_id' => $chatId,
             'text' => $text,
+            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
         ];
     }
 

+ 30 - 0
database/migrations/2025_11_24_140154_update_users.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->string('secret_key')->default("")->comment('找回账号的秘钥');
+            $table->string('secret_pass')->default("")->comment('查看秘钥的密码');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+};