package exchange

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"sundynix-micro-go/app/plant/api/internal/svc"
	"sundynix-micro-go/app/plant/api/internal/types"
	plantPb "sundynix-micro-go/app/plant/rpc/plant"
)

type UpdateExchangeOrderLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateExchangeOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateExchangeOrderLogic {
	return &UpdateExchangeOrderLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *UpdateExchangeOrderLogic) UpdateExchangeOrder(req *types.UpdateExchangeOrderReq) error {
	_, err := l.svcCtx.PlantRpc.UpdateExchangeOrder(l.ctx, &plantPb.UpdateExchangeOrderReq{
		Id: req.Id, Status: int32(req.Status), TrackingNo: req.TrackingNo, Remark: req.Remark,
	})
	return err
}
