From eaa4218d45fade3a9ac2cfb7ff81cbfceeb650cd Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期四, 11 一月 2024 10:36:23 +0800
Subject: [PATCH] 问题修改

---
 proto/product_inventory/server.go |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index a4c77bf..14bf8cd 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -34,7 +34,7 @@
 	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 as location_id,"+
+		Select("wms_operation_details.product_id,wms_operation_details.amount,wms_operation_details.from_location_id as location_id,"+
 			"wms_operation.number,wms_operation.waybill_number, logistic_company.name").
 		Joins("left join wms_operation on wms_operation.id = wms_operation_details.operation_id").
 		Joins("left join logistic_company on logistic_company.id = wms_operation.logistic_company_id").
@@ -92,8 +92,8 @@
 		Select("wms_operation_details.product_id, wms_operation_details.amount").
 		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_details.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, 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,23 +156,31 @@
 	}
 	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
 	}
-	operation.FromLocationID = location.Id
+
 	first, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First()
 	if err != nil {
 		return nil, err
 	}
-	operation.ToLocationID = first.Id
+	operation.LocationID = location.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
 			detail.ProductId = product.Id
 			amount, _ := decimal.NewFromString(product.Amount)
 			detail.Amount = amount
+			detail.FromLocationID = location.Id
+			detail.ToLocationID = first.Id
 			details = append(details, &detail)
 		}
 		operation.Details = details
@@ -183,7 +192,8 @@
 			detail.ProductId = product.Id
 			amount, _ := decimal.NewFromString(product.Amount)
 			detail.Amount = amount
-			details = append(details, &detail)
+			detail.FromLocationID = location.Id
+			detail.ToLocationID = first.Id
 			newOperation.Details = append(newOperation.Details, &detail)
 			operations = append(operations, &newOperation)
 		}

--
Gitblit v1.8.0