From a93fd95cd9bda756b227b7850f1e6aa52ced0ef8 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期五, 22 三月 2024 17:02:40 +0800 Subject: [PATCH] 保存质检信息 --- proto/purchase_wms/server.go | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index 29037a8..7fbf57f 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -139,6 +139,18 @@ if err != nil { return nil, err } + purchaseIds := make([]uint, 0) + for _, p := range ps { + purchaseIds = append(purchaseIds, p.ID) + } + if len(purchaseIds) == 0 { + return nil, errors.New("娌℃湁鏌ュ埌閲囪喘鍗�") + } + pps := make([]*purchase.PurchaseProducts, 0) + err = global.GVA_DB.Model(&purchase.PurchaseProducts{}).Where("purchase_id in (?)", purchaseIds).Preload("Product").Find(&pps).Error + if err != nil { + return nil, err + } infos := make([]*PurchaseInfo, 0) for _, p := range ps { var info PurchaseInfo @@ -147,7 +159,19 @@ info.SupplierName = p.Supplier.Name info.Amount = p.Quantity.IntPart() info.Status = int64(p.Status) - infos = append(infos, &info) + if p.Status == purchase.OrderStatusStored || p.Status == purchase.OrderStatusCompleted { + info.FinishAmount = info.Amount + } + for _, pp := range pps { + if int(p.ID) == pp.PurchaseId { + ni := info + ni.ProductId = pp.Product.Number + ni.ProductName = pp.Product.Name + ni.Specs = pp.Product.Specifications + ni.Unit = pp.Product.Unit + infos = append(infos, &ni) + } + } } resp := new(GetPurchaseInfoResponse) resp.Infos = infos -- Gitblit v1.8.0