package v1

import (
	dto "quyun/v2/app/http/super/v1/dto"
	"quyun/v2/app/requests"
	"quyun/v2/app/services"

	"github.com/gofiber/fiber/v3"
)

// @provider
type orders struct{}

// List orders
//
// @Router /super/v1/orders [get]
// @Summary List orders
// @Description List orders
// @Tags Order
// @Accept json
// @Produce json
// @Param page query int false "Page number"
// @Param limit query int false "Page size"
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
// @Bind filter query
func (c *orders) List(ctx fiber.Ctx, filter *dto.SuperOrderListFilter) (*requests.Pager, error) {
	return services.Super.ListOrders(ctx, filter)
}

// Get order
//
// @Router /super/v1/orders/:id<int> [get]
// @Summary Get order
// @Description Get order
// @Tags Order
// @Accept json
// @Produce json
// @Param id path int64 true "Order ID"
// @Success 200 {object} dto.SuperOrderDetail
// @Bind id path
func (c *orders) Get(ctx fiber.Ctx, id int64) (*dto.SuperOrderDetail, error) {
	return services.Super.GetOrder(ctx, id)
}

// Refund order
//
// @Router /super/v1/orders/:id<int>/refund [post]
// @Summary Refund order
// @Description Refund order
// @Tags Order
// @Accept json
// @Produce json
// @Param id path int64 true "Order ID"
// @Param form body dto.SuperOrderRefundForm true "Refund form"
// @Success 200 {string} string "Refunded"
// @Bind id path
// @Bind form body
func (c *orders) Refund(ctx fiber.Ctx, id int64, form *dto.SuperOrderRefundForm) error {
	return services.Super.RefundOrder(ctx, id, form)
}

// Order statistics
//
// @Router /super/v1/orders/statistics [get]
// @Summary Order statistics
// @Description Order statistics
// @Tags Order
// @Accept json
// @Produce json
// @Success 200 {object} dto.OrderStatisticsResponse
func (c *orders) Statistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
	return services.Super.OrderStatistics(ctx)
}
