添加判断,确认邮件是否发送成功

This commit is contained in:
2025-02-18 17:07:16 +08:00
parent a940863799
commit d6f078ab60
2 changed files with 12 additions and 6 deletions

View File

@@ -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");
}
}

View File

@@ -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());