From d6f078ab606b3a05a7b72cfcaf0e66b30c22c689 Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 18 Feb 2025 17:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E9=82=AE=E4=BB=B6=E6=98=AF=E5=90=A6=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/common/utils/SendEmailUtil.java | 7 +++++-- .../com/ai/da/service/impl/StripeServiceImpl.java | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 1b753520..908e9a17 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -840,7 +840,7 @@ public class SendEmailUtil { private final static Long PAYMENT_FAILED_RENEWAL_USER_EN = 131563L; private final static Long PAYMENT_FAILED_RENEWAL_USER_CN = 131564L; - public static void subscriptionEmailReminder(String type, SubscriptionEmailParamsDTO subscriptionEmailParamsDTO, String language, String receiverAddress) { + public static boolean subscriptionEmailReminder(String type, SubscriptionEmailParamsDTO subscriptionEmailParamsDTO, String language, String receiverAddress) { try { String merchantEmail = "kimwong@code-create.com.hk"; String developer = "xupei3360@163.com"; @@ -917,6 +917,7 @@ public class SendEmailUtil { break; default: log.error("unknown subscription email type"); + return false; // throw new BusinessException("unknown subscription email type"); } @@ -935,9 +936,11 @@ public class SendEmailUtil { SendEmailResponse respMerchant = client.SendEmail(merchant); log.info("邮件主题:{},发送结果toMerchant###{}", merchant.getSubject(), SendEmailResponse.toJsonString(respMerchant)); } + return true; } catch (TencentCloudSDKException e) { log.info("邮件发送失败###{}", e.toString()); - throw new BusinessException("failed.to.send.mail"); + return false; +// throw new BusinessException("failed.to.send.mail"); } } diff --git a/src/main/java/com/ai/da/service/impl/StripeServiceImpl.java b/src/main/java/com/ai/da/service/impl/StripeServiceImpl.java index da203849..233e802d 100644 --- a/src/main/java/com/ai/da/service/impl/StripeServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/StripeServiceImpl.java @@ -450,7 +450,7 @@ public class StripeServiceImpl implements StripeService { InvoiceLineItem invoiceLineItem = invoice.getLines().getData().get(0); String description = invoiceLineItem.getDescription(); Long amount = invoiceLineItem.getAmount(); - log.info("单次订阅 description : {}, amount: {}", description, amount); + log.info("单次订阅 description : {}, amount: {} 分", description, amount); boolean b = createSubscriptionAndUpdateAccount(orderNo, orderByOrderNo.getAccountId(), description, amount); // 邮件通知用户 if (b){ @@ -1002,7 +1002,8 @@ public class StripeServiceImpl implements StripeService { emailParamsDTO.setEndOfPrepaidTerm(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy)); setSubscriptionParams(paymentInfo, subscriptionInfo, orderByOrderNo, emailParamsDTO, language); - SendEmailUtil.subscriptionEmailReminder(type, emailParamsDTO, language, account.getUserEmail()); + boolean b = SendEmailUtil.subscriptionEmailReminder(type, emailParamsDTO, language, account.getUserEmail()); + if (!b) return false; // 邮件通知成功后,更新标志 if (!type.equals("reminder") && !type.equals("cancel")){ @@ -1039,7 +1040,8 @@ public class StripeServiceImpl implements StripeService { emailParamsDTO.setPaymentMethod(paymentInfo.getPaymentMethod()); emailParamsDTO.setLast4(paymentInfo.getLast4()); - SendEmailUtil.subscriptionEmailReminder("fail_new", emailParamsDTO, language, account.getUserEmail()); + boolean b = SendEmailUtil.subscriptionEmailReminder("fail_new", emailParamsDTO, language, account.getUserEmail()); + if (!b) return false; // 邮件通知成功后,更新标志 PaymentInfo payment = new PaymentInfo(); @@ -1100,7 +1102,8 @@ public class StripeServiceImpl implements StripeService { setSubscriptionParams(paymentInfo, subscriptionInfo, orderByOrderNo, emailParamsDTO, language); // 4、发邮件 - SendEmailUtil.subscriptionEmailReminder("fail_renewal", emailParamsDTO, language, account.getUserEmail()); + boolean b = SendEmailUtil.subscriptionEmailReminder("fail_renewal", emailParamsDTO, language, account.getUserEmail()); + if (!b) return false; PaymentInfo payment = new PaymentInfo(); payment.setId(paymentInfo.getId());