package card_info_original_jd

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

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

	"kami/api/card_info_original_jd/v1"
)

func (c *ControllerV1) OriginalJDAccountWalletList(ctx context.Context, req *v1.OriginalJDAccountWalletListReq) (res *v1.OriginalJDAccountWalletListRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	total, data, err := service.CardRedeemAccount().GetWalletHistory(ctx, &model.RedeemAccountHistoryQueryInput{
		CommonPageReq: commonApi.CommonPageReq{
			Current:  req.Current,
			PageSize: req.PageSize,
		},
		AccountId: req.AccountId,
	})
	res = &v1.OriginalJDAccountWalletListRes{}
	res.List = data
	res.Total = total
	return
}
