package com.red.circle.order.inner.convertor;

import com.red.circle.framework.core.convertor.ConvertorModel;
import com.red.circle.order.infra.database.mongo.order.entity.InAppPurchaseDetails;
import com.red.circle.order.infra.database.mongo.order.entity.assist.CountUserInAppPurchase;
import com.red.circle.order.infra.database.mongo.order.query.InAppPurchaseDetailsQuery;
import com.red.circle.order.inner.model.cmd.inapp.InAppPurchaseDetailsQryCmd;
import com.red.circle.order.inner.model.dto.inapp.BatchUserRechargeStatisticsDTO;
import com.red.circle.order.inner.model.dto.inapp.CountUserInAppPurchaseDTO;
import com.red.circle.order.inner.model.dto.inapp.InAppPurchaseDetailsDTO;
import java.util.List;
import org.mapstruct.Mapper;

/**
 * @author pengliang on 2023/12/15
 */
@Mapper(componentModel = ConvertorModel.SPRING)
public interface InAppPurchaseDetailsInnerConvert {

  InAppPurchaseDetailsQuery toInAppPurchaseDetailsQuery(InAppPurchaseDetailsQryCmd qryCmd);

  InAppPurchaseDetailsDTO toInAppPurchaseDetailsDTO(InAppPurchaseDetails details);

  List<InAppPurchaseDetailsDTO> toListInAppPurchaseDetailsDTO(List<InAppPurchaseDetails> details);

  List<CountUserInAppPurchaseDTO> toListCountUserInAppPurchase(List<CountUserInAppPurchase> list);

  /**
   * 转换为批量用户充值统计DTO列表.
   *
   * @param list CountUserInAppPurchase列表
   * @return BatchUserRechargeStatisticsDTO列表
   */
  List<BatchUserRechargeStatisticsDTO> toBatchUserRechargeStatisticsDTOList(List<CountUserInAppPurchase> list);

  /**
   * 转换为批量用户充值统计DTO.
   *
   * @param source CountUserInAppPurchase
   * @return BatchUserRechargeStatisticsDTO
   */
  default BatchUserRechargeStatisticsDTO toBatchUserRechargeStatisticsDTO(CountUserInAppPurchase source) {
    if (source == null) {
      return null;
    }
    BatchUserRechargeStatisticsDTO dto = new BatchUserRechargeStatisticsDTO();
    dto.setUserId(source.getUserId());
    dto.setTotalAmount(source.getAmount());
    dto.setOrderCount(source.getOrderCount());
    return dto;
  }
}
