package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.OverrideSummaryResp;
import com.ga.core.vo.commission.OverrideSummarySearchParam;
import com.ga.core.vo.commission.OverrideSummaryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * override_summary Mapper — agent+settle_month 단위 오버라이드 합계 (V44).
 * UPSERT(agent_id, settle_month) 메서드 핵심.
 */
@Mapper
public interface OverrideSummaryMapper {
    OverrideSummaryResp selectById(@Param("summaryId") Long summaryId);
    OverrideSummaryResp selectByAgentAndMonth(@Param("toAgentId") Long toAgentId,
                                              @Param("settleMonth") String settleMonth);
    List<OverrideSummaryResp> selectList(OverrideSummarySearchParam param);

    /**
     * UPSERT — UNIQUE(to_agent_id, settle_month).
     * 배치 완료 후 집계 결과 반영 시 호출.
     */
    int upsert(OverrideSummaryVO vo);

    int updateStatus(@Param("summaryId") Long summaryId, @Param("status") String status);
}
