package com.red.circle.other.app.service.material;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.ResponseErrorCode;
import com.red.circle.other.app.command.material.PropsGiveAwayCmdExe;
import com.red.circle.other.app.command.material.PropsPurchasingCmdExe;
import com.red.circle.other.app.command.material.PropsPurchasingRoomLockCmdExe;
import com.red.circle.other.app.command.material.PropsPurchasingStealthBrowseCmdExe;
import com.red.circle.other.app.command.material.UserSwitchUsePropsCmdExe;
import com.red.circle.other.app.command.material.query.NobleVipStoreListQryExe;
import com.red.circle.other.app.command.material.query.PropsRoomLockExpiredTimeQryExe;
import com.red.circle.other.app.command.material.query.PropsStealthBrowseExpiredTimeQryExe;
import com.red.circle.other.app.command.material.query.PropsStoreCommodityQryExe;
import com.red.circle.other.app.command.material.query.PropsUserBackpackQryExe;
import com.red.circle.other.app.dto.clientobject.material.PropsNobleVipStoreCO;
import com.red.circle.other.app.dto.clientobject.material.PropsStoreCommodityInfoCO;
import com.red.circle.other.app.dto.cmd.material.PropsGiveAwayCmd;
import com.red.circle.other.app.dto.cmd.material.PropsNobleVipQryCmd;
import com.red.circle.other.app.dto.cmd.material.PropsPurchasingCmd;
import com.red.circle.other.app.dto.cmd.material.PropsStoreBackpackTypeQryCmd;
import com.red.circle.other.app.dto.cmd.material.PropsStoreTypeQryCmd;
import com.red.circle.other.app.dto.cmd.material.SwitchUsePropsCmd;
import com.red.circle.other.inner.model.dto.material.props.UserBackpackProps;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 道具商店 实现.
 *
 * @author pengliang on 2023/9/19
 */
@Service
@RequiredArgsConstructor
public class PropsStoreServiceImpl implements PropsStoreService {

  private final PropsGiveAwayCmdExe propsGiveAwayCmdExe;
  private final PropsPurchasingCmdExe propsPurchasingCmdExe;
  private final PropsUserBackpackQryExe propsUserBackpackQryExe;
  private final NobleVipStoreListQryExe nobleVipStoreListQryExe;
  private final UserSwitchUsePropsCmdExe userSwitchUsePropsCmdExe;
  private final PropsStoreCommodityQryExe propsStoreCommodityQryExe;
  private final PropsPurchasingRoomLockCmdExe propsPurchasingRoomLockCmdExe;
  private final PropsRoomLockExpiredTimeQryExe propsRoomLockExpiredTimeQryExe;
  private final PropsPurchasingStealthBrowseCmdExe propsPurchasingStealthBrowseCmdExe;
  private final PropsStealthBrowseExpiredTimeQryExe propsStealthBrowseExpiredTimeQryExe;

  @Override
  public List<PropsStoreCommodityInfoCO> listStore(PropsStoreTypeQryCmd cmd) {
    return propsStoreCommodityQryExe.execute(cmd);
  }

  @Override
  public List<PropsNobleVipStoreCO> listNobleVip(PropsNobleVipQryCmd cmd) {
    return nobleVipStoreListQryExe.execute(cmd);
  }

  @Override
  public BigDecimal purchasing(PropsPurchasingCmd cmd) {
    cmd.setAcceptUserId(cmd.requiredReqUserId());
    return propsPurchasingCmdExe.execute(cmd);
  }

  @Override
  public BigDecimal giveAway(PropsPurchasingCmd cmd) {
    if (Objects.isNull(cmd.getAcceptUserId())) {
      ResponseAssert.failure(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
          "acceptUserId is not null.");
    }
    return propsPurchasingCmdExe.execute(cmd);
  }

  @Override
  public void giveAwayInBackpack(PropsGiveAwayCmd cmd) {
    propsGiveAwayCmdExe.execute(cmd);
  }

  @Override
  public List<UserBackpackProps> listUserBackpack(PropsStoreBackpackTypeQryCmd cmd) {
    return propsUserBackpackQryExe.execute(cmd);
  }

  @Override
  public void switchUse(SwitchUsePropsCmd cmd) {
    userSwitchUsePropsCmdExe.execute(cmd);
  }

  @Override
  public BigDecimal purchasingRoomLock(AppExtCommand cmd) {
    return propsPurchasingRoomLockCmdExe.execute(cmd);
  }

  @Override
  public Timestamp getRoomLockExpiredTime(AppExtCommand cmd) {
    return propsRoomLockExpiredTimeQryExe.execute(cmd);
  }

  @Override
  public BigDecimal purchasingStealthBrowse(AppExtCommand cmd) {
    return propsPurchasingStealthBrowseCmdExe.execute(cmd);
  }

  @Override
  public Timestamp getStealthBrowseExpiredTime(AppExtCommand cmd) {
    return propsStealthBrowseExpiredTimeQryExe.execute(cmd);
  }

}
