|
@@ -135,7 +135,7 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
createSubscription.setPrice(price);
|
|
|
createSubscription.setPayTime(0);
|
|
|
subscriptionsService.createSubscription(createSubscription);
|
|
|
- String readeNo = MyDateUtils.getTimeStamp() + "-" + product.getId() + "-" + (int) ((Math.random() * 9 + 1) * 1000);
|
|
|
+ String readeNo = cn.kdan.cloud.pdf.office.payment.utils.CommonUtils.generateRightsId((long) ((Math.random() * 9999 + 1) * 10000));
|
|
|
CreateOrderManualDTO orderManualDTO = CreateOrderManualDTO.builder()
|
|
|
.thirdTradeNo(subscriptionPurchaseV2.getExternalAccountIdentifiers().getObfuscatedExternalAccountId())
|
|
|
.thirdOrderNo(subscriptionPurchaseV2.getLatestOrderId())
|
|
@@ -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()+price);
|
|
|
+ contentMap.put("@renewPrice@",orderManualDTO.getCurrency()+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);
|
|
@@ -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()+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", currency);
|
|
|
+ }
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
// 封装表单数据
|
|
@@ -298,8 +302,11 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
}
|
|
|
OrdersVO ordersVONew = orderByTradeNo.get(0);
|
|
|
ProductVO productVO = orderService.getProduct(ordersVONew.getProductId());
|
|
|
-
|
|
|
- webhookService.handleSubsequentAutomaticDeduction(productVO.getPrice(), thirdTradeNo, thirdOrderId,ordersVONew, 1, subscriptionGoogleOrderV2.toString());
|
|
|
+ BigDecimal price = productVO.getPrice();
|
|
|
+ if(orderByTradeNo.size()==1&&productVO.getCode().equals("advanced-annual-subscription-blackFive-trail")){
|
|
|
+ price = productVO.getDisplayPrice();
|
|
|
+ }
|
|
|
+ webhookService.handleSubsequentAutomaticDeduction(price, thirdTradeNo, thirdOrderId,ordersVONew, 1, subscriptionGoogleOrderV2.toString());
|
|
|
}
|
|
|
|
|
|
@Override
|