employService.go 36 KB

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