package com.ga.core.mapper.chargeback;

import com.ga.core.vo.chargeback.ChargebackGradeResp;
import com.ga.core.vo.chargeback.ChargebackGradeSearchParam;
import com.ga.core.vo.chargeback.ChargebackGradeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ChargebackGradeMapper {

    List<ChargebackGradeResp> selectList(ChargebackGradeSearchParam param);

    ChargebackGradeResp selectDetailById(@Param("gradeId") Long gradeId);

    ChargebackGradeVO selectById(@Param("gradeId") Long gradeId);

    /** 해약 경과월에 적용되는 환수 비율 구간 1건 조회 (차등 환수 계산 핵심) */
    ChargebackGradeVO selectByMonths(@Param("productCategory") String productCategory,
                                     @Param("monthsElapsed") Integer monthsElapsed,
                                     @Param("baseDate") String baseDate);

    /** 특정 시점 활성 전체 구간 조회 (months_from ASC) */
    List<ChargebackGradeVO> selectAll(@Param("baseDate") String baseDate);

    /** 카테고리별 활성 구간 조회 */
    List<ChargebackGradeVO> selectByCategory(@Param("productCategory") String productCategory,
                                              @Param("baseDate") String baseDate);

    int insert(ChargebackGradeVO vo);

    int update(ChargebackGradeVO vo);

    int updateStatus(@Param("gradeId") Long gradeId, @Param("isActive") Boolean isActive);
}
