Files
sundynix-micro-be/app/plant/api/internal/logic/exchange/createExchangeOrderLogic.go
T
2026-05-23 13:55:05 +08:00

44 lines
1.0 KiB
Go

// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1
package exchange
import (
"context"
"fmt"
"sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types"
"sundynix-micro-go/app/plant/rpc/plant"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateExchangeOrderLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 兑换商品
func NewCreateExchangeOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExchangeOrderLogic {
return &CreateExchangeOrderLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateExchangeOrderLogic) CreateExchangeOrder(req *types.ExchangeOrderReq) error {
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
_, err := l.svcCtx.PlantRpc.CreateExchangeOrder(l.ctx, &plant.CreateExchangeOrderReq{
UserId: userId,
ItemId: req.ItemId,
Quantity: int32(req.Quantity),
RecipientName: req.RecipientName,
Phone: req.Phone,
Address: req.Address,
})
return err
}