Ken 1 viikko sitten
vanhempi
commit
a3dbfb6970

+ 2 - 1
app/Http/Controllers/api/Fingerprint.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\api;
 
 use App\Constants\HttpStatus;
+use App\Services\PublicService;
 use Illuminate\Validation\ValidationException;
 use Exception;
 
@@ -15,7 +16,7 @@ class Fingerprint extends BaseController
                 'member_id' => ['required', 'string'],
                 'visitor_id' => ['required', 'string'],
             ]);
-
+            PublicService:: setVisitorId($params['member_id'], $params['visitor_id']);
 
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());

+ 2 - 1
app/Models/User.php

@@ -10,11 +10,12 @@ namespace App\Models;
  * @property string $language
  * @property string $register_ip
  * @property integer $status
+ * @property string $visitor_id
  */
 class User extends BaseModel
 {
     protected $table = 'users';
-    protected $fillable = ['usdt', 'is_banned', 'register_ip', 'status', 'admin_note', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass', 'language'];
+    protected $fillable = ['usdt', 'is_banned', 'visitor_id', 'register_ip', 'status', 'admin_note', 'member_id', 'first_name', 'game_id', 'username', 'secret_key', 'secret_pass', 'language'];
     protected $attributes = [
         'language' => 'zh',
     ];

+ 7 - 3
app/Services/PublicService.php

@@ -18,7 +18,13 @@ class PublicService extends BaseService
         }
     }
 
-    public static function setVisitorId($memberId, $visitorId)
+    /**
+     * @param  $memberId string 会员编号
+     * @param $visitorId string 访客ID
+     * @return void
+     * @throws Exception
+     */
+    public static function setVisitorId(string $memberId, string $visitorId): void
     {
         $user = User::where('member_id', $memberId)->first();
         if (!$user) throw new Exception('验证失败', HttpStatus::CUSTOM_ERROR);
@@ -37,8 +43,6 @@ class PublicService extends BaseService
             }
             $user->register_ip = $registerIp;
         }
-
-
         $user->save();
     }