Browse Source

Merge remote-tracking branch 'origin/feature/v1.5.27' into dev_v1.5.27_wh

# Conflicts:
#	clueSync/config.go
#	clueSync/config.json
#	clueSync/kc.go
#	clueSync/main.go
WH01243 6 months ago
parent
commit
adea26bfc7
5 changed files with 268 additions and 678 deletions
  1. 1 0
      clueSync/config.go
  2. 152 137
      clueSync/job.go
  3. 42 0
      clueSync/jobutil.go
  4. 71 537
      clueSync/kc.go
  5. 2 4
      clueSync/main.go

+ 1 - 0
clueSync/config.go

@@ -31,6 +31,7 @@ type (
 		ActiveTime              string  `json:"activeTime"`
 		RebindTime              string  `json:"rebindTime"`
 		InviteTime              string  `json:"inviteTime"`
+		ActivityTime            string  `json:"activityTime"`
 		LastKcChangeTime        string  `json:"lastKcChangeTime"`
 	}
 	DB struct {

+ 152 - 137
clueSync/job.go

@@ -17,7 +17,7 @@ import (
 )
 
 func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
-	userId, uId, positionId, source, cluename, phone, sourceCode, keyword, _ := common.ObjToString(data["user_id"]), "", "", "", "", "", "", []string{}, ""
+	userId, uId, positionId, source, cluename, phone, sourceCode, keyword, _ := gconv.String(data["user_id"]), "", "", "", "", "", "", []string{}, ""
 	role, industry, department, departments, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", "", ""
 	query, topname, subname, belong_to, sourceName, remark, sourceId := map[string]interface{}{}, "", "", "01", "", "", int64(0)
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
@@ -26,35 +26,35 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 			positionId = 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"])
+				userId = gconv.String((*userMapping)["userid"])
 			}
 		}
 		query["userid"] = userId
 		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])       //用户来源
-			belong_to = common.ObjToString((*userInfo)["belong_to"]) //用户归属
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])       //用户来源
+			belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
 		}
-		cluename = common.ObjToString(data["company_name"])
-		phone = common.ObjToString(data["user_phone"])
+		cluename = gconv.String(data["company_name"])
+		phone = gconv.String(data["user_phone"])
 	} else if item == "message" {
 		userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"base_user_id": common.Int64All(data["own_id"])}, "", "")
 		if userMapping != nil && len(*userMapping) > 0 {
-			userId = common.ObjToString((*userMapping)["userid"])
+			userId = gconv.String((*userMapping)["userid"])
 			positionId = fmt.Sprint((*userMapping)["position_id"])
 		}
 		query["userid"] = userId
 		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])
-			belong_to = common.ObjToString((*userInfo)["belong_to"])
-			phone = common.ObjToString((*userInfo)["phone"])
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])
+			belong_to = gconv.String((*userInfo)["belong_to"])
+			phone = gconv.String((*userInfo)["phone"])
 			if phone != "" {
 				phoneMapping := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
 				if phoneMapping != nil && len(*phoneMapping) > 0 {
-					cluename = common.ObjToString((*phoneMapping)["cluename"])
+					cluename = gconv.String((*phoneMapping)["cluename"])
 				}
 			}
 		}
@@ -66,13 +66,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		}
 		userId = mongodb.BsonIdToSId(data["userid"])
 		//新用户没有uid、source要等5分钟
-		cluename = common.ObjToString(data["company_name"])
-		phone = common.ObjToString(data["phone"])
+		cluename = gconv.String(data["company_name"])
+		phone = gconv.String(data["phone"])
 		if phone != "" {
 			contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
 			if contactsData != nil && len(*contactsData) > 0 {
-				if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
-					uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
+				if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
+					uId = gconv.String((*contactsData)[0]["baseinfo_id"])
 					query["uid"] = uId
 				} else {
 					query["userid"] = userId
@@ -83,14 +83,14 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 			//createtimeStr := ""
 			userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 			if userInfo != nil && len(*userInfo) > 0 {
-				uId = common.ObjToString((*userInfo)["uid"])
-				source = common.ObjToString((*userInfo)["source"])
-				belong_to = common.ObjToString((*userInfo)["belong_to"])
-				//s_sourceid = common.ObjToString((*userInfo)["s_sourceid"])
-				//createtimeStr = common.ObjToString((*userInfo)["l_registedate"])
+				uId = gconv.String((*userInfo)["uid"])
+				source = gconv.String((*userInfo)["source"])
+				belong_to = gconv.String((*userInfo)["belong_to"])
+				//s_sourceid =  gconv.String((*userInfo)["s_sourceid"])
+				//createtimeStr =  gconv.String((*userInfo)["l_registedate"])
 			}
 			if item == "xcxusers" {
-				sourceCode = common.ObjToString(data["industry"])
+				sourceCode = gconv.String(data["industry"])
 				//t, _ := time.Parse("2006-01-02 15:04:05", createtimeStr)
 				if sourceCode == "" {
 					log.Println("留资没有source", phone)
@@ -116,44 +116,44 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 			"userid": userId,
 		}, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			phone = common.ObjToString((*userInfo)["phone"])
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])
-			belong_to = common.ObjToString((*userInfo)["belong_to"])
+			phone = gconv.String((*userInfo)["phone"])
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])
+			belong_to = gconv.String((*userInfo)["belong_to"])
 		}
 	} else if item == "saleLeads" { //留资
 		//线索名称打印
-		log.Println(1111, common.ObjToString(data["company"]))
-		userId = common.ObjToString(data["userid"])
+		log.Println(1111, gconv.String(data["company"]))
+		userId = gconv.String(data["userid"])
 		if !mongodb.IsObjectIdHex(userId) {
 			positionId = 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"])
-			}
-		}
-		cluename = common.ObjToString(data["company"])
-		phone = common.ObjToString(data["phone"])
-		role = common.ObjToString(data["companyType"])
-		industry = common.ObjToString(data["industry"])
-		department = common.ObjToString(data["branch"])
-		departments = common.ObjToString(data["department"])
-		position = common.ObjToString(data["position"])
-		name = common.ObjToString(data["name"])
-		sourceCode = common.ObjToString(data["source"])
+				userId = gconv.String((*userMapping)["userid"])
+			}
+		}
+		cluename = gconv.String(data["company"])
+		phone = gconv.String(data["phone"])
+		role = gconv.String(data["companyType"])
+		industry = gconv.String(data["industry"])
+		department = gconv.String(data["branch"])
+		departments = gconv.String(data["department"])
+		position = gconv.String(data["position"])
+		name = gconv.String(data["name"])
+		sourceCode = gconv.String(data["source"])
 		if sourceCode == "" {
 			log.Println("留资没有source", phone)
 			return true, true, true
 		}
