Просмотр исходного кода

feat(user): 兼容港澳台证件号年龄计算- 根据证件类型判断是否使用生日字段计算年龄
- 保持原有大陆身份证号码的年龄计算逻辑
- 确保不同证件类型的用户都能正确计算年龄

shichen месяцев назад: 10
Родитель
Сommit
2bad519558
1 измененных файлов с 8 добавлено и 1 удалено
  1. 8 1
      app/common/repositories/user/UserRepository.php

+ 8 - 1
app/common/repositories/user/UserRepository.php

@@ -2899,7 +2899,14 @@ class UserRepository extends BaseRepository
2899 2899
             //            $birth = strtotime(substr($certification["user_card"], 6, 8));
2900 2900
             $old_age = $this->getSex($certification["user_card"])?60:55;
2901 2901
             //            $age = $this->howOld($birth);
2902
-            $age=$this->calculateAge($birth_data);
2902
+
2903
+
2904
+            // 兼容港澳台证件号
2905
+            if ($certification['card_type'] == 1){
2906
+                $age=$this->calculateAge($birth_data);
2907
+            }else{
2908
+                $age=$this->calculateAge($certification['birthday']);
2909
+            }
2903 2910
 
2904 2911
             if ($age < $old_age) {
2905 2912
                 //                $yes = $old_age - $age;