From 952854aaaefaca423c0b87144203551809cb8bdc Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 30 三月 2024 17:29:41 +0800 Subject: [PATCH] crm获取发货数量 --- 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 8bd4069..41a6b6e 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).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