From c1a537aaa86fbb878cea6ab29a2df41ae15a4c48 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期日, 18 二月 2024 16:22:35 +0800
Subject: [PATCH] 修改bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |   15 ++++++++-------
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/itextpdf/HtmlToPdfUtils.java                  |   23 ++++++++++++-----------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index fb22ad0..9c3b445 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -209,9 +209,6 @@
             Map<String, Object> data = price.getData();
             Double ordinary = Double.valueOf(data.get("ordinary").toString());
             Double precious = Double.valueOf(data.get("precious").toString());
-            Double discount = Double.valueOf(data.get("discount").toString());
-            Double discountMoney = Double.valueOf(data.get("discountMoney").toString());
-            Integer activityId = Integer.valueOf(data.get("activityId").toString());
             data.put("ordinary", ordinary * number);
             data.put("precious", precious * number);
         }
@@ -219,9 +216,7 @@
             Map<String, Object> data = price.getData();
             Double ordinary = Double.valueOf(data.get("ordinary").toString());
             Double precious = Double.valueOf(data.get("precious").toString());
-            Double discount = Double.valueOf(data.get("discount").toString());
             Double discountMoney = Double.valueOf(data.get("discountMoney").toString());
-            Integer activityId = Integer.valueOf(data.get("activityId").toString());
             data.put("ordinary", ordinary - discountMoney);
             data.put("precious", precious - discountMoney);
         }
@@ -302,9 +297,15 @@
         Map<String, Object> data = price.getData();
         Double ordinary = Double.valueOf(data.get("ordinary").toString());
         Double precious = Double.valueOf(data.get("precious").toString());
-        Double discount = Double.valueOf(data.get("discount").toString());
+        Double discount = null;
+        if(null != data.get("discount")){
+            discount = Double.valueOf(data.get("discount").toString());
+        }
         Double discountMoney = Double.valueOf(data.get("discountMoney").toString());
-        Integer activityId = Integer.valueOf(data.get("activityId").toString());
+        Integer activityId = null;
+        if(null != data.get("activityId")){
+            activityId = Integer.valueOf(data.get("activityId").toString());
+        }
         orderLogistics.setOrderMoney((cargoType == 1 ? ordinary : precious) + tipMoney);
         orderLogistics.setTravelMoney((cargoType == 1 ? ordinary : precious));
         if(type == 5){
diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/itextpdf/HtmlToPdfUtils.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/itextpdf/HtmlToPdfUtils.java
index fc03ade..1a0093f 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/itextpdf/HtmlToPdfUtils.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/itextpdf/HtmlToPdfUtils.java
@@ -9,6 +9,7 @@
 import com.itextpdf.kernel.pdf.PdfDocument;
 import com.itextpdf.kernel.pdf.PdfWriter;
 import com.itextpdf.layout.font.FontProvider;
+import org.apache.commons.lang.StringUtils;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -66,21 +67,21 @@
 
         //添加页码
         //pdfDocument.addEventHandler(PdfDocumentEvent.END_PAGE,new PageEventHandler());
-//        //添加中文字体支持
-//        ConverterProperties properties = new ConverterProperties();
-//        FontProvider fontProvider = new FontProvider();
-//
-//        PdfFont sysFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
-//        fontProvider.addFont(sysFont.getFontProgram(), "UniGB-UCS2-H");
-//
-//        //添加自定义字体,例如微软雅黑
+        //添加中文字体支持
+        ConverterProperties properties = new ConverterProperties();
+        FontProvider fontProvider = new FontProvider();
+
+        PdfFont sysFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
+        fontProvider.addFont(sysFont.getFontProgram(), "UniGB-UCS2-H");
+
+        //添加自定义字体,例如微软雅黑
 //        if (StringUtils.isNotBlank(fontPath)){
 //            PdfFont microsoft = PdfFontFactory.createFont(fontPath, PdfEncodings.IDENTITY_H, false);
 //            fontProvider.addFont(microsoft.getFontProgram(), PdfEncodings.IDENTITY_H);
 //        }
-//
-//        properties.setFontProvider(fontProvider);
-        HtmlConverter.convertToPdf(htmlStream, pdfDocument);
+
+        properties.setFontProvider(fontProvider);
+        HtmlConverter.convertToPdf(htmlStream, pdfDocument, properties);
 
         pdfWriter.close();
         pdfDocument.close();

--
Gitblit v1.7.1