浏览代码

移交销售更新

xuzhiheng 1 年之前
父节点
当前提交
f8d6fed0de
共有 5 个文件被更改,包括 17 次插入1384 次删除
  1. 1 31
      clueSync/everything.go
  2. 8 0
      clueSync/jobutil.go
  3. 8 605
      clueSync/kc.go
  4. 0 133
      clueSync/subscribeAll.go
  5. 0 615
      clueSync/trailContent.go

+ 1 - 31
clueSync/everything.go

@@ -335,40 +335,10 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
 
 // 大客户线索-发邮件
 func bigCustomer() {
-	/*
-		2、线索来源:
-			(1)留资线索
-			   根据留资维表:tidb/Jianyu_subjectdb/d_saleleads_code
-			   根据维表中department字段包含“大客户”的所有source
-			   Source对应的中文名称用维表中的name,name要去掉"-pc","-app","-wx","-h5"
-			   查询sql如下:SELECT source,name FROM Jianyu_subjectdb.d_saleleads_code WHERE department LIKE '%大客户' AND is_delete = 1
-			(2)订单线索
-				①线上历史数据导出未支付订单
-				②线上历史数据导出已支付订单
-		3、线索处理逻辑
-			(1)线索每天保留最新的一条数据
-			(2)"具体来源", "数据需求" 这两个字段要将该用户当天作为线索进入大客户线索池的内容去重汇总,并用逗号分隔
-		4、导出明细
-			购买条数据:购买产品是“历史数据”,获取对应的购买条数
-			已支付订单信息:产品类型-有效期-金额
-			未支付订单信息:产品类型
-		5、发送邮件
-			(1)邮件主题:线索日期+大客户销售线索
-			(2)收件人:
-				"gaoxiang@jianyu360.com",
-				"sunzhenjie@jianyu360.com",
-				"fanzongdong@jianyu360.com",
-				"chenzhaobiao@jianyu360.com"
-			(3)发送内容
-				①当天有线索,邮件正文为:线索日期+数据详情请查看附件。附件名称同主题名称
-				②当天无线索,邮件正文为:线索日期+无数据。
-			(4)发送时间
-				每天一次,每天早上8:20
-	*/
 	log.Println("大客户线索定时任务开始")
 	dataArr := []map[string]interface{}{}
 	filterArr := []string{"-pc", "-app", "-wx", "-h5"}
-	sourceMap := map[string]string{}
+	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 {

+ 8 - 0
clueSync/jobutil.go

@@ -508,3 +508,11 @@ func GetCompanyType(companyName string) (int, int) {
 	}
 	return isGroup, isCommerce
 }
+
+func getSeatNumberPositionId(seatNumber string) (positionId int64) {
+	saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "")
+	if saleData != nil && len(*saleData) > 0 {
+		positionId = common.Int64All((*saleData)["position_id"])
+	}
+	return
+}

+ 8 - 605
clueSync/kc.go

