Merge branch 'dev/dev' into test/stable

This commit is contained in:
2024-07-09 17:30:54 +08:00
4 changed files with 35 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ public class AccountTask {
}
// todo 多久执行一次?
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void getPaidUser(){
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
accountService.extendValidityForCC();

View File

@@ -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_CN = 0L;
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 0L;
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_CN = 0L;
private final static Long NEW_USER_PAYMENT_NOTIFICATION_EN = 124889L;
private final static Long NEW_USER_PAYMENT_NOTIFICATION_CN = 124888L;
private final static Long RENEWAL_NOTIFICATION_FOR_OLD_USER_EN = 124892L;
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 {
// 实例化一个认证对象
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
@@ -514,6 +514,7 @@ public class SendEmailUtil {
// 根据邮件类型设置不同的主题和模板
String subject = "";
Template template = new Template();
JSONObject parameter = new JSONObject();
switch (emailType) {
// 新用户
case 1:
@@ -523,6 +524,8 @@ public class SendEmailUtil {
}else {
template.setTemplateID(NEW_USER_PAYMENT_NOTIFICATION_EN);
}
parameter.put("userName", userName);
parameter.put("email", receiverAddress);
break;
// 续费用户
case 2:
@@ -535,10 +538,12 @@ public class SendEmailUtil {
break;
default:
break;
// template.setTemplateData(buildNotificationData(trialOrder, link));
}
parameter.put("userName", userName);
parameter.put("date", date);
template.setTemplateData(parameter.toJSONString());
req.setSubject(subject);
req.setTemplate(template);

View File

@@ -130,6 +130,7 @@ public interface AccountService extends IService<Account> {
void moveLibraryDate();
void updateCredits(Long accountId, String value);
void updateCreditsAndEndTime(Long accountId, String value, Long endTime);
Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO);

View File

@@ -43,6 +43,7 @@ import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -960,6 +961,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setCredits(new BigDecimal(value));
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
public Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
@@ -1034,6 +1043,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("maxLifetime", 300000);
dataSource = new HikariDataSource(config);
}
@@ -1057,7 +1067,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
String email = "";
String userName = "";
// 为什么一般没有值
String country = "";
String country = "English";
// 1、查pmr_wc_customer_lookup表确认当前订单对应的用户邮箱
PreparedStatement preparedQueryEmail = connection.prepareStatement(QUERY_CUSTOMER_EMAIL);
preparedQueryEmail.setInt(1, customerId);
@@ -1091,10 +1101,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// 2、获取当前续费费用能延长多长时间
Account account = extendValidity(validEndTime, totalSales);
int systemUserType = 0;
if (flag) {
// 是新用户 => 新增一条数据
String credits = "0";
int systemUserType = 0;
if (totalSales == 5000.0){
log.info("年付用户初始积分6000");
credits = CreditsEventsEnum.INIT_MONTHLY.getValue();
@@ -1117,14 +1127,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
if (b) log.info("付费新用户新增成功!");
} else {
userInfo.setValidEndTime(account.getValidEndTime());
baseMapper.updateById(account);
baseMapper.updateById(userInfo);
log.info("付费用户续订成功");
}
// 3、todo 邮件通知
// 3.1 判断用户语言
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
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、更新订单状态和日期
PreparedStatement preparedUpdateOrder = connection.prepareStatement(UPDATE_ORDER_STATUS);
@@ -1222,7 +1234,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
creditsService.save(creditsDetail);
// 3.3、更新 t_account 表
updateCredits(account.getId(), added.toString());
if (account.getValidEndTime() < 1720972799000L){
updateCreditsAndEndTime(account.getId(), added.toString(), 1720972799000L);
}
}
// 4、发邮件 区分中英文