-		remark = common.ObjToString(data["jyRemark"]) //荟聚线索备注
+		remark = gconv.String(data["jyRemark"]) //荟聚线索备注
 		keywordArr := data["keyword"]
 		if keywordArr != nil {
 			keyword = common.ObjArrToStringArr(data["keyword"].([]interface{}))
 		}
 		contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
 		if contactsData != nil && len(*contactsData) > 0 {
-			if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
-				uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
+			if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
+				uId = gconv.String((*contactsData)[0]["baseinfo_id"])
 				query["uid"] = uId
 			} else {
 				query["userid"] = userId
@@ -164,11 +164,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		if userId != "" || uId != "" {
 			userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 			if userInfo != nil && len(*userInfo) > 0 {
-				uId = common.ObjToString((*userInfo)["uid"])
-				source = common.ObjToString((*userInfo)["source"])
-				belong_to = common.ObjToString((*userInfo)["belong_to"])
-				userId = common.ObjToString((*userInfo)["userid"])
-				//s_sourceid = common.ObjToString((*userInfo)["s_sourceid"])
+				uId = gconv.String((*userInfo)["uid"])
+				source = gconv.String((*userInfo)["source"])
+				belong_to = gconv.String((*userInfo)["belong_to"])
+				userId = gconv.String((*userInfo)["userid"])
+				//s_sourceid =  gconv.String((*userInfo)["s_sourceid"])
 			}
 		} else {
 			if sourceCode == "report_retention" || sourceCode == "marketing_retention" { //荟聚线索来源,不是剑鱼用户,需要等待用户归集
@@ -180,20 +180,20 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 			}
 		}
 	} else if item == "eventReg" { //渠道
-		userId = common.ObjToString(data["userid"])
-		cluename = common.ObjToString(data["company"])
-		phone = common.ObjToString(data["sign_phone"])
-		role = common.ObjToString(data["company_type"])
-		department = common.ObjToString(data["branch"])
-		position = common.ObjToString(data["position"])
-		name = common.ObjToString(data["sign_name"])
-		sourceCode = common.ObjToString(data["source_code"])
-		sourceName = common.ObjToString(data["source_name"])
+		userId = gconv.String(data["userid"])
+		cluename = gconv.String(data["company"])
+		phone = gconv.String(data["sign_phone"])
+		role = gconv.String(data["company_type"])
+		department = gconv.String(data["branch"])
+		position = gconv.String(data["position"])
+		name = gconv.String(data["sign_name"])
+		sourceCode = gconv.String(data["source_code"])
+		sourceName = gconv.String(data["source_name"])
 		log.Println(sourceName)
 		contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
 		if contactsData != nil && len(*contactsData) > 0 {
-			if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
-				uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
+			if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
+				uId = gconv.String((*contactsData)[0]["baseinfo_id"])
 				query["uid"] = uId
 			} else {
 				query["userid"] = userId
@@ -203,43 +203,58 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		}
 		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])
-			belong_to = common.ObjToString((*userInfo)["belong_to"])
-			userId = common.ObjToString((*userInfo)["userid"])
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])
+			belong_to = gconv.String((*userInfo)["belong_to"])
+			userId = gconv.String((*userInfo)["userid"])
 		}
 		if role == "集成商" || role == "设计院" {
 			role = "其他-" + role
 		}
 	} else if item == "readClue" {
-		userId = common.ObjToString(data["userId"])
+		userId = gconv.String(data["userId"])
 		query["userid"] = userId
 		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])
-			belong_to = common.ObjToString((*userInfo)["belong_to"])
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])
+			belong_to = gconv.String((*userInfo)["belong_to"])
 		}
-		// cluename = common.ObjToString(data["companyName"])
-		phone = common.ObjToString(data["phone"])
+		// cluename =  gconv.String(data["companyName"])
+		phone = gconv.String(data["phone"])
 		sourceId = common.Int64All(data["sourceId"])
 	} else if item == "invite" {
 		query["userid"] = userId
 		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
 		if userInfo != nil && len(*userInfo) > 0 {
-			uId = common.ObjToString((*userInfo)["uid"])
-			source = common.ObjToString((*userInfo)["source"])       //用户来源
-			belong_to = common.ObjToString((*userInfo)["belong_to"]) //用户归属
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])       //用户来源
+			belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
 		} else {
 			log.Println("邀请用户,用户归集没数据", data)
 			return true, true, true
 		}
-		cluename = common.ObjToString((*userInfo)["company_name"])
-		phone = common.ObjToString((*userInfo)["phone"])
-		sourceCode = common.ObjToString(data["sourceCode"])
+		cluename = gconv.String((*userInfo)["company_name"])
+		phone = gconv.String((*userInfo)["phone"])
+		sourceCode = gconv.String(data["sourceCode"])
+	} else if item == "activity" {
+		query["userid"] = userId
+		userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
+		if userInfo != nil && len(*userInfo) > 0 {
+			uId = gconv.String((*userInfo)["uid"])
+			source = gconv.String((*userInfo)["source"])       //用户来源
+			belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
+		} else {
+			log.Println("邀请用户,用户归集没数据", data)
+			return true, true, true
+		}
+		cluename = gconv.String((*userInfo)["company_name"])
+		phone = gconv.String((*userInfo)["phone"])
+		sourceCode = gconv.String(data["sourceCode"])
+		log.Println(sourceCode)
 	}
 	log.Println(222, cluename)
-	if cluename == "" && item != "message" && item != "orders" && item != "readClue" && item != "rebind" && item != "allocation" {
+	if cluename == "" && item != "message" && item != "orders" && item != "readClue" && item != "rebind" && item != "allocation" && item != "activity" {
 		cluename = phone //没有线索名,手机号代替
 	}
 	log.Println(333, cluename)
@@ -277,12 +292,12 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		saleLeadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"userid": qid}, map[string]interface{}{"_id": -1}, nil, false, 0, 1)
 		if ok && saleLeadsData != nil && len(*saleLeadsData) > 0 {
 			sdata := (*saleLeadsData)[0]
-			role = common.ObjToString(sdata["companyType"])
-			industry = common.ObjToString(sdata["industry"])
-			department = common.ObjToString(sdata["branch"])
-			departments = common.ObjToString(sdata["department"])
-			position = common.ObjToString(sdata["position"])
-			name = common.ObjToString(sdata["name"])
+			role = gconv.String(sdata["companyType"])
+			industry = gconv.String(sdata["industry"])
+			department = gconv.String(sdata["branch"])
+			departments = gconv.String(sdata["department"])
+			position = gconv.String(sdata["position"])
+			name = gconv.String(sdata["name"])
 		}
 	}
 	top_cluetype, sub_cluetype, level, topname, subname = getClueType(item, data, sourceCode, sourceId) //查留资来源名字
@@ -314,7 +329,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 				cluename = ""
 			}
 			//已存在,走更新
-			batch_import := common.ObjToString((*uCount)["batch_import"])
+			batch_import := gconv.String((*uCount)["batch_import"])
 			if batch_import != "" && item == "users" { //有导入批次号还是新用户,不执行
 				return true, true, true
 			}
