付费用户邮件通知
This commit is contained in:
@@ -23,6 +23,7 @@ public class AccountTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo 多久执行一次?
|
// todo 多久执行一次?
|
||||||
|
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||||
public void getPaidUser(){
|
public void getPaidUser(){
|
||||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
||||||
accountService.extendValidityForCC();
|
accountService.extendValidityForCC();
|
||||||
|
|||||||
@@ -493,12 +493,12 @@ public class SendEmailUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 0L;
|
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 124889L;
|
||||||
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 0L;
|
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 124888L;
|
||||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 0L;
|
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 124892L;
|
||||||
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 0L;
|
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 124891L;
|
||||||
|
|
||||||
public static void notificationForPaidUser(String receiverAddress, int emailType, String country){
|
public static void notificationForPaidUser(String receiverAddress, int emailType, String country, String userName, String date){
|
||||||
try {
|
try {
|
||||||
// 实例化一个认证对象
|
// 实例化一个认证对象
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||||
@@ -514,6 +514,7 @@ public class SendEmailUtil {
|
|||||||
// 根据邮件类型设置不同的主题和模板
|
// 根据邮件类型设置不同的主题和模板
|
||||||
String subject = "";
|
String subject = "";
|
||||||
Template template = new Template();
|
Template template = new Template();
|
||||||
|
JSONObject parameter = new JSONObject();
|
||||||
switch (emailType) {
|
switch (emailType) {
|
||||||
// 新用户
|
// 新用户
|
||||||
case 1:
|
case 1:
|
||||||
@@ -523,6 +524,8 @@ public class SendEmailUtil {
|
|||||||
}else {
|
}else {
|
||||||
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
|
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
|
||||||
}
|
}
|
||||||
|
parameter.put("userName", userName);
|
||||||
|
parameter.put("email", receiverAddress);
|
||||||
break;
|
break;
|
||||||
// 续费用户
|
// 续费用户
|
||||||
case 2:
|
case 2:
|
||||||
@@ -535,10 +538,12 @@ public class SendEmailUtil {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// template.setTemplateData(buildNotificationData(trialOrder, link));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter.put("userName", userName);
|
||||||
|
parameter.put("date", date);
|
||||||
|
template.setTemplateData(parameter.toJSONString());
|
||||||
|
|
||||||
req.setSubject(subject);
|
req.setSubject(subject);
|
||||||
req.setTemplate(template);
|
req.setTemplate(template);
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public interface AccountService extends IService<Account> {
|
|||||||
void moveLibraryDate();
|
void moveLibraryDate();
|
||||||
|
|
||||||
void updateCredits(Long accountId, String value);
|
void updateCredits(Long accountId, String value);
|
||||||
|
void updateCreditsAndEndTime(Long accountId, String value, Long endTime);
|
||||||
|
|
||||||
Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO);
|
Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO);
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import java.math.BigDecimal;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@@ -960,6 +961,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
account.setCredits(new BigDecimal(value));
|
account.setCredits(new BigDecimal(value));
|
||||||
accountMapper.updateById(account);
|
accountMapper.updateById(account);
|
||||||
}
|
}
|
||||||
|
// todo 将其与上一个合并
|
||||||
|
public void updateCreditsAndEndTime(Long accountId, String value, Long endTime) {
|
||||||
|
Account account = new Account();
|
||||||
|
account.setId(accountId);
|
||||||
|
account.setCredits(new BigDecimal(value));
|
||||||
|
account.setValidEndTime(endTime);
|
||||||
|
accountMapper.updateById(account);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
public Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
|
||||||
@@ -1034,6 +1043,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
|
config.addDataSourceProperty("maxLifetime", 300000);
|
||||||
dataSource = new HikariDataSource(config);
|
dataSource = new HikariDataSource(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1057,7 +1067,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
String email = "";
|
String email = "";
|
||||||
String userName = "";
|
String userName = "";
|
||||||
// 为什么一般没有值
|
// 为什么一般没有值
|
||||||
String country = "";
|
String country = "English";
|
||||||
// 1、查pmr_wc_customer_lookup表;确认当前订单对应的用户邮箱
|
// 1、查pmr_wc_customer_lookup表;确认当前订单对应的用户邮箱
|
||||||
PreparedStatement preparedQueryEmail = connection.prepareStatement(QUERY_CUSTOMER_EMAIL);
|
PreparedStatement preparedQueryEmail = connection.prepareStatement(QUERY_CUSTOMER_EMAIL);
|
||||||
preparedQueryEmail.setInt(1, customerId);
|
preparedQueryEmail.setInt(1, customerId);
|
||||||
@@ -1091,10 +1101,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
// 2、获取当前续费费用能延长多长时间
|
// 2、获取当前续费费用能延长多长时间
|
||||||
Account account = extendValidity(validEndTime, totalSales);
|
Account account = extendValidity(validEndTime, totalSales);
|
||||||
|
|
||||||
|
int systemUserType = 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
// 是新用户 => 新增一条数据
|
// 是新用户 => 新增一条数据
|
||||||
String credits = "0";
|
String credits = "0";
|
||||||
int systemUserType = 0;
|
|
||||||
if (totalSales == 5000.0){
|
if (totalSales == 5000.0){
|
||||||
log.info("年付用户,初始积分6000");
|
log.info("年付用户,初始积分6000");
|
||||||
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
|
||||||
@@ -1117,14 +1127,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (b) log.info("付费新用户新增成功!");
|
if (b) log.info("付费新用户新增成功!");
|
||||||
} else {
|
} else {
|
||||||
userInfo.setValidEndTime(account.getValidEndTime());
|
userInfo.setValidEndTime(account.getValidEndTime());
|
||||||
baseMapper.updateById(account);
|
baseMapper.updateById(userInfo);
|
||||||
log.info("付费用户续订成功");
|
log.info("付费用户续订成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、todo 邮件通知
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
// 3.1 判断用户语言
|
String format = simpleDateFormat.format(account.getValidEndTime());
|
||||||
|
|
||||||
// 3.2 将用户信息填到邮件中
|
// 3、邮件通知
|
||||||
|
SendEmailUtil.notificationForPaidUser(email, flag ? 1 : 2, country,
|
||||||
|
StringUtil.isNullOrEmpty(userName) ? email.substring(0, email.indexOf("@")) : userName, format);
|
||||||
|
|
||||||
// 4、更新订单状态和日期
|
// 4、更新订单状态和日期
|
||||||
PreparedStatement preparedUpdateOrder = connection.prepareStatement(UPDATE_ORDER_STATUS);
|
PreparedStatement preparedUpdateOrder = connection.prepareStatement(UPDATE_ORDER_STATUS);
|
||||||
@@ -1222,7 +1234,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
creditsService.save(creditsDetail);
|
creditsService.save(creditsDetail);
|
||||||
|
|
||||||
// 3.3、更新 t_account 表
|
// 3.3、更新 t_account 表
|
||||||
updateCredits(account.getId(), added.toString());
|
if (account.getValidEndTime() < 1720972799000L){
|
||||||
|
updateCreditsAndEndTime(account.getId(), added.toString(), 1720972799000L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4、发邮件 区分中英文
|
// 4、发邮件 区分中英文
|
||||||
|
|||||||
Reference in New Issue
Block a user