Explorar el Código

24680兼容电话号码整理

PPPPPPP hace 1 semana
padre
commit
94a1f093f4

+ 24 - 3
app/Http/Controllers/Admin/LiveDataController.php

@@ -366,6 +366,25 @@ class LiveDataController extends Controller
             $value['status']=200;
             $googlePlayList[]=$value;
         }
+
+        // 获取iOS App Store监控列表
+        $ioslist = DB::connection('mysql')->table('webgame.WebChannelConfig')
+            ->selectRaw("LightApk as iosurl, Channel as id, Remarks as name")
+            ->whereNotNull('LightApk')
+            ->where('LightApk', '!=', '')
+            ->get()->toArray();
+
+        foreach ($ioslist as $value){
+            $value=(array)$value;
+            // 只处理包含apple的URL
+            if(!empty($value['iosurl']) && strpos($value['iosurl'], 'apple') !== false){
+                $value['url'] = $value['iosurl'];
+                $value['status'] = 200;
+                $value['type'] = 'ios';
+                $googlePlayList[]=$value;
+            }
+        }
+
         $old_list=[];
         if(Redis::exists("googleplay_list")){
             $old_list=json_decode(Redis::get("googleplay_list"),true);
@@ -405,13 +424,15 @@ class LiveDataController extends Controller
                     if($item['status']!=$olditem['status']){
                         $telegram = new TelegramBot();
                         $env = env('APP_ENV');
-                        $telegram->sendMsg($env."在线包 ".$item['name']." 异常,立即通知广告".$item['status'].':'.$item['url']);
+                        $platform = isset($item['type']) && $item['type'] == 'ios' ? 'iOS App' : 'Google Play';
+                        $telegram->sendMsg($env."在线包(".$platform.") ".$item['name']." 异常,立即通知广告".$item['status'].':'.$item['url']);
                         if(!isset($item['downtime']))$item['downtime']=time();
                     }else if($item['status']==200){
                         if(isset($item['title'])&&isset($olditem['title'])&&$item['title']!=$olditem['title']){
                             $telegram = new TelegramBot();
                             $env = env('APP_ENV');
-                            $telegram->sendMsg($env."上包通过 ".$item['name']." 名称更改--".$item['title'].",立即通知广告".$item['status'].':'.$item['url']);
+                            $platform = isset($item['type']) && $item['type'] == 'ios' ? 'iOS App' : 'Google Play';
+                            $telegram->sendMsg($env."上包通过(".$platform.") ".$item['name']." 名称更改--".$item['title'].",立即通知广告".$item['status'].':'.$item['url']);
                             if(!isset($item['uptime']))$item['uptime']=time();
                         }
                     }
@@ -449,7 +470,7 @@ class LiveDataController extends Controller
             'pay_user_count' => $pay_user_count,//总充值人数
 
             'time' => date('Y-m-d'),
-            ];
+        ];
 
 
 //        print_r($alldatas);die;

+ 6 - 1
app/Http/Controllers/Api/ApkController.php

@@ -49,7 +49,12 @@ class ApkController extends Controller
         if (strstr($username, '@')) {
             $user = GlobalUserInfo::getGameUserInfo("Email", $username);
         } else if(is_numeric($username)){
-            $user = GlobalUserInfo::getGameUserInfo("Phone", $RegisterLocation . $username);
+            $phone = preg_replace('/\D/s', '', trim((string)$username));
+            $countryCode = preg_replace('/\D/s', '', trim((string)$RegisterLocation));
+            if ($phone !== '' && $countryCode !== '' && !str_starts_with($phone, $countryCode)) {
+                $phone = $countryCode . $phone;
+            }
+            $user = GlobalUserInfo::getGameUserInfo("Phone", $phone);
         }else{
             $user = GlobalUserInfo::getGameUserInfo("Accounts", $username);
         }

+ 10 - 3
app/Http/Controllers/Api/SendCodeController.php

