Merge branch 'open_gj' into 'master'

新增估值系数

See merge request !359
This commit is contained in:
2022-07-28 09:34:26 +08:00
6 changed files with 197 additions and 9 deletions
@@ -0,0 +1,11 @@
package com.fangjia.dal.mongo.open.dao;
import com.fangjia.dal.MongoDao;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
/**
* @author shenjian
* @since 2022/7/27
*/
public interface EvaluateRatioDao extends MongoDao<EvaluateRatio> {
}
@@ -0,0 +1,13 @@
package com.fangjia.dal.mongo.open.dao.impl;
import com.fangjia.dal.MongoDaoImpl;
import com.fangjia.dal.mongo.open.dao.EvaluateRatioDao;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
/**
* @author shenjian
* @since 2022/7/27
*/
public class EvaluateRatioDaoImpl extends MongoDaoImpl<EvaluateRatio> implements EvaluateRatioDao {
}
@@ -0,0 +1,72 @@
package com.fangjia.dal.mongo.open.model;
import com.fangjia.dal.MongoEntity;
import javax.persistence.*;
/**
* ¹À¼ÛϵÊý
*
* @author shenjian
* @since 2022/7/27
*/
@Entity
@Table(name = "business.evaluate_ratio")
public class EvaluateRatio implements MongoEntity {
private static final long serialVersionUID = 5299813614465690722L;
private String id;
private String category;
private String city;
private String region;
private Double ratio;
@Id
@GeneratedValue
@Column(name = "_id", unique = true, nullable = false)
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
@Column(name = "category")
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Column(name = "city")
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Column(name = "region")
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
@Column(name = "ratio")
public Double getRatio() {
return ratio;
}
public void setRatio(Double ratio) {
this.ratio = ratio;
}
}
@@ -33,13 +33,13 @@ import com.fangjia.dal.*;
import com.fangjia.dal.mongo.model.*;
import com.fangjia.dal.mongo.open.model.CommunityBasePrice;
import com.fangjia.dal.mongo.open.model.CommunityPoi;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
import com.fangjia.dal.seawater.dao.SeawaterDao;
import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.open.dto.*;
import com.fangjia.service.district.*;
import com.fangjia.service.mongo.fangjia.*;
import com.fangjia.service.open.*;
import com.fangjia.service.open.impl.CommunityPoiServiceImpl;
import com.fangjia.service.util.DistrictScoreUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -193,6 +193,7 @@ public class PropertyController {
private DistrictRoomSqmetreRentService districtRoomSqmetreRentService;
private RentDealPriceService rentDealPriceService;
private EvaluateRatioService evaluateRatioService;
private static final int EVALUATE_SHOW_DETAIL = 1;
private static final Map<String, String> PROPERTY_TYPES = new HashMap<String, String>() {
@@ -1017,6 +1018,8 @@ public class PropertyController {
} catch (IllegalAccessException e) {
e.printStackTrace();
}
this.adjustPriceByRatio(district, evaluation);
}
// 调整面积不同面积价格
@@ -1042,7 +1045,7 @@ public class PropertyController {
}
}
} catch (Exception ex) {
LOGGER.error("调整面积不同面积价格异常{}", ex.getMessage());
}
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0
@@ -1128,6 +1131,41 @@ public class PropertyController {
}
}
/**
* 系数下调
*
* @param district
* @param evaluation
*/
private void adjustPriceByRatio(District district, Evaluation evaluation) {
try {
ApiUserCfg apiUserCfg_pt = apiUserCfgService.findByUserId(Long.valueOf(evaluation.getFromUserId()), ApiUserCfg.ApiUserCfgKey.PRICE_TYPE);
if (apiUserCfg_pt != null && apiUserCfg_pt.getCfgValue() != null) {
String priceType = apiUserCfg_pt.getCfgValue().toString();
// 评估价则系数调整
if (StringUtils.isNotBlank(priceType) && "evaluate".equals(priceType)) {
EvaluateRatio evaluateRatio = null;
if (StringUtils.isNotBlank(district.getRegion())) {
evaluateRatio = evaluateRatioService.findByCityAndRegion(district.getCity(), district.getRegion());
}
if (evaluateRatio == null) {
evaluateRatio = evaluateRatioService.findByCity(district.getCity());
}
if (evaluateRatio != null) {
// 系数添加
long totalPrice = evaluation.getBigTotalPrice();
totalPrice = (long) (totalPrice * (1 + evaluateRatio.getRatio()));
evaluation.setBigTotalPrice(totalPrice);
evaluation.setAvgPrice((int) (totalPrice / evaluation.getArea()));
}
}
}
} catch (Exception ex) {
LOGGER.error("系数下调异常{}", ex.getMessage());
}
}
static final Map<String, Double> CITY_CORRECTION_FACTOR = new HashMap<String, Double>();
static {
CITY_CORRECTION_FACTOR.put("上海", 0.02);
@@ -1216,6 +1254,9 @@ public class PropertyController {
mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData());
return mav;
}
this.adjustPriceByRatio(district, evaluation);
// 调整面积不同面积价格
try {
DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district));
@@ -1245,13 +1286,7 @@ public class PropertyController {
districtPriceMap.put("city", district.getCity());
districtPriceMap.put("district", district.getRegion());
districtPriceMap.put("name", district.getName());
long totalPrice = evaluation.getBigTotalPrice();
// 取消系数下调
// if(CITY_CORRECTION_FACTOR.containsKey(district.getCity())){
// totalPrice = (long)(totalPrice * (1 - CITY_CORRECTION_FACTOR.get(district.getCity())));
// evaluation.setBigTotalPrice(totalPrice);
// evaluation.setAvgPrice((int)(totalPrice/evaluation.getArea()));
// }
districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice());
districtPriceMap.put("unitPrice", evaluation.getAvgPrice());
// 新增置信度
@@ -5757,6 +5792,10 @@ public class PropertyController {
this.rentDealPriceService = rentDealPriceService;
}
public void setEvaluateRatioService(EvaluateRatioService evaluateRatioService) {
this.evaluateRatioService = evaluateRatioService;
}
public void setCommunityPoiService(CommunityPoiService communityPoiService) {
this.communityPoiService = communityPoiService;
}
@@ -0,0 +1,14 @@
package com.fangjia.service.open;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
/**
* @author shenjian
* @since 2022/7/27
*/
public interface EvaluateRatioService {
EvaluateRatio findByCityAndRegion(String city, String region);
EvaluateRatio findByCity(String city);
}
@@ -0,0 +1,39 @@
package com.fangjia.service.open.impl;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.mongo.open.dao.EvaluateRatioDao;
import com.fangjia.dal.mongo.open.model.EvaluateRatio;
import com.fangjia.service.open.EvaluateRatioService;
import java.util.ArrayList;
import java.util.List;
/**
* @author shenjian
* @since 2022/7/27
*/
public class EvaluateRatioServiceImpl implements EvaluateRatioService {
private EvaluateRatioDao evaluateRatioDao;
@Override
public EvaluateRatio findByCityAndRegion(String city, String region) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", "region"));
params.add(new QueryParam("city", city));
params.add(new QueryParam("region", region));
return evaluateRatioDao.findFirstByParams(params);
}
@Override
public EvaluateRatio findByCity(String city) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", "city"));
params.add(new QueryParam("city", city));
return evaluateRatioDao.findFirstByParams(params);
}
public void setEvaluateRatioDao(EvaluateRatioDao evaluateRatioDao) {
this.evaluateRatioDao = evaluateRatioDao;
}
}