fix: 票池附件优先取PDF版式(taxPdfUrl)并按实际格式命名,修复OFD文件被当.pdf预览/下载失败

This commit is contained in:
刘泉佳
2026-10-05 15:52:09 +08:00
parent 08d9a87e29
commit 1d37596c2d
@@ -1244,13 +1244,21 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
}
private String buildAttachmentJson(BfiInvoicePoolVO row) {
if (Func.isEmpty(row.getDownloadUrl())) {
// 数电票 downloadUrl 可能是 OFD 版式(fileType=4,ZIP 容器),前端按扩展名选预览器:
// 依次取 PDF 版式地址(taxPdfUrl/pdfurl,A801-1 样例中两者互有空缺),都缺才用 downloadUrl 并按 fileType 命名
String path = Func.isBlank(row.getTaxPdfUrl()) ? row.getPdfurl() : row.getTaxPdfUrl();
boolean fromPdfField = !Func.isBlank(path);
if (!fromPdfField) {
path = row.getDownloadUrl();
}
if (Func.isBlank(path)) {
return null;
}
boolean ofdOnly = !fromPdfField && "4".equals(row.getFileType());
Map<String, Object> attachment = new LinkedHashMap<>();
attachment.put("source", "piaozone");
attachment.put("path", row.getDownloadUrl());
attachment.put("name", row.getInvoiceNo() + ".pdf");
attachment.put("path", path);
attachment.put("name", row.getInvoiceNo() + (ofdOnly ? ".ofd" : ".pdf"));
return JsonUtil.toJson(attachment);
}