@@ -28,7 +28,7 @@ class SendCodeController
     public function send(Request $request)
     {
 
-        $phone = $request->Phone ?: '';
+        $phone = preg_replace('/\D/s', '', trim((string)($request->Phone ?: '')));
         $UserID = $request->UserID ?: 0;
         $Type = $request->Type ?: 0;    // 标识 1找回密码
         $ip = $request->ip();
@@ -84,9 +84,10 @@ class SendCodeController
         //给电话号码加区号
         $CountryCode=env('COUNTRY_CODE','52');
         if(strstr($CountryCode,','))$CountryCode=IpCheck::$countries[$user->BindCountry]['phone_code']??env('COUNTRY_CODE','52');
-        Log::info($CountryCode.'|'.$user->BindCountry);
         //用了配置的多区域区号带逗号来分割
         if(strlen($CountryCode)>3)$CountryCode=explode(',',$CountryCode)[0];
+        $CountryCode = preg_replace('/\D/s', '', trim((string)$CountryCode));
+        Log::info($CountryCode.'|'.$user->BindCountry);
 
 
         //巴基斯坦判断
@@ -134,6 +135,10 @@ class SendCodeController
             }
         }
 
+        if ($CountryCode !== '' && str_starts_with($phone, $CountryCode)) {
+            $phone = substr($phone, strlen($CountryCode));
+        }
+
         //检查电话长度
         $lenSize=IpCheck::$countries[$user->BindCountry]['phone_length']??env("PHONE_LENGTH","7,10");
         $lenSize=explode(",",$lenSize);
@@ -144,7 +149,9 @@ class SendCodeController
         }
 
             //电话补齐
-        $phone=$CountryCode.$phone;
+        if ($CountryCode !== '' && !str_starts_with($phone, $CountryCode)) {
+            $phone = $CountryCode . $phone;
+        }
         Log::info('now:'.$phone);
 
         if ($SendCodeConfig->count() > 1) {

+ 23 - 10
app/Http/Controllers/Game/LoginController.php

@@ -63,7 +63,7 @@ class LoginController extends Controller
         if (mb_strlen($PhoneCode) > 6) {
             return apiReturnFail(['web.verify.code_too_long', 'Phone code is too long']);
         }
-        $Phone = $RegisterLocation.trim($Phone);
+        $Phone = $this->normalizePhoneWithCountryCode($Phone, $RegisterLocation);
 
 
         Log::info('验证电话开始' . $Phone);
@@ -120,7 +120,7 @@ class LoginController extends Controller
 
 
 
-        $Phone = $RegisterLocation.trim($Phone);
+        $Phone = $this->normalizePhoneWithCountryCode($Phone, $RegisterLocation);
 
         Log::info('绑定电话开始' . $Phone);
 
@@ -518,7 +518,7 @@ class LoginController extends Controller
             return apiReturnFail(['web.verify.code_too_long', 'Phone code is too long']);
         }
 
-        $Phone = $RegisterLocation.trim($Phone);
+        $Phone = $this->normalizePhoneWithCountryCode($Phone, $RegisterLocation);
 
         Log::info('验证电话开始' . $Phone);
 
@@ -550,7 +550,7 @@ class LoginController extends Controller
             return $check;
         }
         $RegisterLocation = $request->country ?? env('COUNTRY_CODE','55');
-        $user = GlobalUserInfo::getGameUserInfo("Phone", $RegisterLocation . $request->phone);
+        $user = GlobalUserInfo::getGameUserInfo("Phone", $this->normalizePhoneWithCountryCode($request->phone, $RegisterLocation));
         if(!$user||empty($user)){
             return $this->registerUser($request);
             return apiReturnFail(['web.login.notfound', 'Erro de entrada, tente novamente!'], '', 2);
@@ -796,7 +796,7 @@ class LoginController extends Controller
         if (strstr($request->account, '@')) {
             $user = GlobalUserInfo::query()->where('RegionID', $config->isRegionUnique())->where("Email", $request->account)->first();
         } else if (is_numeric($request->account)) {
-            $user = GlobalUserInfo::query()->where('RegionID', $config->isRegionUnique())->where("Phone", $RegisterLocation . $request->account)->first();
+            $user = GlobalUserInfo::query()->where('RegionID', $config->isRegionUnique())->where("Phone", $this->normalizePhoneWithCountryCode($request->account, $RegisterLocation))->first();
         } else {
             $user = GlobalUserInfo::query()->where('RegionID', $config->isRegionUnique())->where("Accounts", $request->account)->first();
         }
@@ -815,14 +815,27 @@ class LoginController extends Controller
 
     }
 
