LAPTOP-GC5B4H2B\35838 6 months ago
parent
commit
62e24a5d0a

+ 10 - 1
pro-base/src/main/java/com/idea/customerManagement/dto/CustomerManagementDto.java

@@ -3,6 +3,7 @@ package com.idea.customerManagement.dto;
 import com.idea.customerManagement.model.CustomerManagement;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Data
@@ -29,11 +30,19 @@ public class CustomerManagementDto extends CustomerManagement {
 
     private String statusStr;
 
-    private String intentionalDepositStatus;
+    /**
+     * 意向金收取状态
+     */
+    private int intentionalDepositStatus;
 
     /**
      * 是否已交认购金
      */
     private int roomSelectionCount;
 
+    /**
+     * 意向金余额
+     */
+    private BigDecimal intentionalDepositMoney;
+
 }

+ 2 - 0
pro-base/src/main/java/com/idea/customerManagement/dto/RoomSelectionInfoDto.java

@@ -53,4 +53,6 @@ public class RoomSelectionInfoDto extends RoomSelectionInfo {
 
     private String statusStr;
 
+    private String intentionalDepositId;
+
 }

+ 15 - 1
pro-base/src/main/java/com/idea/customerManagement/service/CustomerManagementService.java

@@ -47,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -385,12 +386,25 @@ public class CustomerManagementService implements BaseService<CustomerManagement
             String name = frameUser == null ? "" : frameUser.getTruename();
             result.setAbandonmentName(name);
         }
+
+        BigDecimal intentionalDepositMoney = BigDecimal.ZERO;
+        // 默认意向金 未收取
+        int intentionalDepositStatus = 0;
         IntentionalDepositExample intentionalDepositExample = new IntentionalDepositExample();
         intentionalDepositExample.createCriteria().andCustomerManagementIdEqualTo(id);
         List<IntentionalDeposit> intentionalDeposits = intentionalDepositService.selectByExample(intentionalDepositExample);
         if(CollectionUtils.isNotEmpty(intentionalDeposits)){
-            result.setIntentionalDepositStatus(intentionalDeposits.get(0).getStatus().toString());
+            IntentionalDeposit intentionalDeposit = intentionalDeposits.get(0);
+            intentionalDepositStatus = intentionalDeposit.getStatus();
+            // 已收取
+            if(intentionalDeposit.getStatus() == 1){
+                intentionalDepositMoney = intentionalDeposit.getReceivedAmount();
+            }
         }
+        result.setIntentionalDepositMoney(intentionalDepositMoney);
+        result.setIntentionalDepositStatus(intentionalDepositStatus);
+
+
         RoomSelectionInfoExample roomSelectionInfoExample = new RoomSelectionInfoExample();
         roomSelectionInfoExample.createCriteria().andCustomerManagementIdEqualTo(id);
         long count = roomSelectionInfoMapper.countByExample(roomSelectionInfoExample);

+ 51 - 27
pro-base/src/main/java/com/idea/customerManagement/service/IntentionalDepositService.java

@@ -248,6 +248,7 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         payLog.setHouseId(null);
         payLog.setContractId(null);
         payLog.setCustomerManagementId(model.getCustomerManagementId());
+        payLog.setBusinessId(id);
         // 收款类型 预收款
         payLog.setPayType(1);
         // 款项内容 意向金
@@ -366,15 +367,8 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         if (StringUtils.isEmpty(uerId)){
             uerId = ShiroUtils.getUserId();
         }
-        String roomSelectionInfoId = IdUtil.simpleUUID();
-
-        // 转定金
-        model.setStatus(2);
-        model.setHandleId(ShiroUtils.getUserId());
-        model.setHandleDate(new Date());
-        model.setRoomSelectionInfoId(roomSelectionInfoId);
-        int result = modelMapper.updateByPrimaryKeySelective(model);
-
+        String roomSelectionInfoId;
+        RoomSelectionInfo roomSelectionInfo;
         String houseId = model.getHouseId();
         String customerManagementId = model.getCustomerManagementId();
 
@@ -393,24 +387,48 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         customerManagement.setHouseName(builder.toString());
         customerManagementMapper.updateByPrimaryKeySelective(customerManagement);
 
