package card_info_t_mall_game

import (
	"context"
	"kami/internal/errHandler"
	"kami/internal/model"
	"kami/internal/service"

	"kami/api/card_info_t_mall_game/v1"

	"github.com/gogf/gf/v2/errors/gcode"
)

func (c *ControllerV1) TMallGameStats(ctx context.Context, req *v1.TMallGameStatsReq) (res *v1.TMallGameStatsRes, err error) {
	orderService := service.RechargeTMallGameOrder()
	res = &v1.TMallGameStatsRes{}
	list, err := orderService.GetOrderStats(ctx, &model.TMallGameStatsInput{
		TMallGameStatsReq: *req,
	})
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取订单统计失败")
		return
	}
	res = list.TMallGameStatsRes
	err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "转换订单统计数据失败")
	return
}