-    private function checkPhone($Phone, $RegisterLocation = '1',Request $request=null)
+    private function normalizePhoneWithCountryCode($Phone, $RegisterLocation = '1')
     {
-        $OrgPhone=$Phone;
-//        dd($RegisterLocation,$Phone,str_starts_with($Phone,$RegisterLocation),$Phone=explode($RegisterLocation,$Phone));
-        if(!empty($RegisterLocation)&&str_starts_with($Phone,$RegisterLocation)){
+        $Phone = preg_replace('/\D/s', '', trim((string)$Phone));
+        $RegisterLocation = preg_replace('/\D/s', '', trim((string)$RegisterLocation));
+
+        if ($Phone === '' || $RegisterLocation === '') {
+            return $Phone;
+        }
 
-            $Phone=$OrgPhone;
+        if (str_starts_with($Phone, $RegisterLocation)) {
+            return $Phone;
         }
+
+        return $RegisterLocation . $Phone;
+    }
+
+    private function checkPhone($Phone, $RegisterLocation = '1',Request $request=null)
+    {
+        $OrgPhone=trim((string)$Phone);
+        $Phone = $this->normalizePhoneWithCountryCode($Phone, $RegisterLocation);
+//        dd($RegisterLocation,$Phone,str_starts_with($Phone,$RegisterLocation),$Phone=explode($RegisterLocation,$Phone));
         if (!empty($Phone)) {
             // 验证规则
             // Remove spaces and dashes from the input

+ 5 - 3
app/Http/Controllers/Game/SendCodeController.php

@@ -26,13 +26,13 @@ class SendCodeController
         $Channel=$request->input("c",99);
         $UserID=0;
 
-        $phone = $request->Phone ?: '';
+        $phone = preg_replace('/\D/s', '', trim((string)($request->Phone ?: '')));
 
         if (!is_numeric($phone)) {
             return apiReturnFail(['web.user.phone_fail', 'Not correct phone number'], '', 422);
         }
 
-        $LocationCode = $request->country ?? env('COUNTRY_CODE',1);
+        $LocationCode = preg_replace('/\D/s', '', trim((string)($request->country ?? env('COUNTRY_CODE',1))));
 
         $user=$request->user();
         if($user){
@@ -63,7 +63,9 @@ class SendCodeController
 //        Redis::expire('SendCodeController' . $phone, 30);
 
 
-        $phone=$LocationCode.$phone;
+        if ($LocationCode !== '' && !str_starts_with($phone, $LocationCode)) {
+            $phone = $LocationCode . $phone;
+        }
         Log::info('接收客户端发送验证码手机号:'.$phone.' Type类型:'.$Type.' 用户ID:'.$UserID.' WebRegister:'.$WebRegister);
         $SendCodeConfig = DB::connection('read')->table('QPAccountsDB.dbo.SysSmsConfig')
             ->where('Status', 1)

+ 5 - 2
app/Http/Controllers/Game/WithDrawInfoController.php

@@ -567,8 +567,11 @@ class WithDrawInfoController
                 return apiReturnFail(['web.verify.code_empty', 'Verification code cannot be empty']);
             }
 
-            $phone = DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum');
-            $phone = trim(env('COUNTRY_CODE',1) . $phone);
+            $phone = trim((string)DB::table(TableName::QPAccountsDB() . 'AccountPhone')->where('UserID', $UserID)->value('PhoneNum'));
+            $countryCode = preg_replace('/\D/s', '', trim((string)env('COUNTRY_CODE',1)));
+            if ($phone !== '' && $countryCode !== '' && !str_starts_with($phone, $countryCode)) {
+                $phone = $countryCode . $phone;
+            }
             if (empty($phone)) {
                 return apiReturnFail(['web.verify.phone_not_bound', 'Phone number not bound']);
             }