Pārlūkot izejas kodu

手机号号码过滤

bianjunhui 2 gadi atpakaļ
vecāks
revīzija
1f0065993b

+ 28 - 8
application/module/ctrl/Send_sms_adminAction.class.php

@@ -228,7 +228,7 @@ class Send_sms_adminAction extends Action
         $where =" where is_send=0";
         $page=1;
         $pageSize=50;
-        $city_code =$admin->selectCityCode();
+        $city_code =$admin->selectCityCode() ;
         $new=array();
         foreach ($city_code as $v){
             $new[]=$v['code'];
@@ -243,12 +243,7 @@ class Send_sms_adminAction extends Action
                 foreach ($customer_list as $vs){
                     $countryMobile = $this->getCountryMobile($vs['country']);
                     if($countryMobile==1){
-                        $code = substr($vs['tel'] , 0 , 3);
-                        if (in_array($code, $new)) {
-                            $is_send=1;
-                        }else{
-                            $is_send=2;
-                        }
+                        $is_send =$this->getSend($vs['tel'],$new);
                     }
                     $admin->upCodeSmsCustomer($is_send,$vs['id']);
                 }
@@ -262,7 +257,32 @@ class Send_sms_adminAction extends Action
 
 
     }
-
+    public function getSend($mobile,$new)
+    {
+        $mobile= str_replace('-', '', $mobile);
+        $mobile= str_replace('_', '', $mobile);
+        $mobile= str_replace('(', '', $mobile);
+        $mobile= str_replace(')', '', $mobile);
+        $mobile= str_replace('+', '', $mobile);
+        $mobile= str_replace(' ', '', $mobile);
+        $mobile=trim($mobile);
+        $lenth=strlen($mobile);
+        $frist =(int)substr($mobile, 0, 1 );
+        $code=0;
+        if($lenth==10){
+            $code = substr($mobile , 0 , 3);
+        }
+        if($lenth==11&&$frist==1){//例:14696305087
+            $code = substr($mobile , 1 , 3);
+        }
+        $is_send=2;
+        if($code){
+            if (in_array($code, $new)) {
+                $is_send=1;
+            }
+        }
+        return $is_send;
+    }
     public function getCountryMobile($countryCode){
         $country = $countryCode;
         $countrys_en = [ "China", "Afghanistan", "Albania", "Algera",

+ 30 - 6
application/module/ctrl/Sms_customer_list_adminAction.class.php

@@ -347,12 +347,8 @@ class Sms_customer_list_adminAction extends Action{
 							continue;
 						}
 						if($country=='United States'||$country=='Canada'){
-                            $code = substr($tel , 0 , 3);
-                            if (in_array($code, $new)) {
-                                $is_send=1;
-                            }else{
-                                $is_send=2;
-                            }
+                            $is_send =$this->getSend($tel,$new);
+
                         }
 						$values .= "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$groupName}', 0, '{$is_send}'),";
 					}
@@ -377,6 +373,34 @@ class Sms_customer_list_adminAction extends Action{
 
 	}
 
+
+    public function getSend($mobile,$new)
+    {
+        $mobile= str_replace('-', '', $mobile);
+        $mobile= str_replace('_', '', $mobile);
+        $mobile= str_replace('(', '', $mobile);
+        $mobile= str_replace(')', '', $mobile);
+        $mobile= str_replace('+', '', $mobile);
+        $mobile= str_replace(' ', '', $mobile);
+        $mobile=trim($mobile);
+        $lenth=strlen($mobile);
+        $frist =(int)substr($mobile, 0, 1 );
+        $code=0;
+        if($lenth==10){
+            $code = substr($mobile , 0 , 3);
+        }
+        if($lenth==11&&$frist==1){//例:14696305087
+            $code = substr($mobile , 1 , 3);
+        }
+        $is_send=2;
+        if($code){
+            if (in_array($code, $new)) {
+                $is_send=1;
+            }
+        }
+        return $is_send;
+    }
+
 	public function importBlackList(){
 
 		$admin = new AdvertAdminAction();