Explorar el Código

客户端-短信验证码支持港澳台手机号码

sunxbiao hace 1 año
padre
commit
56062b7d32
Se han modificado 1 ficheros con 19 adiciones y 4 borrados
  1. 19 4
      crmeb/services/AliYunSmsService.php

+ 19 - 4
crmeb/services/AliYunSmsService.php

@@ -39,10 +39,25 @@ class AliYunSmsService
39
         log::info("发送短信方法");
39
         log::info("发送短信方法");
40
         switch ($templateId) {
40
         switch ($templateId) {
41
             case 'AUTHCODE':
41
             case 'AUTHCODE':
42
-                $SignName = '融合华夏';
43
-                $TemplateCode = 'SMS_311255692';
44
-
45
-                $content = '【华夏幸福保】您的验证码是:' . $code;
42
+                // 移除所有非数字字符(保留+)
43
+                $phone = preg_replace('/[^0-9+]/', '', $mobile);
44
+                // 检查是否带国际区号
45
+                if (strpos($phone, '+852') === 0) {
46
+                    // 格式:+85251234567 → 检查后8位
47
+                    $phone = substr($phone, 4);
48
+                }
49
+                if((strlen($phone) === 8 && preg_match('/^[569]\d{7}$/', $phone))) {
50
+                    $SignName = '融合华夏';
51
+                    $TemplateCode = 'SMS_492105133';
52
+                    $templateParam = [
53
+                        'code_zh' => $code,
54
+                        'code_en' => $code
55
+                    ];
56
+                } else if (strlen($phone) === 11 && preg_match('/^1[3-9]\d{9}$/', $phone)) {
57
+                    $SignName = '融合华夏';
58
+                    $TemplateCode = 'SMS_311255692';
59
+                    $content = '【华夏幸福保】您的验证码是:' . $code;
60
+                }
46
                 break;
61
                 break;
47
             case 'ONESELFCARRY':
62
             case 'ONESELFCARRY':
48
                 $SignName = '华夏幸福保';
63
                 $SignName = '华夏幸福保';