Skip to content

Commit

Permalink
FEAT:fixing subscription algorthm
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo pelu committed Dec 7, 2024
1 parent 5e0f35c commit 26f21a4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/com/pos/app/service/impl/PaymentServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,21 @@ public ResponseEnum postNotificationFromMidTrans(ReqNotificationMidTrans req) {
if (findOrder.isPresent()) {
subscriptionOrder = findOrder.get();

if (req.getTransactionStatus().equals("settlement")) {
Long currentExpiredDate = 0L;
if ("settlement".equals(req.getTransactionStatus())) {
Client client = subscriptionOrder.getClient();
BigInteger subscriptionDurationPerDay = subscriptionOrder.getSubscriptionPackage().getDurationPerDay();
Long durationSubscription = UtilsHelper.addDaysUnixTime(new Date().getTime(), subscriptionDurationPerDay);

Long additionalDuration = UtilsHelper.addDaysUnixTime(0L, subscriptionDurationPerDay);

Long currentExpiredDate = client.getSubscriptionExpiredDate() != null
? client.getSubscriptionExpiredDate()
: new Date().getTime() / 1000;

Long newExpiredDate = currentExpiredDate + additionalDuration;
client.setSubscriptionExpiredDate(newExpiredDate);

subscriptionOrder.setStatus(SubscriptionOrderStatusEnum.SUCCESS);
client.setIsActiveSubscription(true);
if (client.getSubscriptionExpiredDate() != null) {
currentExpiredDate = client.getSubscriptionExpiredDate();
}
client.setSubscriptionExpiredDate(currentExpiredDate + durationSubscription);
}
}

Expand Down

0 comments on commit 26f21a4

Please sign in to comment.