From 576039f5ee85910edd332aa4459a132b713e80bd Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 18 三月 2024 20:00:50 +0800
Subject: [PATCH] 发货grpc接口

---
 models/operation_type.go                             |   22 +
 proto/product_inventory/product_inventory.pb.go      |  368 +++++++++++++++++++++++++-----
 proto/product_inventory/product_inventory_grpc.pb.go |   37 +++
 proto/product_inventory.proto                        |   19 +
 service/operation.go                                 |   75 ++++++
 proto/product_inventory/server.go                    |  148 ++++++++++++
 6 files changed, 603 insertions(+), 66 deletions(-)

diff --git a/models/operation_type.go b/models/operation_type.go
index 4857259..b206050 100644
--- a/models/operation_type.go
+++ b/models/operation_type.go
@@ -41,12 +41,13 @@
 
 	OperationTypeSearch struct {
 		OperationType
-		Order    string
-		PageNum  int
-		PageSize int
-		Keyword  string
-		Orm      *gorm.DB
-		Preload  bool
+		Order        string
+		PageNum      int
+		PageSize     int
+		Keyword      string
+		Orm          *gorm.DB
+		Preload      bool
+		WarehouseIds []int
 	}
 
 	OperationTypeByStatus struct {
@@ -109,6 +110,11 @@
 	return slf
 }
 
+func (slf *OperationTypeSearch) SetWarehouseIds(warehouseIds []int) *OperationTypeSearch {
+	slf.WarehouseIds = warehouseIds
+	return slf
+}
+
 func (slf *OperationTypeSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&OperationType{})
 
@@ -136,6 +142,10 @@
 		db = db.Where("warehouse_id = ?", slf.WarehouseId)
 	}
 
+	if len(slf.WarehouseIds) > 0 {
+		db = db.Where("warehouse_id in ?", slf.WarehouseIds)
+	}
+
 	if int(slf.BaseOperationType) != 0 {
 		db = db.Where("base_operation_type = ?", slf.BaseOperationType)
 	}
diff --git a/proto/product_inventory.proto b/proto/product_inventory.proto
index 97640bb..35789d9 100644
--- a/proto/product_inventory.proto
+++ b/proto/product_inventory.proto
@@ -7,6 +7,7 @@
   rpc GetInventoryProductInfo(GetInventoryProductInfoRequest) returns (GetInventoryProductInfoResponse) {}
   rpc UpdateSalesDetailStatus(UpdateSalesDetailStatusRequest) returns (UpdateSalesDetailStatusResponse) {}
   rpc GetOrderInputAndOutputInfo(GetOrderInputAndOutputInfoRequest) returns (GetOrderInputAndOutputInfoResponse) {}
+  rpc OrderProductOutput(OrderProductOutputRequest) returns (OrderProductOutputResponse) {}
 }
 
 message CreateOperationRequest{
@@ -92,6 +93,8 @@
   string Amount = 11; //鏁伴噺
   FinishStatus Status = 13;
   string CreateTime = 14;
+  int64 LocationID = 15;
+  int64 WareHouseID = 16;
 }
 message GetOrderInputAndOutputInfoRequest {
    string Number = 1;//鏄庣粏鍗曠紪鐮�
@@ -102,4 +105,20 @@
   string  Msg = 2;
   repeated InputAndOutputInfo InputList = 3;
   repeated InputAndOutputInfo OutputList = 4;
+}
+
+message OutputProduct {
+  string Number = 1;//浜у搧缂栫爜
+  string Amount = 2; //鍙戣揣鏁伴噺
+}
+
+
+message OrderProductOutputRequest {
+  string OrderNumber = 1;//鏄庣粏鍗曠紪鐮�
+  repeated OutputProduct Products= 2;//鍙戣揣鏄庣粏
+}
+
+message OrderProductOutputResponse {
+  int32   Code = 1;
+  string  Msg = 2;
 }
\ No newline at end of file
diff --git a/proto/product_inventory/product_inventory.pb.go b/proto/product_inventory/product_inventory.pb.go
index 3ef9721..970a96e 100644
--- a/proto/product_inventory/product_inventory.pb.go
+++ b/proto/product_inventory/product_inventory.pb.go
@@ -660,6 +660,8 @@
 	Amount      string       `protobuf:"bytes,11,opt,name=Amount,proto3" json:"Amount,omitempty"` //鏁伴噺
 	Status      FinishStatus `protobuf:"varint,13,opt,name=Status,proto3,enum=FinishStatus" json:"Status,omitempty"`
 	CreateTime  string       `protobuf:"bytes,14,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"`
