package com.ga.core.mapper.commission;

import com.ga.core.vo.commission.ReferralCommissionLedgerResp;
import com.ga.core.vo.commission.ReferralCommissionLedgerSearchParam;
import com.ga.core.vo.commission.ReferralCommissionLedgerVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * referral_commission_ledger Mapper — 소개·이관수수료 원장 (V89)
 */
@Mapper
public interface ReferralCommissionLedgerMapper {

    ReferralCommissionLedgerResp selectById(@Param("ledgerId") Long ledgerId);

    List<ReferralCommissionLedgerResp> selectList(ReferralCommissionLedgerSearchParam param);

    /** 설계사 + 정산월 소개·이관수수료 합계 — commission_master 집계 배치 용도 */
    BigDecimal sumByAgentAndMonth(@Param("referrerAgentId") Long referrerAgentId,
                                 @Param("settleMonth") String settleMonth);

    /** 정산월 기준 설계사별 합계 — settle_master 집계 배치 용도 */
    List<Map<String, Object>> aggregateByAgent(@Param("settleMonth") String settleMonth);

    int insert(ReferralCommissionLedgerVO vo);

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

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