package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.ReferralCommissionRuleResp;
import com.ga.core.vo.commission.ReferralCommissionRuleSearchParam;
import com.ga.core.vo.commission.ReferralCommissionRuleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * referral_commission_rule Mapper — 소개·이관수수료 룰 (V89)
 */
@Mapper
public interface ReferralCommissionRuleMapper {

    ReferralCommissionRuleResp selectById(@Param("ruleId") Long ruleId);

    List<ReferralCommissionRuleResp> selectList(ReferralCommissionRuleSearchParam param);

    /**
     * 유형 + 기준일 기준 유효 룰 1건 조회.
     * 수수료 계산 Service에서 호출.
     */
    ReferralCommissionRuleVO selectActiveRule(@Param("referralType") String referralType,
                                             @Param("baseDate") LocalDate baseDate);

    int insert(ReferralCommissionRuleVO vo);

    int update(ReferralCommissionRuleVO vo);

    int delete(@Param("ruleId") Long ruleId);
}
