package com.red.circle.other.infra.database.mongo.service.team.team;

import com.red.circle.other.infra.database.mongo.entity.team.team.TeamBillCycle;
import com.red.circle.other.inner.model.cmd.team.TeamBillCmd;
import com.red.circle.other.inner.model.cmd.team.TeamBillCycleBackQryCmd;
import com.red.circle.other.inner.model.dto.agency.agency.TeamRemark;
import com.red.circle.other.inner.enums.team.TeamBillCycleStatus;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

/**
 * 团队账单服务.
 *
 * @author pengliang on 2022/12/13
 */
public interface TeamBillCycleService {

  /**
   * 获取一组账单信息.
   */
  Map<Long, TeamBillCycle> mapByTeamIds(Set<Long> teamIds, Integer billBelong, TeamBillCycleStatus status);

  /**
   * 获取一组账单信息2.
   */
  Map<Long, TeamBillCycle> mapByTeamIds2(Set<Long> teamIds, Integer billBelong, TeamBillCycleStatus status);

  /**
   * 获取一组账单信息.
   */
  Map<Long, TeamBillCycle> mapByTeamIds(Set<Long> teamIds, Integer billBelong);

  /**
   * 获取一组账单信息.
   */
  Map<String, TeamBillCycle> mapByBillIds(Set<Long> teamIds, Set<Integer> billBelongs);

  /**
   * 获取上个月已完成账单信息.
   */
  Map<Long, TeamBillCycle> mapLastMonthByTeamIds(Set<Long> teamIds);

  /**
   * 创建账单.
   */
  void createIfAbsent(TeamBillCmd param);

  /**
   * 获取上个月已完成账单信息.
   */
  List<TeamBillCycle> listLastMonthByTeamIds(Set<Long> teamIds);

  /**
   * 获取一组账单信息.
   */
  List<TeamBillCycle> listByTeamIds(Set<Long> teamIds, TeamBillCycleStatus status);

  /**
   * 团队已出账，账单.
   */
  List<TeamBillCycle> listTeamPayOutBill(Long teamId);

  /**
   * 团队未出账，账单.
   */
  TeamBillCycle getTeamUnpaidBill(Long teamId);

  /**
   * 获得最新账单ID.
   */
  Long getLatestBillIdByTeamId(Long teamId);

  /**
   * 获得最新账单.
   */
  TeamBillCycle getLatestByTeamId(Long teamId);

  /**
   * 获取指定账单信息.
   */
  TeamBillCycle getByBillId(Long billId);

  /**
   * 获取团队指定账单信息.
   */
  TeamBillCycle getTeamBill(Long teamId, Integer billBelong);

  /**
   * 查询账单.
   */
  List<TeamBillCycle> list(TeamBillCycleBackQryCmd query);

  List<TeamBillCycle> listAll();

  /**
   * 获取用户账单 >= billBelong 记录..
   */
  List<TeamBillCycle> listByGeBillBelong(Long teamId, Integer billBelong, Integer size);

  /**
   * 获取最新账单信息.
   */
  List<TeamBillCycle> listLatestBill(Long teamId, Integer size);

  /**
   * 修改账单信息.
   */
  void updateSelective(TeamBillCycle param);

  /**
   * 修改状态.
   */
  void updateStatus(Long billId, TeamBillCycleStatus status, Long updateUser);

  /**
   * 修改状态.
   */
  void updateStatus(Long billId, TeamBillCycleStatus status, TeamRemark remark);

  /**
   * 添加账单内部备注.
   */
  void addInternalRemarks(Long id, TeamRemark remark);

  /**
   * 移除账单内部备注.
   */
  void removeInternalRemarks(Long id, String remarkId);

  /**
   * 移除团队账单.
   */
  void removeBatchByTeamId(List<Long> teamIds);

  /**
   * 修改账单备注.
   */
  void updateRemarks(Long id, String remarks);

  /**
   * 出单.
   */
  void billStatusPayOut();

  /**
   * 出账团队id, 扫描.
   */
  void scanPayOut(Consumer<List<TeamBillCycle>> execute, Integer limit);

  /**
   * 扫描挂起单据.
   */
  void scanHangUp(Consumer<List<TeamBillCycle>> execute, Integer limit);

  /**
   * 查询团队账单
   *
   * @param sysOrigin  系统
   * @param billStatus 账单状态
   * @param region     区域
   * @param billBelong 账单归属
   */
  List<TeamBillCycle> queryTeamBillByCondition(String sysOrigin,
      List<TeamBillCycleStatus> billStatus, String region, Integer billBelong);

  /**
   * 修改为结算账单区域.
   */
  void updateUnpaidTeamBillRegion(Long teamId, String region, Long updateUser);
}
