package com.red.circle.other.app.command.team.query;


import com.red.circle.common.business.dto.cmd.app.AppIdStringCmd;
import com.red.circle.other.app.convertor.team.TeamAppConvertor;
import com.red.circle.other.app.dto.clientobject.team.TeamMemberTargetSettlementResultCO;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget;
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberTargetService;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 用户结算详情.
 *
 * @author pengliang on 2023/2/23
 */
@Component
@RequiredArgsConstructor
public class UserBankSettlementWagesQryExe {

  private final TeamAppConvertor teamAppConvertor;
  private final TeamMemberTargetService teamMemberTargetService;

  public TeamMemberTargetSettlementResultCO execute(AppIdStringCmd cmd) {

    TeamMemberTarget teamMemberTarget = teamMemberTargetService.getById(cmd.getId());

    if (Objects.isNull(teamMemberTarget)) {
      return null;
    }

    return teamAppConvertor.toTeamMemberTargetSettlementResultCO(
        teamMemberTarget.getSettlementResult());
  }

}
