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

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.order.inner.endpoint.api.UserMonthlyRechargeClientApi;
import com.red.circle.order.inner.model.cmd.MonthlyRechargeDatesQryCmd;
import com.red.circle.order.inner.model.cmd.MonthlyRechargeQryCmd;
import com.red.circle.order.inner.model.dto.MonthlyRechargeSummaryVO;
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
import com.red.circle.order.inner.service.UserMonthlyRechargeClientService;
import java.util.List;
import java.util.Map;
import java.util.Set;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 累计用户每月充值.
 *
 * @author pengliang on 2024/1/23
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = UserMonthlyRechargeClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
public class UserMonthlyRechargeClientEndpoint implements UserMonthlyRechargeClientApi {

  private final UserMonthlyRechargeClientService userMonthlyRechargeClientService;

  @Override
  public ResultResponse<Map<Long, List<UserMonthlyRechargeDTO>>> mapGroupByUserId(
      MonthlyRechargeQryCmd qryCmd) {
    return ResultResponse.success(
        userMonthlyRechargeClientService.mapGroupByUserId(qryCmd)
    );
  }

  @Override
  public ResultResponse<Map<Integer, List<UserMonthlyRechargeDTO>>> mapGroupByRechargeDates(
      MonthlyRechargeDatesQryCmd qryCmd) {
    return ResultResponse.success(
        userMonthlyRechargeClientService.mapGroupByRechargeDates(qryCmd)
    );
  }

  @Override
  public ResultResponse<List<UserMonthlyRechargeDTO>> listThisMonth(Long userId) {
    return ResultResponse.success(
        userMonthlyRechargeClientService.listThisMonth(userId)
    );
  }

    @Override
    public ResultResponse<List<UserMonthlyRechargeDTO>> listThisMonthByIds(List<Long> userIds) {
        return ResultResponse.success(
                userMonthlyRechargeClientService.listThisMonthByIds(userIds)
        );
    }

    @Override
    public ResultResponse<List<UserMonthlyRechargeDTO>> listLastMonthByIds(List<Long> userIds) {
        return ResultResponse.success(
                userMonthlyRechargeClientService.listLastMonthByIds(userIds)
        );
    }

    @Override
    public ResultResponse<List<MonthlyRechargeSummaryVO>> getMonthlyRechargeSummary(Set<Long> userIds) {
        return ResultResponse.success(userMonthlyRechargeClientService.getMonthlyRechargeSummary(userIds));
    }

}
