kc.go 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. package main
  2. import (
  3. "database/sql"
  4. "encoding/json"
  5. "fmt"
  6. "log"
  7. "strconv"
  8. "strings"
  9. "time"
  10. "app.yhyue.com/moapp/jybase/common"
  11. "app.yhyue.com/moapp/jybase/date"
  12. "app.yhyue.com/moapp/jybase/mongodb"
  13. "app.yhyue.com/moapp/jybase/redis"
  14. "github.com/tealeg/xlsx"
  15. )
  16. func kcSync() {
  17. log.Println("客户成功系统移交定时任务开始")
  18. sql := `select * from dwd_f_userbase_order_info where pay_money > 0 and autoUpdate >= "` + cfg.LastkcTime + `" order by autoUpdate asc`
  19. data := TiDb.SelectBySql(sql)
  20. if data != nil && *data != nil && len(*data) > 0 {
  21. for _, v := range *data {
  22. product_type := common.ObjToString(v["product_type"])
  23. data_spec := common.ObjToString(v["data_spec"])
  24. starttime := common.ObjToString(v["vip_starttime"])
  25. order_status := common.IntAll(v["order_status"])
  26. if (product_type == "大会员" || product_type == "企业商机管理") && order_status == 1 && data_spec != "dhy4" && !strings.HasPrefix(starttime, "2099") {
  27. status := kcJob(v)
  28. if status == 0 {
  29. break
  30. }
  31. }
  32. cfg.LastkcTime = common.ObjToString(v["autoUpdate"])
  33. }
  34. }
  35. common.WriteSysConfig(&cfg)
  36. log.Println("客户成功系统移交定时任务结束")
  37. }
  38. func kcJob(data map[string]interface{}) int {
  39. nowTime := time.Now().Format(date.Date_Full_Layout)
  40. uId, entId, clueId, saveMap, name, positionId, status := common.ObjToString(data["uid"]), fmt.Sprint(data["ent_id"]), int64(0), map[string]interface{}{}, "", int64(0), 1
  41. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", "")
  42. if clueData != nil && len(*clueData) > 0 {
  43. clueId = common.Int64All((*clueData)["id"])
  44. if cicount := TiDb.Count("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}); cicount > 0 {
  45. return 1
  46. }
  47. starttime := common.ObjToString(data["vip_starttime"])
  48. endtime := common.ObjToString(data["vip_endtime"])
  49. // user_role := common.IntAll(data["user_role"])
  50. buy_subject := common.IntAll(data["buy_subject"])
  51. product_type := common.ObjToString(data["product_type"])
  52. data_spec := common.ObjToString(data["data_spec"])
  53. userName := common.ObjToString((*clueData)["name"])
  54. phone := common.ObjToString((*clueData)["phone"])
  55. product, company_name := 0, common.ObjToString(data["company_name"])
  56. productMap := map[string]int{
  57. "dhy6": 1,
  58. "dhy7": 2,
  59. "dhy3": 4,
  60. "dhy1": 5,
  61. "dhy2": 6,
  62. "dhy5": 7,
  63. "企业商机管理": 8,
  64. }
  65. if buy_subject == 1 {
  66. entId = common.ObjToString(data["userid"])
  67. }
  68. if product_type == "企业商机管理" {
  69. product = productMap[product_type]
  70. powerData := TiDb.FindOne("dwd_f_data_equity_info", map[string]interface{}{"phone": phone, "product_type": "商机管理"}, "", "comeintime desc")
  71. if powerData != nil {
  72. starttime = common.ObjToString((*powerData)["starttime"])
  73. endtime = common.ObjToString((*powerData)["endtime"])
  74. } else {
  75. return 0
  76. }
  77. } else {
  78. if data_spec == "dhy6" {
  79. product = 1
  80. filter := common.ObjToString(data["filter"])
  81. filterMap := map[string]interface{}{}
  82. json.Unmarshal([]byte(filter), &filterMap)
  83. if len(filterMap) > 0 {
  84. areaCount := common.IntAll(filterMap["areaCount"])
  85. if areaCount == 1 {
  86. product = 3
  87. }
  88. }
  89. } else {
  90. product = productMap[data_spec]
  91. }
  92. }
  93. //同一公司名称(以客户详情-组织机构-公司名称)下的线索需分配给同1人
  94. //合力亿捷线索同步
  95. customerData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
  96. if customerData != nil {
  97. status999 := common.ObjToString((*customerData)["status999"]) //线索状态
  98. source := common.ObjToString((*customerData)["source"]) //销售来源
  99. customerNeeds := common.ObjToString((*customerData)["customerNeeds"]) //客户需求
  100. wantGoods := common.ObjToString((*customerData)["wantGoods"]) //意向产品
  101. job := common.ObjToString((*customerData)["job"]) //职位
  102. createTime := common.ObjToString((*customerData)["createTime"]) //创建时间
  103. lastUpdateTime := common.ObjToString((*customerData)["lastUpdateTime"]) //更新时间
  104. area := common.ObjToString((*customerData)["area"]) //关注区域
  105. customerBudget := common.ObjToString((*customerData)["customerBudget"]) //客户预算
  106. isPolicymaker := common.ObjToString((*customerData)["customerBudget"]) //是否为决策人
  107. belongToIndustry := common.ObjToString((*customerData)["belongToIndustry"]) //所属行业
  108. seatNumber := common.ObjToString((*customerData)["empNo"]) //坐席号
  109. statusMap := map[string]string{
  110. "status0": "08",
  111. "status1": "07",
  112. "status2": "06",
  113. "status3": "05",
  114. "status4": "04",
  115. "status6": "00",
  116. "status5": "01",
  117. "spaceNumber": "02",
  118. "phoneDown": "02",
  119. }
  120. if status999 != "" {
  121. status999 = statusMap[status999]
  122. } else {
  123. status999 = "01"
  124. }
  125. top_cluetype := "172"
  126. sub_cluetype := ""
  127. cluetypeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"name": "其他-" + source}, "", "")
  128. if cluetypeData != nil {
  129. sub_cluetype = common.ObjToString((*cluetypeData)["code"])
  130. }
  131. wantGoods = strings.ReplaceAll(wantGoods, "剑鱼大会员", "大会员")
  132. wantGoods = strings.ReplaceAll(wantGoods, "数据导出", "数据流量包")
  133. if isPolicymaker == "是" {
  134. isPolicymaker = "决策人"
  135. } else {
  136. isPolicymaker = "使用人"
  137. }
  138. areaCodeArr := []string{}
  139. areaCode := ""
  140. for _, v := range strings.Split(area, ",") {
  141. areaCodeArr = append(areaCodeArr, AreaCode[v])
  142. }
  143. if len(areaCodeArr) > 0 {
  144. areaCode = strings.Join(areaCodeArr, ",")
  145. }
  146. SalePositionId := getSeatNumberPositionId(seatNumber)
  147. TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, map[string]interface{}{
  148. "position_id": SalePositionId,
  149. "seatNumber": seatNumber,
  150. "is_assign": -2,
  151. "createtime": createTime,
  152. "updatetime": lastUpdateTime,
  153. "top_cluetype": top_cluetype,
  154. "sub_cluetype": sub_cluetype,
  155. "customer_demand": customerNeeds,
  156. "intended_products": wantGoods,
  157. "customer_budget": customerBudget,
  158. "contact_type": isPolicymaker,
  159. "position": job,
  160. "industry": belongToIndustry,
  161. "follow_project_area": areaCode,
  162. })
  163. }
  164. //
  165. entIds := common.IntAll(data["ent_id"])
  166. positionId, name = cAutoDraw(entIds)
  167. saveMap = map[string]interface{}{
  168. "clue_id": clueId,
  169. "transfertime": nowTime,
  170. "position_id": positionId,
  171. "name": name,
  172. "service_starttime": starttime,
  173. "service_endtime": endtime,
  174. "ent_id": entId,
  175. "is_task": 1,
  176. "tasktime": nowTime,
  177. "taskstatus": 0,
  178. "tasksource": "1",
  179. "is_admin": 1,
  180. "product_access": product,
  181. "buy_subject": buy_subject,
  182. "relationship_building_way": 1,
  183. "inventory_way": 1,
  184. "training_way": 1,
  185. "is_pre_sales_training": 0,
  186. "service_stage": 1,
  187. "company_name": company_name,
  188. }
  189. cId, ok, updateId1, updateId2, updateId3 := int64(-1), false, int64(-1), int64(-1), int64(-1)
  190. if TiDb.ExecTx("保存客户", func(tx *sql.Tx) bool {
  191. cId = TiDb.InsertByTx(tx, "dwd_f_csm_customer_info", saveMap)
  192. ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
  193. updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
  194. "clue_id": clueId,
  195. "position_id": positionId,
  196. "change_type": "加入任务车",
  197. "new_value": "未建联",
  198. "createtime": nowTime,
  199. "BCPCID": common.GetRandom(32),
  200. "operator_id": -1,
  201. })
  202. updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
  203. "clue_id": clueId,
  204. "position_id": positionId,
  205. "change_type": "成交客户移交",
  206. "new_value": "",
  207. "createtime": nowTime,
  208. "BCPCID": common.GetRandom(32),
  209. "operator_id": -1,
  210. })
  211. updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
  212. "clue_id": clueId,
  213. "position_id": positionId,
  214. "change_field": "position_id",
  215. "change_type": "客户成功经理变更",
  216. "old_value": "/",
  217. "new_value": name,
  218. "createtime": nowTime,
  219. "BCPCID": common.GetRandom(32),
  220. "operator_id": -1,
  221. })
  222. return cId > -1 && ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1
  223. }) {
  224. TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, name)
  225. log.Println("保存客户成功")
  226. } else {
  227. log.Println("保存客户失败!!!", clueId, cId, ok, updateId1, updateId2, updateId3, " 用户信息 ", name, positionId, uId)
  228. }
  229. return status
  230. } else {
  231. log.Println("客户未查到线索!!!", uId)
  232. if isExists, _ := redis.Exists("bidx", "bidx_uId_"+uId); isExists {
  233. redisInt := redis.GetInt("bidx", "bidx_uId_"+uId)
  234. if redisInt > 2 {
  235. return 1
  236. } else {
  237. redis.Incr("bidx", "bidx_uId_"+uId)
  238. return 0
  239. }
  240. } else {
  241. redis.Put("bidx", "bidx_uId_"+uId, 1, 3600)
  242. return 0
  243. }
  244. }
  245. }
  246. func cAutoDraw(entId int) (positionId int64, name string) {
  247. query := `SELECT name,position_id FROM dwd_d_crm_department_level_succbi WHERE bi_pcode = (SELECT bi_code FROM dwd_d_crm_department_level_succbi WHERE name = "客户成功组") and resign = 0`
  248. data := TiDb.SelectBySql(query)
  249. if data != nil && len(*data) > 0 {
  250. if entId > 0 {
  251. entdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"ent_id": entId}, "", "")
  252. if entdata != nil && len(*entdata) > 0 {
  253. positionId = common.Int64All((*entdata)["position_id"])
  254. name = common.ObjToString((*entdata)["name"])
  255. return
  256. }
  257. }
  258. sql := `select a.name,a.count from dwd_f_csm_customer_autodraw_record a INNER JOIN dwd_d_crm_department_level_succbi b on (a.name = b.name) where b.resign = 0`
  259. countData := TiDb.SelectBySql(sql)
  260. if countData != nil && len(*countData) > 0 {
  261. for _, v := range *data {
  262. //判断是否有新员工
  263. isOk := false
  264. for _, vv := range *countData {
  265. if common.ObjToString(v["name"]) == common.ObjToString(vv["name"]) {
  266. isOk = true
  267. }
  268. }
  269. //有新员工直接分给新员工
  270. if !isOk {
  271. name = common.ObjToString(v["name"])
  272. rData := TiDb.FindOne("dwd_f_csm_customer_autodraw_record", map[string]interface{}{}, "", "count desc")
  273. TiDb.Insert("dwd_f_csm_customer_autodraw_record", map[string]interface{}{
  274. "name": name,
  275. "count": common.Int64All((*rData)["count"]),
  276. })
  277. break
  278. }
  279. }
  280. res := int64(0)
  281. countres := 0
  282. for _, v := range *countData {
  283. if countres == 0 {
  284. res = common.Int64All(v["count"])
  285. name = common.ObjToString(v["name"])
  286. } else {
  287. if common.Int64All(v["count"]) <= res {
  288. res = common.Int64All(v["count"])
  289. name = common.ObjToString(v["name"])
  290. }
  291. }
  292. countres++
  293. }
  294. }
  295. for _, v := range *data {
  296. if name == common.ObjToString(v["name"]) {
  297. positionId = common.Int64All(v["position_id"])
  298. }
  299. }
  300. }
  301. return
  302. }
  303. func kcAuto() {
  304. log.Println("客户成功系统自动进入任务车定时任务开始")
  305. nowTime := time.Now().Format(date.Date_Full_Layout)
  306. sql := `select * from dwd_f_csm_customer_info where ((relationship_building_way != 1 and inventory_way = 1) or (inventory_way != 1 and training_way = 1)) and is_task = 0`
  307. data := TiDb.SelectBySql(sql)
  308. if data != nil && *data != nil && len(*data) > 0 {
  309. for _, v := range *data {
  310. relationship_building_way := common.IntAll(v["relationship_building_way"])
  311. inventory_way := common.IntAll(v["inventory_way"])
  312. training_way := common.IntAll(v["training_way"])
  313. positionId := common.Int64All(v["position_id"])
  314. clueId := common.Int64All(v["clue_id"])
  315. tasksource, tasksources := common.ObjToString(v["tasksource"]), ""
  316. taskstatus := common.IntAll(v["taskstatus"])
  317. if relationship_building_way != 1 && inventory_way == 1 {
  318. tasksources = "2"
  319. TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
  320. "clue_id": clueId,
  321. "position_id": positionId,
  322. "change_type": "加入任务车",
  323. "new_value": "未盘点",
  324. "createtime": nowTime,
  325. "BCPCID": common.GetRandom(32),
  326. "operator_id": -1,
  327. })
  328. } else if inventory_way != 1 && training_way == 1 {
  329. tasksources = "3"
  330. TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
  331. "clue_id": clueId,
  332. "position_id": positionId,
  333. "change_type": "加入任务车",
  334. "new_value": "未培训",
  335. "createtime": nowTime,
  336. "BCPCID": common.GetRandom(32),
  337. "operator_id": -1,
  338. })
  339. }
  340. if taskstatus == 1 {
  341. tasksource = tasksources
  342. } else {
  343. if tasksource != "" {
  344. if !strings.Contains(tasksource, tasksources) {
  345. tasksource += "," + tasksources
  346. }
  347. } else {
  348. tasksource = tasksources
  349. }
  350. }
  351. TiDb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
  352. "tasksource": tasksource,
  353. "tasktime": nowTime,
  354. "is_task": 1,
  355. "taskstatus": 0,
  356. })
  357. }
  358. }
  359. log.Println("客户成功系统进入任务车定时任务结束")
  360. }
  361. func ordersClue() {
  362. log.Println("后台订单线索定时任务开始")
  363. lastOrderClueId := cfg.LastOrderClueId
  364. nowTime := time.Now().Format(date.Date_Full_Layout)
  365. sql := fmt.Sprintf(`select * from dataexport_order where autoUpdate >= "%s" order by autoUpdate asc`, lastOrderClueId)
  366. data := Mysql.SelectBySql(sql)
  367. if data != nil && *data != nil && len(*data) > 0 {
  368. for _, v := range *data {
  369. order_status := common.IntAll(v["order_status"])
  370. is_backstage_order := common.IntAll(v["is_backstage_order"])
  371. pay_money := common.IntAll(v["pay_money"])
  372. saleDep := common.ObjToString(v["saleDep"])
  373. salesperson := common.ObjToString(v["salesperson"])
  374. user_phone := common.ObjToString(v["user_phone"])
  375. createperson := common.ObjToString(v["create_person"])
  376. saleMoney := common.ObjToString(v["saleMoney"])
  377. userId, uId, cluename, seatNumber, positionId, trailstatus, clueId := common.ObjToString(v["user_id"]), "", "", "", int64(0), "", int64(0)
  378. product_type_str2 := `"大会员","企业商机管理","VIP订阅"`
  379. product_type := common.ObjToString(v["product_type"])
  380. if order_status == 1 && is_backstage_order == 1 && salesperson != "" && !strings.HasPrefix(user_phone, "9") && strings.Contains(product_type_str2, product_type) {
  381. //销售部
  382. query := map[string]interface{}{}
  383. if product_type == "企业商机管理" {
  384. query["phone"] = user_phone
  385. userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
  386. if userInfo != nil && len(*userInfo) > 0 {
  387. uId = common.ObjToString((*userInfo)["uid"])
  388. userId = common.ObjToString((*userInfo)["userid"])
  389. } else {
  390. break
  391. }
  392. } else {
  393. if !mongodb.IsObjectIdHex(userId) {
  394. userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userId}, "", "")
  395. if userMapping != nil && len(*userMapping) > 0 {
  396. userId = common.ObjToString((*userMapping)["userid"])
  397. } else {
  398. break
  399. }
  400. }
  401. query["userid"] = userId
  402. userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
  403. if userInfo != nil && len(*userInfo) > 0 {
  404. uId = common.ObjToString((*userInfo)["uid"])
  405. } else {
  406. break
  407. }
  408. }
  409. cluename = common.ObjToString(v["company_name"])
  410. if cluename == "" {
  411. cluename = user_phone
  412. }
  413. if pay_money > 0 {
  414. trailstatus = "08"
  415. } else {
  416. trailstatus = "01"
  417. }
  418. isGroup, isCommerce := GetCompanyType(cluename) //判断是否集团公司、工商库
  419. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", "")
  420. if clueData == nil || len(*clueData) == 0 {
  421. log.Println("saleDep", saleDep)
  422. if strings.HasPrefix(saleDep, "01") || strings.HasPrefix(saleDep, "05") {
  423. //撞单
  424. log.Println("销售部订单", saleDep)
  425. if strings.Contains(salesperson, ",") {
  426. log.Println("销售部撞单 ", salesperson)
  427. if saleMoney != "" {
  428. var saleMoneyStu = struct {
  429. Data []struct {
  430. Name string
  431. Money interface{}
  432. }
  433. }{}
  434. json.Unmarshal([]byte(saleMoney), &saleMoneyStu)
  435. areAllEqual := true
  436. if firstMoney, ok := saleMoneyStu.Data[0].Money.(string); ok {
  437. maxMoney := "0"
  438. log.Println("销售部订单firstMoney", saleMoneyStu, saleMoneyStu.Data[0].Money)
  439. for _, item := range saleMoneyStu.Data {
  440. if item.Name != "合计" && item.Money != firstMoney {
  441. areAllEqual = false
  442. break
  443. }
  444. }
  445. log.Println("销售部订单areAllEqual", areAllEqual)
  446. if areAllEqual {
  447. salesperson = createperson
  448. } else {
  449. for _, item := range saleMoneyStu.Data {
  450. money1, _ := strconv.ParseFloat(item.Money.(string), 64)
  451. money2, _ := strconv.ParseFloat(maxMoney, 64)
  452. if item.Name != "合计" && money1 > money2 {
  453. maxMoney = item.Money.(string)
  454. salesperson = item.Name
  455. }
  456. }
  457. }
  458. } else {
  459. maxMoney := 0.0
  460. log.Println("销售部订单firstMoney222", saleMoneyStu, saleMoneyStu.Data[0].Money)
  461. for _, item := range saleMoneyStu.Data {
  462. if item.Name != "合计" && item.Money != firstMoney {
  463. areAllEqual = false
  464. break
  465. }
  466. }
  467. log.Println("销售部订单areAllEqual222", areAllEqual)
  468. if areAllEqual {
  469. salesperson = createperson
  470. } else {
  471. for _, item := range saleMoneyStu.Data {
  472. if item.Name != "合计" && item.Money.(float64) > maxMoney {
  473. maxMoney = item.Money.(float64)
  474. salesperson = item.Name
  475. }
  476. }
  477. }
  478. }
  479. } else {
  480. salesperson = createperson
  481. }
  482. }
  483. log.Println("销售部订单salesperson", salesperson)
  484. saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"name": salesperson}, "", "")
  485. if saleData != nil {
  486. seatNumber = common.ObjToString((*saleData)["seat_number"])
  487. positionId = common.Int64All((*saleData)["position_id"])
  488. }
  489. clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
  490. "userid": userId,
  491. "uid": uId,
  492. "seatNumber": seatNumber,
  493. "position_id": positionId,
  494. "is_assign": 1,
  495. "comeintime": nowTime,
  496. "createtime": nowTime,
  497. "updatetime": nowTime,
  498. "cluename": cluename,
  499. "top_cluetype": "4",
  500. "sub_cluetype": "154",
  501. "trailstatus": trailstatus,
  502. "name": user_phone,
  503. "phone": user_phone,
  504. "comeinsource_private": 2,
  505. "is_task": 0,
  506. "taskstatus": 0,
  507. "company_nature": isGroup,
  508. "company_verification": isCommerce,
  509. })
  510. } else if strings.HasPrefix(saleDep, "03") {
  511. log.Println("市场部订单", saleDep)
  512. clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
  513. "userid": userId,
  514. "uid": uId,
  515. "is_assign": -2,
  516. "createtime": nowTime,
  517. "updatetime": nowTime,
  518. "cluename": cluename,
  519. "top_cluetype": "4",
  520. "sub_cluetype": "154",
  521. "trailstatus": trailstatus,
  522. "name": user_phone,
  523. "phone": user_phone,
  524. "is_task": 0,
  525. "taskstatus": 0,
  526. "company_nature": isGroup,
  527. "company_verification": isCommerce,
  528. })
  529. }
  530. if clueId > 0 {
  531. TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
  532. "clue_id": clueId,
  533. "position_id": common.If(positionId > 0, positionId, -1),
  534. "change_type": "创建线索",
  535. "new_value": "系统自动创建",
  536. "createtime": nowTime,
  537. "BCPCID": common.GetRandom(32),
  538. "operator_id": -1,
  539. })
  540. }
  541. }
  542. }
  543. cfg.LastOrderClueId = common.ObjToString(v["autoUpdate"])
  544. }
  545. }
  546. common.WriteSysConfig(&cfg)
  547. log.Println("后台订单线索定时任务结束")
  548. }
  549. func kcHistorySync() {
  550. filePath := "./无线索的.xlsx"
  551. // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
  552. // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
  553. // return
  554. xlFile, _ := xlsx.OpenFile(filePath)
  555. //获取行数
  556. // length := len(xlFile.Sheets[0].Rows)
  557. //开辟除表头外的行数的数组内存
  558. // resourceArr := make([]map[string]interface{}, length-1)
  559. //遍历sheet
  560. for k, sheet := range xlFile.Sheets {
  561. if k > 0 {
  562. break
  563. }
  564. //遍历每一行
  565. for rowIndex, row := range sheet.Rows {
  566. //跳过第一行表头信息
  567. if rowIndex == 0 {
  568. continue
  569. }
  570. nowTime := time.Now().Format(date.Date_Full_Layout)
  571. relationship_building_way := row.Cells[1].Value
  572. relationship_building_ways := 1
  573. if relationship_building_way == "个人微信" {
  574. relationship_building_ways = 2
  575. } else if relationship_building_way == "企业微信" {
  576. relationship_building_ways = 3
  577. }
  578. training_way := row.Cells[2].Value
  579. training_ways := 1
  580. if training_way == "发送使用资料" {
  581. training_ways = 5
  582. } else if training_way == "线上一对一" {
  583. training_ways = 3
  584. } else if training_way == "线下一对一" {
  585. training_ways = 4
  586. }
  587. inventory_way := row.Cells[3].Value
  588. inventory_ways := 1
  589. if inventory_way == "电话盘点" {
  590. inventory_ways = 3
  591. } else if inventory_way == "微信盘点" {
  592. inventory_ways = 2
  593. }
  594. service_stage := row.Cells[4].Value
  595. service_stages := 1
  596. if service_stage == "断约" {
  597. service_stages = 2
  598. } else if service_stage == "续约期" {
  599. service_stages = 3
  600. }
  601. renewal_intention := row.Cells[5].Value
  602. renewal_intentions := 1
  603. if renewal_intention == "中" {
  604. renewal_intentions = 2
  605. } else if renewal_intention == "高" {
  606. renewal_intentions = 3
  607. }
  608. positive_behavior_reminder := row.Cells[6].Value
  609. positive_behavior_reminders := ""
  610. if positive_behavior_reminder != "" {
  611. positive_behavior_reminders = "1,3"
  612. }
  613. // negative_behavior_reminder := ""
  614. name := row.Cells[13].Value
  615. // phoneMap := map[string]string{
  616. // "朱庆伟": "17600755377",
  617. // "程涵": "15538709520",
  618. // "张铭铭": "18237530966",
  619. // }
  620. // company_name := row.Cells[10].Value
  621. company_address := row.Cells[14].Value
  622. company_website := row.Cells[15].Value
  623. service_starttime := row.Cells[16].Value
  624. service_endtime := row.Cells[17].Value
  625. industry_status := row.Cells[21].Value
  626. industry_statuss := 1
  627. if industry_status == "非头部" {
  628. industry_statuss = 2
  629. }
  630. target_customer_type := row.Cells[24].Value
  631. main_sale_way := row.Cells[25].Value
  632. main_get_info_way := row.Cells[26].Value
  633. bid_sales_proportion := row.Cells[27].Value
  634. continuous_use_judgment := row.Cells[29].Value
  635. bid_sales_proportions := 1
  636. continuous_use_judgments := 1
  637. if bid_sales_proportion == "10%-19%" {
  638. bid_sales_proportions = 2
  639. } else if bid_sales_proportion == "20%-49%" {
  640. bid_sales_proportions = 3
  641. } else if bid_sales_proportion == "50%-69%" {
  642. bid_sales_proportions = 4
  643. } else if bid_sales_proportion == "70%及以上" {
  644. bid_sales_proportions = 4
  645. }
  646. if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
  647. continuous_use_judgments = 2
  648. } else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
  649. continuous_use_judgments = 3
  650. } else if strings.Contains(continuous_use_judgment, "需持续培育") {
  651. continuous_use_judgments = 4
  652. }
  653. is_pre_sales_training := row.Cells[30].Value
  654. is_pre_sales_trainings := 0
  655. if is_pre_sales_training == "是" {
  656. is_pre_sales_trainings = 1
  657. }
  658. shpx := row.Cells[31].Value
  659. if shpx == "否" {
  660. training_ways = 2
  661. }
  662. notes := row.Cells[32].Value
  663. phone := strings.TrimSpace(row.Cells[11].Value)
  664. log.Println("PHONE", phone, name, len(phone))
  665. // if phone != "" && len(phone) == 11 && phoneMap[name] != "" {
  666. positionId := 0
  667. if name == "程涵" {
  668. positionId = 2202735
  669. } else if name == "张铭铭" {
  670. positionId = 2202736
  671. }
  672. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
  673. log.Println("clueData", clueData)
  674. if clueData != nil {
  675. clueId := common.Int64All((*clueData)["id"])
  676. log.Println("线索存在", phone, clueId)
  677. role := row.Cells[18].Value
  678. business_scope := row.Cells[19].Value
  679. industry := row.Cells[20].Value
  680. salesperson_num := row.Cells[22].Value
  681. salesperson_nums := 1
  682. if salesperson_num == "10-19" {
  683. salesperson_nums = 2
  684. } else if salesperson_num == "20-49" {
  685. salesperson_nums = 3
  686. } else if salesperson_num == "50-99" {
  687. salesperson_nums = 4
  688. }
  689. area := row.Cells[23].Value
  690. areaArr := []string{}
  691. for _, v := range strings.Split(area, ",") {
  692. areaArr = append(areaArr, AreaCode[v])
  693. }
  694. follow_project_area := ""
  695. if len(areaArr) > 0 {
  696. follow_project_area = strings.Join(areaArr, ",")
  697. }
  698. customer_demand := row.Cells[28].Value
  699. updatetime := row.Cells[36].Value
  700. ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
  701. "role": role,
  702. "business_scope": business_scope,
  703. "industry": industry,
  704. "follow_project_area": follow_project_area,
  705. "customer_demand": customer_demand,
  706. "updatetime": updatetime,
  707. "is_transfer": 1,
  708. "salesperson_num": salesperson_nums,
  709. })
  710. if ok {
  711. entId := "0"
  712. buy_subject := 1
  713. company_name := ""
  714. product := 1
  715. powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
  716. if powerData != nil {
  717. buy_subject = common.IntAll((*powerData)["buy_subject"])
  718. if buy_subject == 1 {
  719. entId = common.ObjToString((*powerData)["userid"])
  720. } else {
  721. entId = fmt.Sprint((*powerData)["ent_id"])
  722. }
  723. company_name = common.ObjToString((*powerData)["company_name"])
  724. product_type := common.ObjToString((*powerData)["product_type"])
  725. data_spec := common.ObjToString((*powerData)["data_spec"])
  726. productMap := map[string]int{
  727. "dhy6": 1,
  728. "dhy7": 2,
  729. "dhy3": 4,
  730. "dhy1": 5,
  731. "dhy2": 6,
  732. "dhy5": 7,
  733. "企业商机管理": 8,
  734. }
  735. if product_type == "企业商机管理" {
  736. product = productMap[product_type]
  737. } else {
  738. if data_spec == "dhy6" {
  739. product = 1
  740. filter := common.ObjToString((*powerData)["filter"])
  741. filterMap := map[string]interface{}{}
  742. json.Unmarshal([]byte(filter), &filterMap)
  743. if len(filterMap) > 0 {
  744. areaCount := common.IntAll(filterMap["areaCount"])
  745. if areaCount == 1 {
  746. product = 3
  747. }
  748. }
  749. } else {
  750. product = productMap[data_spec]
  751. }
  752. }
  753. }
  754. cid := TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
  755. "clue_id": clueId,
  756. "transfertime": nowTime,
  757. "position_id": positionId,
  758. "name": name,
  759. "service_starttime": service_starttime,
  760. "service_endtime": service_endtime,
  761. "ent_id": entId,
  762. "is_task": 1,
  763. "tasktime": nowTime,
  764. "taskstatus": 0,
  765. "tasksource": "1",
  766. "is_admin": 1,
  767. "product_access": product,
  768. "buy_subject": buy_subject,
  769. "relationship_building_way": relationship_building_ways,
  770. "inventory_way": inventory_ways,
  771. "training_way": training_ways,
  772. "is_pre_sales_training": is_pre_sales_trainings,
  773. "service_stage": service_stages,
  774. "company_name": company_name,
  775. "renewal_intention": renewal_intentions,
  776. "positive_behavior_reminder": positive_behavior_reminders,
  777. "company_address": company_address,
  778. "company_website": company_website,
  779. "industry_status": industry_statuss,
  780. "target_customer_type": target_customer_type,
  781. "main_sale_way": main_sale_way,
  782. "main_get_info_way": main_get_info_way,
  783. // "bid_sales_proportion": bid_sales_proportions,
  784. // "continuous_use_judgment": continuous_use_judgments,
  785. "notes": notes,
  786. })
  787. if cid > 0 {
  788. log.Println("保存客户成功", phone)
  789. } else {
  790. log.Println("保存客户失败!!!", phone)
  791. }
  792. } else {
  793. log.Println("线索修改失败!!!", phone)
  794. }
  795. } else {
  796. role := row.Cells[18].Value
  797. business_scope := row.Cells[19].Value
  798. industry := row.Cells[20].Value
  799. salesperson_num := row.Cells[22].Value
  800. salesperson_nums := 1
  801. if salesperson_num == "10-19" {
  802. salesperson_nums = 2
  803. } else if salesperson_num == "20-49" {
  804. salesperson_nums = 3
  805. } else if salesperson_num == "50-99" {
  806. salesperson_nums = 4
  807. }
  808. area := row.Cells[23].Value
  809. areaArr := []string{}
  810. for _, v := range strings.Split(area, ",") {
  811. areaArr = append(areaArr, AreaCode[v])
  812. }
  813. follow_project_area := ""
  814. if len(areaArr) > 0 {
  815. follow_project_area = strings.Join(areaArr, ",")
  816. }
  817. customer_demand := row.Cells[28].Value
  818. entId := "0"
  819. clueId := int64(0)
  820. buy_subject := 1
  821. company_name := ""
  822. product := 1
  823. powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
  824. if powerData != nil {
  825. buy_subject = common.IntAll((*powerData)["buy_subject"])
  826. if buy_subject == 1 {
  827. entId = common.ObjToString((*powerData)["userid"])
  828. } else {
  829. entId = fmt.Sprint((*powerData)["ent_id"])
  830. }
  831. company_name = common.ObjToString((*powerData)["company_name"])
  832. product_type := common.ObjToString((*powerData)["product_type"])
  833. data_spec := common.ObjToString((*powerData)["data_spec"])
  834. productMap := map[string]int{
  835. "dhy6": 1,
  836. "dhy7": 2,
  837. "dhy3": 4,
  838. "dhy1": 5,
  839. "dhy2": 6,
  840. "dhy5": 7,
  841. "企业商机管理": 8,
  842. }
  843. if product_type == "企业商机管理" {
  844. product = productMap[product_type]
  845. } else {
  846. if data_spec == "dhy6" {
  847. product = 1
  848. filter := common.ObjToString((*powerData)["filter"])
  849. filterMap := map[string]interface{}{}
  850. json.Unmarshal([]byte(filter), &filterMap)
  851. if len(filterMap) > 0 {
  852. areaCount := common.IntAll(filterMap["areaCount"])
  853. if areaCount == 1 {
  854. product = 3
  855. }
  856. }
  857. } else {
  858. product = productMap[data_spec]
  859. }
  860. }
  861. //
  862. uId := common.ObjToString((*powerData)["uid"])
  863. userId := common.ObjToString((*powerData)["userid"])
  864. pay_money := common.IntAll((*powerData)["pay_money"])
  865. seatNumber, trailstatus := "", ""
  866. salePositionId := int64(0)
  867. cluename := common.ObjToString((*powerData)["company_name"])
  868. salesperson := common.ObjToString((*powerData)["salesperson"])
  869. if cluename == "" {
  870. cluename = phone
  871. }
  872. if pay_money > 0 {
  873. trailstatus = "08"
  874. } else {
  875. trailstatus = "01"
  876. }
  877. saleData := TiDb.FindOne("jy_salesperson_info", map[string]interface{}{"name": salesperson}, "", "")
  878. if saleData != nil {
  879. seatNumber = common.ObjToString((*saleData)["seat_number"])
  880. salePositionId = common.Int64All((*saleData)["position_id"])
  881. }
  882. clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
  883. "userid": userId,
  884. "uid": uId,
  885. "seatNumber": seatNumber,
  886. "position_id": salePositionId,
  887. "is_assign": 1,
  888. "comeintime": nowTime,
  889. "createtime": nowTime,
  890. "updatetime": nowTime,
  891. "cluename": cluename,
  892. "top_cluetype": "4",
  893. "sub_cluetype": "154",
  894. "trailstatus": trailstatus,
  895. "name": phone,
  896. "phone": phone,
  897. "comeinsource_private": 2,
  898. "is_task": 0,
  899. "taskstatus": 1,
  900. "role": role,
  901. "business_scope": business_scope,
  902. "industry": industry,
  903. "follow_project_area": follow_project_area,
  904. "customer_demand": customer_demand,
  905. "is_transfer": 1,
  906. "salesperson_num": salesperson_nums,
  907. })
  908. //
  909. }
  910. TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
  911. "clue_id": clueId,
  912. "transfertime": nowTime,
  913. "position_id": positionId,
  914. "name": name,
  915. "service_starttime": service_starttime,
  916. "service_endtime": service_endtime,
  917. "ent_id": entId,
  918. "is_task": 0,
  919. "tasktime": nil,
  920. "taskstatus": 1,
  921. "tasksource": nil,
  922. "is_admin": 1,
  923. "product_access": product,
  924. "buy_subject": buy_subject,
  925. "relationship_building_way": relationship_building_ways,
  926. "inventory_way": inventory_ways,
  927. "training_way": training_ways,
  928. "is_pre_sales_training": is_pre_sales_trainings,
  929. "service_stage": service_stages,
  930. "company_name": company_name,
  931. "renewal_intention": renewal_intentions,
  932. "positive_behavior_reminder": positive_behavior_reminders,
  933. "company_address": company_address,
  934. "company_website": company_website,
  935. "industry_status": industry_statuss,
  936. "target_customer_type": target_customer_type,
  937. "main_sale_way": main_sale_way,
  938. "main_get_info_way": main_get_info_way,
  939. "bid_sales_proportion": bid_sales_proportions,
  940. "continuous_use_judgment": continuous_use_judgments,
  941. "notes": notes,
  942. })
  943. }
  944. // } else {
  945. // log.Println("手机号有问题!!!", phone)
  946. // row.AddCell().SetValue("手机号有问题!!!")
  947. // }
  948. }
  949. }
  950. // err := xlFile.Save("./222.xlsx")
  951. // if err != nil {
  952. // log.Println("xls error")
  953. // }
  954. }
  955. func kcHistorySyncs() {
  956. filePath := "./有线索的.xlsx"
  957. // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
  958. // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
  959. // return
  960. xlFile, _ := xlsx.OpenFile(filePath)
  961. //获取行数
  962. // length := len(xlFile.Sheets[0].Rows)
  963. //开辟除表头外的行数的数组内存
  964. // resourceArr := make([]map[string]interface{}, length-1)
  965. //遍历sheet
  966. for k, sheet := range xlFile.Sheets {
  967. if k > 0 {
  968. break
  969. }
  970. //遍历每一行
  971. for rowIndex, row := range sheet.Rows {
  972. //跳过第一行表头信息
  973. if rowIndex == 0 {
  974. continue
  975. }
  976. bid_sales_proportion := row.Cells[2].Value
  977. continuous_use_judgment := row.Cells[3].Value
  978. phone := row.Cells[0].Value
  979. bid_sales_proportions := 1
  980. continuous_use_judgments := 1
  981. if bid_sales_proportion == "10%-19%" {
  982. bid_sales_proportions = 2
  983. } else if bid_sales_proportion == "20%-49%" {
  984. bid_sales_proportions = 3
  985. } else if bid_sales_proportion == "50%-69%" {
  986. bid_sales_proportions = 4
  987. } else if bid_sales_proportion == "70%及以上" {
  988. bid_sales_proportions = 4
  989. }
  990. if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
  991. continuous_use_judgments = 2
  992. } else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
  993. continuous_use_judgments = 3
  994. } else if strings.Contains(continuous_use_judgment, "需持续培育") {
  995. continuous_use_judgments = 4
  996. }
  997. if phone != "" {
  998. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
  999. if clueData != nil {
  1000. clueId := common.Int64All((*clueData)["id"])
  1001. log.Println("线索存在", phone, clueId)
  1002. salesperson_num := row.Cells[1].Value
  1003. salesperson_nums := 1
  1004. if salesperson_num == "10-19" {
  1005. salesperson_nums = 2
  1006. } else if salesperson_num == "20-49" {
  1007. salesperson_nums = 3
  1008. } else if salesperson_num == "50-99" {
  1009. salesperson_nums = 4
  1010. }
  1011. ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
  1012. "salesperson_num": salesperson_nums,
  1013. })
  1014. if ok {
  1015. oks := TiDb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
  1016. "bid_sales_proportion": bid_sales_proportions,
  1017. "continuous_use_judgment": continuous_use_judgments,
  1018. })
  1019. if oks {
  1020. log.Println("修改客户成功", phone)
  1021. } else {
  1022. log.Println("修改客户失败!!!", phone)
  1023. }
  1024. } else {
  1025. log.Println("线索修改失败!!!", phone)
  1026. }
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. func kcVisitSync() {
  1033. filePath := "./222.xlsx"
  1034. // SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
  1035. // log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
  1036. // return
  1037. xlFile, _ := xlsx.OpenFile(filePath)
  1038. //获取行数
  1039. // length := len(xlFile.Sheets[0].Rows)
  1040. //开辟除表头外的行数的数组内存
  1041. // resourceArr := make([]map[string]interface{}, length-1)
  1042. //遍历sheet
  1043. for k, sheet := range xlFile.Sheets {
  1044. if k == 1 {
  1045. //遍历每一行
  1046. for rowIndex, row := range sheet.Rows {
  1047. //跳过第一行表头信息
  1048. if rowIndex == 0 {
  1049. continue
  1050. }
  1051. tasksource := row.Cells[1].Value
  1052. tasksources := 1
  1053. if tasksource == "客户情况盘点" {
  1054. tasksources = 2
  1055. } else if tasksource == "未培训" {
  1056. tasksources = 3
  1057. } else if tasksource == "日常沟通" {
  1058. tasksources = 4
  1059. } else if tasksource == "续约沟通" {
  1060. tasksources = 5
  1061. } else if tasksource == "月度回访" {
  1062. tasksources = 6
  1063. } else if tasksource == "培训首周回访" {
  1064. tasksources = 7
  1065. } else if tasksource == "建联" {
  1066. tasksources = 1
  1067. }
  1068. phone := row.Cells[2].Value
  1069. trail_way := row.Cells[3].Value
  1070. trail_ways := 1
  1071. if trail_way == "电话沟通" {
  1072. trail_ways = 2
  1073. } else if trail_way == "线下面访" {
  1074. trail_ways = 3
  1075. } else if trail_way == "腾讯会议" {
  1076. trail_ways = 4
  1077. }
  1078. content := row.Cells[4].Value
  1079. name := row.Cells[5].Value
  1080. positionId := 0
  1081. if name == "程涵" {
  1082. positionId = 2202735
  1083. } else if name == "张铭铭" {
  1084. positionId = 2202736
  1085. } else {
  1086. positionId = -1
  1087. }
  1088. createtime := row.Cells[6].Value
  1089. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
  1090. if clueData != nil {
  1091. clueId := common.Int64All((*clueData)["id"])
  1092. TiDb.Insert("dwd_f_crm_trail_content", map[string]interface{}{
  1093. "clue_id": clueId,
  1094. "position_id": positionId,
  1095. "operator_id": -1,
  1096. "content": content,
  1097. "createtime": createtime,
  1098. "tasksource": tasksources,
  1099. "trail_way": trail_ways,
  1100. })
  1101. } else {
  1102. row.AddCell().SetValue("没有线索")
  1103. }
  1104. }
  1105. } else if k == 2 {
  1106. //遍历每一行
  1107. for rowIndex, row := range sheet.Rows {
  1108. //跳过第一行表头信息
  1109. if rowIndex == 0 {
  1110. continue
  1111. }
  1112. phone := row.Cells[2].Value
  1113. contact_type := row.Cells[4].Value
  1114. clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
  1115. if clueData != nil {
  1116. clueId := common.Int64All((*clueData)["id"])
  1117. TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"contact_type": contact_type})
  1118. } else {
  1119. row.AddCell().SetValue("没有线索")
  1120. }
  1121. }
  1122. }
  1123. }
  1124. err := xlFile.Save("./333.xlsx")
  1125. if err != nil {
  1126. log.Println("xls error")
  1127. }
  1128. }