Browse Source

美国的邮编需要长度为5且位数字的字符串

lvhao 2 months ago
parent
commit
744ef66e42
1 changed files with 11 additions and 5 deletions
  1. 11 5
      core/CoreApp/models/Model_logic_order.php

+ 11 - 5
core/CoreApp/models/Model_logic_order.php

@@ -255,12 +255,18 @@ class Model_logic_order extends Lin_Model {
 
     //根据提交信息 校验一下客户下单是否正确
     public function checkEditCustomer($post){
-        if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
+
+        if($post['country'] == 192 )
         {
-            return [
-                'code'=>-1,
-                "msg"=>"USPS-USA的邮编需按5位数格式提交!"
-            ];
+            //如果国家是美国 邮编只能是字符串为5位的数字
+            $pattern = '/^\d{5}$/';
+            if(!preg_match($pattern, $post['zipcode'])){
+                return [
+                    'code'=>-1,
+                    "msg"=>"美国的邮编需按5位数格式提交!"
+                ];
+            }
+           
         }
         if($post['type'] != 5 && in_array($post['express'],[2,63,64]))
         {