| | |
| | | BigDecimal discount = productTotal.subtract(total); |
| | | replace(document, Map.of("customerName", text(contract.getCustomerName()), |
| | | "contractNo", text(contract.getNo()), |
| | | "contractName", text(contract.getName()), |
| | | "contractDate", contract.getOrderDate() == null ? "____________" : contract.getOrderDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")), |
| | | "startDate", date(contract.getStartTime()), |
| | | "endDate", date(contract.getEndTime()), |
| | | "totalPrice", money(total), "totalUpper", Convert.digitToChinese(total), |
| | | "discountNote", discount.signum() == 0 ? "" : "(明细合计 " + money(productTotal) + " 元,整单优惠 " + money(discount) + " 元)")); |
| | | "discountNote", discount.signum() == 0 ? "" : "(明细合计 " + money(productTotal) + " 元,与合同金额的差额 " + money(discount) + " 元)")); |
| | | if (document.getDocumentElement().getTextContent().contains("${")) throw new IOException("合同模板存在未填写槽位"); |
| | | var transformerFactory = TransformerFactory.newInstance(); |
| | | transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); |
| | |
| | | } |
| | | |
| | | private static String money(BigDecimal value) { return value.setScale(2, RoundingMode.HALF_UP).toPlainString(); } |
| | | private static String date(java.time.LocalDateTime value) { return value == null ? "____________" : value.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")); } |
| | | private static String text(String value) { return value == null ? "" : value; } |
| | | } |