+	LocationID  int64        `protobuf:"varint,15,opt,name=LocationID,proto3" json:"LocationID,omitempty"`
+	WareHouseID int64        `protobuf:"varint,16,opt,name=WareHouseID,proto3" json:"WareHouseID,omitempty"`
 }
 
 func (x *InputAndOutputInfo) Reset() {
@@ -785,6 +787,20 @@
 	return ""
 }
 
+func (x *InputAndOutputInfo) GetLocationID() int64 {
+	if x != nil {
+		return x.LocationID
+	}
+	return 0
+}
+
+func (x *InputAndOutputInfo) GetWareHouseID() int64 {
+	if x != nil {
+		return x.WareHouseID
+	}
+	return 0
+}
+
 type GetOrderInputAndOutputInfoRequest struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -903,6 +919,171 @@
 	return nil
 }
 
+type OutputProduct struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` //浜у搧缂栫爜
+	Amount string `protobuf:"bytes,2,opt,name=Amount,proto3" json:"Amount,omitempty"` //鍙戣揣鏁伴噺
+}
+
+func (x *OutputProduct) Reset() {
+	*x = OutputProduct{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_product_inventory_proto_msgTypes[11]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OutputProduct) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OutputProduct) ProtoMessage() {}
+
+func (x *OutputProduct) ProtoReflect() protoreflect.Message {
+	mi := &file_product_inventory_proto_msgTypes[11]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use OutputProduct.ProtoReflect.Descriptor instead.
+func (*OutputProduct) Descriptor() ([]byte, []int) {
+	return file_product_inventory_proto_rawDescGZIP(), []int{11}
+}
+
+func (x *OutputProduct) GetNumber() string {
+	if x != nil {
+		return x.Number
+	}
+	return ""
+}
+
+func (x *OutputProduct) GetAmount() string {
+	if x != nil {
+		return x.Amount
+	}
+	return ""
+}
+
+type OrderProductOutputRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OrderNumber string           `protobuf:"bytes,1,opt,name=OrderNumber,proto3" json:"OrderNumber,omitempty"` //鏄庣粏鍗曠紪鐮�
+	Products    []*OutputProduct `protobuf:"bytes,2,rep,name=Products,proto3" json:"Products,omitempty"`       //鍙戣揣鏄庣粏
+}
+
+func (x *OrderProductOutputRequest) Reset() {
+	*x = OrderProductOutputRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_product_inventory_proto_msgTypes[12]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OrderProductOutputRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OrderProductOutputRequest) ProtoMessage() {}
+
+func (x *OrderProductOutputRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_product_inventory_proto_msgTypes[12]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use OrderProductOutputRequest.ProtoReflect.Descriptor instead.
+func (*OrderProductOutputRequest) Descriptor() ([]byte, []int) {
+	return file_product_inventory_proto_rawDescGZIP(), []int{12}
+}
+
+func (x *OrderProductOutputRequest) GetOrderNumber() string {
+	if x != nil {
+		return x.OrderNumber
+	}
+	return ""
+}
+
+func (x *OrderProductOutputRequest) GetProducts() []*OutputProduct {
+	if x != nil {
+		return x.Products
+	}
+	return nil
+}
+
+type OrderProductOutputResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Code int32  `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
+	Msg  string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
+}
+
+func (x *OrderProductOutputResponse) Reset() {
+	*x = OrderProductOutputResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_product_inventory_proto_msgTypes[13]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OrderProductOutputResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OrderProductOutputResponse) ProtoMessage() {}
+
+func (x *OrderProductOutputResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_product_inventory_proto_msgTypes[13]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use OrderProductOutputResponse.ProtoReflect.Descriptor instead.
+func (*OrderProductOutputResponse) Descriptor() ([]byte, []int) {
+	return file_product_inventory_proto_rawDescGZIP(), []int{13}
+}
+
+func (x *OrderProductOutputResponse) GetCode() int32 {
+	if x != nil {
+		return x.Code
+	}
+	return 0
+}
+
+func (x *OrderProductOutputResponse) GetMsg() string {
+	if x != nil {
+		return x.Msg
+	}
+	return ""
+}
+
 var File_product_inventory_proto protoreflect.FileDescriptor
 
 var file_product_inventory_proto_rawDesc = []byte{
@@ -977,8 +1158,8 @@
 	0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
 	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
 	0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03,
-	0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0xf9,
-	0x02, 0x0a, 0x12, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75,
+	0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0xbb,
+	0x03, 0x0a, 0x12, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75,
 	0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18,
 	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a,
 	0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d,
@@ -1001,51 +1182,76 @@
 	0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x53, 0x74, 0x61, 0x74,
 	0x75, 0x73, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72,
 	0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
-	0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x21, 0x47, 0x65,
+	0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x4c, 0x6f,
+	0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a,
+	0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x57, 0x61,
+	0x72, 0x65, 0x48, 0x6f, 0x75, 0x73, 0x65, 0x49, 0x44, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x0b, 0x57, 0x61, 0x72, 0x65, 0x48, 0x6f, 0x75, 0x73, 0x65, 0x49, 0x44, 0x22, 0x3b, 0x0a, 0x21,
+	0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64,
+	0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x74, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xb2, 0x01, 0x0a, 0x22, 0x47, 0x65,
 	0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75,
-	0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
-	0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xb2, 0x01, 0x0a, 0x22, 0x47, 0x65, 0x74, 0x4f,
-	0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70,
-	0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12,
-	0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f,
-	0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x03, 0x4d, 0x73, 0x67, 0x12, 0x31, 0x0a, 0x09, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73,
-	0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41,
-	0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x49, 0x6e,
-	0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x0a, 0x4f, 0x75, 0x74, 0x70, 0x75,
-	0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x49, 0x6e,
-	0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f,
-	0x52, 0x0a, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x2a, 0x25, 0x0a, 0x0c,
-	0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x09, 0x0a, 0x05,
-	0x52, 0x65, 0x61, 0x64, 0x79, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x69, 0x6e, 0x69, 0x73,
-	0x68, 0x10, 0x01, 0x32, 0x8a, 0x03, 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49,
-	0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
-	0x46, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
-	0x6f, 0x6e, 0x12, 0x17, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61,
-	0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x43, 0x72,
-	0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6e,
-	0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e,
-	0x66, 0x6f, 0x12, 0x1f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72,
-	0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
-	0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74,
-	0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74,
-	0x75, 0x73, 0x12, 0x1f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73,
-	0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65,
-	0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x67, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x4f, 0x72,
-	0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75,
-	0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72,
+	0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+	0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
+	0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x31, 0x0a, 0x09, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x4c,
+	0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x49, 0x6e, 0x70, 0x75,
+	0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09,
+	0x49, 0x6e, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x0a, 0x4f, 0x75, 0x74,
+	0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e,
 	0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x49, 0x6e,
-	0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x47, 0x65, 0x74, 0x4f,
-	0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70,
-	0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
-	0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x69, 0x6e,
-	0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x66, 0x6f, 0x52, 0x0a, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x3f,
+	0x0a, 0x0d, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12,
+	0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
+	0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22,
+	0x69, 0x0a, 0x19, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4f,
+	0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b,
+	0x4f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x0b, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2a,
+	0x0a, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
+	0x32, 0x0e, 0x2e, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
+	0x52, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x22, 0x42, 0x0a, 0x1a, 0x4f, 0x72,
+	0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74,
+	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03,
+	0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x2a, 0x25,
+	0x0a, 0x0c, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x09,
+	0x0a, 0x05, 0x52, 0x65, 0x61, 0x64, 0x79, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x69, 0x6e,
+	0x69, 0x73, 0x68, 0x10, 0x01, 0x32, 0xdb, 0x03, 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63,
+	0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
+	0x65, 0x12, 0x46, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61,
+	0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65,
+	0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
+	0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
+	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x47, 0x65, 0x74,
+	0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
+	0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74,
+	0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
+	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e,
+	0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52,
+	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x55, 0x70, 0x64,
+	0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74,
+	0x61, 0x74, 0x75, 0x73, 0x12, 0x1f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c,
+	0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
+	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61,
+	0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
+	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x67, 0x0a, 0x1a, 0x47, 0x65, 0x74,
+	0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74,
+	0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64,
+	0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74,
+	0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x47, 0x65,
+	0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x41, 0x6e, 0x64, 0x4f, 0x75,
+	0x74, 0x70, 0x75, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+	0x22, 0x00, 0x12, 0x4f, 0x0a, 0x12, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x64, 0x75,
+	0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1a, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72,
+	0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x64,
+	0x75, 0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
+	0x65, 0x22, 0x00, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
+	0x5f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
+	0x6f, 0x33,
 }
 
 var (
@@ -1061,7 +1267,7 @@
 }
 
 var file_product_inventory_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_product_inventory_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
+var file_product_inventory_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
 var file_product_inventory_proto_goTypes = []interface{}{
 	(FinishStatus)(0),                          // 0: FinishStatus
 	(*CreateOperationRequest)(nil),             // 1: CreateOperationRequest
@@ -1075,6 +1281,9 @@
 	(*InputAndOutputInfo)(nil),                 // 9: InputAndOutputInfo
 	(*GetOrderInputAndOutputInfoRequest)(nil),  // 10: GetOrderInputAndOutputInfoRequest
 	(*GetOrderInputAndOutputInfoResponse)(nil), // 11: GetOrderInputAndOutputInfoResponse
+	(*OutputProduct)(nil),                      // 12: OutputProduct
+	(*OrderProductOutputRequest)(nil),          // 13: OrderProductOutputRequest
+	(*OrderProductOutputResponse)(nil),         // 14: OrderProductOutputResponse
 }
 var file_product_inventory_proto_depIdxs = []int32{
 	2,  // 0: CreateOperationRequest.ProductList:type_name -> InventoryProduct
@@ -1082,19 +1291,22 @@
 	0,  // 2: InputAndOutputInfo.Status:type_name -> FinishStatus
 	9,  // 3: GetOrderInputAndOutputInfoResponse.InputList:type_name -> InputAndOutputInfo
 	9,  // 4: GetOrderInputAndOutputInfoResponse.OutputList:type_name -> InputAndOutputInfo
-	1,  // 5: productInventoryService.CreateOperation:input_type -> CreateOperationRequest
-	4,  // 6: productInventoryService.GetInventoryProductInfo:input_type -> GetInventoryProductInfoRequest
-	7,  // 7: productInventoryService.UpdateSalesDetailStatus:input_type -> UpdateSalesDetailStatusRequest
-	10, // 8: productInventoryService.GetOrderInputAndOutputInfo:input_type -> GetOrderInputAndOutputInfoRequest
-	3,  // 9: productInventoryService.CreateOperation:output_type -> CreateOperationResponse
-	6,  // 10: productInventoryService.GetInventoryProductInfo:output_type -> GetInventoryProductInfoResponse
-	8,  // 11: productInventoryService.UpdateSalesDetailStatus:output_type -> UpdateSalesDetailStatusResponse
-	11, // 12: productInventoryService.GetOrderInputAndOutputInfo:output_type -> GetOrderInputAndOutputInfoResponse
-	9,  // [9:13] is the sub-list for method output_type
-	5,  // [5:9] is the sub-list for method input_type
-	5,  // [5:5] is the sub-list for extension type_name
-	5,  // [5:5] is the sub-list for extension extendee
-	0,  // [0:5] is the sub-list for field type_name
+	12, // 5: OrderProductOutputRequest.Products:type_name -> OutputProduct
+	1,  // 6: productInventoryService.CreateOperation:input_type -> CreateOperationRequest
+	4,  // 7: productInventoryService.GetInventoryProductInfo:input_type -> GetInventoryProductInfoRequest
+	7,  // 8: productInventoryService.UpdateSalesDetailStatus:input_type -> UpdateSalesDetailStatusRequest
+	10, // 9: productInventoryService.GetOrderInputAndOutputInfo:input_type -> GetOrderInputAndOutputInfoRequest
+	13, // 10: productInventoryService.OrderProductOutput:input_type -> OrderProductOutputRequest
+	3,  // 11: productInventoryService.CreateOperation:output_type -> CreateOperationResponse
+	6,  // 12: productInventoryService.GetInventoryProductInfo:output_type -> GetInventoryProductInfoResponse
+	8,  // 13: productInventoryService.UpdateSalesDetailStatus:output_type -> UpdateSalesDetailStatusResponse
+	11, // 14: productInventoryService.GetOrderInputAndOutputInfo:output_type -> GetOrderInputAndOutputInfoResponse
+	14, // 15: productInventoryService.OrderProductOutput:output_type -> OrderProductOutputResponse
+	11, // [11:16] is the sub-list for method output_type
+	6,  // [6:11] is the sub-list for method input_type
+	6,  // [6:6] is the sub-list for extension type_name
+	6,  // [6:6] is the sub-list for extension extendee
+	0,  // [0:6] is the sub-list for field type_name
 }
 
 func init() { file_product_inventory_proto_init() }
@@ -1235,6 +1447,42 @@
 				return nil
 			}
 		}
