package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.ClawbackInstallmentPlanResp;
import com.ga.core.vo.commission.ClawbackInstallmentPlanSearchParam;
import com.ga.core.vo.commission.ClawbackInstallmentPlanVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * clawback_installment_plan Mapper — 환수 분할상환 계획 (V118)
 */
@Mapper
public interface ClawbackInstallmentPlanMapper {

    ClawbackInstallmentPlanResp selectById(@Param("planId") Long planId);

    List<ClawbackInstallmentPlanResp> selectList(ClawbackInstallmentPlanSearchParam param);

    /**
     * 채권 ID 기준 분할상환 계획 목록 — 회차순 정렬.
     */
    List<ClawbackInstallmentPlanVO> selectByReceivable(@Param("receivableId") Long receivableId);

    /**
     * 분할상환 계획 일괄 등록.
     */
    int insertBatch(List<ClawbackInstallmentPlanVO> plans);

    /**
     * 분할상환 회차 상태 갱신 (SCHEDULED→RECOVERED 또는 CANCELLED).
     */
    int updateStatus(@Param("planId") Long planId,
                     @Param("status") String status);
}
