Compare commits
4 Commits
921de43b08
...
61e8901bb1
| Author | SHA1 | Date | |
|---|---|---|---|
| 61e8901bb1 | |||
| 1680debd4b | |||
| bd6ba95a25 | |||
| 75efc341be |
@@ -3383,13 +3383,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
if (!Objects.isNull(account.getValidEndTime())
|
||||
&& account.getValidEndTime().equals(currentPeriodEnd * 1000)) {
|
||||
log.info("accountId:{}未更新账号有效期。current validEnd:{}, new validEnd:{}", accountId, account.getValidEndTime(), currentPeriodEnd);
|
||||
return false;
|
||||
} else {
|
||||
account.setValidEndTime(currentPeriodEnd * 1000);
|
||||
accountMapper.updateById(account);
|
||||
log.info("accountId:{} 将账号有效期更新到 {}", accountId, currentPeriodEnd);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -486,7 +486,8 @@ public class StripeServiceImpl implements StripeService {
|
||||
emailParamsDTO.setEmail(account.getUserEmail());
|
||||
emailParamsDTO.setCountry(paymentInfo.getCountry());
|
||||
emailParamsDTO.setOrderId(paymentInfo.getId().toString());
|
||||
emailParamsDTO.setOrderRef("\"" + orderListLink + paymentInfo.getId().toString() + "\"");
|
||||
// emailParamsDTO.setOrderRef("\"" + orderListLink + paymentInfo.getId().toString() + "\"");
|
||||
emailParamsDTO.setOrderRef("\"" + paymentInfo.getHostedInvoiceUrl() + "\"");
|
||||
emailParamsDTO.setCreateDate(String.valueOf(paymentInfo.getCreateTime()).replace("T", " "));
|
||||
emailParamsDTO.setQuantity(String.valueOf(1));
|
||||
emailParamsDTO.setTotalFee(paymentInfo.getPayerTotal().toString());
|
||||
|
||||
@@ -135,13 +135,17 @@ public class StripeSubscriptionServiceImpl implements StripeSubscriptionService
|
||||
// renewal 场景:从 InvoicePaidHandler 直接传入已更新的 SubscriptionInfo,避免事务未提交导致查询不到
|
||||
if (passedInfo != null) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
// 限制当前时间在订阅区间内,避免处理上个周期内的回调而重复发送邮件
|
||||
if (now > passedInfo.getCurrentPeriodStart() && now < passedInfo.getCurrentPeriodEnd()
|
||||
&& "active".equals(passedInfo.getStatus())) {
|
||||
boolean inPeriod = now > passedInfo.getCurrentPeriodStart() && now < passedInfo.getCurrentPeriodEnd();
|
||||
// 续订失败的场景,可能订单状态已被更新为past_due
|
||||
boolean validStatus = "fail_renewal".equals(type)
|
||||
? ("past_due".equals(passedInfo.getStatus()) || "active".equals(passedInfo.getStatus()))
|
||||
: "active".equals(passedInfo.getStatus());
|
||||
if (inPeriod && validStatus) {
|
||||
return passedInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(orderNo)) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
List<SubscriptionInfo> infos = subscriptionInfoMapper.selectList(
|
||||
|
||||
@@ -96,10 +96,6 @@ public class CheckoutSessionExpiredHandler implements StripeEventHandler {
|
||||
// 首次订阅失败
|
||||
stripeSubscriptionService.sendFailedNewOrderEmail(orderNo);
|
||||
log.info("[checkout.session.expired] 首次订阅失败邮件已发送,orderNo={}", orderNo);
|
||||
} else {
|
||||
// 续费失败 todo 续费不走这里吧?
|
||||
stripeSubscriptionService.sendSubscriptionEmail(null, "fail_renewal", subInfoList.getFirst().getOrderNo(), null);
|
||||
log.info("[checkout.session.expired] 续费失败邮件已发送,orderNo={}", orderNo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class InvoicePaidHandler implements StripeEventHandler {
|
||||
updateSubscriptionPeriod(invoice, subscriptionInfo);
|
||||
|
||||
// 更新用户积分、账号到期时间,添加积分详细记录
|
||||
accountService.updateAccountValidity(subscriptionInfo.getAccountId(), invoice.getPeriodEnd());
|
||||
accountService.updateAccountValidity(subscriptionInfo.getAccountId(), subscriptionInfo.getCurrentPeriodEnd());
|
||||
accountService.updateUserRoleAndCredits(subscriptionInfo.getAccountId(), subscriptionInfo.getOrderNo());
|
||||
|
||||
// 发送通知邮件
|
||||
|
||||
Reference in New Issue
Block a user