From 2d2bf820ba55c486dd214a8f23b4b47dbc3d144e Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 29 Jan 2026 19:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E9=93=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/CommercialController.java | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CommercialController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CommercialController.java index 96ac55875..8dcfc974c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CommercialController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CommercialController.java @@ -116,15 +116,18 @@ public class CommercialController { if(mav.model()!=null){ return mav; } - Double ratio = null;//getUserPriceRatio(request); + Double ratio = getUserPriceRatio(request); JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPSELL_EVALUATE); if (json != null) { if (json.containsKey("msg") && "³É¹¦".equals(json.getString("msg"))) { if (json.containsKey("unitPrice") && json.containsKey("location")) { - Integer unitPrice = null; + Double unitPrice = null; if(json.get("unitPrice") != null){ - unitPrice = (Integer) json.get("unitPrice"); + unitPrice = (Double) json.get("unitPrice"); + if(ratio!=null){ + unitPrice = unitPrice * ratio; + } int minPrice = (int) (unitPrice - unitPrice * 0.1); model.setMinPrice(minPrice); @@ -141,12 +144,17 @@ public class CommercialController { JSONObject locObj = json.getJSONObject("location"); Double lng = locObj.getDouble("lon"); Double lat = locObj.getDouble("lat"); - List houseSelf = dealSampleService.querySampleByLocation(lng, lat, model.getMinPrice(), model.getMaxPrice(), "shop_sell", 5); + List houseSelf = dealSampleService.querySampleByLocation(lng, lat, model.getMinPrice(), model.getMaxPrice(), "shop_sell", 30); List dtos = createSample(houseSelf, "sell", ratio, lng, lat, unitPrice.doubleValue()); + + if(dtos!=null && dtos.size()>5){ + dtos = dtos.subList(0,5); + } mav.setModel(BasicModel.buildOKModel().setResult(dtos)); if(dtos!=null && dtos.size()<5){ BasicModel.markNoDataRequest(); } + } } else{ mav.setModel(BasicModel.buildOKModel().setResult(null)); @@ -280,17 +288,17 @@ public class CommercialController { dto.setName(sample.getName()); // dto.setLocation(sample.getString("location")); - if(ratio != null){ - Integer totalPrice = (int)(sample.getTotalPrice().intValue() * ratio); - if(cat.equals("rent")){ - Double dayPrice = totalPrice/(sample.getSize()*30); - dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice)); - }else{ - Integer avgPrice = BigDecimal.valueOf(totalPrice/sample.getSize()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); - dto.setUnitPrice(avgPrice); - } - dto.setTotalPrice(totalPrice); - }else{ +// if(ratio != null){ +// Integer totalPrice = (int)(sample.getTotalPrice().intValue() * ratio); +// if(cat.equals("rent")){ +// Double dayPrice = totalPrice/(sample.getSize()*30); +// dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice)); +// }else{ +// Integer avgPrice = BigDecimal.valueOf(totalPrice/sample.getSize()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); +// dto.setUnitPrice(avgPrice); +// } +// dto.setTotalPrice(totalPrice); +// }else{ if(cat.equals("rent")){ Double dayPrice = sample.getTotalPrice()/(sample.getSize()*30); dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice)); @@ -298,7 +306,7 @@ public class CommercialController { dto.setUnitPrice(sample.getUnitPrice()); } dto.setTotalPrice(sample.getTotalPrice()); - } +// } dto.setSize(sample.getSize()); if(StringUtils.isNotBlank(sample.getType())){ dto.setEstateType(sample.getType()); @@ -383,7 +391,7 @@ public class CommercialController { if(mav.model()!=null){ return mav; } - Double ratio = null;//getUserPriceRatio(request); + Double ratio = getUserPriceRatio(request); JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPRENT_EVALUATE); if (json != null) { if (json.containsKey("msg") && "³É¹¦".equals(json.getString("msg"))) { @@ -394,6 +402,9 @@ public class CommercialController { Double unitPrice = null; if(json.get("unitPrice") != null){ unitPrice = (Double) json.get("unitPrice"); + if(ratio!=null){ + unitPrice = unitPrice * ratio; + } minPrice = unitPrice - unitPrice * 0.1; maxPrice = unitPrice + unitPrice * 0.1; @@ -409,6 +420,7 @@ public class CommercialController { Double lng = locObj.getDouble("lon"); Double lat = locObj.getDouble("lat"); List houseSelf = dealSampleService.querySampleByLocation(lng, lat, DataUtil.getDoubleRound(2, minPrice), DataUtil.getDoubleRound(2, maxPrice), "shop_rent", 30); + List dtos = createSample(houseSelf, "rent", ratio, lng, lat, unitPrice); if(dtos!=null && dtos.size()>5){