From 942642be1995671d65b013e559376ac0bde4e8b9 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 16 四月 2024 16:26:55 +0800 Subject: [PATCH] 产品添加字段 --- proto/product_inventory/server.go | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go index 26bd44b..1113c11 100644 --- a/proto/product_inventory/server.go +++ b/proto/product_inventory/server.go @@ -5,6 +5,7 @@ "errors" "fmt" "github.com/shopspring/decimal" + "gorm.io/gorm" "strconv" "strings" "time" @@ -466,3 +467,31 @@ resp.Msg = "success" return resp, nil } + +func (s *Server) GetOutputOperationInfo(ctx context.Context, req *GetOutputOperationInfoRequest) (*GetOutputOperationInfoResponse, error) { + if req.Number == "" { + return nil, errors.New("鍙傛暟涓嶈兘涓虹┖") + } + result := new(GetOutputOperationInfoResponse) + first, err := models.NewOperationSearch().SetSourceNumber(req.Number).SetBaseOperationType(constvar.BaseOperationTypeOutgoing).SetStatus(constvar.OperationStatus_Finish).First() + if err != nil { + if err == gorm.ErrRecordNotFound { + return result, nil + } + return nil, err + } + details, err := models.NewOperationDetailsSearch().SetOperationId(first.Id).FindNotTotal() + if err != nil { + return nil, err + } + list := make([]*OutputProduct, 0) + for _, detail := range details { + var op OutputProduct + op.Number = detail.ProductId + op.Amount = detail.Amount.String() + list = append(list, &op) + } + result.Products = list + + return result, nil +} -- Gitblit v1.8.0