BUGFIX:aida;
This commit is contained in:
@@ -9,12 +9,14 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.ses.v20201002.SesClient;
|
||||
import com.tencentcloudapi.ses.v20201002.models.Attachment;
|
||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
||||
import com.tencentcloudapi.ses.v20201002.models.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -130,7 +132,9 @@ public class SendEmailUtil {
|
||||
private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L;
|
||||
private final static Long APPROVAL_TEMPLATE_ID = 117215L;
|
||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType) {
|
||||
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -162,7 +166,11 @@ public class SendEmailUtil {
|
||||
break;
|
||||
case 3:
|
||||
subject = "Approval Confirmation for AiDA System Trial Access";
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID);
|
||||
}else {
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
}
|
||||
template.setTemplateData(buildNotificationData(trialOrder));
|
||||
break;
|
||||
default:
|
||||
@@ -180,6 +188,45 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendExcelEmail(String receiverAddress, String senderAddress, byte[] fileContent, String fileName) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "昨日试用订单数据";
|
||||
template.setTemplateID(TRIAL_ORDER_LIST_ID);
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
Attachment attachment = new Attachment();
|
||||
attachment.setFileName(fileName); // 设置附件文件名
|
||||
// 设置附件内容
|
||||
attachment.setContent(Base64.getEncoder().encodeToString(fileContent));
|
||||
req.setAttachments(new Attachment[] {attachment});
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
||||
try {
|
||||
@@ -293,7 +340,7 @@ public class SendEmailUtil {
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "Notice: AiDA 3.0 Website Maintenance Downtime";
|
||||
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
|
||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user