From 4b15160f8821d9b4c223a817c2632ae1425be533 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 10 十一月 2023 10:51:54 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
---
proto/product_inventory/server.go | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index 9ebb7fb..d2c289a 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -22,19 +22,23 @@
LocationId int `json:"locationId"`
}
-func (s *Server) GetProductInfo(ctx context.Context, req *GetInventoryProductInfoRequest) (*GetInventoryProductInfoResponse, error) {
+func (s *Server) GetInventoryProductInfo(ctx context.Context, req *GetInventoryProductInfoRequest) (*GetInventoryProductInfoResponse, error) {
if req.Number == "" {
return nil, errors.New("鍙傛暟涓嶈兘涓虹┖")
}
//鏌ヨ浜у搧id
var details []ProductAndLocationInfo
var productIds []string
+ resp := new(GetInventoryProductInfoResponse)
err := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}).
- Select("wms_operation_details.product_id,wms_operation_details.amount,wms_operation.from_location_id").
+ Select("wms_operation_details.product_id,wms_operation_details.amount,wms_operation.from_location_id as location_id").
Joins("left join wms_operation on wms_operation.id = wms_operation_details.operation_id").
Where("wms_operation.source_number = ?", req.Number).Find(&details).Error
if err != nil {
return nil, err
+ }
+ if len(details) == 0 {
+ return resp, nil
}
var locationId int
for _, detail := range details {
@@ -91,12 +95,13 @@
}
products := make([]*ProductInfo, 0)
for _, material := range materials {
- var p *ProductInfo
+ var p ProductInfo
p.Id = material.ID
p.Name = material.Name
for _, detail := range details {
if material.ID == detail.ProductId {
p.OrderAmount = detail.Amount.String()
+ p.Valorem = detail.Amount.Mul(material.SalePrice).String()
break
}
}
@@ -118,9 +123,8 @@
}
p.AvailableNumber = cu.String()
- products = append(products, p)
+ products = append(products, &p)
}
- resp := new(GetInventoryProductInfoResponse)
resp.ProductList = products
return resp, nil
}
@@ -156,23 +160,23 @@
operation.BaseOperationType = constvar.BaseOperationTypeOutgoing
if req.DeliverType == 1 {
for _, product := range req.ProductList {
- var detail *models.OperationDetails
+ var detail models.OperationDetails
detail.ProductId = product.Id
amount, _ := decimal.NewFromString(product.Amount)
detail.Amount = amount
- details = append(details, detail)
+ details = append(details, &detail)
}
operation.Details = details
operations = append(operations, &operation)
} else {
for _, product := range req.ProductList {
newOperation := operation
- var detail *models.OperationDetails
+ var detail models.OperationDetails
detail.ProductId = product.Id
amount, _ := decimal.NewFromString(product.Amount)
detail.Amount = amount
- details = append(details, detail)
- newOperation.Details = append(newOperation.Details, detail)
+ details = append(details, &detail)
+ newOperation.Details = append(newOperation.Details, &detail)
operations = append(operations, &newOperation)
}
}
--
Gitblit v1.8.0