浏览代码

Merge remote-tracking branch 'origin/master'

zt 7 月之前
父节点
当前提交
26038f45e2

+ 32 - 4
pro-base/src/main/java/com/idea/customerManagement/controller/CustomerManagementController.java

@@ -1,9 +1,16 @@
 package com.idea.customerManagement.controller;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
+import com.idea.buildManage.excel.MnpBuildingExcel;
+import com.idea.buildManage.excel.MnpBuildingListener;
+import com.idea.buildManage.excel.ParkRoomExcel;
 import com.idea.customerManagement.dto.CustomerManagementDto;
 import com.idea.customerManagement.dto.RoomSelectionInfoDto;
+import com.idea.customerManagement.excel.CustomerManagementExcel;
 import com.idea.customerManagement.service.CustomerManagementService;
+import com.idea.util.ExcelUtils;
 import com.rockstar.common.base.BaseController;
 import com.rockstar.common.domain.AjaxResult;
 import com.rockstar.frame.model.extend.DateTrans;
@@ -12,14 +19,15 @@ import com.rockstar.frame.model.extend.Tablepar;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
 import java.util.Date;
+import java.util.List;
 
 @Controller
 @RequestMapping(value = "CustomerManagementController")
@@ -109,4 +117,24 @@ public class CustomerManagementController extends BaseController {
         modelService.downLoad(id,response);
     }
 
+    @PostMapping(value = "handleImport", produces = {"application/json;charset=UTF-8"})
+    @ResponseBody
+    public AjaxResult handleImport(@RequestParam("file") MultipartFile file) throws IOException {
+        JSONObject jsonObject = modelService.handleImport(file);
+        return AjaxResult.success(jsonObject);
+    }
+
+
+    /**
+     * 导出
+     * @param list
+     * @param response
+     * @throws IOException
+     */
+    @PostMapping(value = "errorListExport")
+    @ResponseBody
+    public void errorListExport(@RequestBody List<CustomerManagementExcel> list, HttpServletResponse response) throws IOException {
+        modelService.errorListExport(list,response);
+    }
+
 }

+ 55 - 0
pro-base/src/main/java/com/idea/customerManagement/excel/CustomerManagementExcel.java

@@ -0,0 +1,55 @@
+package com.idea.customerManagement.excel;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.idea.customerManagement.model.Buyer;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CustomerManagementExcel {
+
+    @ExcelProperty(value = "小区名称")
+    private String groupName;
+
+    @ExcelProperty(value = "分期名称")
+    private String discName;
+
+    @ExcelProperty(value = "选房日")
+    private String roomSelectionDate;
+
+    @ExcelProperty(value = "批次号")
+    private String batchNumber;
+
+    @ExcelProperty(value = "选房号")
+    private String roomSelectionNumber;
+
+    @ExcelProperty(value = "姓名")
+    private String buyerName;
+
+    @ExcelProperty(value = "身份证号")
+    private String identityCard;
+
+    @ExcelProperty(value = "手机号")
+    private String phone;
+
+    @ExcelProperty(value = "关系")
+    private String relationship;
+
+    @ExcelProperty(value = "顺序号")
+    private String orderNum;
+
+    @ExcelProperty(value = "失败原因")
+    private String reason;
+
+//    @ExcelIgnore
+//    private List<Buyer> buyers;
+
+    @ExcelIgnore
+    private String relationshipStr;
+
+
+
+
+}

+ 11 - 0
pro-base/src/main/java/com/idea/customerManagement/model/Buyer.java

@@ -28,6 +28,17 @@ public class Buyer implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    //非数据库字段
+    private String relationshipStr;
+
+    public String getRelationshipStr() {
+        return relationshipStr;
+    }
+
+    public void setRelationshipStr(String relationshipStr) {
+        this.relationshipStr = relationshipStr;
+    }
+
     public String getId() {
         return id;
     }

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

@@ -2,22 +2,30 @@ package com.idea.customerManagement.service;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.IdUtil;
+import com.alibaba.excel.EasyExcel;
 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.ParkInfoMapper;
 import com.idea.buildManage.mapper.ParkRoomMapper;
 import com.idea.buildManage.model.ParkInfo;
 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.customerManagement.dto.CustomerManagementDto;
 import com.idea.customerManagement.dto.RoomSelectionInfoDto;
+import com.idea.customerManagement.excel.CustomerManagementExcel;
 import com.idea.customerManagement.mapper.CustomerManagementExtendMapper;
 import com.idea.customerManagement.mapper.CustomerManagementMapper;
 import com.idea.customerManagement.mapper.RoomSelectionInfoMapper;
 import com.idea.customerManagement.model.*;
 import com.idea.util.DateUtils;
+import com.idea.util.ExcelUtils;
 import com.idea.util.ReplaceWord;
 import com.rockstar.common.base.BaseService;
 import com.rockstar.frame.model.FrameUser;
@@ -27,14 +35,20 @@ import com.rockstar.frame.service.FrameUserService;
 import com.rockstar.shiro.util.ShiroUtils;
 import com.rockstar.system.service.SysDictService;
 import com.rockstar.util.StringUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 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.IOException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
+@Slf4j
 @Service
 public class CustomerManagementService implements BaseService<CustomerManagement, CustomerManagementExample> {
 
@@ -55,6 +69,10 @@ public class CustomerManagementService implements BaseService<CustomerManagement
     private ParkRoomMapper parkRoomMapper;
     @Autowired
     private ParkInfoMapper parkInfoMapper;
+    @Autowired
+    private ParkFloorDiscService floorDiscService;
+    @Autowired
+    private ParkInfoService parkInfoService;
 
     @Override
     public int deleteByPrimaryKey(String s) {
@@ -335,6 +353,7 @@ public class CustomerManagementService implements BaseService<CustomerManagement
             Map<String, Object> data = new HashMap<>();
             Map<String, Object> picData = new HashMap<>();
             Map<String, Object> sealData = new HashMap<>();
+            Map<String, Object> settingData = new HashMap<>();
             data.put("${name}", name);
             data.put("${identityCard}", identityCard);
             data.put("${roomSelectionNumber}", roomSelectionNumber);
@@ -342,7 +361,7 @@ public class CustomerManagementService implements BaseService<CustomerManagement
             data.put("${month}", month);
             data.put("${date}", date);
             data.put("${region}", region);
-            ReplaceWord.operateWord(response,filePath,fileName,data, picData,sealData);
+            ReplaceWord.operateWord(response,filePath,fileName,data, picData,sealData,settingData);
         }
 
 
@@ -350,7 +369,275 @@ public class CustomerManagementService implements BaseService<CustomerManagement
 
     }
 
