ソースを参照

feat(property): 添加退租功能并优化相关服务

- 在 AContractInfoController 中添加退租接口- 在 AContractInfoService 接口中定义退租方法
- 实现 AContractInfoServiceImpl 中的退租逻辑
- 优化获取合同信息的查询条件
- 更新房屋信息和租户信息的相关服务- 调整房屋状态和合同状态
nahida 10 ヶ月 前
コミット
d0954deaf4

+ 6 - 0
src/main/java/com/zksy/controller/property/AContractInfoController.java

@@ -69,4 +69,10 @@ public class AContractInfoController {
         return AjaxResult.success(service.signContract(dto));
     }
 
+    @GetMapping("/returnRent")
+    @ApiOperation(value = "退租")
+    public AjaxResult returnRent(String houseId) {
+        return AjaxResult.success(service.returnRent(houseId));
+    }
+
 }

+ 1 - 0
src/main/java/com/zksy/property/domain/vo/HouseInfoVo.java

@@ -11,6 +11,7 @@ import java.util.List;
 @NoArgsConstructor
 @AllArgsConstructor
 public class HouseInfoVo {
+    private String assetType;
     private String houseName;//房间名称 (A栋101)
     private String address;//地址
     private String status ;//状态 (未租/已租)

+ 2 - 0
src/main/java/com/zksy/property/service/AContractInfoService.java

@@ -19,4 +19,6 @@ public interface AContractInfoService extends IService<AContractInfo> {
     AContractInfo getBySimplifiedHouseId(String simplifiedHouseId);
 
     String signContract(ContractFormDTO dto);
+
+    String returnRent(String houseId);
 }

+ 26 - 3
src/main/java/com/zksy/property/service/impl/AContractInfoServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zksy.property.domain.AContractInfo;
 import com.zksy.property.domain.AHouseInfoDetail;
 import com.zksy.property.domain.ASimplifiedHouseInfo;
+import com.zksy.property.domain.ATenantInfo;
 import com.zksy.property.domain.bo.*;
 import com.zksy.property.domain.dto.ContractFormDTO;
 import com.zksy.property.factory.ContractFactory;
@@ -32,6 +33,27 @@ import static com.zksy.utils.util.generateAssetNumber;
 @Service
 public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, AContractInfo>
         implements AContractInfoService {
+    @Override
+    public String returnRent(String houseId) {
+        ASimplifiedHouseInfo houseInfo = aSimplifiedHouseInfoService.getById(houseId);
+        if(houseInfo.getStatus().equals("空闲")){
+            throw new RuntimeException("此房屋未出租");
+        }
+        AContractInfo contractInfo = this.getBySimplifiedHouseId(houseId);
+        if(contractInfo == null){
+            throw new RuntimeException("数据不存在");
+        }
+        houseInfo.setStatus("空闲");
+        //删除租户信息
+        ATenantInfo tenantInfo = aTenantInfoService.getBySimplifiedHouseId(houseId);
+        if(tenantInfo != null){
+            aTenantInfoService.removeById(tenantInfo);
+        }
+        aSimplifiedHouseInfoService.updateById(houseInfo);
+        contractInfo.setContractStatus("已退租");
+        this.updateById(contractInfo);
+        return "退租成功";
+    }
 
     @Autowired
     @Lazy
@@ -65,6 +87,7 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
     public AContractInfo getBySimplifiedHouseId(String simplifiedHouseId) {
         LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AContractInfo::getSimplifiedHouseId, simplifiedHouseId);
+        queryWrapper.eq(AContractInfo::getContractStatus, "有效");
         return this.getOne(queryWrapper);
     }
 
@@ -138,7 +161,7 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
             this.save(contractInfo);
         }
 
-        /*aSimplifiedHouseInfo.setStatus("已租");
+        aSimplifiedHouseInfo.setStatus("已租");
         aSimplifiedHouseInfoService.updateById(aSimplifiedHouseInfo);
 
         ATenantInfo aTenantInfo = new ATenantInfo();
@@ -151,9 +174,9 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
         aTenantInfo.setSimplifiedHouseId(dto.getHouseId());
         aTenantInfo.setCreateTime(LocalDateTime.now());
         aTenantInfo.setUpdateTime(LocalDateTime.now());
-        aTenantInfoService.save(aTenantInfo);*/
+        aTenantInfoService.save(aTenantInfo);
 
-        return resPath;
+        return "签约成功";
     }
 
     private static void processContractC(ContractC baseContract, RentalTempBo bo,String contractNumber) {

+ 2 - 1
src/main/java/com/zksy/property/service/impl/ASimplifiedHouseInfoServiceImpl.java

@@ -107,6 +107,7 @@ public class ASimplifiedHouseInfoServiceImpl extends ServiceImpl<ASimplifiedHous
         vo.setAddress(houseInfo.getAddress());
         vo.setStatus(houseInfo.getStatus());
         vo.setRentRange(houseInfo.getRentRange());
+        vo.setAssetType(houseInfo.getAssetType());
 
         // 设置房屋详细信息
         AHouseInfoDetail detail = aHouseInfoDetailService.getBySimplifiedHouseId(simplifiedHouseId);
@@ -230,7 +231,7 @@ public class ASimplifiedHouseInfoServiceImpl extends ServiceImpl<ASimplifiedHous
             contract.setContractExpirationDate(formatDate(contractInfo.getContractExpirationDate()));
             contract.setContractDeposit(contractInfo.getContractDeposit().toString());
             contract.setContractStatus(contractInfo.getContractStatus());
-            contract.setContractOriginalUrl(contractInfo.getSignContractUrl());
+            contract.setContractOriginalUrl(contractInfo.getOriginalContractUrl());
         }
 
         return contract;

+ 4 - 4
src/main/resources/application-dev.yml

@@ -49,7 +49,7 @@ knife4j:
         api-rule: package
         api-rule-resources:
           - com.zksy.controller
-logging:
-  level:
-    root: debug  # 设置全局日志级别为debug
-    com.zksy: debug  # 设置特定包的日志级别为debug
+#logging:
+#  level:
+#    root: debug  # 设置全局日志级别为debug
+#    com.zksy: debug  # 设置特定包的日志级别为debug