package com.red.circle.order.infra.database.rds.service.count.impl;

import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.order.infra.database.rds.dao.count.RoomRefundAnchorTrackRecordDAO;
import com.red.circle.order.infra.database.rds.entity.count.RoomRefundAnchorTrackRecord;
import com.red.circle.order.infra.database.rds.service.count.RoomRefundAnchorTrackRecordService;
import java.util.Objects;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户退款影响至主播业绩减少情况记录表 服务实现类.
 * </p>
 *
 * @author pengshigang
 * @since 2021-10-28
 */
@Service
public class RoomRefundAnchorTrackRecordServiceImpl extends
    BaseServiceImpl<RoomRefundAnchorTrackRecordDAO, RoomRefundAnchorTrackRecord> implements
    RoomRefundAnchorTrackRecordService {

  @Override
  public boolean exists(Integer dateNumber, Long anchorUserId, Long refundUserId) {
    return Objects.nonNull(query()
        .select(RoomRefundAnchorTrackRecord::getId)
        .eq(RoomRefundAnchorTrackRecord::getYears, dateNumber)
        .eq(RoomRefundAnchorTrackRecord::getAnchorUserId, anchorUserId)
        .eq(RoomRefundAnchorTrackRecord::getRefunderUserId, refundUserId)
        .getOne());
  }
}