+		file_product_inventory_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OutputProduct); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_product_inventory_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OrderProductOutputRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_product_inventory_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OrderProductOutputResponse); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -1242,7 +1490,7 @@
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_product_inventory_proto_rawDesc,
 			NumEnums:      1,
-			NumMessages:   11,
+			NumMessages:   14,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
diff --git a/proto/product_inventory/product_inventory_grpc.pb.go b/proto/product_inventory/product_inventory_grpc.pb.go
index f010022..f2bc889 100644
--- a/proto/product_inventory/product_inventory_grpc.pb.go
+++ b/proto/product_inventory/product_inventory_grpc.pb.go
@@ -23,6 +23,7 @@
 	ProductInventoryService_GetInventoryProductInfo_FullMethodName    = "/productInventoryService/GetInventoryProductInfo"
 	ProductInventoryService_UpdateSalesDetailStatus_FullMethodName    = "/productInventoryService/UpdateSalesDetailStatus"
 	ProductInventoryService_GetOrderInputAndOutputInfo_FullMethodName = "/productInventoryService/GetOrderInputAndOutputInfo"
+	ProductInventoryService_OrderProductOutput_FullMethodName         = "/productInventoryService/OrderProductOutput"
 )
 
 // ProductInventoryServiceClient is the client API for ProductInventoryService service.
