瀏覽代碼

Merge branch 'dev_v1.0.4_wh' of CRM/application into hotfix/v1.0.4.2

王浩 1 年之前
父節點
當前提交
5b1131a21a
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      api/internal/service/owner.go

+ 6 - 3
api/internal/service/owner.go

@@ -58,6 +58,7 @@ type BuyerProject struct {
 	Area             string
 	Zbtime           int64
 	BuyerType        string
+	CId              string
 }
 type ProjectEntity struct {
 	Number          int64
@@ -390,14 +391,13 @@ func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]
 	}
 	//中间人  作为可介绍业主    企业名称
 	companyArr := CrmMysql.SelectBySql(
-		fmt.Sprintf("select DISTINCT b.id, b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person   from  connection_introduce a  INNER JOIN  connection   b  on  a.position_id=%d  and a.connection_id=b.id  and   a.relate_Id in (%s) and  a.itype =1  and  b.itype=4 and  b.status=1 ", positionId, strings.Join(buyerArr, ",")))
+		fmt.Sprintf("select DISTINCT  b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person   from  connection_introduce a  INNER JOIN  connection   b  on  a.position_id=%d  and a.connection_id=b.id  and   a.relate_Id in (%s) and  a.itype =1  and  b.itype=4 and  b.status=1 ", positionId, strings.Join(buyerArr, ",")))
 	for _, v := range *companyArr {
 		companyId := gconv.String(v["company_id"])
 		companyName := gconv.String(v["company_name"])
 		relateName := gconv.String(v["relate_name"])
 		relateId := gconv.String(v["relate_id"])
 		returnData = append(returnData, map[string]interface{}{
-			"c_id":         gconv.String(v["id"]),
 			"b_id":         companyId,
 			"b_name":       companyName,
 			"a_name":       relateName,
@@ -559,6 +559,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 				IsIgnore:         gconv.Bool(buyerMap["isIgnore"]),
 				IsMonitor:        gconv.Bool(buyerMap["isMonitor"]),
 				IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
+				CId:              gconv.String(buyerMap["cId"]),
 			})
 		} else {
 			if sourceType == "1" {
@@ -580,6 +581,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 				IsIgnore:         gconv.Bool(buyerMap["isIgnore"]),
 				IsMonitor:        gconv.Bool(buyerMap["isMonitor"]),
 				IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
+				CId:              gconv.String(buyerMap["cId"]),
 			})
 
 		}
@@ -738,7 +740,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 	if intermediary != "" {
 		wh, args := common.WhArgs(strings.Split(intermediary, ","))
 		args = append(args, positionId)
-		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.id in (`+wh+`) and  a.position_id=?  and a.id=b.connection_id and b.itype=1)`, args...)
+		intermediaryArr := CrmMysql.SelectBySql(`select a.id,b.relate_id as relate_id,b.relate_name as relate_name from crm.connection a inner join crm.connection_introduce b on ( a.id in (`+wh+`) and  a.position_id=?  and a.id=b.connection_id and b.itype=1)`, args...)
 		if intermediaryArr != nil && len(*intermediaryArr) > 0 {
 			for _, m := range *intermediaryArr {
 				buyerId := gconv.String(m["relate_id"])
@@ -746,6 +748,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 				(*dataMap)[buyerId] = map[string]interface{}{
 					"buyerName": buyerName,
 					"buyerType": "middleman",
+					"cId":       gconv.String(m["id"]),
 				}
 			}
 		}