@@ -13,7 +13,6 @@ import (
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/redis"
-	"github.com/tealeg/xlsx"
 )
 
 func kcSync() {
@@ -594,627 +593,31 @@ func ordersClue() {
 	log.Println("后台订单线索定时任务结束")
 }
 
-func kcHistorySync() {
-	filePath := "./无线索的.xlsx"
-	// SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
-	// log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
-	// return
-	xlFile, _ := xlsx.OpenFile(filePath)
-	//获取行数
-	// length := len(xlFile.Sheets[0].Rows)
-	//开辟除表头外的行数的数组内存
-	// resourceArr := make([]map[string]interface{}, length-1)
-	//遍历sheet
-	for k, sheet := range xlFile.Sheets {
-		if k > 0 {
-			break
-		}
-		//遍历每一行
-		for rowIndex, row := range sheet.Rows {
-			//跳过第一行表头信息
-			if rowIndex == 0 {
-				continue
-			}
-			nowTime := time.Now().Format(date.Date_Full_Layout)
-			relationship_building_way := row.Cells[1].Value
-			relationship_building_ways := 1
-			if relationship_building_way == "个人微信" {
-				relationship_building_ways = 2
-			} else if relationship_building_way == "企业微信" {
-				relationship_building_ways = 3
-			}
-			training_way := row.Cells[2].Value
-			training_ways := 1
-			if training_way == "发送使用资料" {
-				training_ways = 5
-			} else if training_way == "线上一对一" {
-				training_ways = 3
-			} else if training_way == "线下一对一" {
-				training_ways = 4
-			}
-			inventory_way := row.Cells[3].Value
-			inventory_ways := 1
-			if inventory_way == "电话盘点" {
-				inventory_ways = 3
-			} else if inventory_way == "微信盘点" {
-				inventory_ways = 2
-			}
-			service_stage := row.Cells[4].Value
-			service_stages := 1
-			if service_stage == "断约" {
-				service_stages = 2
-			} else if service_stage == "续约期" {
-				service_stages = 3
-			}
-			renewal_intention := row.Cells[5].Value
-			renewal_intentions := 1
-			if renewal_intention == "中" {
-				renewal_intentions = 2
-			} else if renewal_intention == "高" {
-				renewal_intentions = 3
-			}
-			positive_behavior_reminder := row.Cells[6].Value
-			positive_behavior_reminders := ""
-			if positive_behavior_reminder != "" {
-				positive_behavior_reminders = "1,3"
-			}
-			// negative_behavior_reminder := ""
-			name := row.Cells[13].Value
-			// phoneMap := map[string]string{
-			// "朱庆伟": "17600755377",
-			// "程涵":  "15538709520",
-			// "张铭铭": "18237530966",
-			// }
-
-			// company_name := row.Cells[10].Value
-			company_address := row.Cells[14].Value
-			company_website := row.Cells[15].Value
-			service_starttime := row.Cells[16].Value
-			service_endtime := row.Cells[17].Value
-
-			industry_status := row.Cells[21].Value
-			industry_statuss := 1
-			if industry_status == "非头部" {
-				industry_statuss = 2
-			}
-			target_customer_type := row.Cells[24].Value
-			main_sale_way := row.Cells[25].Value
-			main_get_info_way := row.Cells[26].Value
-			bid_sales_proportion := row.Cells[27].Value
-			continuous_use_judgment := row.Cells[29].Value
-			bid_sales_proportions := 1
-			continuous_use_judgments := 1
-			if bid_sales_proportion == "10%-19%" {
-				bid_sales_proportions = 2
-			} else if bid_sales_proportion == "20%-49%" {
-				bid_sales_proportions = 3
-			} else if bid_sales_proportion == "50%-69%" {
-				bid_sales_proportions = 4
-			} else if bid_sales_proportion == "70%及以上" {
-				bid_sales_proportions = 4
-			}
-			if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
-				continuous_use_judgments = 2
-			} else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
-				continuous_use_judgments = 3
-			} else if strings.Contains(continuous_use_judgment, "需持续培育") {
-				continuous_use_judgments = 4
-			}
-			is_pre_sales_training := row.Cells[30].Value
-			is_pre_sales_trainings := 0
-			if is_pre_sales_training == "是" {
-				is_pre_sales_trainings = 1
-			}
-			shpx := row.Cells[31].Value
-			if shpx == "否" {
-				training_ways = 2
-			}
-			notes := row.Cells[32].Value
-			phone := strings.TrimSpace(row.Cells[11].Value)
-			log.Println("PHONE", phone, name, len(phone))
-			// if phone != "" && len(phone) == 11 && phoneMap[name] != "" {
-			positionId := 0
-			if name == "程涵" {
-				positionId = 2202735
-			} else if name == "张铭铭" {
-				positionId = 2202736
-			}
-			clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
-			log.Println("clueData", clueData)
-			if clueData != nil {
-				clueId := common.Int64All((*clueData)["id"])
-				log.Println("线索存在", phone, clueId)
-				role := row.Cells[18].Value
-				business_scope := row.Cells[19].Value
-				industry := row.Cells[20].Value
-				salesperson_num := row.Cells[22].Value
-				salesperson_nums := 1
-				if salesperson_num == "10-19" {
-					salesperson_nums = 2
-				} else if salesperson_num == "20-49" {
-					salesperson_nums = 3
-				} else if salesperson_num == "50-99" {
-					salesperson_nums = 4
-				}
-				area := row.Cells[23].Value
-				areaArr := []string{}
-				for _, v := range strings.Split(area, ",") {
-					areaArr = append(areaArr, AreaCode[v])
-				}
-				follow_project_area := ""
-				if len(areaArr) > 0 {
-					follow_project_area = strings.Join(areaArr, ",")
-				}
-				customer_demand := row.Cells[28].Value
-				updatetime := row.Cells[36].Value
-				ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
-					"role":                role,
-					"business_scope":      business_scope,
-					"industry":            industry,
-					"follow_project_area": follow_project_area,
-					"customer_demand":     customer_demand,
-					"updatetime":          updatetime,
-					"is_transfer":         1,
-					"salesperson_num":     salesperson_nums,
-				})
-				if ok {
-					entId := "0"
-					buy_subject := 1
-					company_name := ""
-					product := 1
-					powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
-					if powerData != nil {
-						buy_subject = common.IntAll((*powerData)["buy_subject"])
-						if buy_subject == 1 {
-							entId = common.ObjToString((*powerData)["userid"])
-						} else {
-							entId = fmt.Sprint((*powerData)["ent_id"])
-						}
-						company_name = common.ObjToString((*powerData)["company_name"])
-						product_type := common.ObjToString((*powerData)["product_type"])
-						data_spec := common.ObjToString((*powerData)["data_spec"])
-						productMap := map[string]int{
-							"dhy6":   1,
-							"dhy7":   2,
-							"dhy3":   4,
-							"dhy1":   5,
-							"dhy2":   6,
-							"dhy5":   7,
-							"企业商机管理": 8,
-						}
-						if product_type == "企业商机管理" {
-							product = productMap[product_type]
-						} else {
-							if data_spec == "dhy6" {
-								product = 1
-								filter := common.ObjToString((*powerData)["filter"])
-								filterMap := map[string]interface{}{}
-								json.Unmarshal([]byte(filter), &filterMap)
-								if len(filterMap) > 0 {
-									areaCount := common.IntAll(filterMap["areaCount"])
-									if areaCount == 1 {
-										product = 3
-									}
-								}
-							} else {
-								product = productMap[data_spec]
-							}
-						}
-					}
-					cid := TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
-						"clue_id":                    clueId,
-						"transfertime":               nowTime,
-						"position_id":                positionId,
-						"name":                       name,
-						"service_starttime":          service_starttime,
-						"service_endtime":            service_endtime,
-						"ent_id":                     entId,
-						"is_task":                    1,
-						"tasktime":                   nowTime,
-						"taskstatus":                 0,
-						"tasksource":                 "1",
-						"is_admin":                   1,
-						"product_access":             product,
-						"buy_subject":                buy_subject,
-						"relationship_building_way":  relationship_building_ways,
-						"inventory_way":              inventory_ways,
-						"training_way":               training_ways,
-						"is_pre_sales_training":      is_pre_sales_trainings,
-						"service_stage":              service_stages,
-						"company_name":               company_name,
-						"renewal_intention":          renewal_intentions,
-						"positive_behavior_reminder": positive_behavior_reminders,
-						"company_address":            company_address,
-						"company_website":            company_website,
-						"industry_status":            industry_statuss,
-						"target_customer_type":       target_customer_type,
-						"main_sale_way":              main_sale_way,
-						"main_get_info_way":          main_get_info_way,
-						// "bid_sales_proportion":    bid_sales_proportions,
-						// "continuous_use_judgment": continuous_use_judgments,
-						"notes": notes,
-					})
-					if cid > 0 {
-						log.Println("保存客户成功", phone)
-					} else {
-						log.Println("保存客户失败!!!", phone)
-					}
-				} else {
-					log.Println("线索修改失败!!!", phone)
-				}
-			} else {
-				role := row.Cells[18].Value
-				business_scope := row.Cells[19].Value
-				industry := row.Cells[20].Value
-				salesperson_num := row.Cells[22].Value
-				salesperson_nums := 1
-				if salesperson_num == "10-19" {
-					salesperson_nums = 2
-				} else if salesperson_num == "20-49" {
-					salesperson_nums = 3
-				} else if salesperson_num == "50-99" {
-					salesperson_nums = 4
-				}
-				area := row.Cells[23].Value
-				areaArr := []string{}
-				for _, v := range strings.Split(area, ",") {
-					areaArr = append(areaArr, AreaCode[v])
-				}
-				follow_project_area := ""
-				if len(areaArr) > 0 {
-					follow_project_area = strings.Join(areaArr, ",")
-				}
-				customer_demand := row.Cells[28].Value
-				entId := "0"
-				clueId := int64(0)
-				buy_subject := 1
-				company_name := ""
-				product := 1
-				powerData := TiDb.FindOne("dwd_f_userbase_order_info", map[string]interface{}{"phone": phone}, "", "autoUpdate desc")
-				if powerData != nil {
-					buy_subject = common.IntAll((*powerData)["buy_subject"])
-					if buy_subject == 1 {
-						entId = common.ObjToString((*powerData)["userid"])
-					} else {
-						entId = fmt.Sprint((*powerData)["ent_id"])
-					}
-					company_name = common.ObjToString((*powerData)["company_name"])
-					product_type := common.ObjToString((*powerData)["product_type"])
-					data_spec := common.ObjToString((*powerData)["data_spec"])
-					productMap := map[string]int{
-						"dhy6":   1,
-						"dhy7":   2,
-						"dhy3":   4,
-						"dhy1":   5,
-						"dhy2":   6,
-						"dhy5":   7,
-						"企业商机管理": 8,
-					}
-					if product_type == "企业商机管理" {
-						product = productMap[product_type]
-					} else {
-						if data_spec == "dhy6" {
-							product = 1
-							filter := common.ObjToString((*powerData)["filter"])
-							filterMap := map[string]interface{}{}
-							json.Unmarshal([]byte(filter), &filterMap)
-							if len(filterMap) > 0 {
-								areaCount := common.IntAll(filterMap["areaCount"])
-								if areaCount == 1 {
-									product = 3
-								}
-							}
-						} else {
-							product = productMap[data_spec]
-						}
-					}
-					//
-					uId := common.ObjToString((*powerData)["uid"])
-					userId := common.ObjToString((*powerData)["userid"])
-					pay_money := common.IntAll((*powerData)["pay_money"])
-					seatNumber, trailstatus := "", ""
-					salePositionId := int64(0)
-					cluename := common.ObjToString((*powerData)["company_name"])
-					salesperson := common.ObjToString((*powerData)["salesperson"])
-					if cluename == "" {
-						cluename = phone
-					}
-					if pay_money > 0 {
-						trailstatus = "08"
-					} else {
-						trailstatus = "01"
-					}
-					saleData := TiDb.FindOne("jy_salesperson_info", map[string]interface{}{"name": salesperson}, "", "")
-					if saleData != nil {
-						seatNumber = common.ObjToString((*saleData)["seat_number"])
-						salePositionId = common.Int64All((*saleData)["position_id"])
-					}
-					clueId = TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-						"userid":               userId,
-						"uid":                  uId,
-						"seatNumber":           seatNumber,
-						"position_id":          salePositionId,
-						"is_assign":            1,
-						"comeintime":           nowTime,
-						"createtime":           nowTime,
-						"updatetime":           nowTime,
-						"cluename":             cluename,
-						"top_cluetype":         "4",
-						"sub_cluetype":         "154",
-						"trailstatus":          trailstatus,
-						"name":                 phone,
-						"phone":                phone,
-						"comeinsource_private": 2,
-						"is_task":              0,
-						"taskstatus":           1,
-						"role":                 role,
-						"business_scope":       business_scope,
-						"industry":             industry,
-						"follow_project_area":  follow_project_area,
-						"customer_demand":      customer_demand,
-						"is_transfer":          1,
-						"salesperson_num":      salesperson_nums,
-					})
-					//
-				}
-				TiDb.Insert("dwd_f_csm_customer_info", map[string]interface{}{
-					"clue_id":                    clueId,
-					"transfertime":               nowTime,
-					"position_id":                positionId,
-					"name":                       name,
-					"service_starttime":          service_starttime,
-					"service_endtime":            service_endtime,
-					"ent_id":                     entId,
-					"is_task":                    0,
-					"tasktime":                   nil,
-					"taskstatus":                 1,
-					"tasksource":                 nil,
-					"is_admin":                   1,
-					"product_access":             product,
-					"buy_subject":                buy_subject,
-					"relationship_building_way":  relationship_building_ways,
-					"inventory_way":              inventory_ways,
-					"training_way":               training_ways,
-					"is_pre_sales_training":      is_pre_sales_trainings,
-					"service_stage":              service_stages,
-					"company_name":               company_name,
-					"renewal_intention":          renewal_intentions,
-					"positive_behavior_reminder": positive_behavior_reminders,
-					"company_address":            company_address,
-					"company_website":            company_website,
-					"industry_status":            industry_statuss,
-					"target_customer_type":       target_customer_type,
-					"main_sale_way":              main_sale_way,
-					"main_get_info_way":          main_get_info_way,
-					"bid_sales_proportion":       bid_sales_proportions,
-					"continuous_use_judgment":    continuous_use_judgments,
-					"notes":                      notes,
-				})
-			}
-			// } else {
-			// 	log.Println("手机号有问题!!!", phone)
-			// 	row.AddCell().SetValue("手机号有问题!!!")
-			// }
-		}
-	}
-	// err := xlFile.Save("./222.xlsx")
-	// if err != nil {
-	// 	log.Println("xls error")
-	// }
-}
-
-func kcHistorySyncs() {
-	filePath := "./有线索的.xlsx"
-	// SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
-	// log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
-	// return
-	xlFile, _ := xlsx.OpenFile(filePath)
-	//获取行数
-	// length := len(xlFile.Sheets[0].Rows)
-	//开辟除表头外的行数的数组内存
-	// resourceArr := make([]map[string]interface{}, length-1)
-	//遍历sheet
-	for k, sheet := range xlFile.Sheets {
-		if k > 0 {
-			break
-		}
-		//遍历每一行
-		for rowIndex, row := range sheet.Rows {
-			//跳过第一行表头信息
-			if rowIndex == 0 {
-				continue
-			}
-			bid_sales_proportion := row.Cells[2].Value
-			continuous_use_judgment := row.Cells[3].Value
-			phone := row.Cells[0].Value
-			bid_sales_proportions := 1
-			continuous_use_judgments := 1
-			if bid_sales_proportion == "10%-19%" {
-				bid_sales_proportions = 2
-			} else if bid_sales_proportion == "20%-49%" {
-				bid_sales_proportions = 3
-			} else if bid_sales_proportion == "50%-69%" {
-				bid_sales_proportions = 4
-			} else if bid_sales_proportion == "70%及以上" {
-				bid_sales_proportions = 4
-			}
-			if strings.Contains(continuous_use_judgment, "预计可持续使用。需勤维护") {
-				continuous_use_judgments = 2
-			} else if strings.Contains(continuous_use_judgment, "需从功能层面提升客户粘性") {
-				continuous_use_judgments = 3
-			} else if strings.Contains(continuous_use_judgment, "需持续培育") {
-				continuous_use_judgments = 4
-			}
-			if phone != "" {
-				clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
-				if clueData != nil {
-					clueId := common.Int64All((*clueData)["id"])
-					log.Println("线索存在", phone, clueId)
-					salesperson_num := row.Cells[1].Value
-					salesperson_nums := 1
-					if salesperson_num == "10-19" {
-						salesperson_nums = 2
-					} else if salesperson_num == "20-49" {
-						salesperson_nums = 3
-					} else if salesperson_num == "50-99" {
-						salesperson_nums = 4
-					}
-					ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, map[string]interface{}{
-						"salesperson_num": salesperson_nums,
-					})
-					if ok {
-						oks := TiDb.Update("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
-							"bid_sales_proportion":    bid_sales_proportions,
-							"continuous_use_judgment": continuous_use_judgments,
-						})
-						if oks {
-							log.Println("修改客户成功", phone)
-						} else {
-							log.Println("修改客户失败!!!", phone)
-						}
-					} else {
-						log.Println("线索修改失败!!!", phone)
-					}
-				}
-			}
-		}
-	}
-}
-
-func kcVisitSync() {
-	filePath := "./222.xlsx"
-	// SE := qu.SimpleEncrypt{Key: "topJYBX2019"}
-	// log.Println(SE.DecodeString("QltHc2AmagsIUFwVV0dybyZpAwECX0YK"))
-	// return
-	xlFile, _ := xlsx.OpenFile(filePath)
-	//获取行数
-	// length := len(xlFile.Sheets[0].Rows)
-	//开辟除表头外的行数的数组内存
-	// resourceArr := make([]map[string]interface{}, length-1)
-	//遍历sheet
-	for k, sheet := range xlFile.Sheets {
-		if k == 1 {
-			//遍历每一行
-			for rowIndex, row := range sheet.Rows {
-				//跳过第一行表头信息
-				if rowIndex == 0 {
-					continue
-				}
-				tasksource := row.Cells[1].Value
-				tasksources := 1
-				if tasksource == "客户情况盘点" {
-					tasksources = 2
-				} else if tasksource == "未培训" {
-					tasksources = 3
-				} else if tasksource == "日常沟通" {
-					tasksources = 4
-				} else if tasksource == "续约沟通" {
-					tasksources = 5
-				} else if tasksource == "月度回访" {
-					tasksources = 6
-				} else if tasksource == "培训首周回访" {
-					tasksources = 7
-				} else if tasksource == "建联" {
-					tasksources = 1
-				}
-				phone := row.Cells[2].Value
-				trail_way := row.Cells[3].Value
-				trail_ways := 1
-				if trail_way == "电话沟通" {
-					trail_ways = 2
-				} else if trail_way == "线下面访" {
-					trail_ways = 3
-				} else if trail_way == "腾讯会议" {
-					trail_ways = 4
-				}
-				content := row.Cells[4].Value
-				name := row.Cells[5].Value
-				positionId := 0
-				if name == "程涵" {
-					positionId = 2202735
-				} else if name == "张铭铭" {
-					positionId = 2202736
-				} else {
-					positionId = -1
-				}
-				createtime := row.Cells[6].Value
-				clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
-				if clueData != nil {
-					clueId := common.Int64All((*clueData)["id"])
-					TiDb.Insert("dwd_f_crm_trail_content", map[string]interface{}{
-						"clue_id":     clueId,
-						"position_id": positionId,
-						"operator_id": -1,
-						"content":     content,
-						"createtime":  createtime,
-						"tasksource":  tasksources,
-						"trail_way":   trail_ways,
-					})
-				} else {
-					row.AddCell().SetValue("没有线索")
-				}
-			}
-		} else if k == 2 {
-			//遍历每一行
-			for rowIndex, row := range sheet.Rows {
-				//跳过第一行表头信息
-				if rowIndex == 0 {
-					continue
-				}
-				phone := row.Cells[2].Value
-				contact_type := row.Cells[4].Value
-				clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
-				if clueData != nil {
-					clueId := common.Int64All((*clueData)["id"])
-					TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"contact_type": contact_type})
-				} else {
-					row.AddCell().SetValue("没有线索")
-				}
-			}
-		}
-	}
-	err := xlFile.Save("./333.xlsx")
-	if err != nil {
-		log.Println("xls error")
-	}
-}
-
 func refundAuto() {
 	log.Println("自动移交销售定时任务开始")
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
 		for _, v := range *l {
-			saleId, cluename, company_nature, company_verification := int64(0), "", 0, 0
+			saleId, cluename, company_nature, company_verification, uid := int64(0), "", 0, 0, ""
 			clueId := common.Int64All(v["clue_id"])
 			name := common.ObjToString(v["name"])
 			kcposition_id := common.Int64All(v["position_id"])
 			isRenewalProtection := common.IntAll(v["is_renewal_protection"])
-			phone := ""
-
-			// if !mongodb.IsObjectIdHex(userId) {
-			clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "company_nature,company_verification,cluename,userid,position_id,phone", "")
+			clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "company_nature,company_verification,cluename,userid,position_id,uid", "")
 			if clueData != nil && len(*clueData) > 0 {
 				saleId = common.Int64All((*clueData)["position_id"])
-				// userId = common.ObjToString((*clueData)["userid"])
 				cluename = common.ObjToString((*clueData)["cluename"])
 				company_nature = common.IntAll((*clueData)["company_nature"])
 				company_verification = common.IntAll((*clueData)["company_verification"])
-				phone = common.ObjToString((*clueData)["phone"])
+				uid = common.ObjToString((*clueData)["uid"])
 			}
