From 4d0b38be2e3977ec390f70de2f022fe96c4cbb61 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 30 十月 2023 20:36:57 +0800
Subject: [PATCH] 数据权限支持职级

---
 api/v1/plan.go            |    5 
 api/v1/client.go          |    2 
 model/plan.go             |   19 +++-
 model/contract.go         |    4 +
 api/v1/contact.go         |    2 
 api/v1/contract.go        |    2 
 model/contact.go          |    4 +
 api/v1/quotation.go       |    2 
 api/v1/receipt.go         |    7 +
 model/masterOrder.go      |    4 +
 conf/aps-crm.json         |    4 
 model/serviceFeeManage.go |   11 ++
 api/v1/invoice.go         |    7 +
 model/user.go             |   26 ++++--
 model/client.go           |    4 +
 model/invoice.go          |   21 +++-
 model/subOrder.go         |    4 +
 model/salesLeads.go       |    1 
 api/v1/subOrder.go        |    2 
 api/v1/masterOrder.go     |    2 
 model/saleChance.go       |    4 +
 model/quotation.go        |    4 +
 service/invoice.go        |    2 
 model/followRecord.go     |    4 +
 model/request/invoice.go  |    5 
 model/receipt.go          |   21 +++-
 api/v1/saleChance.go      |    2 
 model/serviceOrder.go     |    2 
 model/request/receipt.go  |    7 +
 api/v1/followRecord.go    |    2 
 main.go                   |    2 
 service/receipt.go        |    1 
 32 files changed, 143 insertions(+), 46 deletions(-)

diff --git a/api/v1/client.go b/api/v1/client.go
index d7dc42e..c149aea 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -220,7 +220,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	clients, total, errCode := clientService.GetClientList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/contact.go b/api/v1/contact.go
index 2a6b72e..97068ca 100644
--- a/api/v1/contact.go
+++ b/api/v1/contact.go
@@ -181,7 +181,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	contacts, total, errCode := contactService.GetContactList(params.Page, params.PageSize, params.SearchMap, params.ClientId)
diff --git a/api/v1/contract.go b/api/v1/contract.go
index 5a0dcdd..5cfdd31 100644
--- a/api/v1/contract.go
+++ b/api/v1/contract.go
@@ -166,7 +166,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	contracts, total, errCode := contractService.GetContractList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index 1fe90dd..666ea35 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -246,7 +246,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/invoice.go b/api/v1/invoice.go
index 3c51eb3..89edcd4 100644
--- a/api/v1/invoice.go
+++ b/api/v1/invoice.go
@@ -1,6 +1,7 @@
 package v1
 
 import (
+	"aps_crm/constvar"
 	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
@@ -8,6 +9,7 @@
 	"aps_crm/pkg/ecode"
 	"aps_crm/pkg/structx"
 	"aps_crm/service"
+	"aps_crm/utils"
 	"github.com/gin-gonic/gin"
 	"strconv"
 )
@@ -123,6 +125,11 @@
 		return
 	}
 
+	userInfo := utils.GetUserInfo(c)
+	if userInfo.UserType == constvar.UserTypeSub {
+		params.PrincipalIds = userInfo.SubUserIds
+	}
+
 	invoice, total, errCode := service.NewInvoiceService().GetInvoiceList(params)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
diff --git a/api/v1/masterOrder.go b/api/v1/masterOrder.go
index af2fb9d..6362d0d 100644
--- a/api/v1/masterOrder.go
+++ b/api/v1/masterOrder.go
@@ -168,7 +168,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	masterOrders, total, errCode := masterOrderService.GetMasterOrderList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/plan.go b/api/v1/plan.go
index f09f7d9..2b59b8a 100644
--- a/api/v1/plan.go
+++ b/api/v1/plan.go
@@ -98,7 +98,6 @@
 	ctx.Ok()
 }
 
-
 func checkPlanParams(plan request.Plan) (errCode int, p model.Plan) {
 	//if plan.Number == "" {
 	//	return ecode.InvalidParams, p
@@ -155,7 +154,7 @@
 	}
 
 	ctx.OkWithDetailed(response.PlanResponse{
-		List: plans,
+		List:  plans,
 		Count: int(total),
 	})
-}
\ No newline at end of file
+}
diff --git a/api/v1/quotation.go b/api/v1/quotation.go
index 3fd3552..2455731 100644
--- a/api/v1/quotation.go
+++ b/api/v1/quotation.go
@@ -186,7 +186,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.CrmUserId
 	}
 
 	quotations, total, errCode := quotationService.GetQuotationList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/receipt.go b/api/v1/receipt.go
index 3367e14..44b0bb2 100644
--- a/api/v1/receipt.go
+++ b/api/v1/receipt.go
@@ -1,11 +1,13 @@
 package v1
 
 import (
+	"aps_crm/constvar"
 	"aps_crm/model/request"
 	"aps_crm/model/response"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
 	"aps_crm/service"
+	"aps_crm/utils"
 	"github.com/gin-gonic/gin"
 	"strconv"
 )
@@ -99,6 +101,11 @@
 		return
 	}
 
+	userInfo := utils.GetUserInfo(c)
+	if userInfo.UserType == constvar.UserTypeSub {
+		params.PrincipleIds = userInfo.SubUserIds
+	}
+
 	receipt, total, errCode := service.NewReceiptService().GetReceiptList(params)
 	if errCode != ecode.OK {
 		ctx.Fail(errCode)
diff --git a/api/v1/saleChance.go b/api/v1/saleChance.go
index 73bcdb0..addf56e 100644
--- a/api/v1/saleChance.go
+++ b/api/v1/saleChance.go
@@ -226,7 +226,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	saleChances, total, errCode := saleChanceService.GetSaleChanceList(params.Page, params.PageSize, params.SearchMap)
diff --git a/api/v1/subOrder.go b/api/v1/subOrder.go
index 188e036..7f1e53a 100644
--- a/api/v1/subOrder.go
+++ b/api/v1/subOrder.go
@@ -157,7 +157,7 @@
 		if params.SearchMap == nil {
 			params.SearchMap = make(map[string]interface{}, 0)
 		}
-		params.SearchMap["member_id"] = userInfo.CrmUserId
+		params.SearchMap["member_ids"] = userInfo.SubUserIds
 	}
 
 	subOrders, total, errCode := subOrderService.GetSubOrderList(params.Page, params.PageSize, params.SearchMap)
diff --git a/conf/aps-crm.json b/conf/aps-crm.json
index eeb4146..9774105 100644
--- a/conf/aps-crm.json
+++ b/conf/aps-crm.json
@@ -48,8 +48,8 @@
     "Issuer": "qmPlus"
   },
   "GrpcServiceAddr": {
-    "Aps": "192.168.20.119:9091",
-    "Admin": "192.168.20.119:50051"
+    "Aps": "192.168.20.120:9091",
+    "Admin": "192.168.20.120:50051"
   }
 }
 
diff --git a/main.go b/main.go
index 558c976..4996087 100644
--- a/main.go
+++ b/main.go
@@ -50,7 +50,7 @@
 	middleware.InitUserConn()
 	v1.InitCodeServiceConn()
 
-	middleware.InitRefreshUserManager(5, 5, 3600)
+	middleware.InitRefreshUserManager(1, 5, 3600)
 	middleware.RunRefreshUser() ///瀹氭椂瀵规椿璺冪敤鎴锋洿鏂扮敤鎴疯鎯�
 
 	logx.Error(server.ListenAndServe().Error())
diff --git a/model/client.go b/model/client.go
index 590c079..cafe6cb 100644
--- a/model/client.go
+++ b/model/client.go
@@ -129,6 +129,10 @@
 						db = db.Where("clients.member_id = ?", constvar.UserTypeSuper)
 					}
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("clients.member_id in ?", v)
+				}
 
 			}
 		}
diff --git a/model/contact.go b/model/contact.go
index f47d4f3..a01d3be 100644
--- a/model/contact.go
+++ b/model/contact.go
@@ -100,6 +100,10 @@
 				if key == "client_id" {
 					db = db.Where("client_id = ? and is_first = true", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("contacts.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/contract.go b/model/contract.go
index 91e50e8..e437c6c 100644
--- a/model/contract.go
+++ b/model/contract.go
@@ -80,6 +80,10 @@
 				if key == "member_id" {
 					db = db.Where(key+"= ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("contract.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/followRecord.go b/model/followRecord.go
index afc27cb..b220de2 100644
--- a/model/followRecord.go
+++ b/model/followRecord.go
@@ -106,6 +106,10 @@
 				if key == "client_id" || key == "contact_id" || key == "sales_leads_id" || key == "sale_chance_id" || key == "member_id" {
 					db = db.Where(key+" = ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("follow_records.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/invoice.go b/model/invoice.go
index 0db64fa..7089b18 100644
--- a/model/invoice.go
+++ b/model/invoice.go
@@ -36,12 +36,13 @@
 	// InvoiceSearch 閿�鍞彂绁ㄦ悳绱㈡潯浠�
 	InvoiceSearch struct {
 		Invoice
-		Orm         *gorm.DB
-		QueryClass  constvar.InvoiceQueryClass
-		KeywordType constvar.InvoiceKeywordType
-		Keyword     string
-		PageNum     int
-		PageSize    int
+		Orm          *gorm.DB
+		QueryClass   constvar.InvoiceQueryClass
+		KeywordType  constvar.InvoiceKeywordType
+		Keyword      string
+		PageNum      int
+		PageSize     int
+		PrincipalIds []int
 	}
 )
 
@@ -65,6 +66,11 @@
 	return slf
 }
 
+func (slf *InvoiceSearch) SetPrincipalIds(principalIds []int) *InvoiceSearch {
+	slf.PrincipalIds = principalIds
+	return slf
+}
+
 func (slf *InvoiceSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Invoice{})
 	if slf.Id != 0 {
@@ -81,6 +87,9 @@
 	if slf.Number != "" {
 		db.Where("number = ?", slf.Number)
 	}
+	if len(slf.PrincipalIds) > 0 {
+		db = db.Where("principal_id in ?", slf.PrincipalIds)
+	}
 
 	return db
 }
diff --git a/model/masterOrder.go b/model/masterOrder.go
index 112d16f..3b77851 100644
--- a/model/masterOrder.go
+++ b/model/masterOrder.go
@@ -72,6 +72,10 @@
 				if key == "client_id" || key == "member_id" || key == "money" {
 					db = db.Where(key+" = ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("master_order.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/plan.go b/model/plan.go
index 0ba2f15..8386692 100644
--- a/model/plan.go
+++ b/model/plan.go
@@ -25,11 +25,12 @@
 	PlanSearch struct {
 		Plan
 
-		Orm      *gorm.DB
-		Keyword  string
-		OrderBy  string
-		PageNum  int
-		PageSize int
+		Orm       *gorm.DB
+		Keyword   string
+		OrderBy   string
+		PageNum   int
+		PageSize  int
+		MemberIds []int
 	}
 )
 
@@ -50,6 +51,9 @@
 	}
 	if slf.Id != 0 {
 		db = db.Where("id = ?", slf.Id)
+	}
+	if len(slf.MemberIds) != 0 {
+		db = db.Where("member_id in ?", slf.MemberIds)
 	}
 
 	return db
@@ -97,6 +101,11 @@
 	return slf
 }
 
+func (slf *PlanSearch) SetMemberIds(ids []int) *PlanSearch {
+	slf.MemberIds = ids
+	return slf
+}
+
 func (slf *PlanSearch) SetKeyword(keyword string) *PlanSearch {
 	slf.Keyword = keyword
 	return slf
diff --git a/model/quotation.go b/model/quotation.go
index 969d34f..1c45c24 100644
--- a/model/quotation.go
+++ b/model/quotation.go
@@ -88,6 +88,10 @@
 				if key == "client_id" || key == "sale_chance_id" || key == "member_id" {
 					db = db.Where(key+" = ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("quotation.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/receipt.go b/model/receipt.go
index 2ca94cf..ff0a169 100644
--- a/model/receipt.go
+++ b/model/receipt.go
@@ -34,12 +34,13 @@
 	// ReceiptSearch 鏀舵鍗曟悳绱㈡潯浠�
 	ReceiptSearch struct {
 		Receipt
-		Orm         *gorm.DB
-		QueryClass  constvar.ReceiptQueryClass
-		KeywordType constvar.ReceiptKeywordType
-		Keyword     string
-		PageNum     int
-		PageSize    int
+		Orm          *gorm.DB
+		QueryClass   constvar.ReceiptQueryClass
+		KeywordType  constvar.ReceiptKeywordType
+		Keyword      string
+		PageNum      int
+		PageSize     int
+		PrincipalIds []int
 	}
 )
 
@@ -72,6 +73,11 @@
 	return slf
 }
 
+func (slf *ReceiptSearch) SetPrincipalIds(principalIds []int) *ReceiptSearch {
+	slf.PrincipalIds = principalIds
+	return slf
+}
+
 func (slf *ReceiptSearch) SetPage(page, size int) *ReceiptSearch {
 	slf.PageNum, slf.PageSize = page, size
 	return slf
@@ -91,6 +97,9 @@
 	if slf.ClientId != 0 {
 		db = db.Where("client_id = ?", slf.ClientId)
 	}
+	if len(slf.PrincipalIds) != 0 {
+		db = db.Where("principal_id in ?", slf.PrincipalIds)
+	}
 
 	return db
 }
diff --git a/model/request/invoice.go b/model/request/invoice.go
index fa08e2f..f22f4f1 100644
--- a/model/request/invoice.go
+++ b/model/request/invoice.go
@@ -44,6 +44,7 @@
 
 type GetInvoiceList struct {
 	PageInfo
-	SourceId   int                        `json:"sourceId"`
-	SourceType constvar.InvoiceSourceType `json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
+	SourceId     int                        `json:"sourceId"`
+	SourceType   constvar.InvoiceSourceType `json:"sourceType"` // 婧愬崟绫诲瀷(1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓)
+	PrincipalIds []int
 }
diff --git a/model/request/receipt.go b/model/request/receipt.go
index 2285ea3..626e8d3 100644
--- a/model/request/receipt.go
+++ b/model/request/receipt.go
@@ -16,7 +16,8 @@
 
 type GetReceiptList struct {
 	PageInfo
-	SourceType constvar.ReceiptSourceType `json:"sourceType" form:"sourceType"` //鏉ユ簮绫诲瀷锛�1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓3閿�鍞彂绁�4鏀舵璁″垝5鍑哄簱鍗曪級
-	SourceId   int                        `json:"sourceId" form:"sourceId"`
-	ClientId   int                        `json:"clientId"  form:"clientId"` //瀹㈡埛id
+	SourceType   constvar.ReceiptSourceType `json:"sourceType" form:"sourceType"` //鏉ユ簮绫诲瀷锛�1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓3閿�鍞彂绁�4鏀舵璁″垝5鍑哄簱鍗曪級
+	SourceId     int                        `json:"sourceId" form:"sourceId"`
+	ClientId     int                        `json:"clientId"  form:"clientId"` //瀹㈡埛id
+	PrincipleIds []int
 }
diff --git a/model/saleChance.go b/model/saleChance.go
index 5f0f37c..9cde56f 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -121,6 +121,10 @@
 				if key == "member_id" || key == "budget" || key == "projected_amount" || key == "client_id" {
 					db = db.Where(key+" = ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("sale_chance.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/salesLeads.go b/model/salesLeads.go
index 6ccbdcb..f783ad2 100644
--- a/model/salesLeads.go
+++ b/model/salesLeads.go
@@ -92,6 +92,7 @@
 				}
 
 			case int:
+			case []int:
 				if key == "member_ids" {
 					db = db.Where("sales_leads.member_id in ?", v)
 				}
diff --git a/model/serviceFeeManage.go b/model/serviceFeeManage.go
index 45f4705..f54d3e7 100644
--- a/model/serviceFeeManage.go
+++ b/model/serviceFeeManage.go
@@ -28,6 +28,7 @@
 		OrderBy     string
 		PageNum     int
 		PageSize    int
+		MemberIds   []int
 	}
 )
 
@@ -53,6 +54,11 @@
 	if slf.ClientId != 0 {
 		db.Where("client_id = ?", slf.ClientId)
 	}
+
+	if len(slf.MemberIds) > 0 {
+		db.Where("service_fee_manage.member_id in ?", slf.MemberIds)
+	}
+
 	switch slf.QueryClass {
 	case constvar.ServiceFeeQueryClassExpireLessThen60Days:
 		db = db.Where("latest_date > ? and latest_date < ?", time.Now(), time.Now().AddDate(0, 0, 60))
@@ -120,6 +126,11 @@
 	return slf
 }
 
+func (slf *ServiceFeeManageSearch) SetMemberIds(ids []int) *ServiceFeeManageSearch {
+	slf.MemberIds = ids
+	return slf
+}
+
 func (slf *ServiceFeeManageSearch) SetKeywordType(keyword constvar.ServiceFeeKeywordType) *ServiceFeeManageSearch {
 	slf.KeywordType = keyword
 	return slf
diff --git a/model/serviceOrder.go b/model/serviceOrder.go
index c3d350b..7af464a 100644
--- a/model/serviceOrder.go
+++ b/model/serviceOrder.go
@@ -132,7 +132,7 @@
 	}
 
 	if len(slf.ServiceManIds) > 0 {
-		db = db.Where("service_man_id in ?", slf.ServiceManIds)
+		db = db.Where("service_order.service_man_id in ?", slf.ServiceManIds)
 	}
 	if slf.ServiceNumber != "" {
 		db = db.Where("service_number = ?", slf.ServiceNumber)
diff --git a/model/subOrder.go b/model/subOrder.go
index 930e672..765b112 100644
--- a/model/subOrder.go
+++ b/model/subOrder.go
@@ -81,6 +81,10 @@
 				if key == "member_id" {
 					db = db.Where("sub_order.member_id = ?", v)
 				}
+			case []int:
+				if key == "member_ids" {
+					db = db.Where("sub_order.member_id in ?", v)
+				}
 			}
 		}
 	}
diff --git a/model/user.go b/model/user.go
index db6afb1..17da6c3 100644
--- a/model/user.go
+++ b/model/user.go
@@ -5,14 +5,13 @@
 	"aps_crm/pkg/mysqlx"
 	"fmt"
 	"gorm.io/gorm"
-	"gorm.io/gorm/clause"
 )
 
 type (
 	// User token閲岃竟鎶婄敤鎴稩D銆佺埗鐢ㄦ埛ID銆佽鑹查兘甯︿笂
 	User struct {
 		ID           int               `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		UUID         string            `json:"uuid" gorm:"unique;type:varchar(255);comment:鐢ㄦ埛ID"`
+		UUID         string            `json:"uuid" gorm:"uniqueIndex;type:varchar(255);comment:鐢ㄦ埛ID"`
 		Username     string            `json:"username" gorm:"index;type:varchar(255);comment:鐢ㄦ埛鐧诲綍鍚�"`
 		UserType     constvar.UserType `json:"userType" gorm:"type:int(11);comment:鐢ㄦ埛绫诲瀷 1瓒呯骇绠$悊鍛� 2涓昏处鎴� 3瀛愯处鎴�"`
 		Password     string            `json:"-"  gorm:"type:varchar(255);comment:鐢ㄦ埛鐧诲綍瀵嗙爜"`
@@ -294,13 +293,24 @@
 }
 
 func (slf *UserSearch) Upsert(record User) error {
-	var db = slf.build()
 
-	if err := db.Clauses(clause.OnConflict{
-		Columns:   []clause.Column{{Name: "uuid"}},
-		DoUpdates: clause.AssignmentColumns([]string{"username", "user_type", "nick_name", "sub_user_ids"}),
-	}).Create(&record).Error; err != nil {
-		return fmt.Errorf("first or create err: %v, record: %+v", err, record)
+	var db = slf.SetId(record.UUID).build()
+	old, err := slf.First()
+	if err == gorm.ErrRecordNotFound {
+		if err := db.Create(&record).Error; err != nil {
+			return fmt.Errorf("create user err: %v, record: %+v", err, record)
+		}
+	} else if old.Username != record.Username ||
+		old.UserType != record.UserType ||
+		old.NickName != record.NickName ||
+		old.SubUserIds != record.SubUserIds {
+		old.Username = record.Username
+		old.UserType = record.UserType
+		old.NickName = record.NickName
+		old.SubUserIds = record.SubUserIds
+		if err := db.Updates(&record).Error; err != nil {
+			return fmt.Errorf("update user err: %v, record: %+v", err, record)
+		}
 	}
 
 	return nil
diff --git a/service/invoice.go b/service/invoice.go
index 9aaf90f..339674a 100644
--- a/service/invoice.go
+++ b/service/invoice.go
@@ -140,7 +140,7 @@
 }
 
 func (InvoiceService) GetInvoiceList(params request.GetInvoiceList) ([]*model.Invoice, int64, int) {
-	list, total, err := model.NewInvoiceSearch().SetSourceId(params.SourceId).SetSourceType(params.SourceType).Find()
+	list, total, err := model.NewInvoiceSearch().SetSourceId(params.SourceId).SetSourceType(params.SourceType).SetPrincipalIds(params.PrincipalIds).Find()
 	if err != nil {
 		return nil, 0, ecode.DBErr
 	}
diff --git a/service/receipt.go b/service/receipt.go
index 9ec0ba3..b4999cf 100644
--- a/service/receipt.go
+++ b/service/receipt.go
@@ -136,6 +136,7 @@
 		SetSourceType(params.SourceType).
 		SetSourceId(params.SourceId).
 		SetClientId(params.ClientId).
+		SetPrincipalIds(params.PrincipleIds).
 		Find()
 	if err != nil {
 		return nil, 0, ecode.DBErr

--
Gitblit v1.8.0