package com.ga.core.mapper.settle;

import com.ga.core.vo.settle.SettleMasterResp;
import com.ga.core.vo.settle.SettleMasterVO;
import com.ga.core.vo.settle.SettleSearchParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface SettleMasterMapper {
    List<SettleMasterResp> selectList(SettleSearchParam param);
    SettleMasterResp selectDetail(@Param("agentId") Long agentId,
                                  @Param("settleMonth") String settleMonth);
    SettleMasterVO selectByAgentAndMonth(@Param("agentId") Long agentId,
                                         @Param("settleMonth") String settleMonth);
    SettleMasterVO selectById(@Param("settleId") Long settleId);

    /** 정산 마스터 UPSERT (agent_id + settle_month UNIQUE) */
    int upsert(SettleMasterVO vo);

    int updateStatus(@Param("settleId") Long settleId,
                     @Param("status") String status,
                     @Param("userId") Long userId);
    int updateHold(@Param("settleId") Long settleId,
                   @Param("reason") String reason,
                   @Param("reasonCode") String reasonCode);

    /** 월 요약 (전체) */
    Map<String, Object> selectMonthSummary(@Param("settleMonth") String settleMonth);

    /** 조직별 월 합계 */
    List<Map<String, Object>> selectOrgSummary(@Param("settleMonth") String settleMonth);
}
