|
@@ -1097,14 +1097,15 @@ func AdvisoryCommittee() {
|
|
|
sourceMap := buildSourceMap("咨询组")
|
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
startTime := getCommitteeTime(cfg.AdvisoryCommitteeTime)
|
|
|
- dataArr, abhList := processLeads("zx", startTime, sourceMap, nowTime)
|
|
|
+ dataArr, abhList, endtime := processLeads("zx", startTime, sourceMap, nowTime)
|
|
|
if len(abhList) > 0 {
|
|
|
ABHEmail("advisory", abhList)
|
|
|
}
|
|
|
|
|
|
- cfg.AdvisoryCommitteeTime = startTime
|
|
|
+ cfg.AdvisoryCommitteeTime = endtime
|
|
|
exportToExcel(dataArr, "咨询服务销售线索", "zx")
|
|
|
log.Println("咨询部线索定时任务结束")
|
|
|
+ common.WriteSysConfig(&cfg)
|
|
|
}
|
|
|
|
|
|
// 运营部线索
|
|
@@ -1118,13 +1119,14 @@ func SelectionDepartment() {
|
|
|
sourceMap := buildSourceMap("运营部")
|
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
startTime := getCommitteeTime(cfg.SelectionDepartmentTime)
|
|
|
- dataArr, abhList := processLeads("yy", startTime, sourceMap, nowTime)
|
|
|
+ dataArr, abhList, endtime := processLeads("yy", startTime, sourceMap, nowTime)
|
|
|
if len(abhList) > 0 {
|
|
|
ABHEmail("selection", abhList)
|
|
|
}
|
|
|
- cfg.SelectionDepartmentTime = startTime
|
|
|
+ cfg.SelectionDepartmentTime = endtime
|
|
|
exportToExcel(dataArr, "运营部销售线索", "yy")
|
|
|
log.Println("运营部线索定时任务结束")
|
|
|
+ common.WriteSysConfig(&cfg)
|
|
|
}
|
|
|
|
|
|
// 市场部线索
|
|
@@ -1138,15 +1140,13 @@ func MarketCustomer() {
|
|
|
sourceMap := buildSourceMap("市场组")
|
|
|
nowTime := time.Now().Format(date.Date_Full_Layout)
|
|
|
startTime := getCommitteeTime(cfg.MarketSaleTime)
|
|
|
- dataArr, abhList := processLeads("sc", startTime, sourceMap, nowTime)
|
|
|
-
|
|
|
+ dataArr, abhList, endtime := processLeads("sc", startTime, sourceMap, nowTime)
|
|
|
if len(abhList) > 0 {
|
|
|
ABHEmail("market", abhList)
|
|
|
}
|
|
|
-
|
|
|
- cfg.MarketSaleTime = startTime
|
|
|
+ cfg.MarketSaleTime = endtime
|
|
|
exportToExcel(dataArr, "商务合作销售线索", "sc")
|
|
|
-
|
|
|
+ common.WriteSysConfig(&cfg)
|
|
|
log.Println("市场部线索定时任务结束")
|
|
|
}
|
|
|
|
|
@@ -1188,14 +1188,17 @@ func getCommitteeTime(cfgTime int64) int64 {
|
|
|
}
|
|
|
|
|
|
// 处理线索
|
|
|
-func processLeads(batch string, committeeTime int64, sourceMap map[string]string, nowTime string) ([]map[string]interface{}, []map[string]interface{}) {
|
|
|
+func processLeads(batch string, committeeTime int64, sourceMap map[string]string, nowTime string) ([]map[string]interface{}, []map[string]interface{}, int64) {
|
|
|
dataArr := []map[string]interface{}{}
|
|
|
abhList := []map[string]interface{}{}
|
|
|
+ endtime := int64(0)
|
|
|
saleleadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"createtime": map[string]interface{}{"$gte": committeeTime}}, `{"phone":1,"createtime":1}`, nil, false, -1, -1)
|
|
|
if ok && saleleadsData != nil {
|
|
|
data := FindBatchData(batch)
|
|
|
for _, v := range *saleleadsData {
|
|
|
- if lead := processLead(v, sourceMap, nowTime, committeeTime, data); lead != nil {
|
|
|
+ lead := map[string]interface{}{}
|
|
|
+ lead, endtime = processLead(v, sourceMap, nowTime, committeeTime, data)
|
|
|
+ if lead != nil {
|
|
|
if isABHLead(lead) {
|
|
|
abhList = append(abhList, lead)
|
|
|
} else {
|
|
@@ -1206,35 +1209,34 @@ func processLeads(batch string, committeeTime int64, sourceMap map[string]string
|
|
|
saveDataToRedis(data, batch)
|
|
|
}
|
|
|
|
|
|
- return dataArr, abhList
|
|
|
+ return dataArr, abhList, endtime
|
|
|
}
|
|
|
|
|
|
// 处理单个线索
|
|
|
-func processLead(v map[string]interface{}, sourceMap map[string]string, nowTime string, committeeTime int64, data map[string]interface{}) map[string]interface{} {
|
|
|
+func processLead(v map[string]interface{}, sourceMap map[string]string, nowTime string, committeeTime int64, data map[string]interface{}) (map[string]interface{}, int64) {
|
|
|
sources := common.ObjToString(v["source"])
|
|
|
+ // 更新委员会时间
|
|
|
+ if gconv.Int64(v["createtime"]) > committeeTime {
|
|
|
+ committeeTime = gconv.Int64(v["createtime"])
|
|
|
+ }
|
|
|
if sourceMap[sources] == "" {
|
|
|
- return nil
|
|
|
+ return nil, committeeTime
|
|
|
}
|
|
|
phone := common.ObjToString(v["phone"])
|
|
|
if IsInternal(phone) {
|
|
|
- return nil
|
|
|
+ return nil, committeeTime
|
|
|
}
|
|
|
// 获取用户信息
|
|
|
userData := getUserData(v)
|
|
|
if userData == nil || isUserInBlackList(userData) {
|
|
|
- return nil
|
|
|
+ return nil, committeeTime
|
|
|
}
|
|
|
key := fmt.Sprintf("%s_%s_%s", sourceMap[sources], phone, common.ObjToString(v["interest"]))
|
|
|
if _, exists := data[key]; exists {
|
|
|
- return nil
|
|
|
+ return nil, committeeTime
|
|
|
}
|
|
|
data[key] = true
|
|
|
|
|
|
- // 更新委员会时间
|
|
|
- if gconv.Int64(v["createtime"]) > committeeTime {
|
|
|
- committeeTime = gconv.Int64(v["createtime"])
|
|
|
- }
|
|
|
-
|
|
|
return map[string]interface{}{
|
|
|
"createTime": nowTime,
|
|
|
"createtime": v["createtime"],
|
|
@@ -1248,7 +1250,7 @@ func processLead(v map[string]interface{}, sourceMap map[string]string, nowTime
|
|
|
"branch": v["branch"],
|
|
|
"job": v["position"],
|
|
|
"email": common.ObjToString(v["mail"]),
|
|
|
- }
|
|
|
+ }, committeeTime
|
|
|
}
|
|
|
|
|
|
// 获取用户数据
|