package api

import (
	"gadmin/internal/admin/forms"
	"gadmin/internal/admin/service"
	"github.com/gin-gonic/gin"
)

func OrderUserStatistics(c *gin.Context) {
	var req forms.OrderUserStatisticsReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.UserStatistics(c, req))
}

func RechargeRanking(c *gin.Context) {
	var req forms.RechargeRankingReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.RechargeRanking(c, req))
}

func OrderSevenStatistics(c *gin.Context) {
	var req forms.OrderSevenStatisticsListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.SevenStatisticsList(c, req))
}

func OrderDailyStatistics(c *gin.Context) {
	var req forms.OrderDailyStatisticsListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.DailyStatisticsList(c, req))
}

func OrderList(c *gin.Context) {
	var req forms.OrderListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}
	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.List(c, req))
}

func AbnormalOrderList(c *gin.Context) {
	var req forms.AbnormalOrderListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}
	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.AbnormalList(c, req))
}

func AbnormalOrderReissue(c *gin.Context) {
	var req forms.AbnormalOrderReissueReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}
	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.Order.AbnormalReissue(c, req))
}
