TASK:数据迁移;

This commit is contained in:
shahaibo
2024-01-26 13:17:59 +08:00
parent 449c568907
commit 62e6f8b77d
12 changed files with 391 additions and 9 deletions

View File

@@ -196,7 +196,7 @@ public class MinioUtil {
}
}
}
return bucketName + path;
return bucketName + "/" + path;
}
// public String upload(String bucketName, String path, File file) {

View File

@@ -34,6 +34,7 @@ public class SendEmailUtil {
* 发信地址
*/
private static String SEND_ADDRESS = "info@aida.com.hk";
private final static String CODE_CREATE_SEND_ADDRESS = "info@code-create.com.hk";
/**
* 登入主题
*/
@@ -219,18 +220,20 @@ public class SendEmailUtil {
JSONObject jsonObject = new JSONObject();
// 设置试用订单相关数据
jsonObject.put("userName", account.getUserName());
// 用户到期时间戳
Long timestamp = account.getValidEndTime(); // 替换为你的时间戳
if (null != timestamp) {
// 获取当前时间戳
Long currentTimestamp = System.currentTimeMillis();
// 获取当前时间戳
Long currentTimestamp = System.currentTimeMillis();
// 计算时间差(毫秒)
long timeDifference = currentTimestamp - timestamp;
// 计算时间差(毫秒)
long timeDifference = currentTimestamp - timestamp;
// 向上取整计算天数
long days = (timeDifference + 24 * 60 * 60 * 1000 - 1) / (24 * 60 * 60 * 1000);
jsonObject.put("days", days);
// 向上取整计算天数
long days = (timeDifference + 24 * 60 * 60 * 1000 - 1) / (24 * 60 * 60 * 1000);
jsonObject.put("days", days);
}
return jsonObject.toJSONString();
}
@@ -269,4 +272,40 @@ public class SendEmailUtil {
jsonObject.put("email", trialOrder.getEmail());
return jsonObject.toJSONString();
}
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
public static void sendUpgradeNotification(Account account, String senderAddress) {
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();
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
template.setTemplateID(UPGRADE_NOTIFICATION_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");
}
}
}