WH01243 1 жил өмнө
parent
commit
93a9816d85
1 өөрчлөгдсөн 18 нэмэгдсэн , 12 устгасан
  1. 18 12
      clueSync/everything.go

+ 18 - 12
clueSync/everything.go

@@ -366,6 +366,7 @@ func bigCustomer() {
 	if bigOrderTime == "" {
 		bigOrderTime = nowTime
 	}
+	data := FindBatchData("dk")
 	saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": bigSaleTime}}, "createtime", nil, false, -1, -1)
 	if ok && saleleadsData != nil && len(*saleleadsData) > 0 {
 		for _, v := range *saleleadsData {
@@ -380,14 +381,20 @@ func bigCustomer() {
 				}
 			}
 			if sourceMap[sources] != "" {
-				company := common.ObjToString(v["company"])
+				source := sourceMap[sources]
 				phone := common.ObjToString(v["phone"])
+				key := fmt.Sprintf("%s_%s", source, phone)
+				if _, ok := data[key]; ok {
+					continue
+				}
+				data[key] = true
+				company := common.ObjToString(v["company"])
 				job := common.ObjToString(v["position"])
 				username := common.ObjToString(v["name"])
 				email := common.ObjToString(v["mail"])
 				interest := common.ObjToString(v["interest"])
 				data_requirement := common.ObjToString(v["data_requirement"])
-				source := sourceMap[sources]
+
 				belongTo, usernickname := "大客户", ""
 				userData := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"uid": uid}, "", "")
 				if userData != nil {
@@ -397,7 +404,6 @@ func bigCustomer() {
 						continue
 					}
 				}
-
 				dataArr = append(dataArr, map[string]interface{}{
 					"createTime":       nowTime,
 					"lastUpdateTime":   nowTime,
@@ -454,6 +460,11 @@ func bigCustomer() {
 					payorderinfo = "数据流量包" + fmt.Sprint(common.IntAll(v["pay_money"])/100)
 				}
 			}
+			key := fmt.Sprintf("%s_%s", source, phone)
+			if _, ok := data[key]; ok {
+				continue
+			}
+			data[key] = true
 			dataArr = append(dataArr, map[string]interface{}{
 				"createTime":     nowTime,
 				"lastUpdateTime": nowTime,
@@ -475,9 +486,9 @@ func bigCustomer() {
 		cfg.BigOrderTime = bigOrderTime
 	}
 	xlsxArr := []string{"用户昵称", "姓名", "公司名称", "职位", "联系人电话", "购买条数", "用户邮箱", "已支付订单信息", "未支付订单类型", "销售线索来源", "具体来源", "数据需求"}
-	batch := FindBatch("dk")
-	fileName, detailName := time.Now().Format(date.Date_Short_Layout)+"-"+batch+"大客户销售线索", ""
 	if len(dataArr) > 0 {
+		keyContent := fmt.Sprintf("data_%s_%s", time.Now().Format("2006-01-02"), "dk")
+		redis.Put("newother", keyContent, data, 86400)
 		bigData := TiDb.SelectBySql("select * from dwd_f_crm_clue_big_autodraw_record")
 		if bigData != nil && len(*bigData) > 0 {
 			cdata := *bigData
@@ -501,6 +512,8 @@ func bigCustomer() {
 				TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_big_autodraw_record set count = count + 1 where name = ?`, name)
 			}
 			for k, vb := range bigArr {
+				batch := FindBatch("dk")
+				fileName, detailName := time.Now().Format(date.Date_Short_Layout)+"-"+batch+"大客户销售线索", ""
 				xf := xlsx.NewFile()
 				style := xlsx.NewStyle()
 				style.Font.Size = 12
@@ -651,13 +664,6 @@ func marketCustomer() {
 	xlsxArr := []string{"姓名", "联系人电话", "公司名称", "职位", "部门", "销售线索来源", "留资时间"}
 	if len(dataArr) > 0 {
 		//排序:首先按照“联系方式”排序,即同1个用户的留资放在一起,其次按照留资时间正序排序。
-		/*sort.Slice(dataArr, func(i, j int) bool {
-			aa := fmt.Sprintf("%s%s", gconv.String(returnData[i]["zbtime"]),
-				gconv.String(returnData[i]["b_id"]))
-			bb := fmt.Sprintf("%s%s", gconv.String(returnData[j]["zbtime"]),
-				gconv.String(returnData[j]["b_id"]))
-			return aa > bb
-		})*/
 		batch := FindBatch("sc")
 		fileName, detailName := "商务合作销售线索 "+time.Now().Format(date.Date_Short_Layout)+"-"+batch, ""
 		xf := xlsx.NewFile()