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

import com.red.circle.framework.dto.ResultResponse;
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.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 内购详情.
 *
 * @author pengliang on 2023/11/3
 */
public interface InAppPurchaseDetailsClientApi {

  String API_PREFIX = "/in-app-purchase-details/client";


  /**
   * 获取订单信息.
   */
  @GetMapping("/getById")
  ResultResponse<InAppPurchaseDetailsDTO> getById(@RequestParam("id") String id);

  /**
   * 订单信息查询.
   */
  @PostMapping("/list")
  ResultResponse<List<InAppPurchaseDetailsDTO>> list(
      @RequestBody @Validated InAppPurchaseDetailsQryCmd qryCmd);

  /**
   * 统计用户内购.
   */
  @GetMapping("/countUserInAppPurchase")
  ResultResponse<List<CountUserInAppPurchaseDTO>> countUserInAppPurchase(@RequestParam("sysOrigin")String sysOrigin,
      @RequestParam("startTime")LocalDateTime startTime,
      @RequestParam("endTime")LocalDateTime endTime,
      @RequestParam("limit")Integer limit);

  /**
   * 订单统计查询 - 返回金额总数和订单总数
   */
  @PostMapping("/statistics")
  ResultResponse<Map<String, Object>> statistics(
      @RequestBody @Validated InAppPurchaseDetailsQryCmd qryCmd);

  /**
   * 批量查询用户充值统计.
   * 统计指定用户列表在指定时间范围内的支付成功订单金额总和.
   *
   * @param userIds 用户ID列表
   * @param sysOrigin 系统来源
   * @param startTime 开始时间（可选）
   * @param endTime 结束时间（可选）
   * @return 用户充值统计列表（包含用户ID、总金额、订单数量）
   */
  @PostMapping("/batchUserRechargeStatistics")
  ResultResponse<List<BatchUserRechargeStatisticsDTO>> batchUserRechargeStatistics(
      @RequestBody List<Long> userIds,
      @RequestParam("sysOrigin") String sysOrigin,
      @RequestParam(value = "startTime", required = false) LocalDateTime startTime,
      @RequestParam(value = "endTime", required = false) LocalDateTime endTime);
}
