Browse Source

Bug修复

tangxiangan 3 months ago
parent
commit
88d5564f03

+ 10 - 6
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/AppStoreServiceImpl.java

@@ -177,12 +177,13 @@ public class AppStoreServiceImpl implements AppStoreService {
                 price = ObjectUtils.isNotEmpty(product.getCnyDisplayPrice())? product.getCnyDisplayPrice().toString() : product.getCnyPrice().toString();
                 renewPrice = product.getCnyPrice();
             }
-            contentMap.put("@payPrice@", price);
-            contentMap.put("@renewPrice@", renewPrice.toString());
+            contentMap.put("@payPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+price:"¥"+price);
+            contentMap.put("@renewPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+renewPrice.toString():"¥"+renewPrice.toString());
+
             bo.setSendTitleContent(titleMap);
             //设置内容
             bo.setSendContent(contentMap);
-            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
+            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice(),orderManualDTO.getCurrency());
             bo.setFileUrl(file);
             bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
@@ -211,11 +212,11 @@ public class AppStoreServiceImpl implements AppStoreService {
                 price = ObjectUtils.isNotEmpty(product.getCnyDisplayPrice())? product.getCnyDisplayPrice().toString() : product.getCnyPrice().toString();
                 renewPrice = product.getCnyPrice();
             }
-            contentMap.put("@payPrice@", price);
+            contentMap.put("@payPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+price:"¥"+price);
             bo.setSendTitleContent(titleMap);
             //设置内容
             bo.setSendContent(contentMap);
-            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
+            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice(),orderManualDTO.getCurrency());
             bo.setFileUrl(file);
             bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
@@ -223,7 +224,7 @@ public class AppStoreServiceImpl implements AppStoreService {
     }
 
     //生成发票
-    private String sendInvoice(String email, String purchasedDate,String tradeNo,String invoiceNumber,BigDecimal unitPrice,BigDecimal amount) {
+    private String sendInvoice(String email, String purchasedDate,String tradeNo,String invoiceNumber,BigDecimal unitPrice,BigDecimal amount,String currency) {
         String invoiceHtml = null;
         try {
             invoiceHtml = new String(StreamUtils.copyToByteArray(this.getClass().getClassLoader().getResourceAsStream("templates/invoice_member.html")), StandardCharsets.UTF_8);
@@ -246,6 +247,9 @@ public class AppStoreServiceImpl implements AppStoreService {
         log.info("发票html内容填充map:{}", map);
         // 生成替换内容后的发票
         String htmlStr = TemplatesUtil.replaceStringUsingFreeMarker(invoiceHtml, map);
+        if (!currency.equals("USD")) {
+            htmlStr = htmlStr.replace("USD", "CNY");
+        }
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
         // 封装表单数据

+ 10 - 6
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/GooglePayServiceImpl.java

@@ -190,12 +190,13 @@ public class GooglePayServiceImpl implements GooglePayService {
                 price = ObjectUtils.isNotEmpty(product.getCnyDisplayPrice())? product.getCnyDisplayPrice().toString() : product.getCnyPrice().toString();
                 renewPrice = product.getCnyPrice();
             }
-            contentMap.put("@payPrice@", price);
-            contentMap.put("@renewPrice@", renewPrice.toString());
+            contentMap.put("@payPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+price:"¥"+price);
+            contentMap.put("@renewPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+renewPrice.toString():"¥"+renewPrice.toString());
+
             bo.setSendTitleContent(titleMap);
             //设置内容
             bo.setSendContent(contentMap);
-            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
+            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice(),orderManualDTO.getCurrency());
             bo.setFileUrl(file);
             bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
@@ -224,11 +225,11 @@ public class GooglePayServiceImpl implements GooglePayService {
                 price = ObjectUtils.isNotEmpty(product.getCnyDisplayPrice())? product.getCnyDisplayPrice().toString() : product.getCnyPrice().toString();
                 renewPrice = product.getCnyPrice();
             }
-            contentMap.put("@payPrice@", price);
+            contentMap.put("@payPrice@", orderManualDTO.getCurrency().equals("USD")?"$"+price:"¥"+price);
             bo.setSendTitleContent(titleMap);
             //设置内容
             bo.setSendContent(contentMap);
-            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
+            String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice(),orderManualDTO.getCurrency());
             bo.setFileUrl(file);
             bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
@@ -236,7 +237,7 @@ public class GooglePayServiceImpl implements GooglePayService {
     }
 
     //生成发票
-    private String sendInvoice(String email, String purchasedDate,String tradeNo,String invoiceNumber,BigDecimal unitPrice,BigDecimal amount) {
+    private String sendInvoice(String email, String purchasedDate,String tradeNo,String invoiceNumber,BigDecimal unitPrice,BigDecimal amount,String currency) {
         String invoiceHtml = null;
         try {
             invoiceHtml = new String(StreamUtils.copyToByteArray(this.getClass().getClassLoader().getResourceAsStream("templates/invoice_member.html")), StandardCharsets.UTF_8);
@@ -259,6 +260,9 @@ public class GooglePayServiceImpl implements GooglePayService {
         log.info("发票html内容填充map:{}", map);
         // 生成替换内容后的发票
         String htmlStr = TemplatesUtil.replaceStringUsingFreeMarker(invoiceHtml, map);
+        if (!currency.equals("USD")) {
+            htmlStr = htmlStr.replace("USD", "CNY");
+        }
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
         // 封装表单数据