-			query1 := `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "` + nowTime + `" and order_status = 1 and user_phone = "` + phone + `"`
-			query2 := `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and user_phone = "` + phone + `"`
-			// userData := TiDb.SelectBySql("select position_id from dwd_f_userbase_id_mapping where userid = ? and ent_id = ?", userId, entId)
-			// if userData != nil && len(*userData) > 0 {
-			// 	positionId = common.Int64All((*userData)[0]["position_id"])
-			// 	query1 = `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "` + nowTime + `" and order_status = 1 and user_id = "` + fmt.Sprint(positionId) + `"`
-			// 	query2 = `select id from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and user_id = "` + fmt.Sprint(positionId) + `"`
-			// }
-			// }
-			order1 := Mysql.SelectBySql(query1)
+			query1 := `select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "?" and order_status = 1 and uid = "?"`
+			query2 := `select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and uid = "?"`
+			order1 := TiDb.SelectBySql(query1, nowTime, uid)
 			if order1 == nil || len(*order1) == 0 {
 				log.Println("query1 ", query1)
 				isOk := false
-				order3 := Mysql.SelectBySql(`select vip_endtime from dataexport_order where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "` + nowTime + `" and order_status = 1 and user_phone = "` + phone + `"`)
+				order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "?" and order_status = 1 and uid = "?"`, nowTime, uid)
 				if order3 != nil && len(*order3) > 0 {
 					for _, vv := range *order3 {
 						if isRenewalProtection == 1 {
@@ -1312,7 +715,7 @@ func refundAuto() {
 					TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
 				}
 			}
-			order2 := Mysql.SelectBySql(query2)
+			order2 := TiDb.SelectBySql(query2, uid)
 			if order2 == nil || len(*order2) == 0 {
 				log.Println("query2 ", query2)
 				//全退款了

+ 0 - 133
clueSync/subscribeAll.go

@@ -1,12 +1,9 @@
 package main
 
 import (
-	"regexp"
 	"strings"
 	"time"
 
-	"app.yhyue.com/moapp/jybase/date"
-
 	"log"
 
 	"app.yhyue.com/moapp/jybase/common"
@@ -179,133 +176,3 @@ func FormatSubscribeAllData(data map[string]interface{}) {
 		}
 	}
 }
-
-func eventSync() {
-	AppBuyPortraitReg := regexp.MustCompile("^/jyapp/big/page/unit_portrayal")
-	AppArticleReg := regexp.MustCompile("^/jyapp/article/(content|bdprivate|mailprivate)")
-	AppEntPortraitReg := regexp.MustCompile("^/jyapp/big/page/ent_portrait")
-	AppClientReg := regexp.MustCompile("^^/jyapp/big/page/client_portrayal")
-	TiDb.SelectByBath(1000, func(l *[]map[string]interface{}) bool {
-		for _, v := range *l {
-			url_ := common.ObjToString(v["url"])
-			id := common.Int64All(v["id"])
-			if AppBuyPortraitReg.MatchString(url_) {
-				url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
-			} else if AppArticleReg.MatchString(url_) {
-				url_ = strings.ReplaceAll(url_, "/jyapp", "")
-			} else if AppEntPortraitReg.MatchString(url_) {
-				url_ = strings.ReplaceAll(url_, "/jyapp/big/page", "/swordfish/page_big_pc")
-			} else if AppClientReg.MatchString(url_) {
-				url_ = strings.ReplaceAll(url_, "/jyapp/big/page/client_portrayal?entName=", "/swordfish/page_big_pc/unit_portrayal/")
-			}
-			ok := TiDb.Update("dwd_f_userbase_event_info", map[string]interface{}{"id": id}, map[string]interface{}{"url": url_})
-			if ok {
-				log.Println("修改成功 ", id, url_)
-			} else {
-				log.Println("修改失败 ", id, url_)
-			}
-		}
-		return true
-	}, `SELECT * from dwd_f_userbase_event_info where platform = 1`)
-	log.Println("app刷行为信息链接结束")
-}
-
-func uidSync() {
-	phoneMap := map[string][]map[string]interface{}{}
-	data := TiDb.SelectBySql(`SELECT * FROM dwd_f_crm_clue_info WHERE phone IN (SELECT phone FROM dwd_f_crm_clue_info GROUP BY phone HAVING COUNT(1) > 1) ORDER BY comeintime asc`)
-	if data != nil && len(*data) > 0 {
-		for _, v := range *data {
-			phone := common.ObjToString(v["phone"])
-			id1 := common.Int64All(v["id"])
-			if phone != "" {
-				phoneMap[phone] = append(phoneMap[phone], v)
-			} else {
-				TiDb.Delete("dwd_f_crm_clue_info", map[string]interface{}{"id": id1})
-				TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id1})
-				TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id1})
-				TiDb.Delete("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": id1})
-			}
-		}
-	}
-	log.Println(len(phoneMap))
-	for _, v := range phoneMap {
-		userid1 := common.ObjToString(v[0]["userid"])
-		id1 := common.Int64All(v[0]["id"])
-		id2 := common.Int64All(v[1]["id"])
-		if userid1 != "" {
-			TiDb.Delete("dwd_f_crm_clue_info", map[string]interface{}{"id": id2})
-			TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id2})
-			TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id2})
-			TiDb.Delete("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": id2})
-			is_assign := common.IntAll(v[0]["is_assign"])
-			DelClue(is_assign, id1)
-		} else {
-			TiDb.Delete("dwd_f_crm_clue_info", map[string]interface{}{"id": id1})
-			TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id1})
-			TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id1})
-			TiDb.Delete("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": id1})
-			is_assign := common.IntAll(v[1]["is_assign"])
-			DelClue(is_assign, id2)
-		}
-	}
-}
-
-func DelClue(is_assign int, id2 int64) {
-	if is_assign == 1 {
-		pd := TiDb.FindOne("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id2}, "", "")
-		if pd != nil && len(*pd) > 0 {
-			TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id2})
-		} else {
-			od := TiDb.FindOne("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id2}, "", "")
-			if od != nil && len(*od) > 0 {
-				TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": id2}, map[string]interface{}{"is_assign": 0})
-			} else {
-				TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": id2}, map[string]interface{}{"is_assign": 0})
-				TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
-					"clue_id":      id2,
-					"comeintime":   time.Now().Format(date.Date_Full_Layout),
-					"comeinsource": 2,
-				})
-			}
-		}
-	} else if is_assign == 0 {
-		od := TiDb.FindOne("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id2}, "", "")
-		if od != nil && len(*od) > 0 {
-			TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id2})
-		} else {
-			TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
-				"clue_id":      id2,
-				"comeintime":   time.Now().Format(date.Date_Full_Layout),
-				"comeinsource": 2,
-			})
-			TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id2})
-		}
-	} else if is_assign == -1 {
-		TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id2})
-		TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": id2})
-	}
-}
-
-func privateClueSync() {
-	phoneMap := map[int64][]map[string]interface{}{}
-	data := TiDb.SelectBySql(`SELECT * FROM dwd_f_crm_private_sea WHERE clue_id IN (SELECT clue_id FROM dwd_f_crm_private_sea GROUP BY clue_id HAVING COUNT(1) > 1)`)
-	if data != nil && len(*data) > 0 {
-		for _, v := range *data {
-			clue_id := common.Int64All(v["clue_id"])
-			if clue_id > 0 {
-				phoneMap[clue_id] = append(phoneMap[clue_id], v)
-			}
-		}
-	}
-	log.Println(len(phoneMap))
-	for _, v := range phoneMap {
-		if len(v) > 1 {
-			clue_id1 := common.Int64All(v[1]["clue_id"])
-			// seatNumber1 := common.ObjToString(v[1]["seatNumber"])
-			id1 := common.Int64All(v[1]["id"])
-			if clue_id1 > 0 {
-				TiDb.Delete("dwd_f_crm_private_sea", map[string]interface{}{"id": id1})
-			}
-		}
-	}
-}

+ 0 - 615
clueSync/trailContent.go

@@ -1,615 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"log"
-	"regexp"
-
-	"app.yhyue.com/moapp/jybase/mongodb"
-
-	"strings"
-	"time"
-
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/date"
-	"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("dwd_f_crm_personnel_management", map[string]interface{}{"name": name, "resign": 0}, "", "")
-	if saleData != nil && len(*saleData) > 0 {
-		positionId = common.Int64All((*saleData)["position_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
-}
-
-func getSeatNumberPositionId(seatNumber string) (positionId int64) {
-	saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "")
-	if saleData != nil && len(*saleData) > 0 {
-		positionId = common.Int64All((*saleData)["position_id"])
-	}
-	return
-}
-
-func getXlsx() {
-	filePath := "./code1.xlsx"
-	nowTime := time.Now().Format(date.Date_Full_Layout)
-	xlFile, _ := xlsx.OpenFile(filePath)
-	//获取行数
-	// length := len(xlFile.Sheets[0].Rows)
-	//开辟除表头外的行数的数组内存
-	// resourceArr := make([]map[string]interface{}, length-1)
-	//遍历sheet
-	for _, sheet := range xlFile.Sheets {
-		//遍历每一行
-		for rowIndex, row := range sheet.Rows {
-			//跳过第一行表头信息
-			if rowIndex == 0 {
-				continue
-			}
-			company := row.Cells[1].Value
-			name := row.Cells[2].Value
-			position := row.Cells[3].Value
-			phone := row.Cells[4].Value
-			if phone != "" {
-				data := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
-				if data != nil && len(*data) > 0 {
-					isAssign := common.IntAll((*data)["is_assign"])
-					clueId := common.Int64All((*data)["id"])
-					if isAssign == 1 {
-						//在私海
-						TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
-							"is_assign":    1,
-							"comeintime":   nowTime,
-							"updatetime":   nowTime,
-							"top_cluetype": "377",
-							"sub_cluetype": "381",
-						})
-						TiDb.Update("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, map[string]interface{}{
-							"comeintime":   nowTime,
-							"comeinsource": 2,
-							"is_task":      1,
-							"task_time":    nowTime,
-							"tasktime":     nowTime,
-							"taskstatus":   0,
-							"tasksource":   "线索自动分配-批量导入-6月份获取拟建项目清单留资",
-						})
-					} else {
-						//在公海
-						positionId, seatNumber, _, _, _ := autoDraw("C", "", "", 0, 0)
-						TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"is_assign":    1,
-							"comeintime":   nowTime,
-							"updatetime":   nowTime,
-							"trailstatus":  "01",
-							"top_cluetype": "377",
-							"sub_cluetype": "381",
-						})
-						TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
-						TiDb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
-							"clue_id":      clueId,
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"comeintime":   nowTime,
-							"comeinsource": 2,
-							"is_task":      1,
-							"task_time":    nowTime,
-							"tasktime":     nowTime,
-							"taskstatus":   0,
-							"tasksource":   "线索自动分配-批量导入-6月份获取拟建项目清单留资",
-						})
-					}
-				} else {
-					//无线索
-					base := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"phone": phone}, "", "")
-					if base != nil && len(*base) > 0 {
-						uId := common.ObjToString((*base)["uid"])
-						userId := common.ObjToString((*base)["userid"])
-						positionId, seatNumber, _, _, _ := autoDraw("C", "", "", 0, 0)
-						clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-							"userid":       userId,
-							"uid":          uId,
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"is_assign":    1,
-							"comeintime":   nowTime,
-							"createtime":   nowTime,
-							"updatetime":   nowTime,
-							"cluename":     common.If(company != "", company, phone),
-							"top_cluetype": "377",
-							"sub_cluetype": "381",
-							"trailstatus":  "01",
-							"name":         name,
-							"phone":        phone,
-							"position":     position,
-						})
-						if clueId > -1 {
-							TiDb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
-								"clue_id":      clueId,
-								"seatNumber":   seatNumber,
-								"position_id":  positionId,
-								"comeintime":   nowTime,
-								"comeinsource": 2,
-								"is_task":      1,
-								"task_time":    nowTime,
-								"tasktime":     "2023-06-12 10:00:00",
-								"taskstatus":   0,
-								"tasksource":   "线索自动分配-批量导入-6月份获取拟建项目清单留资",
-							})
-						}
-					}
-				}
-			}
-		}
-	}
-}
-
-func getXlsx2() {
-	filePath := "./code2.xlsx"
-	nowTime := time.Now().Format(date.Date_Full_Layout)
-	xlFile, _ := xlsx.OpenFile(filePath)
-	//获取行数
-	// length := len(xlFile.Sheets[0].Rows)
-	//开辟除表头外的行数的数组内存
-	// resourceArr := make([]map[string]interface{}, length-1)
-	//遍历sheet
-	for _, sheet := range xlFile.Sheets {
-		//遍历每一行
-		for rowIndex, row := range sheet.Rows {
-			//跳过第一行表头信息
-			if rowIndex == 0 {
-				continue
-			}
-			userId := row.Cells[0].Value
-			company := row.Cells[5].Value
-			name := row.Cells[1].Value
-			position := row.Cells[6].Value
-			phone := row.Cells[7].Value
-			positionId, seatNumber := int64(2047781), "8040"
-			if phone != "" {
-				data := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"userid": userId}, "", "")
-				if data != nil && len(*data) > 0 {
-					isAssign := common.IntAll((*data)["is_assign"])
-					clueId := common.Int64All((*data)["id"])
-					if isAssign != 1 {
-						//不在私海
-						TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"is_assign":    1,
-							"comeintime":   nowTime,
-							"updatetime":   nowTime,
-							"trailstatus":  "01",
-							"top_cluetype": "377",
-							"sub_cluetype": "382",
-						})
-						TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
-						TiDb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
-							"clue_id":      clueId,
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"comeintime":   nowTime,
-							"comeinsource": 2,
-							"is_task":      1,
-							"task_time":    nowTime,
-							"tasktime":     nowTime,
-							"taskstatus":   0,
-							"tasksource":   "线索自动分配-批量导入-医械厂商线索",
-						})
-					}
-				} else {
-					//无线索
-					base := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"userid": userId}, "", "")
-					if base != nil && len(*base) > 0 {
-						uId := common.ObjToString((*base)["uid"])
-						clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-							"userid":       userId,
-							"uid":          uId,
-							"seatNumber":   seatNumber,
-							"position_id":  positionId,
-							"is_assign":    1,
-							"comeintime":   nowTime,
-							"createtime":   nowTime,
-							"updatetime":   nowTime,
-							"cluename":     common.If(company != "", company, phone),
-							"top_cluetype": "377",
-							"sub_cluetype": "382",
-							"trailstatus":  "01",
-							"name":         name,
-							"phone":        phone,
-							"position":     position,
-						})
-						if clueId > -1 {
-							TiDb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
-								"clue_id":      clueId,
-								"seatNumber":   seatNumber,
-								"position_id":  positionId,
-								"comeintime":   nowTime,
-								"comeinsource": 2,
-								"is_task":      1,
-								"task_time":    nowTime,
-								"tasktime":     "2023-06-12 10:00:00",
-								"taskstatus":   0,
-								"tasksource":   "线索自动分配-批量导入-医械厂商线索",
-							})
-						}
-					}
-				}
-			}
-		}
-	}
-}
-
-func clueInfoSync() {
-	TiDb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
-		for _, v := range *l {
-			id := common.Int64All(v["id"])
-			is_assign := common.IntAll(v["is_assign"])
-			comeintime := common.ObjToString(v["comeintime"])
-			comeintime_open := common.ObjToString(v["comeintime_open"])
-			trail_time, trail_times, next_trail_time := common.ObjToString(v["createtime"]), "", ""
-			tasktime := common.ObjToString(v["tasktime"])
-			task_time := common.ObjToString(v["task_time"])
-			is_task := common.IntAll(v["is_task"])
-			taskstatus := common.IntAll(v["taskstatus"])
-			comeinsource_private := common.IntAll(v["comeinsource_private"])
-			tasksource := common.ObjToString(v["tasksource"])
-			out_task_time := common.ObjToString(v["out_task_time"])
-			out_task_status := common.IntAll(v["out_task_status"])
-			comeinsource_open := common.IntAll(v["comeinsource_open"])
-			level_open := common.IntAll(v["level_open"])
-			clue_level := common.ObjToString(v["clue_level"])
-			var (
-				trail_time_s time.Time
-				comeintime_s time.Time
-			)
-			if trail_time != "" && comeintime != "" {
-				trail_time_s, _ = time.ParseInLocation(date.Date_Full_Layout, trail_time, time.Local)
-				comeintime_s, _ = time.ParseInLocation(date.Date_Full_Layout, comeintime, time.Local)
-				if trail_time_s.Unix() > comeintime_s.Unix() {
-					trail_times = trail_time
-					next_trail_time = common.ObjToString(v["next_time"])
-				}
-			}
-			updateData := map[string]interface{}{
-				"comeintime":      common.If(comeintime != "", comeintime, nil),
-				"comeintime_open": common.If(comeintime_open != "", comeintime_open, nil),
-			}
-			if is_assign == 1 {
-				updateData["trail_time"] = common.If(trail_times != "", trail_times, nil)
-				updateData["next_trail_time"] = common.If(next_trail_time != "", next_trail_time, nil)
-				updateData["is_task"] = is_task
-				updateData["tasktime"] = common.If(tasktime != "", tasktime, nil)
-				updateData["task_time"] = common.If(task_time != "", task_time, nil)
-				updateData["taskstatus"] = taskstatus
-				updateData["comeinsource_private"] = comeinsource_private
-				updateData["tasksource"] = tasksource
-				updateData["out_task_time"] = common.If(out_task_time != "", out_task_time, nil)
-				updateData["out_task_status"] = out_task_status
-			} else if is_assign == 0 {
-				updateData["comeinsource_open"] = comeinsource_open
-				updateData["level_open"] = level_open
-				updateData["clue_level"] = clue_level
-			}
-			ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": id}, updateData)
-			if ok {
-				log.Println("线索表同步成功 ", id)
-			} else {
-				log.Println("线索表同步失败!!! ", id, updateData)
-			}
-		}
-		return true
-	}, `SELECT a.id,a.is_assign,c.comeintime,b.comeintime as comeintime_open,d.createtime,d.next_time,c.tasktime,c.task_time,c.is_task,c.taskstatus,c.comeinsource as comeinsource_private,c.tasksource,c.out_task_time,c.out_task_status,b.comeinsource as comeinsource_open,b.level as level_open,b.clue_level
- 			FROM dwd_f_crm_clue_info a 
-				LEFT JOIN dwd_f_crm_open_sea b ON b.clue_id=a.id 
-				LEFT JOIN dwd_f_crm_private_sea c ON c.clue_id=a.id 
-				LEFT JOIN dwd_f_crm_trail_content d ON d.clue_id=a.id and d.position_id=a.position_id`)
-}
-
-func app_xzcyh_sync() {
-	query := map[string]interface{}{"source": "app_xzcyh"}
-	session := Mgo.GetMgoConn()
-	defer func() {
-		Mgo.DestoryMongoConn(session)
-	}()
-	iter := session.DB(cfg.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
-	thisData := map[string]interface{}{}
-	for {
-		if !iter.Next(&thisData) {
-			break
-		}
-		userId := common.ObjToString(thisData["userid"])
-		keyword := common.ObjArrToStringArr(thisData["keyword"].([]interface{}))
-		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"])
-			}
-		}
-		data := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"userid": userId}, "", "")
-		if data != nil && len(*data) > 0 {
-			business_scope := common.ObjToString((*data)["business_scope"])
-			clueUpdateData := map[string]interface{}{}
-			keywords := ""
-			if len(keyword) > 0 && keyword[0] != "" {
-				keywords = strings.Join(keyword, ",")
-				if business_scope != "" {
-					clueUpdateData["business_scope"] = business_scope + "," + keywords
-				} else {
-					clueUpdateData["business_scope"] = keywords
-				}
-				ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"userid": userId}, clueUpdateData)
-				if ok {
-					log.Println("主营业务修改成功", userId, keywords)
-				} else {
-					log.Println("主营业务修改失败!!!", userId, keywords)
-				}
-			}
-		}
-	}
-}
-
-func lzhSync() {
-	nowTime, count := time.Now().Format("2006-01-02 15:04:05"), 0
-	data := TiDbData.SelectBySql(`SELECT * FROM customer where owner in (2646,8050) and status999 in ("status0","status1","status2","status3")`)
-	if data != nil {
-		for _, v := range *data {
-			count++
-			owner := common.ObjToString(v["owner"])
-			positionId, seatNumber, trailstatus, uId, userId := int64(0), "", "", "", ""
-			if owner == "2646" {
-				positionId = 1205321180
-				seatNumber = "2646"
-			} else {
-				positionId = 1205321184
-				seatNumber = "8050"
-			}
-			phone := common.ObjToString(v["phone"])
-			status := common.ObjToString(v["status999"])
-			cluename := common.ObjToString(v["company"])
-			name := common.ObjToString(v["username"])
-			position := common.ObjToString(v["job"])
-			if status == "status0" {
-				trailstatus = "08"
-			} else if status == "status1" {
-				trailstatus = "07"
-			} else if status == "status2" {
-				trailstatus = "06"
-			} else {
-				trailstatus = "05"
-			}
-			cdata := TiDb.FindOne("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}, "", "")
-			if cdata != nil {
-				uId = common.ObjToString((*cdata)["baseinfo_id"])
-				cluedata := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", "")
-				if cluedata != nil {
-					log.Println("第", count, "条已有线索", phone, uId)
-					seatNumbersss := common.ObjToString((*cluedata)["seatNumber"])
-					if seatNumbersss == "" {
-						TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, map[string]interface{}{
-							"seatNumber":           seatNumber,
-							"position_id":          positionId,
-							"is_assign":            1,
-							"comeintime":           nowTime,
-							"updatetime":           nowTime,
-							"trailstatus":          trailstatus,
-							"is_task":              1,
-							"task_time":            nowTime,
-							"tasktime":             nowTime,
-							"taskstatus":           0,
-							"comeinsource_private": 2,
-						})
-					}
-				} else {
-					udata := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"uid": uId}, "", "")
-					if udata != nil {
-						userId = common.ObjToString((*udata)["userid"])
-						clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-							"userid":               userId,
-							"uid":                  uId,
-							"seatNumber":           seatNumber,
-							"position_id":          positionId,
-							"is_assign":            1,
-							"comeintime":           nowTime,
-							"createtime":           nowTime,
-							"updatetime":           nowTime,
-							"cluename":             cluename,
-							"top_cluetype":         "4",
-							"sub_cluetype":         "154",
-							"trailstatus":          trailstatus,
-							"name":                 name,
-							"phone":                phone,
-							"position":             position,
-							"comeinsource_private": 2,
-							"is_task":              1,
-							"task_time":            nowTime,
-							"tasktime":             nowTime,
-							"taskstatus":           0,
-						})
-						if clueId > 0 {
-							log.Println("第", count, "条保存成功", phone, uId)
-						}
-					}
-				}
-			}
-
-		}
-	}
-}
-
-func piliangfenpeicuowu() {
-	data := TiDb.SelectBySql(`SELECT a.clue_id,a.old_value,b.position_id,b.seat_number FROM dwd_f_crm_clue_change_record a INNER JOIN dwd_f_crm_personnel_management b on b.name = a.old_value where a.position_id = 2222419 and a.createtime > "2024-02-26 00:00:00" and a.change_type = "所属人变更" and a.new_value != "/"`)
-	if data != nil && len(*data) > 0 {
-		for _, v := range *data {
-			clue_id := common.Int64All(v["clue_id"])
-			name := common.ObjToString(v["old_value"])
-			position_id := common.Int64All(v["position_id"])
-			seat_number := common.ObjToString(v["seat_number"])
-			ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": position_id, "seatNumber": seat_number})
-			if ok {
-				log.Println("修改成功 ", clue_id, name)
-			} else {
-				log.Println("修改失败!!! ", clue_id, name, position_id, seat_number)
-			}
-		}
-	}
-}
-
-func pilianggonghaicuowu() {
-	count := 0
-	data := TiDb.SelectBySql(`SELECT id FROM dwd_f_crm_clue_info WHERE comeintime_open >= "2024-03-04 16:46:16" and comeintime_open <= "2024-03-04 16:46:18"`)
-	if data != nil && len(*data) > 0 {
-		log.Println("LEN", len(*data))
-		for _, v := range *data {
-			count++
-			clue_id := common.Int64All(v["id"])
-			log.Println("COUNT ", count, clue_id)
-			sdata := TiDb.SelectBySql(`SELECT a.clue_id,a.old_value,a.new_value,b.position_id,b.seat_number,a.createtime FROM dwd_f_crm_clue_change_record a INNER JOIN dwd_f_crm_personnel_management b on b.name = a.new_value where a.clue_id = ` + fmt.Sprint(clue_id) + ` and a.change_type = "所属人变更" and a.new_value != "/" and a.new_value != "沈炳毅" ORDER BY a.createtime desc`)
-			if sdata != nil && len(*sdata) > 0 {
-				name := common.ObjToString((*sdata)[0]["new_value"])
-				position_id := common.Int64All((*sdata)[0]["position_id"])
-				seat_number := common.ObjToString((*sdata)[0]["seat_number"])
-				ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": position_id, "seatNumber": seat_number, "is_assign": 1})
-				if ok {
-					log.Println("修改成功 ", clue_id, name)
-				} else {
-					log.Println("修改失败!!! ", clue_id, name, position_id, seat_number)
-				}
-			}
-		}
-	}
-}
-
-func userbase_error() {
-	log.Println("userbase_error定时任务开始")
-	sql := `SELECT dfub.uid,dfub.userid,dfub.phone,dfub.source FROM 
-	dwd_f_userbase_baseinfo dfub 
-	LEFT JOIN dwd_f_crm_clue_info dfci ON dfub.uid = dfci.uid 
-	LEFT JOIN dwd_f_userbase_contacts dfuc ON dfub.uid = dfuc.baseinfo_id 
-WHERE 
-	dfci.id IS NULL 
-	AND dfub.phone IS NOT NULL 
-	AND dfub.phone != "" 
-	AND dfub.belong_to NOT LIKE "02%" 
-	AND dfub.belong_to NOT LIKE "03%" 
-	AND dfub.status NOT IN (0,2) 
-	AND dfub.source NOT IN ("0102","0103","0104","0105")`
-	data := TiDb.SelectBySql(sql)
-	if data != nil && *data != nil && len(*data) > 0 {
-		for _, v := range *data {
-			phone := common.ObjToString(v["phone"])
-			uId := common.ObjToString(v["uid"])
-			userId := common.ObjToString(v["userid"])
-			nowTime := time.Now().Format(date.Date_Full_Layout)
-			source := common.ObjToString(v["source"])
-			if phone != "" {
-				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
-				if contactsData == nil || len(*contactsData) == 0 {
-					TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
-						"status":      1,
-						"is_delete":   1,
-						"createtime":  nowTime,
-						"updatetime":  nowTime,
-						"phone":       phone,
-						"baseinfo_id": uId,
-						"SOURCE":      source,
-					})
-				}
-				count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
-				log.Println("userbase uid 线索数量 ", count)
-				if count == 0 {
-					clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
-						"userid":            userId,
-						"uid":               uId,
-						"is_assign":         0,
-						"comeintime":        nowTime,
-						"createtime":        nowTime,
-						"updatetime":        nowTime,
-						"cluename":          phone,
-						"top_cluetype":      "532",
-						"sub_cluetype":      "475",
-						"trailstatus":       "01",
-						"phone":             phone,
-						"comeintime_open":   nowTime,
-						"comeinsource_open": 1,
-					})
-					if clueId > 0 {
-						TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
-							"clue_id":     clueId,
-							"position_id": -1,
-							"change_type": "创建线索",
-							"new_value":   "系统自动创建",
-							"createtime":  nowTime,
-							"BCPCID":      common.GetRandom(32),
-							"operator_id": -1,
-						})
-					}
-				}
-			}
-		}
-	}
-	log.Println("userbase_error定时任务结束")
-}