From f4508a84236a4aff1c7b5bfa17a14a8ff95728ba Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期一, 08 七月 2024 09:45:10 +0800 Subject: [PATCH] 接口调用报错处理 --- proto/purchase_wms/server.go | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index 80f4c71..5d1da59 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -2,6 +2,7 @@ import ( "context" + "errors" "github.com/shopspring/decimal" "gorm.io/gorm" "strconv" @@ -24,8 +25,11 @@ operation.Number = strconv.FormatInt(time.Now().Unix(), 10) operation.Status = constvar.OperationStatus_Ready operation.CompanyName = req.SupplierName + operation.CompanyID = strconv.FormatInt(req.SupplierId, 10) operation.Source = req.Source - warehouse, err := models.NewWarehouseSearch().First() + operation.OperationSource = constvar.OperationSource(req.OperationSource) + operation.SalesDetailsNumber = req.SalesDetailsNumber + warehouse, err := models.NewWarehouseSearch().SetName(req.WarehouseName).First() if err != nil { return nil, err } @@ -89,7 +93,13 @@ } func (s *Server) SrmGetOperationInfo(c context.Context, req *SrmGetOperationInfoRequest) (*SrmGetOperationInfoResponse, error) { - operations, err := models.NewOperationSearch().SetSourceNumber(req.Number).SetPreload(true).FindNotTotal() + if req.Number == "" && req.SalesDetailsNumber == "" && req.OperationSource == 0 { + return nil, errors.New("鍙傛暟缂哄け") + } + operations, err := models.NewOperationSearch().SetSourceNumber(req.Number). + SetOperationSource(constvar.OperationSource(req.OperationSource)). + SetSalesDetailsNumber(req.SalesDetailsNumber). + SetPreload(true).FindNotTotal() if err != nil { return nil, err } @@ -100,9 +110,7 @@ index := strings.LastIndex(operation.OperationTypeName, "-") so.WarehouseName = operation.OperationTypeName[:index] so.Status = int64(operation.Status) - if operation.Status == constvar.OperationStatus_Finish { - so.OverTime = operation.UpdateTime - } + so.OverTime = operation.CreateTime for _, detail := range operation.Details { s := so s.ProductId = detail.ProductId -- Gitblit v1.8.0