@@ -33,6 +34,7 @@
 	GetInventoryProductInfo(ctx context.Context, in *GetInventoryProductInfoRequest, opts ...grpc.CallOption) (*GetInventoryProductInfoResponse, error)
 	UpdateSalesDetailStatus(ctx context.Context, in *UpdateSalesDetailStatusRequest, opts ...grpc.CallOption) (*UpdateSalesDetailStatusResponse, error)
 	GetOrderInputAndOutputInfo(ctx context.Context, in *GetOrderInputAndOutputInfoRequest, opts ...grpc.CallOption) (*GetOrderInputAndOutputInfoResponse, error)
+	OrderProductOutput(ctx context.Context, in *OrderProductOutputRequest, opts ...grpc.CallOption) (*OrderProductOutputResponse, error)
 }
 
 type productInventoryServiceClient struct {
@@ -79,6 +81,15 @@
 	return out, nil
 }
 
+func (c *productInventoryServiceClient) OrderProductOutput(ctx context.Context, in *OrderProductOutputRequest, opts ...grpc.CallOption) (*OrderProductOutputResponse, error) {
+	out := new(OrderProductOutputResponse)
+	err := c.cc.Invoke(ctx, ProductInventoryService_OrderProductOutput_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ProductInventoryServiceServer is the server API for ProductInventoryService service.
 // All implementations must embed UnimplementedProductInventoryServiceServer
 // for forward compatibility
@@ -87,6 +98,7 @@
 	GetInventoryProductInfo(context.Context, *GetInventoryProductInfoRequest) (*GetInventoryProductInfoResponse, error)
 	UpdateSalesDetailStatus(context.Context, *UpdateSalesDetailStatusRequest) (*UpdateSalesDetailStatusResponse, error)
 	GetOrderInputAndOutputInfo(context.Context, *GetOrderInputAndOutputInfoRequest) (*GetOrderInputAndOutputInfoResponse, error)
+	OrderProductOutput(context.Context, *OrderProductOutputRequest) (*OrderProductOutputResponse, error)
 	mustEmbedUnimplementedProductInventoryServiceServer()
 }
 
@@ -105,6 +117,9 @@
 }
 func (UnimplementedProductInventoryServiceServer) GetOrderInputAndOutputInfo(context.Context, *GetOrderInputAndOutputInfoRequest) (*GetOrderInputAndOutputInfoResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetOrderInputAndOutputInfo not implemented")
+}
+func (UnimplementedProductInventoryServiceServer) OrderProductOutput(context.Context, *OrderProductOutputRequest) (*OrderProductOutputResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method OrderProductOutput not implemented")
 }
 func (UnimplementedProductInventoryServiceServer) mustEmbedUnimplementedProductInventoryServiceServer() {
 }
