owner.go 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. package service
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "sort"
  7. "strings"
  8. "time"
  9. elastic "app.yhyue.com/moapp/jybase/es"
  10. "app.yhyue.com/moapp/jybase/encrypt"
  11. "app.yhyue.com/moapp/jybase/common"
  12. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  13. "bp.jydev.jianyu360.cn/CRM/application/entity"
  14. "github.com/gogf/gf/v2/util/gconv"
  15. "github.com/shopspring/decimal"
  16. "github.com/zeromicro/go-zero/core/logx"
  17. )
  18. const (
  19. EntINDEX = "ent_info"
  20. EntTYPE = "ent_info"
  21. )
  22. type OwnerService struct {
  23. PartyA string
  24. Supplier string
  25. Heterotophy string
  26. Intermediary string
  27. Agency string
  28. SearchEntName string
  29. SourceType string
  30. ProcessingStatus string
  31. Area string
  32. PositionId int64
  33. PageIndex int64
  34. PageSize int64
  35. BuyerId string
  36. BuyerName string
  37. WinnerId string
  38. WinnerName string
  39. CooperateType string
  40. EntAccountId int64
  41. ProjectType string
  42. Type string
  43. }
  44. type BuyerProject struct {
  45. BuyerId string
  46. BuyerName string
  47. Project ProjectEntity
  48. IsMonitor bool
  49. IsCreateCustomer bool
  50. IsIgnore bool
  51. Area string
  52. Zbtime int64
  53. }
  54. type ProjectEntity struct {
  55. Number int64
  56. zbtime int64
  57. EstimatedAmount int64
  58. Connections []map[string]interface{}
  59. }
  60. type Recommend struct {
  61. BuyerId string `ch:"buyer_id"`
  62. Buyer string `ch:"buyer"`
  63. }
  64. type Project struct {
  65. BuyerId string `ch:"buyer_id"`
  66. Area string `ch:"area"`
  67. GroupCount uint64 `ch:"group_count"`
  68. Zbtime int64 `ch:"zbtime"`
  69. Money decimal.Decimal `ch:"money"`
  70. }
  71. func (t *OwnerService) OwnerlList() map[string]interface{} {
  72. //先查询采购单位列表
  73. startTime := time.Now().Unix()
  74. dataMap := &map[string]map[string]interface{}{}
  75. projectMap := &map[string]map[string]interface{}{}
  76. if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
  77. dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
  78. if len(*dataMap) == 0 {
  79. return map[string]interface{}{
  80. "connectionsNumber": 0,
  81. "highSuccessNumber": 0,
  82. "monitorNumber": 0,
  83. "list": []BuyerProject{},
  84. }
  85. }
  86. //处理状态初始化
  87. ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
  88. //监控状态处理
  89. MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
  90. //项目数量查询
  91. buyerArr := []string{}
  92. for _, value := range *dataMap {
  93. buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
  94. }
  95. //项目数量处理
  96. projectMap, _, dataMap = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
  97. } else if t.SearchEntName != "" {
  98. //1 只看转介绍成功率高2只看已监控的
  99. //先查找采购单位数据
  100. projectMap, dataMap, _ = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
  101. a7 := time.Now().Unix()
  102. fmt.Println("es用时", a7-startTime)
  103. ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
  104. a8 := time.Now().Unix()
  105. fmt.Println("状态用时", a8-a7)
  106. //监控状态处理
  107. MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
  108. a9 := time.Now().Unix()
  109. fmt.Println("监控用时", a9-a8)
  110. }
  111. endTime := time.Now().Unix()
  112. fmt.Println("用时时间:", endTime-startTime)
  113. if len(*dataMap) == 0 {
  114. return map[string]interface{}{}
  115. }
  116. //采购单位和项目合并
  117. a1 := time.Now().Unix()
  118. returnData, connectionsNumber, highSuccessNumber, monitorNumber := BuyerProjectMerge(dataMap, projectMap, t.SourceType)
  119. a2 := time.Now().Unix()
  120. fmt.Println("组合数据", a2-a1)
  121. //数组排序
  122. //分页数据处理
  123. if t.PageSize == 0 {
  124. t.PageSize = 10
  125. }
  126. if t.PageIndex == 0 {
  127. t.PageIndex = 1
  128. }
  129. startIndex := (t.PageIndex - 1) * t.PageSize
  130. endIndex := t.PageIndex * t.PageSize
  131. sort.Slice(returnData, func(i, j int) bool {
  132. if returnData[i].Zbtime != 0 {
  133. return returnData[i].Zbtime > returnData[j].Zbtime
  134. } else {
  135. return returnData[i].BuyerId > returnData[j].BuyerId
  136. }
  137. })
  138. if startIndex < gconv.Int64(len(returnData)) {
  139. if endIndex > gconv.Int64(len(returnData)) {
  140. endIndex = gconv.Int64(len(returnData))
  141. }
  142. returnData = returnData[startIndex:endIndex]
  143. } else {
  144. return map[string]interface{}{}
  145. }
  146. buyerIdArr := []string{}
  147. for _, value := range returnData {
  148. if value.BuyerId != "" {
  149. buyerIdArr = append(buyerIdArr, fmt.Sprintf("'%s'", value.BuyerId))
  150. }
  151. }
  152. //可介绍业主人脉处理
  153. a3 := time.Now().Unix()
  154. routeList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
  155. a4 := time.Now().Unix()
  156. fmt.Println("组合数1111据", a4-a3)
  157. for _, v := range routeList {
  158. buyerId := gconv.String(v["a_id"])
  159. for i, v1 := range returnData {
  160. aBuyerId := v1.BuyerId
  161. if buyerId == aBuyerId {
  162. //组装数据
  163. returnData[i].Project.Connections = append(returnData[i].Project.Connections, v)
  164. }
  165. }
  166. }
  167. //返回数据组装
  168. return map[string]interface{}{
  169. "connectionsNumber": connectionsNumber,
  170. "highSuccessNumber": highSuccessNumber,
  171. "monitorNumber": monitorNumber,
  172. "list": returnData,
  173. }
  174. }
  175. // 可介绍业主人脉列表
  176. func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[string]interface{} {
  177. returnData := []map[string]interface{}{}
  178. a1 := time.Now().Unix()
  179. //中间人
  180. returnData = FindMiddleman(buyerArr, positionId, returnData)
  181. a2 := time.Now().Unix()
  182. fmt.Println("中间人", a2-a1)
  183. if isAll && len(returnData) > 0 {
  184. return returnData
  185. }
  186. //采购单位 投资关系 管辖关系
  187. //采购单位
  188. a3 := time.Now().Unix()
  189. returnData = Findfirstparty(buyerArr, returnData)
  190. a4 := time.Now().Unix()
  191. fmt.Println("采购单位", a4-a3)
  192. if isAll && len(returnData) > 0 {
  193. return returnData
  194. }
  195. a5 := time.Now().Unix()
  196. returnData = Findwinner(buyerArr, returnData)
  197. a6 := time.Now().Unix()
  198. logx.Info("供应商", a6-a5)
  199. return returnData
  200. }
  201. // 供应商处理
  202. func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
  203. if len(buyerArr) == 0 {
  204. return returnData
  205. }
  206. //供应商 采购单位 供应商 招标代理机构 采购单位 招标代理机构 需要计算合作次数
  207. winnerSql := fmt.Sprintf(`select
  208. DISTINCT
  209. zbtime,
  210. project_id,
  211. project_name,
  212. buyer_id,
  213. buyer,
  214. agency_id,
  215. agency,
  216. winner_id,
  217. winner
  218. from
  219. transaction_info
  220. where
  221. buyer_id in (%s) order by zbtime DESC,project_id DESC `, strings.Join(buyerArr, ","))
  222. winnerArr := SupplierFindConnectionsHandle(winnerSql)
  223. if winnerArr != nil && len(winnerArr) > 0 {
  224. //企业联系人处理
  225. entIdArr := []string{}
  226. for _, v := range winnerArr {
  227. if v.WinnerId != "" {
  228. entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.WinnerId))
  229. }
  230. if v.Agency_id != "" {
  231. entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.Agency_id))
  232. }
  233. }
  234. personMap := map[string]string{}
  235. entNameMap := map[string]string{}
  236. if len(entIdArr) > 0 {
  237. personSql := fmt.Sprintf(`select id,name as personName from ent_contact where id in (%s) ORDER by name`, strings.Join(entIdArr, ","))
  238. personArr := PersonFindConnectionsHandle(personSql)
  239. //联系人处理
  240. for _, v := range personArr {
  241. personMap[v.Id] = v.PersonName
  242. }
  243. entSql := fmt.Sprintf(`select id ,company_name as personName from ent_info where id in (%s) ORDER by company_name`, strings.Join(entIdArr, ","))
  244. entNameArr := PersonFindConnectionsHandle(entSql)
  245. for _, v := range entNameArr {
  246. entNameMap[v.Id] = v.PersonName
  247. }
  248. }
  249. winnerMap := map[string]map[string]interface{}{}
  250. agencyMap := map[string]map[string]interface{}{}
  251. agencyIdMap := map[string]bool{}
  252. for _, m := range winnerArr {
  253. buyerId := m.Buyer_id
  254. winner := m.Winner
  255. buyer := m.Buyer
  256. winnerId := m.WinnerId
  257. agency := m.Agency
  258. agencyId := m.Agency_id
  259. projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
  260. projectName := m.Project_name
  261. zbtime := m.Zbtime
  262. key := fmt.Sprintf("%s_%s", buyerId, winnerId)
  263. if winnerId != "" {
  264. if _, ok := winnerMap[key]; ok {
  265. data := winnerMap[key]
  266. data["count"] = gconv.Int64(data["data"]) + 1
  267. dataList := gconv.Maps(data["list"])
  268. dataList = append(dataList, map[string]interface{}{
  269. "zbtime": zbtime,
  270. "projectId": projectId,
  271. "projectName": projectName,
  272. })
  273. data["list"] = dataList
  274. winnerMap[key] = data
  275. } else {
  276. winnerMap[key] = map[string]interface{}{
  277. "b_id": winnerId,
  278. "b_name": winner,
  279. "a_name": buyer,
  280. "a_id": buyerId,
  281. "sourceType": "supplier",
  282. "personName": gconv.String(personMap[winnerId]),
  283. "count": 1,
  284. "list": []map[string]interface{}{
  285. {
  286. "zbtime": zbtime,
  287. "entName": winner,
  288. "projectId": projectId,
  289. "projectName": projectName,
  290. },
  291. },
  292. }
  293. }
  294. }
  295. if agencyId != "" && buyerId != "" && projectId != "" {
  296. key = fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
  297. key1 := fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
  298. if _, ok := agencyIdMap[key]; ok {
  299. data := agencyMap[key]
  300. data["count"] = gconv.Int64(data["data"]) + 1
  301. dataList := gconv.Maps(data["list"])
  302. dataList = append(dataList, map[string]interface{}{
  303. "zbtime": zbtime,
  304. "projectId": projectId,
  305. "projectName": projectName,
  306. })
  307. data["list"] = dataList
  308. agencyMap[key] = data
  309. } else {
  310. agencyIdMap[key] = true
  311. agencyMap[key1] = map[string]interface{}{
  312. "b_id": agencyId,
  313. "b_name": agency,
  314. "a_name": buyer,
  315. "a_id": buyerId,
  316. "sourceType": "agency",
  317. "count": 1,
  318. "personName": gconv.String(personMap[agencyId]),
  319. "list": []map[string]interface{}{
  320. {
  321. "zbtime": zbtime,
  322. "projectId": projectId,
  323. "projectName": projectName,
  324. },
  325. },
  326. }
  327. }
  328. }
  329. }
  330. for _, m := range winnerMap {
  331. returnData = append(returnData, map[string]interface{}{
  332. "b_id": gconv.String(m["b_id"]),
  333. "b_name": gconv.String(m["b_name"]),
  334. "a_name": gconv.String(m["a_name"]),
  335. "a_id": gconv.String(m["a_id"]),
  336. "sourceType": gconv.String(m["sourceType"]),
  337. "relationship": gconv.String(m["relationship"]),
  338. "count": gconv.Int64(m["count"]),
  339. "list": m["list"],
  340. })
  341. }
  342. for _, m := range agencyMap {
  343. returnData = append(returnData, map[string]interface{}{
  344. "b_id": gconv.String(m["b_id"]),
  345. "b_name": gconv.String(m["b_name"]),
  346. "a_name": gconv.String(m["a_name"]),
  347. "a_id": gconv.String(m["a_id"]),
  348. "sourceType": gconv.String(m["sourceType"]),
  349. "relationship": gconv.String(m["relationship"]),
  350. "count": gconv.Int64(m["count"]),
  351. "list": m["list"],
  352. })
  353. }
  354. }
  355. return returnData
  356. }
  357. // 中间人查询
  358. func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]interface{}) []map[string]interface{} {
  359. if len(buyerArr) == 0 {
  360. return returnData
  361. }
  362. //中间人 作为可介绍业主 企业名称
  363. companyArr := CrmMysql.SelectBySql(
  364. 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, ",")))
  365. for _, v := range *companyArr {
  366. companyId := gconv.String(v["company_id"])
  367. companyName := gconv.String(v["company_name"])
  368. relateName := gconv.String(v["relate_name"])
  369. relateId := gconv.String(v["relate_id"])
  370. //key := fmt.Sprintf("%s_%s", relateId, companyId)
  371. returnData = append(returnData, map[string]interface{}{
  372. "b_id": companyId,
  373. "b_name": companyName,
  374. "a_name": relateName,
  375. "a_id": relateId,
  376. "sourceType": "middleman",
  377. "relationship": "业主的关系人",
  378. "personName": gconv.String(v["contact_person"]),
  379. })
  380. }
  381. return returnData
  382. }
  383. // 企业之间关系查询
  384. func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
  385. if len(buyerArr) == 0 {
  386. return returnData
  387. }
  388. buyerSql := fmt.Sprintf(`select DISTINCT
  389. a.a_id as a_id,
  390. a.b_id as b_id,
  391. a.a_name as a_name,
  392. a.b_name as b_name,
  393. 111 as status,
  394. a.code as code
  395. from
  396. ent_map_code a
  397. where
  398. a.a_id in (%s)
  399. and a.code in('0101', '0201')
  400. UNION ALL
  401. select
  402. a.b_id as a_id,
  403. a.a_id as b_id,
  404. a.b_name as a_name,
  405. a.a_name as b_name,
  406. 222 as status,
  407. a.code as code
  408. from
  409. ent_map_code a
  410. where
  411. a.b_id in (%s)
  412. and a.code in('0101', '0201')`,
  413. strings.Join(buyerArr, ","),
  414. strings.Join(buyerArr, ","))
  415. relationshipArr := BuyerFindConnectionsHandle(buyerSql)
  416. if relationshipArr != nil && len(relationshipArr) > 0 {
  417. entIdArr := []string{}
  418. for _, v := range relationshipArr {
  419. if v.Bid != "" {
  420. entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.Bid))
  421. }
  422. }
  423. personMap := map[string]string{}
  424. if len(entIdArr) > 0 {
  425. personSql := fmt.Sprintf(`select id,name from ent_contact where id in (%s) ORDER by name`, strings.Join(entIdArr, ","))
  426. personArr := PersonFindConnectionsHandle(personSql)
  427. //联系人处理
  428. for _, v := range personArr {
  429. personMap[v.Id] = v.PersonName
  430. }
  431. }
  432. for _, v := range relationshipArr {
  433. code := v.Code
  434. status := v.Status
  435. if gconv.String(status) == "111" {
  436. //key := fmt.Sprintf("%s_%s", a_id, b_id)
  437. switch code {
  438. case "0101": //管辖关系
  439. returnData = append(returnData, map[string]interface{}{
  440. "b_id": v.Bid,
  441. "b_name": v.Bname,
  442. "a_name": v.Aname,
  443. "a_id": v.Aid,
  444. "sourceType": "firstparty",
  445. "relationship": "业主的下级机构",
  446. "personName": gconv.String(personMap[v.Bid]),
  447. })
  448. case "0201": //投资关系
  449. returnData = append(returnData, map[string]interface{}{
  450. "b_id": v.Bid,
  451. "b_name": v.Bname,
  452. "a_name": v.Aname,
  453. "a_id": v.Aid,
  454. "sourceType": "firstparty",
  455. "relationship": "业主的股东",
  456. "personName": gconv.String(personMap[v.Bid]),
  457. })
  458. }
  459. }
  460. if gconv.String(status) == "222" {
  461. //key := fmt.Sprintf("%s_%s", b_id, a_id)
  462. if code == "0101" {
  463. //"0101":管辖关系
  464. returnData = append(returnData, map[string]interface{}{
  465. "b_id": v.Bid,
  466. "b_name": v.Bname,
  467. "a_name": v.Aname,
  468. "a_id": v.Aid,
  469. "sourceType": "firstparty",
  470. "relationship": "业主的上级机构",
  471. "personName": gconv.String(personMap[v.Aid]),
  472. })
  473. }
  474. if code == "0201" {
  475. returnData = append(returnData, map[string]interface{}{
  476. "b_id": v.Bid,
  477. "b_name": v.Bname,
  478. "a_name": v.Aname,
  479. "a_id": v.Aid,
  480. "sourceType": "firstparty",
  481. "relationship": "业主的股东",
  482. "personName": gconv.String(personMap[v.Aid]),
  483. })
  484. }
  485. }
  486. }
  487. }
  488. return returnData
  489. }
  490. // 采购单位和项目合并
  491. func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, sourceType string) ([]BuyerProject, int64, int64, int64) {
  492. returnData := []BuyerProject{}
  493. connectionsNumber := int64(0)
  494. highSuccessNumber := int64(0)
  495. monitorNumber := int64(0)
  496. for buyerId, buyerMap := range *dataMap {
  497. buyerName := gconv.String(buyerMap["buyerName"])
  498. count := int64(0)
  499. if _, ok := (*projectMap)[buyerName]; ok {
  500. projectMap := (*projectMap)[buyerName]
  501. if isMonitor := gconv.Bool(buyerMap["isMonitor"]); isMonitor {
  502. monitorNumber++
  503. }
  504. count = gconv.Int64(projectMap["count"])
  505. money := gconv.Int64(projectMap["money"])
  506. zbtime := gconv.Int64(projectMap["zbtime"])
  507. if count >= 2 {
  508. highSuccessNumber++
  509. }
  510. if sourceType == "1" {
  511. if count < 2 {
  512. continue
  513. }
  514. }
  515. returnData = append(returnData, BuyerProject{
  516. BuyerId: buyerId,
  517. BuyerName: buyerName,
  518. Project: ProjectEntity{
  519. Number: count,
  520. EstimatedAmount: money,
  521. Connections: []map[string]interface{}{},
  522. },
  523. Area: gconv.String(projectMap["area"]),
  524. Zbtime: zbtime,
  525. IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
  526. IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
  527. IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
  528. })
  529. } else {
  530. if sourceType == "1" {
  531. if count < 2 {
  532. continue
  533. }
  534. }
  535. returnData = append(returnData, BuyerProject{
  536. BuyerId: buyerId,
  537. BuyerName: buyerName,
  538. Project: ProjectEntity{
  539. Number: 0,
  540. EstimatedAmount: 0,
  541. Connections: []map[string]interface{}{},
  542. },
  543. Area: "",
  544. Zbtime: 0,
  545. IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
  546. IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
  547. IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
  548. })
  549. }
  550. connectionsNumber++
  551. }
  552. return returnData, connectionsNumber, highSuccessNumber, monitorNumber
  553. }
  554. // 已监控数据处理
  555. func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, sourceType string) {
  556. monitorMap := map[string]bool{}
  557. query := map[string]interface{}{
  558. "userId": gconv.String(positionId),
  559. }
  560. clist, ok := Mgo.Find("follow_customer", query, ``, `{"name":1}`, false, -1, -1)
  561. if ok && clist != nil && len(*clist) > 0 {
  562. for _, v := range *clist {
  563. monitorMap[gconv.String(v["name"])] = true
  564. }
  565. }
  566. //采购单位和自己监控的对比
  567. newMap := &map[string]map[string]interface{}{}
  568. for k, v := range *dataMap {
  569. buyerName := gconv.String(v["buyerName"])
  570. if _, ok1 := monitorMap[gconv.String(buyerName)]; ok1 {
  571. v["isMonitor"] = true
  572. (*newMap)[k] = v
  573. } else {
  574. if sourceType != "2" {
  575. v["isMonitor"] = false
  576. (*newMap)[k] = v
  577. }
  578. }
  579. }
  580. if sourceType == "2" {
  581. *dataMap = *newMap
  582. return
  583. }
  584. if newMap != nil {
  585. *dataMap = *newMap
  586. }
  587. }
  588. func FindStatus(positionId int64) (map[string]bool, map[string]bool, map[string]bool) {
  589. //未处理
  590. untreatedMap := map[string]bool{}
  591. //已忽略
  592. ignoredMap := map[string]bool{}
  593. //已创建
  594. createdMap := map[string]bool{}
  595. processingArr := CrmMysql.Find(entity.CONNECTION_STATUS, map[string]interface{}{
  596. "itype": 1,
  597. "position_id": positionId,
  598. }, "relate_id,is_handle,is_ignore,is_create", "", -1, -1)
  599. if processingArr != nil && len(*processingArr) > 0 {
  600. for _, v := range *processingArr {
  601. entId := gconv.String(v["relate_id"])
  602. handle := gconv.Int64(v["is_handle"])
  603. ignore := gconv.Int64(v["is_ignore"])
  604. create := gconv.Int64(v["is_create"])
  605. if handle == 1 {
  606. untreatedMap[entId] = true
  607. }
  608. if ignore == 1 {
  609. ignoredMap[entId] = true
  610. }
  611. if create == 1 {
  612. createdMap[entId] = true
  613. }
  614. }
  615. }
  616. return untreatedMap, ignoredMap, createdMap
  617. }
  618. // 处理状态初始化
  619. func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, processingStatus string) {
  620. //收录数据处理
  621. untreatedMap, ignoredMap, createdMap := FindStatus(positionId)
  622. newMap := &map[string]map[string]interface{}{}
  623. //所有采购单位和处理状态对比
  624. for buyerId, value := range *dataMap {
  625. if _, ok := ignoredMap[buyerId]; ok {
  626. value["isIgnore"] = true
  627. }
  628. if _, ok := createdMap[buyerId]; ok {
  629. value["isCreateCustomer"] = true
  630. }
  631. for _, v := range strings.Split(processingStatus, ",") {
  632. switch v {
  633. case "1":
  634. if _, ok := untreatedMap[buyerId]; !ok {
  635. (*newMap)[buyerId] = value
  636. }
  637. case "2":
  638. if _, ok := ignoredMap[buyerId]; ok {
  639. (*newMap)[buyerId] = value
  640. }
  641. case "3":
  642. if _, ok := createdMap[buyerId]; ok {
  643. (*newMap)[buyerId] = value
  644. }
  645. case "全部", "":
  646. (*newMap)[buyerId] = value
  647. }
  648. }
  649. }
  650. if newMap != nil {
  651. *dataMap = *newMap
  652. }
  653. }
  654. // 采购单位查询
  655. func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, positionId int64) *map[string]map[string]interface{} {
  656. dataMap := &map[string]map[string]interface{}{}
  657. //甲方
  658. if partyA != "" {
  659. intermediaryArr := []string{}
  660. for _, v := range strings.Split(partyA, ",") {
  661. if v != "" {
  662. intermediaryArr = append(intermediaryArr, fmt.Sprintf("'%s'", v))
  663. }
  664. }
  665. if len(partyA) > 0 {
  666. partyASql := fmt.Sprintf(`select id as buyer_id,company_name as buyer from ent_info where id in (%s)`, strings.Join(intermediaryArr, ","))
  667. FindHandle(partyASql, dataMap)
  668. }
  669. }
  670. //供应商 //同甲异业
  671. findInSetArr := []string{}
  672. if supplier != "" {
  673. for _, v := range strings.Split(supplier, ",") {
  674. if v != "" {
  675. findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
  676. }
  677. }
  678. }
  679. //同甲异业
  680. if heterotophy != "" {
  681. for _, v := range strings.Split(heterotophy, ",") {
  682. if v != "" {
  683. findInSetArr = append(findInSetArr, fmt.Sprintf("'%s'", v))
  684. }
  685. }
  686. }
  687. if len(findInSetArr) > 0 {
  688. sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where hasAny(winner_id,[%s]) `, strings.Join(findInSetArr, ","))
  689. FindHandle(sqlStr, dataMap)
  690. }
  691. //中间人
  692. if intermediary != "" {
  693. wh, args := common.WhArgs(strings.Split(intermediary, ","))
  694. args = append(args, positionId)
  695. 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...)
  696. if intermediaryArr != nil && len(*intermediaryArr) > 0 {
  697. for _, m := range *intermediaryArr {
  698. buyerId := gconv.String(m["relate_id"])
  699. buyerName := gconv.String(m["relate_name"])
  700. (*dataMap)[buyerId] = map[string]interface{}{
  701. "buyerName": buyerName,
  702. }
  703. }
  704. }
  705. }
  706. //招标代理
  707. if agency != "" {
  708. agencyArr := []string{}
  709. for _, s := range strings.Split(agency, ",") {
  710. agencyArr = append(agencyArr, fmt.Sprintf("'%s'", s))
  711. }
  712. sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where agency_id in (%s) `, strings.Join(agencyArr, ","))
  713. FindHandle(sqlStr, dataMap)
  714. }
  715. return dataMap
  716. }
  717. // 项目数量查询
  718. func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, projectType string, dataMap *map[string]map[string]interface{}) (*map[string]map[string]interface{}, *map[string]map[string]interface{}, *map[string]map[string]interface{}) {
  719. projectMap := &map[string]map[string]interface{}{}
  720. returnMap := &map[string]map[string]interface{}{}
  721. sql := ""
  722. sqlStr := ""
  723. propertyFormStr := ""
  724. if projectType == "1" {
  725. propertyForm := ""
  726. m1 := CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": entAccountId}, "probusfor", "")
  727. if m1 != nil && len(*m1) > 0 {
  728. propertyForm = common.ObjToString((*m1)["probusfor"])
  729. if propertyForm != "" {
  730. propertyFormStr = fmt.Sprintf(`,{"match":{"property_form":"%s"}}`, propertyForm)
  731. }
  732. }
  733. }
  734. if entName != "" {
  735. sql = `{"query":{"bool":{"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%s%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
  736. sqlStr = fmt.Sprintf(sql, entName, common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), common.If(projectType == "1", propertyFormStr, ""))
  737. } else {
  738. sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}}%s%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
  739. sqlStr = fmt.Sprintf(sql, strings.Join(buyerArr, ","), common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), common.If(projectType == "1", propertyFormStr, ""))
  740. }
  741. startTime := time.Now().Unix()
  742. data, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, sqlStr)
  743. endTime := time.Now().Unix()
  744. fmt.Println("es用时时间:", endTime-startTime)
  745. if len(data) == 0 {
  746. return projectMap, returnMap, dataMap
  747. }
  748. for _, object := range data {
  749. buyerArr := BuyerAggStruct{}
  750. bs, ok := object.MarshalJSON()
  751. if ok != nil {
  752. logx.Error("解析项目数据失败", object)
  753. continue
  754. }
  755. err := json.Unmarshal(bs, &buyerArr)
  756. if err != nil {
  757. logx.Error(err)
  758. }
  759. for _, v := range buyerArr.Buckets {
  760. buyerName := v.Key
  761. area := ""
  762. buyerId := ""
  763. for _, areaEntity := range v.Area_count.Buckets {
  764. area = Deduplication(area, areaEntity.Key)
  765. }
  766. for _, buyerIdEntity := range v.Buyer_id.Buckets {
  767. if buyerIdEntity.Key != "" {
  768. buyerId = buyerIdEntity.Key
  769. }
  770. }
  771. (*projectMap)[buyerName] = map[string]interface{}{
  772. "area": area,
  773. "zbtime": v.Zbtime_count.Value,
  774. "money": common.RetainDecimal(common.Float64All(v.Money_count.Value)/10000, 2),
  775. "count": v.Doc_count,
  776. "buyerId": buyerId,
  777. }
  778. (*returnMap)[buyerId] = map[string]interface{}{
  779. "buyerName": buyerName,
  780. }
  781. }
  782. }
  783. if projectType == "1" || area != "" {
  784. if entName == "" {
  785. for buyerId, v := range *dataMap {
  786. buyerName := gconv.String(v["buyerName"])
  787. if _, ok := (*projectMap)[buyerName]; !ok {
  788. delete(*dataMap, buyerId)
  789. }
  790. }
  791. } else {
  792. for buyerId, v := range *returnMap {
  793. buyerName := gconv.String(v["buyerName"])
  794. if _, ok := (*projectMap)[buyerName]; !ok {
  795. delete(*returnMap, buyerId)
  796. }
  797. }
  798. }
  799. }
  800. return projectMap, returnMap, dataMap
  801. }
  802. type BuyerAggStruct struct {
  803. Buckets []struct {
  804. Key string `json:"key,omitempty"`
  805. Doc_count int64 `json:"doc_count,omitempty"`
  806. Zbtime_count struct {
  807. Value interface{} `json:"value,omitempty"`
  808. } `json:"zbtime_count,omitempty"`
  809. Money_count struct {
  810. Value interface{} `json:"value,omitempty"`
  811. } `json:"money_count,omitempty"`
  812. Area_count struct {
  813. Buckets []struct {
  814. Key string `json:"key,omitempty"`
  815. Doc_count int64 `json:"doc_count,omitempty"`
  816. }
  817. } `json:"area_count"`
  818. Buyer_id struct {
  819. Buckets []struct {
  820. Key string `json:"key,omitempty"`
  821. Doc_count int64 `json:"doc_count,omitempty"`
  822. }
  823. } `json:"buyer_id"`
  824. }
  825. }
  826. // 采购单位查询sql
  827. func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
  828. rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
  829. if err != nil {
  830. logx.Error("查询失败", sqlStr, err)
  831. }
  832. for rows.Next() {
  833. data := Recommend{}
  834. rows.ScanStruct(&data)
  835. if data.BuyerId != "" {
  836. (*dataMap)[data.BuyerId] = map[string]interface{}{
  837. "buyerName": data.Buyer,
  838. }
  839. }
  840. }
  841. return
  842. }
  843. type ConnectionsEntity struct {
  844. Aid string `ch:"a_id"`
  845. Bid string `ch:"b_id"`
  846. Aname string `ch:"a_name"`
  847. Bname string `ch:"b_name"`
  848. Status uint8 `ch:"status"`
  849. Code string `ch:"code"`
  850. Cperson string `ch:"c_person"`
  851. }
  852. type PersonEntity struct {
  853. Id string `ch:"id"`
  854. PersonName string `ch:"personName"`
  855. }
  856. type SupplierConnectionsEntity struct {
  857. Zbtime int64 `ch:"zbtime"`
  858. Project_id string `ch:"project_id"`
  859. Project_name string `ch:"project_name"`
  860. Buyer_id string `ch:"buyer_id"`
  861. Buyer string `ch:"buyer"`
  862. Agency_id string `ch:"agency_id"`
  863. Agency string `ch:"agency"`
  864. WinnerId []string `ch:"winner_id"`
  865. Winner []string `ch:"winner"`
  866. }
  867. type SupplierConnectionsEntitys struct {
  868. Zbtime int64
  869. Project_id string
  870. Project_name string
  871. Buyer_id string
  872. Buyer string
  873. Agency_id string
  874. Agency string
  875. WinnerId string
  876. Winner string
  877. }
  878. type TimeConnectionsEntity struct {
  879. Zbtime int64 `ch:"zbtime"`
  880. Project_id string `ch:"project_id"`
  881. Project_name string `ch:"project_name"`
  882. }
  883. // 采购单位人脉信息查询sql
  884. func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
  885. returnData := []ConnectionsEntity{}
  886. rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
  887. if err != nil {
  888. logx.Error("查询失败", sqlStr, err)
  889. }
  890. for rows.Next() {
  891. data := ConnectionsEntity{}
  892. err := rows.ScanStruct(&data)
  893. logx.Info(err)
  894. returnData = append(returnData, data)
  895. }
  896. return returnData
  897. }
  898. func PersonFindConnectionsHandle(sqlStr string) []PersonEntity {
  899. returnData := []PersonEntity{}
  900. rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
  901. if err != nil {
  902. logx.Error("查询失败", sqlStr, err)
  903. }
  904. for rows.Next() {
  905. data := PersonEntity{}
  906. rows.ScanStruct(&data)
  907. returnData = append(returnData, data)
  908. }
  909. return returnData
  910. }
  911. // 供应商
  912. func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntitys {
  913. returnData := []SupplierConnectionsEntitys{}
  914. rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
  915. if err != nil {
  916. logx.Error("查询失败", sqlStr, err)
  917. }
  918. for rows.Next() {
  919. data := SupplierConnectionsEntity{}
  920. err = rows.ScanStruct(&data)
  921. if err != nil {
  922. logx.Error(err)
  923. }
  924. if len(data.Winner) == 0 {
  925. returnData = append(returnData, SupplierConnectionsEntitys{
  926. Zbtime: data.Zbtime,
  927. Project_id: data.Project_id,
  928. Project_name: data.Project_name,
  929. Buyer_id: data.Buyer_id,
  930. Buyer: data.Buyer,
  931. Agency_id: data.Agency_id,
  932. Agency: data.Agency,
  933. WinnerId: "",
  934. Winner: "",
  935. })
  936. } else {
  937. for k, v := range data.WinnerId {
  938. fmt.Println(k, len(data.Winner))
  939. if k+1 > len(data.Winner) {
  940. continue
  941. }
  942. returnData = append(returnData, SupplierConnectionsEntitys{
  943. Zbtime: data.Zbtime,
  944. Project_id: data.Project_id,
  945. Project_name: data.Project_name,
  946. Buyer_id: data.Buyer_id,
  947. Buyer: data.Buyer,
  948. Agency_id: data.Agency_id,
  949. Agency: data.Agency,
  950. WinnerId: gconv.String(v),
  951. Winner: gconv.String(data.Winner[k]),
  952. })
  953. }
  954. }
  955. }
  956. return returnData
  957. }
  958. // 合作时间查询
  959. func TimeFindConnectionsHandle(sqlStr string) []TimeConnectionsEntity {
  960. returnData := []TimeConnectionsEntity{}
  961. rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
  962. if err != nil {
  963. logx.Error("查询失败", sqlStr, err)
  964. }
  965. for rows.Next() {
  966. data := TimeConnectionsEntity{}
  967. rows.ScanStruct(&data)
  968. returnData = append(returnData, data)
  969. }
  970. return returnData
  971. }
  972. // 去重处理
  973. func Deduplication(a, b string) string {
  974. newArr := []string{}
  975. if b == "全国" {
  976. return a
  977. }
  978. if a != "" {
  979. newArr = append(newArr, a)
  980. }
  981. if b != "" {
  982. newArr = append(newArr, b)
  983. }
  984. return strings.Join(newArr, ",")
  985. }
  986. // 路径列表
  987. func (t *OwnerService) OwnerRoute() []map[string]interface{} {
  988. if t.BuyerId == "" {
  989. return []map[string]interface{}{}
  990. }
  991. routeList := ConnectionsHandle([]string{
  992. fmt.Sprintf("'%s'", t.BuyerId),
  993. }, t.PositionId, false)
  994. for i, routeMap := range routeList {
  995. sourceType := gconv.String(routeMap["sourceType"])
  996. if sourceType == "agency" || sourceType == "supplier" {
  997. data := routeList[i]
  998. data["cooperateCount"] = len(gconv.Maps(data["list"]))
  999. delete(data, "list")
  1000. routeList[i] = data
  1001. }
  1002. }
  1003. return routeList
  1004. }
  1005. // 合作列表
  1006. func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
  1007. returData := []map[string]interface{}{}
  1008. dataArr := []TimeConnectionsEntity{}
  1009. if t.CooperateType == "supplier" {
  1010. //供应商
  1011. supplierSql := fmt.Sprintf(`SELECT
  1012. zbtime,
  1013. project_id,
  1014. project_name
  1015. FROM
  1016. transaction_info
  1017. ARRAY
  1018. JOIN winner_id as winnerId
  1019. where buyer_id= '%s' and winnerId='%s' order by zbtime DESC,project_id DESC `, t.BuyerId, t.WinnerId)
  1020. dataArr = TimeFindConnectionsHandle(supplierSql)
  1021. } else if t.CooperateType == "agency" {
  1022. //代理机构
  1023. agentSql := fmt.Sprintf(`select zbtime,project_id,project_name from transaction_info where buyer_id ='%s' and agency_id ='%s' order by zbtime DESC,project_id DESC `, t.BuyerId, t.WinnerId)
  1024. dataArr = TimeFindConnectionsHandle(agentSql)
  1025. }
  1026. if dataArr != nil && len(dataArr) > 0 {
  1027. for _, m := range dataArr {
  1028. zbtime := m.Zbtime
  1029. returData = append(returData, map[string]interface{}{
  1030. "zbtime": common.If(zbtime == 0, "", time.Unix(zbtime, 10).Format("2006.01.02")),
  1031. "entName": t.WinnerName,
  1032. "projectId": encrypt.EncodeArticleId2ByCheck(m.Project_id),
  1033. "projectName": m.Project_name,
  1034. })
  1035. }
  1036. }
  1037. return returData
  1038. }
  1039. func (t *OwnerService) CandidateChannel() ([]*ResultData, int, int, int, int) {
  1040. returnData := []*ResultData{}
  1041. dataMap := &map[string]map[string]interface{}{}
  1042. if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
  1043. dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
  1044. }
  1045. a1, a2, a3, a4 := 0, 0, 0, 0
  1046. if len(*dataMap) > 0 && dataMap != nil {
  1047. propertyForm := NetworkCom.GetMyProbusfor(t.EntAccountId)
  1048. for buyerId := range *dataMap {
  1049. r1, r2 := GetData(propertyForm, buyerId)
  1050. if r1 != nil && len(r1) > 0 {
  1051. for _, m := range r1 {
  1052. near, zbtime := LastTimeCoop(buyerId, common.ObjToString(m["name"]), "adiffb")
  1053. tmp := ResultData{
  1054. SourceType: "adiffb",
  1055. EntName: common.ObjToString(m["name"]),
  1056. ProjectNum: common.IntAll(m["coop_size"]),
  1057. TotalAmount: common.Float64All(m["coop_amount"]),
  1058. RecentTime: zbtime,
  1059. NearlyYears: near,
  1060. }
  1061. a1++
  1062. returnData = append(returnData, &tmp)
  1063. }
  1064. }
  1065. if r2 != nil && len(r2) > 0 {
  1066. for _, m := range r2 {
  1067. near, zbtime := LastTimeCoop(buyerId, common.ObjToString(m["name"]), "agency")
  1068. tmp := ResultData{
  1069. SourceType: "agency",
  1070. EntName: common.ObjToString(m["name"]),
  1071. ProjectNum: common.IntAll(m["coop_size"]),
  1072. TotalAmount: common.Float64All(m["coop_amount"]),
  1073. RecentTime: zbtime,
  1074. NearlyYears: near,
  1075. BuyerId: common.ObjToString(m["nameId"]),
  1076. }
  1077. a2++
  1078. returnData = append(returnData, &tmp)
  1079. }
  1080. }
  1081. // 中间人可介绍业主
  1082. var r3 []map[string]interface{}
  1083. r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", buyerId)}, t.PositionId, r3)
  1084. if r3 != nil && len(r3) > 0 {
  1085. for _, m := range r3 {
  1086. tmp := ResultData{
  1087. SourceType: "middleman",
  1088. EntName: common.ObjToString(m["b_name"]),
  1089. EntPerson: common.ObjToString(m["personName"]),
  1090. Relationship: "业主的关系人",
  1091. BuyerId: common.ObjToString(m["b_id"]),
  1092. }
  1093. a3++
  1094. returnData = append(returnData, &tmp)
  1095. }
  1096. }
  1097. // 关联单位
  1098. var r4 []map[string]interface{}
  1099. r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", buyerId)}, r4)
  1100. if r4 != nil && len(r4) > 0 {
  1101. for _, m := range r4 {
  1102. tmp := ResultData{
  1103. SourceType: "sup_sub",
  1104. EntName: common.ObjToString(m["b_name"]),
  1105. EntPerson: common.ObjToString(m["personName"]),
  1106. Relationship: common.ObjToString(m["relationship"]),
  1107. BuyerId: common.ObjToString(m["b_id"]),
  1108. }
  1109. a4++
  1110. returnData = append(returnData, &tmp)
  1111. }
  1112. }
  1113. }
  1114. }
  1115. //状态处理
  1116. result := []*ResultData{}
  1117. if len(returnData) > 0 {
  1118. monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
  1119. _, ignoredMap, createdMap := FindStatus(t.PositionId)
  1120. for k, value := range returnData {
  1121. buyerId := value.BuyerId
  1122. if _, ok := ignoredMap[buyerId]; ok {
  1123. value.IsIgnore = true
  1124. }
  1125. if _, ok := createdMap[buyerId]; ok {
  1126. value.IsCreateCustomer = true
  1127. }
  1128. if _, ok := monitorMap[value.EntName]; ok {
  1129. value.IsMonitor = true
  1130. }
  1131. returnData[k] = value
  1132. if t.Type != "" && t.Type != value.SourceType {
  1133. continue
  1134. }
  1135. result = append(result, value)
  1136. }
  1137. }
  1138. return result, a1, a2, a3, a4
  1139. }