employService.go 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. package service
  2. import (
  3. "database/sql"
  4. "fmt"
  5. "log"
  6. "strings"
  7. "time"
  8. "app.yhyue.com/moapp/jybase/common"
  9. "app.yhyue.com/moapp/jybase/date"
  10. elastic "app.yhyue.com/moapp/jybase/es"
  11. "app.yhyue.com/moapp/jypkg/ent/util"
  12. MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
  13. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  14. "bp.jydev.jianyu360.cn/CRM/application/entity"
  15. "github.com/RoaringBitmap/roaring"
  16. "github.com/gogf/gf/v2/util/gconv"
  17. )
  18. const (
  19. BuyerIndex = "buyer" // 采购单位index
  20. BuyerType = "buyer"
  21. INDEX = "bidding"
  22. TYPE = "bidding"
  23. )
  24. type EmPloyService struct{}
  25. type PersonSmmary struct {
  26. EntUserId int64
  27. EntDeptId int64
  28. Summary map[int64]*roaring.Bitmap
  29. }
  30. // InfoEmployinfo 收录情况查询
  31. func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) ([]map[string]interface{}, int64) {
  32. var data []map[string]interface{}
  33. depIDArr := ""
  34. batchEmploy := int64(0)
  35. if in.EntNicheDis > 0 {
  36. //查询所有部门标识
  37. deptArr := MC.MainMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a"+
  38. " INNER JOIN entniche_department b "+
  39. "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", in.EntId, in.EntDeptId, in.EntDeptId)
  40. if len(*deptArr) == 0 {
  41. return data, batchEmploy
  42. }
  43. depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
  44. if depIDArr == "" {
  45. return data, batchEmploy
  46. }
  47. }
  48. //是否可以批量收录配置回显
  49. accountId := int64(0)
  50. if in.PositionType == 0 {
  51. accountId = in.AccountId
  52. } else {
  53. accountId = in.EntAccountId
  54. }
  55. configData := MC.CrmMysql.FindOne("config_tenant", map[string]interface{}{
  56. "account_id": accountId,
  57. }, "batch_employ", "")
  58. if configData != nil {
  59. batchEmploy = gconv.Int64((*configData)["batch_employ"])
  60. }
  61. //版本查询
  62. res := MC.Middleground.ResourceCenter.Haspowers(in.AccountId, in.EntAccountId, in.EntId, in.EntUserId)
  63. version := 0
  64. for _, pCode := range res.Powers {
  65. //0:通用版 1:物业专版
  66. if pCode == "bi_yx_wyzb" {
  67. version = 1
  68. }
  69. }
  70. infoId1Arr := []string{}
  71. niJianIdArr := []string{}
  72. infoId2Arr := []string{}
  73. wuye1Arr := []string{}
  74. wuye2Arr := []string{}
  75. infoMap := map[string]interface{}{}
  76. table, findKey, employKey, employData := employKeyFormat(in.EmployType, in.IdArr)
  77. for _, employ := range employData {
  78. source := employ.Source
  79. isNiJian := employ.IsNiJian
  80. if (employ.Subtype == "成交" || employ.Subtype == "中标" || employ.Subtype == "合同" || employ.Subtype == "验收" || employ.Subtype == "违规") && in.EmployType == 1 && version == 1 {
  81. infoMap[employ.Id] = employ.ProjectId
  82. if isNiJian {
  83. infoMap[employ.Id] = employ.ProjectId
  84. if source == 1 {
  85. wuye1Arr = append(wuye1Arr, employ.ProjectId)
  86. } else {
  87. wuye2Arr = append(wuye2Arr, employ.ProjectId)
  88. }
  89. } else {
  90. infoMap[employ.Id] = employ.SourceId
  91. if source == 1 {
  92. wuye1Arr = append(wuye1Arr, employ.SourceId)
  93. } else {
  94. wuye2Arr = append(wuye2Arr, employ.SourceId)
  95. }
  96. }
  97. } else if isNiJian {
  98. infoMap[employ.Id] = employ.ProjectId
  99. niJianIdArr = append(niJianIdArr, employ.ProjectId)
  100. } else if source == 2 {
  101. infoMap[employ.Id] = employ.SourceId
  102. infoId2Arr = append(infoId2Arr, employ.SourceId)
  103. } else if source == 1 {
  104. infoMap[employ.Id] = employ.SourceId
  105. infoId1Arr = append(infoId1Arr, employ.SourceId)
  106. }
  107. }
  108. //收录情况查询
  109. dataList := map[string]map[string]interface{}{}
  110. if in.EntNicheDis > 0 {
  111. dataList = employInfoEnt(table, employKey, findKey, depIDArr, in, version, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr)
  112. } else {
  113. dataList = employInfoPerson(table, employKey, findKey, in, version, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr)
  114. }
  115. for k, v := range infoMap {
  116. fool := true
  117. for sourceId, v1 := range dataList {
  118. if v == sourceId {
  119. v1["id"] = k
  120. data = append(data, v1)
  121. fool = false
  122. break
  123. }
  124. }
  125. if fool {
  126. data = append(data, map[string]interface{}{
  127. "id": k,
  128. "isIgnore": false,
  129. "isEmploy": false,
  130. "customCount": 0,
  131. "clueCount": 0,
  132. "chanceCount": 0,
  133. "type": 1,
  134. "employId": 0,
  135. })
  136. }
  137. }
  138. return data, batchEmploy
  139. }
  140. // EmployOperate 收录操作
  141. func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) (bool, string) {
  142. log.Println("收录入参", in)
  143. //收录汇总表
  144. //summaryMap := SummaryFormat(in.PositionId)
  145. msg := ""
  146. return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
  147. fool := false
  148. //id转中文
  149. table, _, employKey, data := employKeyFormat(in.EmployType, in.IdArr)
  150. for id, employ := range data {
  151. findMap := map[string]interface{}{}
  152. findMap["position_id"] = in.PositionId
  153. if employ.IsNiJian {
  154. findMap[employKey] = employ.ProjectId
  155. } else {
  156. findMap[employKey] = id
  157. }
  158. if employ.SourceId == "" {
  159. log.Println(employ.Id, in.EmployType, "该信息查询不到数据")
  160. continue
  161. }
  162. if in.IsEmploy {
  163. if MC.CrmMysql.Count(table, findMap) > 0 {
  164. MC.CrmMysql.UpdateByTx(tx, table, findMap, map[string]interface{}{
  165. "status": 1,
  166. })
  167. } else {
  168. //收录新增
  169. data := map[string]interface{}{}
  170. if in.EmployType == 1 || in.EmployType == 4 {
  171. data = infoFind(id, employ.Id)
  172. } else if in.EmployType == 2 {
  173. data = customFind(id, in.EmployType)
  174. data["jybx_url"] = "/swordfish/page_big_pc/ent_portrait/" + employ.Id
  175. data["source"] = employ.Source
  176. } else if in.EmployType == 3 {
  177. data = customFind(id, in.EmployType)
  178. data["jybx_url"] = "/publicapply/biTransfer?buyerName=" + employ.Id
  179. data["source"] = employ.Source
  180. }
  181. data["position_id"] = in.PositionId
  182. data["ent_id"] = in.EntId
  183. data["ent_dept_id"] = in.EntDeptId
  184. data["ent_user_id"] = in.EntUserId
  185. ok := MC.CrmMysql.InsertByTx(tx, table, data)
  186. if ok <= 0 {
  187. log.Println(employ.Id, id, in.EmployType, "收录失败")
  188. continue
  189. }
  190. }
  191. fool = true
  192. } else {
  193. //取消收录
  194. if in.From == "jhfp" {
  195. findMap["type"] = 3
  196. }
  197. if MC.CrmMysql.Count(table, findMap) > 0 {
  198. ok := MC.CrmMysql.UpdateByTx(tx, table, findMap, map[string]interface{}{
  199. "status": -1,
  200. })
  201. if !ok {
  202. log.Println(employ.Id, id, in.EmployType, "取消收录失败")
  203. continue
  204. }
  205. fool = true
  206. } else {
  207. if in.EmployType == 1 {
  208. msg = "该资讯已有员工收录,不可取消收录。"
  209. continue
  210. } else {
  211. msg = "该企业已有员工收录,不可取消收录。"
  212. continue
  213. }
  214. }
  215. }
  216. }
  217. if in.IsEmploy && !fool {
  218. msg = "收录失败"
  219. }
  220. return fool
  221. }), msg
  222. }
  223. // customFind 企业信息查询
  224. func customFind(id string, employType int64) map[string]interface{} {
  225. data := map[string]interface{}{}
  226. //company_id 企业id name户名称 address 地址 industry 行业
  227. if employType == 2 {
  228. //企业详情
  229. entinfo, _ := MC.MgoEnt.FindOneByField("qyxy_std", map[string]interface{}{"_id": id}, map[string]interface{}{
  230. "company_address": 1, //注册地
  231. "company_name": 1,
  232. })
  233. if entinfo != nil && len(*entinfo) > 0 {
  234. data["name"] = (*entinfo)["company_name"]
  235. data["address"] = (*entinfo)["company_address"]
  236. data["company_id"] = id
  237. }
  238. } else {
  239. //采购单位详情
  240. rs := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"_id":["%s"]}}]}},"size":1,"_source":["buyer_name","city"]}`, id))
  241. if rs != nil && len(*rs) > 0 {
  242. data["name"] = (*rs)[0]["buyer_name"]
  243. data["address"] = (*rs)[0]["city"]
  244. data["company_id"] = id
  245. }
  246. }
  247. data["status"] = 1
  248. data["create_time"] = time.Now().Format(date.Date_Full_Layout)
  249. return data
  250. }
  251. // infoFind 标讯信息查询
  252. func infoFind(id string, v1 string) map[string]interface{} {
  253. data := map[string]interface{}{}
  254. //source_id 信息id、项目id- title 标题-area 省 -city 市 -subtype 信息类型二级分类
  255. //buyerclass 采购单位行业 -budget 预算 -bidamount 中标金额 buyer采购单位 annex有无附件 publishtime发布时间 projectname 项目时间
  256. //ownerclass 业主类型(拟在建搜索) expurasing_time 预计采购时间 jybx_url 标讯详情页
  257. //标讯信息
  258. obj := map[string]interface{}{}
  259. aobj := elastic.Get(INDEX, TYPE, fmt.Sprintf(`{"query":{"bool":{"must":[{"match":{"id":"%s"}}],"must_not":[],"should":[]}},"from":0,"size":10,"_source":["_id","purchasinglist","projectname","projectcode","title","s_winner","buyertel","bidstatus","site","bidamount","toptype","winneraddr","winner","agency","buyer","detail","city","subtype","buyerclass","href","comeintime","winnertel","area","publishtime","buyeraddr","agencytel","budget","entidlist","buyerperson","winnerperson","agencyaddr","recommended_service","competehref","owner","total_investment","projectaddr","projectperiod","approvedept","approvecontent","approvecode","approvenumber","approvetime","approvestatus","project_scale"],"sort":[],"aggs":{}}`, id))
  260. log.Println(len(*aobj))
  261. if aobj != nil || *aobj != nil || len(*aobj) > 0 {
  262. obj = (*aobj)[0]
  263. }
  264. toptype := common.InterfaceToStr(obj["toptype"])
  265. subtype := common.InterfaceToStr(obj["subtype"])
  266. pushTime := ""
  267. if obj != nil && len(obj) > 0 {
  268. data["title"] = common.ObjToString(obj["title"])
  269. city := gconv.String(obj["city"])
  270. area := gconv.String(obj["area"])
  271. data["city"] = city
  272. data["area"] = area
  273. //省份代码处理
  274. areaCode := ""
  275. if MC.AreaCodeMap[city] != "" {
  276. areaCode = MC.AreaCodeMap[city]
  277. } else {
  278. areaCode = MC.AreaCodeMap[area]
  279. }
  280. data["area_code"] = areaCode
  281. data["subtype"] = obj["subtype"]
  282. data["buyerclass"] = obj["buyerclass"]
  283. data["budget"] = obj["budget"]
  284. data["bidamount"] = obj["bidamount"]
  285. data["annex"] = 0
  286. data["buyer"] = obj["buyer"]
  287. data["winner"] = obj["s_winner"]
  288. data["jybx_url"] = "/article/content/" + v1 + ".html"
  289. //类型处理
  290. pushTime = time.Unix(common.Int64All(obj["publishtime"]), 0).Format(date.Date_Full_Layout)
  291. data["source"] = 1
  292. data["source_id"] = id
  293. if subtype == "拟建" {
  294. data["source"] = 2
  295. }
  296. if toptype == "采购意向" || toptype == "预告" || toptype == "招标" || toptype == "" {
  297. data["type"] = 2
  298. } else {
  299. if subtype == "废标" || subtype == "流标" || subtype == "其它" {
  300. data["type"] = 2
  301. } else if subtype == "成交" || subtype == "中标" || subtype == "合同" || subtype == "验收" || subtype == "违规" {
  302. data["type"] = 3
  303. } else {
  304. data["type"] = 1
  305. }
  306. }
  307. if obj["projectinfo"] != nil {
  308. projectinfo := common.ObjToMap(obj["projectinfo"])
  309. if (*projectinfo)["attachments"] != nil {
  310. data["annex"] = 1
  311. }
  312. }
  313. data["publishtime"] = pushTime
  314. data["show_time"] = pushTime
  315. data["projectname"] = obj["projectname"]
  316. procurementlist, _ := obj["procurementlist"].([]interface{})
  317. for _, vs := range procurementlist { //1.采购意向清单数据集打码处理
  318. vsMap, _ := vs.(map[string]interface{})
  319. if vsMap["expurasingtime"] != nil {
  320. data["expurasing_time"] = vsMap["expurasingtime"]
  321. break
  322. }
  323. }
  324. }
  325. data["status"] = 1
  326. data["employ_way"] = 1
  327. data["create_time"] = time.Now().Format(date.Date_Full_Layout)
  328. if subtype == "拟建" {
  329. data = niJianHandle(id, data, v1, pushTime)
  330. data["type"] = 1
  331. }
  332. return data
  333. }
  334. // GetBuyerIdByName 通过采购单位名称获取id
  335. func getBuyerIdByName(buyerName string) (buyerId string) {
  336. r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyerName))
  337. if r == nil || len(*r) == 0 {
  338. return
  339. }
  340. buyerId, _ = (*r)[0]["_id"].(string)
  341. return
  342. }
  343. // IdFormat id解密
  344. func idFormat(encryptionId string, employType int64) string {
  345. decryptId := ""
  346. switch employType {
  347. case 1, 2:
  348. decryptId = util.DecodeId(encryptionId)
  349. case 3:
  350. if len(encryptionId) > 0 && len([]rune(encryptionId)) == len(encryptionId) {
  351. //此数据是id
  352. //获取中文名字
  353. decryptId = util.DecodeId(encryptionId)
  354. } else {
  355. //次数据传的名字
  356. decryptId = getBuyerIdByName(encryptionId)
  357. }
  358. }
  359. return decryptId
  360. }
  361. type Employ struct {
  362. Source int64
  363. IsNiJian bool
  364. ProjectId string
  365. Id string
  366. SourceId string
  367. Subtype string
  368. }
  369. // employKeyFormat 根据收录类型 字段处理 table,findKey,employKey,source
  370. func employKeyFormat(employType int64, idArrStr string) (string, string, string, map[string]Employ) {
  371. table := ""
  372. employKey := "company_id"
  373. findKey := "employ_custom_id"
  374. infoIdMap := map[string]Employ{}
  375. idArr := []string{}
  376. source := int64(0)
  377. switch employType {
  378. case 1:
  379. table = entity.EMPLOY_INFO
  380. employKey = "source_id"
  381. findKey = "employ_info_id"
  382. source = 1
  383. case 2:
  384. table = entity.EMPLOY_CUSTOM
  385. source = 1
  386. case 3:
  387. table = entity.EMPLOY_CUSTOM
  388. source = 2
  389. case 4:
  390. table = entity.EMPLOY_INFO
  391. source = 2
  392. employKey = "source_id"
  393. findKey = "employ_info_id"
  394. }
  395. for _, v := range strings.Split(idArrStr, ",") {
  396. id := idFormat(v, employType)
  397. idArr = append(idArr, id)
  398. infoIdMap[id] = Employ{
  399. Source: source,
  400. IsNiJian: false,
  401. ProjectId: "",
  402. Id: v,
  403. SourceId: id,
  404. }
  405. }
  406. if employType == 1 {
  407. table = entity.EMPLOY_INFO
  408. employKey = "source_id"
  409. findKey = "employ_info_id"
  410. source = 1
  411. aobj := elastic.Get(INDEX, TYPE, fmt.Sprintf(`{"query":{"bool":{"must_not":[],"should":[ {
  412. "terms": {
  413. "id": [
  414. "%s"
  415. ]
  416. }
  417. }]}},"from":0,"size":100,"_source":["_id","purchasinglist","projectname","projectcode","title","s_winner","buyertel","bidstatus","site","bidamount","toptype","winneraddr","winner","agency","buyer","detail","city","subtype","buyerclass","href","comeintime","winnertel","area","publishtime","buyeraddr","agencytel","budget","entidlist","buyerperson","winnerperson","agencyaddr","recommended_service","competehref","owner","total_investment","projectaddr","projectperiod","approvedept","approvecontent","approvecode","approvenumber","approvetime","approvestatus","project_scale"],"sort":[],"aggs":{}}`, strings.Join(idArr, `","`)))
  418. if aobj != nil && len(*aobj) > 0 || *aobj != nil {
  419. for _, v := range *aobj {
  420. id := common.InterfaceToStr(v["_id"])
  421. subtype := common.InterfaceToStr(v["subtype"])
  422. data, ok := infoIdMap[id]
  423. data.Subtype = subtype
  424. if subtype == "拟建" && ok {
  425. project, _ := MC.MgoProject.FindOne("projectset_proposed", map[string]interface{}{
  426. "ids": id,
  427. })
  428. data.Source = 2
  429. if project != nil && len(*project) > 0 {
  430. projectId := common.InterfaceToStr((*project)["_id"])
  431. data.IsNiJian = true
  432. data.ProjectId = projectId
  433. }
  434. }
  435. infoIdMap[id] = data
  436. }
  437. }
  438. }
  439. return table, findKey, employKey, infoIdMap
  440. }
  441. // IgnoreOperate 忽略操作
  442. func (e *EmPloyService) IgnoreOperate(in *types.IgnoreOperateReq) (bool, string) {
  443. //
  444. table := ""
  445. switch in.EmployType {
  446. case 1, 4:
  447. table = entity.EMPLOY_INFO
  448. case 2, 3:
  449. table = entity.EMPLOY_CUSTOM
  450. }
  451. msg := ""
  452. fool := true
  453. for _, v := range strings.Split(in.IdArr, ",") {
  454. id := idFormat(v, in.EmployType)
  455. if id == "" {
  456. log.Println(v, id, in.EmployType, "忽略处理,id解析失败")
  457. continue
  458. }
  459. findMap := map[string]interface{}{
  460. "position_id": in.PositionId,
  461. }
  462. if in.EmployType == 3 || in.EmployType == 2 {
  463. findMap["company_id"] = id
  464. } else {
  465. findMap["source_id"] = id
  466. }
  467. if MC.CrmMysql.Count(table, findMap) == 0 {
  468. log.Println(v, id, in.EmployType, "忽略处理,id所对应数据不存在")
  469. fool = false
  470. if in.EmployType == 1 {
  471. if in.IsIgnore {
  472. msg = "该资讯已有员工收录,不可忽略。"
  473. } else {
  474. msg = "该资讯已有员工收录,不可取消忽略。"
  475. }
  476. } else {
  477. if in.IsIgnore {
  478. msg = "该企业已有员工收录,不可忽略。"
  479. } else {
  480. msg = "该企业已有员工收录,不可取消忽略。"
  481. }
  482. }
  483. continue
  484. }
  485. if in.IsIgnore {
  486. MC.CrmMysql.Update(table, findMap, map[string]interface{}{
  487. "is_ignore": 1,
  488. "is_handle": 1,
  489. })
  490. } else {
  491. MC.CrmMysql.Update(table, findMap, map[string]interface{}{
  492. "is_ignore": 0,
  493. "is_handle": 1,
  494. })
  495. }
  496. }
  497. return fool, msg
  498. }
  499. // DistributePerson 分发操作
  500. func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
  501. return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
  502. personMap := map[int64]PersonSmmary{}
  503. //人员信息处理
  504. for _, person := range in.Person {
  505. personMap[person.PositionId] = PersonSmmary{
  506. EntUserId: person.EntUserId,
  507. EntDeptId: person.EntDeptId,
  508. }
  509. }
  510. //分发数据处理
  511. infoMap := map[string]map[string]interface{}{}
  512. onlyMap := map[string]interface{}{}
  513. topMap := map[string]string{}
  514. topEnt := 0
  515. //标讯数据处理
  516. for _, v := range strings.Split(in.EmployIdArr, ",") {
  517. //查询信息
  518. infoDataList := MC.CrmMysql.SelectBySqlByTx(tx, "SELECT * FROM employ_info WHERE id=?", v)
  519. if infoDataList != nil && len(*infoDataList) > 0 {
  520. source_id := common.InterfaceToStr((*infoDataList)[0]["source_id"])
  521. isOut := common.IntAll((*infoDataList)[0]["is_timeout"]) // 拓普 超时未处理标签
  522. //if onlyMap[source_id] == nil {
  523. (*infoDataList)[0]["dis_id"] = v
  524. (*infoDataList)[0]["is_handle"] = 0
  525. (*infoDataList)[0]["is_ignore"] = 0
  526. (*infoDataList)[0]["is_dis"] = 0
  527. (*infoDataList)[0]["is_create_clue"] = 0
  528. (*infoDataList)[0]["is_create_chance"] = 0
  529. (*infoDataList)[0]["is_create_custom"] = 0
  530. (*infoDataList)[0]["create_time"] = time.Now().Format(date.Date_Full_Layout)
  531. delete((*infoDataList)[0], "id")
  532. MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, map[string]interface{}{
  533. "id": v,
  534. }, map[string]interface{}{
  535. "is_dis": 1,
  536. "is_handle": 1,
  537. "is_timeout": 0,
  538. })
  539. infoMap[source_id] = (*infoDataList)[0]
  540. onlyMap[source_id] = v
  541. if isOut == 1 {
  542. topMap[source_id] = v
  543. topEnt = common.IntAll((*infoDataList)[0]["ent_id"])
  544. }
  545. //} else {
  546. // log.Println(v, "查询不到改收录信息")
  547. // continue
  548. //}
  549. }
  550. }
  551. // 修改 topnet_info is_timeout
  552. log.Println("修改 topnet_info ", topEnt, topMap)
  553. if topEnt > 0 && len(topMap) > 0 {
  554. for k, _ := range topMap {
  555. c := MC.CrmMysql.Count(entity.EMPLOY_INFO, map[string]interface{}{"source_id": k, "is_timeout": 1, "ent_id": topEnt})
  556. if c <= 0 {
  557. MC.CrmMysql.ExecBySql("UPDATE crm.topnet_info SET is_timeout = 1 WHERE info_id = ?", k)
  558. }
  559. }
  560. }
  561. //普通人员分发
  562. for positionId, personSmmary := range personMap {
  563. //查询时候收录过
  564. for _, v := range infoMap {
  565. //查询时候收录过
  566. findMap := map[string]interface{}{
  567. "position_id": positionId,
  568. "source_id": v["source_id"],
  569. }
  570. if MC.CrmMysql.Count(entity.EMPLOY_INFO, findMap) == 0 {
  571. //新增
  572. v["ent_user_id"] = personSmmary.EntUserId
  573. v["ent_dept_id"] = personSmmary.EntDeptId
  574. v["position_id"] = positionId
  575. MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, v)
  576. }
  577. }
  578. }
  579. if in.EntNicheDis > 0 {
  580. //查询分配员有没有该数据
  581. for _, v := range infoMap {
  582. //查询时候收录过
  583. findMap := map[string]interface{}{
  584. "position_id": in.PositionId,
  585. "source_id": v["source_id"],
  586. }
  587. employPositionId := v["position_id"]
  588. if employPositionId != in.PositionId {
  589. //分发消息不属于自己
  590. if MC.CrmMysql.Count(entity.EMPLOY_INFO, findMap) == 0 {
  591. v["ent_user_id"] = in.EntUserId
  592. v["position_id"] = in.PositionId
  593. v["is_handle"] = 1
  594. v["ent_dept_id"] = in.EntDeptId
  595. MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, v)
  596. } else {
  597. MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, findMap, map[string]interface{}{
  598. "is_handle": 1,
  599. })
  600. }
  601. }
  602. }
  603. }
  604. return true
  605. })
  606. }
  607. func niJianHandle(infoId string, data map[string]interface{}, v1, pushTime string) map[string]interface{} {
  608. project, _ := MC.MgoProject.FindOne("projectset_proposed", map[string]interface{}{
  609. "ids": infoId,
  610. })
  611. if project != nil && len(*project) > 0 {
  612. city := common.InterfaceToStr((*project)["city"])
  613. area := common.InterfaceToStr((*project)["area"])
  614. category_code := common.InterfaceToStr((*project)["category_code"])
  615. lasttime := common.Int64All((*project)["lasttime"])
  616. ownerclass_code := common.InterfaceToStr((*project)["ownerclass_code"])
  617. total_investment := common.InterfaceToStr((*project)["total_investment"])
  618. project_stage_code := common.InterfaceToStr((*project)["project_stage_code"])
  619. infoList := gconv.SliceMap((*project)["list"])
  620. title := ""
  621. projectname := ""
  622. if len(infoList) > 0 {
  623. title = common.InterfaceToStr(infoList[0]["title"])
  624. projectname = common.InterfaceToStr(infoList[0]["projectname"])
  625. }
  626. category := ""
  627. ownerclass := ""
  628. project_stage := ""
  629. if category_code != "" {
  630. categoryData := MC.NiJian.FindOne("d_nzj_category_code", map[string]interface{}{
  631. "code": category_code,
  632. }, "name", "")
  633. category = common.InterfaceToStr((*categoryData)["name"])
  634. }
  635. if ownerclass_code != "" {
  636. ownerclassData := MC.NiJian.FindOne("d_nzj_ownerclass_code", map[string]interface{}{
  637. "code": ownerclass_code,
  638. }, "name", "")
  639. ownerclass = common.InterfaceToStr((*ownerclassData)["name"])
  640. }
  641. if project_stage_code != "" {
  642. projectStageData := MC.NiJian.FindOne("d_nzj_project_stage_code", map[string]interface{}{
  643. "code": project_stage_code,
  644. }, "name", "")
  645. project_stage = common.InterfaceToStr((*projectStageData)["name"])
  646. }
  647. data["title"] = title
  648. data["city"] = city
  649. data["area"] = area
  650. data["projectname"] = projectname
  651. data["ownerclass"] = ownerclass
  652. data["project_stage"] = project_stage
  653. data["project_category"] = category
  654. data["project_investment"] = total_investment
  655. lastTimeStr := common.If(lasttime == 0, pushTime, time.Unix(lasttime, 0).Format(date.Date_Full_Layout))
  656. data["project_evolve"] = lastTimeStr
  657. data["show_time"] = lastTimeStr
  658. data["publishtime"] = lastTimeStr
  659. pid := common.InterfaceToStr((*project)["_id"])
  660. data["jybx_url"] = "/succbi/nzj/app/nzj.app/nzj_detail_0.spg?pid=" + pid
  661. data["source"] = 2
  662. data["source_id"] = pid
  663. } else {
  664. data["source"] = 1
  665. data["source_id"] = infoId
  666. data["jybx_url"] = "/article/content/" + v1 + ".html"
  667. }
  668. return data
  669. }
  670. // 个人收录情况查询
  671. func employInfoPerson(table, employKey, findKey string, in *types.InfoEmployinfoReq, version int, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr []string) map[string]map[string]interface{} {
  672. //
  673. data := map[string]map[string]interface{}{}
  674. infoData1 := &[]map[string]interface{}{}
  675. infoData2 := &[]map[string]interface{}{}
  676. niJianData := &[]map[string]interface{}{}
  677. wuyeData1 := &[]map[string]interface{}{}
  678. wuyeData2 := &[]map[string]interface{}{}
  679. orderKey := "type"
  680. if employKey == "company_id" {
  681. orderKey = "source"
  682. }
  683. if len(infoId1Arr) > 0 {
  684. infoData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(infoId1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  685. }
  686. if len(infoId2Arr) > 0 {
  687. infoData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(infoId2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  688. }
  689. if len(niJianIdArr) > 0 {
  690. niJianData = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(niJianIdArr, "','"), employKey, orderKey, orderKey), in.PositionId)
  691. }
  692. if len(wuye1Arr) > 0 {
  693. wuyeData1 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(wuye1Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  694. }
  695. if len(wuye2Arr) > 0 {
  696. wuyeData2 = MC.CrmMysql.SelectBySql(fmt.Sprintf("select %s, is_ignore,status,id,%s from %s where position_id =? and %s in ('%s') GROUP BY %s ,%s order by %s ", employKey, orderKey, table, employKey, strings.Join(wuye2Arr, "','"), employKey, orderKey, orderKey), in.PositionId)
  697. }
  698. for _, v := range *infoData1 {
  699. valueMap := map[string]interface{}{
  700. "id": v,
  701. "isIgnore": false,
  702. "isEmploy": false,
  703. "customCount": 0,
  704. "clueCount": 0,
  705. "chanceCount": 0,
  706. "type": 1,
  707. }
  708. sourceId := gconv.String(v[employKey])
  709. if _, ok := data[sourceId]; ok {
  710. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  711. } else {
  712. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  713. }
  714. }
  715. for _, v := range *infoData2 {
  716. valueMap := map[string]interface{}{
  717. "id": v,
  718. "isIgnore": false,
  719. "isEmploy": false,
  720. "customCount": 0,
  721. "clueCount": 0,
  722. "chanceCount": 0,
  723. "type": 1,
  724. }
  725. sourceId := gconv.String(v[employKey])
  726. if _, ok := data[sourceId]; ok {
  727. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  728. } else {
  729. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  730. }
  731. }
  732. for _, v := range *niJianData {
  733. valueMap := map[string]interface{}{
  734. "id": v,
  735. "isIgnore": false,
  736. "isEmploy": false,
  737. "customCount": 0,
  738. "clueCount": 0,
  739. "chanceCount": 0,
  740. "type": 1,
  741. }
  742. sourceId := gconv.String(v[employKey])
  743. if _, ok := data[sourceId]; ok {
  744. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  745. } else {
  746. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  747. }
  748. }
  749. for _, v := range *wuyeData1 {
  750. valueMap := map[string]interface{}{
  751. "id": v,
  752. "isIgnore": false,
  753. "isEmploy": false,
  754. "customCount": 0,
  755. "clueCount": 0,
  756. "chanceCount": 0,
  757. "type": 1,
  758. }
  759. sourceId := gconv.String(v[employKey])
  760. if _, ok := data[sourceId]; ok {
  761. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  762. } else {
  763. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  764. }
  765. }
  766. for _, v := range *wuyeData2 {
  767. valueMap := map[string]interface{}{
  768. "id": v,
  769. "isIgnore": false,
  770. "isEmploy": false,
  771. "customCount": 0,
  772. "clueCount": 0,
  773. "chanceCount": 0,
  774. "type": 1,
  775. }
  776. sourceId := gconv.String(v[employKey])
  777. if _, ok := data[sourceId]; ok {
  778. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  779. } else {
  780. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  781. }
  782. }
  783. return data
  784. }
  785. // 企业收录情况查询
  786. func employInfoEnt(table, employKey, findKey, depIDArr string, in *types.InfoEmployinfoReq, version int, infoId1Arr, infoId2Arr, niJianIdArr, wuye1Arr, wuye2Arr []string) map[string]map[string]interface{} {
  787. data := map[string]map[string]interface{}{}
  788. infoData1 := &[]map[string]interface{}{}
  789. infoData2 := &[]map[string]interface{}{}
  790. niJianData := &[]map[string]interface{}{}
  791. wuyeData1 := &[]map[string]interface{}{}
  792. wuyeData2 := &[]map[string]interface{}{}
  793. orderKey := "type"
  794. if employKey == "company_id" {
  795. orderKey = "source"
  796. }
  797. if len(infoId1Arr) > 0 {
  798. 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)
  799. }
  800. if len(infoId2Arr) > 0 {
  801. 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)
  802. }
  803. if len(niJianIdArr) > 0 {
  804. 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)
  805. }
  806. if len(wuye1Arr) > 0 {
  807. 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)
  808. }
  809. if len(wuye2Arr) > 0 {
  810. 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)
  811. }
  812. for _, v := range *infoData1 {
  813. valueMap := map[string]interface{}{
  814. "id": v,
  815. "isIgnore": false,
  816. "isEmploy": false,
  817. "customCount": 0,
  818. "clueCount": 0,
  819. "chanceCount": 0,
  820. "type": 1,
  821. }
  822. sourceId := gconv.String(v[employKey])
  823. if _, ok := data[sourceId]; ok {
  824. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  825. } else {
  826. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  827. }
  828. }
  829. for _, v := range *infoData2 {
  830. valueMap := map[string]interface{}{
  831. "id": v,
  832. "isIgnore": false,
  833. "isEmploy": false,
  834. "customCount": 0,
  835. "clueCount": 0,
  836. "chanceCount": 0,
  837. "type": 1,
  838. }
  839. sourceId := gconv.String(v[employKey])
  840. if _, ok := data[sourceId]; ok {
  841. data[sourceId] = EmployHandle(data[sourceId], v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  842. } else {
  843. data[sourceId] = EmployHandle(valueMap, v, 0, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  844. }
  845. }
  846. for _, v := range *niJianData {
  847. valueMap := map[string]interface{}{
  848. "id": v,
  849. "isIgnore": false,
  850. "isEmploy": false,
  851. "customCount": 0,
  852. "clueCount": 0,
  853. "chanceCount": 0,
  854. "type": 1,
  855. }
  856. sourceId := gconv.String(v[employKey])
  857. if _, ok := data[sourceId]; ok {
  858. data[sourceId] = EmployHandle(data[sourceId], v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  859. } else {
  860. data[sourceId] = EmployHandle(valueMap, v, version, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  861. }
  862. }
  863. for _, v := range *wuyeData1 {
  864. valueMap := map[string]interface{}{
  865. "id": v,
  866. "isIgnore": false,
  867. "isEmploy": false,
  868. "customCount": 0,
  869. "clueCount": 0,
  870. "chanceCount": 0,
  871. "type": 1,
  872. }
  873. sourceId := gconv.String(v[employKey])
  874. if _, ok := data[sourceId]; ok {
  875. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  876. } else {
  877. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  878. }
  879. }
  880. for _, v := range *wuyeData2 {
  881. valueMap := map[string]interface{}{
  882. "id": v,
  883. "isIgnore": false,
  884. "isEmploy": false,
  885. "customCount": 0,
  886. "clueCount": 0,
  887. "chanceCount": 0,
  888. "type": 1,
  889. }
  890. sourceId := gconv.String(v[employKey])
  891. if _, ok := data[sourceId]; ok {
  892. data[sourceId] = EmployHandle(data[sourceId], v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  893. } else {
  894. data[sourceId] = EmployHandle(valueMap, v, 1, in.From, len(strings.Split(in.IdArr, ",")) == 1, findKey, in.PositionId, in.PositionType, in.EmployType)
  895. }
  896. }
  897. return data
  898. }
  899. func EmployHandle(valueMap map[string]interface{}, employData map[string]interface{}, version int, originate string, single bool, findKey string, positionId, positionType, inEmployType int64) map[string]interface{} {
  900. employType := common.Int64All(employData["type"])
  901. employStatus := common.Int64All(employData["status"])
  902. employ2 := false
  903. employ3 := false
  904. employIgnore := false
  905. employId := int64(0)
  906. is_ignore := int64(0)
  907. employArrStr := ""
  908. //收录标识处理
  909. if common.Int64All(employData["id"]) == 0 {
  910. if len(gconv.String(employData["employIdArr"])) > 0 {
  911. employArrStr = gconv.String(employData["employIdArr"])
  912. employId = gconv.Int64(strings.Split(employArrStr, ",")[0])
  913. }
  914. } else {
  915. employId = common.Int64All(employData["id"])
  916. }
  917. if version == 1 {
  918. is_ignore = common.Int64All(employData["is_ignore"])
  919. switch employType {
  920. case 2:
  921. if valueMap["employ3"] != nil {
  922. employ3 = gconv.Bool(valueMap["employ3"])
  923. }
  924. if employStatus == 1 {
  925. employ2 = true
  926. }
  927. case 3:
  928. if valueMap["employ2"] != nil {
  929. employ2 = gconv.Bool(valueMap["employ2"])
  930. }
  931. if employStatus == 1 {
  932. employ3 = true
  933. }
  934. }
  935. if is_ignore > 0 {
  936. employIgnore = true
  937. }
  938. employType = common.Int64All(employData["type"])
  939. valueMap["isIgnore"] = employIgnore
  940. if originate == "jhfp" {
  941. valueMap["isEmploy"] = employ3
  942. } else {
  943. valueMap["isEmploy"] = common.If(employ2 && employ3, true, false)
  944. }
  945. valueMap["type"] = employType
  946. valueMap["employ2"] = employ2
  947. valueMap["employ3"] = employ3
  948. valueMap["employId"] = employId
  949. } else {
  950. valueMap["isIgnore"] = common.If(common.Int64All(employData["is_ignore"]) == 1, true, false)
  951. valueMap["isEmploy"] = common.If(common.Int64All(employData["status"]) == 1, true, false)
  952. valueMap["type"] = common.Int64All(employData["type"])
  953. valueMap["employId"] = employId
  954. }
  955. if employType == 2 {
  956. valueMap["intelligenceId"] = employId
  957. }
  958. if single && employArrStr != "" {
  959. //列表查询
  960. //是否忽略处理
  961. //客户数量
  962. customSql := ""
  963. clueSql := ""
  964. chanceSql := ""
  965. if positionType == 0 {
  966. customSql = fmt.Sprintf("select COUNT(1) from %s where %s in (%s) and position_id=%d", entity.CUSTOM, findKey, employArrStr, positionId)
  967. clueSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s) and position_id=%d", entity.SALE_CLUE, employArrStr, positionId)
  968. chanceSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s) and position_id=%d", entity.SALE_CHANCE, employArrStr, positionId)
  969. } else {
  970. customSql = fmt.Sprintf("select COUNT(1) from %s where %s in (%s)", entity.CUSTOM, findKey, employArrStr)
  971. clueSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s)", entity.SALE_CLUE, employArrStr)
  972. chanceSql = fmt.Sprintf("select COUNT(1) from %s where employ_info_id in (%s)", entity.SALE_CHANCE, employArrStr)
  973. }
  974. customCount := MC.CrmMysql.CountBySql(customSql)
  975. valueMap["customCount"] = customCount
  976. if inEmployType == 1 || inEmployType == 4 {
  977. //销售线索数量
  978. clueCount := MC.CrmMysql.CountBySql(clueSql)
  979. valueMap["clueCount"] = clueCount
  980. //销售机会数量
  981. chanceCount := MC.CrmMysql.CountBySql(chanceSql)
  982. valueMap["chanceCount"] = chanceCount
  983. }
  984. } else {
  985. valueMap["chanceCount"] = 0
  986. valueMap["clueCount"] = 0
  987. valueMap["customCount"] = 0
  988. }
  989. return valueMap
  990. }