|
@@ -6,13 +6,11 @@ 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.auth.utils.ShiroUtils;
|
|
|
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.Result;
|
|
|
-import com.ljq.house.biz.model.TmAgency;
|
|
|
-import com.ljq.house.biz.model.TmHouse;
|
|
|
-import com.ljq.house.biz.model.TmHouseAgencyRelation;
|
|
|
+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;
|
|
@@ -20,6 +18,7 @@ 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.service.HouseHelperService;
|
|
|
import com.ljq.house.common.utils.*;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
@@ -96,12 +95,28 @@ public class AdminTmHouseController {
|
|
|
@Value("${user.wx.app.secret}")
|
|
|
private String userWxAppSecret;
|
|
|
|
|
|
+ @Value("${4dkankan.api.vr.house.host}")
|
|
|
+ private String apiVrHouseHost;
|
|
|
+
|
|
|
+ @Value("${4dkankan.vr.house.host}")
|
|
|
+ private String fdvrhouseCallBackUrl;
|
|
|
+
|
|
|
+ @Value("${4dkankan.api.app.id}")
|
|
|
+ private String fdAppId;
|
|
|
+
|
|
|
+ @Value("${4dkankan.api.app.secret}")
|
|
|
+ private String fdAppSecret;
|
|
|
+
|
|
|
@Value("${4dkankan.vr.house.path}")
|
|
|
private String vrHousePath;
|
|
|
|
|
|
@Autowired
|
|
|
private TmHouseAgencyRelationDao tmHouseAgencyRelationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HouseHelperService houseHelperService;
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation(value = "获取房源详情")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "house_id", value = "房源ID(32位)", paramType = "query", required = true, dataType = "String")}
|
|
@@ -136,6 +151,14 @@ public class AdminTmHouseController {
|
|
|
if(null == dbHouse){
|
|
|
throw new CommonBaseException(ResultCodeEnum.D017 , "房源不存在,无需更新");
|
|
|
}
|
|
|
+
|
|
|
+ TmAdmin user = ShiroUtils.getAdmin();
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户未登录,登录");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "未登录,请登录");
|
|
|
+ }
|
|
|
+ tmHouse.setUpdateUserId(user.getAdminId());
|
|
|
+
|
|
|
int result = -1;
|
|
|
try{
|
|
|
result = tmHouseDao.updateByIdSelectively(tmHouse);
|
|
@@ -205,7 +228,7 @@ public class AdminTmHouseController {
|
|
|
@PostMapping("/changeAgency")
|
|
|
@ResponseBody
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, logical = Logical.OR)
|
|
|
public Result changeAttachAgency(@RequestBody @ApiParam(name = "修改房源关联经纪人请求体", value = "传入json格式", required = true) HouseAttachAgencyChange houseAttachAgencyChange) {
|
|
|
if (null == houseAttachAgencyChange) {
|
|
|
throw new CommonBaseException(ResultCodeEnum.D017);
|
|
@@ -218,31 +241,53 @@ public class AdminTmHouseController {
|
|
|
if (null == tmAgencyNew || 1 != tmAgencyNew.getEnable()) {
|
|
|
throw new CommonBaseException(ResultCodeEnum.D033);
|
|
|
}
|
|
|
- if (StringUtils.isBlank( houseAttachAgencyChange.getHouseId())) {
|
|
|
+ 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());
|
|
|
- }
|
|
|
+ //先删除旧的关联关系如果存在
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //新插一个经纪人房源管理关系
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //将经纪人关联信息同步到open-api
|
|
|
+ String openApiResult = houseHelperService.getHouseInfoFromOpenApi(house , apiVrHouseHost);
|
|
|
+ log.info("获取OpenApi的房源信息结果:{}" , openApiResult);
|
|
|
+ if(StringUtils.isNotBlank(openApiResult)){
|
|
|
+ Result openApiRes = JSONObject.parseObject(openApiResult , Result.class);
|
|
|
+ if(null != openApiRes){
|
|
|
+ JSONObject jsonObject = (JSONObject) openApiRes.getData();
|
|
|
+ String roomId = jsonObject.getString("roomId");
|
|
|
+ String type = jsonObject.getString("terminalType");
|
|
|
+ String userId = jsonObject.getString("userId");
|
|
|
+ String apiResultStr = houseHelperService.sendDataToOpenApi(house.getHouseId(), fdvrhouseCallBackUrl, userId,
|
|
|
+ roomId, type, fdAppId, fdAppSecret, apiVrHouseHost);
|
|
|
+ log.info("修改房源经纪人的关联关系,openApi服务器返回:{}" , apiResultStr);
|
|
|
+ Result totalResult = JSONObject.parseObject(apiResultStr , Result.class);
|
|
|
+ if(null == totalResult || null == totalResult.getCode()|| totalResult.getCode() != 0){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "修改openApi的关联关系失败");
|
|
|
+ }
|
|
|
}
|
|
|
+ }else{
|
|
|
+ log.warn("从OpenApi接口上获取房源信息失败,OpenApi上不存在或者异常,这里不去更细OpenApi上的推荐房源关联关系");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return Result.success("关联房源成功");
|
|
|
}
|
|
@@ -295,63 +340,7 @@ public class AdminTmHouseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @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.setArea(tmHouse.getBuildingArea());
|
|
|
- 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({
|
|
@@ -361,7 +350,7 @@ public class AdminTmHouseController {
|
|
|
@GetMapping("/queryHouse")
|
|
|
@ResponseBody
|
|
|
// @RequiresPermissions("admin:house:queryHouse")
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, logical = Logical.OR)
|
|
|
public Result queryUnDistributeHouse(@RequestParam(name = "sale_type") Integer saleType,
|
|
|
@RequestParam(name = "query_name") String queryName,
|
|
|
@RequestParam(name = "page_num") Long pageNum,
|
|
@@ -379,6 +368,19 @@ public class AdminTmHouseController {
|
|
|
constantQuery.put("distribute_status", 0);
|
|
|
//只捞未删除的数据
|
|
|
constantQuery.put("enable", 1);
|
|
|
+ if(!ShiroUtils.getSubject().hasRole("super_admin")){
|
|
|
+ //非超级管理员,则需要过滤数据
|
|
|
+ TmAdmin user = ShiroUtils.getAdmin();
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户未登录,登录");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "未登录,请登录");
|
|
|
+ }
|
|
|
+ if(null == user.getDeptId()){
|
|
|
+ log.error("用户未分配归属部门");
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+ queryWrapper.eq("CREATE_USER_DEPT_ID" , user.getDeptId());
|
|
|
+ }
|
|
|
resultPage = timesQueryHouse(constantQuery, queryName, page, queryWrapper,
|
|
|
"house_id", "title", "estate_name");
|
|
|
|
|
@@ -398,7 +400,7 @@ public class AdminTmHouseController {
|
|
|
@GetMapping("/queryAll")
|
|
|
@ResponseBody
|
|
|
// @RequiresPermissions("admin:house:queryAll")
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, logical = Logical.OR)
|
|
|
public Result queryAllHouse(@RequestParam(name = "estate_name") String estateName,
|
|
|
@RequestParam(name = "sale_type") Integer saleType,
|
|
|
@RequestParam(name = "query_name") String queryName,
|
|
@@ -407,21 +409,34 @@ public class AdminTmHouseController {
|
|
|
|
|
|
QueryWrapper<TmHouse> houseQueryWrapper = new QueryWrapper<>();
|
|
|
//只捞取未删除的数据
|
|
|
- houseQueryWrapper.eq("a.enable" , 1);
|
|
|
+ houseQueryWrapper.eq("house.enable", 1);
|
|
|
Page<TmHouse> page = new Page(pageNum, pageSize);
|
|
|
- IPage<Map<String ,Object>> resultPage = new Page<>();
|
|
|
+ IPage<Map<String, Object>> resultPage = new Page<>();
|
|
|
Map<String, Object> constantQuery = new HashMap<>();
|
|
|
if (null != saleType) {
|
|
|
- constantQuery.put("a.sale_type", saleType);
|
|
|
+ constantQuery.put("house.sale_type", saleType);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(estateName)) {
|
|
|
- constantQuery.put("a.estate_name", estateName);
|
|
|
+ constantQuery.put("house.estate_name", estateName);
|
|
|
}
|
|
|
|
|
|
- DataUtils.assembleTimeQueryWrapper(constantQuery, queryName, houseQueryWrapper, "a.house_id", "a.title", "a.name");
|
|
|
+ DataUtils.assembleTimeQueryWrapper(constantQuery, queryName, houseQueryWrapper, "house.house_id", "house.title", "relation.name");
|
|
|
|
|
|
- houseQueryWrapper.orderByDesc("a.create_time");
|
|
|
+ houseQueryWrapper.orderByDesc("house.create_time");
|
|
|
|
|
|
+ if(!ShiroUtils.getSubject().hasRole("super_admin")){
|
|
|
+ //非超级管理员,则需要过滤数据
|
|
|
+ TmAdmin user = ShiroUtils.getAdmin();
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户未登录,登录");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "未登录,请登录");
|
|
|
+ }
|
|
|
+ if(null == user.getDeptId()){
|
|
|
+ log.error("用户未分配归属部门");
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+ houseQueryWrapper.eq("house.CREATE_USER_DEPT_ID" , user.getDeptId());
|
|
|
+ }
|
|
|
resultPage = tmHouseDao.selectHouseInfoList(page, houseQueryWrapper);
|
|
|
|
|
|
return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
@@ -436,6 +451,7 @@ public class AdminTmHouseController {
|
|
|
resultPage = tmHouseDao.selectPage(page, queryWrapper);
|
|
|
return resultPage;
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "获取客户所有的场景列表")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "page_num", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
@@ -443,73 +459,90 @@ public class AdminTmHouseController {
|
|
|
)
|
|
|
@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) {
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, 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){
|
|
|
+ if (requestScene.getPageNum() == 0) {
|
|
|
//看看的页码从1开始算起
|
|
|
requestScene.setPageNum(1);
|
|
|
}
|
|
|
String url = kankanHost + "api/user/scene/list";
|
|
|
- Map<String , Object> headers = new HashMap<>();
|
|
|
- headers.put("token" , requestScene.getToken());
|
|
|
+ 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){
|
|
|
+ if (null != res) {
|
|
|
log.info("看看获取场景列表返回:{}", res.toJSONString());
|
|
|
int code = -10;
|
|
|
- if(res.containsKey("code")){
|
|
|
+ if (res.containsKey("code")) {
|
|
|
code = (int) res.get("code");
|
|
|
- if(code != 0){
|
|
|
- Result.failure("调用看看失败" );
|
|
|
+ if (code != 0) {
|
|
|
+ Result.failure("调用看看失败");
|
|
|
}
|
|
|
- }else{
|
|
|
- Result.failure("调用看看失败" );
|
|
|
+ } else {
|
|
|
+ Result.failure("调用看看失败");
|
|
|
}
|
|
|
- }else{
|
|
|
- Result.failure("调用看看失败" );
|
|
|
+ } else {
|
|
|
+ Result.failure("调用看看失败");
|
|
|
}
|
|
|
- return Result.success("获取场景结束" , res.get("data"));
|
|
|
+ return Result.success("获取场景结束", res.get("data"));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除房源")
|
|
|
@PostMapping("/delete")
|
|
|
@ResponseBody
|
|
|
- @RequiresRoles(value = {"super_admin","normal_admin","agency"},logical = Logical.OR)
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, logical = Logical.OR)
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Result delete(@RequestBody @ApiParam(name = "删除请求体", value = "传入json格式", required = true)
|
|
|
- DeleteRequestVo requestVo) {
|
|
|
+ DeleteRequestVo requestVo) {
|
|
|
+ TmAdmin user = ShiroUtils.getAdmin();
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户未登录,登录");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "未登录,请登录");
|
|
|
+ }
|
|
|
|
|
|
- if(!CollectionUtils.isEmpty(requestVo.getStrIds())){
|
|
|
- for (String id : requestVo.getStrIds()){
|
|
|
- if(StringUtils.isNotBlank(id)){
|
|
|
+ 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, "删除房源经纪人关联关系失败");
|
|
|
+ tmHouse.setUpdateUserId(user.getAdminId());
|
|
|
+ updateWrapper.eq("house_id", id);
|
|
|
+ int delete = tmHouseDao.update(tmHouse, updateWrapper);
|
|
|
+ if(delete == 1){
|
|
|
+ //删除房源经纪人关系
|
|
|
+ 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, "删除房源经纪人关联关系失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //将房源的删除信息同步给open-api
|
|
|
+ String apiResultStr = houseHelperService.sendDataToOpenApi(id , fdvrhouseCallBackUrl ,"" ,
|
|
|
+ "","" , fdAppId , fdAppSecret , apiVrHouseHost);
|
|
|
+ log.info("删除房源并同步到openApi,api服务器返回:{}" , apiResultStr);
|
|
|
+ Result totalResult = JSONObject.parseObject(apiResultStr , Result.class);
|
|
|
+ if(null == totalResult || null == totalResult.getCode()|| totalResult.getCode() != 0){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "同步删除房源到api失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|