jobutil.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/gogf/gf/v2/util/gconv"
  5. "log"
  6. "strings"
  7. "time"
  8. "app.yhyue.com/moapp/jybase/common"
  9. "app.yhyue.com/moapp/jybase/date"
  10. "app.yhyue.com/moapp/jybase/mongodb"
  11. )
  12. // 未支付订单 30分钟一次
  13. func orders() {
  14. //一个小时未支付进入线索 A
  15. log.Println("未支付订单定时任务开始")
  16. lastOrderId := cfg.LastOrderId
  17. selectTimeStart := time.Unix(time.Now().Unix()-7200, 0).Format(date.Date_Full_Layout)
  18. selectTimeEnd := time.Unix(time.Now().Unix()-3600, 0).Format(date.Date_Full_Layout)
  19. sql := fmt.Sprintf(`select * from dataexport_order where create_time <= "%s" and create_time >= "%s" and id > %s`, selectTimeEnd, selectTimeStart, fmt.Sprint(lastOrderId))
  20. data := Mysql.SelectBySql(sql)
  21. if data != nil && *data != nil && len(*data) > 0 {
  22. for _, v := range *data {
  23. order_status := common.IntAll(v["order_status"])
  24. is_backstage_order := common.IntAll(v["is_backstage_order"])
  25. product_type_str1 := `"大会员","VIP订阅","数据流量包","历史数据"`
  26. product_type := common.ObjToString(v["product_type"])
  27. if order_status == 0 && is_backstage_order == 0 && strings.Contains(product_type_str1, product_type) {
  28. ok1, ok2 := FormatData(v, "orders")
  29. if !ok1 {
  30. common.WriteSysConfig(&cfg)
  31. break
  32. } else {
  33. if !ok2 {
  34. log.Println("用户分配已达上限")
  35. common.WriteSysConfig(&cfg)
  36. break
  37. }
  38. }
  39. }
  40. cfg.LastOrderId = common.IntAll(v["id"])
  41. }
  42. }
  43. common.WriteSysConfig(&cfg)
  44. log.Println("未支付订单定时任务结束")
  45. }
  46. func readClue() {
  47. log.Println("读表进线索定时任务开始")
  48. lastReadClueTime := cfg.LastReadClueTime
  49. sql := fmt.Sprintf(`select * from clue_info where updatetime > "%s" order by updatetime asc`, fmt.Sprint(lastReadClueTime))
  50. data := TiDb.SelectBySql(sql)
  51. if data != nil && *data != nil && len(*data) > 0 {
  52. for _, v := range *data {
  53. ok1, ok2 := FormatData(v, "readClue")
  54. if !ok1 {
  55. common.WriteSysConfig(&cfg)
  56. break
  57. } else {
  58. if !ok2 {
  59. log.Println("用户分配已达上限")
  60. common.WriteSysConfig(&cfg)
  61. break
  62. }
  63. }
  64. cfg.LastReadClueTime = common.ObjToString(v["updatetime"])
  65. }
  66. }
  67. common.WriteSysConfig(&cfg)
  68. log.Println("读表进线索定时任务结束")
  69. }
  70. // 新注册用户 5分钟一次
  71. func users() {
  72. //判断节假日
  73. runOk := getRunOk()
  74. if !runOk {
  75. log.Println("不是工作日,任务暂停")
  76. return
  77. }
  78. //新用户注册后5分钟内进入线索 C
  79. log.Println("新注册用户定时任务开始")
  80. selectTimeEnd := cfg.LastUserId
  81. sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where createtime > "%s" and source = "0101" and status != 2`, selectTimeEnd)
  82. data := TiDb.SelectBySql(sql)
  83. if data != nil && *data != nil && len(*data) > 0 {
  84. for k, v := range *data {
  85. createtime := common.ObjToString(v["createtime"])
  86. FormatData(v, "users")
  87. if k == len(*data)-1 {
  88. cfg.LastUserId = createtime
  89. }
  90. }
  91. }
  92. common.WriteSysConfig(&cfg)
  93. log.Println("新注册用户定时任务结束")
  94. }
  95. // 留资 5分钟一次
  96. func saleLeads() {
  97. //判断节假日
  98. runOk := getRunOk()
  99. if !runOk {
  100. log.Println("不是工作日,任务暂停")
  101. return
  102. }
  103. //留资后5分钟内进入线索
  104. //分为免费留资和付费留资 付费B 免费C
  105. log.Println("用户留资定时任务开始")
  106. session := Mgo.GetMgoConn()
  107. lastId := cfg.LastId
  108. defer func() {
  109. Mgo.DestoryMongoConn(session)
  110. }()
  111. query := map[string]interface{}{}
  112. if lastId != "" {
  113. query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(lastId)}
  114. }
  115. log.Println("query :", query)
  116. iter := session.DB(cfg.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
  117. thisData := map[string]interface{}{}
  118. for {
  119. if !iter.Next(&thisData) {
  120. break
  121. }
  122. ok1, ok2 := FormatData(thisData, "saleLeads")
  123. if !ok1 {
  124. common.WriteSysConfig(&cfg)
  125. break
  126. } else {
  127. if !ok2 {
  128. log.Println("用户分配已达上限")
  129. common.WriteSysConfig(&cfg)
  130. break
  131. }
  132. }
  133. cfg.LastId = mongodb.BsonIdToSId(thisData["_id"])
  134. }
  135. common.WriteSysConfig(&cfg)
  136. log.Println("用户留资定时任务结束")
  137. }
  138. func userbase() {
  139. log.Println("userbase定时任务开始")
  140. selectTimeEnd := time.Unix(time.Now().Unix()-1800, 0).Format("2006-01-02 15:04:05")
  141. sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s" and source != "0105" and source != "0104" and source != "0103" and source != "0102"`, selectTimeEnd)
  142. //sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where id='11927183'`)
  143. data := TiDb.SelectBySql(sql)
  144. if data != nil && *data != nil && len(*data) > 0 {
  145. for _, v := range *data {
  146. phone := common.ObjToString(v["phone"])
  147. uId := common.ObjToString(v["uid"])
  148. userId := common.ObjToString(v["userid"])
  149. registedate := common.ObjToString(v["l_registedate"])
  150. name := common.ObjToString(v["name"])
  151. nowTime := time.Now().Format(date.Date_Full_Layout)
  152. source := common.ObjToString(v["source"])
  153. if phone != "" {
  154. contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where D = ? and is_delete = 1", phone)
  155. if contactsData == nil || len(*contactsData) == 0 {
  156. contactsData2 := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1", uId)
  157. if contactsData2 != nil && len(*contactsData2) > 0 {
  158. log.Println("userbase uid不为空 新增通讯录", uId)
  159. TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
  160. "status": 1,
  161. "is_delete": 1,
  162. "createtime": nowTime,
  163. "updatetime": nowTime,
  164. "phone": phone,
  165. "baseinfo_id": uId,
  166. "SOURCE": source,
  167. })
  168. } else {
  169. registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
  170. count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
  171. log.Println("userbase uid 线索数量 ", count)
  172. log.Println("userbase uid 注册时间 ", registedates)
  173. if time.Now().Unix()-registedates.Unix() > int64(cfg.RegTimes)*86400 {
  174. if count == 0 {
  175. // TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
  176. // "clue_id": clueId,
  177. // "comeintime": nowTime,
  178. // "comeinsource": 2,
  179. // })
  180. clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
  181. "userid": userId,
  182. "uid": uId,
  183. "is_assign": 0,
  184. "comeintime": nowTime,
  185. "createtime": nowTime,
  186. "updatetime": nowTime,
  187. "cluename": phone,
  188. "top_cluetype": "532",
  189. "sub_cluetype": "475",
  190. "trailstatus": "01",
  191. "name": name,
  192. "phone": phone,
  193. "comeintime_open": nowTime,
  194. "comeinsource_open": 1,
  195. "FREEZE_TIME": nowTime,
  196. })
  197. if clueId > 0 {
  198. TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
  199. "status": 1,
  200. "is_delete": 1,
  201. "createtime": nowTime,
  202. "updatetime": nowTime,
  203. "phone": phone,
  204. "baseinfo_id": uId,
  205. "SOURCE": source,
  206. })
  207. TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
  208. "clue_id": clueId,
  209. "position_id": -1,
  210. "change_type": "创建线索",
  211. "new_value": "系统自动创建",
  212. "createtime": nowTime,
  213. "BCPCID": common.GetRandom(32),
  214. "operator_id": -1,
  215. })
  216. }
  217. } else {
  218. TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
  219. "status": 1,
  220. "is_delete": 1,
  221. "createtime": nowTime,
  222. "updatetime": nowTime,
  223. "phone": phone,
  224. "baseinfo_id": uId,
  225. "SOURCE": source,
  226. })
  227. }
  228. } else {
  229. if count == 0 {
  230. FormatData(v, "users")
  231. } else {
  232. TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
  233. "status": 1,
  234. "is_delete": 1,
  235. "createtime": nowTime,
  236. "updatetime": nowTime,
  237. "phone": phone,
  238. "baseinfo_id": uId,
  239. "SOURCE": source,
  240. })
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. log.Println("userbase定时任务结束")
  249. }
  250. func getRunOk() bool {
  251. currentTime, runOk := time.Now(), false
  252. if currentTime.Weekday() == time.Sunday {
  253. isok := false
  254. for k, v := range DateMap {
  255. if currentTime.Format(date.Date_Short_Layout) == k && v == 2 {
  256. isok = true
  257. }
  258. }
  259. if isok {
  260. runOk = true
  261. }
  262. } else {
  263. isok := true
  264. for k, v := range DateMap {
  265. if currentTime.Format(date.Date_Short_Layout) == k && v == 1 {
  266. isok = false
  267. }
  268. }
  269. if isok {
  270. runOk = true
  271. }
  272. }
  273. return runOk
  274. }
  275. func getAreaCode(userId string) (code string) {
  276. followData := Base.Find("follow_project_monitor", map[string]interface{}{"s_userid": userId}, "", "", -1, -1)
  277. sidArr := []string{}
  278. if followData != nil && len(*followData) > 0 {
  279. for _, v := range *followData {
  280. infoId := common.ObjToString(v["s_id"])
  281. sidArr = append(sidArr, infoId)
  282. }
  283. }
  284. if len(sidArr) > 0 {
  285. query := `{"query": {"bool": {"must": [{"terms": {"_id": ["%s"]}}],"must_not": [],"should": []}}}`
  286. query = fmt.Sprintf(query, strings.Join(sidArr, `","`))
  287. biddingData := Es.Get("bidding", "bidding", query)
  288. if biddingData != nil && len(*biddingData) > 0 {
  289. codeMap := map[string]string{}
  290. codeArr := []string{}
  291. for _, v := range *biddingData {
  292. area := common.ObjToString(v["area"])
  293. address := common.ObjToString(v["city"])
  294. if address == "" {
  295. address = area
  296. }
  297. codeMap[address] = AreaCode[address]
  298. }
  299. if len(codeMap) > 0 {
  300. for _, v := range codeMap {
  301. codeArr = append(codeArr, v)
  302. }
  303. }
  304. if len(codeArr) > 0 {
  305. code = strings.Join(codeArr, ",")
  306. }
  307. }
  308. }
  309. log.Println("code ", code)
  310. return
  311. }
  312. func getClueType(item string, data map[string]interface{}, sourceCode string, sourceId int64) (pcode, code, level, topname, subname string) {
  313. if item == "orders" {
  314. productType := common.ObjToString(data["product_type"])
  315. pcode = "1"
  316. level = "A"
  317. topname = "提交订单未支付"
  318. if productType == "VIP订阅" {
  319. code = "6"
  320. subname = "超级订阅"
  321. } else if productType == "大会员" {
  322. code = "7"
  323. subname = "大会员"
  324. } else if productType == "数据流量包" {
  325. code = "8"
  326. subname = "数据流量包"
  327. } else if productType == "历史数据" {
  328. code = "9"
  329. subname = "数据自助导出"
  330. }
  331. } else if item == "users" {
  332. pcode = "4"
  333. code = "154"
  334. level = "C"
  335. topname = "新增注册"
  336. subname = "新增注册用户"
  337. } else if item == "message" {
  338. pcode = "532"
  339. code = "477"
  340. level = "B"
  341. topname = "其他"
  342. subname = "机器人客服主动咨询"
  343. } else if item == "readClue" {
  344. level = "A"
  345. topname = "超级订阅临期用户"
  346. pcode = "614"
  347. if sourceId == 1 {
  348. code = "615"
  349. subname = "60天后到期"
  350. } else if sourceId == 2 {
  351. code = "616"
  352. subname = "45天后到期"
  353. } else if sourceId == 3 {
  354. code = "617"
  355. subname = "15天后到期"
  356. } else {
  357. code = "618"
  358. subname = "7天后到期"
  359. }
  360. } else {
  361. if sourceCode != "" {
  362. codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"source": sourceCode}, "", "")
  363. if codeData != nil && len(*codeData) > 0 {
  364. pcode = common.ObjToString((*codeData)["pcode"])
  365. code = common.ObjToString((*codeData)["code"])
  366. level = common.ObjToString((*codeData)["clue_level"])
  367. subname = common.ObjToString((*codeData)["name"])
  368. pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": pcode}, "", "")
  369. if pcodeData != nil && len(*pcodeData) > 0 {
  370. topname = common.ObjToString((*pcodeData)["name"])
  371. }
  372. }
  373. }
  374. }
  375. return
  376. }
  377. // 获取自动分配的人
  378. func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk, isFreeze, isWait bool) {
  379. isOk = false
  380. isFreeze = false
  381. if TiDb.Count("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone, "is_assign": 1}) == 0 { //线索没销售进入,有销售走分配次数最少的逻辑
  382. if isGroup == 0 && isCommerce == 1 && cluename != "" { //非集团在工商库线索名不为空
  383. cdata := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"cluename": cluename, "is_assign": 1}, "", "")
  384. if cdata != nil && len(*cdata) > 0 { //找到了公司有人在跟进
  385. isOk = true
  386. positionId = common.Int64All((*cdata)["position_id"])
  387. seatNumber = common.ObjToString((*cdata)["seatNumber"])
  388. log.Println("positionId seatNumber ", positionId, seatNumber)
  389. if positionId > 0 {
  390. pdata := TiDb.SelectBySql(`select * from dwd_f_crm_personnel_management where seat_number is not null and seat_number != ""`)
  391. if pdata != nil {
  392. saleData = *pdata
  393. for _, v := range *pdata {
  394. resign := common.IntAll(v["resign"])
  395. if positionId == common.Int64All(v["position_id"]) {
  396. if resign == 1 { //离职分配,找到的销售离职了,分给组员,没离职就给他
  397. sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, positionId)
  398. if sdata != nil && len(*sdata) > 0 {
  399. for _, m := range *sdata {
  400. if !FindUpperLimit(gconv.String(positionId), "positionId") {
  401. positionId = common.Int64All(m["position_id"])
  402. seatNumber = common.ObjToString(m["seat_number"])
  403. saleName = common.ObjToString(m["name"])
  404. return
  405. }
  406. }
  407. isWait = true
  408. return
  409. }
  410. } else {
  411. saleName = common.ObjToString(v["name"])
  412. if FindUpperLimit(gconv.String(positionId), "positionId") {
  413. isFreeze = true
  414. }
  415. }
  416. }
  417. }
  418. }
  419. return
  420. }
  421. }
  422. }
  423. }
  424. query := `select * from dwd_f_crm_personnel_management where assign_type = 1 and`
  425. if mode == "A" {
  426. query += ` assign_level like "%A%"`
  427. } else if mode == "B" {
  428. query += ` assign_level like "%B%"`
  429. } else {
  430. query += ` assign_level like "%C%"`
  431. }
  432. data := TiDb.SelectBySql(query)
  433. if data != nil && len(*data) > 0 {
  434. saleData = *data
  435. sql := "select * from dwd_f_crm_clue_autodraw_record where clue_level = ?"
  436. countData := TiDb.SelectBySql(sql, mode)
  437. if countData != nil && len(*countData) > 0 {
  438. for _, v := range *data {
  439. isOk := false //判断是否有新员工
  440. for _, vv := range *countData {
  441. if common.Int64All(v["position_id"]) == common.Int64All(vv["position_id"]) {
  442. if common.IntAll(v["resign"]) == 0 {
  443. vv["status"] = 1
  444. } else {
  445. vv["status"] = 2
  446. }
  447. isOk = true
  448. }
  449. }
  450. if !isOk { //有新员工直接分给新员工
  451. positionId = common.Int64All(v["position_id"])
  452. saleName = common.ObjToString(v["name"])
  453. log.Println("新员工, ", positionId, saleName)
  454. rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count desc")
  455. TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
  456. "position_id": positionId,
  457. "clue_level": mode,
  458. "count": common.Int64All((*rData)["count"]),
  459. })
  460. break
  461. }
  462. }
  463. if positionId == 0 {
  464. res := int64(0)
  465. countres := 0
  466. for _, v := range *countData {
  467. if common.IntAll(v["status"]) == 1 {
  468. if FindUpperLimit(gconv.String(common.Int64All(v["position_id"])), "positionId") {
  469. continue
  470. }
  471. if countres == 0 {
  472. res = common.Int64All(v["count"])
  473. positionId = common.Int64All(v["position_id"])
  474. } else {
  475. if common.Int64All(v["count"]) <= res {
  476. res = common.Int64All(v["count"])
  477. seatNumber = common.ObjToString(v["seatNumber"])
  478. }
  479. }
  480. countres++
  481. }
  482. }
  483. }
  484. } else {
  485. for _, kv := range *data {
  486. positionId1 := gconv.String(kv["position_id"])
  487. if !FindUpperLimit(positionId1, "positionId") {
  488. saleName = common.ObjToString(kv["name"])
  489. positionId = common.Int64All((*data)[0]["position_id"])
  490. saleName = common.ObjToString((*data)[0]["name"])
  491. rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count desc")
  492. if rData != nil && len(*rData) > 0 {
  493. TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
  494. "position_id": positionId,
  495. "clue_level": mode,
  496. "count": common.Int64All((*rData)["count"]),
  497. })
  498. } else {
  499. TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
  500. "position_id": positionId,
  501. "clue_level": mode,
  502. "count": 0,
  503. })
  504. }
  505. break
  506. }
  507. }
  508. }
  509. for _, v := range *data {
  510. if positionId == common.Int64All(v["position_id"]) {
  511. seatNumber = common.ObjToString(v["seat_number"])
  512. saleName = common.ObjToString(v["name"])
  513. }
  514. }
  515. }
  516. return
  517. }
  518. func getPositionId(phone string) (positionId int64) {
  519. userData, ok := Mgo.FindOne("user", map[string]interface{}{"s_phone": phone})
  520. if ok && userData != nil && len(*userData) > 0 {
  521. userId := common.Int64All((*userData)["base_user_id"])
  522. positionData := Base.FindOne("base_position", map[string]interface{}{"type": 1, "ent_id": 25917, "user_id": userId}, "", "") //TODO ent_id
  523. if positionData != nil && len(*positionData) > 0 {
  524. positionId = common.Int64All((*positionData)["id"])
  525. }
  526. }
  527. return
  528. }
  529. func GetCompanyType(companyName string) (int, int) {
  530. //是否是集团
  531. isGroup, isCommerce := 0, 0
  532. if c := TiDb.CountBySql(`select count(1) from group_company_name where company_name=?`, companyName); c > 0 {
  533. isGroup = 1
  534. }
  535. //是否在工商库
  536. if c := MgoQyxy.Count("qyxy_std", map[string]interface{}{"company_name": companyName, "company_type": map[string]interface{}{"$ne": "个体工商户"}}); c > 0 {
  537. isCommerce = 1
  538. }
  539. return isGroup, isCommerce
  540. }
  541. // 查询是否达上限
  542. func FindUpperLimit(positionId string, dataType string) bool {
  543. if positionId == "" {
  544. return false
  545. }
  546. if dataType == "positionId" {
  547. fmt.Println("111", positionId, TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 `, positionId))
  548. return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 and trailstatus != '08' `, positionId) >= cfg.AllocationCap
  549. //return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 `, positionId) >= cfg.AllocationCap
  550. } else {
  551. fmt.Println("222", positionId, TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign `, positionId))
  552. return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign and trailstatus != '08' `, positionId) >= cfg.AllocationCap
  553. //return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign `, positionId) >= cfg.AllocationCap
  554. }
  555. }
  556. func getSeatNumberPositionId(seatNumber string) (positionId int64) {
  557. saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "")
  558. if saleData != nil && len(*saleData) > 0 {
  559. positionId = common.Int64All((*saleData)["position_id"])
  560. }
  561. return
  562. }