+    public JSONObject handleImport(MultipartFile file) throws IOException {
+
+        String userId = ShiroUtils.getUserId();
+        // 读取excel
+        ExcelUtils excelUtils = new ExcelUtils();
+        List<CustomerManagementExcel> list = excelUtils.excelImport(file.getInputStream(), CustomerManagementExcel.class);
+
+        Map<String, String> discNameIdMap = floorDiscService.getNameIdMap();
+        Map<String, String> parkNameIdMap = parkInfoService.getNameIdMap();
+        List<Map<String, String>> relationship = sysDictService.selectDictList("RELATIONSHIP");
+
+
+        List<CustomerManagementExcel> badList = new ArrayList<>();
+        int count;
+        JSONObject jsonObject = new JSONObject();
+
+        // 先校验
+        for(CustomerManagementExcel excel : list){
+
+            new CustomerManagement();
+
+            boolean groupNameFlag = true;
+            boolean discNameFlag = true;
+            boolean roomSelectionDateFlag = true;
+            boolean batchNumberFlag = true;
+            boolean roomSelectionNumberFlag = true;
+            boolean buyerNameFlag = true;
+            boolean identityCardFlag = true;
+            boolean phoneFlag = true;
+            boolean relationshipFlag = true;
+
+            StringBuilder builder = new StringBuilder();
+            try {
+
+                if (StringUtils.isEmpty(excel.getGroupName())) {
+                    groupNameFlag = false;
+                    builder.append("楼盘/小区名称为空").append(",");
+                    excel.setGroupName("{" + excel.getGroupName() + "}");
+                }
+
+                if (StringUtils.isEmpty(excel.getDiscName())) {
+                    discNameFlag = false;
+                    builder.append("楼分期名称为空").append(",");
+                    excel.setDiscName("{" + excel.getDiscName() + "}");
+                }
+
+                // 判断小区是否存在
+                if(StringUtils.isEmpty(parkNameIdMap.get(excel.getGroupName()))){
+                    groupNameFlag = false;
+                    builder.append("楼盘/小区不存在").append(",");
+                    excel.setGroupName("{" + excel.getGroupName() + "}");
+                }
+
+                // 判断分期是否存在
+                if(StringUtils.isEmpty(discNameIdMap.get(excel.getDiscName()))){
+                    discNameFlag = false;
+                    builder.append("分期不存在").append(",");
+                    excel.setDiscName("{" + excel.getDiscName() + "}");
+                }
+
+                if(StringUtils.isEmpty(excel.getRoomSelectionDate())){
+                    roomSelectionDateFlag = false;
+                    builder.append("选房日期为空").append(",");
+                    excel.setRoomSelectionDate("{" + excel.getRoomSelectionDate() + "}");
+                }else {
+                    try {
+                        Date date = DateUtils.parseDate(excel.getRoomSelectionDate(), "yyyy/MM/dd");
+                    }catch (Exception e){
+                        roomSelectionDateFlag = false;
+                        builder.append("选房日期格式有误").append(",");
+                        excel.setRoomSelectionDate("{" + excel.getRoomSelectionDate() + "}");
+                    }
+                }
+
+                if (StringUtils.isEmpty(excel.getBatchNumber())){
+                    batchNumberFlag = false;
+                    builder.append("批次号为空").append(",");
+                    excel.setBatchNumber("{" + excel.getBatchNumber() + "}");
+                }
+
+                if (StringUtils.isEmpty(excel.getRoomSelectionNumber())){
+                    roomSelectionNumberFlag = false;
+                    builder.append("选房号为空").append(",");
+                    excel.setRoomSelectionNumber("{" + excel.getRoomSelectionNumber() + "}");
+                }
+
+                if (StringUtils.isEmpty(excel.getBuyerName())){
+                    buyerNameFlag = false;
+                    builder.append("姓名为空").append(",");
+                    excel.setBuyerName("{" + excel.getBuyerName() + "}");
+                }
+
+                if (StringUtils.isEmpty(excel.getIdentityCard())){
+                    identityCardFlag = false;
+                    builder.append("身份证号为空").append(",");
+                    excel.setIdentityCard("{" + excel.getIdentityCard() + "}");
+                }else {
+                    if(!this.isIdentityCard(excel.getIdentityCard())){
+                        identityCardFlag = false;
+                        builder.append("身份证号格式有误").append(",");
+                        excel.setIdentityCard("{" + excel.getIdentityCard() + "}");
+                    }
+                }
+
+                if (StringUtils.isEmpty(excel.getPhone())){
+                    phoneFlag = false;
+                    builder.append("手机号为空").append(",");
+                    excel.setPhone("{" + excel.getPhone() + "}");
+                }else {
+                    if(!this.isPhone(excel.getPhone())){
+                        phoneFlag = false;
+                        builder.append("手机号格式有误").append(",");
+                        excel.setPhone("{" + excel.getPhone() + "}");
+                    }
+                }
+
+                // 关系
+                if (StringUtils.isNotEmpty(excel.getRelationship())) {
+                    for (Map<String, String> stringStringMap : relationship) {
+                        if (stringStringMap.get("label").equals(excel.getRelationship())) {
+                            excel.setRelationship(stringStringMap.get("value"));
+                            excel.setRelationshipStr(stringStringMap.get("label"));
+                        }
+                    }
+                    // 没匹配上的情况
+                    if (excel.getRelationship() == null) {
+                        relationshipFlag = false;
+                        builder.append("关系格式有误").append(",");
+                        excel.setRelationship("{" + excel.getRelationship() + "}");
+                    }
+                }
+
+
+                if (StringUtils.isEmpty(excel.getOrderNum())){
+                    relationshipFlag = false;
+                    builder.append("顺序号为空").append(",");
+                    excel.setOrderNum("{" + excel.getOrderNum() + "}");
+                }
+
+                if (groupNameFlag && discNameFlag && roomSelectionDateFlag && batchNumberFlag && roomSelectionNumberFlag
+                        && buyerNameFlag && identityCardFlag && phoneFlag && relationshipFlag){
+
+                }else {
+                    throw new RuntimeException(builder.toString());
+                }
+
+            }catch (Exception e){
+                String message = e.getMessage();
+                excel.setReason(message);
+            }
+        }
+
+        // 合并新增
+        Map<String, List<CustomerManagementExcel>> map = new HashMap<>();
+        for(CustomerManagementExcel excel : list){
+            // 判断批次号+选房号是否重复
+            String key = excel.getBatchNumber() + "-" + excel.getRoomSelectionNumber();
+            if(map.containsKey(key)){
+                // 批次号+选房号重复 合并选房人信息
+                List<CustomerManagementExcel> oldExcels = map.get(key);
+                oldExcels.add(excel);
+                map.put(key, oldExcels);
+            }else {
+                List<CustomerManagementExcel> excelList = new ArrayList<>();
+                excelList.add(excel);
+                map.put(key, excelList);
+            }
+        }
+
+        // 合并后数据
+        for (Map.Entry<String, List<CustomerManagementExcel>> entry : map.entrySet()) {
+            // 批次号+选房号 对应的数据
+            List<CustomerManagementExcel> value = entry.getValue();
+            CustomerManagement customerManagement = new CustomerManagement();
+            BeanUtil.copyProperties(value.get(0), customerManagement);
+            String id = IdUtil.simpleUUID();
+            List<Buyer> buyers = new ArrayList<>();
+            // 拼接买受人姓名
+            StringBuilder builder = new StringBuilder();
+            boolean insertFlag = true;
+            for (CustomerManagementExcel excel : value){
+                if(StringUtils.isEmpty(excel.getReason())){
+                    Buyer buyer = new Buyer();
+                    buyer.setCustomerManagementId(id);
+                    buyer.setCreatedAt(new Date());
+                    buyer.setCreatedId(userId);
+                    buyers.add(buyer);
+                    if(StringUtils.isEmpty(excel.getRelationship())){
+                        builder.append(excel.getBuyerName()).append(",");
+                    }else {
+                        builder.append(excel.getBuyerName())
+                                .append("(")
+                                .append(excel.getRelationshipStr())
+                                .append(")")
+                                .append(",");
+                    }
+                    if(builder.length() > 0){
+                        builder.deleteCharAt(builder.length()-1);
+                    }
+
+                }else {
+                    insertFlag = false;
+                    badList.add(excel);
+                }
+            }
+            if(insertFlag){
+                customerManagement.setBuyerName(builder.toString());
+                customerManagement.setId(id);
+                customerManagement.setStatus(1);
+                customerManagement.setGroupId(parkNameIdMap.get(value.get(0).getGroupName()));
+                customerManagement.setDiscId(discNameIdMap.get(value.get(0).getDiscName()));
+                customerManagement.setCreatedAt(new Date());
+                customerManagement.setCreatedId(userId);
+                modelMapper.insertSelective(customerManagement);
+                for (Buyer buyer : buyers){
+                    buyer.setCustomerManagementId(id);
+                    buyer.setCreatedAt(new Date());
+                    buyer.setCreatedId(userId);
+                    buyerService.insertSelective(buyer);
+                }
+            }
+        }
+
+        count = list.size();
+        jsonObject.put("successCount", count - badList.size());
+        jsonObject.put("errorList", badList);
+        jsonObject.put("errorCount", badList.size());
+        list.clear();
+        return jsonObject;
+    }
 
