package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.LapsedReinstatementRecoveryResp;
import com.ga.core.vo.commission.LapsedReinstatementRecoverySearchParam;
import com.ga.core.vo.commission.LapsedReinstatementRecoveryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * lapsed_reinstatement_recovery Mapper — 익월 부활 재지급 원장 (V119)
 */
@Mapper
public interface LapsedReinstatementRecoveryMapper {

    LapsedReinstatementRecoveryResp selectById(@Param("recoveryId") Long recoveryId);

    List<LapsedReinstatementRecoveryResp> selectList(LapsedReinstatementRecoverySearchParam param);

    int insert(LapsedReinstatementRecoveryVO vo);

    int updateStatus(@Param("recoveryId") Long recoveryId,
                     @Param("status") String status,
                     @Param("repaidAmount") java.math.BigDecimal repaidAmount);

    /**
     * 정산월 기준 설계사별 재지급 합계 — AggregateStep other_commission_total 가산용.
     * status='REPAID' 대상 SUM(repaid_amount) GROUP BY agent_id.
     */
    List<Map<String, Object>> aggregateByAgent(@Param("settleMonth") String settleMonth);
}