@@ -192,6 +207,24 @@
 	return interceptor(ctx, in, info, handler)
 }
 
+func _ProductInventoryService_OrderProductOutput_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(OrderProductOutputRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ProductInventoryServiceServer).OrderProductOutput(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: ProductInventoryService_OrderProductOutput_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ProductInventoryServiceServer).OrderProductOutput(ctx, req.(*OrderProductOutputRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // ProductInventoryService_ServiceDesc is the grpc.ServiceDesc for ProductInventoryService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -215,6 +248,10 @@
 			MethodName: "GetOrderInputAndOutputInfo",
 			Handler:    _ProductInventoryService_GetOrderInputAndOutputInfo_Handler,
 		},
+		{
+			MethodName: "OrderProductOutput",
+			Handler:    _ProductInventoryService_OrderProductOutput_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "product_inventory.proto",
diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index e76b520..bf8ee7e 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -3,12 +3,14 @@
 import (
 	"context"
 	"errors"
+	"fmt"
 	"github.com/shopspring/decimal"
 	"strconv"
 	"strings"
 	"time"
 	"wms/constvar"
 	"wms/models"
+	"wms/pkg/logx"
 	"wms/pkg/timex"
 	"wms/service"
 )
@@ -295,11 +297,15 @@
 		if detail.BaseOperationType == constvar.BaseOperationTypeIncoming && detail.Status == constvar.OperationStatus_Finish {
 			if locationHouseMap[detail.ToLocationId] != nil {
 				info.Warehouse = locationHouseMap[detail.ToLocationId].Name //鍏ュ簱浠撳簱鍚�
+				info.LocationID = int64(detail.ToLocationId)
+				info.WareHouseID = int64(locationHouseMap[detail.ToLocationId].Id)
 			}
 			inputList = append(inputList, &info)
 		} else if detail.BaseOperationType == constvar.BaseOperationTypeOutgoing {
 			if locationHouseMap[detail.FromLocationId] != nil {
 				info.Warehouse = locationHouseMap[detail.FromLocationId].Name //鍙戣揣浠撳簱鍚�
+				info.LocationID = int64(detail.FromLocationId)
+				info.WareHouseID = int64(locationHouseMap[detail.FromLocationId].Id)
 			}
 			outputList = append(outputList, &info)
 		}
@@ -309,3 +315,145 @@
 
 	return resp, nil
 }
+
+type StoreInfo struct {
+	Name            string          `json:"name"`            //浜у搧鍚嶇О
+	Number          string          `json:"number"`          //浜у搧缂栧彿
+	StoreAmount     decimal.Decimal `json:"storeAmount"`     //璁㈠崟鍏ュ簱鏁伴噺
+	AvailableAmount decimal.Decimal `json:"availableAmount"` //鍓╀綑鍙敤鏁伴噺
+}
+
+type OutputSimpleInfo struct {
+	Number string          `json:"number"` //浜у搧缂栧彿
+	Amount decimal.Decimal `json:"amount"` //鍦ㄥ簱鏁伴噺
+	Status int             `json:"status"` //0灏辩华 1瀹屾垚
+}
+
+func (s *Server) OrderProductOutput(ctx context.Context, req *OrderProductOutputRequest) (resp *OrderProductOutputResponse, err error) {
+	if req.OrderNumber == "" || len(req.Products) == 0 {
+		return nil, errors.New("鍙傛暟缂哄け")
+	}
+	orderInputAndOutputInfoResponse, err := s.GetOrderInputAndOutputInfo(ctx, &GetOrderInputAndOutputInfoRequest{
+		Number: req.OrderNumber,
+	})
+	if err != nil {
+		logx.Errorf("OrderProductOutput GetOrderInputAndOutputInfo err:%v, req:%v", err, req)
+		return nil, errors.New("鑾峰彇鍑哄叆搴撲俊鎭け璐�")
+	}
+
+	outputList := orderInputAndOutputInfoResponse.OutputList
+	inputList := orderInputAndOutputInfoResponse.InputList
+	inputProductMap := make(map[string]*StoreInfo)
+	outputProductMap := make(map[string]*OutputSimpleInfo)
+	inputLocationAmountMap := make(map[int64]map[string]decimal.Decimal)
+	outputLocationAmountMap := make(map[int64]map[string]decimal.Decimal)
+	for _, v := range outputList {
+		if outputProductMap[v.Number] == nil {
+			simpleInfo := &OutputSimpleInfo{
+				Number: v.Number,
+			}
+			amount, _ := decimal.NewFromString(v.Amount)
+			simpleInfo.Amount = amount
+			outputProductMap[v.Number] = simpleInfo
+		} else {
+			amount, _ := decimal.NewFromString(v.Amount)
+			outputProductMap[v.Number].Amount = outputProductMap[v.Number].Amount.Add(amount)
+		}
+	}
+	for _, v := range inputList {
+		if inputProductMap[v.Number] == nil {
+			storeInfo := &StoreInfo{
+				Number: v.Number,
+				Name:   v.Name,
+			}
+			storeAmount, _ := decimal.NewFromString(v.Amount)
+			storeInfo.StoreAmount = storeAmount
+			storeInfo.AvailableAmount = storeAmount
+			inputProductMap[v.Number] = storeInfo
+		} else {
+			storeAmount, _ := decimal.NewFromString(v.Amount)
+			inputProductMap[v.Number].StoreAmount = inputProductMap[v.Number].StoreAmount.Add(storeAmount)
+			inputProductMap[v.Number].AvailableAmount = inputProductMap[v.Number].StoreAmount
+		}
+	}
+
+	for number, inputInfo := range inputProductMap {
+		outputInfo := outputProductMap[inputInfo.Number]
+		if outputInfo != nil {
+			inputProductMap[number].AvailableAmount = inputProductMap[number].AvailableAmount.Sub(outputInfo.Amount) //鍙敤鏁伴噺 = 鍏ュ簱瀹屾垚鏁伴噺 - 宸插彂璐ф暟閲�
+		}
+	}
+
+	//鏍¢獙鍙敤鏁伴噺鏄惁瓒冲
+	productNeedSendAmount := make(map[string]decimal.Decimal)
+	for _, product := range req.Products {
+		sendAmount, _ := decimal.NewFromString(product.Amount)
+		productNeedSendAmount[product.Number] = sendAmount
+		if inputProductMap[product.Number] == nil {
+			return nil, fmt.Errorf("鑾峰彇鍏ュ簱淇℃伅澶辫触锛屼骇鍝佺紪鍙凤細%v", product.Number)
+		}
+		if sendAmount.GreaterThan(inputProductMap[product.Number].AvailableAmount) {
+			return nil, fmt.Errorf("浜у搧鍙敤鏁伴噺涓嶈冻浠ュ彂璐э紝浜у搧缂栧彿锛�%v", product.Number)
+		}
+	}
+
+	LocationIDWarehouseIDMap := make(map[int64]int64)
+	for _, output := range outputList {
+		if outputLocationAmountMap[output.LocationID] == nil {
+			outputLocationAmountMap[output.LocationID] = make(map[string]decimal.Decimal)
+		}
+		outputAmount, _ := decimal.NewFromString(output.Amount)
+		outputLocationAmountMap[output.LocationID][output.Number] = outputAmount
+	}
+	for _, input := range inputList {
+		LocationIDWarehouseIDMap[input.LocationID] = input.WareHouseID
+
+		if inputLocationAmountMap[input.LocationID] == nil {
+			inputLocationAmountMap[input.LocationID] = make(map[string]decimal.Decimal)
+		}
+		storeAmount, _ := decimal.NewFromString(input.Amount)
+		if outputLocationAmountMap[input.LocationID] != nil {
+			storeAmount = storeAmount.Sub(outputLocationAmountMap[input.LocationID][input.Number])
+		}
+		inputLocationAmountMap[input.LocationID][input.Number] = storeAmount
+	}
+
+	productHasSendAmount := make(map[string]decimal.Decimal) //鏈宸插彂璐ф暟閲�
+
+	//find location ID
+	outputInfoList := make([]*service.OutputInfo, 0)
+	for locationID, locationProductAmounts := range inputLocationAmountMap {
+		productInfoList := make([]*service.ProductInfo, 0)
+		for productNumber, productAmount := range locationProductAmounts {
+			remainAmount := productNeedSendAmount[productNumber].Sub(productHasSendAmount[productNumber])
+			var locationSendAmount decimal.Decimal
+			if productAmount.GreaterThanOrEqual(remainAmount) {
+				locationSendAmount = remainAmount
+			} else {
+				locationSendAmount = productAmount
+			}
+			productInfoList = append(productInfoList, &service.ProductInfo{
+				ProductID: productNumber,
+				Amount:    locationSendAmount,
+			})
+			productHasSendAmount[productNumber] = productHasSendAmount[productNumber].Add(locationSendAmount)
+		}
+		outputInfoList = append(outputInfoList, &service.OutputInfo{
+			LocationID:   int(locationID),
+			WarehouseID:  int(LocationIDWarehouseIDMap[locationID]),
+			Products:     productInfoList,
+			OperationID:  0,
+			SourceNumber: req.OrderNumber,
+		})
+	}
+
+	err = service.AddOutputOperations(outputInfoList)
+
+	if err != nil {
+		return nil, err
+	}
+
+	resp.Code = 1
+	resp.Msg = "success"
+	return nil, nil
+}
diff --git a/service/operation.go b/service/operation.go
new file mode 100644
index 0000000..03ac1e6
--- /dev/null
+++ b/service/operation.go
@@ -0,0 +1,75 @@
+package service
+
+import (
+	"github.com/shopspring/decimal"
+	"time"
+	"wms/constvar"
+	"wms/models"
+)
+
+type OutputInfo struct {
+	LocationID   int
+	WarehouseID  int
+	Products     []*ProductInfo
+	OperationID  int
+	SourceNumber string
+}
+
+type ProductInfo struct {
+	ProductID string
+	Amount    decimal.Decimal
+}
+
+func AddOutputOperations(outputList []*OutputInfo) (err error) {
+	//鏌ユ壘operationID
+	warehouseIds := make([]int, 0)
+	for _, output := range outputList {
+		warehouseIds = append(warehouseIds, output.WarehouseID)
+	}
+	opTypes, err := models.NewOperationTypeSearch().SetWarehouseIds(warehouseIds).SetBaseOperationType(constvar.BaseOperationTypeOutgoing).FindNotTotal()
+	if err != nil {
+		return err
+	}
+	opTypeMap := make(map[int]*models.OperationType, len(opTypes))
+	for _, opType := range opTypes {
+		opTypeMap[opType.WarehouseId] = opType
+	}
+	operations := make([]*models.Operation, 0, len(outputList))
+	for _, output := range outputList {
+		details := make([]*models.OperationDetails, 0, len(output.Products))
+		for _, product := range output.Products {
+			details = append(details, &models.OperationDetails{
+				OperationID:    0,
+				ProductId:      product.ProductID,
+				Amount:         product.Amount,
+				FromLocationID: output.LocationID,
+			})
+		}
+		operation := &models.Operation{
+			Id:                0,
+			Number:            "",
+			SourceNumber:      output.SourceNumber,
+			OperationTypeId:   opTypeMap[output.WarehouseID].Id,
+			OperationTypeName: opTypeMap[output.WarehouseID].Name,
+			Status:            constvar.OperationStatus_Ready,
+			OperationDate:     time.Now().Format("2006-01-02 15:04:05"),
+			ContacterID:       0,
+			ContacterName:     "",
+			CompanyID:         0,
+			CompanyName:       "",
+			Comment:           "crm鍙戣揣鐢宠",
+			LogisticCompanyId: "",
+			LogisticCompany:   models.LogisticCompany{},
+			WaybillNumber:     "",
+			Weight:            decimal.Decimal{},
+			LogisticWeight:    decimal.Decimal{},
+			Source:            "crm",
+			Details:           details,
+			BaseOperationType: constvar.BaseOperationTypeOutgoing,
+			LocationID:        output.LocationID,
+		}
+		operations = append(operations, operation)
+	}
+
+	return models.NewOperationSearch().CreateBatch(operations)
+}

--
Gitblit v1.8.0