From ca8c83c771495363c46b6cfe56a599dfbdbe70d2 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 07 三月 2025 14:23:34 +0800
Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java |   66 ++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
index bdd80b0..eb12c0a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -227,7 +227,7 @@
                 .list();
         BigDecimal payMoney = new BigDecimal("0");
         for (TBill tBill : list) {
-            payMoney = payMoney.add(tBill.getPayFeesMoney()).add(tBill.getPayableFeesPenalty());
+            payMoney = payMoney.add(tBill.getOutstandingMoney()).add(tBill.getPayableFeesPenalty());
         }
         TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, id).one();
         res.setCheckResult(Objects.nonNull(tCheckAcceptRecord)&&Objects.nonNull(tCheckAcceptRecord.getCheckResult())?tCheckAcceptRecord.getCheckResult():false);
@@ -257,7 +257,14 @@
         TContract contract = contractService.getById(id);
         contract.setStatus("8");
         contractService.updateById(contract);
-        return R.ok();
+        // 将所有未缴费账单设置未已失效
+        List<TBill> tBills = billService.list(new LambdaQueryWrapper<TBill>()
+                .ne(TBill::getPayFeesStatus, 3)
+                .eq(TBill::getContractId, contract.getId()));
+        for (TBill tBill : tBills) {
+            tBill.setPayFeesStatus("5");
+        }
+        billService.updateBatchById(tBills);        return R.ok();
     }
     @ApiOperation(value = "终止合同剩余未缴费账单列表")
     @PostMapping(value = "/contractBillList")
@@ -291,47 +298,46 @@
 
             THouse tHouse = houseService.getById(contract.getHouseId());
             Map<String, Object> templateParam = new HashMap<>(5);
-            templateParam.put("partyOneName", contract.getPartyOneName());
-            templateParam.put("partyTwoName", contract.getPartyTwoName());
-            templateParam.put("houseAddress", tHouse.getHouseAddress());
-            templateParam.put("houseArea", tHouse.getHouseArea()+"m²");
+            templateParam.put("${partyOneName}", contract.getPartyOneName());
+            templateParam.put("${partyTwoName}", contract.getPartyTwoName());
+            templateParam.put("${houseAddress}", tHouse.getHouseAddress());
+            templateParam.put("${houseArea}", tHouse.getHouseArea()+"m²");
             long between = ChronoUnit.DAYS.between(contract.getStartTime(), contract.getStartPayTime())+1;
-            templateParam.put("day", between);
-            templateParam.put("endTimeFree", DateUtils.localDateTimeToStringYear(contract.getStartPayTime().plusDays(1)));
-            templateParam.put("startPayTime", DateUtils.localDateTimeToStringYear(contract.getStartPayTime()));
-            templateParam.put("startTime", DateUtils.localDateTimeToStringYear(contract.getStartTime()));
-            templateParam.put("endTime", DateUtils.localDateTimeToStringYear(contract.getEndTime()));
-            templateParam.put("monthRent", "¥¥"+contract.getMonthRent()+"元");
-            templateParam.put("monthRentString", "人民币"+NumberToChineseUtils.numberToChinese(contract.getMonthRent().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
+            templateParam.put("${day}", between);
+            templateParam.put("${endTimeFree}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime().plusDays(1)));
+            templateParam.put("${startPayTime}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime()));
+            templateParam.put("${startTime}", DateUtils.localDateTimeToStringYear(contract.getStartTime()));
+            templateParam.put("${endTime}", DateUtils.localDateTimeToStringYear(contract.getEndTime()));
+            templateParam.put("${monthRent}", "¥"+contract.getMonthRent()+"元");
+            templateParam.put("${monthRentString}", "人民币"+NumberToChineseUtils.numberToChinese(contract.getMonthRent().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
             String totalYear = Objects.nonNull(contract.getTotalYear())?contract.getTotalYear().toString():"";
-            templateParam.put("totalYear", "¥¥"+totalYear+"元");
+            templateParam.put("${totalYear}", "¥"+totalYear+"元");
             String totalYearString = StringUtils.isNotEmpty(totalYear)?NumberToChineseUtils.numberToChinese(contract.getTotalYear().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()):"";
-            templateParam.put("totalYearString", "人民币"+totalYearString);
-            templateParam.put("payType", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
+            templateParam.put("${totalYearString}", "人民币"+totalYearString);
+            templateParam.put("${payType}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
             if(firstBill!=null){
-                templateParam.put("firstRent", "¥"+(firstBill.getPayableFeesMoney())+"元");
+                templateParam.put("${firstRent}", "¥"+(firstBill.getPayableFeesMoney())+"元");
             }else{
-                templateParam.put("firstRent", "");
+                templateParam.put("${firstRent}", "");
 
             }
-            templateParam.put("firstRentString", "人民币"+NumberToChineseUtils.numberToChinese((contract.getPayType().equals("1")?contract.getMonthRent():contract.getPayType().equals("2")?contract.getMonthRent().multiply(new BigDecimal("3")):contract.getMonthRent().multiply(new BigDecimal("12")).setScale(2,BigDecimal.ROUND_DOWN)).doubleValue()));
-            templateParam.put("nextPayTime", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
-            templateParam.put("deposit", "¥"+contract.getDeposit()+"元");
-            templateParam.put("depositString", NumberToChineseUtils.numberToChinese(contract.getDeposit().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
-            templateParam.put("partyOnePerson", contract.getPartyOnePerson());
-            templateParam.put("partyOnePhone", contract.getPartyOnePhone());
-            templateParam.put("partyTwoPerson", contract.getPartyTwoPerson());
-            templateParam.put("partyTwoPhone", contract.getPartyTwoPhone());
+            templateParam.put("${firstRentString}", "人民币"+NumberToChineseUtils.numberToChinese((contract.getPayType().equals("1")?contract.getMonthRent():contract.getPayType().equals("2")?contract.getMonthRent().multiply(new BigDecimal("3")):contract.getMonthRent().multiply(new BigDecimal("12")).setScale(2,BigDecimal.ROUND_DOWN)).doubleValue()));
+            templateParam.put("${nextPayTime}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
+            templateParam.put("${deposit}", "¥"+contract.getDeposit()+"元");
+            templateParam.put("${depositString}", NumberToChineseUtils.numberToChinese(contract.getDeposit().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
+            templateParam.put("${partyOnePerson}", contract.getPartyOnePerson());
+            templateParam.put("${partyOnePhone}", contract.getPartyOnePhone());
+            templateParam.put("${partyTwoPerson}", contract.getPartyTwoPerson());
+            templateParam.put("${partyTwoPhone}", contract.getPartyTwoPhone());
             // 验收时间
             TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, contract.getId()).last("limit 1").one();
             if (tCheckAcceptRecord!=null &&tCheckAcceptRecord.getCheckTime()!=null ){
-                templateParam.put("checkTime", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime()));
+                templateParam.put("${checkTime}", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime()));
             }else{
-                templateParam.put("checkTime", "");
+                templateParam.put("${checkTime}", "");
 
             }
-            String url = wordUtil.generatePdf("/template", "1_yzj_租赁合同.xml", templateParam, "租赁合同", "E:\\");
-            System.out.println(url);
+            String url = wordUtil.generatePdf("/usr/local/project/file/", "1_yzj_租赁合同.docx", templateParam, "租赁合同", "/usr/local/project/file/");
             res.add(url);
         }
 

--
Gitblit v1.7.1