public static PhoneProviderType getPhoneProvider(String phone) {
// 截取前3或前4位電話號碼,判斷運營商
String head_three = phone.substring(0, 3);
PhoneProviderType phoneProviderType = pre_three.entrySet().stream().filter(e -> e.getValue().contains(head_three)).map(e -> e.getKey()).findFirst().orElse(null);
if(phoneProviderType == null){
String head_four = phone.substring(0, 4);
phoneProviderType = pre_four.entrySet().stream().filter(e -> e.getValue().contains(head_four)).map(e -> e.getKey()).findFirst().orElse(null);
}
if(phoneProviderType == null){
phoneProviderType = PhoneProviderType.聯通;
}
return phoneProviderType;
}