租金接口修改

This commit is contained in:
2026-01-13 21:53:18 +08:00
parent 2ffda14e94
commit 39ff1bca75
@@ -5970,9 +5970,8 @@ public class PropertyController {
public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException {
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();
mav.setViewType("rest"); mav.setViewType("rest");
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) {
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) { mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,地址,面积(size)为必填项"));
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
return mav; return mav;
} }
if (model.getCity().endsWith("市")) { if (model.getCity().endsWith("市")) {
@@ -5992,15 +5991,6 @@ public class PropertyController {
model.setCalDate(calDate); model.setCalDate(calDate);
} }
} }
/* 先到CPDB库中查找小区 */
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
"district");
if (district == null) {
mav.setModel(BasicModel.buildBadRequestModel("该小区不存在"));
return mav;
}
model.setName(district.getName());
if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) { if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)")); mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
@@ -6016,6 +6006,59 @@ public class PropertyController {
return mav; return mav;
} }
District district = null;
if(StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())){
/* 先到CPDB库中查找小区 */
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
"district");
}
boolean villaFlag = DataUtil.isVilla(model.getSize(), model.getName(), model.getHeight(), model.getRoom());
Map<String, Object> params = new HashMap<String, Object>();
params.put("city", model.getCity());
if (StringUtils.isNotBlank(model.getDistrict())) {
params.put("suggestDistrict", model.getDistrict());
}
params.put("address", model.getAddress());
if (StringUtils.isNotBlank(model.getName())) {
params.put("suggestName", model.getName());
}
params.put("category", "district");
params.put("propertyType", model.getPropertyType());
String result = addressMatchProxyService.parser(params);
if (result != null) {
JSONObject json = JSONObject.fromObject(result);
if (json.getInt("code") == 200) {
Map<String, Object> map = (Map<String, Object>) json.get("result");
if ((Integer) map.get("precise") >= 0) {
String propertyType = (String) map.get("propertyType");
// 优先使用客户的物业类型,即使面积很大也不进行别墅推断 20241111
String userPropertyTypeParam = model.getPropertyType();
if (StringUtils.isNotBlank(userPropertyTypeParam) && ("0,2".contains(userPropertyTypeParam))) {
villaFlag = false;
}
if (villaFlag && StringUtils.isNotBlank(propertyType) && !propertyType.equals("别墅")) {
district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name") + "别墅", "district");
}
if (null == district) {
district = districtService.findByNameAndAlias((String) map.get("city"), (String) map.get("district"), (String) map.get("name"), "district");
}
}
}
}
if (district == null) {
//使用新匹配再配一遍,不加类型,有结果,类型为district则走小区估值,其它类型也走经纬度估值
JSONObject resultObject = addressMatchProxyService.newMatch(model.getCity(), model.getAddress(), null, false);
if (resultObject != null && resultObject.containsKey("category") && resultObject.get("category")!=null) {
if(resultObject.containsKey("id") && resultObject.get("category").equals("district")){
String id = (String) resultObject.get("id");
district = districtService.findById(id);
}
}
}
if(district != null){
model.setRegion(district.getRegion()); model.setRegion(district.getRegion());
model.setDistrictName(district.getName()); model.setDistrictName(district.getName());
if (StringUtils.isBlank(model.getPropertyType())) { if (StringUtils.isBlank(model.getPropertyType())) {
@@ -6038,7 +6081,6 @@ public class PropertyController {
evaluation.setSource("api_property_evaluate_rent"); evaluation.setSource("api_property_evaluate_rent");
evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate()); evaluation = evaluationService.evaluateRent(district, evaluation, model.getCalDate());
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) { if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) {
Map<String, Object> districtPriceMap = new HashMap<String, Object>(); Map<String, Object> districtPriceMap = new HashMap<String, Object>();
districtPriceMap.put("city", district.getCity()); districtPriceMap.put("city", district.getCity());
@@ -6050,12 +6092,14 @@ public class PropertyController {
districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue()); districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
return mav; return mav;
} else { }else{
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData()); mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav; return mav;
} }
} }
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的租金估价").markNoData());
return mav;
}
public Object searchHouseLoudongAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException { public Object searchHouseLoudongAction(PropertyEvaluationModel model, HttpServletRequest request) throws NumberFormatException, IllegalAccessException {
RestfulModelAndView mav = new RestfulModelAndView(); RestfulModelAndView mav = new RestfulModelAndView();