From 1ae2ab7b60ef374c77eebc08d63759a98f625066 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 15 三月 2024 10:10:43 +0800
Subject: [PATCH] crm查询采购信息
---
proto/crm_srm/crm_srm.pb.go | 300 +++++++++++++++++++++++++++++++++++++
proto/crm_srm/server.go | 45 +++++
proto/crm_srm/crm_srm_grpc.pb.go | 101 ++++++++++++
main.go | 2
proto/purchase_wms/server.go | 3
proto/crm_srm.proto | 21 ++
6 files changed, 472 insertions(+), 0 deletions(-)
diff --git a/main.go b/main.go
index 2b4c8d8..2c657ed 100644
--- a/main.go
+++ b/main.go
@@ -6,6 +6,7 @@
"google.golang.org/grpc"
"net"
"srm/api/v1/test"
+ "srm/proto/crm_srm"
"srm/proto/purchase_wms"
"srm/proto/qualityinspect"
"srm/proto/supplier"
@@ -50,6 +51,7 @@
//todo 娣诲姞鍏蜂綋鏈嶅姟
purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.Server{})
supplier.RegisterSupplierServiceServer(s, &supplier.Server{})
+ crm_srm.RegisterCrmAndSrmServiceServer(s, &crm_srm.Server{})
err = s.Serve(ln)
if err != nil {
global.GVA_LOG.Error("grpc server init error: %v", zap.Error(err))
diff --git a/proto/crm_srm.proto b/proto/crm_srm.proto
new file mode 100644
index 0000000..be954c9
--- /dev/null
+++ b/proto/crm_srm.proto
@@ -0,0 +1,21 @@
+syntax = "proto3";
+
+option go_package = "./crm_srm";
+
+service CrmAndSrmService {
+ rpc CrmGetPurchaseInfo(CrmGetPurchaseInfoRequest) returns(CrmGetPurchaseInfoResponse) {}
+}
+
+message CrmGetPurchaseInfoRequest{
+ string SalesDetailsNumber = 1;
+}
+
+message CrmGetPurchaseInfo {
+ int64 Amount = 1;
+ int64 FinishAmount = 2;
+ string ProductId = 3;
+}
+
+message CrmGetPurchaseInfoResponse{
+ repeated CrmGetPurchaseInfo Info = 1;
+}
\ No newline at end of file
diff --git a/proto/crm_srm/crm_srm.pb.go b/proto/crm_srm/crm_srm.pb.go
new file mode 100644
index 0000000..ec0f7e6
--- /dev/null
+++ b/proto/crm_srm/crm_srm.pb.go
@@ -0,0 +1,300 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.26.0
+// protoc v4.24.0
+// source: crm_srm.proto
+
+package crm_srm
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type CrmGetPurchaseInfoRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ SalesDetailsNumber string `protobuf:"bytes,1,opt,name=SalesDetailsNumber,proto3" json:"SalesDetailsNumber,omitempty"`
+}
+
+func (x *CrmGetPurchaseInfoRequest) Reset() {
+ *x = CrmGetPurchaseInfoRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_crm_srm_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *CrmGetPurchaseInfoRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CrmGetPurchaseInfoRequest) ProtoMessage() {}
+
+func (x *CrmGetPurchaseInfoRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_crm_srm_proto_msgTypes[0]
+ 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 CrmGetPurchaseInfoRequest.ProtoReflect.Descriptor instead.
+func (*CrmGetPurchaseInfoRequest) Descriptor() ([]byte, []int) {
+ return file_crm_srm_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *CrmGetPurchaseInfoRequest) GetSalesDetailsNumber() string {
+ if x != nil {
+ return x.SalesDetailsNumber
+ }
+ return ""
+}
+
+type CrmGetPurchaseInfo struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Amount int64 `protobuf:"varint,1,opt,name=Amount,proto3" json:"Amount,omitempty"`
+ FinishAmount int64 `protobuf:"varint,2,opt,name=FinishAmount,proto3" json:"FinishAmount,omitempty"`
+ ProductId string `protobuf:"bytes,3,opt,name=ProductId,proto3" json:"ProductId,omitempty"`
+}
+
+func (x *CrmGetPurchaseInfo) Reset() {
+ *x = CrmGetPurchaseInfo{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_crm_srm_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *CrmGetPurchaseInfo) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CrmGetPurchaseInfo) ProtoMessage() {}
+
+func (x *CrmGetPurchaseInfo) ProtoReflect() protoreflect.Message {
+ mi := &file_crm_srm_proto_msgTypes[1]
+ 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 CrmGetPurchaseInfo.ProtoReflect.Descriptor instead.
+func (*CrmGetPurchaseInfo) Descriptor() ([]byte, []int) {
+ return file_crm_srm_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *CrmGetPurchaseInfo) GetAmount() int64 {
+ if x != nil {
+ return x.Amount
+ }
+ return 0
+}
+
+func (x *CrmGetPurchaseInfo) GetFinishAmount() int64 {
+ if x != nil {
+ return x.FinishAmount
+ }
+ return 0
+}
+
+func (x *CrmGetPurchaseInfo) GetProductId() string {
+ if x != nil {
+ return x.ProductId
+ }
+ return ""
+}
+
+type CrmGetPurchaseInfoResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Info []*CrmGetPurchaseInfo `protobuf:"bytes,1,rep,name=Info,proto3" json:"Info,omitempty"`
+}
+
+func (x *CrmGetPurchaseInfoResponse) Reset() {
+ *x = CrmGetPurchaseInfoResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_crm_srm_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *CrmGetPurchaseInfoResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CrmGetPurchaseInfoResponse) ProtoMessage() {}
+
+func (x *CrmGetPurchaseInfoResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_crm_srm_proto_msgTypes[2]
+ 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 CrmGetPurchaseInfoResponse.ProtoReflect.Descriptor instead.
+func (*CrmGetPurchaseInfoResponse) Descriptor() ([]byte, []int) {
+ return file_crm_srm_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *CrmGetPurchaseInfoResponse) GetInfo() []*CrmGetPurchaseInfo {
+ if x != nil {
+ return x.Info
+ }
+ return nil
+}
+
+var File_crm_srm_proto protoreflect.FileDescriptor
+
+var file_crm_srm_proto_rawDesc = []byte{
+ 0x0a, 0x0d, 0x63, 0x72, 0x6d, 0x5f, 0x73, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
+ 0x4b, 0x0a, 0x19, 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73,
+ 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x12,
+ 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4e, 0x75, 0x6d, 0x62,
+ 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44,
+ 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x6e, 0x0a, 0x12,
+ 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e,
+ 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x46, 0x69,
+ 0x6e, 0x69, 0x73, 0x68, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
+ 0x52, 0x0c, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c,
+ 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x1a,
+ 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e,
+ 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x04, 0x49, 0x6e,
+ 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x43, 0x72, 0x6d, 0x47, 0x65,
+ 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49,
+ 0x6e, 0x66, 0x6f, 0x32, 0x63, 0x0a, 0x10, 0x43, 0x72, 0x6d, 0x41, 0x6e, 0x64, 0x53, 0x72, 0x6d,
+ 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, 0x12, 0x43, 0x72, 0x6d, 0x47, 0x65,
+ 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x2e,
+ 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e,
+ 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x43, 0x72, 0x6d, 0x47,
+ 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
+ 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x63, 0x72,
+ 0x6d, 0x5f, 0x73, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_crm_srm_proto_rawDescOnce sync.Once
+ file_crm_srm_proto_rawDescData = file_crm_srm_proto_rawDesc
+)
+
+func file_crm_srm_proto_rawDescGZIP() []byte {
+ file_crm_srm_proto_rawDescOnce.Do(func() {
+ file_crm_srm_proto_rawDescData = protoimpl.X.CompressGZIP(file_crm_srm_proto_rawDescData)
+ })
+ return file_crm_srm_proto_rawDescData
+}
+
+var file_crm_srm_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
+var file_crm_srm_proto_goTypes = []interface{}{
+ (*CrmGetPurchaseInfoRequest)(nil), // 0: CrmGetPurchaseInfoRequest
+ (*CrmGetPurchaseInfo)(nil), // 1: CrmGetPurchaseInfo
+ (*CrmGetPurchaseInfoResponse)(nil), // 2: CrmGetPurchaseInfoResponse
+}
+var file_crm_srm_proto_depIdxs = []int32{
+ 1, // 0: CrmGetPurchaseInfoResponse.Info:type_name -> CrmGetPurchaseInfo
+ 0, // 1: CrmAndSrmService.CrmGetPurchaseInfo:input_type -> CrmGetPurchaseInfoRequest
+ 2, // 2: CrmAndSrmService.CrmGetPurchaseInfo:output_type -> CrmGetPurchaseInfoResponse
+ 2, // [2:3] is the sub-list for method output_type
+ 1, // [1:2] is the sub-list for method input_type
+ 1, // [1:1] is the sub-list for extension type_name
+ 1, // [1:1] is the sub-list for extension extendee
+ 0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_crm_srm_proto_init() }
+func file_crm_srm_proto_init() {
+ if File_crm_srm_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_crm_srm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*CrmGetPurchaseInfoRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_crm_srm_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*CrmGetPurchaseInfo); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_crm_srm_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*CrmGetPurchaseInfoResponse); 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{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_crm_srm_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 3,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_crm_srm_proto_goTypes,
+ DependencyIndexes: file_crm_srm_proto_depIdxs,
+ MessageInfos: file_crm_srm_proto_msgTypes,
+ }.Build()
+ File_crm_srm_proto = out.File
+ file_crm_srm_proto_rawDesc = nil
+ file_crm_srm_proto_goTypes = nil
+ file_crm_srm_proto_depIdxs = nil
+}
diff --git a/proto/crm_srm/crm_srm_grpc.pb.go b/proto/crm_srm/crm_srm_grpc.pb.go
new file mode 100644
index 0000000..6ed2547
--- /dev/null
+++ b/proto/crm_srm/crm_srm_grpc.pb.go
@@ -0,0 +1,101 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+
+package crm_srm
+
+import (
+ context "context"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+const _ = grpc.SupportPackageIsVersion7
+
+// CrmAndSrmServiceClient is the client API for CrmAndSrmService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type CrmAndSrmServiceClient interface {
+ CrmGetPurchaseInfo(ctx context.Context, in *CrmGetPurchaseInfoRequest, opts ...grpc.CallOption) (*CrmGetPurchaseInfoResponse, error)
+}
+
+type crmAndSrmServiceClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewCrmAndSrmServiceClient(cc grpc.ClientConnInterface) CrmAndSrmServiceClient {
+ return &crmAndSrmServiceClient{cc}
+}
+
+func (c *crmAndSrmServiceClient) CrmGetPurchaseInfo(ctx context.Context, in *CrmGetPurchaseInfoRequest, opts ...grpc.CallOption) (*CrmGetPurchaseInfoResponse, error) {
+ out := new(CrmGetPurchaseInfoResponse)
+ err := c.cc.Invoke(ctx, "/CrmAndSrmService/CrmGetPurchaseInfo", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// CrmAndSrmServiceServer is the server API for CrmAndSrmService service.
+// All implementations must embed UnimplementedCrmAndSrmServiceServer
+// for forward compatibility
+type CrmAndSrmServiceServer interface {
+ CrmGetPurchaseInfo(context.Context, *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error)
+ mustEmbedUnimplementedCrmAndSrmServiceServer()
+}
+
+// UnimplementedCrmAndSrmServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedCrmAndSrmServiceServer struct {
+}
+
+func (UnimplementedCrmAndSrmServiceServer) CrmGetPurchaseInfo(context.Context, *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method CrmGetPurchaseInfo not implemented")
+}
+func (UnimplementedCrmAndSrmServiceServer) mustEmbedUnimplementedCrmAndSrmServiceServer() {}
+
+// UnsafeCrmAndSrmServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to CrmAndSrmServiceServer will
+// result in compilation errors.
+type UnsafeCrmAndSrmServiceServer interface {
+ mustEmbedUnimplementedCrmAndSrmServiceServer()
+}
+
+func RegisterCrmAndSrmServiceServer(s grpc.ServiceRegistrar, srv CrmAndSrmServiceServer) {
+ s.RegisterService(&CrmAndSrmService_ServiceDesc, srv)
+}
+
+func _CrmAndSrmService_CrmGetPurchaseInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(CrmGetPurchaseInfoRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(CrmAndSrmServiceServer).CrmGetPurchaseInfo(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/CrmAndSrmService/CrmGetPurchaseInfo",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(CrmAndSrmServiceServer).CrmGetPurchaseInfo(ctx, req.(*CrmGetPurchaseInfoRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// CrmAndSrmService_ServiceDesc is the grpc.ServiceDesc for CrmAndSrmService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var CrmAndSrmService_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "CrmAndSrmService",
+ HandlerType: (*CrmAndSrmServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "CrmGetPurchaseInfo",
+ Handler: _CrmAndSrmService_CrmGetPurchaseInfo_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "crm_srm.proto",
+}
diff --git a/proto/crm_srm/server.go b/proto/crm_srm/server.go
new file mode 100644
index 0000000..8909db1
--- /dev/null
+++ b/proto/crm_srm/server.go
@@ -0,0 +1,45 @@
+package crm_srm
+
+import (
+ "context"
+ "errors"
+ "srm/global"
+ "srm/model/purchase"
+)
+
+type Server struct {
+ UnimplementedCrmAndSrmServiceServer
+}
+
+func (s *Server) CrmGetPurchaseInfo(ctx context.Context, req *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error) {
+ if req.SalesDetailsNumber == "" {
+ return nil, errors.New("閲囪喘鍗曠紪鐮佷笉鑳戒负绌�")
+ }
+ var ps purchase.Purchase
+ err := global.GVA_DB.Model(&purchase.Purchase{}).Where("source_order = ?", req.SalesDetailsNumber).Preload("Supplier").First(&ps).Error
+ if err != nil {
+ return nil, err
+ }
+ pps := make([]*purchase.PurchaseProducts, 0)
+ err = global.GVA_DB.Model(&purchase.PurchaseProducts{}).Where("purchase_id = ?", ps.ID).Preload("Product").Find(&pps).Error
+ if err != nil {
+ return nil, err
+ }
+ info := make([]*CrmGetPurchaseInfo, 0)
+ flag := false
+ if ps.Status == purchase.OrderStatusStored || ps.Status == purchase.OrderStatusCompleted {
+ flag = true
+ }
+ for _, pp := range pps {
+ var cgpi CrmGetPurchaseInfo
+ cgpi.ProductId = pp.Product.Number
+ cgpi.Amount = pp.Amount.IntPart()
+ if flag {
+ cgpi.FinishAmount = cgpi.Amount
+ }
+ info = append(info, &cgpi)
+ }
+ resp := new(CrmGetPurchaseInfoResponse)
+ resp.Info = info
+ return resp, nil
+}
diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go
index e8ee1a4..f7339e7 100644
--- a/proto/purchase_wms/server.go
+++ b/proto/purchase_wms/server.go
@@ -159,6 +159,9 @@
info.SupplierName = p.Supplier.Name
info.Amount = p.Quantity.IntPart()
info.Status = int64(p.Status)
+ if p.Status == purchase.OrderStatusStored || p.Status == purchase.OrderStatusCompleted {
+ info.FinishAmount = info.Amount
+ }
for _, pp := range pps {
if int(p.ID) == pp.PurchaseId {
info.ProductId = pp.Product.Number
--
Gitblit v1.8.0