Pārlūkot izejas kodu

Merge commit 'd4699c94c2821fd8f88e98a9eebceb3cf679870c' into feature/v1.5.15

* commit 'd4699c94c2821fd8f88e98a9eebceb3cf679870c':
  加车处理
  人员处理
  merge
  排序处理
  文案修改
  去重处理
  排序
  文案修改
  文案修改
  merge
  邮件发送修改
  去重处理
  报错提交
  613需求

# Conflicts:
#	telemarketingEtl/telemarketingEtl
Jianghan 11 mēneši atpakaļ
vecāks
revīzija
e787cb2234

+ 42 - 30
clueSync/config.go

@@ -8,26 +8,27 @@ import (
 
 type (
 	Config struct {
-		LastOrderId        int     `json:"lastOrderId"`
-		LastOrderClueId    string  `json:"lastOrderClueId"`
-		LastUserId         string  `json:"lastUserId"`
-		LastXcxUserId      string  `json:"lastXcxUserId"`
-		LastId             string  `json:"lastId"`
-		LastOrderTime      string  `json:"lastOrderTime"`
-		LastUserTime       string  `json:"lastUserTime"`
-		LastSubscribeId    string  `json:"lastSubscribeId"`
-		LastMessageTime    string  `json:"lastMessageTime"`
-		LastkcTime         string  `json:"lastkcTime"`
-		LastEverythingTime string  `json:"lastEverythingTime"`
-		LastEventRegTime   string  `json:"lastEventRegTime"`
-		LastReadClueTime   string  `json:"lastReadClueTime"`
-		BigSaleTime        int64   `json:"bigSaleTime"`
-		BigOrderTime       string  `json:"bigOrderTime"`
-		MarketSaleTime     int64   `json:"marketSaleTime"`
-		AllocationTime     string  `json:"allocationTime"`
-		AllocationRatio    float64 `json:"allocationRatio"`
-		ActiveTime         string  `json:"activeTime"`
-		RebindTime         string  `json:"rebindTime"`
+		LastOrderId           int     `json:"lastOrderId"`
+		LastOrderClueId       string  `json:"lastOrderClueId"`
+		LastUserId            string  `json:"lastUserId"`
+		LastXcxUserId         string  `json:"lastXcxUserId"`
+		LastId                string  `json:"lastId"`
+		LastOrderTime         string  `json:"lastOrderTime"`
+		LastUserTime          string  `json:"lastUserTime"`
+		LastSubscribeId       string  `json:"lastSubscribeId"`
+		LastMessageTime       string  `json:"lastMessageTime"`
+		LastkcTime            string  `json:"lastkcTime"`
+		LastEverythingTime    string  `json:"lastEverythingTime"`
+		LastEventRegTime      string  `json:"lastEventRegTime"`
+		LastReadClueTime      string  `json:"lastReadClueTime"`
+		BigSaleTime           int64   `json:"bigSaleTime"`
+		BigOrderTime          string  `json:"bigOrderTime"`
+		MarketSaleTime        int64   `json:"marketSaleTime"`
+		AdvisoryCommitteeTime int64   `json:"advisoryCommitteeTime"`
+		AllocationTime        string  `json:"allocationTime"`
+		AllocationRatio       float64 `json:"allocationRatio"`
+		ActiveTime            string  `json:"activeTime"`
+		RebindTime            string  `json:"rebindTime"`
 	}
 	DB struct {
 		CornExp1      int64  `json:"cornexp1"`
@@ -129,6 +130,16 @@ type (
 			MaxIdle     int    `json:"maxidle"`
 			MaxLeftTime int    `json:"maxleft"`
 		} `json:"mysql"`
+		DataAnalysis struct {
+			Host        string `json:"host"`
+			Port        int    `json:"port"`
+			Database    string `json:"database"`
+			User        string `json:"user"`
+			Password    string `json:"password"`
+			PollSize    int    `json:"poolsize"`
+			MaxIdle     int    `json:"maxidle"`
+			MaxLeftTime int    `json:"maxleft"`
+		} `json:"dataAnalysis"`
 		Mgo struct {
 			Address string `json:"address"`
 			DbName  string `json:"dbName"`
@@ -155,16 +166,17 @@ type (
 			UserName string `json:"user	Name"`
 			Password string `json:"password"`
 		} `json:"es"`
-		ProductArr     []string          `json:"productArr"`
-		RedisServer    string            `json:"redisServer"`
-		MarketSaleMail string            `json:"marketSaleMail"`
-		AllocationCap  int64             `json:"allocationCap"`
-		WarningValue   int64             `json:"warningValue"`
-		CornMail       string            `json:"corn_mail"`
-		RegTimes       int               `json:"regTimes"`
-		NameToMail     map[string]string `json:"nameToMail"`
-		ThawDay        int64             `json:"thawDay"`
-		LoopType       int64             `json:"loopType"`
+		ProductArr            []string          `json:"productArr"`
+		RedisServer           string            `json:"redisServer"`
+		MarketSaleMail        string            `json:"marketSaleMail"`
+		AdvisoryCommitteeMail []string          `json:"advisoryCommitteeMail"`
+		AllocationCap         int64             `json:"allocationCap"`
+		WarningValue          int64             `json:"warningValue"`
+		CornMail              string            `json:"corn_mail"`
+		RegTimes              int               `json:"regTimes"`
+		NameToMail            map[string]string `json:"nameToMail"`
+		ThawDay               int64             `json:"thawDay"`
+		LoopType              int64             `json:"loopType"`
 	}
 )
 

+ 1 - 23
clueSync/config.json

@@ -1,23 +1 @@
-{
-  "lastOrderId": 258784,
-  "lastOrderClueId": "2024-05-25 02:23:21",
-  "lastUserId": "2024-05-20 15:40:02",
-  "lastId": "668c9fdbd1f99a10cd641691",
-  "lastOrderTime": "2023-04-25 00:00:00",
-  "lastUserTime": "2024-07-09 11:54:02",
-  "lastSubscribeId": "645470af172d9e8dcc5c507a",
-  "lastMessageTime": "2024-06-20 17:54:18",
-  "lastkcTime": "",
-  "lastEverythingTime": "",
-  "lastEventRegTime": "",
-  "lastReadClueTime": "",
-  "bigSaleTime": 1718241923,
-  "bigOrderTime": "2024-06-12 17:01:39",
-  "marketSaleTime": 1708160200,
-  "allocationTime": "2024-07-01 14:59:37",
-  "allocationRatio": 2,
-  "lastXcxUserId": "2024-07-09 14:59:37",
-  "activeTime": "2024-07-01 14:59:37",
-  "rebindTime": "2024-07-01 14:59:37"
-}
-
+{"lastOrderId":258784,"lastOrderClueId":"2024-05-25 02:23:21","lastUserId":"2024-05-20 15:40:02","lastXcxUserId":"2024-07-09 14:59:37","lastId":"668c9fdbd1f99a10cd641691","lastOrderTime":"2023-04-25 00:00:00","lastUserTime":"2024-07-09 11:54:02","lastSubscribeId":"645470af172d9e8dcc5c507a","lastMessageTime":"2024-06-20 17:54:18","lastkcTime":"","lastEverythingTime":"","lastEventRegTime":"","lastReadClueTime":"","bigSaleTime":1718241923,"bigOrderTime":"2024-06-12 17:01:39","marketSaleTime":1708160200,"advisoryCommitteeTime":1724136683,"allocationTime":"2024-07-01 14:59:37","allocationRatio":2,"activeTime":"2024-07-01 14:59:37","rebindTime":"2024-07-01 14:59:37"}

+ 12 - 1
clueSync/db.json

@@ -79,6 +79,16 @@
     "maxidle": 40,
     "maxleft": 40
   },
+  "dataAnalysis": {
+    "host": "192.168.3.14",
+    "port": 4000,
+    "database": "data_analysis",
+    "user": "root",
+    "password": "=PDT49#80Z!RVv52_z",
+    "poolsize": 20,
+    "maxidle": 40,
+    "maxleft": 40
+  },
   "mysql": {
     "host": "192.168.3.14",
     "port": 4000,
@@ -140,5 +150,6 @@
   },
   "nameToMail": null,
   "thawDay": 3,
-  "loopType": 1
+  "loopType": 1,
+  "advisoryCommitteeMail": ["wanghao@topnet.net.cn"]
 }

