LAPTOP-FO2T5SIU\35838 11 月之前
父节点
当前提交
7cd741f892

+ 1 - 1
pro-base/src/main/java/com/idea/buildManage/controller/ParkRoomController.java

@@ -108,7 +108,7 @@ public class ParkRoomController extends BaseController {
     @PostMapping(value = "getById", produces = {"application/json;charset=UTF-8"})
     @ResponseBody
     public ParkRoom getById(String id) {
-        return modelService.selectByPrimaryKey(id);
+        return modelService.getById(id);
     }
 
     @ApiOperation(value = "房间列表分页")

+ 36 - 0
pro-base/src/main/java/com/idea/customerManagement/excel/TempContractExcel.java

@@ -0,0 +1,36 @@
+package com.idea.customerManagement.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class TempContractExcel {
+
+    @ExcelProperty(value = "楼栋")
+    private String buildName;
+
+    @ExcelProperty(value = "户号")
+    private String roomNo;
+
+    @ExcelProperty(value = "原编号")
+    private String oldRoomSelectionNumber;
+
+    @ExcelProperty(value = "合同编号")
+    private String contractNumber;
+
+    @ExcelProperty(value = "合同时间")
+    private String signingDate;
+
+    @ExcelProperty(value = "合同金额")
+    private String contractAmount;
+
+    @ExcelProperty(value = "房款存入账号开户行")
+    private String bankName;
+
+    @ExcelProperty(value = "房款存入账号")
+    private String bankNumber;
+
+    @ExcelProperty(value = "付款方式")
+    private String paymentMethod;
+
+}

+ 57 - 0
pro-base/src/main/java/com/idea/customerManagement/excel/TempCusExcel.java

@@ -0,0 +1,57 @@
+package com.idea.customerManagement.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class TempCusExcel {
+
+    @ExcelProperty(value = "楼栋")
+    private String buildName;
+
+    @ExcelProperty(value = "户号")
+    private String roomNo;
+
+    @ExcelProperty(value = "选房时间")
+    private String roomSelectionDate;
+
+    @ExcelProperty(value = "原编号")
+    private String oldRoomSelectionNumber;
+
+    @ExcelProperty(value = "低收入编号")
+    private String roomSelectionNumber;
+
+    @ExcelProperty(value = "买受人1")
+    private String buyerName1;
+
+    @ExcelProperty(value = "买受人1身份证")
+    private String identityCard1;
+
+    @ExcelProperty(value = "买受人1手机号")
+    private String phone1;
+
+    @ExcelProperty(value = "买受人2")
+    private String buyerName2;
+
+    @ExcelProperty(value = "买受人2身份证")
+    private String identityCard2;
+
+    @ExcelProperty(value = "买受人2手机号")
+    private String phone2;
+
+    @ExcelProperty(value = "买受人3")
+    private String buyerName3;
+
+    @ExcelProperty(value = "买受人3身份证")
+    private String identityCard3;
+
+    @ExcelProperty(value = "买受人4")
+    private String buyerName4;
+
+    @ExcelProperty(value = "买受人4身份证")
+    private String identityCard4;
+
+
+
+
+}

+ 3 - 2
pro-base/src/main/java/com/idea/customerManagement/mapper/CustomerManagementExtendMapper.java

@@ -1,5 +1,6 @@
 package com.idea.customerManagement.mapper;
 
+import com.idea.buildManage.model.ParkRoom;
 import com.idea.customerManagement.dto.CustomerManagementDto;
 import com.idea.customerManagement.model.CustomerManagement;
 import com.idea.customerManagement.model.CustomerManagementExample;
@@ -13,8 +14,8 @@ public interface CustomerManagementExtendMapper {
 
     List<CustomerManagementDto> selectNeedSendList();
 
+    CustomerManagement getByNum(String num);
 
-
-
+    ParkRoom getByBuildHouseName(String buildName, String roomNo);
 
 }

+ 247 - 6
pro-base/src/main/java/com/idea/customerManagement/service/CustomerManagementService.java

@@ -12,22 +12,22 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.idea.buildManage.excel.MnpBuildingExcel;
-import com.idea.buildManage.excel.ParkRoomExcel;
 import com.idea.buildManage.excel.WriteHandlerStrategy;
 import com.idea.buildManage.mapper.ParkFloorDiscMapper;
 import com.idea.buildManage.mapper.ParkInfoMapper;
 import com.idea.buildManage.mapper.ParkRoomMapper;
 import com.idea.buildManage.model.ParkFloorDisc;
 import com.idea.buildManage.model.ParkInfo;
-import com.idea.buildManage.model.ParkInfoExample;
 import com.idea.buildManage.model.ParkRoom;
 import com.idea.buildManage.response.ParkRoomResponse;
 import com.idea.buildManage.service.ParkFloorDiscService;
 import com.idea.buildManage.service.ParkInfoService;
+import com.idea.buildManage.service.ParkRoomService;
 import com.idea.customerManagement.dto.CustomerManagementDto;
-import com.idea.customerManagement.dto.RoomSelectionInfoDto;
 import com.idea.customerManagement.excel.CustomerManagementExcel;
+import com.idea.customerManagement.excel.TempContractExcel;
+import com.idea.customerManagement.excel.TempCusExcel;
+import com.idea.customerManagement.mapper.ContractManageMapper;
 import com.idea.customerManagement.mapper.CustomerManagementExtendMapper;
 import com.idea.customerManagement.mapper.CustomerManagementMapper;
 import com.idea.customerManagement.mapper.RoomSelectionInfoMapper;
@@ -51,7 +51,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
@@ -61,7 +60,6 @@ import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -92,6 +90,13 @@ public class CustomerManagementService implements BaseService<CustomerManagement
     private IntentionalDepositService intentionalDepositService;
     @Autowired
     private ParkFloorDiscMapper parkFloorDiscMapper;
+    @Autowired
+    private RoomSelectionInfoService roomSelectionInfoService;
+    @Autowired
+    private ParkRoomService parkRoomService;
+    @Autowired
+    private ContractManageService contractManageService;
+
 
     @Override
     public int deleteByPrimaryKey(String s) {
@@ -1036,4 +1041,240 @@ public class CustomerManagementService implements BaseService<CustomerManagement
         return extendMapper.selectNeedSendList();
     }
 
+
+    /**
+     * 更新客户基础信息
+     * @param file
+     * @throws IOException
+     */
+    public void tempCusUpdate(MultipartFile file) throws IOException {
+
+        // 读取excel
+        ExcelUtils excelUtils = new ExcelUtils();
+        List<TempCusExcel> list = excelUtils.excelImport(file.getInputStream(), TempCusExcel.class,1);
+        for(TempCusExcel excel : list){
+            System.out.println("excel信息" + excel.toString());
+
+            Buyer buyer1 = new Buyer();
+            Buyer buyer2 = new Buyer();
+            Buyer buyer3 = new Buyer();
+            Buyer buyer4 = new Buyer();
+
+
+            String number = excel.getRoomSelectionNumber();
+            String[] split = number.split("批");
+            String batchNumber = split[0].replace("第", "");
+            String roomSelectionNumber = split[1].replace("号", "");
+            StringBuilder buyerNameBuilder = new StringBuilder();
+            StringBuilder idCardBuilder = new StringBuilder();
+
+            CustomerManagement customerManagement = extendMapper.getByNum(excel.getOldRoomSelectionNumber());
+            List<Buyer> buyers = new ArrayList<>();
+
+            // 拼接买受人名称
+            if(StringUtils.isNotEmpty(excel.getBuyerName1())){
+                buyerNameBuilder.append(excel.getBuyerName1()).append(",");
+
+                buyer1.setCustomerManagementId(customerManagement.getId());
+                buyer1.setName(excel.getBuyerName1());
+                buyer1.setIdentityCard(excel.getIdentityCard1());
+                buyer1.setPhone(excel.getPhone1());
+                buyer1.setOrderNum(1);
+                buyers.add(buyer1);
+            }
+            if(StringUtils.isNotEmpty(excel.getBuyerName2())){
+                buyerNameBuilder.append(excel.getBuyerName2()).append(",");
+
+                buyer2.setCustomerManagementId(customerManagement.getId());
+                buyer2.setName(excel.getBuyerName2());
+                buyer2.setIdentityCard(excel.getIdentityCard2());
+                buyer2.setPhone(excel.getPhone2());
+                buyer2.setOrderNum(2);
+                buyers.add(buyer2);
+            }
+            if(StringUtils.isNotEmpty(excel.getBuyerName3())){
+                buyerNameBuilder.append(excel.getBuyerName3()).append(",");
+
+                buyer3.setCustomerManagementId(customerManagement.getId());
+                buyer3.setName(excel.getBuyerName3());
+                buyer3.setIdentityCard(excel.getIdentityCard3());
+                buyer3.setOrderNum(3);
+                buyers.add(buyer3);
+            }
+            if(StringUtils.isNotEmpty(excel.getBuyerName4())){
+                buyerNameBuilder.append(excel.getBuyerName4()).append(",");
+
+                buyer4.setCustomerManagementId(customerManagement.getId());
+                buyer4.setName(excel.getBuyerName4());
+                buyer4.setIdentityCard(excel.getIdentityCard4());
+                buyer4.setOrderNum(4);
+                buyers.add(buyer4);
+            }
+
+            // 拼接 身份证
+            if(StringUtils.isNotEmpty(excel.getIdentityCard1())){
+                idCardBuilder.append(excel.getIdentityCard1()).append(",");
+            }
+            if(StringUtils.isNotEmpty(excel.getIdentityCard2())){
+                idCardBuilder.append(excel.getIdentityCard2()).append(",");
+            }
+            if(StringUtils.isNotEmpty(excel.getIdentityCard3())){
+                idCardBuilder.append(excel.getIdentityCard3()).append(",");
+            }
+            if(StringUtils.isNotEmpty(excel.getIdentityCard4())){
+                idCardBuilder.append(excel.getIdentityCard4()).append(",");
+            }
+
+            if(buyerNameBuilder.length()>1){
+                buyerNameBuilder.deleteCharAt(buyerNameBuilder.length()-1);
+            }
+            if(idCardBuilder.length()>1){
+                idCardBuilder.deleteCharAt(idCardBuilder.length()-1);
+            }
+
+
+            customerManagement.setBatchNumber(batchNumber);
+            customerManagement.setRoomSelectionNumber(roomSelectionNumber);
+            customerManagement.setBuyerName(buyerNameBuilder.toString());
+            customerManagement.setBuyerIdentityCard(idCardBuilder.toString());
+            updateByPrimaryKeySelective(customerManagement);
+
+            for(Buyer buyer: buyers){
+                buyerService.insertSelective(buyer);
+            }
+
+
+        }
+
+    }
+
+    /**
+     * 客户选房信息
+     * @param file
+     * @throws IOException
+     */
+    public void tempCusUpdate2(MultipartFile file) throws IOException {
+
+        // 读取excel
+        ExcelUtils excelUtils = new ExcelUtils();
+        List<TempCusExcel> list = excelUtils.excelImport(file.getInputStream(), TempCusExcel.class,"需要新增的选房信息",1);
+        for(TempCusExcel excel : list){
+            System.out.println("excel信息" + excel.toString());
+
+            // 原编号
+            String oldRoomSelectionNumber = excel.getOldRoomSelectionNumber();
+            String roomSelectionDate = excel.getRoomSelectionDate();
+            Date date = DateUtils.parseDate(roomSelectionDate);
+
+            CustomerManagement customerManagement = extendMapper.getByNum(oldRoomSelectionNumber);
+            customerManagement.setRoomSelectionDate(date);
+            updateByPrimaryKeySelective(customerManagement);
+
+            String buildName = excel.getBuildName();
+            String roomNo = excel.getRoomNo();
+            ParkRoom room = extendMapper.getByBuildHouseName(buildName, roomNo);
+
+            // 选房
+            roomSelectionInfoService.submit(room.getId(),customerManagement.getId(),"1");
+
+        }
+
+    }
+
+
+    public void tempContractUpdate(MultipartFile file) throws IOException {
+
+        // 读取excel
+        ExcelUtils excelUtils = new ExcelUtils();
+        List<TempContractExcel> list = excelUtils.excelImport(file.getInputStream(), TempContractExcel.class,"需要新增的合同信息",1);
+        for(TempContractExcel excel : list){
+            System.out.println("excel信息" + excel.toString());
+
+            // 原编号
+            String oldRoomSelectionNumber = excel.getOldRoomSelectionNumber();
+            // 客户信息
+            CustomerManagement customerManagement = extendMapper.getByNum(oldRoomSelectionNumber);
+            // 已签约
+            customerManagement.setStatus(3);
+            updateByPrimaryKeySelective(customerManagement);
+
+            String buildName = excel.getBuildName();
+            String roomNo = excel.getRoomNo();
+            ParkRoom parkRoom = extendMapper.getByBuildHouseName(buildName, roomNo);
+            ParkFloorDisc parkFloorDisc = parkFloorDiscMapper.selectByPrimaryKey(parkRoom.getDiscId());
+
+            String signingDateStr = excel.getSigningDate();
+            // 签约日期
+            Date signingDate = DateUtils.parseDate(signingDateStr);
+            String contractAmountStr = excel.getContractAmount();
+            BigDecimal contractAmount = new BigDecimal(contractAmountStr);
+            BigDecimal roomArea = new BigDecimal(parkRoom.getActualBuildArea() + "");
+            BigDecimal housePrice = contractAmount.divide(roomArea, 2, BigDecimal.ROUND_HALF_UP);
+
+            // 合同新增
+            ContractManage contractManage = new ContractManage();
+            contractManage.setContractNumber(excel.getContractNumber());
+            contractManage.setSigningDate(signingDate);
+            contractManage.setTotalPrice(contractAmount);
+            contractManage.setHousePrice(housePrice);
+            contractManage.setBankName(excel.getBankName());
+            contractManage.setBankNumber(excel.getBankNumber());
+            if(excel.getPaymentMethod().equals("贷款")){
+                contractManage.setPaymentMethod(2);
+            }else if(excel.getPaymentMethod().equals("一次性付款")){
+                contractManage.setPaymentMethod(1);
+            }
+
+            contractManage.setId(IdUtil.simpleUUID());
+            contractManage.setCustomerManagementId(customerManagement.getId());
+            contractManage.setHouseId(parkRoom.getId());
+//            contractManage.setSubscriptionFunds(roomSelectionInfo.getReceivableMoney());
+            contractManage.setActualBuildArea(parkRoom.getActualBuildArea());
+            contractManage.setActualInternalArea(parkRoom.getActualInternalArea());
+            contractManage.setActualShareArea(parkRoom.getActualShareArea());
+            contractManage.setMaintenanceFunds(parkFloorDisc.getMaintenanceFunds());
+            if(parkFloorDisc.getMaintenanceFunds() != null){
+                BigDecimal area = new BigDecimal(parkRoom.getActualBuildArea().toString());
+                contractManage.setMaintenanceTotalPrice(parkFloorDisc.getMaintenanceFunds().multiply(area));
+            }
+            contractManage.setContractStatus(1);
+            contractManage.setFundCollectionStatus(1);
+            contractManage.setCreatedAt(new Date());
+            contractManage.setCreatedId("1");
+
+            // 拼接买受人名称
+            BuyerExample buyerExample = new BuyerExample();
+            buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagement.getId());
+            List<Buyer> buyers = buyerService.selectByExample(buyerExample);
+            StringBuilder builder = new StringBuilder();
+            for(Buyer buyer : buyers){
+                if(buyer.getOrderNum() == 1){
+                    builder.append(buyer.getName()).append(",");
+                }else {
+                    String dictLabel = sysDictService.getDictLabel("RELATIONSHIP", buyer.getRelationship());
+                    builder.append(buyer.getName())
+                            .append("(")
+                            .append(dictLabel)
+                            .append(")")
+                            .append(",");
+                }
+            }
+            if(builder.length() > 0){
+                builder.deleteCharAt(builder.length()-1);
+            }
+            contractManage.setBuyerName(builder.toString());
+
+            ParkRoomResponse response = parkRoomService.getFullName(parkRoom.getId());
+            String fullName = response.getGroupName() + "-" +
+                    response.getDiscName() + "-" +
+                    response.getBuildName() + "-" +
+                    response.getRoomNo();
+            contractManage.setHouseName(fullName);
+            int result = contractManageService.insertWithoutId(contractManage);
+
+
+        }
+
+    }
+
 }

