Browse Source

Merge branch 'hotfix/v1.0.4.2' of https://jygit.jydev.jianyu360.cn/CRM/application into hotfix/v1.0.4.2

wangchuanjin 1 year ago
parent
commit
813c5ad960
2 changed files with 13 additions and 9 deletions
  1. 8 6
      api/internal/service/employService.go
  2. 5 3
      api/internal/service/owner.go

+ 8 - 6
api/internal/service/employService.go

@@ -798,19 +798,19 @@ func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmp
 		orderKey = "source"
 	}
 	if len(infoId1Arr) > 0 {
-		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
+		infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select  %s,GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, orderKey, table, employKey, strings.Join(infoId1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
 	}
 	if len(infoId2Arr) > 0 {
-		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
+		infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from  %s   where %s in ('%s') and  source=? and    ent_dept_id in  (%s)  GROUP BY %s ,%s order  by %s", employKey, orderKey, table, employKey, strings.Join(infoId2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	if len(niJianIdArr) > 0 {
-		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
+		niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, GROUP_CONCAT(id) as  employIdArr,MAX(is_ignore) as is_ignore,MAX(status) as status,%s from  %s   where %s  in ('%s') and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, orderKey, table, employKey, strings.Join(niJianIdArr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	if len(wuye1Arr) > 0 {
-		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status   from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,%s order  by %s", employKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
+		wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s,  id,is_ignore,status,%s   from  %s   where %s in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s)  GROUP BY %s  ,%s order  by %s", employKey, orderKey, table, employKey, strings.Join(wuye1Arr, "','"), depIDArr, employKey, orderKey, orderKey), 1)
 	}
 	if len(wuye2Arr) > 0 {
-		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status   from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
+		wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, id,is_ignore,status,%s   from  %s   where %s  in ('%s')  and status =1 and  source=? and    ent_dept_id in  (%s) GROUP BY %s ,%s order  by %s", employKey, orderKey, table, employKey, strings.Join(wuye2Arr, "','"), depIDArr, employKey, orderKey, orderKey), 2)
 	}
 	for _, v := range *infoData1 {
 		valueMap := map[string]interface{}{
@@ -937,7 +937,6 @@ func EmployHandle(valueMap map[string]interface{}, employData map[string]interfa
 			if employStatus == 1 {
 				employ2 = true
 			}
-			valueMap["intelligenceId"] = employId
 		case 3:
 			if valueMap["employ2"] != nil {
 				employ2 = gconv.Bool(valueMap["employ2"])
@@ -967,6 +966,9 @@ func EmployHandle(valueMap map[string]interface{}, employData map[string]interfa
 		valueMap["type"] = common.Int64All(employData["type"])
 		valueMap["employId"] = employId
 	}
+	if employType == 2 {
+		valueMap["intelligenceId"] = employId
+	}
 	if single && employArrStr != "" {
 		//列表查询
 		//是否忽略处理

+ 5 - 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
@@ -203,7 +204,6 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
 		return returnData
 	}
 	a5 := time.Now().Unix()
-
 	returnData = append(returnData, Findwinner(buyerArr)...)
 	a6 := time.Now().Unix()
 	logx.Info("供应商", a6-a5)
@@ -397,7 +397,6 @@ func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]
 		companyName := gconv.String(v["company_name"])
 		relateName := gconv.String(v["relate_name"])
 		relateId := gconv.String(v["relate_id"])
-		//key := fmt.Sprintf("%s_%s", relateId, companyId)
 		returnData = append(returnData, map[string]interface{}{
 			"b_id":         companyId,
 			"b_name":       companyName,
@@ -560,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" {
@@ -581,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"]),
 			})
 
 		}
@@ -739,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"])
@@ -747,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"]),
 				}
 			}
 		}