package com.ruoyi.system.omgpay.service;

import com.ruoyi.system.omgpay.domain.OmgPaymentAttempt;
import com.ruoyi.system.omgpay.domain.OmgPaymentOrderSnapshot;

import java.util.Date;
import java.util.List;

/**
 * Transaction-participating operations needed to create one OMG payment attempt.
 */
public interface IOmgPaymentAttemptService {
    OmgPaymentOrderSnapshot selectOrderForUpdate(String ddId);

    OmgPaymentOrderSnapshot selectOrder(String ddId);

    /** Current read that makes committed active attempts visible during duplicate classification. */
    OmgPaymentAttempt selectActiveCreatedByDdIdForUpdate(String ddId);

    OmgPaymentAttempt selectActiveCreatedByDdId(String ddId);

    OmgPaymentAttempt selectPaidByDdId(String ddId);

    /** Current read that classifies a committed MerchantTradeNo unique-key collision. */
    OmgPaymentAttempt selectByMerchantTradeNoForUpdate(String merchantTradeNo);

    OmgPaymentAttempt selectByMerchantTradeNo(String merchantTradeNo);

    List<OmgPaymentAttempt> scanDueCreated(Date now, int limit);

    int reserveDueQuery(Long id, Date now, Date nextQueryTime);

    OmgPaymentAttempt createCreated(String ddId, String merchantTradeNo, Long storeId,
                                    String merchantId, Integer amount,
                                    String hashKeySnapshot, String hashIvSnapshot);

    int markPaid(OmgPaymentAttempt paymentFacts);

    int markFailed(OmgPaymentAttempt paymentFacts);

    int supersedeCreated(Long id);

    int supersedeOtherCreated(String ddId, Long paidAttemptId);

    int markOrderPaid(String ddId);

    int countOtherPaidAttempts(String ddId, Long attemptId);
}