-        // 新增选房信息
-        RoomSelectionInfo roomSelectionInfo = new RoomSelectionInfo();
-        roomSelectionInfo.setId(roomSelectionInfoId);
-        roomSelectionInfo.setCustomerManagementId(customerManagementId);
-        roomSelectionInfo.setHouseId(response.getId());
-        roomSelectionInfo.setBuildId(response.getBuildId());
-        roomSelectionInfo.setDiscId(response.getDiscId());
-        roomSelectionInfo.setGroupId(response.getGroupId());
-        roomSelectionInfo.setCreatedAt(new Date());
-        roomSelectionInfo.setCreatedId(ShiroUtils.getUserId());
-        roomSelectionInfo.setReceivableMoney(model.getReceivableMoney());
-        roomSelectionInfo.setReceivedAmount(model.getReceivedAmount());
-        // 收取状态 意向金转入
-        roomSelectionInfo.setStatus(3);
-        roomSelectionInfo.setSerialNumber(model.getDepositSerialNumber());
-        roomSelectionInfo.setPaymentMethod(model.getPaymentMethod());
-        roomSelectionInfo.setCollectionTime(model.getCollectionTime());
-        roomSelectionInfoMapper.insertSelective(roomSelectionInfo);
+        RoomSelectionInfoExample roomSelectionInfoExample = new RoomSelectionInfoExample();
+        roomSelectionInfoExample.createCriteria().andCustomerManagementIdEqualTo(customerManagementId);
+        List<RoomSelectionInfo> list = roomSelectionInfoMapper.selectByExample(roomSelectionInfoExample);
+        // 已选房的情况
+        if (CollectionUtils.isNotEmpty(list)) {
+            roomSelectionInfo = list.get(0);
+            roomSelectionInfoId = roomSelectionInfo.getId();
+            roomSelectionInfo.setCustomerManagementId(customerManagementId);
+            roomSelectionInfo.setHouseId(response.getId());
+            roomSelectionInfo.setBuildId(response.getBuildId());
+            roomSelectionInfo.setDiscId(response.getDiscId());
+            roomSelectionInfo.setGroupId(response.getGroupId());
+            roomSelectionInfo.setReceivableMoney(model.getReceivableMoney());
+            roomSelectionInfo.setReceivedAmount(model.getReceivedAmount());
+            // 收取状态 意向金转入
+            roomSelectionInfo.setStatus(3);
+            roomSelectionInfo.setSerialNumber(model.getDepositSerialNumber());
+            roomSelectionInfo.setPaymentMethod(model.getPaymentMethod());
+            roomSelectionInfo.setCollectionTime(model.getCollectionTime());
+            roomSelectionInfoMapper.updateByPrimaryKeySelective(roomSelectionInfo);
+        }else {
+            roomSelectionInfoId = IdUtil.simpleUUID();
+            // 新增选房信息
+            roomSelectionInfo = new RoomSelectionInfo();
+            roomSelectionInfo.setId(roomSelectionInfoId);
+            roomSelectionInfo.setCustomerManagementId(customerManagementId);
+            roomSelectionInfo.setHouseId(response.getId());
+            roomSelectionInfo.setBuildId(response.getBuildId());
+            roomSelectionInfo.setDiscId(response.getDiscId());
+            roomSelectionInfo.setGroupId(response.getGroupId());
+            roomSelectionInfo.setCreatedAt(new Date());
+            roomSelectionInfo.setCreatedId(ShiroUtils.getUserId());
+            roomSelectionInfo.setReceivableMoney(model.getReceivableMoney());
+            roomSelectionInfo.setReceivedAmount(model.getReceivedAmount());
+            // 收取状态 意向金转入
+            roomSelectionInfo.setStatus(3);
+            roomSelectionInfo.setSerialNumber(model.getDepositSerialNumber());
+            roomSelectionInfo.setPaymentMethod(model.getPaymentMethod());
+            roomSelectionInfo.setCollectionTime(model.getCollectionTime());
+            roomSelectionInfoMapper.insertSelective(roomSelectionInfo);
+        }
+
 
         // 转定金后生成合同
         String contractId = IdUtil.simpleUUID();
@@ -484,6 +502,12 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
             receiptManageService.updateByPrimaryKeySelective(manage);
         }
 
+        // 转定金
+        model.setStatus(2);
+        model.setHandleId(ShiroUtils.getUserId());
+        model.setHandleDate(new Date());
+        model.setRoomSelectionInfoId(roomSelectionInfoId);
+        int result = modelMapper.updateByPrimaryKeySelective(model);
 
         return result;
 

+ 4 - 1
pro-base/src/main/resources/mybatis/customerManagement/RoomSelectionInfoExtendMapper.xml

@@ -9,11 +9,14 @@
            park_room.actual_internal_area,
            park_room.actual_build_area,
            park_room.decoration_situation,
-           frame_user.truename createdName
+           frame_user.truename createdName,
+           customer_management.buyer_name,
+           (select id from intentional_deposit where customer_management_id = room_selection_info.customer_management_id) as intentional_deposit_id
            from room_selection_info
     left join mnp_building on mnp_building.id = room_selection_info.build_id
     left join park_room on park_room.id = room_selection_info.house_id
     left join frame_user on frame_user.id = room_selection_info.created_id
+    left join customer_management on customer_management.id = room_selection_info.customer_management_id
     <where>
         <if test="customerManagementId !=null and customerManagementId != ''">
             and room_selection_info.customer_management_id = #{customerManagementId}