package card_info_t_mall_game

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

	"github.com/jinzhu/copier"

	"kami/api/card_info_t_mall_game/v1"

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

func (c *ControllerV1) TMallGameOrderList(ctx context.Context, req *v1.TMallGameOrderListReq) (res *v1.TMallGameOrderListRes, err error) {
	orderService := service.RechargeTMallGameOrder()
	res = new(v1.TMallGameOrderListRes)
	total, list, err := orderService.List(ctx, &model.RechargeTMallGameOrderListInput{
		TMallGameOrderListReq: req,
	})
	err = errHandler.WrapError(ctx, gcode.CodeInternalError, err)
	if err != nil {
		return
	}
	res.Total = total
	err = copier.Copy(&res.List, list)
	return
}
