From b97b5cb90094f17f68560331724a120008864c68 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期四, 23 十一月 2023 10:44:42 +0800
Subject: [PATCH] aps获取销售明细列表

---
 conf/aps-crm.json                |    4 
 proto/crm_aps/server.go          |  100 +++++++
 model/salesDetails.go            |   51 ++-
 api/v1/salesDetails.go           |    6 
 proto/crm_aps.proto              |   41 ++
 proto/crm_aps/crm_aps_grpc.pb.go |   72 +++++
 proto/crm_aps/crm_aps.pb.go      |  505 +++++++++++++++++++++++++++++++++--
 main.go                          |    2 
 docs/docs.go                     |    2 
 9 files changed, 726 insertions(+), 57 deletions(-)

diff --git a/api/v1/salesDetails.go b/api/v1/salesDetails.go
index 0aea8f1..625e2b6 100644
--- a/api/v1/salesDetails.go
+++ b/api/v1/salesDetails.go
@@ -170,7 +170,11 @@
 	salesDetailsModel.DeliverType = salesDetails.DeliverType
 	salesDetailsModel.QuotationId = salesDetails.QuotationId
 	salesDetailsModel.Status = salesDetails.Status
-	salesDetailsModel.Source = salesDetails.Source
+	if salesDetails.Source == "" {
+		salesDetailsModel.Source = "CRM鑷缓"
+	} else {
+		salesDetailsModel.Source = salesDetails.Source
+	}
 	salesDetailsModel.ProjectId = salesDetails.ProjectId
 
 	return ecode.OK, salesDetailsModel
diff --git a/conf/aps-crm.json b/conf/aps-crm.json
index 7ad9ce1..0269872 100644
--- a/conf/aps-crm.json
+++ b/conf/aps-crm.json
@@ -49,9 +49,9 @@
     "Issuer": "qmPlus"
   },
   "GrpcServiceAddr": {
-    "Aps": "192.168.20.118:9091",
+    "Aps": "192.168.20.119:9091",
     "Admin": "192.168.20.119:50051",
-    "WMS": "192.168.20.118:8006"
+    "WMS": "192.168.20.119:8006"
   }
 }
 
diff --git a/docs/docs.go b/docs/docs.go
index d83cda9..d489003 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -19659,6 +19659,8 @@
 	Description:      "",
 	InfoInstanceName: "swagger",
 	SwaggerTemplate:  docTemplate,
+	LeftDelim:        "{{",
+	RightDelim:       "}}",
 }
 
 func init() {
diff --git a/main.go b/main.go
index d233483..62c3d20 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@
 	"aps_crm/model"
 	"aps_crm/model/grpc_init"
 	"aps_crm/pkg/logx"
+	"aps_crm/proto/crm_aps"
 	"aps_crm/proto/product_inventory"
 	"aps_crm/router"
 	"fmt"
@@ -63,6 +64,7 @@
 		s := grpc.NewServer()
 		//todo 娣诲姞鍏蜂綋鏈嶅姟
 		product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{})
+		crm_aps.RegisterCrmAndApsGrpcServiceServer(s, &crm_aps.Server{})
 		err = s.Serve(ln)
 		if err != nil {
 			logx.Errorf("grpc server init error: %v", err.Error())
diff --git a/model/salesDetails.go b/model/salesDetails.go
index 5ae20b0..0d92c39 100644
--- a/model/salesDetails.go
+++ b/model/salesDetails.go
@@ -59,6 +59,7 @@
 		PageSize    int
 		Preload     bool
 		MemberIds   []int
+		Numbers     []string
 	}
 )
 
@@ -87,6 +88,9 @@
 	}
 	if slf.Number != "" {
 		db = db.Where("number = ?", slf.Number)
+	}
+	if len(slf.Numbers) > 0 {
+		db = db.Where("number in (?)", slf.Numbers)
 	}
 
 	switch slf.KeywordType {
@@ -164,21 +168,6 @@
 	return result.Max, nil
 }
 
-func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch {
-	slf.Id = id
-	return slf
-}
-
-func (slf *SalesDetailsSearch) SetClientId(clientId int) *SalesDetailsSearch {
-	slf.ClientId = clientId
-	return slf
-}
-
-func (slf *SalesDetailsSearch) SetSaleChanceId(saleChanceId int) *SalesDetailsSearch {
-	slf.SaleChanceId = saleChanceId
-	return slf
-}
-
 func (slf *SalesDetailsSearch) First() (*SalesDetails, error) {
 	var db = slf.build()
 	var record = new(SalesDetails)
@@ -197,12 +186,31 @@
 		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
 	}
 
