using HoneyBox.Model.Models.Payment;

namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 统一支付服务接口
/// </summary>
public interface IPaymentService
{
    #region 资产扣减

    /// <summary>
    /// 扣减用户余额
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">扣减金额</param>
    /// <param name="content">扣减说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认3=抽赏消费）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>扣减结果</returns>
    Task<AssetDeductionResult> DeductBalanceAsync(int userId, decimal amount, string content, string? orderNum = null, byte type = 3, int shareUid = 0);

    /// <summary>
    /// 扣减用户积分（吧唧币）
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">扣减金额</param>
    /// <param name="content">扣减说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认2=抽赏消费）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>扣减结果</returns>
    Task<AssetDeductionResult> DeductIntegralAsync(int userId, decimal amount, string content, string? orderNum = null, byte type = 2, int shareUid = 0);

    /// <summary>
    /// 扣减用户哈尼券
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">扣减金额</param>
    /// <param name="content">扣减说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认3=抽赏消费）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>扣减结果</returns>
    Task<AssetDeductionResult> DeductMoney2Async(int userId, decimal amount, string content, string? orderNum = null, byte type = 3, int shareUid = 0);

    #endregion

    #region 资产增加

    /// <summary>
    /// 增加用户余额
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">增加金额</param>
    /// <param name="content">增加说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认2=在线充值）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>是否成功</returns>
    Task<bool> AddBalanceAsync(int userId, decimal amount, string content, string? orderNum = null, byte type = 2, int shareUid = 0);

    /// <summary>
    /// 增加用户积分（吧唧币）
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">增加金额</param>
    /// <param name="content">增加说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认4=抽赏奖励）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>是否成功</returns>
    Task<bool> AddIntegralAsync(int userId, decimal amount, string content, string? orderNum = null, byte type = 4, int shareUid = 0);

    /// <summary>
    /// 增加用户哈尼券
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">增加金额</param>
    /// <param name="content">增加说明</param>
    /// <param name="orderNum">关联订单号</param>
    /// <param name="type">变动类型（默认5=推荐奖励）</param>
    /// <param name="shareUid">关联分享用户ID</param>
    /// <returns>是否成功</returns>
    Task<bool> AddMoney2Async(int userId, decimal amount, string content, string? orderNum = null, byte type = 5, int shareUid = 0);

    #endregion

    #region 支付记录

    /// <summary>
    /// 记录支付流水
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="orderNum">订单号</param>
    /// <param name="amount">支付金额</param>
    /// <param name="payType">支付类型</param>
    /// <param name="content">支付说明</param>
    /// <returns>是否记录成功</returns>
    Task<bool> RecordPaymentAsync(int userId, string orderNum, decimal amount, PaymentType payType, string content);

    /// <summary>
    /// 获取用户支付记录
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="page">页码</param>
    /// <param name="pageSize">每页数量</param>
    /// <returns>支付记录列表</returns>
    Task<List<PaymentRecordDto>> GetPaymentRecordsAsync(int userId, int page = 1, int pageSize = 10);

    /// <summary>
    /// 检查订单是否已有支付记录（用于幂等性检查）
    /// </summary>
    /// <param name="orderNum">订单号</param>
    /// <returns>是否存在支付记录</returns>
    Task<bool> HasPaymentRecordAsync(string orderNum);

    /// <summary>
    /// 根据订单号获取支付记录
    /// </summary>
    /// <param name="orderNum">订单号</param>
    /// <returns>支付记录，如果不存在则返回null</returns>
    Task<PaymentRecordDto?> GetPaymentRecordByOrderNumAsync(string orderNum);

    #endregion

    #region 余额验证

    /// <summary>
    /// 验证用户余额是否充足
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">需要的金额</param>
    /// <returns>是否充足</returns>
    Task<bool> ValidateBalanceAsync(int userId, decimal amount);

    /// <summary>
    /// 验证用户积分是否充足
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">需要的金额</param>
    /// <returns>是否充足</returns>
    Task<bool> ValidateIntegralAsync(int userId, decimal amount);

    /// <summary>
    /// 验证用户哈尼券是否充足
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="amount">需要的金额</param>
    /// <returns>是否充足</returns>
    Task<bool> ValidateMoney2Async(int userId, decimal amount);

    #endregion
}
