新增接口:调查问卷

This commit is contained in:
2024-06-20 10:27:04 +08:00
parent c317942447
commit 227c742f0d
12 changed files with 438 additions and 26 deletions

View File

@@ -50,7 +50,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
"/api/portfolio/page", "/api/portfolio/detail",
"/api/account/designWorksRegister"
"/api/account/designWorksRegister","/api/account/questionnaire"
);
@Override

View File

@@ -450,6 +450,106 @@ public class SendEmailUtil {
}
}
private final static Long QUESTIONNAIRE_FEEDBACK_EN_ID = 124151L;
private final static Long QUESTIONNAIRE_FEEDBACK_CN_ID = 124156L;
public static void questionnaireRelatedNotify(String userName, String email, String language){
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();
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
req.setDestination(new String[]{email});
// 根据邮件类型设置不同的主题和模板
Template template = new Template();
String subject = "Thank You for Completing the AiDA System Survey";
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_EN_ID);
if (language.equals("CN")) {
subject = "感谢您完成AiDA系统问卷调查";
template.setTemplateID(QUESTIONNAIRE_FEEDBACK_CN_ID);
}
JSONObject parameter = new JSONObject();
parameter.put("userName", userName);
template.setTemplateData(parameter.toJSONString());
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");
}
}
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 0L;
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 0L;
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 0L;
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 0L;
public static void notificationForPaidUser(String receiverAddress, int emailType, String country){
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();
req.setFromEmailAddress(SEND_ADDRESS);
req.setDestination(new String[]{receiverAddress});
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
switch (emailType) {
// 新用户
case 1:
subject = "Welcome to AiDA!";
if (country.equals("China")) {
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_CN);
}else {
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
}
break;
// 续费用户
case 2:
subject = "Account renewal notification";
if (country.equals("China")) {
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_CN);
}else {
template.setTemplateID(RENEWAL_NOTIFICATION_FOR_OLD_USER_EN);
}
break;
default:
break;
// template.setTemplateData(buildNotificationData(trialOrder, link));
}
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");
}
}
public static Boolean designWorksRegister(String userEmail, String randomVerifyCode) {
try {