|
@@ -1,629 +0,0 @@
|
|
|
-package com.ljq.house.app.controller;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-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.service.HouseHelperService;
|
|
|
-import com.ljq.house.common.threadPools.service.SyncWxSubscribeServiceImpl;
|
|
|
-import com.ljq.house.common.utils.DataUtils;
|
|
|
-import com.ljq.house.common.utils.HttpClientUtil;
|
|
|
-import com.ljq.house.common.utils.SHAUtils;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.logging.log4j.core.tools.picocli.CommandLine;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author abnerhou
|
|
|
- * @date 2020/4/23 20:46
|
|
|
- * @desciption
|
|
|
- */
|
|
|
-@Api(description = "房源相关接口")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/app/house")
|
|
|
-@Log4j2
|
|
|
-public class AppTmHouseController {
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseDao tmHouseDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseAgencyRelationDao houseAgencyRelationDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmAgencyDao tmAgencyDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmUserDao tmUserDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmEstateDao tmEstateDao;
|
|
|
- @Autowired
|
|
|
- private TmHouseAgencyRelationDao tmHouseAgencyRelationDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseAgencyRelationDao agencyRelationDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SyncWxSubscribeServiceImpl wxSubscribeService;
|
|
|
-
|
|
|
- @Value("${vr_redirect_link}")
|
|
|
- private String vrRedirectLink;
|
|
|
-
|
|
|
- @Value("${4dkankan.vr.house.host}")
|
|
|
- private String fdvrhouseCallBackUrl;
|
|
|
-
|
|
|
- @Value("${4dkankan.api.vr.house.host}")
|
|
|
- private String apiVrHouseHost;
|
|
|
-
|
|
|
- @Value("${4dkankan.api.app.id}")
|
|
|
- private String fdAppId;
|
|
|
-
|
|
|
- @Value("${4dkankan.api.app.secret}")
|
|
|
- private String fdAppSecret;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private HouseHelperService houseHelperService;
|
|
|
- /**
|
|
|
- * 根据房源id拉取房源详情
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Result getHousesDetailById(HttpServletRequest req) {
|
|
|
- String houseId = req.getParameter("house_id");
|
|
|
- //TODO:这里理论上要selectforupdate上个锁,防止多并发数据不一致
|
|
|
- TmHouse tmHouse = tmHouseDao.selectHouseById(houseId);
|
|
|
- if(null != tmHouse){
|
|
|
- //更新浏览量字段
|
|
|
- UpdateWrapper<TmHouse> updateWrapper = new UpdateWrapper<>();
|
|
|
- TmHouse updateHouse = new TmHouse();
|
|
|
- if(null == tmHouse.getQueryNum()){
|
|
|
- tmHouse.setQueryNum(0l);
|
|
|
- }
|
|
|
- updateHouse.setQueryNum(tmHouse.getQueryNum() + 1);
|
|
|
- updateWrapper.eq("house_id" , tmHouse.getHouseId());
|
|
|
- tmHouseDao.update(updateHouse , updateWrapper);
|
|
|
- }
|
|
|
- return Result.success(tmHouse);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据四维看看的场景码获取绑定的经纪人
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/getAgencyId", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getHouseAgencyById(HttpServletRequest req) {
|
|
|
- String sceneCode = req.getParameter("scene_code");
|
|
|
- QueryWrapper<TmHouseAgencyRelation> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("vr_scene" , sceneCode);
|
|
|
- queryWrapper.eq("is_valid" , 1);
|
|
|
- //TODO:这里默认只选取第一个,如果出现一个房源关联多个经纪人的情况,这里需要修改
|
|
|
- queryWrapper.last("limit 1");
|
|
|
- TmHouseAgencyRelation houseAgencyRelation = houseAgencyRelationDao.selectOne(queryWrapper);
|
|
|
- TmAgency tmAgency = tmAgencyDao.selectTmAgencyById(houseAgencyRelation.getAgencyUserId());
|
|
|
- return Result.success("成功", tmAgency);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据场景码获取房源详情
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/getByScene", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getHouseByScene(HttpServletRequest req) {
|
|
|
- String sceneCode = req.getParameter("scene_code");
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("scene_num", sceneCode);
|
|
|
- queryWrapper.last("limit 1");
|
|
|
- TmHouse tmHouse = tmHouseDao.selectOne(queryWrapper);
|
|
|
- if(null != tmHouse && 1 != tmHouse.getEnable()){
|
|
|
- return Result.failure("该场景下绑定的房源已经被删除");
|
|
|
- }
|
|
|
- return Result.success("成功", tmHouse);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据场景码获取房源详情
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "根据楼盘id获取楼盘详情")
|
|
|
- @GetMapping(value = "/getEstateDetail")
|
|
|
- @ResponseBody
|
|
|
- public Result getHouseByScene(@RequestParam(name = "estate_id") String estateId) {
|
|
|
- if(StringUtils.isBlank(estateId)){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- QueryWrapper<TmEstate> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("estate_id", estateId);
|
|
|
- queryWrapper.last("limit 1");
|
|
|
- TmEstate tmEstate = tmEstateDao.selectOne(queryWrapper);
|
|
|
- if(null != tmEstate && 1 != tmEstate.getEnable()){
|
|
|
- return Result.failure("该楼盘已经被删除");
|
|
|
- }
|
|
|
- return null != tmEstate ? Result.success("获取楼盘详情成功", tmEstate) : Result.failure("获取楼盘详情失败");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 推送消息给经纪人
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/subscribe", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result subscribeMsg(HttpServletRequest req) {
|
|
|
- String link = req.getParameter("link");
|
|
|
- String agencyUserId = req.getParameter("agency_user_id");
|
|
|
- String userId = req.getParameter("user_id");
|
|
|
- String sceneCode = req.getParameter("scene_code");
|
|
|
- if (!StringUtils.isNoneBlank(userId, sceneCode)) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D018);
|
|
|
- }
|
|
|
- TmAgency tmAgency = tmAgencyDao.selectTmAgencyById(agencyUserId);
|
|
|
- TmUser tmUser = tmUserDao.selectTmUsers(userId);
|
|
|
- if (null == tmAgency || tmAgency.getEnable() != 1 || null == tmUser) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D018);
|
|
|
- }
|
|
|
-
|
|
|
- if (!StringUtils.isNoneBlank(tmAgency.getName(), tmUser.getName())) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D020);
|
|
|
- }
|
|
|
- List<TmHouseAgencyRelation> relationList = houseAgencyRelationDao.selectAgencyIdByScene(sceneCode);
|
|
|
- TmHouse tmHouse = new TmHouse();
|
|
|
- if (!CollectionUtils.isEmpty(relationList)) {
|
|
|
- tmHouse = tmHouseDao.selectHouseById(relationList.get(0).getHouseId());
|
|
|
- }
|
|
|
- Map<String, Object> content = new HashMap<>();
|
|
|
- content.put("thing1", tmAgency.getName());
|
|
|
- content.put("thing2", tmUser.getName());
|
|
|
- String title = tmHouse.getTitle();
|
|
|
- if (title.length() > 20) {
|
|
|
- title = title.substring(0, 20);
|
|
|
- }
|
|
|
- content.put("thing3", title);
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm:ss");
|
|
|
- content.put("time4", simpleDateFormat.format(new Date()));
|
|
|
- String page = "/pages/web/web?vr_link=" + link;
|
|
|
- log.info("跳转的链接为:{}", page);
|
|
|
- Map<String, Object> result = wxSubscribeService.executeAsync(content, page, tmAgency.getWxOpenId());
|
|
|
- if (null != result && result.containsKey("errcode")) {
|
|
|
- int errorCode = (int) result.get("errcode");
|
|
|
- String errmsg = (String) result.get("errmsg");
|
|
|
- log.info("微信消息订阅完成,返回码={},返回描述={}", errorCode, errmsg);
|
|
|
- if (errorCode != 0) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D019);
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.success("推送消息成功成功");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 1、根据城市、地区、价钱、户型、电梯等条件捞取房源列表
|
|
|
- * 2、支持分页
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getHouseList(HttpServletRequest req) {
|
|
|
- String city = req.getParameter("city");
|
|
|
- String district = req.getParameter("district");
|
|
|
- int pageNum = DataUtils.getInteger(req.getParameter("page_num"));
|
|
|
- int pageSize = DataUtils.getInteger(req.getParameter("page_size"));
|
|
|
- if(0 == pageSize){
|
|
|
- pageSize = 10;
|
|
|
- }
|
|
|
- Page<TmHouse> page = new Page<>(pageNum, pageSize);
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- //只捞取有效的房源,已经被删除的(enable=0)的则不捞取
|
|
|
- queryWrapper.eq("enable" , 1);
|
|
|
- if (StringUtils.isBlank(city) && StringUtils.isBlank(district)) {
|
|
|
- log.error("行政区域和城市都为空");
|
|
|
- return Result.failure("行政区域和城市都为空!无法拉取房源列表");
|
|
|
- }
|
|
|
-
|
|
|
- IPage<TmHouse> iPage = null;
|
|
|
-
|
|
|
- /**
|
|
|
- * 所有tag下面的房源都是统一取数逻辑:先从行政区域捞取,
|
|
|
- * 如果行政区域捞取数量小于10个,则扩大到市区捞取
|
|
|
- */
|
|
|
- if (StringUtils.isNotBlank(district)) {
|
|
|
- log.info("先拉取本行政区域的房源");
|
|
|
- assembleTmHouse(req, queryWrapper, null, district);
|
|
|
- iPage = tmHouseDao.selectPage(page, queryWrapper);
|
|
|
- List<TmHouse> houseList = iPage.getRecords();
|
|
|
- if ((null != houseList && houseList.size() < 10) || (houseList == null)) {
|
|
|
- log.info("行政区域:[{}]下的房源数过少:[{}],从新从市级别拉取", district, null != houseList ? houseList.size() : 0);
|
|
|
- queryWrapper.clear();
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- //只捞取有效的房源,已经被删除的(enable=0)的则不捞取
|
|
|
- queryWrapper.eq("enable" , 1);
|
|
|
- assembleTmHouse(req, queryWrapper, city, null);
|
|
|
- iPage = tmHouseDao.selectPage(page, queryWrapper);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.info("行政区域为空,需要扩充到市级别捞取房源列表");
|
|
|
- assembleTmHouse(req, queryWrapper, city, null);
|
|
|
- iPage = tmHouseDao.selectPage(page, queryWrapper);
|
|
|
- }
|
|
|
- return Result.success(DataUtils.assembleResult(iPage.getTotal(), iPage.getPages(), iPage.getCurrent(), iPage.getRecords()));
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/agencyHouse", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getAgencyHouseList(HttpServletRequest req) {
|
|
|
- String city = req.getParameter("city");
|
|
|
- String district = req.getParameter("district");
|
|
|
- String agencyUserId = req.getParameter("agency_user_id");
|
|
|
- int pageNum = DataUtils.getInteger(req.getParameter("page_num"));
|
|
|
- int pageSize = DataUtils.getInteger(req.getParameter("page_size"));
|
|
|
- if(0 == pageSize){
|
|
|
- pageSize = 10;
|
|
|
- }
|
|
|
- if(StringUtils.isBlank(agencyUserId)){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017, "缺失经纪人id");
|
|
|
- }
|
|
|
- Page<TmHouse> page = new Page<>(pageNum, pageSize);
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("relation.agency_user_id" , agencyUserId);
|
|
|
-
|
|
|
-
|
|
|
- IPage<TmHouse> iPage = null;
|
|
|
-
|
|
|
- assembleTmHouse(req, queryWrapper, city, district,"house.");
|
|
|
- iPage = tmHouseDao.selectAgencyHouseList(page, queryWrapper);
|
|
|
-
|
|
|
- return Result.success(DataUtils.assembleResult(iPage.getTotal(), iPage.getPages(), iPage.getCurrent(), iPage.getRecords()));
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = "/agencyRecHouse", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getAgencyRecHouseList(HttpServletRequest req) {
|
|
|
- String city = req.getParameter("city");
|
|
|
- String district = req.getParameter("district");
|
|
|
- String agencyUserId = req.getParameter("agency_user_id");
|
|
|
- String houseId = req.getParameter("house_id");
|
|
|
- int pageNum = DataUtils.getInteger(req.getParameter("page_num"));
|
|
|
- int pageSize = DataUtils.getInteger(req.getParameter("page_size"));
|
|
|
- if(0 == pageSize){
|
|
|
- pageSize = 10;
|
|
|
- }
|
|
|
- if(!StringUtils.isNoneBlank(agencyUserId , houseId)){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017, "缺失经纪人id,房源id");
|
|
|
- }
|
|
|
- Page<TmHouse> page = new Page<>(pageNum, pageSize);
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("relation.agency_user_id" , agencyUserId);
|
|
|
- queryWrapper.ne("relation.house_id" , houseId);
|
|
|
-
|
|
|
-
|
|
|
- IPage<TmHouse> iPage = null;
|
|
|
- IPage<Map<String , Object>> recPage = new Page<>();
|
|
|
-
|
|
|
- assembleTmHouse(req, queryWrapper, city, district,"house.");
|
|
|
- iPage = tmHouseDao.selectAgencyHouseList(page, queryWrapper);
|
|
|
- List<Map<String , Object>> mapList = new ArrayList<>();
|
|
|
- if(!CollectionUtils.isEmpty(iPage.getRecords())){
|
|
|
- for(TmHouse house : iPage.getRecords()){
|
|
|
- Map<String ,Object> map = new HashMap<>();
|
|
|
- map = houseHelperService.getHouseInfoByHouse(house , "" , "" , "agent" , fdvrhouseCallBackUrl);
|
|
|
- if(!CollectionUtils.isEmpty(map)){
|
|
|
- mapList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- recPage.setRecords(mapList);
|
|
|
- recPage.setPages(1);
|
|
|
- recPage.setCurrent(0);
|
|
|
- recPage.setTotal(mapList.size());
|
|
|
-
|
|
|
- return Result.success(DataUtils.assembleResult(recPage.getTotal(), recPage.getPages(), recPage.getCurrent(), recPage.getRecords()));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 1、获取推荐房源
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/recommend", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Result getRecomandHouse(HttpServletRequest req) {
|
|
|
- //TODO:这里是写死的推荐房源,只拉取10个
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("enable" , 1);
|
|
|
- queryWrapper.last("limit 10");
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- List<TmHouse> houseList = tmHouseDao.selectList(queryWrapper);
|
|
|
- return Result.success(houseList);
|
|
|
- }
|
|
|
-
|
|
|
- private void assembleTmHouse(HttpServletRequest request, QueryWrapper<TmHouse> queryWrapper, String city, String district) {
|
|
|
- if (null != request) {
|
|
|
- String saleType = request.getParameter("saleType");
|
|
|
- String price = request.getParameter("price");
|
|
|
- String rooms = request.getParameter("rooms");
|
|
|
- String houseType = request.getParameter("houseType");
|
|
|
- String orientation = request.getParameter("orientation");
|
|
|
- String elevator = request.getParameter("elevator");
|
|
|
- String title = request.getParameter("title");
|
|
|
- String roomsRange = request.getParameter("room_s");
|
|
|
- String priceRange = request.getParameter("price_s");
|
|
|
- Integer saleState = DataUtils.getInteger(request.getParameter("saleState"));
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(saleType)) {
|
|
|
- queryWrapper.eq("sale_type", saleType.trim());
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNoneBlank(rooms)) {
|
|
|
- Integer getRoom = DataUtils.getIntegerWithDefault(rooms , false);
|
|
|
- if(null != getRoom){
|
|
|
- queryWrapper.eq("rooms", getRoom);
|
|
|
- }else{
|
|
|
- log.info("非法的居室数:{}" , rooms);
|
|
|
- }
|
|
|
- }else{
|
|
|
- //默认填了房间数,就按房间数走,没填,才查看是否上送了房间区间
|
|
|
- if(StringUtils.isNotBlank(roomsRange)){
|
|
|
- String[] roomRangeList = roomsRange.split("#");
|
|
|
- if(null != roomRangeList && roomRangeList.length > 1){
|
|
|
- Integer roomSmall = DataUtils.getInteger(roomRangeList[0]);
|
|
|
- Integer roomBig = DataUtils.getInteger(roomRangeList[1]);
|
|
|
- if(null != roomSmall && null != roomBig){
|
|
|
- queryWrapper.between("rooms" , roomSmall , roomBig);
|
|
|
- }
|
|
|
- }else{
|
|
|
- log.warn("非法的居室范围:{}",roomsRange);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNoneBlank(price)) {
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- BigDecimal getPrice = DataUtils.getBigDecimalObj(price);
|
|
|
- getPrice = getPrice.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- queryWrapper.eq("price", getPrice);
|
|
|
- }else{
|
|
|
- //没有直接上送价格,则尝试获取价格区间
|
|
|
- if(StringUtils.isNotBlank(priceRange)){
|
|
|
- String[] priceRangeList = priceRange.split("#");
|
|
|
- if(null != priceRangeList && priceRangeList.length > 1){
|
|
|
- BigDecimal priceSmall = DataUtils.getBigDecimalObj(priceRangeList[0]);
|
|
|
- BigDecimal priceBig = DataUtils.getBigDecimalObj(priceRangeList[1]);
|
|
|
- if(null != priceSmall && null != priceBig){
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- priceSmall = priceSmall.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- priceBig = priceBig.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- queryWrapper.between("price" , priceSmall , priceBig);
|
|
|
- }
|
|
|
- }else{
|
|
|
- log.warn("非法的价格范围:{}",priceRange);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(StringUtils.isNotBlank(title)){
|
|
|
- //TODO:加索引
|
|
|
- queryWrapper.like("title" , title);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(houseType)) {
|
|
|
- queryWrapper.eq("house_type", houseType);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(orientation)) {
|
|
|
- queryWrapper.eq("orientation", orientation);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(elevator)) {
|
|
|
- queryWrapper.eq("elevator", elevator);
|
|
|
- }
|
|
|
-
|
|
|
- if (null != saleState && saleState > 0) {
|
|
|
- queryWrapper.eq("sale_state", saleState);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(district)) {
|
|
|
- queryWrapper.eq("district", district);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(city)) {
|
|
|
- queryWrapper.likeRight("city", city);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void assembleTmHouse(HttpServletRequest request, QueryWrapper<TmHouse> queryWrapper,
|
|
|
- String city, String district ,String tableAlias) {
|
|
|
- queryWrapper.orderByDesc(tableAlias + "create_time");
|
|
|
- //只捞取有效的房源,已经被删除的(enable=0)的则不捞取
|
|
|
- queryWrapper.eq(tableAlias + "enable" , 1);
|
|
|
-
|
|
|
- if (null != request) {
|
|
|
- String saleType = request.getParameter("saleType");
|
|
|
- String price = request.getParameter("price");
|
|
|
- String rooms = request.getParameter("rooms");
|
|
|
- String houseType = request.getParameter("houseType");
|
|
|
- String orientation = request.getParameter("orientation");
|
|
|
- String elevator = request.getParameter("elevator");
|
|
|
- String title = request.getParameter("title");
|
|
|
- String roomsRange = request.getParameter("room_s");
|
|
|
- String priceRange = request.getParameter("price_s");
|
|
|
- Integer saleState = DataUtils.getInteger(request.getParameter("saleState"));
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(saleType)) {
|
|
|
- queryWrapper.eq(tableAlias + "sale_type", saleType.trim());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNoneBlank(rooms)) {
|
|
|
- Integer getRoom = DataUtils.getIntegerWithDefault(rooms , false);
|
|
|
- if(null != getRoom){
|
|
|
- queryWrapper.eq(tableAlias +"rooms", getRoom);
|
|
|
- }else{
|
|
|
- log.info("非法的居室数:{}" , rooms);
|
|
|
- }
|
|
|
- }else{
|
|
|
- //默认填了房间数,就按房间数走,没填,才查看是否上送了房间区间
|
|
|
- if(StringUtils.isNotBlank(roomsRange)){
|
|
|
- String[] roomRangeList = roomsRange.split("#");
|
|
|
- if(null != roomRangeList && roomRangeList.length > 1){
|
|
|
- Integer roomSmall = DataUtils.getInteger(roomRangeList[0]);
|
|
|
- Integer roomBig = DataUtils.getInteger(roomRangeList[1]);
|
|
|
- if(null != roomSmall && null != roomBig){
|
|
|
- queryWrapper.between(tableAlias +"rooms" , roomSmall , roomBig);
|
|
|
- }
|
|
|
- }else{
|
|
|
- log.warn("非法的居室范围:{}",roomsRange);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNoneBlank(price)) {
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- BigDecimal getPrice = DataUtils.getBigDecimalObj(price);
|
|
|
- getPrice = getPrice.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- queryWrapper.eq(tableAlias +"price", getPrice);
|
|
|
- }else{
|
|
|
- //没有直接上送价格,则尝试获取价格区间
|
|
|
- if(StringUtils.isNotBlank(priceRange)){
|
|
|
- String[] priceRangeList = priceRange.split("#");
|
|
|
- if(null != priceRangeList && priceRangeList.length > 1){
|
|
|
- BigDecimal priceSmall = DataUtils.getBigDecimalObj(priceRangeList[0]);
|
|
|
- BigDecimal priceBig = DataUtils.getBigDecimalObj(priceRangeList[1]);
|
|
|
- if(null != priceSmall && null != priceBig){
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- priceSmall = priceSmall.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- //前端上送的价钱都是以万级为单位,这里需要转换
|
|
|
- priceBig = priceBig.multiply(new BigDecimal(10000)).setScale(2 , BigDecimal.ROUND_HALF_UP);
|
|
|
- queryWrapper.between(tableAlias +"price" , priceSmall , priceBig);
|
|
|
- }
|
|
|
- }else{
|
|
|
- log.warn("非法的价格范围:{}",priceRange);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(StringUtils.isNotBlank(title)){
|
|
|
- //TODO:加索引
|
|
|
- queryWrapper.like(tableAlias +"title" , title);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(houseType)) {
|
|
|
- queryWrapper.eq(tableAlias +"house_type", houseType);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(orientation)) {
|
|
|
- queryWrapper.eq(tableAlias +"orientation", orientation);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(elevator)) {
|
|
|
- queryWrapper.eq(tableAlias +"elevator", elevator);
|
|
|
- }
|
|
|
-
|
|
|
- if (null != saleState && saleState > 0) {
|
|
|
- queryWrapper.eq(tableAlias +"sale_state", saleState);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(district)) {
|
|
|
- queryWrapper.eq(tableAlias +"district", district);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(city)) {
|
|
|
- queryWrapper.likeRight(tableAlias +"city", city);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "向openApi发送数据")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "house_id", value = "房源id", paramType = "query", required = false, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "user_id", value = "用户id", paramType = "query", required = false, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "room_id", value = "语音通话房间id", paramType = "query", required = false, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "type", value = "请求端类型: 经纪人传agent,用户传customer", paramType = "query", required = false, dataType = "String")}
|
|
|
- )
|
|
|
- @GetMapping(value = "/sendData")
|
|
|
- @ResponseBody
|
|
|
- public Result sendFormatDataToOpenApi (@RequestParam(value = "house_id") String houseId ,
|
|
|
- @RequestParam(value = "user_id") String userId ,
|
|
|
- @RequestParam(value = "room_id") String roomId,
|
|
|
- @RequestParam(value = "type") String type) {
|
|
|
- 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 = houseHelperService.getHouseInfoByHouse(dbHouse , userId , roomId , type , callBackUrl);
|
|
|
-
|
|
|
- List<Map<String , Object>> recommends = houseHelperService.getAgencyRecHouseInfo(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);
|
|
|
- String sign = SHAUtils.getSHA256(dataStr + fdAppSecret + timeStamp);
|
|
|
-
|
|
|
- String openApiurl = apiVrHouseHost + "/api/format?appId=" + fdAppId + "&sign=" + sign + "&token=" + token + "&timeStamp=" + timeStamp;
|
|
|
- log.info("请求openApi的url={}", openApiurl);
|
|
|
- String apiResultStr = HttpClientUtil.doPostJson(openApiurl , dataStr);
|
|
|
- Result res = JSONObject.parseObject(apiResultStr , Result.class);
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|