+    /**
+     * 校验身份证号
+     * @param idCard
+     * @return
+     */
+    public boolean isIdentityCard(String idCard){
+        String idCardPattern = "^\\d{17}[0-9Xx]$";
+        boolean isValid = idCard.matches(idCardPattern);
+        return isValid;
+    }
+
+    /**
+     * 校验手机号
+     * @param phone
+     * @return
+     */
+    public boolean isPhone(String phone){
+        String idCardPattern = "^1[3-9]\\d{9}$";
+        boolean isValid = phone.matches(idCardPattern);
+        return isValid;
+    }
+
+
+    public void errorListExport(List<CustomerManagementExcel> list, HttpServletResponse response) throws IOException {
+
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String date = sdf.format(new Date());
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        String fileName = URLEncoder.encode("失败记录" + date, "UTF-8");
+        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+        EasyExcel.write(response.getOutputStream(), CustomerManagementExcel.class)
+                .inMemory(true)
+                .registerWriteHandler(new WriteHandlerStrategy())//自定义样式
+                .sheet().doWrite(list);
+
+    }
 
 
 }

+ 32 - 14
pro-base/src/main/java/com/idea/customerManagement/service/IntentionalDepositService.java

@@ -417,40 +417,58 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
      */
     public void downLoadReceipt(IntentionalDeposit model, HttpServletResponse response) {
 
-        // TODO: 2024/10/24 意向金收据暂无word文档
-        String filePath = "/home/project/settleDown/tem/.docx";
+        IntentionalDeposit newRecord = selectByPrimaryKey(model.getId());
+        String filePath = "/home/project/settleDown/tem/receipt.docx";
+        String sealPath = "/home/project/settleDown/tem/seal.png";
         String fileName = "意向金收据.docx";
-        String customerManagementId = model.getCustomerManagementId();
+        String customerManagementId = newRecord.getCustomerManagementId();
         BuyerExample buyerExample = new BuyerExample();
         buyerExample.setOrderByClause("order_num asc");
         buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagementId);
         List<Buyer> buyers = buyerService.selectByExample(buyerExample);
-        String name = "";
+        StringBuilder builder = new StringBuilder();
         if (CollectionUtils.isNotEmpty(buyers)) {
-            Buyer buyer = buyers.get(0);
-            name = buyer.getName();
+            for(Buyer buyer: buyers){
+                builder.append(buyer.getName()).append(",");
+            }
+            if(builder.length() > 0){
+                builder.deleteCharAt(builder.length()-1);
+            }
+        }
+        String fullName = "";
+        // 意向金只有选房后 才有houseId
+        if(StringUtils.isNotEmpty(newRecord.getHouseId())){
+            ParkRoomResponse roomResponse = roomExtendMapper.getFullName(newRecord.getHouseId());
+            fullName = roomResponse.getGroupName() + "-"
+                    + roomResponse.getDiscName() + "-"
+                    + roomResponse.getBuildName() + "-"
+                    + roomResponse.getRoomNo();
         }
-        String collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, model.getCollectionTime());
-        String content = "定金";
+        String serialNumber = newRecord.getSerialNumber();
+        String collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, newRecord.getCollectionTime());
+        String content = "意向金";
         String paymentMethod = "";
