package com.red.circle.other.app.inner.service.team.impl;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.team.TeamApplicationProcessClientService;
import com.red.circle.other.app.inner.service.team.TeamTerminationFeeRecordClientService;
import com.red.circle.other.infra.convertor.team.TeamTerminationFeeRecordConvertor;
import com.red.circle.other.infra.database.rds.entity.team.TeamTerminationFeeRecord;
import com.red.circle.other.infra.database.rds.service.team.TeamTerminationFeeRecordService;
import com.red.circle.other.inner.model.dto.team.TeamTerminationFeeRecordDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * @author longli on  2024/3/14
 */
@Service
@RequiredArgsConstructor
public class TeamTerminationFeeRecordClientServiceImpl  implements TeamTerminationFeeRecordClientService {

    private final TeamTerminationFeeRecordService teamTerminationFeeRecordService;
    private final TeamTerminationFeeRecordConvertor teamTerminationFeeRecordConvertor;
    @Override
    public List<TeamTerminationFeeRecordDTO> listByTimeGt24AndPayeeUserNull() {
        List<TeamTerminationFeeRecord> recordList = teamTerminationFeeRecordService.listByTimeGt24AndPayeeUserNull();
        List<TeamTerminationFeeRecordDTO> terminationFeeRecordDTOList = teamTerminationFeeRecordConvertor.toListTeamPolicyManagerDTOList(recordList);
        return terminationFeeRecordDTOList;
    }

    @Override
    public TeamTerminationFeeRecordDTO getById(Serializable id) {
        TeamTerminationFeeRecord terminationFeeRecord = teamTerminationFeeRecordService.getById(id);
        TeamTerminationFeeRecordDTO terminationFeeRecordDTO = teamTerminationFeeRecordConvertor.toTeamTerminationFeeRecord(terminationFeeRecord);
        return terminationFeeRecordDTO;
    }

    @Override
    public TeamTerminationFeeRecordDTO updateSelectiveById(TeamTerminationFeeRecordDTO teamTerminationFeeRecordDTO) {
        TeamTerminationFeeRecord teamTerminationFeeRecord =  new TeamTerminationFeeRecord();
        teamTerminationFeeRecord.setPayeeAmount(teamTerminationFeeRecordDTO.getPayeeAmount());
        teamTerminationFeeRecord.setPayeeUserId(teamTerminationFeeRecordDTO.getPayeeUserId());
        teamTerminationFeeRecord.setPayeeRunningWaterId(teamTerminationFeeRecordDTO.getPayeeRunningWaterId());
        teamTerminationFeeRecord.setUpdateTime(teamTerminationFeeRecordDTO.getUpdateTime());
        teamTerminationFeeRecord.setSysOrigin(teamTerminationFeeRecordDTO.getSysOrigin());
        teamTerminationFeeRecordService.updateSelectiveById(teamTerminationFeeRecord);
        return teamTerminationFeeRecordDTO;
    }
}
