From 9313a14c7c08d4dcf73e2f975537aba6a24479b0 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 27 十二月 2023 18:04:09 +0800
Subject: [PATCH] 虚拟物料无库存,不进行出入库

---
 proto/product_inventory/server.go |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index a4c77bf..b564f8d 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -93,7 +93,7 @@
 		Joins("left join wms_operation on wms_operation_details.operation_id = wms_operation.id").
 		Where("wms_operation_details.product_id in (?)", productIds).
 		Where("wms_operation.from_location_id in (?)", locationIds).Where("wms_operation.status = ?", constvar.OperationStatus_Ready).
-		Where("wms_operation.base_operation_type in (?)", []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal}).
+		Where("wms_operation.base_operation_type in (?)", []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal, constvar.BaseOperationTypeDisuse}).
 		Find(&canUse).Error
 	if err != nil {
 		return nil, err
@@ -101,7 +101,7 @@
 	products := make([]*ProductInfo, 0)
 	for _, material := range materials {
 		var p ProductInfo
-		p.Id = material.ID
+		p.Number = material.ID
 		p.Name = material.Name
 		for _, detail := range details {
 			if material.ID == detail.ProductId {
@@ -129,6 +129,7 @@
 				cu = cu.Add(info.Amount)
 			}
 		}
+		cu = at.Sub(cu)
 		p.AvailableNumber = cu.String()
 
 		products = append(products, &p)
@@ -155,7 +156,7 @@
 	}
 	operation.OperationTypeName = operationType.Name
 	operation.OperationTypeId = operationType.Id
-	location, err := models.NewLocationSearch().SetJointNames([]string{warehouse.Code}).First()
+	location, err := models.NewLocationSearch().SetID(warehouse.LocationId).First()
 	if err != nil {
 		return nil, err
 	}
@@ -166,6 +167,12 @@
 	}
 	operation.ToLocationID = first.Id
 	operation.BaseOperationType = constvar.BaseOperationTypeOutgoing
+	operation.ReceiverName = req.Addressee
+	operation.ReceiverPhone = req.Phone
+	operation.ReceiverAddr = req.Address
+	operation.Source = req.Source
+	operation.CompanyID = int(req.ClientId)
+	operation.CompanyName = req.ClientName
 	if req.DeliverType == 1 {
 		for _, product := range req.ProductList {
 			var detail models.OperationDetails
@@ -183,7 +190,6 @@
 			detail.ProductId = product.Id
 			amount, _ := decimal.NewFromString(product.Amount)
 			detail.Amount = amount
-			details = append(details, &detail)
 			newOperation.Details = append(newOperation.Details, &detail)
 			operations = append(operations, &newOperation)
 		}

--
Gitblit v1.8.0