-        String dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", model.getPaymentMethod().toString());
-        if(StringUtils.isNotEmpty(dictLabel)){
+        String dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", newRecord.getPaymentMethod().toString());
+        if (StringUtils.isNotEmpty(dictLabel)) {
             paymentMethod = dictLabel;
         }
-        String receivedAmount = model.getReceivedAmount().toString();
+        String receivedAmount = newRecord.getReceivedAmount().toString();
         String capital = MoneyUtils.amountConversion(receivedAmount);
 
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
-        data.put("${name}", name);
+        Map<String, Object> settingData = new HashMap<>();
+        data.put("${serialNumber}", serialNumber);
+        data.put("${name}", builder.toString());
         data.put("${collectionTime}", collectionTime);
         data.put("${content}", content);
         data.put("${paymentMethod}", paymentMethod);
+        data.put("${fullName}", fullName);
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
-
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        sealData.put("${seal}", sealPath);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

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

@@ -298,8 +298,6 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
     public void downLoad(RoomSelectionInfoDto model, HttpServletRequest request, HttpServletResponse response) {
 
         String filePath = "/home/project/settleDown/tem/roomConfirmationSheet.docx";
-        String picturePath = "C:\\Users\\35838\\Pictures\\liuhaizhu.jpg";
-        String sealPath = "C:\\Users\\35838\\Pictures\\seal.png";
         String fileName = "房源确认单.docx";
         String customerManagementId = model.getCustomerManagementId();
         BuyerExample buyerExample = new BuyerExample();
@@ -317,6 +315,8 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
             Map<String, Object> data = new HashMap<>();
             Map<String, Object> picData = new HashMap<>();
             Map<String, Object> sealData = new HashMap<>();
+            Map<String, Object> settingData = new HashMap<>();
+
             data.put("${name}", buyer.getName());
             data.put("${identityCard}", buyer.getIdentityCard());
             data.put("${address}", fullName);
@@ -324,9 +324,7 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
             data.put("${roomNumber}", roomResponse.getRoomNumber());
             data.put("${roomChooseDate}", roomChooseDate);
             data.put("${username}", loginName);
-            picData.put("${picture}", picturePath);
-            sealData.put("${seal}", sealPath);
-            ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+            ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
         }
 
 
@@ -350,45 +348,53 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
 
     /**
      * 定金收据
+     *
      * @param model
      * @param response
      */
     public void downLoadReceipt(RoomSelectionInfoDto model, HttpServletResponse response) {
 
-        // TODO: 2024/10/24 定金收据暂无word文档
-        String filePath = "/home/project/settleDown/tem/.docx";
+        RoomSelectionInfo newRecord = selectByPrimaryKey(model.getId());
+        String filePath = "/home/project/settleDown/tem/receipt.docx";
         String fileName = "定金收据.docx";
-        String customerManagementId = model.getCustomerManagementId();
+        String customerManagementId = newRecord.getCustomerManagementId();
         BuyerExample buyerExample = new BuyerExample();
         buyerExample.setOrderByClause("order_num asc");
         buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagementId);
         List<Buyer> buyers = buyerService.selectByExample(buyerExample);
-        String name = "";
+        StringBuilder builder = new StringBuilder();
         if (CollectionUtils.isNotEmpty(buyers)) {
-            Buyer buyer = buyers.get(0);
-            name = buyer.getName();
+            for (Buyer buyer : buyers) {
+                builder.append(buyer.getName()).append(",");
+            }
+            if (builder.length() > 0) {
+                builder.deleteCharAt(builder.length() - 1);
+            }
         }
-        ParkRoomResponse roomResponse = roomExtendMapper.getFullName(model.getHouseId());
-        String fullName = roomResponse.getGroupName()
-                + "-"
-                + roomResponse.getDiscName()
-                + roomResponse.getBuildName()
+
+        ParkRoomResponse roomResponse = roomExtendMapper.getFullName(newRecord.getHouseId());
+        String fullName = roomResponse.getGroupName() + "-"
+                + roomResponse.getDiscName() + "-"
+                + roomResponse.getBuildName() + "-"
                 + roomResponse.getRoomNo();
 
-        String collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, model.getCollectionTime());
+        String serialNumber = newRecord.getSerialNumber();
+        String collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, newRecord.getCollectionTime());
         String content = "定金";
         String paymentMethod = "";
