Browse Source

feat(property): 新增合同签订功能

- 在 AContractInfo 模型中添加原合同和签订后合同的 URL 字段
- 更新 AContractInfoMapper 映射文件,增加新字段的映射- 实现合同签订逻辑,包括创建租户信息和更新房屋状态
- 优化合同数据填充逻辑,支持不同类型合同的处理
nahida 10 months ago
parent
commit
dc6ac9d22c

+ 16 - 5
src/main/java/com/zksy/property/domain/AContractInfo.java

@@ -4,15 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
 
 /**
  * 合同信息表
@@ -72,6 +71,18 @@ public class AContractInfo implements Serializable {
     @ApiModelProperty("合同状态")
     private String contractStatus;
 
+    /**
+     * 原合同
+     */
+    @ApiModelProperty("原合同")
+    private String originalContractUrl;
+
+    /**
+     * 签订后合同
+     */
+    @ApiModelProperty("签订后合同")
+    private String signContractUrl;
+
     /**
      * 创建时间
      */

+ 33 - 7
src/main/java/com/zksy/property/service/impl/AContractInfoServiceImpl.java

@@ -7,18 +7,20 @@ 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;
 import com.zksy.property.mapper.AContractInfoMapper;
-import com.zksy.property.service.AContractInfoService;
-import com.zksy.property.service.AHouseInfoDetailService;
-import com.zksy.property.service.ARentalContractService;
-import com.zksy.property.service.ASimplifiedHouseInfoService;
+import com.zksy.property.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -33,6 +35,8 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
     @Autowired
     @Lazy
     private ASimplifiedHouseInfoService aSimplifiedHouseInfoService;
+    @Autowired
+    private ATenantInfoService aTenantInfoService;
 
     @Override
     public Page<AContractInfo> findByPage(long pageNum, long pageSize, String contractNumber, String contractDate, String contractStatus) {
@@ -67,23 +71,45 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
     private AHouseInfoDetailService aHouseInfoDetailService;
 
     @Override
+    @Transactional
     public String signContract(ContractFormDTO dto) {
         AHouseInfoDetail houseInfoDetail = aHouseInfoDetailService.getBySimplifiedHouseId(dto.getHouseId());
         ASimplifiedHouseInfo aSimplifiedHouseInfo = aSimplifiedHouseInfoService.getById(dto.getHouseId());
+
+        if (!"空闲".equals(aSimplifiedHouseInfo.getStatus())) {
+            throw new RuntimeException("此房屋已存在合同");
+        }
+
         Contract baseContract = ContractFactory.createContract(aSimplifiedHouseInfo.getAssetType());
         BeanUtil.copyProperties(dto.getContractData(), baseContract);
         RentalTempBo bo = new RentalTempBo();
         var resPath = "";
         if (baseContract instanceof ContractA) {
-            processContractA((ContractA) baseContract,aSimplifiedHouseInfo,houseInfoDetail, bo);
+            processContractA((ContractA) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
             resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
         } else if (baseContract instanceof ContractB) {
-            processContractB((ContractB) baseContract,aSimplifiedHouseInfo,houseInfoDetail, bo);
+            processContractB((ContractB) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
             resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
         } else if (baseContract instanceof ContractC) {
             processContractC((ContractC) baseContract, bo);
             resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
         }
+
+        aSimplifiedHouseInfo.setStatus("已租");
+        aSimplifiedHouseInfoService.updateById(aSimplifiedHouseInfo);
+
+        ATenantInfo aTenantInfo = new ATenantInfo();
+        aTenantInfo.setTenantName(dto.getRentalInfo().getRentalName());
+        aTenantInfo.setTenantNumber(dto.getRentalInfo().getRentalPhone());
+        aTenantInfo.setTenantIdCard(dto.getRentalInfo().getRentalIdCard());
+        aTenantInfo.setTenantInDate(LocalDate.parse(dto.getRentalInfo().getRentalTimeStart()));
+        aTenantInfo.setTenantTime(dto.getRentalInfo().getRentalTime());
+        aTenantInfo.setTenantRent(new BigDecimal(dto.getRentalInfo().getRentalRect()));
+        aTenantInfo.setSimplifiedHouseId(dto.getHouseId());
+        aTenantInfo.setCreateTime(LocalDateTime.now());
+        aTenantInfo.setUpdateTime(LocalDateTime.now());
+        aTenantInfoService.save(aTenantInfo);
+
         return resPath;
     }
 
@@ -119,7 +145,7 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
         bo.setC27("");
     }
 
-    private static void processContractB(ContractB baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo,RentalTempBo bo) {
+    private static void processContractB(ContractB baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo, RentalTempBo bo) {
         ContractB contractB = baseContract;
         //todo 处理bo
         bo.setB1(contractB.getPurpose());

+ 3 - 1
src/main/resources/mapper/property/AContractInfoMapper.xml

@@ -13,6 +13,8 @@
             <result property="contractExpirationDate" column="contract_expiration_date" jdbcType="DATE"/>
             <result property="contractDeposit" column="contract_deposit" jdbcType="DECIMAL"/>
             <result property="contractStatus" column="contract_status" jdbcType="VARCHAR"/>
+            <result property="originalContractUrl" column="original_contract_url" jdbcType="VARCHAR"/>
+            <result property="signContractUrl" column="sign_contract_url" jdbcType="VARCHAR"/>
             <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
             <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
     </resultMap>
@@ -20,7 +22,7 @@
     <sql id="Base_Column_List">
         id,simplified_house_id,contract_number,
         contract_date,contract_time,contract_expiration_date,
-        contract_deposit,contract_status,create_time,
+        contract_deposit,contract_status,original_contract_url,sign_contract_url,create_time,
         update_time
     </sql>
 </mapper>