package com.sonic.lion.service;

import com.sonic.lion.domain.req.IapUploadReceiptReq;
import org.springframework.lang.NonNull;

/**
 * @author: code
 * @date: 2025/06/24
 * @Description:
 * @version: 1.0.0
 */
public interface IapService  {

    /**
     * 计算付款手续费
     *
     * @param productAmount
     * @return
     */
    Long calculatePaymentFee(@NonNull Long productAmount);

    /**
     * 上传收据
     * @param req
     * @param currentUserId
     */
    void uploadReceipt(@NonNull IapUploadReceiptReq req, Long currentUserId);

    /**
     * 补偿处理客户端已上传还未处理的收据
     */
    void processReceipt();

    /**
     * 处理第一次订阅
     *
     * @param productId
     * @param receiptId
     * @param userId
     * @return
     */
    boolean handReceiptSubscribe(String productId, Long receiptId, Long userId);


    /**
     * 处理订阅的 回调通知
     * @param
     * @return
     */
    boolean handSubscribeWebhook(Long receiptId, String playload);

    /**
     * 处理状态变更的回调
     * @param receiptId
     * @param playload
     */
    void doWhenStatusChange(Long receiptId, String playload);

    /**
     * 处理 CANCEL 的通知类型
     * @param receiptId
     * @param playlod
     */
    void doWhenCancel(Long receiptId, String playlod);

    /**
     * 处理付款续订的通知类型
     * @param receiptId
     * @param playlod
     */
    void doWhenPay(Long receiptId, String playlod);

    /**
     * 处理付款续订失败的通知类型
     * @param receiptId
     * @param playlod
     */
    void doWhenPayFail(Long receiptId, String playlod);

    /**
     * 处理发起争议的通知类型
     * @param receiptId
     * @param playload
     */
    void doWhenConsumptionRequest(Long receiptId, String playload);
}
