ソースを参照

保存手机型号

laowu 1 週間 前
コミット
759dcb3a3a

+ 13 - 2
app/Http/Controllers/Game/WebRouteController.php

@@ -76,8 +76,19 @@ class WebRouteController extends Controller
         }
         $user = GlobalUserInfo::$me;//LoginController::checkLogin($request);
         if ($user) {
-            Redis::set('user_ua_' . $user->UserID, $request->userAgent());
-            Redis::expireAt('user_ua_' . $user->UserID, time() + 86400 * 30);
+            $ua = $request->userAgent();
+            if (stripos($ua, 'iPhone') !== false) {
+                $mobileBand = 'iPhone';
+            }
+            if (preg_match('/Android\s[\d\.]+;\s([^)]+)/i', $ua, $match)) {
+                $mobileBand = 'Android';
+            }
+            if (stripos($ua, 'Windows') !== false) {
+                $mobileBand = 'PC';
+            }
+            if (isset($mobileBand)) {
+                AccountsInfo::saveMobileBand($user->UserID, $mobileBand);
+            }
         }
 
 

+ 1 - 14
app/Http/logic/admin/GlobalLogicController.php

@@ -703,20 +703,7 @@ class GlobalLogicController extends BaseLogicController
             $platformData[$pitem]['today'] = (Redis::get($dkey)?:0)/100;
         }
         // 手机型号
-        $data['mobileBand'] = '';
-        $res = Redis::get('user_ua_' . ($user->UserID ?? ''));
-        if ($res) {
-            $ua = $res ?? '';
-            if (stripos($ua, 'iPhone') !== false) {
-                $data['mobileBand'] = 'iPhone';
-            }
-            if (preg_match('/Android\s[\d\.]+;\s([^)]+)/i', $ua, $match)) {
-                $data['mobileBand'] = 'Android' . trim($match[1]);
-            }
-            if (stripos($ua, 'Windows') !== false) {
-                $data['mobileBand'] = 'PC';
-            }
-        }
+        $data['mobileBand'] = $userInfo->LastLogonMobile;
         // 退款信息
         $data['refund_flag'] = DB::table('agent.dbo.order')
             ->where(['user_id' => $UserID, 'pay_status' => 9])

+ 6 - 0
app/Models/AccountsInfo.php

@@ -734,4 +734,10 @@ class AccountsInfo extends Model
         return $Sql->selectRaw('sum(ChangeScore) Score')
             ->first()->Score;
     }
+
+    public static function saveMobileBand($UserID, $mobileBand)
+    {
+        DB::connection('write')->table('QPAccountsDB.dbo.AccountsInfo')->where('UserID', $UserID)
+            ->update(['LastLogonMobile' => $mobileBand]);
+    }
 }