package controller import ( "context" "fmt" "video-factory/common" "video-factory/shortdrama/model/dto" "video-factory/shortdrama/service" "github.com/gogf/gf/v2/frame/g" ) type transaction struct{} var Transaction = new(transaction) func (c *transaction) List(ctx context.Context, req *dto.ListTransactionReq) (res *dto.ListTransactionRes, err error) { r := g.RequestFromCtx(ctx) userId := req.UserId if userId == 0 { userId = common.GetUserId(r) } list, total, err := service.TransactionService.ListByUser(ctx, userId, req.Type, req.Page, req.PageSize) if err != nil { return nil, err } return &dto.ListTransactionRes{List: list, Total: total, Page: req.Page, PageSize: req.PageSize}, nil } func (c *transaction) Recharge(ctx context.Context, req *dto.RechargeReq) (res *struct{}, err error) { return nil, service.TransactionService.Recharge(ctx, req.UserId, req.Amount, "", fmt.Sprintf("后台充值 %.2f 元", float64(req.Amount)/100)) }