...
|
...
|
@@ -432,6 +432,9 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
|
|
|
}
|
|
|
|
|
|
public static final String KEY_AREA_STR = "区";
|
|
|
|
|
|
public static final String[] REPLACE_STR = {"鉴定中心", "UFO"};
|
|
|
|
|
|
/**
|
|
|
* 查询并校验用户地址(left: 用户地址; right: 脱敏的用户地址)
|
...
|
...
|
@@ -456,9 +459,23 @@ public class ShoppingServiceImpl implements IShoppingService { |
|
|
|
|
|
// 检查地址是否是鉴定中心的地址
|
|
|
List<AppraiseAddressResp> appraiseAddressRespList = appraiseAddressService.queryAddressInfoList();
|
|
|
List<String> appraiseAddressStrList = appraiseAddressRespList.stream().map(AppraiseAddressResp::getAddress).distinct().collect(Collectors.toList());
|
|
|
List<String> appraiseAddressStrList = appraiseAddressRespList.stream().map(AppraiseAddressResp::getAddress).distinct().map(address->{
|
|
|
// 为了提高相似字符串的匹配程度,截掉区之前的字符串以及鉴定中心字符串
|
|
|
String str = address;
|
|
|
int index = str.indexOf(KEY_AREA_STR);
|
|
|
if (index != -1){
|
|
|
str = str.substring(index+1, str.length());
|
|
|
}
|
|
|
|
|
|
for (String replace : REPLACE_STR){
|
|
|
str = str.replaceAll(replace, "");
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}).distinct().collect(Collectors.toList());
|
|
|
// 存在和鉴定中心相同的地址
|
|
|
if (appraiseAddressStrList.stream().filter(x->StringSimilarity.compute(x, addressInfo.getAddress())>0.5).findFirst().isPresent()){
|
|
|
if (appraiseAddressStrList.stream().filter(x->StringSimilarity.getSimilarityRatio(x, addressInfo.getAddress())>0.5).findFirst().isPresent()
|
|
|
|| addressInfo.getAddress().contains(REPLACE_STR[0])){
|
|
|
logger.warn("submit address can not appraiseAddress, uid is {}, address is {}",shoppingRequest.getUid(), addressInfo.getAddress() );
|
|
|
throw new ServiceException(ServiceError.BUY_ADDRESS_CAN_NOT_APPRAISE_ADDRESS);
|
|
|
}
|
...
|
...
|
|