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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.infra.common.user.RedPacketInviteUserCommon;
import com.red.circle.other.infra.database.cache.entity.user.InviteUserRedPacketConfigCache;
import java.util.Objects;
import java.util.Optional;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 红包邀请活动状态(true 已关闭, false 运行中).
 * </p>
 *
 * @author pengshigang
 * @since 2023-12-20
 */
@Service
@AllArgsConstructor
public class InviteNewActivityStatusQryExe {

  private final RedPacketInviteUserCommon redPacketInviteUserCommon;

  public Boolean execute(AppExtCommand cmd) {

    InviteUserRedPacketConfigCache configCache = redPacketInviteUserCommon.getInviteConfig(
        cmd.getReqSysOrigin().getOrigin());
    if (Objects.isNull(configCache)) {
      return Boolean.TRUE;
    }

    return Optional.ofNullable(configCache.getCheckClose()).orElse(Boolean.TRUE);
  }

}
