using HoneyBox.Model.Models.Payment;

namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 微信支付服务接口
/// </summary>
public interface IWechatPayService
{
    /// <summary>
    /// 创建微信支付统一下单
    /// </summary>
    /// <param name="request">支付请求</param>
    /// <returns>支付结果</returns>
    Task<WechatPayResult> CreatePaymentAsync(WechatPayRequest request);

    /// <summary>
    /// 验证支付签名
    /// </summary>
    /// <param name="parameters">参数字典</param>
    /// <param name="sign">签名</param>
    /// <param name="merchantKey">商户密钥（可选，不传则使用默认商户）</param>
    /// <returns>是否验证通过</returns>
    bool VerifySign(Dictionary<string, string> parameters, string sign, string? merchantKey = null);

    /// <summary>
    /// 生成支付签名
    /// </summary>
    /// <param name="parameters">参数字典</param>
    /// <param name="merchantKey">商户密钥（可选，不传则使用默认商户）</param>
    /// <returns>签名字符串</returns>
    string MakeSign(Dictionary<string, string> parameters, string? merchantKey = null);

    /// <summary>
    /// 验证微信回调签名
    /// </summary>
    /// <param name="notifyData">回调数据</param>
    /// <returns>是否验证通过</returns>
    bool VerifyNotifySign(WechatNotifyData notifyData);

    /// <summary>
    /// 根据订单号获取商户密钥
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>商户密钥</returns>
    string GetMerchantKeyByOrderNo(string orderNo);

    /// <summary>
    /// 发送订单发货通知到微信
    /// </summary>
    /// <param name="request">发货通知请求</param>
    /// <returns>发货通知结果</returns>
    Task<OrderShippingNotifyResult> PostOrderShippingAsync(OrderShippingNotifyRequest request);

    /// <summary>
    /// 根据订单号获取商户配置
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>商户配置</returns>
    WechatPayMerchantConfig GetMerchantByOrderNo(string orderNo);

    /// <summary>
    /// 解析微信回调XML数据
    /// </summary>
    /// <param name="xmlData">XML数据</param>
    /// <returns>回调数据对象</returns>
    WechatNotifyData ParseNotifyXml(string xmlData);

    /// <summary>
    /// 生成回调响应XML
    /// </summary>
    /// <param name="returnCode">返回码</param>
    /// <param name="returnMsg">返回消息</param>
    /// <returns>XML字符串</returns>
    string GenerateNotifyResponseXml(string returnCode, string returnMsg);
}
