|
@@ -1,14 +1,21 @@
|
|
|
package com.idea.paymentManagement.service;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
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.model.Buyer;
|
|
|
+import com.idea.customerManagement.model.BuyerExample;
|
|
|
import com.idea.customerManagement.model.ContractManage;
|
|
|
+import com.idea.customerManagement.service.BuyerService;
|
|
|
import com.idea.invoice.model.InvoiceBank;
|
|
|
import com.idea.invoice.model.InvoiceBankExample;
|
|
|
import com.idea.invoice.model.InvoiceManage;
|
|
@@ -22,21 +29,30 @@ import com.idea.paymentManagement.model.MaintenanceFundsManagement;
|
|
|
import com.idea.paymentManagement.model.MaintenanceFundsManagementExample;
|
|
|
import com.idea.paymentManagement.model.PayLog;
|
|
|
import com.idea.paymentManagement.model.PayLogExample;
|
|
|
+import com.idea.util.DateUtils;
|
|
|
+import com.idea.util.MoneyUtils;
|
|
|
+import com.idea.util.ReplaceWord;
|
|
|
+import com.idea.util.WordToPdfUtil;
|
|
|
import com.rockstar.common.base.BaseService;
|
|
|
import com.rockstar.frame.model.extend.DateTrans;
|
|
|
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 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.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class MaintenanceFundsManagementService implements BaseService<MaintenanceFundsManagement, MaintenanceFundsManagementExample> {
|
|
|
|
|
@@ -54,7 +70,12 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
|
|
|
private PayLogMapper payLogMapper;
|
|
|
@Autowired
|
|
|
private InvoiceManageService invoiceManageService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private BuyerService buyerService;
|
|
|
+ @Autowired
|
|
|
+ private ParkRoomExtendMapper roomExtendMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysDictService sysDictService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -160,34 +181,35 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
|
|
|
payLog.setBankNumber(model.getBankNumber());
|
|
|
payLogMapper.insertSelective(payLog);
|
|
|
|
|
|
- // 查询合同的房款收款情况
|
|
|
- Integer collectionStatus = contractManage.getFundCollectionStatus();
|
|
|
- // 完全收款
|
|
|
- if(collectionStatus == 2){
|
|
|
- // 查询该合同是否已生成 正式发票 且类型是专项维修资金
|
|
|
- InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
|
|
|
- invoiceManageExample.createCriteria().andTypeEqualTo("2")
|
|
|
- .andContractIdEqualTo(model.getContractId())
|
|
|
- .andPaymentTypeEqualTo("2");
|
|
|
- List<InvoiceManage> invoiceManages = invoiceManageService.selectByExample(invoiceManageExample);
|
|
|
- if(CollectionUtils.isEmpty(invoiceManages)){
|
|
|
- // 生成一条待推送的开票信息
|
|
|
- InvoiceManage invoiceManage = invoiceManageService.getInfoByContract(model.getContractId(),
|
|
|
- "*不动产*",2);
|
|
|
- invoiceManage.setInvoiceAmount(payMoney);
|
|
|
- // 正式发票
|
|
|
- invoiceManage.setType("2");
|
|
|
- // 专项维修资金
|
|
|
- invoiceManage.setPaymentType("2");
|
|
|
- invoiceManage.setSendStatus("0");
|
|
|
- invoiceManage.setInvoiceStatus("0");
|
|
|
- invoiceManage.setInvoiceTax(null);
|
|
|
- invoiceManage.setRemark(null);
|
|
|
- invoiceManage.setCreateUser(ShiroUtils.getUserId());
|
|
|
- invoiceManage.setCreateTime(new Date());
|
|
|
- invoiceManageService.insertSelective(invoiceManage);
|
|
|
- }
|
|
|
- }
|
|
|
+ // TODO: 2025/1/14 取消正式发票新增
|
|
|
+// // 查询合同的房款收款情况
|
|
|
+// Integer collectionStatus = contractManage.getFundCollectionStatus();
|
|
|
+// // 完全收款
|
|
|
+// if(collectionStatus == 2){
|
|
|
+// // 查询该合同是否已生成 正式发票 且类型是专项维修资金
|
|
|
+// InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
|
|
|
+// invoiceManageExample.createCriteria().andTypeEqualTo("2")
|
|
|
+// .andContractIdEqualTo(model.getContractId())
|
|
|
+// .andPaymentTypeEqualTo("2");
|
|
|
+// List<InvoiceManage> invoiceManages = invoiceManageService.selectByExample(invoiceManageExample);
|
|
|
+// if(CollectionUtils.isEmpty(invoiceManages)){
|
|
|
+// // 生成一条待推送的开票信息
|
|
|
+// InvoiceManage invoiceManage = invoiceManageService.getInfoByContract(model.getContractId(),
|
|
|
+// "*不动产*",2);
|
|
|
+// invoiceManage.setInvoiceAmount(payMoney);
|
|
|
+// // 正式发票
|
|
|
+// invoiceManage.setType("2");
|
|
|
+// // 专项维修资金
|
|
|
+// invoiceManage.setPaymentType("2");
|
|
|
+// invoiceManage.setSendStatus("0");
|
|
|
+// invoiceManage.setInvoiceStatus("0");
|
|
|
+// invoiceManage.setInvoiceTax(null);
|
|
|
+// invoiceManage.setRemark(null);
|
|
|
+// invoiceManage.setCreateUser(ShiroUtils.getUserId());
|
|
|
+// invoiceManage.setCreateTime(new Date());
|
|
|
+// invoiceManageService.insertSelective(invoiceManage);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
@@ -304,7 +326,88 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
|
|
|
|
|
|
|
|
|
|
|
|
+ public void downLoadReceipt(MaintenanceFundsManagement model, HttpServletResponse response) {
|
|
|
+
|
|
|
+ MaintenanceFundsManagementExample example = new MaintenanceFundsManagementExample();
|
|
|
+ example.createCriteria().andContractIdEqualTo(model.getContractId());
|
|
|
+ List<MaintenanceFundsManagement> maintenanceFundsManagements = selectByExample(example);
|
|
|
+ MaintenanceFundsManagement newRecord = maintenanceFundsManagements.get(0);
|
|
|
+ ContractManage contractManage = contractManageMapper.selectByPrimaryKey(newRecord.getContractId());
|
|
|
+
|
|
|
+ String filePath = "/home/project/settleDown/tem/receipt.docx";
|
|
|
+ String fileName = "专项维修资金收据.docx";
|
|
|
+ String sealPath = "/home/project/settleDown/tem/seal.png";
|
|
|
+ String sealPath2 = "/home/project/settleDown/tem/huanpiao.png";
|
|
|
+ String customerManagementId = newRecord.getCustomerManagementId();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ParkRoomResponse roomResponse = roomExtendMapper.getFullName(newRecord.getHouseId());
|
|
|
+ String fullName = roomResponse.getGroupName() + "-"
|
|
|
+ + roomResponse.getDiscName() + "-"
|
|
|
+ + roomResponse.getBuildName() + "-"
|
|
|
+ + roomResponse.getRoomNo();
|
|
|
+
|
|
|
+ String serialNumber = contractManage.getContractNumber();
|
|
|
+ String collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, newRecord.getPayTime());
|
|
|
+ String content = "专项维修资金";
|
|
|
+ String paymentMethod = "";
|
|
|
+ String dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", newRecord.getPaymentMethod().toString());
|
|
|
+ if (StringUtils.isNotEmpty(dictLabel)) {
|
|
|
+ paymentMethod = dictLabel;
|
|
|
+ }
|
|
|
+ String receivedAmount = newRecord.getPayMoney().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", "0");
|
|
|
+ settingData.put("${seal}", settingInfoData);
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ File tempWord = ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
|
|
|
+ File tempPDF = WordToPdfUtil.word2Pdf(tempWord);
|
|
|
+ response.setContentType("text/html;charset=UTF-8");
|
|
|
+ response.setContentType("application/pdf");
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "utf-8"));
|
|
|
+ OutputStream out = response.getOutputStream();
|
|
|
+ IoUtil.copy(FileUtil.getInputStream(tempPDF), out);
|
|
|
+ out.close();
|
|
|
+ tempWord.deleteOnExit();
|
|
|
+ tempPDF.deleteOnExit();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("文档生成报错:", e);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|