package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.StepCloseResp;
import com.ga.core.vo.commission.StepCloseSearchParam;
import com.ga.core.vo.commission.StepCloseVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * settlement_step_close Mapper.
 * 단계마감: 월별 정산 단계(수신→계산→검증→지급)의 OPEN/CLOSED 상태 관리.
 */
@Mapper
public interface StepCloseMapper {

    StepCloseResp selectById(@Param("stepCloseId") Long stepCloseId);

    List<StepCloseResp> selectList(StepCloseSearchParam param);

    /** 정산월 전체 단계 목록 (step_seq 순) */
    List<StepCloseResp> selectBySettleMonth(@Param("settleMonth") String settleMonth);

    int insert(StepCloseVO vo);

    /**
     * 단계 상태 변경 (close: CLOSED, reopen: OPEN).
     * closedAt/closedBy 는 SQL에서 NOW()/userId 처리.
     */
    int updateStatus(@Param("stepCloseId") Long stepCloseId,
                     @Param("status") String status,
                     @Param("closedBy") Long closedBy);

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