+ 174 - 6
clueSync/everything.go

@@ -367,7 +367,7 @@ func bigCustomer() {
 		bigOrderTime = nowTime
 	}
 	data := FindBatchData("dk")
-	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": bigSaleTime}}, "createtime", nil, false, -1, -1)
+	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": bigSaleTime}}, `{"phone":1,"createtime":1}`, nil, false, -1, -1)
 	if ok && saleleadsData != nil && len(*saleleadsData) > 0 {
 		for _, v := range *saleleadsData {
 			sources := common.ObjToString(v["source"])
@@ -383,6 +383,9 @@ func bigCustomer() {
 			if sourceMap[sources] != "" {
 				source := sourceMap[sources]
 				phone := common.ObjToString(v["phone"])
+				if IsInternal(phone) {
+					continue
+				}
 				key := fmt.Sprintf("%s_%s", source, phone)
 				if _, ok := data[key]; ok {
 					continue
@@ -420,7 +423,9 @@ func bigCustomer() {
 					"data_requirement": data_requirement,
 				})
 			}
-			bigSaleTime = gconv.Int64(v["createtime"])
+			if gconv.Int64(v["createtime"]) > bigSaleTime {
+				bigSaleTime = gconv.Int64(v["createtime"])
+			}
 		}
 	}
 	cfg.BigSaleTime = bigSaleTime
@@ -447,6 +452,9 @@ func bigCustomer() {
 				if phone == "" {
 					phone = common.ObjToString((*userData)["phone"])
 				}
+				if IsInternal(phone) {
+					continue
+				}
 				username = common.ObjToString((*userData)["name"])
 				usernickname = common.ObjToString((*userData)["nickname"])
 				uid = common.ObjToString((*userData)["uid"])
@@ -559,7 +567,7 @@ func bigCustomer() {
 				}
 				email := k
 				//email = "wanghao@jianyu360.com"
-				dir := "./xlsx/" + fileName + ".xlsx"
+				dir := "./xlsx/dk/" + fileName + ".xlsx"
 				err := xf.Save(dir)
 				if err != nil {
 					log.Println("xls error", err, dir)
@@ -583,6 +591,161 @@ func bigCustomer() {
 	log.Println("大客户线索定时任务结束")
 }
 
+func IsInternal(phone string) bool {
+	if DataAnalysisService.Count("dwd_f_userbase_insider", map[string]interface{}{
+		"mobile": phone,
+	}) > 0 {
+		return true
+	}
+	return false
+}
+
+// 咨询组线索
+func AdvisoryCommittee() {
+	runOk := getRunOk()
+	if !runOk {
+		log.Println("不是工作日,任务暂停")
+		return
+	}
+	log.Println("咨询部线索定时任务开始")
+	dataArr := []map[string]interface{}{}
+	filterArr := []string{"-pc", "-app", "-wx", "-h5"}
+	sourceMap := map[string]string{} //根据留资维表:tidb/Jianyu_subjectdb/d_saleleads_code
+	saleSource := TiDb.SelectBySql(`SELECT source,name FROM d_saleleads_code WHERE department LIKE '%咨询组%' AND is_delete = 1`)
+	if saleSource != nil && len(*saleSource) > 0 {
+		for _, v := range *saleSource {
+			source := common.ObjToString(v["source"])
+			name := common.ObjToString(v["name"])
+			for _, s := range filterArr {
+				name = strings.ReplaceAll(name, s, "")
+			}
+			sourceMap[source] = name
+		}
+	}
+	nowTime := time.Now().Format(date.Date_Full_Layout)
+	advisoryCommitteeTime := cfg.AdvisoryCommitteeTime
+	if advisoryCommitteeTime == 0 {
+		advisoryCommitteeTime = time.Now().Unix()
+	}
+	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": advisoryCommitteeTime}}, `{"phone":1,"createtime":1}`, nil, false, -1, -1)
+	if ok && saleleadsData != nil && len(*saleleadsData) > 0 {
+		data := FindBatchData("zx")
+		for _, v := range *saleleadsData {
+			sources := common.ObjToString(v["source"])
+			userid := common.ObjToString(v["userid"])
+			uid := ""
+			if !mongodb.IsObjectIdHex(userid) {
+				userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userid}, "", "")
+				if userMapping != nil && len(*userMapping) > 0 {
+					userid = common.ObjToString((*userMapping)["userid"])
+					uid = common.ObjToString((*userMapping)["uid"])
+				}
+			}
+			if sourceMap[sources] != "" {
+				company := common.ObjToString(v["company"])
+				phone := common.ObjToString(v["phone"])
+				if IsInternal(phone) {
+					continue
+				}
+				username := common.ObjToString(v["name"])
+				email := common.ObjToString(v["mail"])
+				interest := common.ObjToString(v["interest"])
+				data_requirement := common.ObjToString(v["data_requirement"])
+				source := sourceMap[sources]
+				belongTo := "咨询组"
+				userData := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"uid": uid}, "", "")
+				if userData != nil {
+					bt := common.ObjToString((*userData)["belong_to"])
+					if strings.HasPrefix(bt, "03") || bt == "0102" {
+						continue
+					}
+				}
+				key := fmt.Sprintf("%s_%s_%s", source, phone, interest)
+				if _, ok := data[key]; ok {
+					continue
+				}
+				data[key] = true
+				dataArr = append(dataArr, map[string]interface{}{
+					"createTime":       nowTime,
+					"createtime":       v["createtime"],
+					"username":         username,
+					"company":          company,
+					"phone":            phone,
+					"source":           source,
+					"belongTo":         belongTo,
+					"interest":         interest,
+					"data_requirement": data_requirement,
+					"branch":           v["branch"],
+					"email":            email,
+				})
+
+			}
+			if gconv.Int64(v["createtime"]) > advisoryCommitteeTime {
+				advisoryCommitteeTime = gconv.Int64(v["createtime"])
+			}
+		}
+		keyContent := fmt.Sprintf("data_%s_%s", time.Now().Format("2006-01-02"), "zx")
+		redis.Put("newother", keyContent, data, 86400)
+	}
+	cfg.AdvisoryCommitteeTime = advisoryCommitteeTime
+	xlsxArr := []string{"姓名", "联系方式", "邮箱", "公司名称", "咨询需求", "销售线索来源", "具体来源", "留资时间"}
+	if len(dataArr) > 0 {
+		//排序:首先按照“联系方式”排序,即同1个用户的留资放在一起,其次按照留资时间正序排序。
+		batch := FindBatch("zx")
+		fileName, detailName := "咨询服务销售线索 "+time.Now().Format(date.Date_Short_Layout)+"-"+batch, ""
+		xf := xlsx.NewFile()
+		style := xlsx.NewStyle()
+		style.Font.Size = 12
+		style.Font.Bold = true
+		style.Alignment.Vertical = "center"
+		style.Alignment.Horizontal = "center"
+		detailName = "今日新增咨询服务销售线索,请查收附件,及时跟进。"
+		sh, _ := xf.AddSheet("线索数据")
+		row1 := sh.AddRow()
+		for _, x := range xlsxArr {
+			cell := row1.AddCell()
+			cell.SetString(x)
+			cell.SetStyle(style)
+		}
+		for _, v := range dataArr {
+
+			row := sh.AddRow()
+			row.AddCell().SetString(common.ObjToString(v["username"]))
+			row.AddCell().SetString(common.ObjToString(v["phone"]))
+			row.AddCell().SetString(common.ObjToString(v["email"]))
+			row.AddCell().SetString(common.ObjToString(v["company"]))
+			row.AddCell().SetString(common.ObjToString(v["data_requirement"]))
+			row.AddCell().SetString(common.ObjToString(v["source"]))
+			row.AddCell().SetString(common.ObjToString(v["interest"]))
+			row.AddCell().SetString(gconv.Time(gconv.Int64(v["createtime"])).Format(date.Date_Full_Layout))
+			//增加客户需求
+		}
+		email := db.AdvisoryCommitteeMail
+		dir := "./xlsx/zx/" + fileName + ".xlsx"
+		err := xf.Save(dir)
+		if err != nil {
+			log.Println("xls error", err, dir)
+		} else {
+			gmail := &mail.GmailAuth{
+				SmtpHost: "smtp.exmail.qq.com",
+				SmtpPort: 465,
+				User:     "public03@topnet.net.cn",
+				Pwd:      "ue9Rg9Sf4CVtdm5a",
+			}
+			for _, v := range email {
+				status := mail.GSendMail_q("剑鱼标讯", v, "", "", fileName, detailName, dir, fileName+".xlsx", gmail)
+				if status {
+					log.Println("send mail success", fileName, v)
+				}
+			}
+
+		}
+
+	}
+	common.WriteSysConfig(&cfg)
+	log.Println("咨询部线索定时任务结束")
+}
+
 // 市场部线索
 func marketCustomer() {
 	runOk := getRunOk()
@@ -610,7 +773,7 @@ func marketCustomer() {
 	if marketSaleTime == 0 {
 		marketSaleTime = time.Now().Unix()
 	}
-	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": marketSaleTime}}, "phone,createtime", nil, false, -1, -1)
+	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": marketSaleTime}}, `{"phone":1,"createtime":1}`, nil, false, -1, -1)
 	if ok && saleleadsData != nil && len(*saleleadsData) > 0 {
 		data := FindBatchData("sc")
 		for _, v := range *saleleadsData {
@@ -627,6 +790,9 @@ func marketCustomer() {
 			if sourceMap[sources] != "" {
 				company := common.ObjToString(v["company"])
 				phone := common.ObjToString(v["phone"])
+				if IsInternal(phone) {
+					continue
+				}
 				job := common.ObjToString(v["position"])
 				username := common.ObjToString(v["name"])
 				email := common.ObjToString(v["mail"])
@@ -668,7 +834,9 @@ func marketCustomer() {
 				})
 
 			}
-			marketSaleTime = gconv.Int64(v["createtime"])
+			if gconv.Int64(v["createtime"]) > marketSaleTime {
+				marketSaleTime = gconv.Int64(v["createtime"])
+			}
 		}
 		keyContent := fmt.Sprintf("data_%s_%s", time.Now().Format("2006-01-02"), "sc")
 		redis.Put("newother", keyContent, data, 86400)
@@ -707,7 +875,7 @@ func marketCustomer() {
 			//增加客户需求
 		}
 		email := db.MarketSaleMail
-		dir := "./xlsx/" + fileName + ".xlsx"
+		dir := "./xlsx/sc/" + fileName + ".xlsx"
 		err := xf.Save(dir)
 		if err != nil {
 			log.Println("xls error", err, dir)

+ 11 - 27
clueSync/job.go

@@ -269,7 +269,6 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 			if batch_import != "" && item == "users" { //有导入批次号还是新用户,不执行
 				return true, true
 			}
-			//oks = UpdateClue(*uCount, saleData, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, level, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce, pIsOk, "")
 			oks = UpdateClue(*uCount, saleData, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, level, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce, pIsOk)
 		} else { //不存在走新增
 			oks = SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce, isFreeze, "")
@@ -1093,19 +1092,6 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 					}
 
 				}
-				if old_sub_cluetype == sub_cluetype && !is_ok {
-					if trailstatus == "00" || is_assign == 0 || is_assign == -1 {
-						updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-							"clue_id":     clueId,
-							"position_id": positionId,
-							"change_type": "加入任务车",
-							"new_value":   gconv.String(common.If(gconv.Int64(data["position_id"]) == 0, "线索自动分配", "线索来源自动更新")) + "-" + topname + "-" + subname,
-							"createtime":  nowTime,
-							"BCPCID":      common.GetRandom(32),
-							"operator_id": -1,
-						})
-					}
-				}
 			}
 		}
 		if old_top_cluetype != "" {
@@ -1669,20 +1655,18 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 							})
 						}
 					}
