|
|
@@ -8,6 +8,9 @@ import com.ljq.house.biz.dao.*;
|
|
|
import com.ljq.house.biz.model.*;
|
|
|
import com.ljq.house.common.enums.ResultCodeEnum;
|
|
|
import com.ljq.house.common.exception.CommonBaseException;
|
|
|
+import com.ljq.house.common.utils.DataUtils;
|
|
|
+import com.ljq.house.common.utils.HttpClientUtil;
|
|
|
+import com.ljq.house.common.utils.SHAUtils;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -15,10 +18,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author abnerhou
|
|
|
@@ -30,7 +30,7 @@ import java.util.Map;
|
|
|
public class HouseHelperService {
|
|
|
|
|
|
@Autowired
|
|
|
- private TmHouseDao tmHouseDao;
|
|
|
+ private TmEstateDao tmEstateDao;
|
|
|
|
|
|
@Autowired
|
|
|
private TmUserDao tmUserDao;
|
|
|
@@ -42,13 +42,16 @@ public class HouseHelperService {
|
|
|
private TmAgencyDao tmAgencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private TmHouseDao tmHouseDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private TmHouseAgencyRelationDao tmHouseAgencyRelationDao;
|
|
|
|
|
|
public Map<String ,Object> getHouseInfoByHouse(TmHouse tmHouse , String userId, String roomId , String type , String callBackUrl){
|
|
|
- QueryWrapper<TmHouse> estateQueryWrapper = new QueryWrapper<>();
|
|
|
+ QueryWrapper<TmEstate> estateQueryWrapper = new QueryWrapper<>();
|
|
|
estateQueryWrapper.eq("estate_id" , tmHouse.getEstateId());
|
|
|
estateQueryWrapper.last("limit 1");
|
|
|
- TmHouse tmEstate = tmHouseDao.selectOne(estateQueryWrapper);
|
|
|
+ TmEstate tmEstate = tmEstateDao.selectOne(estateQueryWrapper);
|
|
|
|
|
|
QueryWrapper<TmHouseAgencyRelation> agencyRelationQuery = new QueryWrapper<>();
|
|
|
agencyRelationQuery.eq("house_id" , tmHouse.getHouseId());
|
|
|
@@ -87,7 +90,7 @@ public class HouseHelperService {
|
|
|
houseQueryWrapper.ne("house_id" , tmHouse.getHouseId());
|
|
|
houseQueryWrapper.eq("enable" ,1);
|
|
|
if(StringUtils.isNoneBlank(tmHouse.getHouseType())){
|
|
|
- houseQueryWrapper.like("house_type" , tmHouse.getHouseType());
|
|
|
+ houseQueryWrapper.like("house_type" , tmHouse.getHouseType());
|
|
|
}
|
|
|
if(null != tmHouse.getPrice()){
|
|
|
if(tmHouse.getPrice().compareTo(new BigDecimal(500000)) > 0){
|
|
|
@@ -142,6 +145,24 @@ public class HouseHelperService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public List<Map<String , Object>> getOneLevelAgencyRecHouseInfo(TmHouse tmHouse , String userId, String roomId , String type , String callBackUrl){
|
|
|
+ List<TmHouse> recommendHouseList = getAgencyHouseByHouseWithoutSelf(tmHouse);
|
|
|
+ List<Map<String , Object>> recommendHouseInfoList = formatOneLevelAgentRecommendHouse(recommendHouseList , userId , roomId , type, callBackUrl);
|
|
|
+ return recommendHouseInfoList;
|
|
|
+ }
|
|
|
+ public List<Map<String , Object>> formatOneLevelAgentRecommendHouse(List<TmHouse> recommendHouseList , String userId, String roomId , String type , String callBackUrl){
|
|
|
+ List<Map<String , Object>> recommendHouseInfoList = new ArrayList<>();
|
|
|
+ if(!CollectionUtils.isEmpty(recommendHouseList)) {
|
|
|
+ for (TmHouse house : recommendHouseList) {
|
|
|
+ Map<String, Object> houseMap = getHouseInfoByHouse(house, userId, roomId, type, callBackUrl);
|
|
|
+ if (!CollectionUtils.isEmpty(houseMap)) {
|
|
|
+ recommendHouseInfoList.add(houseMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return recommendHouseInfoList;
|
|
|
+ }
|
|
|
+
|
|
|
public List<Map<String , Object>> formatAgentRecommendHouseWithRecommend(List<TmHouse> recommendHouseList , String userId, String roomId , String type , String callBackUrl){
|
|
|
List<Map<String , Object>> recommendHouseInfoList = new ArrayList<>();
|
|
|
if(!CollectionUtils.isEmpty(recommendHouseList)){
|
|
|
@@ -203,7 +224,7 @@ public class HouseHelperService {
|
|
|
}
|
|
|
|
|
|
public Map<String , Object> assembleOpenApiData(TmHouse tmHouse , TmAgency tmAgency ,
|
|
|
- TmUser tmUser , TmHouse tmEstate){
|
|
|
+ TmUser tmUser , TmEstate tmEstate){
|
|
|
Map<String , Object> result = new HashMap<>();
|
|
|
if(null != tmHouse){
|
|
|
result.put("houseId" , tmHouse.getHouseId());
|
|
|
@@ -216,22 +237,38 @@ public class HouseHelperService {
|
|
|
//TODO这里应该加载楼盘上的
|
|
|
result.put("estateReferenceAveragePrice" , tmHouse.getUnitPrice());
|
|
|
result.put("houseTypeImages" , tmHouse.getHouseTypeImages());
|
|
|
+ result.put("enable" , tmHouse.getEnable());
|
|
|
+ result.put("wxAqrCode" , tmHouse.getWxAqrCode());
|
|
|
}
|
|
|
|
|
|
if(null != tmEstate){
|
|
|
result.put("estateId" , tmEstate.getEstateId());
|
|
|
+ result.put("earlistHandOver" , tmEstate.getEarliestHandOver());
|
|
|
+ result.put("onSaleTime" , tmEstate.getOnSaleTime());
|
|
|
+ result.put("estateDeveloper" , tmEstate.getDeveloper());
|
|
|
+ result.put("estatePeriodInt" , tmEstate.getPeriod());
|
|
|
result.put("estateAddress" , tmEstate.getAddress());
|
|
|
result.put("estateIntroduceVideo" , tmEstate.getIntroduceVideo());
|
|
|
result.put("estateImages" , tmEstate.getAdditionsImages());
|
|
|
+ result.put("estateLongitude" , tmEstate.getLatitude());
|
|
|
+ result.put("estateLatitude" , tmEstate.getLongitude());
|
|
|
result.put("estateVideoCoverImage" , tmEstate.getVideoCoverImage());
|
|
|
result.put("estateCoverImage" , tmEstate.getCoverImage());
|
|
|
+ result.put("estateIntroduceVideoDesc" , tmEstate.getIntroduceVideoDesc());
|
|
|
}
|
|
|
|
|
|
if(null != tmAgency){
|
|
|
-
|
|
|
- result.put("agencyAvatar" , tmAgency.getAvatar());
|
|
|
+ result.put("agencyId" , tmAgency.getAgencyUserId());
|
|
|
+ result.put("agencyName" , tmAgency.getName());
|
|
|
+ result.put("agencyStore" , tmAgency.getStore());
|
|
|
+ result.put("agencyTag" , tmAgency.getTag());
|
|
|
+ result.put("agnencyPhone" , tmAgency.getPhone());
|
|
|
+ result.put("agencyHalfYearVolume" , tmAgency.getVolumeHalfYear());
|
|
|
+ result.put("agencyDealAverage" , tmAgency.getDealAveragePeriod());
|
|
|
+ result.put("agencyRecentRecommend" , tmAgency.getRecentRecommendVrs());
|
|
|
result.put("agencyAvatar" , tmAgency.getAvatar());
|
|
|
result.put("agencyPassImage" , tmAgency.getWorkPassImage());
|
|
|
+ result.put("agencyTagImage" , tmAgency.getTagImage());
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -244,5 +281,55 @@ public class HouseHelperService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public String sendDataToOpenApi(String houseId , String fdvrhouseCallBackUrl ,
|
|
|
+ String userId ,String roomId , String type ,
|
|
|
+ String fdAppId ,String fdAppSecret ,String apiVrHouseHost){
|
|
|
+ if(StringUtils.isBlank(houseId)){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
+ }
|
|
|
+ QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("house_id" , houseId);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ TmHouse dbHouse = tmHouseDao.selectOne(queryWrapper);
|
|
|
+ if(null == dbHouse){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "房源信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ String callBackUrl = fdvrhouseCallBackUrl;
|
|
|
+ Map<String , Object> data = getHouseInfoByHouse(dbHouse , userId , roomId , type , callBackUrl);
|
|
|
+
|
|
|
+ //这里只包一层推荐房源,推荐房源里面不再插入推荐房源,由api平台建立房源和推荐房源的关联关系
|
|
|
+ List<Map<String , Object>> recommends = getOneLevelAgencyRecHouseInfo(dbHouse , userId , roomId , type ,callBackUrl);
|
|
|
+ data.put("recommend_houses" , JSONObject.toJSONString(recommends));
|
|
|
+ Long timeStamp = System.currentTimeMillis();
|
|
|
+
|
|
|
+ //token=app_id+app_secret+timestamp
|
|
|
+ String token = SHAUtils.getSHA256(fdAppId + fdAppSecret + timeStamp.toString());
|
|
|
+ String dataStr = JSONObject.toJSONString(data);
|
|
|
+ Map<String , Object> dataMap = JSONObject.parseObject(dataStr);
|
|
|
+
|
|
|
+ Map<String , Object> sortMap = DataUtils.sortMapByKey(dataMap);
|
|
|
+ String sortMapStr = JSONObject.toJSONString(sortMap);
|
|
|
+ log.info("待加密的数据={}" ,sortMapStr + fdAppSecret + timeStamp);
|
|
|
+
|
|
|
+ String sign = SHAUtils.getSHA256(sortMapStr + fdAppSecret + timeStamp);
|
|
|
+
|
|
|
+ String openApiurl = apiVrHouseHost + "/api/vrhouse/format?appId=" + fdAppId + "&sign=" + sign + "&token=" + token + "&timeStamp=" + timeStamp;
|
|
|
+ log.info("请求openApi的url={}", openApiurl);
|
|
|
+ String apiResultStr = HttpClientUtil.doPostJson(openApiurl , dataStr);
|
|
|
+ return apiResultStr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getHouseInfoFromOpenApi(TmHouse tmHouse , String openApiHost){
|
|
|
+
|
|
|
+ if(null != tmHouse && StringUtils.isNotBlank(tmHouse.getSceneNum())){
|
|
|
+ if(StringUtils.isNotBlank(openApiHost)){
|
|
|
+ String url = openApiHost + "/vrhouse/4dage/getHouseInfo?scene_code=" + tmHouse.getSceneNum();
|
|
|
+ url += "&user_id=&terminal_type";
|
|
|
+ return HttpClientUtil.doGet(url);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
|
|
|
}
|