From 16a73b39bfb1ed9d58c6fb974b123b4a812b6381 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 9 Sep 2025 17:46:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=BF=E5=B7=9E=E5=B8=82=E6=85=A7=E5=90=88?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/core/util/DataUtil.java | 17 +++++++++++ .../java/com/fangjia/core/util/GeoUtils.java | 3 +- .../open/controllers/PropertyController.java | 30 ++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java index ffaeaceaf..117bb32e7 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java @@ -1876,7 +1876,24 @@ public class DataUtil { } + public static int generateRandomNumber(String address) { + // 使用地址的哈希值作为随机种子 + long seed = address.hashCode(); + Random random = new Random(seed); + // 生成一个初始随机数来决定范围 + int initialRandom = random.nextInt(); + + int result; + if (initialRandom > 0) { + // 生成2到10之间的随机数(包含2和10) + result = random.nextInt(9) + 2; // nextInt(9) 生成 0-8,+2 后得到 2-10 + } else { + // 生成-5到-2之间的随机数(包含-5和-2) + result = random.nextInt(4) - 5; // nextInt(4) 生成 0-3,-5 后得到 -5到-2 + } + return result; + } diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java index f3c007e17..858508625 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java @@ -318,7 +318,8 @@ public class GeoUtils { private static String getGaodeKey(String endpoint) { // 实现获取高德 API key 的逻辑 - return "8796b9dfb3889b57c38e2fff1b7e51bd"; +// return "8796b9dfb3889b57c38e2fff1b7e51bd"; + return "7516b8e9436de903eef85fb156cbc3cf";//临时2天 } public static void main(String[] args) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 12d374094..dce38133b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -1211,6 +1211,16 @@ public class PropertyController { evaluation.setAvgPrice(avgPrice); evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea())); } + if (StringUtils.isNotBlank(evaluation.getFromUserId())) { + // 1007839 广州市慧合信息科技有限公司 huihe_test 价格向上2%-10% 向下 2%-5% + if (evaluation.getFromUserId().equals("1007839")) { + int round = DataUtil.generateRandomNumber(district.getCity() + model.getAddress()); + int newAvgPrice = (int) (evaluation.getAvgPrice() + evaluation.getAvgPrice() * round / 100); + evaluation.setAvgPrice(newAvgPrice); + evaluation.setBigTotalPrice((long) (newAvgPrice * evaluation.getArea())); + } + } + } } catch (Exception ex) { LOGGER.error("调整面积不同面积价格异常{}", ex.getMessage()); @@ -1651,7 +1661,16 @@ public class PropertyController { } } - if (district == null) { + ApiUser apiUser = checkNewAuthorized(model.getToken()); + String userName = null; + if (apiUser != null) { + User user = userService.findById(apiUser.getId()); + if (user != null) { + userName = user.getUserName(); + } + } + + if (district == null && userName!=null && !userName.equals("huihe_test")) { //加上高德获取经纬度 和 根据经纬度估值 Map map = GeoUtils.parserByGaode(model.getCity(), model.getAddress()); if (map != null && map.containsKey("level") && GAODE_LEVEL.contains(map.get("level")) @@ -1668,6 +1687,15 @@ public class PropertyController { HashMap resultMap = new HashMap(); resultMap.put("avgPrice", json.getString("unitPrice")); resultMap.put("totalPrice", json.getString("totalPrice")); + + if (apiUser.getId() == 1007839) { + int round = DataUtil.generateRandomNumber(model.getCity() + model.getAddress()); + Long newAvgPrice = (Long) (json.getLong("unitPrice") + json.getLong("unitPrice") * round / 100); + resultMap.put("avgPrice", newAvgPrice.toString()); + double totalPrice = newAvgPrice * model.getSize(); + resultMap.put("totalPrice", String.valueOf((int)totalPrice)); + } + mav.setModel(BasicModel.buildOKModel().setResult(resultMap)); } else { mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));