|
@@ -1,520 +0,0 @@
|
|
|
-package com.ljq.house.admin.controller;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-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.TmAgencyDao;
|
|
|
-import com.ljq.house.biz.dao.TmHouseAgencyRelationDao;
|
|
|
-import com.ljq.house.biz.dao.TmHouseDao;
|
|
|
-import com.ljq.house.biz.model.*;
|
|
|
-import com.ljq.house.biz.vo.request.DeleteRequestVo;
|
|
|
-import com.ljq.house.biz.vo.request.HouseAttachAgencyChange;
|
|
|
-import com.ljq.house.biz.vo.request.HouseAttachAgencyVO;
|
|
|
-import com.ljq.house.biz.vo.request.RequestScene;
|
|
|
-import com.ljq.house.common.enums.IdStarterEnum;
|
|
|
-import com.ljq.house.common.enums.ResultCodeEnum;
|
|
|
-import com.ljq.house.common.exception.CommonBaseException;
|
|
|
-import com.ljq.house.common.utils.*;
|
|
|
-import io.swagger.annotations.*;
|
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.shiro.authz.annotation.Logical;
|
|
|
-import org.apache.shiro.authz.annotation.RequiresRoles;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.*;
|
|
|
-import java.sql.SQLIntegrityConstraintViolationException;
|
|
|
-import java.util.*;
|
|
|
-import java.util.prefs.BackingStoreException;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author abnerhou
|
|
|
- * @date 2020/4/23 17:25
|
|
|
- * @desciption
|
|
|
- */
|
|
|
-@Api(description = "管理后台-房源管理接口")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/admin/house")
|
|
|
-@Log4j2
|
|
|
-public class AdminTmHouseController {
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseDao tmHouseDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmAgencyDao tmAgencyDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseAgencyRelationDao houseAgencyRelationDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UploadToOssUtil uploadToOssUtil;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OssCheckPointUploadUtil ossCheckPointUploadUtil;
|
|
|
-
|
|
|
- @Value("${oss.image.file.path}")
|
|
|
- private String ossImagePath;
|
|
|
-
|
|
|
- @Value("${oss.video.file.path}")
|
|
|
- private String ossVideoPath;
|
|
|
-
|
|
|
- @Value("${video-file-path}")
|
|
|
- private String videoLocalBackupPath;
|
|
|
-
|
|
|
- @Value("${oss.point}")
|
|
|
- private String endpoint;
|
|
|
-
|
|
|
- @Value("${oss.bucket}")
|
|
|
- private String bucketName;
|
|
|
-
|
|
|
- @Value("${oss.query.url}")
|
|
|
- private String ossQueryUrl;
|
|
|
-
|
|
|
- @Value("${4dkankan.host}")
|
|
|
- private String kankanHost;
|
|
|
-
|
|
|
- @Value("${file-backup-path}")
|
|
|
- private String imageFilePath;
|
|
|
-
|
|
|
- @Value("${user.wx.app.id}")
|
|
|
- private String userWxAppId;
|
|
|
-
|
|
|
- @Value("${user.wx.app.secret}")
|
|
|
- private String userWxAppSecret;
|
|
|
-
|
|
|
- @Value("${4dkankan.vr.house.path}")
|
|
|
- private String vrHousePath;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TmHouseAgencyRelationDao tmHouseAgencyRelationDao;
|
|
|
-
|
|
|
- @ApiOperation(value = "获取房源详情")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "house_id", value = "房源ID(32位)", paramType = "query", required = true, dataType = "String")}
|
|
|
- )
|
|
|
- @GetMapping("/house")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result getHousesDetailById(HttpServletRequest req) {
|
|
|
- String houseId = req.getParameter("house_id");
|
|
|
- if (StringUtils.isBlank(houseId)) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D023);
|
|
|
- }
|
|
|
- TmHouse tmHouse = tmHouseDao.selectHouseById(houseId);
|
|
|
- if(null != tmHouse && 1 != tmHouse.getEnable()){
|
|
|
- return Result.failure("该房源已经被删除");
|
|
|
- }
|
|
|
- return Result.success(tmHouse);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "修改房源信息")
|
|
|
- @PostMapping("/update")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result updateHouseInfo(@RequestBody @ApiParam(name = "房源对象", value = "传入json格式", required = true) TmHouse tmHouse) {
|
|
|
- if (null == tmHouse || StringUtils.isBlank(tmHouse.getHouseId())) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- QueryWrapper<TmHouse> houseQueryWrapper = new QueryWrapper<>();
|
|
|
- houseQueryWrapper.eq("house_id" , tmHouse.getHouseId());
|
|
|
- houseQueryWrapper.last("limit 1");
|
|
|
- TmHouse dbHouse = tmHouseDao.selectOne(houseQueryWrapper);
|
|
|
- if(null == dbHouse){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017 , "房源不存在,无需更新");
|
|
|
- }
|
|
|
- int result = -1;
|
|
|
- try{
|
|
|
- result = tmHouseDao.updateByIdSelectively(tmHouse);
|
|
|
- }catch (Exception e){
|
|
|
- if(e instanceof DuplicateKeyException){
|
|
|
- return Result.failure("请检查场景码是否已经绑定过房源了");
|
|
|
- }else{
|
|
|
- Result.failure("修改房源信息失败,请检查数据是否有重复");
|
|
|
- }
|
|
|
- log.info("修改房源出现异常:{}" , e);
|
|
|
- }
|
|
|
-
|
|
|
- return result == 1 ? Result.success("修改房源信息成功") : Result.failure("修改房源信息失败");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "关联经纪人(新增)")
|
|
|
- @PostMapping("/attachAgency")
|
|
|
- @ResponseBody
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result attachAgency(@RequestBody @ApiParam(name = "房源关联经纪人请求体", value = "传入json格式", required = true) HouseAttachAgencyVO houseAttachAgencyVO) {
|
|
|
- if (null == houseAttachAgencyVO) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- TmAgency tmAgency = tmAgencyDao.selectTmAgencyById(houseAttachAgencyVO.getAgencyUserId());
|
|
|
- if (null == tmAgency || 1 != tmAgency.getEnable()) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D033);
|
|
|
- }
|
|
|
- List<String> houseIds = houseAttachAgencyVO.getHouseIds();
|
|
|
- if (CollectionUtils.isEmpty(houseIds)) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D023);
|
|
|
- }
|
|
|
- for (String houseId : houseIds) {
|
|
|
- TmHouse house = tmHouseDao.selectHouseById(houseId);
|
|
|
- if (null != house) {
|
|
|
- insertHouseAgencyRelation(house , tmAgency);
|
|
|
- house.setDistributeStatus(1);
|
|
|
- int updateResult = tmHouseDao.updateByIdSelectively(house);
|
|
|
- if (updateResult != 1) {
|
|
|
- log.info("关联房源:{}到经纪人:{}失败,全部回滚db操作", houseId, tmAgency.getAgencyUserId());
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D100);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.success("关联房源成功");
|
|
|
- }
|
|
|
-
|
|
|
- public void insertHouseAgencyRelation(TmHouse tmHouse, TmAgency tmAgency){
|
|
|
- TmHouseAgencyRelation houseAgencyRelation = new TmHouseAgencyRelation();
|
|
|
- houseAgencyRelation.setHouseId(tmHouse.getHouseId());
|
|
|
- houseAgencyRelation.setEstateId(tmHouse.getEstateId());
|
|
|
- houseAgencyRelation.setAgencyUserId(tmAgency.getAgencyUserId());
|
|
|
- houseAgencyRelation.setName(tmAgency.getName());
|
|
|
- houseAgencyRelation.setVrScene(tmHouse.getSceneNum());
|
|
|
- houseAgencyRelation.setCreateTime(new Date());
|
|
|
- houseAgencyRelation.setLastModifyDatetime(new Date());
|
|
|
- houseAgencyRelation.setVrScene(tmHouse.getSceneNum());
|
|
|
- houseAgencyRelation.setIsValid(1);
|
|
|
- int insertResult = houseAgencyRelationDao.insert(houseAgencyRelation);
|
|
|
- if (insertResult != 1) {
|
|
|
- log.info("关联房源:{}到经纪人:{}失败,全部回滚db操作", tmHouse.getHouseId(), tmAgency.getAgencyUserId());
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D100);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "关联经纪人(修改)")
|
|
|
- @PostMapping("/changeAgency")
|
|
|
- @ResponseBody
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result changeAttachAgency(@RequestBody @ApiParam(name = "修改房源关联经纪人请求体", value = "传入json格式", required = true) HouseAttachAgencyChange houseAttachAgencyChange) {
|
|
|
- if (null == houseAttachAgencyChange) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- TmAgency tmAgencyOld = tmAgencyDao.selectTmAgencyById(houseAttachAgencyChange.getAgencyUserIdOld());
|
|
|
- if (null == tmAgencyOld || 1 != tmAgencyOld.getEnable()) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D033);
|
|
|
- }
|
|
|
- TmAgency tmAgencyNew = tmAgencyDao.selectTmAgencyById(houseAttachAgencyChange.getAgencyUserIdNew());
|
|
|
- if (null == tmAgencyNew || 1 != tmAgencyNew.getEnable()) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D033);
|
|
|
- }
|
|
|
- if (StringUtils.isBlank( houseAttachAgencyChange.getHouseId())) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D023);
|
|
|
- }
|
|
|
- TmHouse house = tmHouseDao.selectHouseById(houseAttachAgencyChange.getHouseId());
|
|
|
- if (null != house) {
|
|
|
- //先删除旧的关联关系如果存在
|
|
|
- QueryWrapper<TmHouseAgencyRelation> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("agency_user_id" , tmAgencyOld.getAgencyUserId());
|
|
|
- queryWrapper.eq("house_id" , house.getHouseId());
|
|
|
- queryWrapper.last("limit 1");
|
|
|
- TmHouseAgencyRelation oldRelation = houseAgencyRelationDao.selectOne(queryWrapper);
|
|
|
- if(null != oldRelation){
|
|
|
- int delete = houseAgencyRelationDao.delete(queryWrapper);
|
|
|
- if(delete != 1){
|
|
|
- log.error("删除经纪人[{}]-房源[{}]的关系失败",tmAgencyOld.getAgencyUserId() , house.getHouseId());
|
|
|
- }
|
|
|
- }
|
|
|
- //新插一个经纪人房源管理关系
|
|
|
- insertHouseAgencyRelation(house , tmAgencyNew);
|
|
|
- house.setDistributeStatus(1);
|
|
|
- int updateResult = tmHouseDao.updateByIdSelectively(house);
|
|
|
- if (updateResult != 1) {
|
|
|
- log.info("关联房源:{}到经纪人:{}失败,全部回滚db操作", houseAttachAgencyChange.getHouseId(), tmAgencyOld.getAgencyUserId());
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D100);
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.success("关联房源成功");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "上传视频")
|
|
|
- @PostMapping("/upLoadVideo")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result uploadIntroduceVideo(@RequestParam("file") MultipartFile file) {
|
|
|
- if (null == file) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- String downLoanVideoPath = FileUtils.parseFile(file , videoLocalBackupPath);
|
|
|
- log.info("视频文件已经下载到本地:{}" ,downLoanVideoPath);
|
|
|
- //视频文件名一般为:xxx.mp4这种格式
|
|
|
- String videoFilePureName = file.getOriginalFilename();
|
|
|
- log.info("视频文件名为:{}" ,videoFilePureName);
|
|
|
- //去掉格式,只获取纯名字
|
|
|
- int index = videoFilePureName.indexOf(".mp4");
|
|
|
- //获取纯名字
|
|
|
- if(index != -1){
|
|
|
- videoFilePureName = videoFilePureName.substring(0 , index);
|
|
|
- }else{
|
|
|
- Random random = new Random();
|
|
|
- videoFilePureName = "default_imag_" + random.nextInt(10000);
|
|
|
- log.info("采用默认的图片名字:{}" ,videoFilePureName);
|
|
|
- }
|
|
|
- //这里默认第一帧图片是jpg格式
|
|
|
- String imageFormatter = "jpg";
|
|
|
- //视频在oss中的object name
|
|
|
- String imageOssObjectName = ossVideoPath + videoFilePureName + "." + imageFormatter;
|
|
|
- //截取视频第一帧图片
|
|
|
- boolean cutFirstImageResult = FileUtils.executeCodecs(downLoanVideoPath , videoLocalBackupPath ,
|
|
|
- videoFilePureName, imageFormatter);
|
|
|
-
|
|
|
- if(cutFirstImageResult){
|
|
|
- log.info("成功截取第一帧图片,将上传到oss上");
|
|
|
- String imageLocalPath = videoLocalBackupPath + videoFilePureName + "." + imageFormatter;
|
|
|
- uploadToOssUtil.uploadThenDelete(imageLocalPath , imageOssObjectName);
|
|
|
- log.info("上传第一帧图片到oss完成");
|
|
|
- }
|
|
|
-
|
|
|
- String videoObjectName = ossVideoPath + file.getOriginalFilename();
|
|
|
- ossCheckPointUploadUtil.doUploadThenDelete(downLoanVideoPath , videoObjectName);
|
|
|
-
|
|
|
- Map<String , Object> resultMap = new HashMap<>();
|
|
|
- resultMap.put("image" , ossQueryUrl + imageOssObjectName);
|
|
|
- resultMap.put("video" , ossQueryUrl + videoObjectName);
|
|
|
- return Result.success("视频文件上传oss结束" , resultMap);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "新增房源")
|
|
|
- @PostMapping(value = "/add")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result addHouse(@RequestBody @ApiParam(name = "房源对象", value = "传入json格式", required = true) TmHouse tmHouse) {
|
|
|
-
|
|
|
- boolean result = false;
|
|
|
- String houseId = UUidGenerator.generatorUuid(IdStarterEnum.HOUSE.getStarter());
|
|
|
- if (null != tmHouse) {
|
|
|
- if (StringUtils.isBlank(tmHouse.getAddress())) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D024);
|
|
|
- }
|
|
|
- //管控一个场景只能绑定一个房源
|
|
|
- if(StringUtils.isNoneBlank(tmHouse.getSceneNum())){
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("scene_num", tmHouse.getSceneNum());
|
|
|
- queryWrapper.last("limit 1");
|
|
|
- TmHouse dbhouse = tmHouseDao.selectOne(queryWrapper);
|
|
|
- if (null != dbhouse) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D025);
|
|
|
- }
|
|
|
- }
|
|
|
- if(StringUtils.isNoneBlank(tmHouse.getVrLink())){
|
|
|
- String qrCodeUrl = "/pages/web/web?vr_link=" + tmHouse.getVrLink();
|
|
|
- //生成带看页面的二维码
|
|
|
- String imageLocalPath = imageFilePath + houseId + "_QRCode.png";
|
|
|
- WxOpUtils.getWxQRCode(qrCodeUrl , userWxAppId ,userWxAppSecret , imageLocalPath);
|
|
|
- String ossPath = ossImagePath + houseId + "_QRCode.png";
|
|
|
- ossCheckPointUploadUtil.upload2(imageLocalPath , ossPath);
|
|
|
- String imageTotalOssUrl = ossQueryUrl + ossPath;
|
|
|
- tmHouse.setWxAqrCode(imageTotalOssUrl);
|
|
|
- File file = new File(imageLocalPath);
|
|
|
- if(file.exists()){
|
|
|
- //删除本地缓存的二维码
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- tmHouse.setHouseId(houseId);
|
|
|
- tmHouse.setDistributeStatus(0);
|
|
|
- tmHouse.setCreateTime(new Date());
|
|
|
- tmHouse.setLastModifyDatetime(new Date());
|
|
|
- tmHouse.setEnable(1);
|
|
|
- tmHouse.setQueryNum(0l);
|
|
|
- int insert = tmHouseDao.insert(tmHouse);
|
|
|
- if (insert == 1) {
|
|
|
- result = true;
|
|
|
- log.info("成功插入房源[{}]数据", houseId);
|
|
|
- } else {
|
|
|
- log.info("插入房源失败:{}", insert);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- log.warn("数据非法,无法新增房源");
|
|
|
- }
|
|
|
- return result ? Result.success("新增房源成功", houseId) : Result.failure("新增房源失败");
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "根据条件获取未分配的房源")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "sale_type", value = "类型", paramType = "query", required = true, dataType = "Integer"),
|
|
|
- @ApiImplicitParam(name = "query_name", value = "搜索条件(房源ID/名称/楼盘)", paramType = "query", required = true, dataType = "String")}
|
|
|
- )
|
|
|
- @GetMapping("/queryHouse")
|
|
|
- @ResponseBody
|
|
|
-// @RequiresPermissions("admin:house:queryHouse")
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result queryUnDistributeHouse(@RequestParam(name = "sale_type") Integer saleType,
|
|
|
- @RequestParam(name = "query_name") String queryName,
|
|
|
- @RequestParam(name = "page_num") Long pageNum,
|
|
|
- @RequestParam(name = "page_size") Long pageSize
|
|
|
- ) {
|
|
|
-
|
|
|
- QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
- Page<TmHouse> page = new Page(pageNum, pageSize);
|
|
|
- IPage<TmHouse> resultPage = new Page<>();
|
|
|
- Map<String, Object> constantQuery = new HashMap<>();
|
|
|
- if (null != saleType) {
|
|
|
- constantQuery.put("sale_type", saleType);
|
|
|
- }
|
|
|
- //只捞取未分配的房源
|
|
|
- constantQuery.put("distribute_status", 0);
|
|
|
- //只捞未删除的数据
|
|
|
- constantQuery.put("enable", 1);
|
|
|
- resultPage = timesQueryHouse(constantQuery, queryName, page, queryWrapper,
|
|
|
- "house_id", "title", "estate_name");
|
|
|
-
|
|
|
- return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
- resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "根据条件获取所有房源")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "estate_name", value = "楼盘名称", paramType = "query", required = true, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "sale_type", value = "类型", paramType = "query", required = true, dataType = "Integer"),
|
|
|
- @ApiImplicitParam(name = "page_num", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
|
- @ApiImplicitParam(name = "page_size", value = "每页大小", paramType = "query", required = true, dataType = "Long"),
|
|
|
- @ApiImplicitParam(name = "query_name", value = "搜索条件(房源ID/名称/楼盘)", paramType = "query", required = true, dataType = "String")}
|
|
|
- )
|
|
|
- @GetMapping("/queryAll")
|
|
|
- @ResponseBody
|
|
|
-// @RequiresPermissions("admin:house:queryAll")
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result queryAllHouse(@RequestParam(name = "estate_name") String estateName,
|
|
|
- @RequestParam(name = "sale_type") Integer saleType,
|
|
|
- @RequestParam(name = "query_name") String queryName,
|
|
|
- @RequestParam(name = "page_num") Long pageNum,
|
|
|
- @RequestParam(name = "page_size") Long pageSize) {
|
|
|
-
|
|
|
- QueryWrapper<TmHouse> houseQueryWrapper = new QueryWrapper<>();
|
|
|
- //只捞取未删除的数据
|
|
|
- houseQueryWrapper.eq("a.enable" , 1);
|
|
|
- Page<TmHouse> page = new Page(pageNum, pageSize);
|
|
|
- IPage<Map<String ,Object>> resultPage = new Page<>();
|
|
|
- Map<String, Object> constantQuery = new HashMap<>();
|
|
|
- if (null != saleType) {
|
|
|
- constantQuery.put("a.sale_type", saleType);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(estateName)) {
|
|
|
- constantQuery.put("a.estate_name", estateName);
|
|
|
- }
|
|
|
-
|
|
|
- DataUtils.assembleTimeQueryWrapper(constantQuery, queryName, houseQueryWrapper, "a.house_id", "a.title", "a.name");
|
|
|
-
|
|
|
- houseQueryWrapper.orderByDesc("a.create_time");
|
|
|
-
|
|
|
- resultPage = tmHouseDao.selectHouseInfoList(page, houseQueryWrapper);
|
|
|
-
|
|
|
- return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
- resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
- }
|
|
|
-
|
|
|
- private IPage<TmHouse> timesQueryHouse(Map<String, Object> constantQuery, String dynamicQuery,
|
|
|
- Page page, QueryWrapper<TmHouse> queryWrapper,
|
|
|
- String idQuery, String secondQuery, String thirdQuery) {
|
|
|
- IPage<TmHouse> resultPage = new Page<>();
|
|
|
- DataUtils.assembleTimeQueryWrapper(constantQuery, dynamicQuery, queryWrapper, idQuery, secondQuery, thirdQuery);
|
|
|
- resultPage = tmHouseDao.selectPage(page, queryWrapper);
|
|
|
- return resultPage;
|
|
|
- }
|
|
|
- @ApiOperation(value = "获取客户所有的场景列表")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "page_num", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
|
- @ApiImplicitParam(name = "page_size", value = "每页大小", paramType = "query", required = true, dataType = "Long")}
|
|
|
- )
|
|
|
- @PostMapping("/getAllScene")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- public Result getAllScene( @RequestBody @ApiParam(name = "房源对象", value = "传入json格式", required = true) RequestScene requestScene) {
|
|
|
- if (null == requestScene || StringUtils.isBlank(requestScene.getToken())) {
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D017);
|
|
|
- }
|
|
|
- if(requestScene.getPageNum() == 0){
|
|
|
- //看看的页码从1开始算起
|
|
|
- requestScene.setPageNum(1);
|
|
|
- }
|
|
|
- String url = kankanHost + "/scene/list";
|
|
|
- Map<String , Object> headers = new HashMap<>();
|
|
|
- headers.put("token" , requestScene.getToken());
|
|
|
- String kankanResult = HttpClientUtil.doPostJsonWithHeader(url, JSON.toJSONString(requestScene), headers);
|
|
|
- //把信息封装为json
|
|
|
- JSONObject res = JSONObject.parseObject(kankanResult);
|
|
|
- if(null != res){
|
|
|
- log.info("看看获取场景列表返回:{}", res.toJSONString());
|
|
|
- int code = -10;
|
|
|
- if(res.containsKey("code")){
|
|
|
- code = (int) res.get("code");
|
|
|
- if(code != 0){
|
|
|
- Result.failure("调用看看失败" );
|
|
|
- }
|
|
|
- }else{
|
|
|
- Result.failure("调用看看失败" );
|
|
|
- }
|
|
|
- }else{
|
|
|
- Result.failure("调用看看失败" );
|
|
|
- }
|
|
|
- return Result.success("获取场景结束" , res.get("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "删除房源")
|
|
|
- @PostMapping("/delete")
|
|
|
- @ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Result delete(@RequestBody @ApiParam(name = "删除请求体", value = "传入json格式", required = true)
|
|
|
- DeleteRequestVo requestVo) {
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(requestVo.getStrIds())){
|
|
|
- for (String id : requestVo.getStrIds()){
|
|
|
- if(StringUtils.isNotBlank(id)){
|
|
|
- UpdateWrapper<TmHouse> updateWrapper = new UpdateWrapper<>();
|
|
|
- TmHouse tmHouse = new TmHouse();
|
|
|
- tmHouse.setEnable(0);
|
|
|
- updateWrapper.eq("house_id" , id);
|
|
|
- tmHouseDao.update(tmHouse , updateWrapper);
|
|
|
- //TODO:删除房源经纪人关系
|
|
|
- QueryWrapper<TmHouseAgencyRelation> relationQueryWrapper = new QueryWrapper<>();
|
|
|
- relationQueryWrapper.eq("house_id" , id);
|
|
|
- //目前一个房源只会绑定一个经纪人
|
|
|
- relationQueryWrapper.last("limit 1000");
|
|
|
- List<TmHouseAgencyRelation> houseAgencyRelationList = tmHouseAgencyRelationDao.selectList(relationQueryWrapper);
|
|
|
- if(!CollectionUtils.isEmpty(houseAgencyRelationList)){
|
|
|
- for (TmHouseAgencyRelation relation : houseAgencyRelationList){
|
|
|
- UpdateWrapper<TmHouseAgencyRelation> relationUpdateWrapper = new UpdateWrapper<>();
|
|
|
- relationUpdateWrapper.eq("house_id" , id);
|
|
|
- relationUpdateWrapper.eq("agency_user_id" , relation.getAgencyUserId());
|
|
|
- relationUpdateWrapper.last("limit 1");
|
|
|
- relation.setIsValid(0);
|
|
|
- relation.setLastModifyDatetime(new Date());
|
|
|
- int updateRelation = tmHouseAgencyRelationDao.update(relation , relationUpdateWrapper);
|
|
|
- if(updateRelation != 1){
|
|
|
- throw new CommonBaseException(ResultCodeEnum.D101, "删除房源经纪人关联关系失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.success("删除成功");
|
|
|
- }
|
|
|
-
|
|
|
-}
|