-	if slf.PageNum > 0 && slf.PageSize > 0 {
-		db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
-	}
-
 	err := db.Order("id desc").Find(&records).Error
 	return records, total, err
+}
+
+func (slf *SalesDetailsSearch) FindNotTotal() ([]*SalesDetails, error) {
+	var db = slf.build()
+	var records = make([]*SalesDetails, 0)
+
+	err := db.Order("id desc").Find(&records).Error
+	return records, err
+}
+
+func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *SalesDetailsSearch) SetClientId(clientId int) *SalesDetailsSearch {
+	slf.ClientId = clientId
+	return slf
+}
+
+func (slf *SalesDetailsSearch) SetSaleChanceId(saleChanceId int) *SalesDetailsSearch {
+	slf.SaleChanceId = saleChanceId
+	return slf
 }
 
 func (slf *SalesDetailsSearch) SetKeyword(keyword string) *SalesDetailsSearch {
@@ -240,6 +248,11 @@
 	return slf
 }
 
+func (slf *SalesDetailsSearch) SetNumbers(numbers []string) *SalesDetailsSearch {
+	slf.Numbers = numbers
+	return slf
+}
+
 func (slf *SalesDetailsSearch) UpdateByMap(upMap map[string]interface{}) error {
 	var (
 		db = slf.build()
diff --git a/proto/crm_aps.proto b/proto/crm_aps.proto
index 17577db..f740c1c 100644
--- a/proto/crm_aps.proto
+++ b/proto/crm_aps.proto
@@ -5,6 +5,8 @@
 service CrmAndApsGrpcService {
   rpc GetApsProjectList(GetApsProjectListRequest) returns(GetApsProjectListResponse) {}
   rpc SendSalesDetailsToApsProject(SendSalesDetailsToApsProjectRequest) returns(SendSalesDetailsToApsProjectResponse) {}
+  rpc GetCrmSalesDetailsList(GetCrmSalesDetailsListRequest) returns(GetCrmSalesDetailsListResponse) {}
+  rpc SendSalesDetailsAndProjectToCrm(SendSalesDetailsAndProjectToCrmRequest) returns(SendSalesDetailsAndProjectToCrmResponse) {}
 }
 
 //-----------------------------------------------------GetApsProjectList--------------------------------------
@@ -41,4 +43,41 @@
 }
 
 message SendSalesDetailsToApsProjectResponse{
-}
\ No newline at end of file
+}
+
+//-----------------------------------------------------GetCrmSalesDetailsList--------------------------------------------
+
+message GetCrmSalesDetailsListRequest {
+  string TimeType = 1;  //鏃堕棿绫诲瀷:绛剧害鏃ユ湡,浜や粯鏃ユ湡
+  string StartTime = 2;
+  string EndTime = 3;
+  string ClientName = 4;
+  int64 Page = 5;
+  int64 PageSize = 6;
+}
+
+message CrmSalesDetails {
+  string number = 1;//閿�鍞槑缁嗗崟鍙�
+  string clientName = 2;
+  string memberName = 3;//閿�鍞礋璐d汉
+  string signTime = 4;//绛惧崟鏃堕棿
+  string deliveryDate = 5;//浜よ揣鏃ユ湡
+}
+
+message GetCrmSalesDetailsListResponse {
+  repeated CrmSalesDetails SalesDetails = 1;
+  int64 Total = 2;
+}
+
+//------------------------------------------------------------SendSalesDetailsAndProjectToCrm-----------------------------------
+
+message SendSalesDetailsAndProjectToCrmRequest{
+  repeated string SalesDetailsNumbers = 1;
+  string ProjectId = 2;
+}
+
+message SendSalesDetailsAndProjectToCrmResponse{
+
+}
+
+
diff --git a/proto/crm_aps/crm_aps.pb.go b/proto/crm_aps/crm_aps.pb.go
index 02b3c6e..dd584ea 100644
--- a/proto/crm_aps/crm_aps.pb.go
+++ b/proto/crm_aps/crm_aps.pb.go
@@ -364,6 +364,320 @@
 	return file_crm_aps_proto_rawDescGZIP(), []int{5}
 }
 
+type GetCrmSalesDetailsListRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	TimeType   string `protobuf:"bytes,1,opt,name=TimeType,proto3" json:"TimeType,omitempty"` //鏃堕棿绫诲瀷:绛剧害鏃ユ湡,浜や粯鏃ユ湡
+	StartTime  string `protobuf:"bytes,2,opt,name=StartTime,proto3" json:"StartTime,omitempty"`
+	EndTime    string `protobuf:"bytes,3,opt,name=EndTime,proto3" json:"EndTime,omitempty"`
+	ClientName string `protobuf:"bytes,4,opt,name=ClientName,proto3" json:"ClientName,omitempty"`
+	Page       int64  `protobuf:"varint,5,opt,name=Page,proto3" json:"Page,omitempty"`
+	PageSize   int64  `protobuf:"varint,6,opt,name=PageSize,proto3" json:"PageSize,omitempty"`
+}
+
+func (x *GetCrmSalesDetailsListRequest) Reset() {
+	*x = GetCrmSalesDetailsListRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_crm_aps_proto_msgTypes[6]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *GetCrmSalesDetailsListRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetCrmSalesDetailsListRequest) ProtoMessage() {}
+
+func (x *GetCrmSalesDetailsListRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_crm_aps_proto_msgTypes[6]
+	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 GetCrmSalesDetailsListRequest.ProtoReflect.Descriptor instead.
+func (*GetCrmSalesDetailsListRequest) Descriptor() ([]byte, []int) {
+	return file_crm_aps_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetTimeType() string {
+	if x != nil {
+		return x.TimeType
+	}
+	return ""
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetStartTime() string {
+	if x != nil {
+		return x.StartTime
+	}
+	return ""
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetEndTime() string {
+	if x != nil {
+		return x.EndTime
+	}
+	return ""
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetClientName() string {
+	if x != nil {
+		return x.ClientName
+	}
+	return ""
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetPage() int64 {
+	if x != nil {
+		return x.Page
+	}
+	return 0
+}
+
+func (x *GetCrmSalesDetailsListRequest) GetPageSize() int64 {
+	if x != nil {
+		return x.PageSize
+	}
+	return 0
+}
+
+type CrmSalesDetails struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Number       string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` //閿�鍞槑缁嗗崟鍙�
+	ClientName   string `protobuf:"bytes,2,opt,name=clientName,proto3" json:"clientName,omitempty"`
+	MemberName   string `protobuf:"bytes,3,opt,name=memberName,proto3" json:"memberName,omitempty"`     //閿�鍞礋璐d汉
+	SignTime     string `protobuf:"bytes,4,opt,name=signTime,proto3" json:"signTime,omitempty"`         //绛惧崟鏃堕棿
+	DeliveryDate string `protobuf:"bytes,5,opt,name=deliveryDate,proto3" json:"deliveryDate,omitempty"` //浜よ揣鏃ユ湡
+}
+
+func (x *CrmSalesDetails) Reset() {
+	*x = CrmSalesDetails{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_crm_aps_proto_msgTypes[7]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CrmSalesDetails) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CrmSalesDetails) ProtoMessage() {}
+
+func (x *CrmSalesDetails) ProtoReflect() protoreflect.Message {
+	mi := &file_crm_aps_proto_msgTypes[7]
+	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 CrmSalesDetails.ProtoReflect.Descriptor instead.
+func (*CrmSalesDetails) Descriptor() ([]byte, []int) {
+	return file_crm_aps_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *CrmSalesDetails) GetNumber() string {
+	if x != nil {
+		return x.Number
+	}
+	return ""
+}
+
+func (x *CrmSalesDetails) GetClientName() string {
+	if x != nil {
+		return x.ClientName
+	}
+	return ""
+}
+
+func (x *CrmSalesDetails) GetMemberName() string {
+	if x != nil {
+		return x.MemberName
+	}
+	return ""
+}
+
+func (x *CrmSalesDetails) GetSignTime() string {
+	if x != nil {
+		return x.SignTime
+	}
+	return ""
+}
+
+func (x *CrmSalesDetails) GetDeliveryDate() string {
+	if x != nil {
+		return x.DeliveryDate
+	}
+	return ""
+}
+
+type GetCrmSalesDetailsListResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	SalesDetails []*CrmSalesDetails `protobuf:"bytes,1,rep,name=SalesDetails,proto3" json:"SalesDetails,omitempty"`
+	Total        int64              `protobuf:"varint,2,opt,name=Total,proto3" json:"Total,omitempty"`
+}
+
+func (x *GetCrmSalesDetailsListResponse) Reset() {
+	*x = GetCrmSalesDetailsListResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_crm_aps_proto_msgTypes[8]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *GetCrmSalesDetailsListResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetCrmSalesDetailsListResponse) ProtoMessage() {}
+
+func (x *GetCrmSalesDetailsListResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_crm_aps_proto_msgTypes[8]
+	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 GetCrmSalesDetailsListResponse.ProtoReflect.Descriptor instead.
+func (*GetCrmSalesDetailsListResponse) Descriptor() ([]byte, []int) {
+	return file_crm_aps_proto_rawDescGZIP(), []int{8}
+}
+
+func (x *GetCrmSalesDetailsListResponse) GetSalesDetails() []*CrmSalesDetails {
+	if x != nil {
+		return x.SalesDetails
+	}
+	return nil
+}
+
+func (x *GetCrmSalesDetailsListResponse) GetTotal() int64 {
+	if x != nil {
+		return x.Total
+	}
+	return 0
+}
+
+type SendSalesDetailsAndProjectToCrmRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	SalesDetailsNumbers []string `protobuf:"bytes,1,rep,name=SalesDetailsNumbers,proto3" json:"SalesDetailsNumbers,omitempty"`
+	ProjectId           string   `protobuf:"bytes,2,opt,name=ProjectId,proto3" json:"ProjectId,omitempty"`
+}
+
+func (x *SendSalesDetailsAndProjectToCrmRequest) Reset() {
+	*x = SendSalesDetailsAndProjectToCrmRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_crm_aps_proto_msgTypes[9]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *SendSalesDetailsAndProjectToCrmRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SendSalesDetailsAndProjectToCrmRequest) ProtoMessage() {}
+
+func (x *SendSalesDetailsAndProjectToCrmRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_crm_aps_proto_msgTypes[9]
+	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 SendSalesDetailsAndProjectToCrmRequest.ProtoReflect.Descriptor instead.
+func (*SendSalesDetailsAndProjectToCrmRequest) Descriptor() ([]byte, []int) {
+	return file_crm_aps_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *SendSalesDetailsAndProjectToCrmRequest) GetSalesDetailsNumbers() []string {
+	if x != nil {
+		return x.SalesDetailsNumbers
+	}
+	return nil
+}
+
+func (x *SendSalesDetailsAndProjectToCrmRequest) GetProjectId() string {
+	if x != nil {
+		return x.ProjectId
+	}
+	return ""
+}
+
+type SendSalesDetailsAndProjectToCrmResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *SendSalesDetailsAndProjectToCrmResponse) Reset() {
+	*x = SendSalesDetailsAndProjectToCrmResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_crm_aps_proto_msgTypes[10]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *SendSalesDetailsAndProjectToCrmResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SendSalesDetailsAndProjectToCrmResponse) ProtoMessage() {}
+
+func (x *SendSalesDetailsAndProjectToCrmResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_crm_aps_proto_msgTypes[10]
+	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 SendSalesDetailsAndProjectToCrmResponse.ProtoReflect.Descriptor instead.
+func (*SendSalesDetailsAndProjectToCrmResponse) Descriptor() ([]byte, []int) {
+	return file_crm_aps_proto_rawDescGZIP(), []int{10}
+}
+
 var File_crm_aps_proto protoreflect.FileDescriptor
 
 var file_crm_aps_proto_rawDesc = []byte{
@@ -406,22 +720,75 @@
 	0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73,
 	0x22, 0x26, 0x0a, 0x24, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74,
 	0x61, 0x69, 0x6c, 0x73, 0x54, 0x6f, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
-	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd3, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x6d,
-	0x41, 0x6e, 0x64, 0x41, 0x70, 0x73, 0x47, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
-	0x65, 0x12, 0x4c, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65,
-	0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x70, 0x73, 0x50,
-	0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
-	0x74, 0x1a, 0x1a, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
-	0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
-	0x6d, 0x0a, 0x1c, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61,
-	0x69, 0x6c, 0x73, 0x54, 0x6f, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12,
-	0x24, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
-	0x6c, 0x73, 0x54, 0x6f, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65,
-	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65,
+	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc3, 0x01, 0x0a, 0x1d, 0x47, 0x65, 0x74,
+	0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4c,
+	0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x54, 0x69,
+	0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x54, 0x69,
+	0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54,
+	0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x74, 0x61, 0x72, 0x74,
+	0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18,
+	0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x45, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e,
+	0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12,
+	0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x50, 0x61,
+	0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x06,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0xa9,
+	0x01, 0x0a, 0x0f, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
+	0x6c, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c,
+	0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
+	0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x65,
+	0x6d, 0x62, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
+	0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x69,
+	0x67, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x69,
+	0x67, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x65, 0x6c, 0x69, 0x76, 0x65,
+	0x72, 0x79, 0x44, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65,
+	0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x44, 0x61, 0x74, 0x65, 0x22, 0x6c, 0x0a, 0x1e, 0x47, 0x65,
+	0x74, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73,
+	0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x0c,
+	0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03,
+	0x28, 0x0b, 0x32, 0x10, 0x2e, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74,
+	0x61, 0x69, 0x6c, 0x73, 0x52, 0x0c, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
+	0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x22, 0x78, 0x0a, 0x26, 0x53, 0x65, 0x6e, 0x64,
+	0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x41, 0x6e, 0x64, 0x50,
+	0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x6f, 0x43, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65,
+	0x73, 0x74, 0x12, 0x30, 0x0a, 0x13, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
+	0x6c, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52,
+	0x13, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4e, 0x75, 0x6d,
+	0x62, 0x65, 0x72, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49,
+	0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
+	0x49, 0x64, 0x22, 0x29, 0x0a, 0x27, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44,
+	0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
+	0x54, 0x6f, 0x43, 0x72, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa8, 0x03,
+	0x0a, 0x14, 0x43, 0x72, 0x6d, 0x41, 0x6e, 0x64, 0x41, 0x70, 0x73, 0x47, 0x72, 0x70, 0x63, 0x53,
+	0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4c, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x41, 0x70, 0x73,
+	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x47, 0x65,
+	0x74, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52,
+	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x70, 0x73, 0x50,
+	0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x22, 0x00, 0x12, 0x6d, 0x0a, 0x1c, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65,
 	0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x54, 0x6f, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f,
-	0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b,
-	0x5a, 0x09, 0x2e, 0x2f, 0x63, 0x72, 0x6d, 0x5f, 0x61, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
-	0x74, 0x6f, 0x33,
+	0x6a, 0x65, 0x63, 0x74, 0x12, 0x24, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73,
+	0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x54, 0x6f, 0x41, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a,
+	0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x53, 0x65, 0x6e,
+	0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x54, 0x6f, 0x41,
+	0x70, 0x73, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
+	0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c,
+	0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1e, 0x2e,
+	0x47, 0x65, 0x74, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
+	0x6c, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e,
+	0x47, 0x65, 0x74, 0x43, 0x72, 0x6d, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
+	0x6c, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
+	0x12, 0x76, 0x0a, 0x1f, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74,
+	0x61, 0x69, 0x6c, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x6f,
+	0x43, 0x72, 0x6d, 0x12, 0x27, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44,
+	0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
+	0x54, 0x6f, 0x43, 0x72, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x53,
+	0x65, 0x6e, 0x64, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x41,
+	0x6e, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x6f, 0x43, 0x72, 0x6d, 0x52, 0x65,
+	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x63, 0x72,
+	0x6d, 0x5f, 0x61, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -436,27 +803,37 @@
 	return file_crm_aps_proto_rawDescData
 }
 
-var file_crm_aps_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
+var file_crm_aps_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
 var file_crm_aps_proto_goTypes = []interface{}{
-	(*GetApsProjectListRequest)(nil),             // 0: GetApsProjectListRequest
-	(*ApsProject)(nil),                           // 1: ApsProject
-	(*GetApsProjectListResponse)(nil),            // 2: GetApsProjectListResponse
-	(*SalesDetailsProduct)(nil),                  // 3: SalesDetailsProduct
-	(*SendSalesDetailsToApsProjectRequest)(nil),  // 4: SendSalesDetailsToApsProjectRequest
-	(*SendSalesDetailsToApsProjectResponse)(nil), // 5: SendSalesDetailsToApsProjectResponse
+	(*GetApsProjectListRequest)(nil),                // 0: GetApsProjectListRequest
+	(*ApsProject)(nil),                              // 1: ApsProject
+	(*GetApsProjectListResponse)(nil),               // 2: GetApsProjectListResponse
+	(*SalesDetailsProduct)(nil),                     // 3: SalesDetailsProduct
+	(*SendSalesDetailsToApsProjectRequest)(nil),     // 4: SendSalesDetailsToApsProjectRequest
+	(*SendSalesDetailsToApsProjectResponse)(nil),    // 5: SendSalesDetailsToApsProjectResponse
+	(*GetCrmSalesDetailsListRequest)(nil),           // 6: GetCrmSalesDetailsListRequest
+	(*CrmSalesDetails)(nil),                         // 7: CrmSalesDetails
+	(*GetCrmSalesDetailsListResponse)(nil),          // 8: GetCrmSalesDetailsListResponse
+	(*SendSalesDetailsAndProjectToCrmRequest)(nil),  // 9: SendSalesDetailsAndProjectToCrmRequest
+	(*SendSalesDetailsAndProjectToCrmResponse)(nil), // 10: SendSalesDetailsAndProjectToCrmResponse
 }
 var file_crm_aps_proto_depIdxs = []int32{
-	1, // 0: GetApsProjectListResponse.List:type_name -> ApsProject
-	3, // 1: SendSalesDetailsToApsProjectRequest.Products:type_name -> SalesDetailsProduct
-	0, // 2: CrmAndApsGrpcService.GetApsProjectList:input_type -> GetApsProjectListRequest
-	4, // 3: CrmAndApsGrpcService.SendSalesDetailsToApsProject:input_type -> SendSalesDetailsToApsProjectRequest
-	2, // 4: CrmAndApsGrpcService.GetApsProjectList:output_type -> GetApsProjectListResponse
-	5, // 5: CrmAndApsGrpcService.SendSalesDetailsToApsProject:output_type -> SendSalesDetailsToApsProjectResponse
-	4, // [4:6] is the sub-list for method output_type
-	2, // [2:4] is the sub-list for method input_type
-	2, // [2:2] is the sub-list for extension type_name
-	2, // [2:2] is the sub-list for extension extendee
-	0, // [0:2] is the sub-list for field type_name
+	1,  // 0: GetApsProjectListResponse.List:type_name -> ApsProject
+	3,  // 1: SendSalesDetailsToApsProjectRequest.Products:type_name -> SalesDetailsProduct
+	7,  // 2: GetCrmSalesDetailsListResponse.SalesDetails:type_name -> CrmSalesDetails
+	0,  // 3: CrmAndApsGrpcService.GetApsProjectList:input_type -> GetApsProjectListRequest
+	4,  // 4: CrmAndApsGrpcService.SendSalesDetailsToApsProject:input_type -> SendSalesDetailsToApsProjectRequest
+	6,  // 5: CrmAndApsGrpcService.GetCrmSalesDetailsList:input_type -> GetCrmSalesDetailsListRequest
+	9,  // 6: CrmAndApsGrpcService.SendSalesDetailsAndProjectToCrm:input_type -> SendSalesDetailsAndProjectToCrmRequest
+	2,  // 7: CrmAndApsGrpcService.GetApsProjectList:output_type -> GetApsProjectListResponse
+	5,  // 8: CrmAndApsGrpcService.SendSalesDetailsToApsProject:output_type -> SendSalesDetailsToApsProjectResponse
+	8,  // 9: CrmAndApsGrpcService.GetCrmSalesDetailsList:output_type -> GetCrmSalesDetailsListResponse
+	10, // 10: CrmAndApsGrpcService.SendSalesDetailsAndProjectToCrm:output_type -> SendSalesDetailsAndProjectToCrmResponse
+	7,  // [7:11] is the sub-list for method output_type
+	3,  // [3:7] is the sub-list for method input_type
+	3,  // [3:3] is the sub-list for extension type_name
+	3,  // [3:3] is the sub-list for extension extendee
+	0,  // [0:3] is the sub-list for field type_name
 }
 
 func init() { file_crm_aps_proto_init() }
@@ -537,6 +914,66 @@
 				return nil
 			}
 		}
+		file_crm_aps_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*GetCrmSalesDetailsListRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_crm_aps_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CrmSalesDetails); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_crm_aps_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*GetCrmSalesDetailsListResponse); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_crm_aps_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*SendSalesDetailsAndProjectToCrmRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_crm_aps_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*SendSalesDetailsAndProjectToCrmResponse); 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{
@@ -544,7 +981,7 @@
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_crm_aps_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   6,
+			NumMessages:   11,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
diff --git a/proto/crm_aps/crm_aps_grpc.pb.go b/proto/crm_aps/crm_aps_grpc.pb.go
index 2c32de6..b5e0c95 100644
--- a/proto/crm_aps/crm_aps_grpc.pb.go
+++ b/proto/crm_aps/crm_aps_grpc.pb.go
@@ -20,6 +20,8 @@
 type CrmAndApsGrpcServiceClient interface {
 	GetApsProjectList(ctx context.Context, in *GetApsProjectListRequest, opts ...grpc.CallOption) (*GetApsProjectListResponse, error)
 	SendSalesDetailsToApsProject(ctx context.Context, in *SendSalesDetailsToApsProjectRequest, opts ...grpc.CallOption) (*SendSalesDetailsToApsProjectResponse, error)
+	GetCrmSalesDetailsList(ctx context.Context, in *GetCrmSalesDetailsListRequest, opts ...grpc.CallOption) (*GetCrmSalesDetailsListResponse, error)
+	SendSalesDetailsAndProjectToCrm(ctx context.Context, in *SendSalesDetailsAndProjectToCrmRequest, opts ...grpc.CallOption) (*SendSalesDetailsAndProjectToCrmResponse, error)
 }
 
 type crmAndApsGrpcServiceClient struct {
@@ -48,12 +50,32 @@
 	return out, nil
 }
 
+func (c *crmAndApsGrpcServiceClient) GetCrmSalesDetailsList(ctx context.Context, in *GetCrmSalesDetailsListRequest, opts ...grpc.CallOption) (*GetCrmSalesDetailsListResponse, error) {
+	out := new(GetCrmSalesDetailsListResponse)
+	err := c.cc.Invoke(ctx, "/CrmAndApsGrpcService/GetCrmSalesDetailsList", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *crmAndApsGrpcServiceClient) SendSalesDetailsAndProjectToCrm(ctx context.Context, in *SendSalesDetailsAndProjectToCrmRequest, opts ...grpc.CallOption) (*SendSalesDetailsAndProjectToCrmResponse, error) {
+	out := new(SendSalesDetailsAndProjectToCrmResponse)
+	err := c.cc.Invoke(ctx, "/CrmAndApsGrpcService/SendSalesDetailsAndProjectToCrm", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // CrmAndApsGrpcServiceServer is the server API for CrmAndApsGrpcService service.
 // All implementations must embed UnimplementedCrmAndApsGrpcServiceServer
 // for forward compatibility
 type CrmAndApsGrpcServiceServer interface {
 	GetApsProjectList(context.Context, *GetApsProjectListRequest) (*GetApsProjectListResponse, error)
 	SendSalesDetailsToApsProject(context.Context, *SendSalesDetailsToApsProjectRequest) (*SendSalesDetailsToApsProjectResponse, error)
+	GetCrmSalesDetailsList(context.Context, *GetCrmSalesDetailsListRequest) (*GetCrmSalesDetailsListResponse, error)
+	SendSalesDetailsAndProjectToCrm(context.Context, *SendSalesDetailsAndProjectToCrmRequest) (*SendSalesDetailsAndProjectToCrmResponse, error)
 	mustEmbedUnimplementedCrmAndApsGrpcServiceServer()
 }
 
@@ -66,6 +88,12 @@
 }
 func (UnimplementedCrmAndApsGrpcServiceServer) SendSalesDetailsToApsProject(context.Context, *SendSalesDetailsToApsProjectRequest) (*SendSalesDetailsToApsProjectResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method SendSalesDetailsToApsProject not implemented")
+}
+func (UnimplementedCrmAndApsGrpcServiceServer) GetCrmSalesDetailsList(context.Context, *GetCrmSalesDetailsListRequest) (*GetCrmSalesDetailsListResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetCrmSalesDetailsList not implemented")
+}
+func (UnimplementedCrmAndApsGrpcServiceServer) SendSalesDetailsAndProjectToCrm(context.Context, *SendSalesDetailsAndProjectToCrmRequest) (*SendSalesDetailsAndProjectToCrmResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SendSalesDetailsAndProjectToCrm not implemented")
 }
 func (UnimplementedCrmAndApsGrpcServiceServer) mustEmbedUnimplementedCrmAndApsGrpcServiceServer() {}
 
@@ -116,6 +144,42 @@
 	return interceptor(ctx, in, info, handler)
 }
 
+func _CrmAndApsGrpcService_GetCrmSalesDetailsList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GetCrmSalesDetailsListRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(CrmAndApsGrpcServiceServer).GetCrmSalesDetailsList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/CrmAndApsGrpcService/GetCrmSalesDetailsList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(CrmAndApsGrpcServiceServer).GetCrmSalesDetailsList(ctx, req.(*GetCrmSalesDetailsListRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _CrmAndApsGrpcService_SendSalesDetailsAndProjectToCrm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(SendSalesDetailsAndProjectToCrmRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(CrmAndApsGrpcServiceServer).SendSalesDetailsAndProjectToCrm(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/CrmAndApsGrpcService/SendSalesDetailsAndProjectToCrm",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(CrmAndApsGrpcServiceServer).SendSalesDetailsAndProjectToCrm(ctx, req.(*SendSalesDetailsAndProjectToCrmRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // CrmAndApsGrpcService_ServiceDesc is the grpc.ServiceDesc for CrmAndApsGrpcService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -131,6 +195,14 @@
 			MethodName: "SendSalesDetailsToApsProject",
 			Handler:    _CrmAndApsGrpcService_SendSalesDetailsToApsProject_Handler,
 		},
+		{
+			MethodName: "GetCrmSalesDetailsList",
+			Handler:    _CrmAndApsGrpcService_GetCrmSalesDetailsList_Handler,
+		},
+		{
+			MethodName: "SendSalesDetailsAndProjectToCrm",
+			Handler:    _CrmAndApsGrpcService_SendSalesDetailsAndProjectToCrm_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "crm_aps.proto",
diff --git a/proto/crm_aps/server.go b/proto/crm_aps/server.go
new file mode 100644
index 0000000..fd51bc1
--- /dev/null
+++ b/proto/crm_aps/server.go
@@ -0,0 +1,100 @@
+package crm_aps
+
+import (
+	"aps_crm/constvar"
+	"aps_crm/model"
+	"aps_crm/model/grpc_init"
+	"context"
+	"github.com/shopspring/decimal"
+)
+
+type Server struct {
+	UnimplementedCrmAndApsGrpcServiceServer
+}
+
+func (s *Server) GetCrmSalesDetailsList(ctx context.Context, req *GetCrmSalesDetailsListRequest) (*GetCrmSalesDetailsListResponse, error) {
+	search := model.NewSalesDetailsSearch().Orm.Model(model.SalesDetails{})
+	if req.StartTime != "" && req.EndTime != "" {
+		if req.TimeType == "绛剧害鏃ユ湡" {
+			search = search.Where("sign_time between ? and ?", req.StartTime, req.EndTime)
+		} else if req.TimeType == "浜や粯鏃ユ湡" {
+			search = search.Where("delivery_date between ? and ?", req.StartTime, req.EndTime)
+		}
+	}
+	if req.ClientName != "" {
+		search = search.Joins("Client", "LEFT").Where("Client.name like ?", "%"+req.ClientName+"%")
+	}
+	search = search.Preload("Member").Preload("Client").Where("status = ?", constvar.WaitConfirmed).Where("project_id = ?", "")
+
+	var records = make([]*model.SalesDetails, 0)
+	var total int64
+	err := search.Count(&total).Error
+	if err != nil {
+		return nil, err
+	}
+	if req.Page*req.PageSize > 0 {
+		search = search.Limit(int(req.PageSize)).Offset(int((req.Page - 1) * req.PageSize))
+	}
+	err = search.Order("id desc").Find(&records).Error
+	if err != nil {
+		return nil, err
+	}
+	sds := make([]*CrmSalesDetails, 0)
+	for _, record := range records {
+		var sd CrmSalesDetails
+		sd.Number = record.Number
+		sd.ClientName = record.Client.Name
+		sd.MemberName = record.Member.Username
+		sd.SignTime = record.SignTime
+		sd.DeliveryDate = record.DeliveryDate
+		sds = append(sds, &sd)
+	}
+	resp := new(GetCrmSalesDetailsListResponse)
+	resp.SalesDetails = sds
+	resp.Total = total
+	return resp, nil
+}
+
+func (s *Server) SendSalesDetailsAndProjectToCrm(ctx context.Context, req *SendSalesDetailsAndProjectToCrmRequest) (*SendSalesDetailsAndProjectToCrmResponse, error) {
+	details, err := model.NewSalesDetailsSearch().SetNumbers(req.SalesDetailsNumbers).SetPreload(true).FindNotTotal()
+	if err != nil {
+		return nil, err
+	}
+	for _, detail := range details {
+		m := make(map[string]interface{})
+		m["status"] = constvar.WaitOutbound
+		m["project_id"] = req.ProjectId
+
+		err := model.NewSalesDetailsSearch().SetNumber(detail.Number).UpdateByMap(m)
+		if err != nil {
+			return nil, err
+		}
+
+		products := make([]*SalesDetailsProduct, 0)
+		var total decimal.Decimal
+		for _, product := range detail.Products {
+			var sp SalesDetailsProduct
+			sp.ProductId = product.Number
+			sp.Amount = product.Amount.IntPart()
+			products = append(products, &sp)
+			total = total.Add(product.Amount)
+		}
+
+		client := NewCrmAndApsGrpcServiceClient(grpc_init.CrmApsGrpcServiceConn)
+		_, err = client.SendSalesDetailsToApsProject(ctx, &SendSalesDetailsToApsProjectRequest{
+			Number:       detail.Number,
+			ClientName:   detail.Client.Name,
+			MemberName:   detail.Member.Username,
+			SignTime:     detail.SignTime,
+			DeliveryDate: detail.DeliveryDate,
+			Source:       detail.Source,
+			ProductTotal: total.IntPart(),
+			ProjectId:    req.ProjectId,
+			Products:     products,
+		})
+		if err != nil {
+			return nil, err
+		}
+	}
+	return new(SendSalesDetailsAndProjectToCrmResponse), nil
+}

--
Gitblit v1.8.0