package com.jeesharp.business.modules.pay.paywechatconfig.mapper;

import com.jeesharp.business.modules.pay.paywechatconfig.entity.PayWechatConfig;
import com.jeesharp.business.modules.pay.paywechatconfig.vo.PayWechatConfigQueryVO;
import com.jeesharp.framework.mybatis.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 微信支付配置表 MyBatis Mapper。
 *
 * @author jeesharp
 * @since 2026-05-25
 */
@Mapper
public interface PayWechatConfigMapper extends BaseMapper<PayWechatConfig, PayWechatConfigQueryVO> {

    PayWechatConfig findActive();

    PayWechatConfig findActiveByTenantId(@Param("tenantId") String tenantId);

    PayWechatConfig findActivePlatform();

    PayWechatConfig findByConfigCode(@Param("configCode") String configCode);

    PayWechatConfig findByConfigCodeAndTenant(@Param("configCode") String configCode,
            @Param("tenantId") String tenantId);

    /**
     * 按渠道公共配置主键查询微信子配置。
     */
    PayWechatConfig findByChannelConfigId(@Param("channelConfigId") String channelConfigId);

    /**
     * 将除 keepId 外所有启用中的配置置为禁用。
     */
    int disableOtherActiveExcept(@Param("tenantId") String tenantId, @Param("keepId") String keepId,
            @Param("enabledStatus") Integer enabledStatus, @Param("disabledStatus") Integer disabledStatus);
}
