package com.huiju.estateagents.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huiju.estateagents.base.BaseController;
import com.huiju.estateagents.base.ResponseBean;
import com.huiju.estateagents.common.CommConstant;
import com.huiju.estateagents.entity.*;
import com.huiju.estateagents.po.TaHousingResourcesPO;
import com.huiju.estateagents.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 房源表  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-02-10
 */
@RestController
@RequestMapping("/api")
public class TaHousingResourcesController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(TaHousingResourcesController.class);

    @Autowired
    public ITaHousingResourcesService iTaHousingResourcesService;

    @Autowired
    private ITaBuildingRoomService taBuildingRoomService;

    @Autowired
    private ITaPreselectionRecordService taPreselectionRecordService;

    @Autowired
    private ITaRaiseRecordService taRaiseRecordService;

    @Autowired
    private ITaRaiseHouseService taRaiseHouseService;

    @Autowired
    public ITaBuildingApartmentService taBuildingApartmentService;

    @Autowired
    public ITaBuildingImgService taBuildingImgService;

    @Autowired
    public ITaSalesBatchService taSalesBatchService;

    @Autowired
    private ITaRaiseService iTaRaiseService;

    @Autowired
    ITaPersonService iTaPersonService;

    @Autowired
    private ITaRaiseInviteService iTaRaiseInviteService;

    /**
     * 分页查询列表
     *
     * @param salesBatchId
     * @param buildingId
     * @param pageNumber
     * @param pageSize
     * @param request
     * @return
     */
    @RequestMapping(value = "/admin/taHousingResources", method = RequestMethod.GET)
    public ResponseBean taHousingResourcesList(@RequestParam(value = "salesBatchId", required = true) Integer salesBatchId,
                                               @RequestParam(value = "buildingId", required = true) String buildingId,
                                               @RequestParam(value = "termName", required = false) String termName,
                                               @RequestParam(value = "blockName", required = false) String blockName,
                                               @RequestParam(value = "unitName", required = false) String unitName,
                                               @RequestParam(value = "floorName", required = false) String floorName,
                                               @RequestParam(value = "roomName", required = false) String roomName,
                                               @RequestParam(value = "apartmentId", required = false) String apartmentId,
                                               @RequestParam(value = "status", required = false) Integer status,
                                               @RequestParam(value = "houseId", required = false) String houseId,
                                               @RequestParam(value = "lockingStatus", required = false) String lockingStatus,
                                               @RequestParam(value = "actulStartHot", required = false) String actulStartHot,
                                               @RequestParam(value = "actulEndHot", required = false) String actulEndHot,
                                               @RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                               HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean = iTaHousingResourcesService.selectPageList(salesBatchId, buildingId, pageNumber, pageSize, getOrgId(request), termName, blockName,
                    unitName, floorName, roomName, apartmentId, status, houseId, lockingStatus,actulStartHot,actulEndHot);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesList -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 保存对象
     *
     * @param taHousingResources 实体对象
     * @return
     */
    @RequestMapping(value = "/admin/taHousingResources", method = RequestMethod.POST)
    public ResponseBean taHousingResourcesAdd(@RequestBody TaHousingResources taHousingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            taHousingResources.setOrgId(getOrgId(request));
            responseBean = iTaHousingResourcesService.addHouseResources(taHousingResources);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesAdd -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     */
    @ResponseBody
    @RequestMapping(value = "/admin/houseDelete/{id}", method = RequestMethod.DELETE)
    public ResponseBean taHousingResourcesDelete(@PathVariable Integer id, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            //校验是否有预选记录
            QueryWrapper<TaPreselectionRecord> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("status", CommConstant.STATUS_NORMAL);
            queryWrapper.eq("org_id", getOrgId(request));
            queryWrapper.eq("house_id", id);
            List<TaPreselectionRecord> taPreselectionRecords = taPreselectionRecordService.list(queryWrapper);
            if (taPreselectionRecords.size() > 0) {
                return ResponseBean.error("存在预选房源不能删除！", ResponseBean.ERROR_UNAVAILABLE);
            }
            TaHousingResources taHousingResources = new TaHousingResources();
            taHousingResources.setHouseId(id);
            taHousingResources.setStatus(CommConstant.STATUS_DELETE);
            if (iTaHousingResourcesService.updateById(taHousingResources)) {
                //删除房号
                TaHousingResources housingResources = iTaHousingResourcesService.getById(id);
                TaBuildingRoom taBuildingRoom = new TaBuildingRoom();
                taBuildingRoom.setRoomId(housingResources.getRoomId());
                taBuildingRoom.setStatus(CommConstant.STATUS_DELETE);
                taBuildingRoomService.updateById(taBuildingRoom);
                responseBean.addSuccess("success");
            } else {
                responseBean.addError("fail");
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesDelete -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 修改对象
     *
     * @param id                 实体ID
     * @param taHousingResources 实体对象
     * @return
     */
    @RequestMapping(value = "/admin/taHousingResources/{id}", method = RequestMethod.PUT)
    public ResponseBean taHousingResourcesUpdate(@PathVariable Integer id,
                                                 @RequestBody TaHousingResources taHousingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            taHousingResources.setHouseId(id);
            taHousingResources.setUpdateUser(getUserId(request));
            taHousingResources.setOrgId(getOrgId(request));
            responseBean = iTaHousingResourcesService.updateHouseResources(taHousingResources);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 修改户型
     */
    @RequestMapping(value = "/admin/house/changeApartment", method = RequestMethod.PUT)
    public ResponseBean houseApartment(@RequestBody TaHousingResources taHousingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            List<TaHousingResources> houseIdList = taHousingResources.getHouseIdList();
            houseIdList.forEach(e -> {
                e.setApartmentId(taHousingResources.getApartmentId());
            });
            iTaHousingResourcesService.updateBatchById(houseIdList);
            responseBean.addSuccess(houseIdList);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 根据id查询对象
     *
     * @param id 实体ID
     */
    @RequestMapping(value = "/admin/taHousingResources/{id}", method = RequestMethod.GET)
    public ResponseBean taHousingResourcesGet(@PathVariable Integer id) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean.addSuccess(iTaHousingResourcesService.getById(id));
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesDelete -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 获取房源列表
     *
     * @param salesBatchId 销售批次ID
     * @param startPrice   房源起始价格
     * @param endPrice     房源结束价格
     * @param apartmentId  户型ID
     * @param source       来源，raiseChoose 为认筹添加房源来源
     * @param request
     * @return
     * @author gushaoyong
     */
    @RequestMapping(value = "/wx/listHousingResources", method = RequestMethod.GET)
    public ResponseBean listHousingResources(@RequestParam(value = "salesBatchId") String salesBatchId,
                                             String startPrice, String endPrice, String apartmentId, @RequestParam(value = "source", required = false) String source,
                                             HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        Integer orgId = getOrgId(request);
        String openid = getOpenId(request);
        String personId = getPersonId(request);
        List<TaPerson> persons = iTaPersonService.getPersonsByOpenId(openid);
        if (null == persons || persons.size() == 0) {
            return ResponseBean.error("当前账户信息异常, 清除缓存重试", ResponseBean.ERROR_UNAVAILABLE);
        }
        TaPerson person = persons.get(0);
        logger.info("TaHouseingResourcesController.listHousingResources 接收参数：orgId：{},salesBatchId：{},startPrice：{},endPrice：{},apartmentId：{},source:{}",
                orgId, salesBatchId, startPrice, endPrice, apartmentId, source);

        try {
            // 查询批次下认筹是否开启邀请制
            QueryWrapper<TaRaise> taRaiseQueryWrapper = new QueryWrapper<>();
            taRaiseQueryWrapper.eq("org_id", orgId);
            taRaiseQueryWrapper.eq("sales_batch_id", salesBatchId);
            taRaiseQueryWrapper.eq("status", CommConstant.STATUS_NORMAL);
            TaRaise taRaise = iTaRaiseService.getOne(taRaiseQueryWrapper);

            if (null != taRaise && CommConstant.STATUS_NORMAL == taRaise.getInvite()) {
                // 若开启邀请制，校验该用户是否在邀请列表中
                QueryWrapper<TaRaiseInvite> taRaiseInviteQueryWrapper = new QueryWrapper<>();
                taRaiseInviteQueryWrapper.eq("org_id", orgId);
                taRaiseInviteQueryWrapper.eq("invite_tel", person.getPhone());
                taRaiseInviteQueryWrapper.eq("sales_batch_id", salesBatchId);
                TaRaiseInvite taRaiseInvite = iTaRaiseInviteService.getOne(taRaiseInviteQueryWrapper);
                if (null == taRaiseInvite) {
                    return ResponseBean.error("仅限被邀请用户查看房源",ResponseBean.ERROR_ILLEGAL_PARAMS);
                }
            }
            //获取所有楼房的预选热度和认筹热度
            List<TaHousingResourcesPO> taHousingResourcesPOList = iTaHousingResourcesService.listHousingResources(orgId, salesBatchId, startPrice, endPrice, apartmentId, personId, source);
            //此处处理我的预选，我的认筹，和我的锁定
            //我的预选记录
            QueryWrapper<TaPreselectionRecord> taPreselectionRecordQueryWrapper = new QueryWrapper<>();
            taPreselectionRecordQueryWrapper.eq("org_id", orgId);
            taPreselectionRecordQueryWrapper.eq("sales_batch_id", salesBatchId);
            taPreselectionRecordQueryWrapper.eq("person_id", getPersonId(request));
            taPreselectionRecordQueryWrapper.eq("status", CommConstant.STATUS_NORMAL);
            List<TaPreselectionRecord> taPreselectionRecordList = taPreselectionRecordService.list(taPreselectionRecordQueryWrapper);
            //我的认筹记录
            QueryWrapper<TaRaiseRecord> taRaiseRecordQueryWrapper = new QueryWrapper<>();
            taRaiseRecordQueryWrapper.eq("org_id", orgId);
            taRaiseRecordQueryWrapper.eq("sales_batch_id", salesBatchId);
            taRaiseRecordQueryWrapper.eq("person_id", getPersonId(request));
            taRaiseRecordQueryWrapper.eq("status", CommConstant.STATUS_NORMAL);
            List<TaRaiseRecord> taRaiseRecordList = taRaiseRecordService.list(taRaiseRecordQueryWrapper);

            //认筹记录对应的有效房源,我的锁定的房源也在里面
            List<TaRaiseHouse> taRaiseHouseList = new ArrayList<>();
            if (taRaiseRecordList.size() > 0){
                QueryWrapper<TaRaiseHouse> taRaiseHouseQueryWrapper = new QueryWrapper<>();
                taRaiseHouseQueryWrapper.in("raise_record_id", taRaiseRecordList.stream().map(TaRaiseRecord::getRaiseRecordId).collect(Collectors.toList()));
                taRaiseHouseList = taRaiseHouseService.list(taRaiseHouseQueryWrapper);
            }
            List<TaRaiseHouse> finalTaRaiseHouseList = taRaiseHouseList;

            TaSalesBatch taSalesBatch = taSalesBatchService.getById(salesBatchId);
            taHousingResourcesPOList.forEach(e -> {
                taPreselectionRecordList.forEach(p -> {
                    //我的预选
                    if (e.getHouseId().equals(p.getHouseId())) {
                        e.setMinePreselection("mine");
                    }
                });
                //我的认筹和锁定
                if (CollectionUtils.isNotEmpty(taRaiseRecordList)) {
                    finalTaRaiseHouseList.forEach(r -> {
                        //我的认筹
                        if (e.getHouseId().equals(r.getHouseId())) {
                            e.setMineRaise("mine");
                            if (CommConstant.HOUSE_LOCKING_STATUS_LOCKED.equals(e.getHouseLockingStatus()) && personId.equals(e.getHouseLockingPerson())) {
                                e.setMineLocked("mine");
                            }
                        }
                    });
                }


                //塞入户型信息
                if (!StringUtils.isEmpty(e.getApartmentId())) {
                    TaBuildingApartment buildingApartment = taBuildingApartmentService.getById(e.getApartmentId());
                    e.setApartmentName(buildingApartment.getApartmentName());
                    e.setInsideArea(buildingApartment.getInsideArea());
                    e.setBuildingArea(buildingApartment.getBuildingArea());
                    //塞入户型图信息
                    List<String> apartMentIds = new ArrayList<>();
                    apartMentIds.add(e.getApartmentId());
                    List<TaBuildingImg> apartMentList = taBuildingImgService.getAparemnetList(apartMentIds);
                    e.setApartmentImgList(apartMentList);
                }

                e.setDisplayHousePrice(taSalesBatch.getDisplayHousePrice());
            });

            responseBean.addSuccess(taHousingResourcesPOList);
        } catch (Exception e) {
            logger.error("listHousingResources -=- {}", e);
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 获取房源列表-后台管理端
     *
     * @param salesBatchId 销售批次ID
     * @return
     * @author gushaoyong
     */
    @RequestMapping(value = "/admin/listHousingResources", method = RequestMethod.GET)
    public ResponseBean listHousingResourcesFormCms(@RequestParam(value = "salesBatchId") String salesBatchId,
                                                    HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        Integer orgId = getOrgId(request);
        try {
            responseBean.addSuccess(iTaHousingResourcesService.listHousingResourcesForCms(orgId, salesBatchId, "", "", "", 0));
        } catch (Exception e) {
            logger.error("listHousingResourcesFormCms -=- {}", e);
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 获取某销售批次下所有房源户型
     *
     * @param salesBatchId
     * @return
     * @author gushaoyong
     */
    @RequestMapping(value = "/wx/listBuildApartmentBySalesBatchId", method = RequestMethod.GET)
    public ResponseBean listBuildApartmentBySalesBatchId(@RequestParam(value = "salesBatchId") String salesBatchId) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean.addSuccess(iTaHousingResourcesService.listBuildApartmentBySalesBatchId(salesBatchId));
        } catch (Exception e) {
            logger.error("listBuildApartmentBySalesBatchId -=- {}", e);
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 根据房源ID获取房源详情
     *
     * @param houseId
     * @return
     * @author gushaoyong
     */
    @RequestMapping(value = "/wx/getHousingDetailById", method = RequestMethod.GET)
    public ResponseBean getHousingDetailById(@RequestParam(value = "houseId") Integer houseId,
                                             @RequestParam(value = "personId") String personId) {
        ResponseBean responseBean = new ResponseBean();
        try {
            TaHousingResourcesPO taHousingResourcesPO = iTaHousingResourcesService.getHousingDetailById(personId, houseId);
            if (taHousingResourcesPO.getStatus() != null && taHousingResourcesPO.getStatus() == CommConstant.STATUS_NORMAL) {
                responseBean.addSuccess(taHousingResourcesPO);
                return responseBean;
            }
            responseBean.addError("当前房源已下架");
        } catch (Exception e) {
            logger.error("根据房源ID获取房源详情 -=- {}", e);
            return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_ILLEGAL_PARAMS);
        }
        return responseBean;
    }


    /**
     * 校验房源是否合格
     *
     * @return
     */
    @RequestMapping(value = "/admin/house/checked", method = RequestMethod.PUT)
    public ResponseBean houseChecked(@RequestBody TaHousingResources taHousingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            taHousingResources.setOrgId(getOrgId(request));
            StringBuffer result = iTaHousingResourcesService.checked(taHousingResources);
            responseBean.addSuccess(result);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    @PostMapping(value = "/admin/house/uploadExcel")
    public ResponseBean uploadExcel(@RequestParam("file") MultipartFile file,
                                    @RequestParam("salesBatchId") Integer salesBatchId,
                                    @RequestParam("buildingId") String buildingId,
                                    HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean = iTaHousingResourcesService.getExcelData(file, salesBatchId, buildingId, getOrgId(request));
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
            responseBean.addError("请检查文件");
        }
        return responseBean;
    }

    @PostMapping(value = "/admin/house/saveExcelValue", consumes = "multipart/*", headers = "content-type=multipart/form-data")
    public ResponseBean saveExcelValue(@RequestParam("file") MultipartFile file,
                                       @RequestParam("salesBatchId") Integer salesBatchId,
                                       @RequestParam("buildingId") String buildingId,
                                       HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean = iTaHousingResourcesService.saveExcelValue(file, salesBatchId, buildingId, getOrgId(request));
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
            responseBean.addError("请检查文件");
        }
        return responseBean;
    }

    /**
     * 批量更新房源认筹基础热度
     *
     * @param housingResources
     * @param request
     * @return
     */
    @RequestMapping(value = "/admin/house/batchUpdateRaiseHeat", method = RequestMethod.PUT)
    public ResponseBean batchUpdateRaiseHeat(@RequestBody TaHousingResources housingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            // 校验认筹热度
            if (housingResources.getRaiseHeat() == null || housingResources.getRaiseHeat() < 0) {
                responseBean.addError("基础热度需大于等于0");
                return responseBean;
            }

            responseBean = iTaHousingResourcesService.batchUpdateRaiseHeat(housingResources.getHouseIdList(), housingResources.getRaiseHeat(),
                    housingResources.getSalesBatchId(), getOrgId(request), getUserId(request));
        } catch (Exception e) {
            logger.error("batchUpdateRaiseHeat -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 批量更新房源预选基础热度
     *
     * @param housingResources
     * @param request
     * @return
     */
    @RequestMapping(value = "/admin/house/batchUpdateHeat", method = RequestMethod.PUT)
    public ResponseBean batchUpdateHeat(@RequestBody TaHousingResources housingResources, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            // 校验认筹热度
            if (housingResources.getHeat() == null || housingResources.getHeat() < 0) {
                responseBean.addError("基础热度需大于等于0");
                return responseBean;
            }

            responseBean = iTaHousingResourcesService.batchUpdateHeat(housingResources.getHouseIdList(), housingResources.getHeat(),
                    housingResources.getSalesBatchId(), getOrgId(request), getUserId(request));
        } catch (Exception e) {
            logger.error("batchUpdateRaiseHeat -=- {}", e.toString());
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 根据认筹记录查询房源列表
     *
     * @param pageNumber
     * @param pageSize
     * @param raiseRecordId
     * @param request
     * @return
     */
    @RequestMapping(value = "/admin/house/listHouseByRaiseRecordId", method = RequestMethod.GET)
    public ResponseBean listHouseByRaiseRecordId(@RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                 @RequestParam(value = "raiseRecordId") Integer raiseRecordId,
                                                 HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean = iTaHousingResourcesService.listHouseByRaiseRecordId(raiseRecordId, getOrgId(request), pageNumber, pageSize);
            logger.info("listHouseByRaiseRecordId 返回结果：", JSONObject.toJSONString(responseBean));
        } catch (Exception e) {
            logger.error("listHouseByRaiseRecordId 异常：", e);
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }


    /**
     * 更新房源锁定状态
     *
     * @param houseId
     * @param type         修改类型：lock为锁定房源，unlock为解锁房源
     * @param raiseHouseId 认筹房源关系表ID, 接口‘/admin/house/listHouseByRaiseRecordId’ 有返回
     * @param request
     * @return
     */
    @RequestMapping(value = "/admin/house/updateLockingStatus", method = RequestMethod.PUT)
    public ResponseBean updateLockingStatus(Integer houseId, String type, Integer raiseHouseId, String personId, Integer raiseRecordId,
                                            HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            responseBean = iTaHousingResourcesService.updateLockingStatus(houseId, type, getOrgId(request), raiseHouseId, personId, raiseRecordId,getUserId(request));
            logger.info("updateLockingStatus 返回结果：", JSONObject.toJSONString(responseBean));
        } catch (Exception e) {
            logger.error("updateLockingStatus 异常：", e);
            responseBean.addError(e.getMessage());
        }
        return responseBean;
    }

    /**
     * 校验房源认筹状态
     *
     * @return
     */
    @RequestMapping(value = "/wx/check/raise", method = RequestMethod.GET)
    public ResponseBean checkRaise(@RequestParam(value = "houseIds") String houseIds, HttpServletRequest request) {
        ResponseBean responseBean = new ResponseBean();
        try {
            boolean state = iTaHousingResourcesService.checkRaiseState(houseIds, getPersonId(request), getOrgId(request));
            responseBean.addSuccess(state);
        } catch (Exception e) {
            logger.error("校验房源状态 -=- {}", e.getMessage());
            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_MISSING_PARAMS);
        }
        return responseBean;
    }
}
