java110 лет назад: 5
Родитель
Сommit
4b39c963de

+ 38 - 0
java110-bean/src/main/java/com/java110/dto/rentingAppointment/RentingAppointmentDto.java

@@ -16,12 +16,14 @@ import java.util.Date;
 public class RentingAppointmentDto extends PageDto implements Serializable {
 
     public static final String STATE_SUBMIT = "1001";//提交
+    public static final String STATE_SUCCESS = "3003";//租房成功
 
     private String msg;
     private String tenantTel;
     private String tenantName;
     private String appointmentTime;
     private String appointmentRoomId;
+    private String appointmentRoomName;
     private String appointmentId;
     private String remark;
     private String state;
@@ -29,8 +31,12 @@ public class RentingAppointmentDto extends PageDto implements Serializable {
     private String tenantSex;
     private String storeId;
     private String roomId;
+    private String roomName;
     private String rentingId;
 
+    private String appointmentCommunityId;
+    private String communityId;
+
 
     private Date createTime;
 
@@ -157,4 +163,36 @@ public class RentingAppointmentDto extends PageDto implements Serializable {
     public void setRentingId(String rentingId) {
         this.rentingId = rentingId;
     }
+
+    public String getAppointmentRoomName() {
+        return appointmentRoomName;
+    }
+
+    public void setAppointmentRoomName(String appointmentRoomName) {
+        this.appointmentRoomName = appointmentRoomName;
+    }
+
+    public String getRoomName() {
+        return roomName;
+    }
+
+    public void setRoomName(String roomName) {
+        this.roomName = roomName;
+    }
+
+    public String getAppointmentCommunityId() {
+        return appointmentCommunityId;
+    }
+
+    public void setAppointmentCommunityId(String appointmentCommunityId) {
+        this.appointmentCommunityId = appointmentCommunityId;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
 }

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/rentingPoolFlow/RentingPoolFlowDto.java

@@ -18,6 +18,7 @@ public class RentingPoolFlowDto extends PageDto implements Serializable {
     public static final String STATE_SUBMIT = "1001";
     public static final String STATE_PROXY_TRUE = "2002";
     public static final String STATE_PROXY_FALSE = "3003";
+    public static final String STATE_CONFIRM_RENTING = "4004"; // 租客确定租房
 
 
     private String dealTime;

+ 1 - 0
java110-bean/src/main/java/com/java110/po/rentingAppointment/RentingAppointmentPo.java

@@ -18,6 +18,7 @@ public class RentingAppointmentPo implements Serializable {
     private String roomId;
     private String rentingId;
 
+
     public String getMsg() {
         return msg;
     }

+ 3 - 1
java110-db/src/main/resources/mapper/user/RentingAppointmentServiceDaoImplMapper.xml

@@ -23,9 +23,11 @@
         tenantName,t.appointment_time,t.appointment_time appointmentTime,t.appointment_room_id,t.appointment_room_id
         appointmentRoomId,t.appointment_id,t.appointment_id appointmentId,t.remark,t.status_cd,t.status_cd
         statusCd,t.state,t.tenant_sex,t.tenant_sex tenantSex,t.store_id,t.store_id storeId,t.room_id,t.room_id roomId,
-        td.`name` stateName,t.renting_id rentingId
+        td.`name` stateName,t.renting_id rentingId,rp.community_id appointmentCommunityId,rpr.community_id communityId
         from renting_appointment t
         LEFT JOIN t_dict td on t.state=td.status_cd and td.table_columns = 'state' and td.table_name = 'renting_appointment'
+        LEFT JOIN renting_pool rp on t.appointment_room_id = rp.room_id and rp.status_cd = '0'
+        left join renting_pool rpr on t.renting_id = rpr.renting_id and rpr.status_cd = '0'
         where 1 =1
         <if test="msg !=null and msg != ''">
             and t.msg= #{msg}

+ 25 - 4
service-user/src/main/java/com/java110/user/api/RentingAppointmentApi.java

@@ -3,10 +3,7 @@ package com.java110.user.api;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.dto.rentingAppointment.RentingAppointmentDto;
 import com.java110.po.rentingAppointment.RentingAppointmentPo;
-import com.java110.user.bmo.rentingAppointment.IDeleteRentingAppointmentBMO;
-import com.java110.user.bmo.rentingAppointment.IGetRentingAppointmentBMO;
-import com.java110.user.bmo.rentingAppointment.ISaveRentingAppointmentBMO;
-import com.java110.user.bmo.rentingAppointment.IUpdateRentingAppointmentBMO;
+import com.java110.user.bmo.rentingAppointment.*;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +29,9 @@ public class RentingAppointmentApi {
     @Autowired
     private IGetRentingAppointmentBMO getRentingAppointmentBMOImpl;
 
+    @Autowired
+    private IConfirmRentingBMO confirmRentingBMOImpl;
+
     /**
      * 微信保存消息模板
      *
@@ -121,4 +121,25 @@ public class RentingAppointmentApi {
         rentingAppointmentDto.setTenantTel(tenantTel);
         return getRentingAppointmentBMOImpl.get(rentingAppointmentDto);
     }
+
+
+    /**
+     * 确认租房
+     *
+     * @param reqJson
+     * @return
+     * @serviceCode /rentingAppointment/confirmRenting
+     * @path /app/rentingAppointment/confirmRenting
+     */
+    @RequestMapping(value = "/confirmRenting", method = RequestMethod.POST)
+    public ResponseEntity<String> confirmRenting(@RequestBody JSONObject reqJson) {
+
+        Assert.hasKeyAndValue(reqJson, "appointmentId", "appointmentId不能为空");
+        Assert.hasKeyAndValue(reqJson, "rentingId", "rentingId不能为空");
+
+        RentingAppointmentPo rentingAppointmentPo = BeanConvertUtil.covertBean(reqJson, RentingAppointmentPo.class);
+        return confirmRentingBMOImpl.confirm(rentingAppointmentPo);
+    }
+
+
 }

+ 17 - 0
service-user/src/main/java/com/java110/user/bmo/rentingAppointment/IConfirmRentingBMO.java

@@ -0,0 +1,17 @@
+package com.java110.user.bmo.rentingAppointment;
+import com.java110.po.rentingAppointment.RentingAppointmentPo;
+import org.springframework.http.ResponseEntity;
+
+public interface IConfirmRentingBMO {
+
+
+    /**
+     * 确认出租
+     * add by wuxw
+     * @param rentingAppointmentPo
+     * @return
+     */
+    ResponseEntity<String> confirm(RentingAppointmentPo rentingAppointmentPo);
+
+
+}

+ 93 - 0
service-user/src/main/java/com/java110/user/bmo/rentingAppointment/impl/ConfirmRentingBMOImpl.java

@@ -0,0 +1,93 @@
+package com.java110.user.bmo.rentingAppointment.impl;
+
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.rentingAppointment.RentingAppointmentDto;
+import com.java110.dto.rentingPool.RentingPoolDto;
+import com.java110.dto.rentingPoolFlow.RentingPoolFlowDto;
+import com.java110.intf.IRentingAppointmentInnerServiceSMO;
+import com.java110.intf.IRentingPoolFlowInnerServiceSMO;
+import com.java110.intf.user.IRentingPoolInnerServiceSMO;
+import com.java110.po.rentingAppointment.RentingAppointmentPo;
+import com.java110.po.rentingPool.RentingPoolPo;
+import com.java110.po.rentingPoolFlow.RentingPoolFlowPo;
+import com.java110.user.bmo.rentingAppointment.IConfirmRentingBMO;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service("confirmRentingBMOImpl")
+public class ConfirmRentingBMOImpl implements IConfirmRentingBMO {
+
+    @Autowired
+    private IRentingAppointmentInnerServiceSMO rentingAppointmentInnerServiceSMOImpl;
+
+    @Autowired
+    private IRentingPoolInnerServiceSMO rentingPoolInnerServiceSMOImpl;
+
+
+    @Autowired
+    private IRentingPoolFlowInnerServiceSMO rentingPoolFlowInnerServiceSMOImpl;
+
+    /**
+     * @param rentingAppointmentPo
+     * @return 订单服务能够接受的报文
+     */
+    @Java110Transactional
+    public ResponseEntity<String> confirm(RentingAppointmentPo rentingAppointmentPo) {
+
+        //查询 预约数据 校验
+        RentingAppointmentDto rentingAppointmentDto = new RentingAppointmentDto();
+        rentingAppointmentDto.setAppointmentId(rentingAppointmentPo.getAppointmentId());
+        List<RentingAppointmentDto> rentingAppointmentDtos = rentingAppointmentInnerServiceSMOImpl.queryRentingAppointments(rentingAppointmentDto);
+
+        Assert.listOnlyOne(rentingAppointmentDtos, "未找到预约信息");
+
+        //校验 房源信息
+        RentingPoolDto rentingPoolDto = new RentingPoolDto();
+        rentingPoolDto.setRentingId(rentingAppointmentPo.getRentingId());
+        List<RentingPoolDto> rentingPoolDtos = rentingPoolInnerServiceSMOImpl.queryRentingPools(rentingPoolDto);
+
+        Assert.listOnlyOne(rentingPoolDtos, "未找到房源信息");
+
+        //预约数据修改 租房成功
+        rentingAppointmentPo.setState(RentingAppointmentDto.STATE_SUCCESS);
+        rentingAppointmentPo.setRoomId(rentingPoolDtos.get(0).getRoomId());
+        int flag = rentingAppointmentInnerServiceSMOImpl.updateRentingAppointment(rentingAppointmentPo);
+
+        if (flag < 1) {
+            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+        }
+        //房源状态修改 待支付
+        RentingPoolPo rentingPoolPo = new RentingPoolPo();
+        rentingPoolPo.setRentingId(rentingPoolDtos.get(0).getRentingId());
+        rentingPoolPo.setState(RentingPoolDto.STATE_TO_PAY);
+        flag = rentingPoolInnerServiceSMOImpl.updateRentingPool(rentingPoolPo);
+        if (flag < 1) {
+            throw new IllegalArgumentException("修改房屋状态失败");
+        }
+
+        //流程中插入租客信息
+        RentingPoolFlowPo rentingPoolFlowPo = new RentingPoolFlowPo();
+        rentingPoolFlowPo.setUserTel(rentingAppointmentDtos.get(0).getTenantTel());
+        rentingPoolFlowPo.setUseName(rentingAppointmentDtos.get(0).getTenantName());
+        rentingPoolFlowPo.setUserRole("2"); //租客
+        rentingPoolFlowPo.setState(RentingPoolFlowDto.STATE_CONFIRM_RENTING);
+        rentingPoolFlowPo.setRentingId(rentingAppointmentPo.getRentingId());
+        rentingPoolFlowPo.setDealTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        rentingPoolFlowPo.setFlowId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_flowId));
+        rentingPoolFlowPo.setContext("确认租房");
+        rentingPoolFlowPo.setCommunityId(rentingPoolDtos.get(0).getCommunityId());
+        flag = rentingPoolFlowInnerServiceSMOImpl.saveRentingPoolFlow(rentingPoolFlowPo);
+        if (flag < 1) {
+            throw new IllegalArgumentException("修改房屋状态失败");
+        }
+        return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
+    }
+
+}

+ 110 - 0
service-user/src/main/java/com/java110/user/bmo/rentingAppointment/impl/GetRentingAppointmentBMOImpl.java

@@ -1,16 +1,21 @@
 package com.java110.user.bmo.rentingAppointment.impl;
 
+import com.java110.dto.RoomDto;
 import com.java110.dto.rentingAppointment.RentingAppointmentDto;
 import com.java110.intf.IRentingAppointmentInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.user.bmo.rentingAppointment.IGetRentingAppointmentBMO;
 import com.java110.vo.ResultVo;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service("getRentingAppointmentBMOImpl")
 public class GetRentingAppointmentBMOImpl implements IGetRentingAppointmentBMO {
@@ -18,6 +23,10 @@ public class GetRentingAppointmentBMOImpl implements IGetRentingAppointmentBMO {
     @Autowired
     private IRentingAppointmentInnerServiceSMO rentingAppointmentInnerServiceSMOImpl;
 
+
+    @Autowired
+    private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+
     /**
      * @param rentingAppointmentDto
      * @return 订单服务能够接受的报文
@@ -30,6 +39,8 @@ public class GetRentingAppointmentBMOImpl implements IGetRentingAppointmentBMO {
         List<RentingAppointmentDto> rentingAppointmentDtos = null;
         if (count > 0) {
             rentingAppointmentDtos = rentingAppointmentInnerServiceSMOImpl.queryRentingAppointments(rentingAppointmentDto);
+
+            refreshEveryRoom(rentingAppointmentDtos);
         } else {
             rentingAppointmentDtos = new ArrayList<>();
         }
@@ -41,4 +52,103 @@ public class GetRentingAppointmentBMOImpl implements IGetRentingAppointmentBMO {
         return responseEntity;
     }
 
+    private void refreshRoom(List<RentingAppointmentDto> rentingAppointmentDtos) {
+
+        List<String> roomIds = new ArrayList<>();
+
+        for (RentingAppointmentDto rentingAppointmentDto : rentingAppointmentDtos) {
+            if (!StringUtils.isEmpty(rentingAppointmentDto.getAppointmentRoomId())) {
+                roomIds.add(rentingAppointmentDto.getAppointmentRoomId());
+            }
+
+            if (!StringUtils.isEmpty(rentingAppointmentDto.getRoomId())) {
+                roomIds.add(rentingAppointmentDto.getAppointmentRoomId());
+            }
+        }
+
+        RoomDto roomDto = new RoomDto();
+        roomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
+        List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
+
+
+        for (RoomDto tmpRoomDto : roomDtos) {
+            for (RentingAppointmentDto rentingAppointmentDto : rentingAppointmentDtos) {
+                if (tmpRoomDto.getRoomId().equals(rentingAppointmentDto.getAppointmentRoomId())) {
+                    rentingAppointmentDto.setAppointmentRoomName(tmpRoomDto.getFloorNum() + "栋" + tmpRoomDto.getUnitNum() + "单元" + tmpRoomDto.getRoomNum() + "室");
+                }
+
+                if (tmpRoomDto.getRoomId().equals(rentingAppointmentDto.getRoomId())) {
+                    rentingAppointmentDto.setRoomName(tmpRoomDto.getFloorNum() + "栋" + tmpRoomDto.getUnitNum() + "单元" + tmpRoomDto.getRoomNum() + "室");
+                }
+            }
+        }
+
+    }
+
+    private void refreshEveryRoom(List<RentingAppointmentDto> rentingAppointmentDtos) {
+
+        List<Map> roomInfos = new ArrayList<>();
+
+        Map room = null;
+        for (RentingAppointmentDto rentingAppointmentDto : rentingAppointmentDtos) {
+            if (!StringUtils.isEmpty(rentingAppointmentDto.getAppointmentRoomId()) && !StringUtils.isEmpty(rentingAppointmentDto.getAppointmentCommunityId())) {
+                room = new HashMap();
+                room.put("roomId", rentingAppointmentDto.getAppointmentRoomId());
+                room.put("communityId", rentingAppointmentDto.getAppointmentCommunityId());
+                roomInfos.add(room);
+            }
+            if (!StringUtils.isEmpty(rentingAppointmentDto.getRoomId())&&!StringUtils.isEmpty(rentingAppointmentDto.getCommunityId())) {
+                room = new HashMap();
+                room.put("roomId", rentingAppointmentDto.getRoomId());
+                room.put("communityId", rentingAppointmentDto.getCommunityId());
+                roomInfos.add(room);
+            }
+        }
+
+        if (roomInfos.size() < 1) {
+            return;
+        }
+        List<Map> newRoomInfos = new ArrayList<>();
+        Boolean hasRoom = false;
+        for (Map roomMap : roomInfos) {
+            hasRoom = false;
+            for (Map newRoomInfo : newRoomInfos) {
+                if (roomMap.get("roomId").equals(newRoomInfo.get("roomId"))) {
+                    hasRoom = true;
+                    break;
+                }
+            }
+            if (!hasRoom) {
+                newRoomInfos.add(roomMap);
+            }
+        }
+        RoomDto roomDto = new RoomDto();
+        for (Map newRoomInfo : newRoomInfos) {
+            roomDto.setRoomId(newRoomInfo.get("roomId").toString());
+            roomDto.setCommunityId(newRoomInfo.get("communityId").toString());
+            List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
+
+            if (roomDtos == null || roomDtos.size() < 1) {
+                continue;
+            }
+            RoomDto tmpRoomDto = roomDtos.get(0);
+            newRoomInfo.put("roomName", tmpRoomDto.getFloorNum() + "栋" + tmpRoomDto.getUnitNum() + "单元" + tmpRoomDto.getRoomNum() + "室");
+        }
+
+
+
+        for (Map newRoomInfo : newRoomInfos) {
+            for (RentingAppointmentDto rentingAppointmentDto : rentingAppointmentDtos) {
+                if (newRoomInfo.get("roomId").equals(rentingAppointmentDto.getAppointmentRoomId())) {
+                    rentingAppointmentDto.setAppointmentRoomName(newRoomInfo.get("roomName").toString());
+                }
+
+                if (newRoomInfo.get("roomId").equals(rentingAppointmentDto.getRoomId())) {
+                    rentingAppointmentDto.setRoomName(newRoomInfo.get("roomName").toString());
+                }
+            }
+        }
+
+    }
+
 }