dev comment logic for check max users
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-02-20 20:51:14 +07:00
parent 86e0e0619f
commit 5551d84bf7
30 changed files with 1167 additions and 3 deletions
@@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.soune.ReferralService;
import ru.soune.nocopy.entity.payment.Payment;
import ru.soune.nocopy.entity.payment.PaymentOperationType;
import ru.soune.nocopy.entity.payment.PaymentStatus;
@@ -38,6 +39,8 @@ public class PaymentService {
private final TariffInfoService tariffInfoService;
private final ReferralService referralService;
@Transactional
public Payment createPayment(String email, Long tariffId, String operationType, String paymentUuid) {
User user = userRepository.findByEmail(email);
@@ -70,9 +73,15 @@ public class PaymentService {
.orElseThrow(() -> new PaymentNotFoundException("Payment not found"));
if ("payment.succeeded".equals(eventType)) {
Tariff tariff = payment.getTariff();
double price = tariff.getPrice();
int intPrice = (int) Math.round(price);
payment.setStatus(PaymentStatus.SUCCEEDED);
payment.setCancellationReason(null);
activateTariffForUser(payment.getUser(), payment.getTariff());
activateTariffForUser(payment.getUser(), tariff);
referralService.onUserAccountRefill(payment.getUser().getId(), intPrice);
} else if ("payment.canceled".equals(eventType)) {
payment.setStatus(PaymentStatus.CANCELED);