package com.red.circle.console.app.service.app.sys.pay;

import com.red.circle.console.app.convertor.sys.PayAppConvertor;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.order.inner.endpoint.PayCountryClient;
import com.red.circle.order.inner.model.cmd.SysPayCountryChannelCmd;
import com.red.circle.order.inner.model.cmd.SysPayCountryChannelDetailsCmd;
import com.red.circle.order.inner.model.dto.SysPayCountryChannelDetailsDTO;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 国家支持渠道详情 服务实现类
 * </p>
 *
 * @author pengliang
 * @since 2021-12-07
 */
@Service
@RequiredArgsConstructor
public class SysPayCountryChannelDetailsServiceImpl implements
    SysPayCountryChannelDetailsService {

  private final PayAppConvertor payAppConvertor;
  private final PayCountryClient payCountryClient;

  @Override
  public Map<Long, List<SysPayCountryChannelDetailsDTO>> mapByCountryChannelId(
      Set<Long> countryChannelIds) {
    return ResponseAssert.requiredSuccess(
        payCountryClient.mapByCountryChannelId(countryChannelIds));
  }

  @Override
  public void delByCountryChannelId(SysPayCountryChannelCmd param) {
    ResponseAssert.requiredSuccess(payCountryClient.delByCountryChannelId(param));
  }

  @Override
  public List<SysPayCountryChannelDetailsDTO> listSupportAmountUsd(Long payCountryId,
      BigDecimal amountUsd) {
    return ResponseAssert.requiredSuccess(
        payCountryClient.listSupportAmountUsd(payCountryId, amountUsd));
  }


  @Override
  public SysPayCountryChannelDetailsDTO saveOrUpdateCountryChannelDetails(
      SysPayCountryChannelDetailsCmd cmd) {
    ResponseAssert.requiredSuccess(payCountryClient.saveOrUpdateCountryChannelDetails(cmd));
    return payAppConvertor.toSysPayCountryChannelDetailsDTO(cmd);
  }
}
