|
@@ -7,6 +7,8 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
@@ -42,38 +44,105 @@ func orders() {
|
|
|
|
|
|
// 新注册用户 5分钟一次
|
|
// 新注册用户 5分钟一次
|
|
func users() {
|
|
func users() {
|
|
|
|
+ //判断节假日
|
|
|
|
+ currentTime, runOk := time.Now(), false
|
|
|
|
+ if currentTime.Weekday() == time.Sunday || currentTime.Weekday() == time.Saturday {
|
|
|
|
+ isok := false
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 2 {
|
|
|
|
+ isok = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ runOk = true
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ isok := true
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 1 {
|
|
|
|
+ isok = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ runOk = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !runOk {
|
|
|
|
+ log.Println("不是工作日,任务暂停")
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ if currentTime.Hour() == 17 && currentTime.Minute() > 30 {
|
|
|
|
+ log.Println("不是工作日,任务暂停")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//新用户注册后5分钟内进入线索 C
|
|
//新用户注册后5分钟内进入线索 C
|
|
log.Println("新注册用户定时任务开始")
|
|
log.Println("新注册用户定时任务开始")
|
|
- session := Mgo.GetMgoConn()
|
|
|
|
- defer func() {
|
|
|
|
- Mgo.DestoryMongoConn(session)
|
|
|
|
- }()
|
|
|
|
- query := map[string]interface{}{}
|
|
|
|
- if cfg.LastUserId != "" {
|
|
|
|
- query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(cfg.LastUserId)}
|
|
|
|
|
|
+ selectTimeEnd := time.Unix(time.Now().Unix()-300, 0).Format("2006-01-02 15:04:05")
|
|
|
|
+ sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where createtime > "%s" and source = 1`, selectTimeEnd)
|
|
|
|
+ data := TiDb.SelectBySql(sql)
|
|
|
|
+ if data != nil && *data != nil && len(*data) > 0 {
|
|
|
|
+ for _, v := range *data {
|
|
|
|
+ FormatData(v, "users")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- // query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId("6145587145042f9c6444d02c")}
|
|
|
|
- log.Println("query :", query)
|
|
|
|
- iter := session.DB(cfg.Mgo.DbName).C("user").Find(&query).Sort("_id").Iter()
|
|
|
|
- thisData := map[string]interface{}{}
|
|
|
|
|
|
+ log.Println("新注册用户定时任务结束")
|
|
|
|
+}
|
|
|
|
|
|
- for {
|
|
|
|
- if !iter.Next(&thisData) {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- ok1, _ := FormatData(thisData, "users")
|
|
|
|
- if !ok1 {
|
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
|
- break
|
|
|
|
|
|
+func userbase() {
|
|
|
|
+ log.Println("userbase定时任务开始")
|
|
|
|
+ selectTimeEnd := time.Unix(time.Now().Unix()-1800, 0).Format("2006-01-02 15:04:05")
|
|
|
|
+ sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s"`, selectTimeEnd)
|
|
|
|
+ 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"])
|
|
|
|
+ if phone != "" {
|
|
|
|
+ contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1 and status != 0", uid)
|
|
|
|
+ if contactsData == nil || len(*contactsData) == 0 {
|
|
|
|
+ FormatData(v, "users")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- cfg.LastUserId = mongodb.BsonIdToSId(thisData["_id"])
|
|
|
|
}
|
|
}
|
|
- common.WriteSysConfig(&cfg)
|
|
|
|
- log.Println("新注册用户定时任务结束")
|
|
|
|
|
|
+ log.Println("userbase定时任务结束")
|
|
}
|
|
}
|
|
|
|
|
|
// 留资 5分钟一次
|
|
// 留资 5分钟一次
|
|
func saleLeads() {
|
|
func saleLeads() {
|
|
|
|
+ //判断节假日
|
|
|
|
+ currentTime, runOk := time.Now(), false
|
|
|
|
+ if currentTime.Weekday() == time.Sunday || currentTime.Weekday() == time.Saturday {
|
|
|
|
+ isok := false
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 2 {
|
|
|
|
+ isok = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ runOk = true
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ isok := true
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 1 {
|
|
|
|
+ isok = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ runOk = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !runOk {
|
|
|
|
+ log.Println("不是工作日,任务暂停")
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ if currentTime.Hour() == 17 && currentTime.Minute() > 30 {
|
|
|
|
+ log.Println("不是工作日,任务暂停")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//留资后5分钟内进入线索
|
|
//留资后5分钟内进入线索
|
|
//分为免费留资和付费留资 付费B 免费C
|
|
//分为免费留资和付费留资 付费B 免费C
|
|
log.Println("用户留资定时任务开始")
|
|
log.Println("用户留资定时任务开始")
|
|
@@ -130,18 +199,28 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
cluename = common.ObjToString(data["company_name"])
|
|
cluename = common.ObjToString(data["company_name"])
|
|
phone = common.ObjToString(data["user_phone"])
|
|
phone = common.ObjToString(data["user_phone"])
|
|
} else if item == "users" {
|
|
} else if item == "users" {
|
|
- userId = mongodb.BsonIdToSId(data["_id"])
|
|
|
|
|
|
+ userId = mongodb.BsonIdToSId(data["userid"])
|
|
//新用户没有uid、source要等5分钟
|
|
//新用户没有uid、source要等5分钟
|
|
- query["userid"] = userId
|
|
|
|
- userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
|
- if userInfo != nil && len(*userInfo) > 0 {
|
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
|
- source = common.IntAll((*userInfo)["source"])
|
|
|
|
- }
|
|
|
|
- cluename = common.ObjToString(data["s_company"])
|
|
|
|
- phone = common.ObjToString(data["s_phone"])
|
|
|
|
- if phone == "" {
|
|
|
|
- phone = common.ObjToString(data["s_m_phone"])
|
|
|
|
|
|
+ cluename = common.ObjToString(data["company_name"])
|
|
|
|
+ phone = common.ObjToString(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"])
|
|
|
|
+ query["uid"] = uId
|
|
|
|
+ } else {
|
|
|
|
+ query["userid"] = userId
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ query["userid"] = userId
|
|
|
|
+ }
|
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
|
+ uId = common.ObjToString((*userInfo)["uid"])
|
|
|
|
+ source = common.IntAll((*userInfo)["source"])
|
|
|
|
+ userId = common.ObjToString((*userInfo)["userid"])
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if item == "saleLeads" {
|
|
} else if item == "saleLeads" {
|
|
userId = common.ObjToString(data["userid"])
|
|
userId = common.ObjToString(data["userid"])
|
|
@@ -161,7 +240,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
position = common.ObjToString(data["position"])
|
|
position = common.ObjToString(data["position"])
|
|
name = common.ObjToString(data["name"])
|
|
name = common.ObjToString(data["name"])
|
|
// sourceCode = common.ObjToString(data["source"])
|
|
// sourceCode = common.ObjToString(data["source"])
|
|
- contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1 and status != 0", phone)
|
|
|
|
|
|
+ contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
|
|
if contactsData != nil && len(*contactsData) > 0 {
|
|
if contactsData != nil && len(*contactsData) > 0 {
|
|
if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
|
|
uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
|
|
@@ -191,7 +270,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
if uId == "" {
|
|
if uId == "" {
|
|
if isExists, _ := redis.Exists("bidx", "bidx_userId_"+userId); isExists {
|
|
if isExists, _ := redis.Exists("bidx", "bidx_userId_"+userId); isExists {
|
|
redisInt := redis.GetInt("bidx", "bidx_userId_"+userId)
|
|
redisInt := redis.GetInt("bidx", "bidx_userId_"+userId)
|
|
- if redisInt > 1 {
|
|
|
|
|
|
+ if redisInt > 4 {
|
|
log.Println("线索分配失败,线索缺少信息,任务已执行超过1次", item, userId, phone)
|
|
log.Println("线索分配失败,线索缺少信息,任务已执行超过1次", item, userId, phone)
|
|
return true, true
|
|
return true, true
|
|
} else {
|
|
} else {
|
|
@@ -233,17 +312,17 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
position_id, seatNumber, saleName, saleData := autoDraw(level)
|
|
position_id, seatNumber, saleName, saleData := autoDraw(level)
|
|
log.Println("data -------", position_id, seatNumber, saleName)
|
|
log.Println("data -------", position_id, seatNumber, saleName)
|
|
if position_id > 0 && seatNumber != "" {
|
|
if position_id > 0 && seatNumber != "" {
|
|
- if TiDb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": position_id}) >= cfg.CountLimit {
|
|
|
|
- log.Println("线索分配失败,私海线索数据超过限制", item, position_id, seatNumber, uId, userId, phone)
|
|
|
|
- TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
|
|
|
|
- return false, false
|
|
|
|
- // position_id, seatNumber, saleName, saleData = autoDraw(level)
|
|
|
|
- }
|
|
|
|
|
|
+ // if TiDb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": position_id}) >= cfg.CountLimit {
|
|
|
|
+ // log.Println("线索分配失败,私海线索数据超过限制", item, position_id, seatNumber, uId, userId, phone)
|
|
|
|
+ // TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
|
|
|
|
+ // return false, false
|
|
|
|
+ // // position_id, seatNumber, saleName, saleData = autoDraw(level)
|
|
|
|
+ // }
|
|
uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true
|
|
uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true
|
|
if uCount != nil && len(*uCount) > 0 {
|
|
if uCount != nil && len(*uCount) > 0 {
|
|
- oks = UpdateClue(*uCount, saleData, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id)
|
|
|
|
|
|
+ oks = UpdateClue(*uCount, saleData, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id, source)
|
|
} else {
|
|
} else {
|
|
- oks = SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id)
|
|
|
|
|
|
+ oks = SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber, position_id, source)
|
|
}
|
|
}
|
|
if oks {
|
|
if oks {
|
|
TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
|
|
TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
|
|
@@ -255,7 +334,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
return true, true
|
|
return true, true
|
|
}
|
|
}
|
|
|
|
|
|
-func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) bool {
|
|
|
|
|
|
+func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64, source int) bool {
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
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")
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
@@ -340,6 +419,17 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1
|
|
return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1
|
|
}) {
|
|
}) {
|
|
log.Println("线索分配成功")
|
|
log.Println("线索分配成功")
|
|
|
|
+ if TiDb.Count("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}) == 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,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
return true
|
|
return true
|
|
} else {
|
|
} else {
|
|
log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
|
|
log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
|
|
@@ -347,7 +437,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func UpdateClue(data map[string]interface{}, saleData []map[string]interface{}, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64) bool {
|
|
|
|
|
|
+func UpdateClue(data map[string]interface{}, saleData []map[string]interface{}, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, industry, follow_project_area, role, seatNumber string, positionId int64, source int) bool {
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
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")
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
//trailstatus = 无意向 为变更线索状态
|
|
//trailstatus = 无意向 为变更线索状态
|
|
@@ -356,7 +446,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
clueId := common.Int64All(data["id"])
|
|
clueId := common.Int64All(data["id"])
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
- old_position_id, old_seatNumber, old_trailstatus := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"]), common.ObjToString(data["trailstatus"])
|
|
|
|
|
|
+ old_position_id, old_seatNumber := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"])
|
|
//已在任务车的判断任务时间
|
|
//已在任务车的判断任务时间
|
|
privateData := TiDb.FindOne("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
privateData := TiDb.FindOne("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
if privateData != nil && len(*privateData) > 0 {
|
|
if privateData != nil && len(*privateData) > 0 {
|
|
@@ -378,7 +468,38 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //加入任务车判断节假日
|
|
|
|
+ count, counts, t := 0, 0, time.Now()
|
|
|
|
+ for {
|
|
|
|
+ count++
|
|
|
|
+ currentTime := t.AddDate(0, 0, -count)
|
|
|
|
+ if currentTime.Weekday() == time.Sunday || currentTime.Weekday() == time.Saturday {
|
|
|
|
+ isok := false
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 2 {
|
|
|
|
+ isok = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ counts++
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ isok := true
|
|
|
|
+ for k, v := range DateMap {
|
|
|
|
+ if currentTime.Format(date.Date_Short_Layout) == k && v == 1 {
|
|
|
|
+ isok = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isok {
|
|
|
|
+ counts++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if counts >= 2 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ recordCount := TiDb.CountBySql(`select count(1) from dwd_f_crm_trail_content where clue_id = ? and createtime > ?`, clueId, t.AddDate(0, 0, -count).Format(date.Date_Full_Layout))
|
|
|
|
+ //
|
|
clueUpdateData := map[string]interface{}{
|
|
clueUpdateData := map[string]interface{}{
|
|
"is_assign": 1,
|
|
"is_assign": 1,
|
|
"updatetime": nowTime,
|
|
"updatetime": nowTime,
|
|
@@ -388,10 +509,6 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
}
|
|
}
|
|
seaUpdateData := map[string]interface{}{
|
|
seaUpdateData := map[string]interface{}{
|
|
"comeinsource": 2,
|
|
"comeinsource": 2,
|
|
- "is_task": 1,
|
|
|
|
- "task_time": nowTime,
|
|
|
|
- "tasktime": taskTime,
|
|
|
|
- "taskstatus": 0,
|
|
|
|
"tasksource": "线索来源自动更新" + "-" + topname + "-" + subname,
|
|
"tasksource": "线索来源自动更新" + "-" + topname + "-" + subname,
|
|
}
|
|
}
|
|
insertSeaData := map[string]interface{}{
|
|
insertSeaData := map[string]interface{}{
|
|
@@ -413,12 +530,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
clueUpdateData["role"] = role
|
|
clueUpdateData["role"] = role
|
|
clueUpdateData["cluename"] = cluename
|
|
clueUpdateData["cluename"] = cluename
|
|
}
|
|
}
|
|
- if trailstatus == "00" || trailstatus == "01" || old_position_id == 0 {
|
|
|
|
|
|
+ if trailstatus == "00" || old_position_id == 0 || is_assign != 1 {
|
|
clueUpdateData["seatNumber"] = seatNumber
|
|
clueUpdateData["seatNumber"] = seatNumber
|
|
clueUpdateData["position_id"] = positionId
|
|
clueUpdateData["position_id"] = positionId
|
|
- if trailstatus == "00" || trailstatus == "01" {
|
|
|
|
- clueUpdateData["trailstatus"] = "01"
|
|
|
|
- }
|
|
|
|
|
|
+ clueUpdateData["comeintime"] = nowTime
|
|
seaUpdateData["seatNumber"] = seatNumber
|
|
seaUpdateData["seatNumber"] = seatNumber
|
|
seaUpdateData["position_id"] = positionId
|
|
seaUpdateData["position_id"] = positionId
|
|
seaUpdateData["comeintime"] = nowTime
|
|
seaUpdateData["comeintime"] = nowTime
|
|
@@ -433,6 +548,15 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
insertSeaData["seatNumber"] = old_seatNumber
|
|
insertSeaData["seatNumber"] = old_seatNumber
|
|
insertSeaData["position_id"] = old_position_id
|
|
insertSeaData["position_id"] = old_position_id
|
|
}
|
|
}
|
|
|
|
+ if trailstatus != "08" {
|
|
|
|
+ clueUpdateData["trailstatus"] = "01"
|
|
|
|
+ }
|
|
|
|
+ if (trailstatus != "08" && recordCount <= 0) || is_assign == 0 {
|
|
|
|
+ seaUpdateData["is_task"] = 1
|
|
|
|
+ seaUpdateData["task_time"] = nowTime
|
|
|
|
+ seaUpdateData["tasktime"] = taskTime
|
|
|
|
+ seaUpdateData["taskstatus"] = 0
|
|
|
|
+ }
|
|
ok, ok1, ok2, seaId := true, true, true, int64(0)
|
|
ok, ok1, ok2, seaId := true, true, true, int64(0)
|
|
updateId1, updateId2, updateId3, updateId4, updateId5 := int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
updateId1, updateId2, updateId3, updateId4, updateId5 := int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
updateId6, updateId7, updateId8, updateId9, updateId10 := int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
updateId6, updateId7, updateId8, updateId9, updateId10 := int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
@@ -447,7 +571,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
|
|
seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
|
|
}
|
|
}
|
|
//变更记录
|
|
//变更记录
|
|
- if trailstatus == "00" || trailstatus == "01" || old_position_id == 0 {
|
|
|
|
|
|
+ if (trailstatus == "00" || old_position_id == 0) && is_assign == 1 {
|
|
updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": positionId,
|
|
"position_id": positionId,
|
|
@@ -499,7 +623,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"position_id": positionId,
|
|
"position_id": positionId,
|
|
"change_field": "trailstatus",
|
|
"change_field": "trailstatus",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
- "old_value": CodeTrail[old_trailstatus],
|
|
|
|
|
|
+ "old_value": CodeTrail[trailstatus],
|
|
"new_value": "新增",
|
|
"new_value": "新增",
|
|
"createtime": nowTime,
|
|
"createtime": nowTime,
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -531,16 +655,54 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ } else if trailstatus != "08" && is_assign == 0 {
|
|
|
|
+ updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "所属人变更",
|
|
|
|
+ "old_value": common.If(oldsaleName != "", oldsaleName, "/"),
|
|
|
|
+ "new_value": common.If(saleName != "", saleName, "/"),
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ if trailstatus != "01" {
|
|
|
|
+ updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "商机线索",
|
|
|
|
+ "new_value": "新增",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ updateId4 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": CodeTrail[trailstatus],
|
|
|
|
+ "new_value": "商机线索",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if trailstatus != "08" && recordCount <= 0 {
|
|
|
|
+ updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": common.If(trailstatus == "00", positionId, common.Int64All(data["position_id"])),
|
|
|
|
+ "change_type": "加入任务车",
|
|
|
|
+ "new_value": "线索来源自动更新" + "-" + topname + "-" + subname,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
- "clue_id": clueId,
|
|
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
- "change_type": "加入任务车",
|
|
|
|
- "new_value": "线索来源自动更新" + "-" + topname + "-" + subname,
|
|
|
|
- "createtime": nowTime,
|
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
|
- "operator_id": -1,
|
|
|
|
- })
|
|
|
|
BCPCID := common.GetRandom(32)
|
|
BCPCID := common.GetRandom(32)
|
|
old_name := common.ObjToString(data["name"])
|
|
old_name := common.ObjToString(data["name"])
|
|
old_position := common.ObjToString(data["position"])
|
|
old_position := common.ObjToString(data["position"])
|
|
@@ -564,10 +726,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if item != "orders" {
|
|
if item != "orders" {
|
|
- if old_name != name {
|
|
|
|
|
|
+ if old_name != name && name != "" {
|
|
updateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "name",
|
|
"change_field": "name",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_name != "", old_name, "/"),
|
|
"old_value": common.If(old_name != "", old_name, "/"),
|
|
@@ -577,10 +739,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if old_position != position {
|
|
|
|
|
|
+ if old_position != position && position != "" {
|
|
updateId7 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId7 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "position",
|
|
"change_field": "position",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_position != "", old_position, "/"),
|
|
"old_value": common.If(old_position != "", old_position, "/"),
|
|
@@ -590,10 +752,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if old_department != department {
|
|
|
|
|
|
+ if old_department != department && department != "" {
|
|
updateId8 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId8 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "department",
|
|
"change_field": "department",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_department != "", old_department, "/"),
|
|
"old_value": common.If(old_department != "", old_department, "/"),
|
|
@@ -603,10 +765,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if old_role != role {
|
|
|
|
|
|
+ if old_role != role && role != "" {
|
|
updateId9 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId9 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "role",
|
|
"change_field": "role",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_role != "", old_role, "/"),
|
|
"old_value": common.If(old_role != "", old_role, "/"),
|
|
@@ -629,7 +791,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
new_area = strings.Join(new_area_arr, ",")
|
|
new_area = strings.Join(new_area_arr, ",")
|
|
updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "follow_project_area",
|
|
"change_field": "follow_project_area",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_area != "", old_area, "/"),
|
|
"old_value": common.If(old_area != "", old_area, "/"),
|
|
@@ -639,10 +801,10 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if old_cluename != cluename {
|
|
|
|
|
|
+ if old_cluename != cluename && cluename != "" {
|
|
updateId11 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId11 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "cluename",
|
|
"change_field": "cluename",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_cluename != "", old_cluename, "/"),
|
|
"old_value": common.If(old_cluename != "", old_cluename, "/"),
|
|
@@ -656,7 +818,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
if old_top_cluetype != top_cluetype {
|
|
if old_top_cluetype != top_cluetype {
|
|
updateId12 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId12 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "top_cluetype",
|
|
"change_field": "top_cluetype",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_topname != "", old_topname, "/"),
|
|
"old_value": common.If(old_topname != "", old_topname, "/"),
|
|
@@ -669,7 +831,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
if old_sub_cluetype != sub_cluetype {
|
|
if old_sub_cluetype != sub_cluetype {
|
|
updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
- "position_id": common.If(trailstatus == "00" || trailstatus == "01", positionId, common.Int64All(data["position_id"])),
|
|
|
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
"change_field": "sub_cluetype",
|
|
"change_field": "sub_cluetype",
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
@@ -690,6 +852,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
"updatetime": nowTime,
|
|
"updatetime": nowTime,
|
|
"phone": phone,
|
|
"phone": phone,
|
|
"baseinfo_id": uId,
|
|
"baseinfo_id": uId,
|
|
|
|
+ "SOURCE": source,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
return true
|
|
return true
|