package com.ruoyi.app.pay;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/** Runs redirect-triggered recovery outside the browser request thread. */
@Service
public class LinePayAsyncService {
    private static final Logger log = LoggerFactory.getLogger(LinePayAsyncService.class);

    private final LinePayService linePayService;

    public LinePayAsyncService(LinePayService linePayService) {
        this.linePayService = linePayService;
    }

    @Async("linePayTaskExecutor")
    public void reconcile(Long paymentId, String source) {
        try {
            linePayService.reconcilePayment(paymentId, source);
        } catch (Exception exception) {
            log.warn("LINE Pay asynchronous reconcile failed, paymentId={}", paymentId);
        }
    }
}
