BUGFIX:试用时间link14天;
This commit is contained in:
@@ -136,7 +136,7 @@ public class SendEmailUtil {
|
||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||
private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L;
|
||||
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country, boolean link) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -173,7 +173,7 @@ public class SendEmailUtil {
|
||||
}else {
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
}
|
||||
template.setTemplateData(buildNotificationData(trialOrder));
|
||||
template.setTemplateData(buildNotificationData(trialOrder, link));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -345,7 +345,7 @@ public class SendEmailUtil {
|
||||
}
|
||||
|
||||
// 构建试用订单通过通知数据
|
||||
private static String buildNotificationData(TrialOrder trialOrder) {
|
||||
private static String buildNotificationData(TrialOrder trialOrder, boolean link) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 设置试用订单通过通知相关数据
|
||||
jsonObject.put("title", trialOrder.getTitle());
|
||||
@@ -353,6 +353,11 @@ public class SendEmailUtil {
|
||||
jsonObject.put("givenName", trialOrder.getGivenName());
|
||||
jsonObject.put("userName", trialOrder.getUserName());
|
||||
jsonObject.put("email", trialOrder.getEmail());
|
||||
if (link) {
|
||||
jsonObject.put("days", 14);
|
||||
}else {
|
||||
jsonObject.put("days", 5);
|
||||
}
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
@ApiModel("AccountTrial")
|
||||
public class AccountTrialDTO extends TrialOrder {
|
||||
|
||||
private String ref;
|
||||
}
|
||||
|
||||
@@ -468,6 +468,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
public Boolean addTrialUser(AccountTrialDTO accountTrialDTO, HttpServletRequest request) {
|
||||
// 获取用户申请试用IP
|
||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||
boolean link = false;
|
||||
if (StringUtils.isNotBlank(accountTrialDTO.getRef())) {
|
||||
link = true;
|
||||
}
|
||||
// 先检测试用订单
|
||||
QueryWrapper<TrialOrder> trialOrderQueryWrapper = new QueryWrapper<>();
|
||||
trialOrderQueryWrapper.eq("BINARY email", accountTrialDTO.getEmail());
|
||||
@@ -515,7 +519,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
account.setIsTrial(1);
|
||||
account.setIsBeginner(1);
|
||||
account.setValidStartTime(System.currentTimeMillis());
|
||||
account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli());
|
||||
if (link) {
|
||||
account.setValidEndTime(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli());
|
||||
}else {
|
||||
account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli());
|
||||
}
|
||||
accountMapper.updateById(account);
|
||||
}else {
|
||||
account.setUserName(trialOrder.getUserName());
|
||||
@@ -523,7 +531,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
account.setUserEmail(trialOrder.getEmail());
|
||||
account.setLanguage(Language.ENGLISH.name());
|
||||
account.setValidStartTime(System.currentTimeMillis());
|
||||
account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli());
|
||||
if (link) {
|
||||
account.setValidEndTime(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli());
|
||||
}else {
|
||||
account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli());
|
||||
}
|
||||
account.setCreateDate(new Date());
|
||||
account.setIsTrial(1);
|
||||
account.setIsBeginner(1);
|
||||
@@ -534,9 +546,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2);
|
||||
// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2);
|
||||
if (trialOrder.getCountry().equals("China")) {
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry(), link);
|
||||
}else {
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry(), link);
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
@@ -586,9 +598,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2, trialOrder.getCountry());
|
||||
// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2, trialOrder.getCountry());
|
||||
if (trialOrder.getCountry().equals("China")) {
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry(), false);
|
||||
}else {
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry(), false);
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
|
||||
Reference in New Issue
Block a user