+ 3 - 3
pro-base/src/main/java/com/idea/customerManagement/service/RoomSelectionInfoService.java

@@ -150,9 +150,9 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
     public int submit(String houseIds, String customerManagementId, String userId) {
 
         ParkRoom originRoom = parkRoomMapper.selectByPrimaryKey(houseIds);
-        if(originRoom.getIsChoose() == 1){
-            throw new RuntimeException("该房间已被选择!!!");
-        }
+//        if(originRoom.getIsChoose() == 1){
+//            throw new RuntimeException("该房间已被选择!!!");
+//        }
         
         String groupId = "";
         String discId = "";

+ 2 - 2
pro-base/src/main/java/com/idea/util/ExcelUtils.java

@@ -69,8 +69,8 @@ public class ExcelUtils<E> {
      * @param sheetName   读取表格的名称
      * @return
      */
-    public List<E> excelImport(InputStream inputStream, Class<?> clazz, String sheetName) {
-        return EasyExcel.read(inputStream).head(clazz).sheet(sheetName).doReadSync();
+    public List<E> excelImport(InputStream inputStream, Class<?> clazz, String sheetName, int headRowNumber) {
+        return EasyExcel.read(inputStream).headRowNumber(headRowNumber).head(clazz).sheet(sheetName).doReadSync();
     }
 
     public File multipartFileToFile(MultipartFile file) throws Exception {

+ 19 - 0
pro-base/src/main/resources/mybatis/customerManagement/CustomerManagementExtendMapper.xml

@@ -61,4 +61,23 @@
       left join buyer b on c.id = b.customer_management_id and b.order_num = 1
       where c.ncid is null or c.ncid = ''
     </select>
+
+    <select id="getByNum" resultType="com.idea.customerManagement.model.CustomerManagement">
+      select * from customer_management where old_room_selection_number = #{num}
+    </select>
+
+    <select id="getByBuildHouseName" resultType="com.idea.buildManage.model.ParkRoom">
+      SELECT
+        r.*
+      FROM
+        park_room r
+          LEFT JOIN mnp_building b ON b.id = r.build_id
+          LEFT JOIN park_floor_disc d ON d.id = r.disc_id
+          LEFT JOIN park_info p ON p.id = r.group_id
+      WHERE
+        p.group_name = '惠景家园'
+        AND d.NAME = '二期'
+        AND build_num = #{buildName}
+        AND room_no = #{roomNo}
+    </select>
 </mapper>

+ 8 - 2
pro-wx/src/main/java/com/idea/pro/wx/controller/buildManage/WxParkRoomController.java

@@ -11,6 +11,7 @@ import com.idea.buildManage.service.MnpBuildingService;
 import com.idea.buildManage.service.ParkFloorDiscService;
 import com.idea.buildManage.service.ParkInfoService;
 import com.idea.buildManage.service.ParkRoomService;
+import com.idea.customerManagement.service.CustomerManagementService;
 import com.idea.customerManagement.service.IntentionalDepositService;
 import com.idea.invoice.task.InvoiceTask;
 import com.idea.paymentManagement.service.PayLogService;
@@ -62,6 +63,8 @@ public class WxParkRoomController extends BaseController {
 
     @Autowired
     private InvoiceTask invoiceTask;
+    @Autowired
+    private CustomerManagementService customerManagementService;
 
 
     @PostMapping(value = "list", produces = {"application/json;charset=UTF-8"})
@@ -190,12 +193,15 @@ public class WxParkRoomController extends BaseController {
 
     @PostMapping(value = "test")
     @ResponseBody
-    public AjaxResult test(String id){
+    public AjaxResult test(MultipartFile file) throws IOException {
 //        payLogService.sendVoucher(id);
 //        intentionalDepositService.sendToDepositVoucher(id);
 //        List<Map<String, String>> dictList = sysDictService.selectDictList("CONTENT_TYPE");
 //        invoiceTask.sendBuild();
-        invoiceTask.sendHouse();
+//        invoiceTask.sendHouse();
+//        customerManagementService.tempCusUpdate(file);
+//        customerManagementService.tempCusUpdate2(file);
+        customerManagementService.tempContractUpdate(file);
         return success();
     }