-        String dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", model.getPaymentMethod().toString());
-        if(StringUtils.isNotEmpty(dictLabel)){
+        String dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", newRecord.getPaymentMethod().toString());
+        if (StringUtils.isNotEmpty(dictLabel)) {
             paymentMethod = dictLabel;
         }
-        String receivedAmount = model.getReceivedAmount().toString();
+        String receivedAmount = newRecord.getReceivedAmount().toString();
         String capital = MoneyUtils.amountConversion(receivedAmount);
 
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
-        data.put("${name}", name);
+        Map<String, Object> settingData = new HashMap<>();
+        data.put("${serialNumber}", serialNumber);
+        data.put("${name}", builder.toString());
         data.put("${collectionTime}", collectionTime);
         data.put("${content}", content);
         data.put("${paymentMethod}", paymentMethod);
@@ -396,7 +402,7 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
 
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

+ 13 - 1
pro-base/src/main/java/com/idea/invoice/controller/ReceiptManageController.java

@@ -1,6 +1,7 @@
 package com.idea.invoice.controller;
 
 import com.github.pagehelper.PageInfo;
+import com.idea.customerManagement.model.IntentionalDeposit;
 import com.idea.invoice.dto.ReceiptManageDto;
 import com.idea.invoice.model.ReceiptManage;
 import com.idea.invoice.service.ReceiptManageService;
@@ -10,10 +11,13 @@ import com.rockstar.frame.model.extend.Tablepar;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.servlet.http.HttpServletResponse;
+
 @Controller
 @RequestMapping(value = "ReceiptManageController")
 @Api(value="票据管理")
@@ -32,7 +36,15 @@ public class ReceiptManageController extends BaseController {
 
 
 
-
+    /**
+     * 意向金收据下载
+     * @param id
+     * @param response
+     */
+    @GetMapping(value = "downLoadReceipt",produces = {"application/json;charset=UTF-8"})
+    public void downLoadReceipt(String id, HttpServletResponse response) {
+        modelService.downLoadReceipt(id,response);
+    }
 
 
 

+ 164 - 10
pro-base/src/main/java/com/idea/invoice/service/ReceiptManageService.java

@@ -3,21 +3,38 @@ package com.idea.invoice.service;
 import cn.hutool.core.util.IdUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.idea.buildManage.mapper.ParkRoomExtendMapper;
+import com.idea.buildManage.response.ParkRoomResponse;
+import com.idea.customerManagement.mapper.CustomerManagementMapper;
+import com.idea.customerManagement.mapper.IntentionalDepositMapper;
+import com.idea.customerManagement.mapper.RoomSelectionInfoMapper;
+import com.idea.customerManagement.model.*;
+import com.idea.customerManagement.service.BuyerService;
 import com.idea.invoice.dto.ReceiptManageDto;
 import com.idea.invoice.mapper.ReceiptManageExtendMapper;
 import com.idea.invoice.mapper.ReceiptManageMapper;
 import com.idea.invoice.model.InvoiceManage;
 import com.idea.invoice.model.ReceiptManage;
 import com.idea.invoice.model.ReceiptManageExample;
+import com.idea.paymentManagement.model.PayLog;
+import com.idea.paymentManagement.service.PayLogService;
+import com.idea.util.DateUtils;
+import com.idea.util.MoneyUtils;
+import com.idea.util.ReplaceWord;
 import com.rockstar.common.base.BaseService;
 import com.rockstar.frame.model.extend.Tablepar;
 import com.rockstar.shiro.util.ShiroUtils;
+import com.rockstar.system.service.SysDictService;
 import com.rockstar.util.StringUtils;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptManageExample> {
@@ -26,7 +43,20 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
     private ReceiptManageMapper modelMapper;
     @Autowired
     private ReceiptManageExtendMapper extendMapper;
-
+    @Autowired
+    private BuyerService buyerService;
+    @Autowired
+    private CustomerManagementMapper customerManagementMapper;
+    @Autowired
+    private ParkRoomExtendMapper roomExtendMapper;
+    @Autowired
+    private SysDictService sysDictService;
+    @Autowired
+    private IntentionalDepositMapper intentionalDepositMapper;
+    @Autowired
+    private RoomSelectionInfoMapper roomSelectionInfoMapper;
+    @Autowired
+    private PayLogService payLogService;
 
     @Override
     public int deleteByPrimaryKey(String s) {
@@ -51,12 +81,12 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
 
     @Override
     public int updateByExampleSelective(ReceiptManage receiptManage, ReceiptManageExample receiptManageExample) {
-        return modelMapper.updateByExampleSelective(receiptManage,receiptManageExample);
+        return modelMapper.updateByExampleSelective(receiptManage, receiptManageExample);
     }
 
     @Override
     public int updateByExample(ReceiptManage receiptManage, ReceiptManageExample receiptManageExample) {
-        return modelMapper.updateByExample(receiptManage,receiptManageExample);
+        return modelMapper.updateByExample(receiptManage, receiptManageExample);
     }
 
     @Override
@@ -74,34 +104,34 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
         return modelMapper.deleteByExample(receiptManageExample);
     }
 
-    public ReceiptManageExample getCondition(ReceiptManage model){
+    public ReceiptManageExample getCondition(ReceiptManage model) {
 
         ReceiptManageExample example = new ReceiptManageExample();
         example.setOrderByClause("created_at");
         ReceiptManageExample.Criteria criteria = example.createCriteria();
-        if(StringUtils.isNotEmpty(model.getHouseName())){
+        if (StringUtils.isNotEmpty(model.getHouseName())) {
             criteria.andHouseNameLike("%" + model.getHouseName() + "%");
         }
         return example;
     }
 
-    public PageInfo listByModel(Tablepar tablepar, ReceiptManageDto model){
+    public PageInfo listByModel(Tablepar tablepar, ReceiptManageDto model) {
 
-        PageHelper.startPage(tablepar.getPageNum(),tablepar.getPageSize());
+        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
         List<ReceiptManageDto> receiptManages = extendMapper.listByModel(model);
         return new PageInfo<ReceiptManageDto>(receiptManages);
     }
 
 
-
     /**
      * 新增票据 其他业务调用
+     *
      * @param model
      * @return
      */
-    public int add(ReceiptManage model){
+    public int add(ReceiptManage model) {
 
-        if(model.getReceiptStatus() == null){
+        if (model.getReceiptStatus() == null) {
             // 默认 已开
             model.setReceiptStatus(1);
         }
@@ -111,5 +141,129 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
         return result;
     }
 
+    /**
+     * 票据管理 收款收据下载
+     *
+     * @param id
+     * @param response
+     */
+    public void downLoadReceipt(String id, HttpServletResponse response) {
+
+        ReceiptManage receiptManage = selectByPrimaryKey(id);
+        String filePath = "/home/project/settleDown/tem/receipt.docx";
+        String sealPath = "/home/project/settleDown/tem/seal.png";
+        String sealPath2 = "/home/project/settleDown/tem/huanpiao.png";
+        String fileName = "";
+        String serialNumber = "";
+        String collectionTime = "";
+        String content = "";
+        String dictLabel = "";
+        String paymentMethod = "";
+        switch (receiptManage.getReceiptType()) {
+            case "1":
+                fileName = "意向金收据.docx";
+                IntentionalDeposit record = intentionalDepositMapper.selectByPrimaryKey(receiptManage.getBusinessId());
+                serialNumber = record.getSerialNumber();
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, record.getCollectionTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", record.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+                content = "意向金";
+                break;
+            case "2":
+                fileName = "定金收据.docx";
+                RoomSelectionInfo deposit = roomSelectionInfoMapper.selectByPrimaryKey(receiptManage.getBusinessId());
+                serialNumber = deposit.getSerialNumber();
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, deposit.getCollectionTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", deposit.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+                content = "意向金";
+                break;
+            case "3":
+                fileName = "首期收据.docx";
+                content = "首期";
+                break;
+            case "4":
+                fileName = "银行按揭收据.docx";
+                content = "银行按揭";
+                break;
+            default:
+                PayLog payLog = payLogService.selectByPrimaryKey(receiptManage.getBusinessId());
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, payLog.getPayTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", payLog.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+        }
+        String customerManagementId = receiptManage.getCustomerManagementId();
+        CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(customerManagementId);
+        BuyerExample buyerExample = new BuyerExample();
+        buyerExample.setOrderByClause("order_num asc");
+        buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagementId);
+        List<Buyer> buyers = buyerService.selectByExample(buyerExample);
+        StringBuilder builder = new StringBuilder();
+        if (CollectionUtils.isNotEmpty(buyers)) {
+            for (Buyer buyer : buyers) {
+                builder.append(buyer.getName()).append(",");
+            }
+            if (builder.length() > 0) {
+                builder.deleteCharAt(builder.length() - 1);
+            }
+        }
+        String fullName = "";
+        // 意向金只有选房后 才有houseId
+        if (StringUtils.isNotEmpty(customerManagement.getHouseId())) {
+            ParkRoomResponse roomResponse = roomExtendMapper.getFullName(customerManagement.getHouseId());
+            fullName = roomResponse.getGroupName() + "-"
+                    + roomResponse.getDiscName() + "-"
+                    + roomResponse.getBuildName() + "-"
+                    + roomResponse.getRoomNo();
+        }
+
+        String receivedAmount = receiptManage.getReceiptMoney().toString();
+        String capital = MoneyUtils.amountConversion(receivedAmount);
+
+        Map<String, Object> data = new HashMap<>();
+        Map<String, Object> picData = new HashMap<>();
+        Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
+        Map<String, Object> settingInfoData;
+
+        data.put("${serialNumber}", serialNumber);
+        data.put("${name}", builder.toString());
+        data.put("${collectionTime}", collectionTime);
+        data.put("${content}", content);
+        data.put("${paymentMethod}", paymentMethod);
+        data.put("${fullName}", fullName);
+        data.put("${capital}", capital);
+        data.put("${receivedAmount}", receivedAmount);
+        sealData.put("${seal}", sealPath);
+
+        settingInfoData = new HashMap<>();
+        settingInfoData.put("leftOffset", "50");
+        settingInfoData.put("topOffset", "-50");
+        settingData.put("${seal}",settingInfoData);
+
+
+        // 已换票 已红冲
+        if (receiptManage.getReceiptStatus() == 2 || receiptManage.getReceiptStatus() == 3) {
+            filePath = "/home/project/settleDown/tem/receipt_huanpiao.docx";
+            sealData.put("${huanpiao}", sealPath2);
+
+            settingInfoData = new HashMap<>();
+            settingInfoData.put("leftOffset", "300");
+            settingInfoData.put("topOffset", "-50");
+            settingData.put("${huanpiao}",settingInfoData);
+
+        }
+
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
+
+
+    }
+
 
 }

+ 58 - 19
pro-base/src/main/java/com/idea/invoice/util/InvoiceUtil.java

@@ -12,8 +12,11 @@ import com.rockstar.util.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import nccloud.open.api.auto.token.cur.utils.APICurUtils;
 
+import java.math.BigDecimal;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 
 @Slf4j
 public class InvoiceUtil {
@@ -43,7 +46,8 @@ public class InvoiceUtil {
     /**
      * 自定义档案列表编码
      */
-    public static final String pk_defdoclist = "CJ21";
+    public static final String pk_defdoclist_build = "CJ19";
+    public static final String pk_defdoclist_room = "CJ21";
 
     public static final String bank_number = "2019219219212323";
 
@@ -54,19 +58,35 @@ public class InvoiceUtil {
         String roomNumber = "";
         String name = "";
         String def13 = "222";
-//        InvoiceUtil.informerQuery();
         // 收款单接口-新增提交
-//        InvoiceUtil.gatheringbillAdd("F2-Cxx-06","1001I91000000003V3S0");
+//        InvoiceUtil.gatheringbillAdd("F2-Cxx-09","1001I91000000003V3S3");
         // 收款单接口-转账单
 //        InvoiceUtil.gatheringbillTurn(nature,roomNumber);
         // 收款单接口-换票
 //        InvoiceUtil.gatheringbillInvoice(nature,name,def13);
+        // 收款单接口-划拨单
+//        InvoiceUtil.gatheringbillTransfer("F2-Cxx-09","1001I91000000003V3S3");
         // 付款单接口_退款单
 //        InvoiceUtil.paybillAdd();
         // 收款单接口 删除
 //        InvoiceUtil.gatheringbillDelete();
         // 应收接口-收入结转单 新增
 //        InvoiceUtil.recbillAdd();
+        // 楼栋或房间查询
+//        InvoiceUtil.defdocView("CJ19");
+        // 楼栋或房间新增
+//        InvoiceUtil.defdocAdd("41号楼",pk_defdoclist_build);
+        // 到账通知认领查询
+//        InvoiceUtil.informerQuery();
+        BigDecimal one = new BigDecimal("14475.20");
+        BigDecimal two = new BigDecimal("19670.88");
+        BigDecimal three = new BigDecimal("18304.08");
+        List<BigDecimal> list = Arrays.asList(one, two, three);
+        BigDecimal zero = BigDecimal.ZERO;
+        for (BigDecimal bigDecimal : list){
+            zero= zero.add(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
+        }
+        System.out.println(zero);
     }
 
     /**
@@ -83,25 +103,41 @@ public class InvoiceUtil {
     }
 
     /**
-     * 房间新增
+     * 楼栋或房间新增 pk_defdoclist 楼栋传CJ19 房间传CJ21
      *
      * @throws Exception
      */
-    public static void defdocAdd() throws Exception {
+    public static void defdocAdd(String name,String pk_defdoclist) throws Exception {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/uapbd/defdoc/add");
         JSONObject json = new JSONObject();
-        json.put("srcsystemid", "1300419721555869696");
-        json.put("code", "1300419721555869696");
-        json.put("name", "天鹅湖花园-一期-41-101");
+        json.put("srcsystemid", "7b5a4022df7e4ae0a0a9bd4d77409920");
+        json.put("code", "7b5a4022df7e4ae0a0a9bd4d77409920");
+        json.put("name", name);
         json.put("pk_org", pk_org);
         json.put("pk_defdoclist", pk_defdoclist);
         String result = util.getAPIRetrun(token, json.toJSONString());
+        log.info("楼栋或房间新增:{}", result);
+    }
 
-        log.info("房间新增:{}", result);
+    /**
+     * 楼栋或房间新增 pk_defdoclist 楼栋传CJ19 房间传CJ21
+     * @param pk_defdoclist
+     * @throws Exception
+     */
+    public static void defdocView(String pk_defdoclist) throws Exception {
+        APICurUtils util = new APICurUtils();
+        String token = InvoiceUtil.getToken(util);
+        util.setApiUrl("nccloud/api/wxyy/uapbd/defdoc/query");
+        JSONObject json = new JSONObject();
+        json.put("pk_org", pk_org);
+        json.put("code", pk_defdoclist);
+        String result = util.getAPIRetrun(token, json.toJSONString());
+        log.info("房间查看:{}", result);
     }
 
+
     /**
      * 客户新增
      *
@@ -202,7 +238,7 @@ public class InvoiceUtil {
         String srcsystemid = IdUtil.simpleUUID();
         String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
         ar_recbill.put("srcsystemid", srcsystemid); //外系统标识,必选
-        ar_recbill.put("pk_tradetype", "F3-Cxx-05"); //交易类型,必选
+        ar_recbill.put("pk_tradetype", "F0-Cxx-05"); //交易类型,必选
         ar_recbill.put("pk_org", pk_org); //组织编码,必选
         ar_recbill.put("billdate", billdate); //单据日期
         ar_recbill.put("def2", srcsystemid); //外系统单据号,必填,
@@ -218,14 +254,14 @@ public class InvoiceUtil {
         ar_recitemJson.put("scomment", ""); //摘要,非必选
         ar_recitemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
         ar_recitemJson.put("customer", "tyxydm00002"); //客商的纳税人识别号
-        ar_recitemJson.put("money_de", "100"); //金额,必选
+        ar_recitemJson.put("money_de", "-100"); //金额,必选
         ar_recitemJson.put("taxrate", "16"); //税率,必选,无税传0
         ar_recitemJson.put("pk_subjcode", "AJ003"); //收支项目编码,非必选
-        ar_recitemJson.put("def11", "1300419721555869696"); //转出前房号编码,收除了诚意金之外的首期等需要选
+        ar_recitemJson.put("def11", "100"); //转出前房号编码,收除了诚意金之外的首期等需要选
         ar_recitemJson.put("def9", "001"); //业态,必选,看云文档业态
         ar_recitemJson.put("def7", "AJ001"); //房产工程项目,必选,看云文档
-        ar_recitemJson.put("def8", "CJ19"); //楼栋,必选,看云文档
-        ar_recitemJson.put("material", "XXX"); //物料
+        ar_recitemJson.put("def8", "1300419721555869696"); //楼栋,必选,看云文档
+        ar_recitemJson.put("material", "mwjyB"); //物料
         ar_recitem.add(ar_recitemJson);
         json.put("ar_recitem", ar_recitem);
 
@@ -270,11 +306,11 @@ public class InvoiceUtil {
         ar_gatheritemJson.put("recaccount", bank_number); //收款银行账号,必填
 //        ar_gatheritemJson.put("invoiceno","fphm"); //发票号码,非必选
         ar_gatheritemJson.put("scomment", "小二"); //客户名称,必选
-        ar_gatheritemJson.put("pk_subjcode", "AJ022"); //收款类型
+        ar_gatheritemJson.put("pk_subjcode", "AJ015"); //收款类型
         ar_gatheritemJson.put("checktype", "5"); //票据类型,必选,看云文档票据类型
         ar_gatheritemJson.put("checkno", number); //票据号,必选
         ar_gatheritemJson.put("def9", "001"); //业态,必选,看云文档业态
-        ar_gatheritemJson.put("def11", "1300419721555869696"); //转出前房号编码,收除了诚意金之外的首期等需要选
+        ar_gatheritemJson.put("def11", "100"); //转出前房号编码,收除了诚意金之外的首期等需要选
         ar_gatheritemJson.put("def10", "mwjyAdk"); //项目档案编码,看云文档项目档案对照
         ar_gatheritemJson.put("top_billid", pk_informer); //到账通知生单时,(银行流水中返回的id,见5.2.10到账通知认领查询pk_informer字段)
         ar_gatheritem.add(ar_gatheritemJson);
@@ -429,7 +465,12 @@ public class InvoiceUtil {
         log.info("单据提交——换票单:{}", result);
     }
 
-
+    /**
+     * 划拨单
+     * @param nature
+     * @param pk_informer
+     * @throws Exception
+     */
     public static void gatheringbillTransfer(String nature,String pk_informer) throws Exception {
 
         APICurUtils util = new APICurUtils();
@@ -462,8 +503,6 @@ public class InvoiceUtil {
 //        ar_gatheritemJson.put("invoiceno","fphm"); //发票号码,非必选
         ar_gatheritemJson.put("scomment", "小二"); //客户名称,必选
         ar_gatheritemJson.put("pk_subjcode", "AJ015"); //收款类型
-        // TODO: 2024/10/30 没有 
-        ar_gatheritemJson.put("def3", ""); //产品类型,必选
         ar_gatheritemJson.put("checktype", "5"); //票据类型,必选,看云文档票据类型
         ar_gatheritemJson.put("checkno", number); //票据号,必选
         ar_gatheritemJson.put("def9", "001"); //业态,必选,看云文档业态

+ 12 - 2
pro-base/src/main/java/com/idea/paymentManagement/service/MaintenanceFundsManagementService.java

@@ -30,6 +30,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -112,9 +113,18 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
      */
     public int add(MaintenanceFundsManagement model){
 
-        // 更新合同 专项维修资金收取状态 已收款
+        // 更新合同 专项维修资金收取状态
         ContractManage contractManage = contractManageMapper.selectByPrimaryKey(model.getContractId());
-        contractManage.setFundCollectionStatus(2);
+        BigDecimal payMoney = model.getPayMoney();
+        BigDecimal maintenanceTotalPrice = contractManage.getMaintenanceTotalPrice();
+        if(payMoney.doubleValue() >= maintenanceTotalPrice.doubleValue()){
+            // 已收款
+            contractManage.setFundCollectionStatus(2);
+        }else {
+            // 部分收款
+            contractManage.setFundCollectionStatus(4);
+        }
+
         contractManageMapper.updateByPrimaryKeySelective(contractManage);
 
         model.setHouseId(contractManage.getHouseId());

+ 7 - 5
pro-base/src/main/java/com/idea/paymentManagement/service/PayLogService.java

@@ -316,19 +316,20 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
 
         PayLog payLog = selectByPrimaryKey(id);
         Integer contentType = payLog.getContentType();
+        String sealPath = "/home/project/settleDown/tem/seal.png";
         String filePath = "";
         String fileName = "";
         switch (contentType){
             case 1: // 定金
-                filePath = "/home/project/settleDown/tem/.docx";
+                filePath = "/home/project/settleDown/tem/receipt.docx";
                 fileName = "定金收据.docx";
                 break;
             case 2: // 首付
-                filePath = "/home/project/settleDown/tem/.docx";
+                filePath = "/home/project/settleDown/tem/receipt.docx";
                 fileName = "首付收据.docx";
                 break;
             case 3: // 银行按揭
-                filePath = "/home/project/settleDown/tem/.docx";
+                filePath = "/home/project/settleDown/tem/receipt.docx";
                 fileName = "银行按揭收据.docx";
                 break;
         }
@@ -368,6 +369,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
         data.put("${name}", name);
         data.put("${collectionTime}", collectionTime);
         data.put("${fullName}", fullName);
@@ -375,8 +377,8 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         data.put("${paymentMethod}", paymentMethod);
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
-
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        sealData.put("${seal}", sealPath);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

+ 16 - 0
pro-base/src/main/java/com/idea/paymentManagement/service/RefundManageService.java

@@ -6,9 +6,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.idea.buildManage.mapper.ParkRoomExtendMapper;
+import com.idea.buildManage.mapper.ParkRoomMapper;
+import com.idea.buildManage.model.ParkRoom;
 import com.idea.buildManage.response.ParkRoomResponse;
 import com.idea.customerManagement.dto.ContractManageDto;
 import com.idea.customerManagement.mapper.ContractManageMapper;
+import com.idea.customerManagement.mapper.CustomerManagementMapper;
 import com.idea.customerManagement.mapper.RoomSelectionInfoMapper;
 import com.idea.customerManagement.model.*;
 import com.idea.customerManagement.service.BuyerService;
@@ -55,6 +58,10 @@ public class RefundManageService implements BaseService<RefundManage, RefundMana
     private ContractManageMapper contractManageMapper;
     @Autowired
     private FrameUserMapper frameUserMapper;
+    @Autowired
+    private CustomerManagementMapper customerManagementMapper;
+    @Autowired
+    private ParkRoomMapper roomMapper;
 
 
     @Override
@@ -177,6 +184,15 @@ public class RefundManageService implements BaseService<RefundManage, RefundMana
         contractManage.setFundCollectionStatus(fundCollectionStatus);
         contractManage.setContractStatus(3);
         contractManageMapper.updateByPrimaryKeySelective(contractManage);
+        // 更新客户管理 客户状态
+        CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(contractManage.getCustomerManagementId());
+        customerManagement.setStatus(5);
+        customerManagementMapper.updateByPrimaryKeySelective(customerManagement);
+        // 更新房间状态
+        ParkRoom room = roomMapper.selectByPrimaryKey(contractManage.getHouseId());
+        room.setSoldStatus(4);
+        roomMapper.updateByPrimaryKeySelective(room);
+
         return result;
     }
 

+ 15 - 7
pro-base/src/main/java/com/idea/util/ReplaceWord.java

@@ -79,12 +79,13 @@ public class ReplaceWord {
 
     /**
      * 替换印章图片
+     *
      * @param document
      * @param sealData
      * @throws Exception
      */
     public static void changeSeal(XWPFDocument document, Map<String, Object> sealData,
-                                  int leftOffset, int topOffset, boolean behind) throws Exception {
+                                  Map<String, Object> settingData) throws Exception {
         // 获取段落集合
         Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
         XWPFParagraph paragraph;
@@ -93,7 +94,7 @@ public class ReplaceWord {
             // 判断此段落是否需要替换
             String text = paragraph.getText();
             if (checkText(text)) {
-                replaceSealValue(paragraph, sealData,leftOffset,topOffset,behind);
+                replaceSealValue(paragraph, sealData, settingData);
             }
         }
     }
@@ -226,11 +227,18 @@ public class ReplaceWord {
     }
 
     public static void replaceSealValue(XWPFParagraph paragraph, Map<String, Object> sealData,
-                                        int leftOffset, int topOffset, boolean behind) throws Exception {
+                                        Map<String, Object> settingData) throws Exception {
         List<XWPFRun> runs = paragraph.getRuns();
         for (XWPFRun run : runs) {
             Object value = changeValue(run.toString(), sealData);
             if (sealData.containsKey(run.toString())) {
+                int leftOffset = 0, topOffset = 0;
+                boolean behind = false;
+                if(settingData.containsKey(run.toString())){
+                    Map<String, Object> settingInfo = (Map<String, Object>) settingData.get(run.toString());
+                    leftOffset = Integer.parseInt(settingInfo.get("leftOffset").toString());
+                    topOffset = Integer.parseInt(settingInfo.get("topOffset").toString());
+                }
                 //清空内容
                 run.setText("", 0);
                 FileInputStream is = new FileInputStream((String) value);
@@ -295,7 +303,7 @@ public class ReplaceWord {
         operateWord(data, picData);
     }
 
-    public static void operateWord(Map<String, Object> data, Map<String, Object> picData){
+    public static void operateWord(Map<String, Object> data, Map<String, Object> picData) {
         try {
             FileInputStream is = new FileInputStream("C:\\Users\\35838\\Desktop\\中低收入家庭购买共有产权保障房房源确认单(惠景).docx");
             XWPFDocument document = new XWPFDocument(is);
@@ -320,8 +328,8 @@ public class ReplaceWord {
         }
     }
 
-    public static void operateWord(HttpServletResponse response,String filePath,String fileName, Map<String, Object> data,
-                                   Map<String, Object> picData,Map<String, Object> sealData){
+    public static void operateWord(HttpServletResponse response, String filePath, String fileName, Map<String, Object> data,
+                                   Map<String, Object> picData, Map<String, Object> sealData, Map<String, Object> settingData) {
         try {
             FileInputStream is = new FileInputStream(filePath);
             XWPFDocument document = new XWPFDocument(is);
@@ -339,7 +347,7 @@ public class ReplaceWord {
             }
             if (sealData.size() > 0) {
                 // 替换内容图片
-                ReplaceWord.changeSeal(document, sealData,0,0,false);
+                ReplaceWord.changeSeal(document, sealData, settingData);
             }
             response.setContentType("text/html;charset=UTF-8");
             response.setContentType("application/msword");

+ 3 - 3
pro-base/src/main/resources/mybatis/paymentManagement/MaintenanceFundsManagementExtendMapper.xml

@@ -12,16 +12,16 @@
     <where>
         and contract_manage.contract_status = '2'
       <if test="houseName != null and houseName != ''">
-        and house_name like concat('%',#{houseName},'%')
+        and contract_manage.house_name like concat('%',#{houseName},'%')
       </if>
       <if test="fundCollectionStatus != null and fundCollectionStatus != ''">
         and contract_manage.fund_collection_status = #{fundCollectionStatus}
       </if>
       <if test="buyerName != null and buyerName != ''">
-        and maintenance_funds_management.customer_management_id in (select customer_management_id from buyer where name like concat('%',#{buyerName},'%'))
+        and contract_manage.buyer_name like concat('%',#{buyerName},'%')
       </if>
     </where>
-    order by created_at desc
+      order by contract_manage.created_at desc
   </select>