Explorar o código

周期支付设置过期时间优化

Bob hai 4 meses
pai
achega
348b4c5304

+ 10 - 3
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/PayCenterWebhookServiceImpl.java

@@ -432,12 +432,19 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
                         break;
                     }
                     BeanUtil.copyProperties(collect.get(0), userSubscriptionInfo1);
-                    Date date = new Date(nextBillingTime);
-                    userSubscriptionInfo1.setEndDate(date);
+                    // 获取当前时间
+                    Date currentDate = new Date();
+                    // 根据产品周期添加订阅信息记录的结束时间
+                    if (currentDate.compareTo(userSubscriptionInfo1.getEndDate()) < 0) {
+                        // 订阅未过期,设置结束时间为当前时间加产品周期
+                        currentDate = userSubscriptionInfo1.getEndDate();
+                    }
+                    Date endDate = getDateByCycle(currentDate, productVO.getCycle());
+                    userSubscriptionInfo1.setEndDate(endDate);
                     userSubscriptionInfoApi.update(userSubscriptionInfo1);
                     // 订阅过期信息
                     // 发送订阅过期消息
-                    SubscriptionUtil.subscriptionExpiredSendNews(rabbitTemplate, userSubscriptionInfo1.getId(), date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
+                    SubscriptionUtil.subscriptionExpiredSendNews(rabbitTemplate, userSubscriptionInfo1.getId(), endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
                 case "4":
                     // 订阅扣款失败,有延时队列暂不处理
                     log.info("订阅扣款失败,有延时队列暂不处理,thirdTradeId:{}", thirdTradeId);