添加案例价格系数调整
This commit is contained in:
+45
-12
@@ -40,6 +40,7 @@ public class CommercialController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPSELL_EVALUATE);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
@@ -51,7 +52,7 @@ public class CommercialController {
|
||||
resultMap.put("totalPrice", totalPrice);
|
||||
|
||||
if (model.getShowSample()!=null && model.getShowSample()==1 && json.containsKey("case")) {
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell");
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell", ratio);
|
||||
resultMap.put("result", dtos);
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ public class CommercialController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
public Object shopSellSampleAction(CommercialModel model) {
|
||||
public Object shopSellSampleAction(CommercialModel model, HttpServletRequest request) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
@@ -74,12 +75,13 @@ public class CommercialController {
|
||||
if(mav.model()!=null){
|
||||
return mav;
|
||||
}
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPSELL_EVALUATE);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
|
||||
if (json.containsKey("case")) {
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell");
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "sell", ratio);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(dtos));
|
||||
if(dtos.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
@@ -110,6 +112,7 @@ public class CommercialController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPRENT_EVALUATE);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
@@ -122,7 +125,7 @@ public class CommercialController {
|
||||
|
||||
|
||||
if (model.getShowSample()!=null && model.getShowSample()==1 && json.containsKey("case")) {
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent");
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent", ratio);
|
||||
resultMap.put("result", dtos);
|
||||
}
|
||||
|
||||
@@ -154,7 +157,7 @@ public class CommercialController {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
private List<BusinessCaseDto> createBusiness(JSONArray cases, String cat){
|
||||
private List<BusinessCaseDto> createBusiness(JSONArray cases, String cat, Double ratio){
|
||||
if(cases != null && cases.size()>0){
|
||||
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
|
||||
for(int i=0 ;i < cases.size(); i++){
|
||||
@@ -164,14 +167,28 @@ public class CommercialController {
|
||||
dto.setDistrict(jsonObject.getString("district"));
|
||||
dto.setName(jsonObject.getString("name"));
|
||||
dto.setLocation(jsonObject.getString("location"));
|
||||
if(cat.equals("rent")){
|
||||
Double dayPrice = jsonObject.getInt("totalPrice")/(jsonObject.getDouble("size")*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
|
||||
if(ratio != null){
|
||||
Integer totalPrice = new BigDecimal(jsonObject.getInt("totalPrice")* ratio).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
if(cat.equals("rent")){
|
||||
Double dayPrice = totalPrice/(jsonObject.getDouble("size")*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
Integer avgPrie = (int)(totalPrice/jsonObject.getDouble("size"));
|
||||
dto.setUnitPrice(avgPrie);
|
||||
}
|
||||
dto.setTotalPrice(totalPrice);
|
||||
}else{
|
||||
dto.setUnitPrice(jsonObject.getInt("unitPrice"));
|
||||
if(cat.equals("rent")){
|
||||
Double dayPrice = jsonObject.getInt("totalPrice")/(jsonObject.getDouble("size")*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
dto.setUnitPrice(jsonObject.getInt("unitPrice"));
|
||||
}
|
||||
dto.setTotalPrice(jsonObject.getInt("totalPrice"));
|
||||
}
|
||||
|
||||
dto.setTotalPrice(jsonObject.getInt("totalPrice"));
|
||||
|
||||
dto.setDistance(jsonObject.getInt("distance"));
|
||||
|
||||
dto.setSize(jsonObject.getDouble("size"));
|
||||
@@ -191,7 +208,7 @@ public class CommercialController {
|
||||
}
|
||||
|
||||
|
||||
public Object shopRentSampleAction(CommercialModel model) {
|
||||
public Object shopRentSampleAction(CommercialModel model, HttpServletRequest request) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
@@ -199,12 +216,13 @@ public class CommercialController {
|
||||
if(mav.model()!=null){
|
||||
return mav;
|
||||
}
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
JSONObject json = locationEvaluateApi(model, AvmUrls.SHOPRENT_EVALUATE);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
|
||||
if (json.containsKey("case")) {
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent");
|
||||
List<BusinessCaseDto> dtos = createBusiness((JSONArray) json.get("case"), "rent", ratio);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(dtos));
|
||||
if(dtos.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
@@ -334,6 +352,21 @@ public class CommercialController {
|
||||
return json;
|
||||
}
|
||||
|
||||
private Double getUserPriceRatio(HttpServletRequest request){
|
||||
Double ratio = null;
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
String userId = String.valueOf(authenticationBean.apiUser.getId());
|
||||
ApiUserCfg apiUserCfg = apiUserCfgService.findByUserId(Long.valueOf(userId), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
|
||||
if(apiUserCfg != null && apiUserCfg.getCfgValue() != null && apiUserCfg.getCfgValue() instanceof Double){
|
||||
Double rate = (Double)apiUserCfg.getCfgValue();
|
||||
ratio = rate;
|
||||
}
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) {
|
||||
this.apiUserCfgService = apiUserCfgService;
|
||||
}
|
||||
|
||||
+39
-7
@@ -727,6 +727,7 @@ public class OfficeController {
|
||||
}
|
||||
/* 先到CPDB库中查找写字楼 */
|
||||
District district = null;
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
|
||||
if(StringUtils.isNotBlank(model.getDistrict()) && StringUtils.isNotBlank(model.getName())) {
|
||||
district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office");
|
||||
@@ -774,7 +775,7 @@ public class OfficeController {
|
||||
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_rent", district);
|
||||
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_rent", district, ratio);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
|
||||
if(createBusiness.size()<5){
|
||||
BasicModel.markNoDataRequest();
|
||||
@@ -799,6 +800,23 @@ public class OfficeController {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Double getUserPriceRatio(HttpServletRequest request){
|
||||
Double ratio = null;
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
String userId = String.valueOf(authenticationBean.apiUser.getId());
|
||||
ApiUserCfg apiUserCfg = apiUserCfgService.findByUserId(Long.valueOf(userId), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
|
||||
if(apiUserCfg != null && apiUserCfg.getCfgValue() != null && apiUserCfg.getCfgValue() instanceof Double){
|
||||
Double rate = (Double)apiUserCfg.getCfgValue();
|
||||
ratio = rate;
|
||||
}
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过EvaluationModel组装Evaluation实体
|
||||
*
|
||||
@@ -967,7 +985,7 @@ public class OfficeController {
|
||||
}
|
||||
};
|
||||
|
||||
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district){
|
||||
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district, Double ratio){
|
||||
if(seawaterDtos != null && seawaterDtos.size()>0){
|
||||
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
|
||||
for(SeawaterDto house : seawaterDtos){
|
||||
@@ -976,16 +994,30 @@ public class OfficeController {
|
||||
dto.setDistrict(house.getDistrict());
|
||||
dto.setName(house.getName());
|
||||
dto.setLocation(house.getLocation());
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getArea()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
if(ratio != null) {
|
||||
Integer totalPrice = (int) (house.getTotalPrice() * ratio);
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = totalPrice/(house.getArea()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
Integer avgPrie = (int)(totalPrice/house.getArea());
|
||||
dto.setUnitPrice(avgPrie);
|
||||
}
|
||||
dto.setTotalPrice(totalPrice);
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getArea()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(house.getEstateType())){
|
||||
dto.setType(house.getEstateType());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
|
||||
if(StringUtils.isNotBlank(house.getLocation()) && district.getLat()!=null){
|
||||
String[] arrs = house.getLocation().split(",");
|
||||
double distance = GeoUtils.calculateDistance(district.getLng()/10000000000.0, district.getLat()/10000000000.0, Double.valueOf(arrs[0]), Double.valueOf(arrs[1]));
|
||||
|
||||
+39
-7
@@ -440,6 +440,7 @@ public class OfficeSellController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
/* 先到CPDB库中查找写字楼 */
|
||||
District district = null;
|
||||
|
||||
@@ -490,7 +491,7 @@ public class OfficeSellController {
|
||||
OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request));
|
||||
if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) {
|
||||
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_sell", district);
|
||||
List<BusinessCaseDto> createBusiness = createBusiness(evaluation.getSeawater(), "office_sell", district, ratio);
|
||||
// districtPriceMap.put("result", createBusiness);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(createBusiness));
|
||||
if(createBusiness.size()<5){
|
||||
@@ -673,7 +674,7 @@ public class OfficeSellController {
|
||||
}
|
||||
|
||||
|
||||
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district){
|
||||
private List<BusinessCaseDto> createBusiness(List<SeawaterDto> seawaterDtos, String cat, District district, Double ratio){
|
||||
if(seawaterDtos != null && seawaterDtos.size()>0){
|
||||
List<BusinessCaseDto> dtos = new ArrayList<BusinessCaseDto>();
|
||||
for(SeawaterDto house : seawaterDtos){
|
||||
@@ -682,16 +683,31 @@ public class OfficeSellController {
|
||||
dto.setDistrict(house.getDistrict());
|
||||
dto.setName(house.getName());
|
||||
dto.setLocation(house.getLocation());
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getUnitPrice()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
if(ratio != null){
|
||||
Integer totalPrice = (int) (house.getTotalPrice()*ratio);
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = totalPrice/(house.getArea()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
Integer avgPrie = (int)(totalPrice/house.getArea());
|
||||
dto.setUnitPrice(avgPrie);
|
||||
}
|
||||
dto.setTotalPrice(totalPrice);
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
if(cat.equals("office_rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(house.getArea()*30);
|
||||
dto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}else{
|
||||
dto.setUnitPrice(house.getUnitPrice());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(house.getEstateType())){
|
||||
dto.setType(house.getEstateType());
|
||||
}
|
||||
dto.setTotalPrice(house.getTotalPrice());
|
||||
|
||||
if(StringUtils.isNotBlank(house.getLocation()) && district.getLat()!=null){
|
||||
String[] arrs = house.getLocation().split(",");
|
||||
double distance = GeoUtils.calculateDistance(district.getLng()/10000000000.0, district.getLat()/10000000000.0, Double.valueOf(arrs[0]), Double.valueOf(arrs[1]));
|
||||
@@ -714,6 +730,22 @@ public class OfficeSellController {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Double getUserPriceRatio(HttpServletRequest request){
|
||||
Double ratio = null;
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
String userId = String.valueOf(authenticationBean.apiUser.getId());
|
||||
ApiUserCfg apiUserCfg = apiUserCfgService.findByUserId(Long.valueOf(userId), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
|
||||
if(apiUserCfg != null && apiUserCfg.getCfgValue() != null && apiUserCfg.getCfgValue() instanceof Double){
|
||||
Double rate = (Double)apiUserCfg.getCfgValue();
|
||||
ratio = rate;
|
||||
}
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public void setOfficeService(OfficeService officeService) {
|
||||
this.officeService = officeService;
|
||||
}
|
||||
|
||||
+71
-18
@@ -1744,8 +1744,10 @@ public class PropertyController {
|
||||
json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8");
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
HashMap<String, Long> resultMap = new HashMap<String, Long>();
|
||||
resultMap.put("avgPrice", Long.valueOf(json.getString("unitPrice")));
|
||||
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
|
||||
Long totalPrice = getRatioPrice(request, Long.valueOf(json.getString("totalPrice")));
|
||||
|
||||
resultMap.put("avgPrice", new BigDecimal(totalPrice/model.getSize()).setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
||||
resultMap.put("totalPrice", totalPrice);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
@@ -1770,6 +1772,41 @@ public class PropertyController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Long getRatioPrice(HttpServletRequest request, Long totalPrice){
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
String userId = String.valueOf(authenticationBean.apiUser.getId());
|
||||
ApiUserCfg apiUserCfg = apiUserCfgService.findByUserId(Long.valueOf(userId), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
|
||||
if(apiUserCfg != null && apiUserCfg.getCfgValue() != null && apiUserCfg.getCfgValue() instanceof Double){
|
||||
Double rate = (Double)apiUserCfg.getCfgValue();
|
||||
if(rate != 0){
|
||||
totalPrice = (long)(totalPrice * rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
|
||||
private Double getUserPriceRatio(HttpServletRequest request){
|
||||
Double ratio = null;
|
||||
AuthenticationBean authenticationBean = (AuthenticationBean) request
|
||||
.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
|
||||
if (authenticationBean != null && authenticationBean.apiUser != null) {
|
||||
String userId = String.valueOf(authenticationBean.apiUser.getId());
|
||||
ApiUserCfg apiUserCfg = apiUserCfgService.findByUserId(Long.valueOf(userId), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
|
||||
if(apiUserCfg != null && apiUserCfg.getCfgValue() != null && apiUserCfg.getCfgValue() instanceof Double){
|
||||
Double rate = (Double)apiUserCfg.getCfgValue();
|
||||
ratio = rate;
|
||||
}
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
|
||||
public Object evaluate2Action(PropertyEvaluationModel model, HttpServletRequest request)
|
||||
throws NumberFormatException, IllegalAccessException {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
@@ -6195,6 +6232,7 @@ public class PropertyController {
|
||||
model.setRadius(1000);
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
|
||||
if(district != null){
|
||||
if(model.getMinPrice() == null){
|
||||
@@ -6232,7 +6270,7 @@ public class PropertyController {
|
||||
//查自身样本
|
||||
List<Seawater> houseSelf = houseService.findSelfHouseByParams(district, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
for(HouseCaseDto house : caseDtos){
|
||||
house.setDistance(0);
|
||||
}
|
||||
@@ -6251,7 +6289,7 @@ public class PropertyController {
|
||||
newDist.setEstateType2(estateType);
|
||||
houseSelf = houseService.findSelfHouseByParams(newDist, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
@@ -6268,7 +6306,7 @@ public class PropertyController {
|
||||
newDist.setEstateType2(estateType);
|
||||
houseSelf = houseService.findSelfHouseByParams(newDist, "sell", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), null, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
@@ -6333,7 +6371,7 @@ public class PropertyController {
|
||||
houseAround = houseService.findArroundHouseByParams("sell", lng, lat, Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager, model.getRadius());
|
||||
}
|
||||
if(houseAround != null && houseAround.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource(), ratio);
|
||||
}
|
||||
}
|
||||
if(caseDtos.size()>pager.getPageSize()){
|
||||
@@ -6423,6 +6461,7 @@ public class PropertyController {
|
||||
model.setRadius(1000);
|
||||
}
|
||||
|
||||
Double ratio = getUserPriceRatio(request);
|
||||
|
||||
if(district != null){
|
||||
if(model.getMinPrice() == null){
|
||||
@@ -6444,12 +6483,11 @@ public class PropertyController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(caseDtos.size() < pager.getPageSize()){
|
||||
//查自身样本
|
||||
List<Seawater> houseSelf = houseService.findSelfHouseByParams(district, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
for(HouseCaseDto house : caseDtos){
|
||||
house.setDistance(0);
|
||||
}
|
||||
@@ -6468,7 +6506,7 @@ public class PropertyController {
|
||||
newDist.setEstateType2(estateType);
|
||||
houseSelf = houseService.findSelfHouseByParams(newDist, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
@@ -6487,7 +6525,7 @@ public class PropertyController {
|
||||
newDist.setEstateType2(estateType);
|
||||
houseSelf = houseService.findSelfHouseByParams(newDist, "rent", Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), null, pager);
|
||||
if(houseSelf!=null && houseSelf.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseSelf, model.getShowSource(), ratio);
|
||||
if(caseDtos.size() == pager.getPageSize()){
|
||||
caseDtos = caseDtos.subList(0, caseDtos.size()-1);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(caseDtos));
|
||||
@@ -6529,7 +6567,7 @@ public class PropertyController {
|
||||
houseAround = houseService.findArroundHouseByParams("rent", lng, lat, Integer.parseInt(startDate), Integer.parseInt(endDate), model.getMinPrice(), model.getMaxPrice(), estateType, pager, model.getRadius());
|
||||
}
|
||||
if(houseAround != null && houseAround.size()>0){
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource());
|
||||
caseDtos = createHouseCase(caseDtos, houseAround, model.getShowSource(), ratio);
|
||||
}
|
||||
}
|
||||
if(caseDtos.size()>pager.getPageSize()){
|
||||
@@ -6580,7 +6618,7 @@ public class PropertyController {
|
||||
}
|
||||
|
||||
|
||||
private List<HouseCaseDto> createHouseCase(List<HouseCaseDto> caseDtos, List<Seawater> houses, Integer showSource){
|
||||
private List<HouseCaseDto> createHouseCase(List<HouseCaseDto> caseDtos, List<Seawater> houses, Integer showSource, Double ratio){
|
||||
if (houses != null && !houses.isEmpty()) {
|
||||
Set<String> seenIds = new HashSet<String>();
|
||||
Iterator<Seawater> iterator = houses.iterator();
|
||||
@@ -6604,13 +6642,28 @@ public class PropertyController {
|
||||
caseDto.setDistrict(house.getRegion());
|
||||
caseDto.setName(house.getDistrictName());
|
||||
caseDto.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
|
||||
if(house.getCategory().equals("sell")){
|
||||
caseDto.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
|
||||
}else if(house.getCategory().equals("rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(30*house.getArea());
|
||||
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
|
||||
if(house.getTotalPrice()!=null){
|
||||
if(ratio!=null){
|
||||
Integer totalPrice = new BigDecimal(house.getTotalPrice() * ratio).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
caseDto.setTotalPrice(totalPrice);
|
||||
if(house.getCategory().equals("sell")){
|
||||
caseDto.setUnitPrice(new BigDecimal(totalPrice/house.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue());
|
||||
}else if(house.getCategory().equals("rent")){
|
||||
// Double dayPrice = house.getTotalPrice()/(30*house.getArea());
|
||||
Double dayPrice = totalPrice/(30*house.getArea());
|
||||
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}
|
||||
}else{
|
||||
caseDto.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
if(house.getCategory().equals("sell")){
|
||||
caseDto.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
|
||||
}else if(house.getCategory().equals("rent")){
|
||||
Double dayPrice = house.getTotalPrice()/(30*house.getArea());
|
||||
caseDto.setUnitPrice(DataUtil.getDoubleRound(2, dayPrice));
|
||||
}
|
||||
}
|
||||
}
|
||||
caseDto.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
caseDto.setDirection(house.getDirection());
|
||||
caseDto.setDecoration(house.getFitment());
|
||||
caseDto.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
|
||||
|
||||
Reference in New Issue
Block a user