package com.ga.core.mapper.receive;

import com.ga.core.vo.receive.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ReceiveMapper {

    // company_profile
    List<CompanyProfileVO> selectAllProfiles();
    CompanyProfileVO selectProfile(@Param("companyCode") String companyCode);
    int insertProfile(CompanyProfileVO vo);
    int updateProfile(CompanyProfileVO vo);

    // field_mapping
    List<CompanyFieldMappingVO> selectFieldMappings(@Param("companyCode") String companyCode,
                                                    @Param("targetTable") String targetTable);
    int insertFieldMapping(CompanyFieldMappingVO vo);
    int updateFieldMapping(CompanyFieldMappingVO vo);
    int deleteFieldMapping(@Param("mappingId") Long mappingId);

    // code_mapping
    List<CodeMappingVO> selectCodeMappings(@Param("companyCode") String companyCode,
                                           @Param("codeType") String codeType);
    String findTargetCode(@Param("companyCode") String companyCode,
                          @Param("codeType") String codeType,
                          @Param("sourceCode") String sourceCode);
    int insertCodeMapping(CodeMappingVO vo);
    int updateCodeMapping(CodeMappingVO vo);
    int deleteCodeMapping(@Param("codeId") Long codeId);

    // raw_commission_data
    int insertRaw(RawCommissionDataVO vo);
    int insertRawBatch(@Param("list") List<RawCommissionDataVO> list);
    List<RawCommissionDataVO> selectRawList(@Param("companyCode") String companyCode,
                                            @Param("settleMonth") String settleMonth,
                                            @Param("parseStatus") String parseStatus);
    int updateRawStatus(@Param("rawId") Long rawId,
                        @Param("parseStatus") String parseStatus,
                        @Param("mappedLedgerId") Long mappedLedgerId,
                        @Param("mappedTable") String mappedTable);

    // parse_error_log
    List<ParseErrorLogVO> selectErrors(@Param("companyCode") String companyCode,
                                       @Param("resolveStatus") String resolveStatus);
    int insertError(ParseErrorLogVO vo);
    int resolveError(@Param("errorId") Long errorId,
                     @Param("status") String status,
                     @Param("note") String note,
                     @Param("userId") Long userId);
}