+				} else if gconv.Int64(clueUpdateData["is_task"]) == 1 {
+					updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": common.If(trailstatus == "00" || is_assign == 0 || is_assign == -1, positionId, common.Int64All(data["position_id"])),
+						"change_type": "加入任务车",
+						"new_value":   gconv.String(common.If(gconv.Int64(data["position_id"]) == 0, "线索自动分配", "线索来源自动更新")) + "-" + topname + "-" + subname,
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": -1,
+					})
 				}
-				if old_sub_cluetype == sub_cluetype && !is_ok {
-					if trailstatus == "00" || trailstatus == "09" || is_assign == 0 || is_assign == -1 {
-						updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
-							"clue_id":     clueId,
-							"position_id": positionId,
-							"change_type": "加入任务车",
-							"new_value":   gconv.String(common.If(gconv.Int64(data["position_id"]) == 0, "线索自动分配", "线索来源自动更新")) + "-" + topname + "-" + subname,
-							"createtime":  nowTime,
-							"BCPCID":      common.GetRandom(32),
-							"operator_id": -1,
-						})
-					}
-				}
+
 			}
 		}
 		if old_top_cluetype != "" {

+ 4 - 2
clueSync/jobutil.go

@@ -663,7 +663,7 @@ func saleLeads() {
 		//
 		filterArr := []string{"-pc", "-app", "-wx", "-h5"}
 		sourceMap := map[string]string{}
-		saleSource := TiDb.SelectBySql(`SELECT source,name FROM d_saleleads_code WHERE (department LIKE '%大客户%' or department LIKE '%市场组%') AND is_delete = 1`)
+		saleSource := TiDb.SelectBySql(`SELECT source,name FROM d_saleleads_code WHERE (department LIKE '%大客户%' or department LIKE '%市场组%' or department LIKE '%咨询组%') AND is_delete = 1`)
 		if saleSource != nil && len(*saleSource) > 0 {
 			for _, v := range *saleSource {
 				source := common.ObjToString(v["source"])
@@ -1159,10 +1159,12 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 					positionId = common.Int64All((*cdata)[0]["position_id"])
 					noticePositionId = positionId
 					seatNumber = common.ObjToString((*cdata)[0]["seatNumber"])
+					assign_type := common.IntAll(v["assign_type"])
+					role_id := common.IntAll(v["role_id"])
 					for _, v := range *pdata {
 						resign := common.IntAll(v["resign"])
 						if positionId == common.Int64All(v["position_id"]) {
-							if resign == 0 {
+							if resign == 0 && (assign_type == 1 || role_id == 8) {
 								if FindUpperLimit(gconv.String(positionId), mode, true) {
 									isFreeze = true
 									positionId = 0

+ 34 - 25
clueSync/main.go

@@ -14,23 +14,24 @@ import (
 )
 
 var (
-	cfg                = new(Config)
-	db                 = new(DB)
-	Mysql              *mysql.Mysql
-	TiDb               *mysql.Mysql
-	TiDbData           *mysql.Mysql
-	TiDbPower          *mysql.Mysql
-	WorkOrder          *mysql.Mysql
-	ThirdParty         *mysql.Mysql
-	Jyactivities       *mysql.Mysql
-	Base               *mysql.Mysql
-	BiService          *mysql.Mysql
-	Es                 elastic.Es
-	Mgo                *mongodb.MongodbSim
-	MgoLog             *mongodb.MongodbSim
-	MgoQyxy            *mongodb.MongodbSim
-	mode               = flag.Int("m", 1, "")
-	startTime, endTime = "00:00", "23:59"
+	cfg                 = new(Config)
+	db                  = new(DB)
+	Mysql               *mysql.Mysql
+	TiDb                *mysql.Mysql
+	TiDbData            *mysql.Mysql
+	TiDbPower           *mysql.Mysql
+	WorkOrder           *mysql.Mysql
+	ThirdParty          *mysql.Mysql
+	Jyactivities        *mysql.Mysql
+	Base                *mysql.Mysql
+	BiService           *mysql.Mysql
+	DataAnalysisService *mysql.Mysql
+	Es                  elastic.Es
+	Mgo                 *mongodb.MongodbSim
+	MgoLog              *mongodb.MongodbSim
+	MgoQyxy             *mongodb.MongodbSim
+	mode                = flag.Int("m", 1, "")
+	startTime, endTime  = "00:00", "23:59"
 )
 
 func main() {
@@ -120,6 +121,15 @@ func main() {
 		MaxIdleConns: db.BiService.MaxIdle,
 	}
 	BiService.Init()
+	DataAnalysisService = &mysql.Mysql{
+		Address:      db.DataAnalysis.Host + ":" + fmt.Sprint(db.DataAnalysis.Port),
+		UserName:     db.DataAnalysis.User,
+		PassWord:     db.DataAnalysis.Password,
+		DBName:       db.DataAnalysis.Database,
+		MaxOpenConns: db.DataAnalysis.PollSize,
+		MaxIdleConns: db.DataAnalysis.MaxIdle,
+	}
+	DataAnalysisService.Init()
 	Es = elastic.NewEs(db.Es.Version, db.Es.Address, db.Es.DbSize, db.Es.UserName, db.Es.Password)
 	redis.InitRedis(db.RedisServer)
 	Mgo = mongodb.NewMgo(db.Mgo.Address, db.Mgo.DbName, db.Mgo.DbSize)
@@ -127,8 +137,6 @@ func main() {
 	MgoQyxy = mongodb.NewMgoWithUser(db.MgoQyxy.Address, db.MgoQyxy.DbName, db.MgoQyxy.User, db.MgoQyxy.Password, db.MgoQyxy.DbSize)
 	InitArea()
 	InitProduct(db.ProductArr)
-	tagAllSync()
-	//activeUsers() //取关重新关注处理
 	if *mode == 1 {
 		//30分钟一次
 		go p.VarTimeTask.RunInTimeLoop("30分钟定时任务", "", "", db.CornExp1, true, true, nil, func() {
@@ -139,12 +147,13 @@ func main() {
 		//5分钟一次
 
 		go p.VarTimeTask.RunInTimeSection("5分钟定时任务1", db.CornExp2Start, db.CornExp2End, db.CornExp2, func(dayFirst bool) {
-			users()          //新注册用户进线索
-			saleLeads()      //留资进线索
-			eventReg()       //渠道
-			bigCustomer()    //大客户线索
-			marketCustomer() //市场部线索
-			rebind()         //取关重新关注处理
+			users()             //新注册用户进线索
+			saleLeads()         //留资进线索
+			eventReg()          //渠道
+			bigCustomer()       //大客户线索
+			marketCustomer()    //市场部线索
+			AdvisoryCommittee() //咨询组线索
+			rebind()            //取关重新关注处理
 		})
 		//每天8点30
 		c := cron.New()

+ 3 - 1
telemarketingEtl/config.yaml

@@ -136,4 +136,6 @@ businessLeads: 2
 #回收站A.5个自然日内被销售人员手动退回公海的客户;
 handReturn: 5
 #回收站B.3个自然日内有过“已接听”的通话记录且仍处于“商机线索”状态下的客户。
-recycleB: 3
+recycleB: 3
+#3.30个自然日内自动退回公海的“拒绝沟通客户”;;
+refuseHandReturn: 30

+ 40 - 15
telemarketingEtl/entity/dwd_f_crm_open_sea.go

@@ -36,7 +36,7 @@ A.最近30天内活跃天数≥15天的客户;
 B.10天≤最近30天内活跃天数<15天的客户;
 C.5天≤最近30天内活跃天数<10天的客户;
 D.1天≤最近30天内活跃天数<5天的客户;
-备注:判断当日是否活跃的标准为当日是否点击查看了标讯内容。
+备注:判断当日是否活跃的标准为当日是否点击查看了标讯内容。私海无意向客户退回
 (3)三级公海:
 最近30天内活跃天数=0天的客户。
 (4)回收站:
@@ -65,47 +65,47 @@ func GetOpenSea() {
 			"$lt":  end,
 		},
 		"$or": []map[string]interface{}{
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/front/vipsubscribe/introducePage`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/big/wx/page/landingPage`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/product/index`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/front/dataExport/toSieve`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/front/dataExport/toCreateOrderPage`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/front/dataPack/createOrder`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/swordfish/page_big_pc/free/svip/buy`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/big/pc/page/buy_commit`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/front/wx_dataExport/toSieve`,
 				},
@@ -152,17 +152,17 @@ func GetOpenSea() {
 			"$lt":  end,
 		},
 		"$or": []map[string]interface{}{
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/jyapp/vipsubscribe/introducePage`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `jyapp/big/page/landingPage`,
 				},
 			},
-			map[string]interface{}{
+			{
 				"url": map[string]interface{}{
 					"$regex": `/jyapp/front/dataExport/toSieve`,
 				},
@@ -244,6 +244,7 @@ func GetOpenSea() {
 	// AddOpenSea(three, 3, "D")
 	//
 	Recycle()
+	RefuseRecycle()
 	log.Println("end")
 }
 
@@ -255,7 +256,6 @@ func GetOpenSea() {
 	D.1天≤最近30天内活跃天数<5天的客户;
 */
 func TwoOpenSea(oneClassA, oneClassB, oneClassC map[string]bool) (aMap, bMap, cMap, dMap map[string]bool) {
-
 	clubIdMap := func() map[string]string {
 		c := 0
 		mp := map[string]string{}
@@ -422,7 +422,7 @@ func GetClueIdByUserId(userid string) (uuid string) {
 func AddOpenSea(m map[string]bool, level int, clue_level string) {
 	// createtime := time.Now().Format(date.Date_Full_Layout)
 	if len(m) > 0 {
-		for k, _ := range m {
+		for k := range m {
 			config.JianyuSubjectdb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": k}, map[string]interface{}{
 				"clue_level": clue_level,
 				"level_open": level,
@@ -739,6 +739,31 @@ func Recycle() {
 	log.Println("回收站结束")
 
 }
+func RefuseRecycle() {
+	log.Println("拒绝客户回收站开始")
+	ctx := gctx.New()
+	t := time.Now()
+	t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)
+	refuseHandReturn := g.Cfg().MustGet(ctx, "refuseHandReturn").Int()
+	tA := t.AddDate(0, 0, -refuseHandReturn)
+	sql := fmt.Sprintf(`select id from dwd_f_crm_clue_info where comeinsource_open=11 and is_assign = 0 and comeintime_open > "%s" ;`, tA.Format(date.Date_Full_Layout))
+
+	config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
+		ids := []interface{}{}
+		for _, v := range *l {
+			id := v["id"]
+			ids = append(ids, id)
+		}
+		whs := []string{}
+		for i := 0; i < len(ids); i++ {
+			whs = append(whs, "?")
+		}
+		wh := strings.Join(whs, ",")
+		config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET level_open = 4 WHERE id in (`+wh+`)`, ids...)
+		return true
+	}, sql)
+	log.Println("回收站结束")
+}
 
 /*
 dwd_f_crm_clue_info.uid    trailstatus==01

+ 0 - 1
telemarketingEtl/entity/old.go

@@ -16,7 +16,6 @@ import (
 
 // 查看事件
 func VisitInfoAddOld(start, end int64) {
-
 	// 获取时间戳 1 和时间戳 2 所在的日期
 	t1 := time.Unix(start, 0)
 	t2 := time.Unix(end, 0)

BIN
telemarketingEtl/telemarketingEtl