Commit 915cf08e authored by 王业雄's avatar 王业雄

手机号区域限制存中文名

parent ec0ffa58
...@@ -211,7 +211,12 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -211,7 +211,12 @@ public class FundProductServiceImpl implements IFundProductService {
case "tel_area_list": case "tel_area_list":
//手机号区域限制 //手机号区域限制
if (Objects.nonNull(areaRuleConcrete)){ if (Objects.nonNull(areaRuleConcrete)){
map.put(productRuleEntity.getId(),areaRuleConcrete.getTelAreaNameList()); try {
String telAreaCodeListByName = getTelAreaCodeListByName(areaRuleConcrete.getTelAreaNameList());
map.put(productRuleEntity.getId(),telAreaCodeListByName);
}catch (Exception e){
log.error("获取手机号区域限制异常",e);
}
} }
break; break;
case "residence_list": case "residence_list":
...@@ -292,7 +297,12 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -292,7 +297,12 @@ public class FundProductServiceImpl implements IFundProductService {
one.setCardLimit(Integer.valueOf(value)); one.setCardLimit(Integer.valueOf(value));
break; break;
case "tel_area_list": case "tel_area_list":
areaRuleConcrete.setTelAreaNameList(value); try {
String telAreaNameListByCode = getTelAreaNameListByCode(value);
areaRuleConcrete.setTelAreaNameList(telAreaNameListByCode);
}catch (Exception e){
log.error("资金产品保存手机号区域限制异常",e);
}
break; break;
case "residence_list": case "residence_list":
areaRuleConcrete.setResidenceList(value); areaRuleConcrete.setResidenceList(value);
...@@ -310,6 +320,54 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -310,6 +320,54 @@ public class FundProductServiceImpl implements IFundProductService {
return GlobalResponse.success(); return GlobalResponse.success();
} }
//通过地区code获取对应的name
private String getTelAreaNameListByCode(String value) throws IOException {
if (StringUtils.isEmpty(value)){
return "";
}
InputStream in = this.getClass().getResourceAsStream("/phone/gbt.txt");
String var4 = InitAreaCode.getString(in);
List<AreaCode> list = new ArrayList<AreaCode>();
list = JSONObject.parseArray(var4, AreaCode.class);
String replace = value.replace("[", "").replace("]", "");
String[] split = replace.split(",");
List<String> telAreaNameList = new ArrayList<>();
for (int i = 0;i< split.length;i++){
for (AreaCode areaCode:list){
if (areaCode.getAdcode().equals(split[i])){
telAreaNameList.add(areaCode.getName());
break;
}
}
}
return telAreaNameList.toString();
}
//通过地区name获取对应的code
private String getTelAreaCodeListByName(String value) throws IOException {
if (StringUtils.isEmpty(value)){
return "";
}
InputStream in = this.getClass().getResourceAsStream("/phone/gbt.txt");
String var4 = InitAreaCode.getString(in);
List<AreaCode> list = new ArrayList<AreaCode>();
list = JSONObject.parseArray(var4, AreaCode.class);
String replace = value.replace("[", "").replace("]", "");
String[] split = replace.split(",");
List<String> telAreaCodeList = new ArrayList<>();
for (int i = 0;i< split.length;i++){
for (AreaCode areaCode:list){
if (areaCode.getName().equals(split[i])){
telAreaCodeList.add(areaCode.getAdcode());
break;
}
}
}
return telAreaCodeList.toString();
}
@Override @Override
public GlobalResponse getArea() throws IOException { public GlobalResponse getArea() throws IOException {
AreaCodeVo areaCodeVo = new AreaCodeVo(); AreaCodeVo areaCodeVo = new AreaCodeVo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment