Bläddra i källkod

Merge branch 'dev/v1.1.26_fuwencai' of https://jygit.jydev.jianyu360.cn/BaseService/jyMicroservices into dev/v1.1.26_fuwencai

wangshan 2 år sedan
förälder
incheckning
9d43b82147
2 ändrade filer med 18 tillägg och 8 borttagningar
  1. 16 6
      jyBXBuyer/rpc/internal/logic/buyerlistlogic.go
  2. 2 2
      jyBXBuyer/rpc/model/buyerListBYEs.go

+ 16 - 6
jyBXBuyer/rpc/internal/logic/buyerlistlogic.go

@@ -32,10 +32,6 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	resp := &bxbuyer.BuyerListResp{
 		Data: &bxbuyer.BuyerData{},
 	}
-	// 采购单位搜索过来的 最多查100条
-	if in.PageSize*in.PageNum > IC.C.BuyerSearchLimit {
-		in.PageNum = IC.C.BuyerSearchLimit / in.PageSize
-	}
 	if in.PageNum < 1 {
 		in.PageNum = 1
 	}
@@ -45,6 +41,12 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	if in.PageSize > IC.C.BuyerSearchLimit {
 		in.PageSize = IC.C.BuyerSearchLimit
 	}
+	// 判断数量
+	// 采购单位搜索过来的 最多查BuyerSearchLimit条
+	if in.PageNum*in.PageSize > IC.C.BuyerSearchLimit && (in.PageNum-1)*in.PageSize >= IC.C.BuyerSearchLimit {
+		in.PageNum = IC.C.BuyerSearchLimit / in.PageSize
+	}
+
 	query, CountQuery := "", ""
 	buyerNames := []string{}
 	if model.CheckEmpty(in) {
@@ -63,8 +65,8 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 					end := in.PageSize * in.PageNum
 					count := len(list)
 					resp.Data.Count = int64(count)
-					if end > int64(len(list)-1) {
-						end = int64(len(list) - 1)
+					if end > int64(len(list)) {
+						end = int64(len(list))
 					}
 					resp.Data.List = list[start:end]
 					for i := 0; i < len(resp.Data.List); i++ {
@@ -88,6 +90,14 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	if len(resp.Data.List) > 0 && (in.UserId != "" || in.EntUserId != "") {
 		model.SupplyFollowInfo(in, buyerNames, resp)
 	}
+	if len(resp.Data.List) > 0 {
+		if in.PageNum*in.PageSize > IC.C.BuyerSearchLimit && (in.PageNum-1)*in.PageSize < IC.C.BuyerSearchLimit {
+			end := IC.C.BuyerSearchLimit - (in.PageNum-1)*in.PageSize
+			if len(resp.Data.List) > int(end) {
+				resp.Data.List = resp.Data.List[:end]
+			}
+		}
+	}
 	if resp.Data.Count > IC.C.BuyerSearchLimit {
 		resp.Data.Count = IC.C.BuyerSearchLimit
 	}

+ 2 - 2
jyBXBuyer/rpc/model/buyerListBYEs.go

@@ -292,8 +292,8 @@ func BuyerListRedisCache(query string, in *bxbuyer.BuyerListReq) (buyerNames []s
 	start := in.PageSize * (in.PageNum - 1)
 	end := in.PageSize * in.PageNum
 	resp.Data.Count = int64(len(saveBuyerList))
-	if end > int64(len(saveBuyerList)-1) {
-		end = int64(len(saveBuyerList) - 1)
+	if end > int64(len(saveBuyerList)) {
+		end = int64(len(saveBuyerList))
 	}
 	resp.Data.List = saveBuyerList[start:end]
 	logx.Info("空搜索整体耗时;", time.Since(t1).Seconds(), "秒--", time.Since(t1).Microseconds())