using HoneyBox.Model.Models.Payment;

namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 微信支付配置服务接口
/// </summary>
public interface IWechatPayConfigService
{
    /// <summary>
    /// 获取默认微信支付配置
    /// </summary>
    /// <returns>商户配置</returns>
    WechatPayMerchantConfig GetDefaultConfig();

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

    /// <summary>
    /// 根据商户前缀获取商户配置
    /// </summary>
    /// <param name="merchantPrefix">商户前缀（3位字符）</param>
    /// <returns>商户配置</returns>
    WechatPayMerchantConfig? GetMerchantByPrefix(string merchantPrefix);

    /// <summary>
    /// 根据小程序前缀获取小程序配置
    /// </summary>
    /// <param name="miniprogramPrefix">小程序前缀（2位字符）</param>
    /// <returns>小程序配置</returns>
    MiniprogramConfig? GetMiniprogramByPrefix(string miniprogramPrefix);

    /// <summary>
    /// 根据域名获取小程序配置
    /// </summary>
    /// <param name="domain">域名</param>
    /// <returns>小程序配置</returns>
    MiniprogramConfig? GetMiniprogramByDomain(string domain);

    /// <summary>
    /// 获取默认小程序配置
    /// </summary>
    /// <returns>小程序配置</returns>
    MiniprogramConfig? GetDefaultMiniprogram();

    /// <summary>
    /// 从订单号中提取前缀信息
    /// </summary>
    /// <param name="orderNo">订单号</param>
    /// <returns>前缀信息</returns>
    OrderPrefixInfo? ExtractOrderPrefix(string orderNo);

    /// <summary>
    /// 根据权重随机获取一个商户
    /// </summary>
    /// <param name="merchants">商户列表</param>
    /// <returns>随机选择的商户</returns>
    WechatPayMerchantConfig? GetRandomMerchant(IEnumerable<WechatPayMerchantConfig> merchants);

    /// <summary>
    /// 获取微信支付配置（支持随机商户选择）
    /// </summary>
    /// <returns>包含商户和AppId的配置</returns>
    (WechatPayMerchantConfig Merchant, string AppId) GetWxPayConfig();

    /// <summary>
    /// 获取固定的微信支付配置（基于订单前缀）
    /// </summary>
    /// <param name="orderPrefix">订单前缀</param>
    /// <returns>包含商户和AppId的配置</returns>
    (WechatPayMerchantConfig? Merchant, string AppId) GetFixedWxPayConfig(string orderPrefix);
}
