瀏覽代碼

跟进记录

xuzhiheng 2 年之前
父節點
當前提交
0398e36000
共有 7 個文件被更改,包括 177 次插入4 次删除
  1. 1 0
      clueSync/config.go
  2. 63 1
      clueSync/config.json
  3. 1 0
      clueSync/go.mod
  4. 2 0
      clueSync/go.sum
  5. 18 1
      clueSync/job.go
  6. 4 2
      clueSync/main.go
  7. 88 0
      clueSync/trailContent.go

+ 1 - 0
clueSync/config.go

@@ -21,6 +21,7 @@ type (
 		LastOrderTime   string `json:"lastOrderTime"`
 		LastUserTime    string `json:"lastUserTime"`
 		LastSubscribeId string `json:"lastSubscribeId"`
+		XlsxNum         string `json:"xlsxNum"`
 		CountLimit      int64  `json:"countLimit"`
 		TiDb            struct {
 			Host        string `json:"host"`

+ 63 - 1
clueSync/config.json

@@ -1 +1,63 @@
-{"cornexp1":"0 */30 * * * ?","cornexp2":"0 */10 * * * ?","cornexp3":"0 */5 * * * ?","cornexp4":"0 0 0 */1 * ? ","cornexp5":"0 */5 * * * ?","cornexp6":"0 */10 * * * ?","cornexp7":"","lastOrderId":172508,"lastUserId":"644101e58b6d74a60a09aec7","lastId":"6440faf7bd4ea1862af84c56","lastOrderTime":"2023-04-25 00:00:00","lastUserTime":"2023-04-25 00:00:00","lastSubscribeId":"64473e36c572141d78ec7a03","countLimit":1000,"tiDb":{"host":"192.168.3.149","port":4000,"database":"jianyu_subjectdb_test","user":"root","password":"Tibi#20211222","poolsize":20,"maxidle":40,"maxleft":40},"baseService":{"host":"192.168.3.217","port":4000,"database":"base_service","user":"root","password":"=PDT49#80Z!RVv52_z","poolsize":20,"maxidle":40,"maxleft":40},"mysql":{"host":"192.168.3.149","port":3306,"database":"jianyu","user":"root","password":"Topnet123","poolsize":20,"maxidle":40,"maxleft":40},"mgo":{"address":"192.168.3.206:27080","dbName":"qfw","dbSize":20},"mgoLog":{"address":"192.168.3.206:27090","dbName":"qfw","dbSize":20,"user":"admin","password":"123456"},"es":{"address":"http://192.168.3.206:9800","dbSize":20}}
+{
+	"cornexp1": "0 */30 * * * ?",
+	"cornexp2": "0 */10 * * * ?",
+	"cornexp3": "0 */5 * * * ?",
+	"cornexp4": "0 0 0 */1 * ? ",
+	"cornexp5": "0 */5 * * * ?",
+	"cornexp6": "0 */10 * * * ?",
+	"cornexp7": "0 */10 * * * ?",
+	"lastOrderId": 172508,
+	"lastUserId": "644101e58b6d74a60a09aec7",
+	"lastId": "6440faf7bd4ea1862af84c56",
+	"lastOrderTime": "2023-04-25 00:00:00",
+	"lastUserTime": "2023-04-25 00:00:00",
+	"lastSubscribeId": "64473e36c572141d78ec7a03",
+	"countLimit": 1000,
+	"xlsxNum": "1",
+	"tiDb": {
+		"host": "192.168.3.217",
+		"port": 4000,
+		"database": "jianyu_subjectdb_test",
+		"user": "root",
+		"password": "=PDT49#80Z!RVv52_z",
+		"poolsize": 20,
+		"maxidle": 40,
+		"maxleft": 40
+	},
+	"baseService": {
+		"host": "192.168.3.217",
+		"port": 4000,
+		"database": "base_service",
+		"user": "root",
+		"password": "=PDT49#80Z!RVv52_z",
+		"poolsize": 20,
+		"maxidle": 40,
+		"maxleft": 40
+	},
+	"mysql": {
+		"host": "192.168.3.149",
+		"port": 3306,
+		"database": "jianyu",
+		"user": "root",
+		"password": "Topnet123",
+		"poolsize": 20,
+		"maxidle": 40,
+		"maxleft": 40
+	},
+	"mgo": {
+		"address": "192.168.3.206:27080",
+		"dbName": "qfw",
+		"dbSize": 20
+	},
+	"mgoLog": {
+		"address": "192.168.3.206:27090",
+		"dbName": "qfw",
+		"dbSize": 20,
+		"user": "admin",
+		"password": "123456"
+	},
+	"es": {
+		"address": "http://192.168.3.206:9800",
+		"dbSize": 20
+	}
+}

+ 1 - 0
clueSync/go.mod

@@ -7,4 +7,5 @@ require (
 	app.yhyue.com/zhp/util v0.0.0-20211207072713-d9f1393203de
 	github.com/nsqio/go-nsq v1.1.0
 	github.com/robfig/cron v1.2.0
+	github.com/tealeg/xlsx v1.0.5
 )

+ 2 - 0
clueSync/go.sum

@@ -404,6 +404,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
 github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
+github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
 github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
 github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
 github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=

+ 18 - 1
clueSync/job.go

@@ -193,7 +193,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 	log.Println("data +++", top_cluetype, sub_cluetype, level, follow_project_area)
 	position_id, seatNumber, saleName, saleData := autoDraw(level)
 	log.Println("data -------", position_id, seatNumber, saleName)
-	if position_id > 0 && seatNumber != "" {
+	if position_id > 0 && seatNumber != "" && top_cluetype != "" && sub_cluetype != "" {
 		if TiDb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": position_id}) >= cfg.CountLimit {
 			return true, false
 		}
@@ -750,6 +750,23 @@ func autoDraw(mode string) (positionId int64, seatNumber, saleName string, saleD
 					}
 				}
 			}
+		} else {
+			seatNumber = common.ObjToString((*data)[0]["seatNumber"])
+			saleName = common.ObjToString((*data)[0]["name"])
+			rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count asc")
+			if rData != nil && len(*rData) > 0 {
+				TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
+					"seatNumber": seatNumber,
+					"clue_level": mode,
+					"count":      common.Int64All((*rData)["count"]),
+				})
+			} else {
+				TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
+					"seatNumber": seatNumber,
+					"clue_level": mode,
+					"count":      0,
+				})
+			}
 		}
 		for _, v := range *data {
 			if seatNumber == common.ObjToString(v["seatNumber"]) {

+ 4 - 2
clueSync/main.go

@@ -108,8 +108,8 @@ func main() {
 		})
 		f.Start()
 		//自动进入任务车 1天一次
-		autoTask()
-		autoTasks()
+		// autoTask()
+		// autoTasks()
 		g := cron.New()
 		g.AddFunc(cfg.CornExp7, func() {
 			autoTask()
@@ -148,5 +148,7 @@ func main() {
 		autoTask()
 	} else if *mode == 10 {
 		getAreaCode("6447753fb4f3c077da9d5336")
+	} else if *mode == 11 {
+		trail()
 	}
 }

+ 88 - 0
clueSync/trailContent.go

@@ -0,0 +1,88 @@
+package main
+
+import (
+	"log"
+	"regexp"
+
+	"strings"
+
+	"app.yhyue.com/moapp/jybase/common"
+	"github.com/tealeg/xlsx"
+)
+
+func trail() {
+	log.Println("合力亿捷跟进历史任务开始")
+	nameReg := regexp.MustCompile("【.*?】")
+	filePath := "./xlsx/跟进历史" + cfg.XlsxNum + ".xlsx"
+	log.Println("文件名 ", filePath)
+	xlFile, _ := xlsx.OpenFile(filePath)
+	//获取行数
+	length := len(xlFile.Sheets[0].Rows)
+	log.Println("获取行数 ", length)
+	//遍历sheet
+	for _, sheet := range xlFile.Sheets {
+		//遍历每一行
+		for rowIndex, row := range sheet.Rows {
+			//跳过第一行表头信息
+			if rowIndex == 0 {
+				continue
+			}
+			createtime := row.Cells[0].Value
+			name := row.Cells[1].Value
+			nexttype := row.Cells[2].Value
+			content := row.Cells[3].Value
+			phone := row.Cells[6].Value
+			positionId, clueId := getSale(name, phone)
+			log.Println("positionId,clueId ", positionId, clueId)
+			if clueId > 0 {
+				if nexttype == "无类型" {
+					TiDb.Insert("dwd_f_crm_trail_content", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"createtime":  createtime,
+						"content":     content,
+						"operator_id": positionId,
+					})
+				} else {
+					old_value := strings.ReplaceAll(strings.ReplaceAll(nameReg.FindAllString(content, -1)[0], "【", ""), "】", "")
+					new_value := strings.ReplaceAll(strings.ReplaceAll(nameReg.FindAllString(content, -1)[1], "【", ""), "】", "")
+					TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"createtime":   createtime,
+						"change_field": common.If(nexttype == "所属人变更", "position_id", "trailstatus"),
+						"change_type":  common.If(nexttype == "所属人变更", nexttype, "基本信息变更"),
+						"old_value":    common.If(old_value == "销售线索", "商机线索", old_value),
+						"new_value":    common.If(new_value == "销售线索", "商机线索", new_value),
+						"operator_id":  positionId,
+					})
+				}
+			}
+		}
+	}
+}
+
+func getSale(name, phone string) (positionId, clueId int64) {
+	saleData := TiDb.FindOne("jy_salesperson_info", map[string]interface{}{"name": name, "status": 0}, "", "")
+	if saleData != nil && len(*saleData) > 0 {
+		salePhone := common.ObjToString((*saleData)["phone"])
+		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"phone": salePhone}, "", "")
+		if userInfo != nil && len(*userInfo) > 0 {
+			base_user_id := common.Int64All((*userInfo)["base_user_id"])
+			positionData := Base.FindOne("base_position", map[string]interface{}{"type": 1, "user_id": base_user_id, "ent_id": 25917}, "", "")
+			if positionData != nil && len(*positionData) > 0 {
+				positionId = common.Int64All((*positionData)["id"])
+			}
+		}
+	} else {
+		positionId = -1
+	}
+	if positionId == 0 {
+		positionId = -1
+	}
+	clueInfo := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
+	if clueInfo != nil && len(*clueInfo) > 0 {
+		clueId = common.Int64All((*clueInfo)["id"])
+	}
+	return
+}