using HoneyBox.Model.Models.Payment;

namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 支付回调服务接口
/// </summary>
public interface IPaymentNotifyService
{
    /// <summary>
    /// 处理微信支付回调（自动识别 V2/V3 格式）
    /// </summary>
    /// <param name="notifyBody">回调请求体</param>
    /// <param name="headers">回调请求头（V3 需要用于签名验证）</param>
    /// <returns>回调处理结果</returns>
    Task<NotifyResult> HandleWechatNotifyAsync(string notifyBody, WechatPayNotifyHeaders? headers = null);

    /// <summary>
    /// 处理微信支付 V2 回调（XML 格式）
    /// </summary>
    /// <param name="xmlData">微信回调XML数据</param>
    /// <returns>回调处理结果</returns>
    Task<NotifyResult> HandleWechatV2NotifyAsync(string xmlData);

    /// <summary>
    /// 处理微信支付 V3 回调（JSON 格式）
    /// </summary>
    /// <param name="jsonData">微信回调JSON数据</param>
    /// <param name="headers">回调请求头</param>
    /// <returns>回调处理结果</returns>
    Task<NotifyResult> HandleWechatV3NotifyAsync(string jsonData, WechatPayNotifyHeaders headers);

    /// <summary>
    /// 处理一番赏订单支付成功
    /// </summary>
    /// <param name="orderId">订单ID</param>
    /// <param name="userId">用户ID</param>
    /// <param name="goodsId">商品ID</param>
    /// <param name="num">箱号</param>
    /// <returns>是否处理成功</returns>
    Task<bool> ProcessLotteryOrderAsync(int orderId, int userId, int goodsId, int num);

    /// <summary>
    /// 处理无限赏订单支付成功
    /// </summary>
    /// <param name="orderId">订单ID</param>
    /// <param name="userId">用户ID</param>
    /// <param name="goodsId">商品ID</param>
    /// <returns>是否处理成功</returns>
    Task<bool> ProcessInfiniteOrderAsync(int orderId, int userId, int goodsId);

    /// <summary>
    /// 处理充值订单支付成功
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>是否处理成功</returns>
    Task<bool> ProcessRechargeOrderAsync(string orderNo);

    /// <summary>
    /// 处理发货运费支付成功
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>是否处理成功</returns>
    Task<bool> ProcessShippingFeeOrderAsync(string orderNo);

    /// <summary>
    /// 处理抽卡机订单支付成功
    /// </summary>
    /// <param name="orderId">订单ID</param>
    /// <param name="userId">用户ID</param>
    /// <param name="goodsId">商品ID</param>
    /// <returns>是否处理成功</returns>
    Task<bool> ProcessCardExtractorOrderAsync(int orderId, int userId, int goodsId);

    /// <summary>
    /// 检查订单是否已处理（幂等性检查）
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>是否已处理</returns>
    Task<bool> IsOrderProcessedAsync(string orderNo);

    /// <summary>
    /// 记录支付回调通知
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <param name="notifyData">回调数据</param>
    /// <returns>是否记录成功</returns>
    Task<bool> RecordNotifyAsync(string orderNo, WechatNotifyData notifyData);
}
