Ver Fonte

Merge commit 'd925fb4834d75f994abae9d75c3694dfb6b444ae' into hotfix/v1.0.4.2

* commit 'd925fb4834d75f994abae9d75c3694dfb6b444ae':
  采购单位类型处理
  空值处理
Jianghan há 1 ano atrás
pai
commit
40417f66cd
1 ficheiros alterados com 23 adições e 7 exclusões
  1. 23 7
      api/internal/service/owner.go

+ 23 - 7
api/internal/service/owner.go

@@ -57,6 +57,7 @@ type BuyerProject struct {
 	IsIgnore         bool
 	Area             string
 	Zbtime           int64
+	BuyerType        string
 }
 type ProjectEntity struct {
 	Number          int64
@@ -273,6 +274,9 @@ where
 		agencyMap := map[string]map[string]interface{}{}
 		agencyIdMap := map[string]bool{}
 		for _, m := range winnerArr {
+			if m.EntId == "" {
+				continue
+			}
 			projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
 			projectName := m.Project_name
 			zbtime := m.Zbtime
@@ -548,6 +552,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 			returnData = append(returnData, BuyerProject{
 				BuyerId:   buyerId,
 				BuyerName: buyerName,
+				BuyerType: gconv.String(buyerMap["buyerType"]),
 				Project: ProjectEntity{
 					Number:          count,
 					EstimatedAmount: money,
@@ -568,6 +573,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 			returnData = append(returnData, BuyerProject{
 				BuyerId:   buyerId,
 				BuyerName: buyerName,
+				BuyerType: gconv.String(buyerMap["buyerType"]),
 				Project: ProjectEntity{
 					Number:          0,
 					EstimatedAmount: 0,
@@ -703,7 +709,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 		}
 		if len(partyA) > 0 {
 			partyASql := fmt.Sprintf(`select  id as buyer_id,company_name as buyer  from  ent_info   where  id in (%s)`, strings.Join(intermediaryArr, ","))
-			FindHandle(partyASql, dataMap)
+			FindHandle(partyASql, dataMap, "firstparty")
 		}
 	}
 	//供应商 //同甲异业
@@ -715,17 +721,22 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 			}
 		}
 	}
+	if len(findInSetArr) > 0 {
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
+		FindHandle(sqlStr, dataMap, "supplier")
+	}
 	//同甲异业
+	findheterotophyArr := []string{}
 	if heterotophy != "" {
 		for _, v := range strings.Split(heterotophy, ",") {
 			if v != "" {
-				findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
+				findheterotophyArr = append(findheterotophyArr, fmt.Sprintf("'%s'", v))
 			}
 		}
 	}
-	if len(findInSetArr) > 0 {
-		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
-		FindHandle(sqlStr, dataMap)
+	if len(findheterotophyArr) > 0 {
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findheterotophyArr, ","))
+		FindHandle(sqlStr, dataMap, "adiffb")
 	}
 	//中间人
 	if intermediary != "" {
@@ -738,6 +749,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 				buyerName := gconv.String(m["relate_name"])
 				(*dataMap)[buyerId] = map[string]interface{}{
 					"buyerName": buyerName,
+					"buyerType": "middleman",
 				}
 			}
 		}
@@ -749,7 +761,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 			agencyArr = append(agencyArr, fmt.Sprintf("'%s'", s))
 		}
 		sqlStr := fmt.Sprintf(`SELECT  buyer_id,buyer FROM transaction_info  where agency_id in (%s) `, strings.Join(agencyArr, ","))
-		FindHandle(sqlStr, dataMap)
+		FindHandle(sqlStr, dataMap, "agency")
 	}
 	return dataMap
 }
@@ -820,6 +832,7 @@ func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, project
 			}
 			(*returnMap)[buyerId] = map[string]interface{}{
 				"buyerName": buyerName,
+				"buyerType": "firstparty",
 			}
 
 		}
@@ -871,7 +884,7 @@ type BuyerAggStruct struct {
 }
 
 // 采购单位查询sql
-func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
+func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}, buyerType string) {
 	rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
 	if err != nil {
 		logx.Error("查询失败", sqlStr, err)
@@ -882,6 +895,7 @@ func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
 		if data.BuyerId != "" {
 			(*dataMap)[data.BuyerId] = map[string]interface{}{
 				"buyerName": data.Buyer,
+				"buyerType": buyerType,
 			}
 		}
 	}
@@ -1065,6 +1079,8 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 	}
 	return returData
 }
+
+// 候选渠道
 func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
 	returnData := []*ResultData{}
 	dataMap := &map[string]map[string]interface{}{}