TASK:十月优惠邮件发送接口;
This commit is contained in:
@@ -718,4 +718,53 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long HALFPRICEPROMOTION_CN_ID = 128556L;
|
||||
private final static Long HALFPRICEPROMOTION_EN_ID = 128557L;
|
||||
public static void halfPricePromotion(Account account, String senderAddress, int type) {
|
||||
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 = CODE_CREATE_SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{account.getUserEmail()});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
// if (type == 1) {
|
||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// }else {
|
||||
// subject = "即将到来的AiDA 3.0系统升级";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
||||
// }
|
||||
if (type == 1) {
|
||||
subject = "AiDA Limited Time Offer";
|
||||
template.setTemplateID(HALFPRICEPROMOTION_EN_ID);
|
||||
}else {
|
||||
subject = "AiDA国庆优惠活动";
|
||||
template.setTemplateID(HALFPRICEPROMOTION_CN_ID);
|
||||
}
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user