@@ -341,14 +356,14 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 				if item != "orders" && item != "users" { //新用户和订单之外的替换一下新的留资信息
 					BCPCID := common.GetRandom(32)
 					clueId := common.Int64All((*uCount)["id"])
-					old_name := common.ObjToString((*uCount)["name"])
-					old_position := common.ObjToString((*uCount)["position"])
-					old_department := common.ObjToString((*uCount)["department"])
-					old_follow_project_area := common.ObjToString((*uCount)["follow_project_area"])
-					old_role := common.ObjToString((*uCount)["role"])
-					old_cluename := common.ObjToString((*uCount)["cluename"])
-					old_top_cluetype := common.ObjToString((*uCount)["top_cluetype"])
-					old_sub_cluetype := common.ObjToString((*uCount)["sub_cluetype"])
+					old_name := gconv.String((*uCount)["name"])
+					old_position := gconv.String((*uCount)["position"])
+					old_department := gconv.String((*uCount)["department"])
+					old_follow_project_area := gconv.String((*uCount)["follow_project_area"])
+					old_role := gconv.String((*uCount)["role"])
+					old_cluename := gconv.String((*uCount)["cluename"])
+					old_top_cluetype := gconv.String((*uCount)["top_cluetype"])
+					old_sub_cluetype := gconv.String((*uCount)["sub_cluetype"])
 					label := gconv.Int64((*uCount)["label"])
 					trailstatusCode := gconv.String((*uCount)["trailstatus"])
 					clueUpdateData := map[string]interface{}{}
@@ -436,13 +451,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 					if old_top_cluetype != "" {
 						pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
 						if pcodeData != nil && len(*pcodeData) > 0 {
-							old_topname = common.ObjToString((*pcodeData)["name"])
+							old_topname = gconv.String((*pcodeData)["name"])
 						}
 					}
 					if old_sub_cluetype != "" {
 						pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
 						if pcodeData != nil && len(*pcodeData) > 0 {
-							old_subname = common.ObjToString((*pcodeData)["name"])
+							old_subname = gconv.String((*pcodeData)["name"])
 						}
 					}
 					if old_top_cluetype != top_cluetype && top_cluetype != "" {
@@ -716,8 +731,8 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 	log.Println("工单线索修改前", data)
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
 	nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
-	trailstatus := common.ObjToString(data["trailstatus"]) //data都为原线索数据
-	trailstatusTime := common.ObjToString(data["trailstatus_time"])
+	trailstatus := gconv.String(data["trailstatus"]) //data都为原线索数据
+	trailstatusTime := gconv.String(data["trailstatus_time"])
 	var trailstatusTimes time.Time
 	if trailstatusTime != "" {
 		trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
@@ -725,24 +740,24 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 	clueId := common.Int64All(data["id"])
 	is_assign := common.IntAll(data["is_assign"])
 	oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
-	old_position_id, old_seatNumber := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"])
-	oldTaskTime = common.ObjToString(data["tasktime"])
+	old_position_id, old_seatNumber := common.Int64All(data["position_id"]), gconv.String(data["seatNumber"])
+	oldTaskTime = gconv.String(data["tasktime"])
 	is_task = common.IntAll(data["is_task"])
 	taskstatus = common.IntAll(data["taskstatus"])
 	BCPCID := common.GetRandom(32)
-	old_name := common.ObjToString(data["name"])
-	old_position := common.ObjToString(data["position"])
-	old_department := common.ObjToString(data["department"])
-	old_follow_project_area := common.ObjToString(data["follow_project_area"])
-	old_role := common.ObjToString(data["role"])
-	old_cluename := common.ObjToString(data["cluename"])
-	old_top_cluetype := common.ObjToString(data["top_cluetype"])
-	old_sub_cluetype := common.ObjToString(data["sub_cluetype"])
+	old_name := gconv.String(data["name"])
+	old_position := gconv.String(data["position"])
+	old_department := gconv.String(data["department"])
+	old_follow_project_area := gconv.String(data["follow_project_area"])
+	old_role := gconv.String(data["role"])
+	old_cluename := gconv.String(data["cluename"])
+	old_top_cluetype := gconv.String(data["top_cluetype"])
+	old_sub_cluetype := gconv.String(data["sub_cluetype"])
 	label := gconv.Int64(data["label"])
 	old_topname, old_subname := "", ""
 	is_transfer := common.IntAll(data["is_transfer"])
 	if taskstatus == 1 || is_task == 0 {
-		taskTime = common.ObjToString(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
+		taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
 	} else {
 		if is_task == 1 {
 			if oldTaskTime != "" { //以最新的任务时间为主
@@ -797,12 +812,12 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 		"company_nature":       isGroup,
 		"company_verification": isCommerce,
 	}
-	old_remark := common.ObjToString(data["remark"])
+	old_remark := gconv.String(data["remark"])
 	if old_remark != "" {
 		remark = old_remark + ";" + remark //备注不能替换,只能往上拼接
 	}
 	clueUpdateData["remark"] = remark
-	old_demand := common.ObjToString(data["customer_demand"])
+	old_demand := gconv.String(data["customer_demand"])
 	if demand != old_demand {
 		clueUpdateData["customer_demand"] = demand
 	}
@@ -834,7 +849,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 			clueUpdateData["department"] = departments
 			department = departments
 		}
-		business_scope := common.ObjToString(data["business_scope"])
+		business_scope := gconv.String(data["business_scope"])
 		keywords := ""
 		if len(keyword) > 0 && keyword[0] != "" {
 			keywords = strings.Join(keyword, ",")
@@ -848,7 +863,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 	if old_position_id != 0 {
 		for _, v := range saleData {
 			if old_position_id == common.Int64All(v["position_id"]) {
-				oldsaleName = common.ObjToString(v["name"])
+				oldsaleName = gconv.String(v["name"])
 			}
 		}
 	}
@@ -898,7 +913,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 				eData := TiDb.Find("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": clueId, "change_type": "加入任务车"}, "", "", -1, -1)
 				if eData != nil && len(*eData) > 0 {
 					for _, e := range *eData {
-						new_value := common.ObjToString(e["new_value"])
+						new_value := gconv.String(e["new_value"])
 						if strings.Contains(new_value, subname) {
 							is_ok = true
 						}
@@ -1108,7 +1123,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						if cdata != nil && len(*cdata) > 0 {
 							kcpositionId := common.Int64All((*cdata)["position_id"])
-							tasksource := common.ObjToString((*cdata)["tasksource"])
+							tasksource := gconv.String((*cdata)["tasksource"])
 							taskstatus := common.IntAll((*cdata)["taskstatus"])
 							updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 								"clue_id":     clueId,
@@ -1154,13 +1169,13 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 		if old_top_cluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_topname = common.ObjToString((*pcodeData)["name"])
+				old_topname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if old_sub_cluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_subname = common.ObjToString((*pcodeData)["name"])
+				old_subname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if item != "orders" {
@@ -1308,8 +1323,8 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 	name = strings.ReplaceAll(name, " ", "")
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
 	nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
-	trailstatus := common.ObjToString(data["trailstatus"]) //data都为原线索数据
-	trailstatusTime := common.ObjToString(data["trailstatus_time"])
+	trailstatus := gconv.String(data["trailstatus"]) //data都为原线索数据
+	trailstatusTime := gconv.String(data["trailstatus_time"])
 	var trailstatusTimes time.Time
 	if trailstatusTime != "" {
 		trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
@@ -1317,25 +1332,25 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 	clueId := common.Int64All(data["id"])
 	is_assign := common.IntAll(data["is_assign"])
 	oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
-	old_position_id, old_seatNumber := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"])
-	oldTaskTime = common.ObjToString(data["tasktime"])
+	old_position_id, old_seatNumber := common.Int64All(data["position_id"]), gconv.String(data["seatNumber"])
+	oldTaskTime = gconv.String(data["tasktime"])
 	is_task = common.IntAll(data["is_task"])
 	taskstatus = common.IntAll(data["taskstatus"])
 	BCPCID := common.GetRandom(32)
-	old_name := common.ObjToString(data["name"])
-	old_position := common.ObjToString(data["position"])
-	old_department := common.ObjToString(data["department"])
-	old_follow_project_area := common.ObjToString(data["follow_project_area"])
-	old_role := common.ObjToString(data["role"])
-	old_cluename := common.ObjToString(data["cluename"])
-	old_top_cluetype := common.ObjToString(data["top_cluetype"])
-	old_sub_cluetype := common.ObjToString(data["sub_cluetype"])
+	old_name := gconv.String(data["name"])
+	old_position := gconv.String(data["position"])
+	old_department := gconv.String(data["department"])
+	old_follow_project_area := gconv.String(data["follow_project_area"])
+	old_role := gconv.String(data["role"])
+	old_cluename := gconv.String(data["cluename"])
+	old_top_cluetype := gconv.String(data["top_cluetype"])
+	old_sub_cluetype := gconv.String(data["sub_cluetype"])
 	old_topname, old_subname := "", ""
 	is_transfer := common.IntAll(data["is_transfer"])
 	oldLabelChangeTime := gconv.String(data["labelChangeTime"])
 	label := gconv.Int64(data["label"])
 	if taskstatus == 1 || is_task == 0 {
-		taskTime = common.ObjToString(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
+		taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
 	} else {
 		if is_task == 1 {
 			if oldTaskTime != "" { //以最新的任务时间为主
@@ -1390,7 +1405,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		"company_nature":       isGroup,
 		"company_verification": isCommerce,
 	}
-	old_remark := common.ObjToString(data["remark"])
+	old_remark := gconv.String(data["remark"])
 	if old_remark != "" {
 		remark = old_remark + ";" + remark //备注不能替换,只能往上拼接
 	}
@@ -1422,7 +1437,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			clueUpdateData["department"] = departments
 			department = departments
 		}
-		business_scope := common.ObjToString(data["business_scope"])
+		business_scope := gconv.String(data["business_scope"])
 		keywords := ""
 		if len(keyword) > 0 && keyword[0] != "" {
 			keywords = strings.Join(keyword, ",")
@@ -1487,7 +1502,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			clueUpdateData["clue_level"] = nil
 			for _, v := range saleData {
 				if common.Int64All(data["position_id"]) == common.Int64All(v["position_id"]) {
-					oldsaleName = common.ObjToString(v["name"])
+					oldsaleName = gconv.String(v["name"])
 				}
 			}
 		}
@@ -1526,7 +1541,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 				eData := TiDb.Find("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": clueId, "change_type": "加入任务车"}, "", "", -1, -1)
 				if eData != nil && len(*eData) > 0 {
 					for _, e := range *eData {
-						new_value := common.ObjToString(e["new_value"])
+						new_value := gconv.String(e["new_value"])
 						if strings.Contains(new_value, subname) {
 							is_ok = true
 						}
@@ -1733,7 +1748,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						if cdata != nil && len(*cdata) > 0 {
 							kcpositionId := common.Int64All((*cdata)["position_id"])
-							tasksource := common.ObjToString((*cdata)["tasksource"])
+							tasksource := gconv.String((*cdata)["tasksource"])
 							taskstatus := common.IntAll((*cdata)["taskstatus"])
 							updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 								"clue_id":     clueId,
@@ -1779,13 +1794,13 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 		if old_top_cluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_topname = common.ObjToString((*pcodeData)["name"])
+				old_topname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if old_sub_cluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_subname = common.ObjToString((*pcodeData)["name"])
+				old_subname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if item != "orders" {
@@ -1986,13 +2001,13 @@ func clueInfoUpdate(data ClueMapEntity) bool {
 		if data.OldTopCluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": data.OldTopCluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_topname = common.ObjToString((*pcodeData)["name"])
+				old_topname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if data.OldSubCluetype != "" {
 			pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": data.OldSubCluetype}, "", "")
 			if pcodeData != nil && len(*pcodeData) > 0 {
-				old_subname = common.ObjToString((*pcodeData)["name"])
+				old_subname = gconv.String((*pcodeData)["name"])
 			}
 		}
 		if data.Item != "orders" {

+ 42 - 0
clueSync/jobutil.go

@@ -1862,6 +1862,8 @@ func sendEmailIfSuccessful(err error, fileName, detailName, dir string) {
 		log.Println("send mail success", fileName, email)
 	}
 }
+
+// 邀请用户处理
 func inviteUser() {
 	log.Println("邀请用户处理开始")
 	//判断节假日
@@ -1901,3 +1903,43 @@ func inviteUser() {
 	}
 	log.Println("邀请用户处理结束")
 }
+
+// 开年活动
+func nextYearActivity() {
+	log.Println("开年活动处理开始")
+	//判断节假日
+	runOk := getRunOk()
+	if !runOk {
+		log.Println("不是工作日,任务暂停")
+		return
+	}
+	activityTimeEnd := cfg.ActivityTime
+	sql := fmt.Sprintf(`SELECT
+							 a.*
+							FROM
+								jyactivities.lottery_user_account a  
+								INNER JOIN  jyactivities.lottery_prize_info b  on     a.create_time > "%s"  and  a.prize_id=b.id
+								INNER JOIN  jyactivities.prize_base_info c  on   c.name like "%s"  and b.pb_id=c.id
+							ORDER BY
+								a.create_time ASC
+`, activityTimeEnd, "%超级订阅%")
+	data := Mysql.SelectBySql(sql)
+	if data != nil && *data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			activityTimeEnd = common.ObjToString(v["create_time"])
+			v["sourceCode"] = gconv.Int64(v["active_id"])
+			v["user_id"] = gconv.String(v["mgo_user_id"])
+			ok1, ok2, _ := FormatData(v, "activity")
+			if !ok1 {
+				log.Println("线索卡点", "activity", v, activityTimeEnd)
+			} else {
+				if !ok2 {
+					log.Println("开年活动分配已达上限", "activity", v, activityTimeEnd)
+				}
+			}
+		}
+		cfg.ActivityTime = activityTimeEnd
+		common.WriteSysConfig(&cfg)
+	}
+	log.Println("开年活动处理结束")
+}

+ 71 - 537
clueSync/kc.go

@@ -194,7 +194,6 @@ func kcJob(data map[string]interface{}) int {
 		"company_name":              company_name,
 	}
 	if TiDb.Count("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}) > 0 {
-
 		csmdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 		if csmdata != nil && len(*csmdata) > 0 {
 			id := gconv.Int64((*csmdata)["id"])
@@ -259,14 +258,6 @@ func kcJob(data map[string]interface{}) int {
 					"operator_id": -1,
 				})
 			}
-			if is_transfer == 1 {
-				//从新进入需要计算客成数量
-				if customerName == db.KeCheng.Admin {
-					TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 2 where name = ?`, customerName)
-				} else {
-					TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, customerName)
-				}
-			}
 			KcSend(orderCode, customerName)
 			TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
 		}
@@ -314,11 +305,7 @@ func kcJob(data map[string]interface{}) int {
 			})
 			return cId > -1 && ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1
 		}) {
-			if customerName == db.KeCheng.Admin {
-				TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 2 where name = ?`, customerName)
-			} else {
-				TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, customerName)
-			}
+			//TiDb.UpdateOrDeleteBySql(`update dwd_f_csm_customer_autodraw_record set count = count + 1 where name = ?`, name)
 			log.Println("保存客户成功")
 		} else {
 			log.Println("保存客户失败!!!", clueId, cId, ok, updateId1, updateId2, updateId3, " 用户信息 ", customerName, customerPositionId, uId)
@@ -328,20 +315,11 @@ func kcJob(data map[string]interface{}) int {
 }
 
 func cAutoDraw(entId int, orderPositionId int64, salesperson, saleDep string, isExist bool, csmdata *map[string]interface{}) (positionId int64, name string) {
-	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 and  ent_id=?) and resign = 0 `
-	data := TiDb.SelectBySql(query, db.EntId)
+	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) and resign = 0 `
+	data := TiDb.SelectBySql(query)
 	if data == nil || len(*data) == 0 {
 		return
 	}
-	positionId, name = findKcOldPerson(entId, orderPositionId, salesperson, saleDep, isExist, csmdata, data)
-	if positionId == 0 {
-		positionId, name = findKcNewPerson(entId, data)
-	}
-	return
-}
-
-// 从以前数据中获取一个
-func findKcOldPerson(entId int, orderPositionId int64, salesperson, saleDep string, isExist bool, csmdata *map[string]interface{}, data *[]map[string]interface{}) (positionId int64, name string) {
 	//判断是否需要新增客成数据
 	if isExist {
 		//用户存在客成数据
@@ -399,60 +377,6 @@ func findKcOldPerson(entId int, orderPositionId int64, salesperson, saleDep stri
 		return
 	}
 }
-func findKcNewPerson(entId int, data *[]map[string]interface{}) (positionId int64, name string) {
-
-	if entId > 0 {
-		entdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"ent_id": entId}, "", "")
-		if entdata != nil && len(*entdata) > 0 {
-			positionId = common.Int64All((*entdata)["position_id"])
-			name = common.ObjToString((*entdata)["name"])
-			return
-		}
-	}
-	sql := `select a.name,a.count from dwd_f_csm_customer_autodraw_record a INNER JOIN dwd_d_crm_department_level_succbi b on b.ent_id=? and  (a.name = b.name)  and  b.resign = 0`
-	countData := TiDb.SelectBySql(sql, db.EntId)
-	if countData != nil && len(*countData) > 0 {
-		for _, v := range *data {
-			//判断是否有新员工
-			isOk := false
-			for _, vv := range *countData {
-				if common.ObjToString(v["name"]) == common.ObjToString(vv["name"]) {
-					isOk = true
-				}
-			}
-			//有新员工直接分给新员工
-			if !isOk {
-				name = common.ObjToString(v["name"])
-				rData := TiDb.FindOne("dwd_f_csm_customer_autodraw_record", map[string]interface{}{}, "", "count desc")
-				TiDb.Insert("dwd_f_csm_customer_autodraw_record", map[string]interface{}{
-					"name":  name,
-					"count": common.Int64All((*rData)["count"]),
-				})
-				break
-			}
-		}
-		res := int64(0)
-		countres := 0
-		for _, v := range *countData {
-			if countres == 0 {
-				res = common.Int64All(v["count"])
-				name = common.ObjToString(v["name"])
-			} else {
-				if common.Int64All(v["count"]) <= res {
-					res = common.Int64All(v["count"])
-					name = common.ObjToString(v["name"])
-				}
-			}
-			countres++
-		}
-	}
-	for _, v := range *data {
-		if name == common.ObjToString(v["name"]) {
-			positionId = common.Int64All(v["position_id"])
-		}
-	}
-	return
-}
 
 func kcAuto() {
 	log.Println("客户成功系统自动进入任务车定时任务开始")
@@ -682,13 +606,11 @@ func ordersClue() {
 	log.Println("后台订单线索定时任务结束")
 }
 
-// 自动移交销售
 func refundAuto() {
 	log.Println("自动移交销售定时任务开始")
 	findNowTime := time.Now().AddDate(0, 0, -db.ExpirationPeriod).Format(date.Date_Full_Layout)
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	mailData := map[string][]map[string]interface{}{}
-	salesEmailData := map[int64][]map[string]interface{}{}
 	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
 		for _, v := range *l {
 			saleId, cluename, company_nature, company_verification, uid, phone, userName := int64(0), "", 0, 0, "", "", ""
@@ -709,16 +631,19 @@ func refundAuto() {
 			}
 			//查询即将到期数据
 			if isRenewalProtection == 0 {
-				aaa := TiDb.CountBySql(`select count(1) from dwd_f_userbase_order_info where uid=?   and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and  refund_status!=1 and vip_endtime < ? and  vip_endtime > ? `, uid, time.Now().AddDate(0, 0, -db.ExpirationPeriod+1).Format(date.Date_Short_Layout), time.Now().AddDate(0, 0, -db.ExpirationPeriod).Format(date.Date_Short_Layout))
-				log.Println(aaa)
-				if aaa > 0 {
-					//即将到期
-					mailData[name] = append(mailData[name], map[string]interface{}{
-						"company_name": company_name,
-						"phone":        phone,
-						"userName":     userName,
-						"remrk":        "1天后即将移交",
-						"reason":       "成交客户续费失败",
+				orderData := TiDb.SelectBySql(`select * from dwd_f_userbase_order_info where uid=?   and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and  refund_status!=1 ORDER BY   vip_endtime  desc  `, uid)
+				if orderData != nil && len(*orderData) > 0 {
+					endDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod+1).Unix()
+					startDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod).Unix()
+					vipEndDate, _ := time.Parse(time.DateTime, gconv.String((*orderData)[0]["vip_endtime"]))
+					if vipEndDate.Unix() > startDate && vipEndDate.Unix() < endDate {
+						//即将到期
+						mailData[name] = append(mailData[name], map[string]interface{}{
+							"company_name": company_name,
+							"phone":        phone,
+							"userName":     userName,
+							"remrk":        "1天后即将移交",
+							"reason":       "成交客户续费失败",
 					})
 					salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
 						"company_name": company_name,
@@ -727,8 +652,9 @@ func refundAuto() {
 						"remrk":        "1天后即将移交",
 						"reason":       "成交客户续费失败",
 						"cluename":     cluename,
-					})
-					continue
+						})
+						continue
+					}
 				}
 
 			}
@@ -801,39 +727,41 @@ func refundAuto() {
 				order1 := TiDb.SelectBySql(`select id from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > ? and order_status = 1 `, uid, findNowTime)
 				if order1 == nil || len(*order1) == 0 {
 					isOk := false
-					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ? and order_status = 1 `, uid, findNowTime)
+					earliestTime := time.Now().AddDate(0, 0, gconv.Int(-db.HandoverCycle)).Format(date.Date_Full_Layout)
+					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ?  and  vip_endtime>? and order_status = 1 ORDER BY   vip_endtime  desc limit 1  `, uid, findNowTime, earliestTime)
 					if order3 != nil && len(*order3) > 0 {
-						for _, vv := range *order3 {
-							if isRenewalProtection == 1 {
-								vip_endtime := common.ObjToString(vv["vip_endtime"])
-								vip_endtimes, _ := time.ParseInLocation(date.Date_Full_Layout, vip_endtime, time.Local)
-								//查询申请保护时间
-								renewalTime := time.Now()
-								timeData := TiDb.SelectBySql(`select  max(createtime) as createtime from   dwd_f_crm_clue_change_record   where   clue_id =  ?  and  change_type="申请续费保护"`, clueId)
-								if timeData != nil && len(*timeData) > 0 {
-									if gconv.String(gconv.String((*timeData)[0]["createtime"])) != "" {
-										renewalTime, _ = time.ParseInLocation(date.Date_Short_Layout, gconv.String((*timeData)[0]["createtime"]), time.Local)
-									}
+						//获取最后一个订单信息
+						vv := (*order3)[0]
+						if isRenewalProtection == 1 {
+							vip_endtime := common.ObjToString(vv["vip_endtime"])
+							vip_endtimes, _ := time.ParseInLocation(date.Date_Full_Layout, vip_endtime, time.Local)
+							//查询申请保护时间
+							renewalTime := time.Now()
+							timeData := TiDb.SelectBySql(`select  max(createtime) as createtime from   dwd_f_crm_clue_change_record   where   clue_id =  ?  and  change_type="申请续费保护"`, clueId)
+							if timeData != nil && len(*timeData) > 0 {
+								if gconv.String(gconv.String((*timeData)[0]["createtime"])) != "" {
+									renewalTime, _ = time.ParseInLocation(date.Date_Short_Layout, gconv.String((*timeData)[0]["createtime"]), time.Local)
 								}
-								renewalInt := renewalTime.Unix()
-								log.Println("申请保护期时间", clueId, renewalInt)
-								log.Println("申请保护期时间222", time.Now().Unix()-vip_endtimes.Unix(), (db.HandoverCycle-1)*86400, (db.HandoverCycle)*86400)
-								log.Println("申请保护期时间333", (db.HandoverCycle-1)*86400 < time.Now().Unix()-vip_endtimes.Unix(), time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle)*86400)
-								//查看服务到期时间
-								if renewalInt != 0 && renewalInt < db.CustomerTime {
-									//三个月
-									if time.Now().Unix()-vip_endtimes.Unix() < 3*30*86400 {
-										isOk = true
-									}
-								} else if (db.HandoverCycle-2)*86400 < time.Now().Unix()-vip_endtimes.Unix() && time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle-1)*86400 {
-									//提前一天提示
-									mailData[name] = append(mailData[name], map[string]interface{}{
-										"company_name": company_name,
-										"phone":        phone,
-										"userName":     userName,
-										"remrk":        "1天后即将移交",
-										"reason":       "成交客户续费失败",
-									})
+							}
+							renewalInt := renewalTime.Unix()
+							log.Println("申请保护期时间", clueId, renewalInt)
+							log.Println("申请保护期时间222", time.Now().Unix()-vip_endtimes.Unix(), (db.HandoverCycle-1)*86400, (db.HandoverCycle)*86400)
+							log.Println("申请保护期时间333", (db.HandoverCycle-1)*86400 < time.Now().Unix()-vip_endtimes.Unix(), time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle)*86400)
+							//查看服务到期时间
+							if renewalInt != 0 && renewalInt < db.CustomerTime {
+								//三个月
+								if time.Now().Unix()-vip_endtimes.Unix() < 3*30*86400 {
+									isOk = true
+								}
+							} else if (db.HandoverCycle-2)*86400 < time.Now().Unix()-vip_endtimes.Unix() && time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle-1)*86400 {
+								//提前一天提示
+								mailData[name] = append(mailData[name], map[string]interface{}{
+									"company_name": company_name,
+									"phone":        phone,
+									"userName":     userName,
+									"remrk":        "1天后即将移交",
+									"reason":       "成交客户续费失败",
+								})
 									salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
 										"company_name": company_name,
 										"phone":        phone,
@@ -842,9 +770,9 @@ func refundAuto() {
 										"reason":       "成交客户续费失败",
 										"cluename":     cluename,
 									})
-								} else if time.Now().Unix()-vip_endtimes.Unix() < db.HandoverCycle*86400 {
-									isOk = true
-								}
+								isOk = true
+							} else if time.Now().Unix()-vip_endtimes.Unix() < db.HandoverCycle*86400 {
+								isOk = true
 							}
 						}
 					}
@@ -919,14 +847,6 @@ func refundAuto() {
 								"remrk":        "已移交",
 								"reason":       "成交客户续费失败",
 							})
-							salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
-								"company_name": company_name,
-								"phone":        phone,
-								"userName":     userName,
-								"remrk":        "已移交",
-								"reason":       "成交客户续费失败",
-								"cluename":     cluename,
-							})
 						}
 						TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 							"clue_id":      clueId,
@@ -1005,212 +925,13 @@ func refundAuto() {
 	}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where is_transfer = 0`)
 	//}, `select ent_id,clue_id,position_id,name,is_renewal_protection,company_name from dwd_f_csm_customer_info where clue_id =1471384`)
 
-	//移交电销客成提醒
+	//移交电销提醒
 	for i, v := range mailData {
 		ExitKcSend(i, v)
 	}
-	//移交电销销售提醒
-	for i, v := range salesEmailData {
-		ExitKcSaleSend(i, v)
-	}
 	log.Println("自动移交销售定时任务结束")
 }
 
-// 客成人员变更发邮件
-func CustomerChange() {
-	personMap := map[int64]string{}
-	personData := TiDb.SelectBySql(`select  name,position_id  from  dwd_d_crm_department_level_succbi where  ent_id=? and  resign=0   and  position_id>0`, db.EntId)
-	if personData != nil && len(*personData) > 0 {
-		for _, v := range *personData {
-			personMap[gconv.Int64(v["position_id"])] = gconv.String(v["name"])
-		}
-	}
-	startTime := cfg.LastKcChangeTime
-	if startTime == "" {
-		startTime = time.Now().Format(time.DateTime)
-	}
-	customMap1 := map[string][]map[string]interface{}{}
-	customMap2 := map[string][]map[string]interface{}{}
-	saleMap := map[int64][]map[string]interface{}{}
-	saleNobodyCustomMapMap := map[int64][]map[string]interface{}{}
-	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
-		for _, v := range *l {
-			startTime = gconv.String(v["createtime"])
-			data := CustomerChangeHandle(v)
-			oldPerson := gconv.String(data["oldPerson"])
-			newPerson := gconv.String(data["newPerson"])
-			positionId := gconv.Int64(data["positionId"])
-			operatorId := gconv.Int64(data["operatorId"])
-			if oldPerson == "/" {
-				data["oldPerson"] = "-"
-			}
-			if positionId > 0 {
-				data["positionName"] = personMap[positionId]
-			}
-			if operatorId > 0 {
-				data["operatorName"] = personMap[operatorId]
-			}
-			if (oldPerson == "" || oldPerson == "/") && newPerson != "" && newPerson != "/" && positionId > 0 {
-				//之前没有可成人员
-				saleNobodyCustomMapMap[positionId] = append(saleNobodyCustomMapMap[positionId], data)
-			} else if newPerson != "" && newPerson != "/" && oldPerson != "" && oldPerson != "/" && positionId > 0 {
-				//之前有客成
-				saleMap[positionId] = append(saleMap[positionId], data)
-			}
-			if newPerson != "" && newPerson != "/" {
-				customMap2[newPerson] = append(customMap2[newPerson], data)
-			}
-			if oldPerson != "" && oldPerson != "/" {
-				customMap1[oldPerson] = append(customMap1[oldPerson], data)
-			}
-		}
-		return true
-	}, `select operator_id, clue_id,position_id,old_value,new_value from   dwd_f_crm_clue_change_record  where    createtime>?  and change_type="客户成功经理"  and  operator_id>0  order by  createtime`, startTime)
-	if len(customMap1) > 0 {
-		ChangeSendKc(customMap1, 1)
-	}
-	if len(customMap2) > 0 {
-		ChangeSendKc(customMap1, 2)
-	}
-	if len(saleMap) > 0 {
-		ChangeSendSale(saleMap, 2)
-	}
-	if len(saleNobodyCustomMapMap) > 0 {
-		ChangeSendSale(saleNobodyCustomMapMap, 1)
-	}
-	cfg.LastKcChangeTime = startTime
-	common.WriteSysConfig(&cfg)
-}
-
-// 客户成功经理变更邮件提醒客成人员
-func ChangeSendKc(data map[string][]map[string]interface{}, personType int64) {
-	for name, v := range data {
-		to, _ := GetMail(name)
-		//正文拼接
-		startStr := `<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0"><style>table{width:100%;border-collapse:collapse}th,td{border:1px solid#000;padding:8px;text-align:left}th{background-color:#f2f2f2}</style></head><body><p></p><table><thead><tr><th>序号</th><th>公司名称</th><th>联系人</th><th>姓名</th><th>变更前客户经理</th><th>变更后客户经理</th><th>操作人</th></tr></thead><tbody>`
-		for i, v := range v {
-			startStr += fmt.Sprintf(`<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>`, i+1, gconv.String(v["companyName"]), gconv.String(v["phone"]), gconv.String(v["userName"]), gconv.String(v["oldPerson"]), gconv.String(v["newPerson"]), gconv.String(v["operatorName"]))
-		}
-		endStr := `</tbody></table><p></body></html>`
-		startStr += endStr
-		if to != "" {
-			status := mail.GSendMail_q("剑鱼标讯", to, "", "", gconv.String(common.If(personType == 1, "您有新的客户,请及时跟进处理", "您的客户已转至其他客户成功经理负责")), startStr, "", "", &Gmail)
-			if status {
-				log.Println("客成发邮件 send mail success", startStr, to, "")
-			}
-		}
-	}
-}
-
-func ChangeSendSale(data map[int64][]map[string]interface{}, personType int64) {
-	if personType == 1 {
-		//客户成功经理从空变成有人
-		for _, v := range data {
-			for _, v1 := range v {
-				to, img := GetMail(gconv.String(v1["newPerson"]))
-				startStr := `<style> *,body,html{margin:10px;font-family:tahoma,arial,'Hiragino Sans GB','Microsoft YaHei',宋体,ans-serif;font-size:16px;}p{margin:15px;font-size:18px;}table{background-color: rgb(244, 244, 249);padding:5px 15px;border:solid 1px #ddd;margin: 20px 0px 20px 50px;vertical-align:top;display:inline-block;}.tit{width:120px;}td{padding: 5px;}.clear{clear: both;}</style>
-				<p>销售人员"%s"成交的客户已成功移交至客成,公司名称:%s,姓名:%s,手机号:%s,负责客户成功经理:%s</p>
-				<p>请引导客户添加客户成功经理企业微信:</p><div class='clear'>%s</div>`
-				endStr := fmt.Sprintf(startStr, gconv.String(v1["positionName"]), gconv.String(v1["clueName"]), gconv.String(v1["userName"]), gconv.String(v1["phone"]), gconv.String(v1["newPerson"]), common.If(img != "", fmt.Sprintf(`<img width="300" height="450" src="%s">`, img), ""))
-				if to != "" {
-					status := mail.GSendMail_q("剑鱼标讯", to, "", "", "成交客户已成功移交客成", endStr, "", "", &Gmail)
-					if status {
-						log.Println("客成发邮件 send mail success", startStr, to, "")
-					}
-				}
-			}
-		}
-		return
-	}
-	//客户成功经理从A变成了B
-	for positionId, v := range data {
-		person, admin, seniorAdmin := FindDeptAdmin(positionId)
-		personMail := ""
-		adminMail := ""
-		seniorAdminMail := ""
-		if person != nil {
-			personMail, _ = GetMail(gconv.String(person["name"]))
-		}
-		if admin != nil {
-			adminMail, _ = GetMail(gconv.String(admin["name"]))
-		}
-		if seniorAdmin != nil {
-			seniorAdminMail, _ = GetMail(gconv.String(seniorAdmin["name"]))
-		}
-		to := ""
-		cc := ""
-		if personMail != "" {
-			to = personMail
-			if adminMail != "" && seniorAdminMail != "" {
-				cc = adminMail
-			} else if seniorAdminMail != "" {
-				cc = seniorAdminMail
-			}
-		} else {
-			if adminMail != "" {
-				to = adminMail
-				if seniorAdminMail != "" {
-					cc = seniorAdminMail
-				}
-			} else {
-				cc = seniorAdminMail
-
-			}
-		}
-		//正文拼接
-		startStr := `<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0"><style>table{width:100%;border-collapse:collapse}th,td{border:1px solid#000;padding:8px;text-align:left}th{background-color:#f2f2f2}</style></head><body><p>以下客户已从或即将从客成系统退出,并移交销售跟进,请收悉,客户明细如下:
-		</p><table><thead><tr><th>序号</th><th>线索名称</th><th>联系人</th><th>姓名</th><th>变更前客户经理</th><th>变更后客户经理</th><th>销售人员</th></tr></thead><tbody>`
-		for i, v := range v {
-			startStr += fmt.Sprintf(`<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>`, i+1, gconv.String(v["clueName"]), gconv.String(v["phone"]), gconv.String(v["userName"]), gconv.String(v["oldPerson"]), gconv.String(v["newPerson"]), gconv.String(v["positionName"]))
-		}
-		endStr := `</tbody></table><p></body></html>`
-		startStr += endStr
-		if to != "" {
-			status := mail.GSendMail_q("剑鱼标讯", to, cc, "", "成交客户负责客户成功经理变更", startStr, "", "", &Gmail)
-			if status {
-				log.Println("客成发邮件 send mail success", startStr, to, "")
-			}
-		}
-	}
-}
-
-// 客成人员变更基本信息获取
-func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
-	clueId := gconv.Int64(data["clue_id"])
-	oldPerson := gconv.String(data["old_value"])
-	newPerson := gconv.String(data["new_value"])
-	operatorId := gconv.Int64(data["operator_id"])
-	companyName := ""
-	phone := ""
-	userName := ""
-	clueName := ""
-	clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{
-		"id": clueId,
-	}, "", "")
-	if clueData == nil || len(*clueData) == 0 {
-		return nil
-	}
-	phone = common.ObjToString((*clueData)["phone"])
-	userName = gconv.String((*clueData)["name"])
-	positionId := gconv.Int64((*clueData)["position_id"])
-	clueName = gconv.String((*clueData)["cluename"])
-	customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
-		"clue_id": clueId,
-	}, "", "")
-	if customData != nil || len(*customData) != 0 {
-		companyName = gconv.String((*customData)["company_name"])
-	}
-	return map[string]interface{}{
-		"oldPerson":   oldPerson,
-		"newPerson":   newPerson,
-		"operatorId":  operatorId,
-		"phone":       phone,
-		"userName":    userName,
-		"positionId":  positionId,
-		"clueName":    clueName,
-		"companyName": companyName,
-	}
-}
 func refundAutoHistory() {
 	data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
 	if data != nil {
@@ -1426,7 +1147,13 @@ func KcSend(orderCode, personName string) {
 			if adminData != nil && len(*adminData) > 0 {
 				//发送给管理员
 				if adminMailStr != "" {
-					status := mail.GSendMail_q("剑鱼标讯", adminMailStr, "", "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", &Gmail)
+					gmail := &mail.GmailAuth{
+						SmtpHost: db.Mail.SmtpHost,
+						SmtpPort: db.Mail.SmtpPort,
+						User:     db.Mail.User,
+						Pwd:      db.Mail.Pwd,
+					}
+					status := mail.GSendMail_q("剑鱼标讯", adminMailStr, "", "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", gmail)
 					if status {
 						log.Println("客成发邮件 send mail success", table, adminMailStr)
 					}
@@ -1438,11 +1165,17 @@ func KcSend(orderCode, personName string) {
 		if deptData != nil && len(*deptData) > 0 {
 			mailStr := gconv.String((*deptData)[0]["mail"])
 			if mailStr != "" || adminMailStr != "" {
+				gmail := &mail.GmailAuth{
+					SmtpHost: db.Mail.SmtpHost,
+					SmtpPort: db.Mail.SmtpPort,
+					User:     db.Mail.User,
+					Pwd:      db.Mail.Pwd,
+				}
 				status := true
 				if mailStr == "" {
-					status = mail.GSendMail_q("剑鱼标讯", adminMailStr, "", "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", &Gmail)
+					status = mail.GSendMail_q("剑鱼标讯", adminMailStr, "", "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", gmail)
 				} else {
-					status = mail.GSendMail_q("剑鱼标讯", mailStr, adminMailStr, "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", &Gmail)
+					status = mail.GSendMail_q("剑鱼标讯", mailStr, adminMailStr, "", db.KeCheng.Title, fmt.Sprintf(db.KeCheng.Mail.Content, table), "", "", gmail)
 				}
 				if status {
 					log.Println("客成发邮件 send mail success", table, mailStr, adminMailStr)
@@ -1451,8 +1184,6 @@ func KcSend(orderCode, personName string) {
 		}
 	}
 }
-
-// 退客成进销售 客成收邮件
 func ExitKcSend(personName string, infoList []map[string]interface{}) {
 	//退出客成 即将退出客成信息
 	deptData := Mysql.SelectBySql("select b.mail from jianyu.entniche_department_user a inner join jianyu.entniche_user b on a.dept_id=? and a.user_id=b.id and b.name=? ", db.KeCheng.DeptId, personName)
@@ -1516,203 +1247,6 @@ func ExitKcSend(personName string, infoList []map[string]interface{}) {
 		}
 	}
 }
-
-// 查找一部三部人员信息 返回人员信息 以及管理员信息
-func FindDeptAdmin(positionId int64) (map[string]interface{}, map[string]interface{}, map[string]interface{}) {
-	//先判断那个部门的
-	userData1 := TiDb.SelectBySql(`SELECT
-	a.position_id,
-	a.name,
-	b.seat_number,
-	b.role_id,
-	a.bi_pcode,
-	a.dept_name,
-	a.resign
-FROM
-			(SELECT *
-		FROM dwd_d_crm_department_level_succbi u1
-		WHERE id = (
-			SELECT MAX(id)
-			FROM dwd_d_crm_department_level_succbi u2
-			WHERE  u1.position_id = u2.position_id		
-		)
-		ORDER BY id desc) a
-		INNER JOIN (SELECT *
-			FROM dwd_f_crm_personnel_management u1
-			WHERE id = (
-				SELECT MAX(id)
-				FROM dwd_f_crm_personnel_management u2
-				WHERE u1.position_id = u2.position_id		
-			)
-			ORDER BY id desc) b ON  a.dept_name LIKE "%电销部%"
-	AND a.position_id = b.position_id`)
-	userData3 := TiDb.SelectBySql(`SELECT
-	a.position_id,
-	a.name,
-	b.seat_number,
-	b.role_id,
-	a.bi_pcode,
-	a.dept_name,
-	a.resign
-FROM
-			(SELECT *
-		FROM dwd_d_crm_department_level_succbi u1
-		WHERE id = (
-			SELECT MAX(id)
-			FROM dwd_d_crm_department_level_succbi u2
-			WHERE  u1.position_id = u2.position_id		
-		)
-		ORDER BY id desc) a
-			INNER JOIN (SELECT *
-		FROM dwd_f_crm_personnel_management u1
-		WHERE id = (
-			SELECT MAX(id)
-			FROM dwd_f_crm_personnel_management u2
-			WHERE u1.position_id = u2.position_id		
-		)
-		ORDER BY id desc) b ON 
-	a.dept_name LIKE "%销售三部"
-	AND a.position_id = b.position_id`)
-	if userData3 == nil || len(*userData3) == 0 || userData1 == nil || len(*userData1) == 0 {
-		log.Println("找不到一部三部员工信息")
-		return nil, nil, nil
-	}
-	//一部高级管理员信息
-	seniorAdmin1 := map[string]interface{}{}
-	//三部高级管理员信息
-	seniorAdmin3 := map[string]interface{}{}
-	//一部管理员信息
-	admin1 := map[string]map[string]interface{}{}
-
-	//返回当前人信息
-	admin := map[string]interface{}{}
-	for _, v := range *userData3 {
-		v["type"] = 3
-		id := gconv.Int64(v["position_id"])
-		roleId := gconv.Int64(v["role_id"])
-		resign := gconv.Int64(v["resign"])
-		if id == positionId && resign == 0 {
-			admin = v
-		}
-		if roleId == 8 {
-			v["orderStatus"] = 2
-			seniorAdmin3 = v
-		}
-	}
-	for _, v := range *userData1 {
-		v["type"] = 1
-		id := gconv.Int64(v["position_id"])
-		roleId := gconv.Int64(v["role_id"])
-		dept_name := gconv.String(v["dept_name"])
-		resign := gconv.Int64(v["resign"])
-		if id == positionId && resign == 0 {
-			admin = v
-		}
-		if roleId == 8 {
-			v["orderStatus"] = 2
-			seniorAdmin1 = v
-		} else if roleId == 3 {
-			admin1[dept_name] = v
-		}
-	}
-	//查看当前人属于哪个部门
-	if admin == nil {
-		//当前人不属于电销部的
-		admin = *(TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{
-			"position_id": positionId,
-			"resign":      1,
-		}, "name", ""))
-	}
-	positiontype := gconv.Int64(admin["type"])
-	deptName := gconv.String(admin["dept_name"])
-	switch positiontype {
-	case 1:
-		return admin, admin1[deptName], seniorAdmin1
-	case 3:
-		return admin, nil, seniorAdmin3
-	default:
-		return admin, nil, nil
-	}
-}
-
-// 邮箱获取
-func GetMail(personName string) (string, string) {
-	data := Mysql.SelectBySql(`select  name,mail,img from   entniche_user  where  ent_id =?`, db.EntId)
-	if data == nil || len(*data) == 0 {
-		return "", ""
-	}
-	for _, m := range *data {
-		name := gconv.String(m["name"])
-		if name == personName {
-			//
-			return gconv.String(m["mail"]), gconv.String(m["img"])
-		}
-	}
-	return "", ""
-}
-
-// 退客成进销售 销售收邮件
-func ExitKcSaleSend(positionId int64, infoList []map[string]interface{}) {
-	person, admin, seniorAdmin := FindDeptAdmin(positionId)
-	personMail := ""
-	adminMail := ""
-	seniorAdminMail := ""
-	if person != nil {
-		personMail, _ = GetMail(gconv.String(person["name"]))
-	}
-	if admin != nil {
-		adminMail, _ = GetMail(gconv.String(admin["name"]))
-	}
-	if seniorAdmin != nil {
-		seniorAdminMail, _ = GetMail(gconv.String(seniorAdmin["name"]))
-	}
-	//退出客成 即将退出客成信息  销售信息编辑
-	gmail := &mail.GmailAuth{
-		SmtpHost: db.Mail.SmtpHost,
-		SmtpPort: db.Mail.SmtpPort,
-		User:     db.Mail.User,
-		Pwd:      db.Mail.Pwd,
-	}
-	//正文拼接
-	startStr := `<html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, initial-scale=1.0"><style>table{width:100%;border-collapse:collapse}th,td{border:1px solid#000;padding:8px;text-align:left}th{background-color:#f2f2f2}</style></head><body><p>以下客户已从或即将从客成系统退出,并移交销售跟进,请收悉,客户明细如下:</p><table><thead><tr><th>序号</th><th>线索名称</th><th>联系人</th><th>姓名</th><th>移交状态</th><th>移交销售原因</th></tr></thead><tbody>`
-	for i, v := range infoList {
-		startStr += fmt.Sprintf(`<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>`, i+1, gconv.String(v["cluename"]), gconv.String(v["phone"]), gconv.String(v["userName"]), gconv.String(v["remrk"]), gconv.String(v["reason"]))
-	}
-	endStr := `</tbody></table><p></body></html>`
-	startStr += endStr
-	to := ""
-	cc := ""
-	if personMail != "" {
-		to = personMail
-		if adminMail != "" && seniorAdminMail != "" {
-			if adminMail != seniorAdminMail {
-				cc = fmt.Sprintf("%s|%s", adminMail, seniorAdminMail)
-			} else {
-				cc = adminMail
-			}
-		} else if adminMail != "" {
-			cc = adminMail
-		} else if seniorAdminMail != "" {
-			cc = seniorAdminMail
-		}
-	} else {
-		if adminMail != "" {
-			to = adminMail
-			if seniorAdminMail != "" {
-				cc = seniorAdminMail
-			}
-		} else {
-			cc = seniorAdminMail
-
-		}
-	}
-	if to != "" {
-		status := mail.GSendMail_q("剑鱼标讯", to, cc, "", "成交客户续费失败移交销售通知", startStr, "", "", gmail)
-		if status {
-			log.Println("客成发邮件 send mail success", startStr, to, cc)
-		}
-	}
-}
 func KcOrderFormat(orderCode string, bigmemberService, combo map[int64]string) *OrderInfo {
 	orderData := Mysql.SelectBySql(`SELECT a.id,a.order_code,a.pay_money,a.user_phone,a.vip_starttime,a.vip_endtime,a.product_type,a.filter,a.user_id,a.ent_id,a.company_name,a.create_person,SUM(b.return_money) AS return_money 
 		FROM jianyu.dataexport_order a

+ 2 - 4
clueSync/main.go

@@ -153,9 +153,8 @@ func main() {
 	MgoQyxy = mongodb.NewMgoWithUser(db.MgoQyxy.Address, db.MgoQyxy.DbName, db.MgoQyxy.User, db.MgoQyxy.Password, db.MgoQyxy.DbSize)
 	InitArea()
 	InitProduct(db.ProductArr)
-	//kcSync() //移交客成
-	//refundAuto()
-
+	//kcSync()
+	//refundAuto() //客成移交销售
 	if *mode == 1 {
 		go ordersClue() //后台订单进线索
 		//一秒钟一次
@@ -170,7 +169,6 @@ func main() {
 		})
 		//5分钟一次
 		go p.VarTimeTask.RunInTimeSection("5分钟定时任务1", db.CornExp2Start, db.CornExp2End, db.CornExp2, func(dayFirst bool) {
-
 			users()               //新注册用户进线索
 			saleLeads()           //留资进线索
 			eventReg()            //渠道