wangchuanjin hai 1 ano
pai
achega
23695f8062

+ 1 - 2
api/internal/service/network.go

@@ -176,8 +176,7 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 			args := []interface{}{in.EntName}
 			wh, newArgs := NetworkCom.WhArgs(probusfors)
 			args = append(args, newArgs...)
-			q := `select DISTINCT b.winner_id,b.winner from information.transaction_info a 
-				inner join information.transaction_info b on (has(a.winner, ?) and a.buyer_id<>'' and a.buyer_id=b.buyer_id and hasAny(b.property_form,[` + wh + `])=0) ORDER BY b.project_id`
+			q := `select DISTINCT winner_id,winner from information.transaction_info where buyer_id in (select buyer_id from information.transaction_info where has(winner, ?) and buyer_id<>'') and hasAny(property_form,[` + wh + `])=0 ORDER BY project_id`
 			rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 			if err != nil {
 				logx.Error(err)

+ 4 - 4
api/internal/service/network_test.go

@@ -93,10 +93,10 @@ func TestAssociate(t *testing.T) {
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
 	//
 	res := Network.Associate(&types.AssociateReq{
-		EntName:      "深圳市光明区马田街道市政管理和建设工程事务中心",
-		EntAccountId: 64,
-		Name:         "公司",
-		Type:         "adiffb",
+		//EntName:      "深圳市光明区马田街道市政管理和建设工程事务中心",
+		//EntAccountId: 64,
+		Name: "北京",
+		Type: "middleman",
 	})
 	log.Println(res.Data)
 }

+ 1 - 2
api/internal/service/owner.go

@@ -680,8 +680,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 	}
 	//中间人
 	if intermediary != "" {
-		intermediarySql := fmt.Sprintf(`select b.relate_id as relate_id,b.relate_name as relate_name from crm.connection a inner join crm.connection_introduce b on (a.position_id=%s  and  find_in_set(company_id,"")and a.id=b.connection_id and b.itype=1)`, gconv.String(positionId), intermediary)
-		intermediaryArr := CrmMysql.SelectBySql(intermediarySql)
+		intermediaryArr := CrmMysql.SelectBySql(`select b.relate_id as relate_id,b.relate_name as relate_name from crm.connection a inner join crm.connection_introduce b on (a.position_id=? and find_in_set(company_id,?) and a.id=b.connection_id and b.itype=1)`, positionId, intermediary)
 		if intermediaryArr != nil && len(*intermediaryArr) > 0 {
 			for _, m := range *intermediaryArr {
 				buyerId := gconv.String(m["relate_id"])