|
@@ -17,7 +17,7 @@ import (
|
|
|
)
|
|
|
|
|
|
func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
- userId, uId, positionId, source, cluename, phone, sourceCode, keyword, s_sourceid := common.ObjToString(data["user_id"]), "", "", "", "", "", "", []string{}, ""
|
|
|
+ userId, uId, positionId, source, cluename, phone, sourceCode, keyword, _ := gconv.String(data["user_id"]), "", "", "", "", "", "", []string{}, ""
|
|
|
role, industry, department, departments, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", "", ""
|
|
|
query, topname, subname, belong_to, sourceName, remark, sourceId := map[string]interface{}{}, "", "", "01", "", "", int64(0)
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
@@ -26,35 +26,35 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
positionId = userId
|
|
|
userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userId}, "", "")
|
|
|
if userMapping != nil && len(*userMapping) > 0 {
|
|
|
- userId = common.ObjToString((*userMapping)["userid"])
|
|
|
+ userId = gconv.String((*userMapping)["userid"])
|
|
|
}
|
|
|
}
|
|
|
query["userid"] = userId
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"]) //用户来源
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"]) //用户归属
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"]) //用户来源
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
|
|
|
}
|
|
|
- cluename = common.ObjToString(data["company_name"])
|
|
|
- phone = common.ObjToString(data["user_phone"])
|
|
|
+ cluename = gconv.String(data["company_name"])
|
|
|
+ phone = gconv.String(data["user_phone"])
|
|
|
} else if item == "message" {
|
|
|
userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"base_user_id": common.Int64All(data["own_id"])}, "", "")
|
|
|
if userMapping != nil && len(*userMapping) > 0 {
|
|
|
- userId = common.ObjToString((*userMapping)["userid"])
|
|
|
+ userId = gconv.String((*userMapping)["userid"])
|
|
|
positionId = fmt.Sprint((*userMapping)["position_id"])
|
|
|
}
|
|
|
query["userid"] = userId
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
- phone = common.ObjToString((*userInfo)["phone"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
+ phone = gconv.String((*userInfo)["phone"])
|
|
|
if phone != "" {
|
|
|
phoneMapping := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if phoneMapping != nil && len(*phoneMapping) > 0 {
|
|
|
- cluename = common.ObjToString((*phoneMapping)["cluename"])
|
|
|
+ cluename = gconv.String((*phoneMapping)["cluename"])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -66,13 +66,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
}
|
|
|
userId = mongodb.BsonIdToSId(data["userid"])
|
|
|
//新用户没有uid、source要等5分钟
|
|
|
- cluename = common.ObjToString(data["company_name"])
|
|
|
- phone = common.ObjToString(data["phone"])
|
|
|
+ cluename = gconv.String(data["company_name"])
|
|
|
+ phone = gconv.String(data["phone"])
|
|
|
if phone != "" {
|
|
|
contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
|
|
|
if contactsData != nil && len(*contactsData) > 0 {
|
|
|
- if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
- uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
|
|
|
+ if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
+ uId = gconv.String((*contactsData)[0]["baseinfo_id"])
|
|
|
query["uid"] = uId
|
|
|
} else {
|
|
|
query["userid"] = userId
|
|
@@ -83,14 +83,14 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
//createtimeStr := ""
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
- s_sourceid = common.ObjToString((*userInfo)["s_sourceid"])
|
|
|
- //createtimeStr = common.ObjToString((*userInfo)["l_registedate"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
+ //s_sourceid = gconv.String((*userInfo)["s_sourceid"])
|
|
|
+ //createtimeStr = gconv.String((*userInfo)["l_registedate"])
|
|
|
}
|
|
|
if item == "xcxusers" {
|
|
|
- sourceCode = common.ObjToString(data["industry"])
|
|
|
+ sourceCode = gconv.String(data["industry"])
|
|
|
//t, _ := time.Parse("2006-01-02 15:04:05", createtimeStr)
|
|
|
if sourceCode == "" {
|
|
|
log.Println("留资没有source", phone)
|
|
@@ -116,44 +116,44 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
"userid": userId,
|
|
|
}, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- phone = common.ObjToString((*userInfo)["phone"])
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
+ phone = gconv.String((*userInfo)["phone"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
}
|
|
|
} else if item == "saleLeads" { //留资
|
|
|
//线索名称打印
|
|
|
- log.Println(1111, common.ObjToString(data["company"]))
|
|
|
- userId = common.ObjToString(data["userid"])
|
|
|
+ log.Println(1111, gconv.String(data["company"]))
|
|
|
+ userId = gconv.String(data["userid"])
|
|
|
if !mongodb.IsObjectIdHex(userId) {
|
|
|
positionId = userId
|
|
|
userMapping := TiDb.FindOne("dwd_f_userbase_id_mapping", map[string]interface{}{"position_id": userId}, "", "")
|
|
|
if userMapping != nil && len(*userMapping) > 0 {
|
|
|
- userId = common.ObjToString((*userMapping)["userid"])
|
|
|
- }
|
|
|
- }
|
|
|
- cluename = common.ObjToString(data["company"])
|
|
|
- phone = common.ObjToString(data["phone"])
|
|
|
- role = common.ObjToString(data["companyType"])
|
|
|
- industry = common.ObjToString(data["industry"])
|
|
|
- department = common.ObjToString(data["branch"])
|
|
|
- departments = common.ObjToString(data["department"])
|
|
|
- position = common.ObjToString(data["position"])
|
|
|
- name = common.ObjToString(data["name"])
|
|
|
- sourceCode = common.ObjToString(data["source"])
|
|
|
+ userId = gconv.String((*userMapping)["userid"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cluename = gconv.String(data["company"])
|
|
|
+ phone = gconv.String(data["phone"])
|
|
|
+ role = gconv.String(data["companyType"])
|
|
|
+ industry = gconv.String(data["industry"])
|
|
|
+ department = gconv.String(data["branch"])
|
|
|
+ departments = gconv.String(data["department"])
|
|
|
+ position = gconv.String(data["position"])
|
|
|
+ name = gconv.String(data["name"])
|
|
|
+ sourceCode = gconv.String(data["source"])
|
|
|
if sourceCode == "" {
|
|
|
log.Println("留资没有source", phone)
|
|
|
return true, true, true
|
|
|
}
|
|
|
- remark = common.ObjToString(data["jyRemark"]) //荟聚线索备注
|
|
|
+ remark = gconv.String(data["jyRemark"]) //荟聚线索备注
|
|
|
keywordArr := data["keyword"]
|
|
|
if keywordArr != nil {
|
|
|
keyword = common.ObjArrToStringArr(data["keyword"].([]interface{}))
|
|
|
}
|
|
|
contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
|
|
|
if contactsData != nil && len(*contactsData) > 0 {
|
|
|
- if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
- uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
|
|
|
+ if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
+ uId = gconv.String((*contactsData)[0]["baseinfo_id"])
|
|
|
query["uid"] = uId
|
|
|
} else {
|
|
|
query["userid"] = userId
|
|
@@ -164,11 +164,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
if userId != "" || uId != "" {
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
- userId = common.ObjToString((*userInfo)["userid"])
|
|
|
- s_sourceid = common.ObjToString((*userInfo)["s_sourceid"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
+ userId = gconv.String((*userInfo)["userid"])
|
|
|
+ //s_sourceid = gconv.String((*userInfo)["s_sourceid"])
|
|
|
}
|
|
|
} else {
|
|
|
if sourceCode == "report_retention" || sourceCode == "marketing_retention" { //荟聚线索来源,不是剑鱼用户,需要等待用户归集
|
|
@@ -180,20 +180,20 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
}
|
|
|
}
|
|
|
} else if item == "eventReg" { //渠道
|
|
|
- userId = common.ObjToString(data["userid"])
|
|
|
- cluename = common.ObjToString(data["company"])
|
|
|
- phone = common.ObjToString(data["sign_phone"])
|
|
|
- role = common.ObjToString(data["company_type"])
|
|
|
- department = common.ObjToString(data["branch"])
|
|
|
- position = common.ObjToString(data["position"])
|
|
|
- name = common.ObjToString(data["sign_name"])
|
|
|
- sourceCode = common.ObjToString(data["source_code"])
|
|
|
- sourceName = common.ObjToString(data["source_name"])
|
|
|
+ userId = gconv.String(data["userid"])
|
|
|
+ cluename = gconv.String(data["company"])
|
|
|
+ phone = gconv.String(data["sign_phone"])
|
|
|
+ role = gconv.String(data["company_type"])
|
|
|
+ department = gconv.String(data["branch"])
|
|
|
+ position = gconv.String(data["position"])
|
|
|
+ name = gconv.String(data["sign_name"])
|
|
|
+ sourceCode = gconv.String(data["source_code"])
|
|
|
+ sourceName = gconv.String(data["source_name"])
|
|
|
log.Println(sourceName)
|
|
|
contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
|
|
|
if contactsData != nil && len(*contactsData) > 0 {
|
|
|
- if common.ObjToString((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
- uId = common.ObjToString((*contactsData)[0]["baseinfo_id"])
|
|
|
+ if gconv.String((*contactsData)[0]["baseinfo_id"]) != "" {
|
|
|
+ uId = gconv.String((*contactsData)[0]["baseinfo_id"])
|
|
|
query["uid"] = uId
|
|
|
} else {
|
|
|
query["userid"] = userId
|
|
@@ -203,57 +203,72 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
}
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
- userId = common.ObjToString((*userInfo)["userid"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
+ userId = gconv.String((*userInfo)["userid"])
|
|
|
}
|
|
|
if role == "集成商" || role == "设计院" {
|
|
|
role = "其他-" + role
|
|
|
}
|
|
|
} else if item == "readClue" {
|
|
|
- userId = common.ObjToString(data["userId"])
|
|
|
+ userId = gconv.String(data["userId"])
|
|
|
query["userid"] = userId
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"])
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"])
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"])
|
|
|
}
|
|
|
- // cluename = common.ObjToString(data["companyName"])
|
|
|
- phone = common.ObjToString(data["phone"])
|
|
|
+ // cluename = gconv.String(data["companyName"])
|
|
|
+ phone = gconv.String(data["phone"])
|
|
|
sourceId = common.Int64All(data["sourceId"])
|
|
|
} else if item == "invite" {
|
|
|
query["userid"] = userId
|
|
|
userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
if userInfo != nil && len(*userInfo) > 0 {
|
|
|
- uId = common.ObjToString((*userInfo)["uid"])
|
|
|
- source = common.ObjToString((*userInfo)["source"]) //用户来源
|
|
|
- belong_to = common.ObjToString((*userInfo)["belong_to"]) //用户归属
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"]) //用户来源
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
|
|
|
+ } else {
|
|
|
+ log.Println("邀请用户,用户归集没数据", data)
|
|
|
+ return true, true, true
|
|
|
+ }
|
|
|
+ cluename = gconv.String((*userInfo)["company_name"])
|
|
|
+ phone = gconv.String((*userInfo)["phone"])
|
|
|
+ sourceCode = gconv.String(data["sourceCode"])
|
|
|
+ } else if item == "activity" {
|
|
|
+ query["userid"] = userId
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ uId = gconv.String((*userInfo)["uid"])
|
|
|
+ source = gconv.String((*userInfo)["source"]) //用户来源
|
|
|
+ belong_to = gconv.String((*userInfo)["belong_to"]) //用户归属
|
|
|
} else {
|
|
|
log.Println("邀请用户,用户归集没数据", data)
|
|
|
return true, true, true
|
|
|
}
|
|
|
- cluename = common.ObjToString((*userInfo)["company_name"])
|
|
|
- phone = common.ObjToString((*userInfo)["phone"])
|
|
|
- sourceCode = common.ObjToString(data["sourceCode"])
|
|
|
+ cluename = gconv.String((*userInfo)["company_name"])
|
|
|
+ phone = gconv.String((*userInfo)["phone"])
|
|
|
+ sourceCode = gconv.String(data["sourceCode"])
|
|
|
+ log.Println(sourceCode)
|
|
|
}
|
|
|
log.Println(222, cluename)
|
|
|
- if cluename == "" && item != "message" && item != "orders" && item != "readClue" && item != "rebind" && item != "allocation" {
|
|
|
+ if cluename == "" && item != "message" && item != "orders" && item != "readClue" && item != "rebind" && item != "allocation" && item != "activity" {
|
|
|
cluename = phone //没有线索名,手机号代替
|
|
|
}
|
|
|
log.Println(333, cluename)
|
|
|
cluename = strings.ReplaceAll(cluename, " ", "")
|
|
|
- isGroup, isCommerce := GetCompanyType(cluename) //判断是否集团公司、工商库
|
|
|
+ isGroup, isCommerce := GetCompanyType(cluename, uId) //判断是否集团公司、工商库
|
|
|
if source == "0104" || strings.HasPrefix(belong_to, "02") || source == "0102" || source == "0103" || phone == "" { //参照用户来源代码表
|
|
|
//log.Println("线索分配失败,线索过滤!!", item, source, phone, userId)
|
|
|
//saveHlyj(belong_to, item, phone, name, sourceName, cluename, position, nowTime, isGroup, isCommerce)
|
|
|
return true, true, true
|
|
|
}
|
|
|
//安博会
|
|
|
- if s_sourceid == db.Sourceid {
|
|
|
+ /*if s_sourceid == db.Sourceid {
|
|
|
return true, true, false
|
|
|
- }
|
|
|
+ }*/
|
|
|
if uId == "" { //没有进用户归集,等待进入,结束任务,放在下次继续执行
|
|
|
if isExists, _ := redis.Exists("bidx", "bidx_userId_"+userId); isExists {
|
|
|
redisInt := redis.GetInt("bidx", "bidx_userId_"+userId)
|
|
@@ -277,12 +292,12 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
saleLeadsData, ok := Mgo.Find("saleLeads", map[string]interface{}{"userid": qid}, map[string]interface{}{"_id": -1}, nil, false, 0, 1)
|
|
|
if ok && saleLeadsData != nil && len(*saleLeadsData) > 0 {
|
|
|
sdata := (*saleLeadsData)[0]
|
|
|
- role = common.ObjToString(sdata["companyType"])
|
|
|
- industry = common.ObjToString(sdata["industry"])
|
|
|
- department = common.ObjToString(sdata["branch"])
|
|
|
- departments = common.ObjToString(sdata["department"])
|
|
|
- position = common.ObjToString(sdata["position"])
|
|
|
- name = common.ObjToString(sdata["name"])
|
|
|
+ role = gconv.String(sdata["companyType"])
|
|
|
+ industry = gconv.String(sdata["industry"])
|
|
|
+ department = gconv.String(sdata["branch"])
|
|
|
+ departments = gconv.String(sdata["department"])
|
|
|
+ position = gconv.String(sdata["position"])
|
|
|
+ name = gconv.String(sdata["name"])
|
|
|
}
|
|
|
}
|
|
|
top_cluetype, sub_cluetype, level, topname, subname = getClueType(item, data, sourceCode, sourceId) //查留资来源名字
|
|
@@ -314,7 +329,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
cluename = ""
|
|
|
}
|
|
|
//已存在,走更新
|
|
|
- batch_import := common.ObjToString((*uCount)["batch_import"])
|
|
|
+ batch_import := gconv.String((*uCount)["batch_import"])
|
|
|
if batch_import != "" && item == "users" { //有导入批次号还是新用户,不执行
|
|
|
return true, true, true
|
|
|
}
|
|
@@ -341,14 +356,16 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
if item != "orders" && item != "users" { //新用户和订单之外的替换一下新的留资信息
|
|
|
BCPCID := common.GetRandom(32)
|
|
|
clueId := common.Int64All((*uCount)["id"])
|
|
|
- old_name := common.ObjToString((*uCount)["name"])
|
|
|
- old_position := common.ObjToString((*uCount)["position"])
|
|
|
- old_department := common.ObjToString((*uCount)["department"])
|
|
|
- old_follow_project_area := common.ObjToString((*uCount)["follow_project_area"])
|
|
|
- old_role := common.ObjToString((*uCount)["role"])
|
|
|
- old_cluename := common.ObjToString((*uCount)["cluename"])
|
|
|
- old_top_cluetype := common.ObjToString((*uCount)["top_cluetype"])
|
|
|
- old_sub_cluetype := common.ObjToString((*uCount)["sub_cluetype"])
|
|
|
+ old_name := gconv.String((*uCount)["name"])
|
|
|
+ old_position := gconv.String((*uCount)["position"])
|
|
|
+ old_department := gconv.String((*uCount)["department"])
|
|
|
+ old_follow_project_area := gconv.String((*uCount)["follow_project_area"])
|
|
|
+ old_role := gconv.String((*uCount)["role"])
|
|
|
+ old_cluename := gconv.String((*uCount)["cluename"])
|
|
|
+ old_top_cluetype := gconv.String((*uCount)["top_cluetype"])
|
|
|
+ old_sub_cluetype := gconv.String((*uCount)["sub_cluetype"])
|
|
|
+ label := gconv.Int64((*uCount)["label"])
|
|
|
+ trailstatusCode := gconv.String((*uCount)["trailstatus"])
|
|
|
clueUpdateData := map[string]interface{}{}
|
|
|
if old_name != name && name != "" {
|
|
|
clueUpdateData["name"] = name
|
|
@@ -356,6 +373,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
"clue_id": clueId,
|
|
|
"change_field": "name",
|
|
|
"position_id": 0,
|
|
|
+ "seatNumber": nil,
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_name != "", old_name, "/"),
|
|
|
"new_value": common.If(name != "", name, "/"),
|
|
@@ -433,13 +451,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
if old_top_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_topname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_topname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if old_sub_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_subname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_subname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if old_top_cluetype != top_cluetype && top_cluetype != "" {
|
|
@@ -459,7 +477,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
clueUpdateData["sub_cluetype"] = sub_cluetype //新的线索名不为空才替换
|
|
|
TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "change_field": "sub_cluetype",
|
|
|
+ "change_field": "sub_cluetype", //111
|
|
|
"position_id": 0,
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
@@ -467,6 +485,8 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": BCPCID,
|
|
|
"operator_id": -1})
|
|
|
+ //标签处理
|
|
|
+ LabelHandel(nil, label, 2, uId, level, trailstatusCode, gconv.String(clueUpdateData["trailstatus"]), 1)
|
|
|
}
|
|
|
clueUpdateData["company_nature"] = isGroup
|
|
|
clueUpdateData["company_verification"] = isCommerce
|
|
@@ -496,7 +516,6 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
if cluename == "" {
|
|
|
cluename = phone
|
|
|
}
|
|
|
-
|
|
|
clueId = TiDb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
"userid": userId,
|
|
|
"uid": uId,
|
|
@@ -529,6 +548,8 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"remark": remark,
|
|
|
"customer_demand": demand,
|
|
|
"FREEZE_TIME": nowTime,
|
|
|
+ "label": 1,
|
|
|
+ "labelChangeTime": time.Now().Format("2006-01-02"),
|
|
|
})
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -584,7 +605,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
uodateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": positionId,
|
|
|
- "change_field": "sub_cluetype",
|
|
|
+ "change_field": "sub_cluetype", //222
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": "/",
|
|
|
"new_value": subname,
|
|
@@ -652,6 +673,8 @@ func SaveClue0(item, userId, uId, top_cluetype, sub_cluetype, topname, subname,
|
|
|
"company_verification": isCommerce,
|
|
|
"remark": remark,
|
|
|
"FREEZE_TIME": nowTime,
|
|
|
+ "label": 1,
|
|
|
+ "labelChangeTime": time.Now().Format("2006-01-02"),
|
|
|
})
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -708,8 +731,8 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
log.Println("工单线索修改前", data)
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
|
- trailstatus := common.ObjToString(data["trailstatus"]) //data都为原线索数据
|
|
|
- trailstatusTime := common.ObjToString(data["trailstatus_time"])
|
|
|
+ trailstatus := gconv.String(data["trailstatus"]) //data都为原线索数据
|
|
|
+ trailstatusTime := gconv.String(data["trailstatus_time"])
|
|
|
var trailstatusTimes time.Time
|
|
|
if trailstatusTime != "" {
|
|
|
trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
|
|
@@ -717,23 +740,24 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
clueId := common.Int64All(data["id"])
|
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
|
oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
|
- old_position_id, old_seatNumber := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"])
|
|
|
- oldTaskTime = common.ObjToString(data["tasktime"])
|
|
|
+ old_position_id, old_seatNumber := common.Int64All(data["position_id"]), gconv.String(data["seatNumber"])
|
|
|
+ oldTaskTime = gconv.String(data["tasktime"])
|
|
|
is_task = common.IntAll(data["is_task"])
|
|
|
taskstatus = common.IntAll(data["taskstatus"])
|
|
|
BCPCID := common.GetRandom(32)
|
|
|
- old_name := common.ObjToString(data["name"])
|
|
|
- old_position := common.ObjToString(data["position"])
|
|
|
- old_department := common.ObjToString(data["department"])
|
|
|
- old_follow_project_area := common.ObjToString(data["follow_project_area"])
|
|
|
- old_role := common.ObjToString(data["role"])
|
|
|
- old_cluename := common.ObjToString(data["cluename"])
|
|
|
- old_top_cluetype := common.ObjToString(data["top_cluetype"])
|
|
|
- old_sub_cluetype := common.ObjToString(data["sub_cluetype"])
|
|
|
+ old_name := gconv.String(data["name"])
|
|
|
+ old_position := gconv.String(data["position"])
|
|
|
+ old_department := gconv.String(data["department"])
|
|
|
+ old_follow_project_area := gconv.String(data["follow_project_area"])
|
|
|
+ old_role := gconv.String(data["role"])
|
|
|
+ old_cluename := gconv.String(data["cluename"])
|
|
|
+ old_top_cluetype := gconv.String(data["top_cluetype"])
|
|
|
+ old_sub_cluetype := gconv.String(data["sub_cluetype"])
|
|
|
+ label := gconv.Int64(data["label"])
|
|
|
old_topname, old_subname := "", ""
|
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
|
if taskstatus == 1 || is_task == 0 {
|
|
|
- taskTime = common.ObjToString(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
|
+ taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
|
} else {
|
|
|
if is_task == 1 {
|
|
|
if oldTaskTime != "" { //以最新的任务时间为主
|
|
@@ -788,12 +812,12 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
"company_nature": isGroup,
|
|
|
"company_verification": isCommerce,
|
|
|
}
|
|
|
- old_remark := common.ObjToString(data["remark"])
|
|
|
+ old_remark := gconv.String(data["remark"])
|
|
|
if old_remark != "" {
|
|
|
remark = old_remark + ";" + remark //备注不能替换,只能往上拼接
|
|
|
}
|
|
|
clueUpdateData["remark"] = remark
|
|
|
- old_demand := common.ObjToString(data["customer_demand"])
|
|
|
+ old_demand := gconv.String(data["customer_demand"])
|
|
|
if demand != old_demand {
|
|
|
clueUpdateData["customer_demand"] = demand
|
|
|
}
|
|
@@ -825,7 +849,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
clueUpdateData["department"] = departments
|
|
|
department = departments
|
|
|
}
|
|
|
- business_scope := common.ObjToString(data["business_scope"])
|
|
|
+ business_scope := gconv.String(data["business_scope"])
|
|
|
keywords := ""
|
|
|
if len(keyword) > 0 && keyword[0] != "" {
|
|
|
keywords = strings.Join(keyword, ",")
|
|
@@ -839,7 +863,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
if old_position_id != 0 {
|
|
|
for _, v := range saleData {
|
|
|
if old_position_id == common.Int64All(v["position_id"]) {
|
|
|
- oldsaleName = common.ObjToString(v["name"])
|
|
|
+ oldsaleName = gconv.String(v["name"])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -889,7 +913,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
eData := TiDb.Find("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": clueId, "change_type": "加入任务车"}, "", "", -1, -1)
|
|
|
if eData != nil && len(*eData) > 0 {
|
|
|
for _, e := range *eData {
|
|
|
- new_value := common.ObjToString(e["new_value"])
|
|
|
+ new_value := gconv.String(e["new_value"])
|
|
|
if strings.Contains(new_value, subname) {
|
|
|
is_ok = true
|
|
|
}
|
|
@@ -931,7 +955,6 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
//线索
|
|
|
ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, clueUpdateData)
|
|
|
//变更记录
|
|
|
-
|
|
|
if (trailstatus == "00" || old_position_id == 0 || (pIsOk && old_cluename != cluename && cluename != "")) && is_assign == 1 {
|
|
|
if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
} else if old_position_id == 0 {
|
|
@@ -1100,7 +1123,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
|
if cdata != nil && len(*cdata) > 0 {
|
|
|
kcpositionId := common.Int64All((*cdata)["position_id"])
|
|
|
- tasksource := common.ObjToString((*cdata)["tasksource"])
|
|
|
+ tasksource := gconv.String((*cdata)["tasksource"])
|
|
|
taskstatus := common.IntAll((*cdata)["taskstatus"])
|
|
|
updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -1143,17 +1166,16 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if old_top_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_topname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_topname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if old_sub_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_subname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_subname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if item != "orders" {
|
|
@@ -1249,11 +1271,12 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
}
|
|
|
+ newPositionId := gconv.Int64(common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.If(is_assign == 1, positionId, common.If(is_assign == 1, positionId, common.Int64All(data["position_id"]))))))
|
|
|
if old_sub_cluetype != sub_cluetype {
|
|
|
updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.If(is_assign == 1, positionId, common.If(is_assign == 1, positionId, common.Int64All(data["position_id"]))))),
|
|
|
- "change_field": "sub_cluetype",
|
|
|
+ "change_field": "sub_cluetype", //333
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
|
"new_value": common.If(subname != "", subname, "/"),
|
|
@@ -1261,6 +1284,16 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
"BCPCID": BCPCID,
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
+ //标签处理
|
|
|
+ if old_position_id != positionId && newPositionId > 0 {
|
|
|
+ LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ } else {
|
|
|
+ LabelHandel(tx, label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if old_position_id != positionId && newPositionId > 0 {
|
|
|
+ LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ }
|
|
|
}
|
|
|
return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
|
|
|
}) {
|
|
@@ -1290,8 +1323,8 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
name = strings.ReplaceAll(name, " ", "")
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
nowTimes := time.Unix(time.Now().Unix()+3600*12, 0).Format("2006-01-02 15:04:05")
|
|
|
- trailstatus := common.ObjToString(data["trailstatus"]) //data都为原线索数据
|
|
|
- trailstatusTime := common.ObjToString(data["trailstatus_time"])
|
|
|
+ trailstatus := gconv.String(data["trailstatus"]) //data都为原线索数据
|
|
|
+ trailstatusTime := gconv.String(data["trailstatus_time"])
|
|
|
var trailstatusTimes time.Time
|
|
|
if trailstatusTime != "" {
|
|
|
trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
|
|
@@ -1299,23 +1332,25 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
clueId := common.Int64All(data["id"])
|
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
|
oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
|
- old_position_id, old_seatNumber := common.Int64All(data["position_id"]), common.ObjToString(data["seatNumber"])
|
|
|
- oldTaskTime = common.ObjToString(data["tasktime"])
|
|
|
+ old_position_id, old_seatNumber := common.Int64All(data["position_id"]), gconv.String(data["seatNumber"])
|
|
|
+ oldTaskTime = gconv.String(data["tasktime"])
|
|
|
is_task = common.IntAll(data["is_task"])
|
|
|
taskstatus = common.IntAll(data["taskstatus"])
|
|
|
BCPCID := common.GetRandom(32)
|
|
|
- old_name := common.ObjToString(data["name"])
|
|
|
- old_position := common.ObjToString(data["position"])
|
|
|
- old_department := common.ObjToString(data["department"])
|
|
|
- old_follow_project_area := common.ObjToString(data["follow_project_area"])
|
|
|
- old_role := common.ObjToString(data["role"])
|
|
|
- old_cluename := common.ObjToString(data["cluename"])
|
|
|
- old_top_cluetype := common.ObjToString(data["top_cluetype"])
|
|
|
- old_sub_cluetype := common.ObjToString(data["sub_cluetype"])
|
|
|
+ old_name := gconv.String(data["name"])
|
|
|
+ old_position := gconv.String(data["position"])
|
|
|
+ old_department := gconv.String(data["department"])
|
|
|
+ old_follow_project_area := gconv.String(data["follow_project_area"])
|
|
|
+ old_role := gconv.String(data["role"])
|
|
|
+ old_cluename := gconv.String(data["cluename"])
|
|
|
+ old_top_cluetype := gconv.String(data["top_cluetype"])
|
|
|
+ old_sub_cluetype := gconv.String(data["sub_cluetype"])
|
|
|
old_topname, old_subname := "", ""
|
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
|
+ oldLabelChangeTime := gconv.String(data["labelChangeTime"])
|
|
|
+ label := gconv.Int64(data["label"])
|
|
|
if taskstatus == 1 || is_task == 0 {
|
|
|
- taskTime = common.ObjToString(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
|
+ taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
|
} else {
|
|
|
if is_task == 1 {
|
|
|
if oldTaskTime != "" { //以最新的任务时间为主
|
|
@@ -1370,7 +1405,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
"company_nature": isGroup,
|
|
|
"company_verification": isCommerce,
|
|
|
}
|
|
|
- old_remark := common.ObjToString(data["remark"])
|
|
|
+ old_remark := gconv.String(data["remark"])
|
|
|
if old_remark != "" {
|
|
|
remark = old_remark + ";" + remark //备注不能替换,只能往上拼接
|
|
|
}
|
|
@@ -1402,7 +1437,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
clueUpdateData["department"] = departments
|
|
|
department = departments
|
|
|
}
|
|
|
- business_scope := common.ObjToString(data["business_scope"])
|
|
|
+ business_scope := gconv.String(data["business_scope"])
|
|
|
keywords := ""
|
|
|
if len(keyword) > 0 && keyword[0] != "" {
|
|
|
keywords = strings.Join(keyword, ",")
|
|
@@ -1442,6 +1477,9 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
Phone: phone,
|
|
|
Source: source,
|
|
|
PositionId: old_position_id,
|
|
|
+ Level: level,
|
|
|
+ LabelChangeTime: oldLabelChangeTime,
|
|
|
+ Label: label,
|
|
|
}
|
|
|
return clueInfoUpdate(clueMapEntity)
|
|
|
|
|
@@ -1464,7 +1502,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
clueUpdateData["clue_level"] = nil
|
|
|
for _, v := range saleData {
|
|
|
if common.Int64All(data["position_id"]) == common.Int64All(v["position_id"]) {
|
|
|
- oldsaleName = common.ObjToString(v["name"])
|
|
|
+ oldsaleName = gconv.String(v["name"])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1503,7 +1541,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
eData := TiDb.Find("dwd_f_crm_clue_change_record", map[string]interface{}{"clue_id": clueId, "change_type": "加入任务车"}, "", "", -1, -1)
|
|
|
if eData != nil && len(*eData) > 0 {
|
|
|
for _, e := range *eData {
|
|
|
- new_value := common.ObjToString(e["new_value"])
|
|
|
+ new_value := gconv.String(e["new_value"])
|
|
|
if strings.Contains(new_value, subname) {
|
|
|
is_ok = true
|
|
|
}
|
|
@@ -1710,7 +1748,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
|
|
|
if cdata != nil && len(*cdata) > 0 {
|
|
|
kcpositionId := common.Int64All((*cdata)["position_id"])
|
|
|
- tasksource := common.ObjToString((*cdata)["tasksource"])
|
|
|
+ tasksource := gconv.String((*cdata)["tasksource"])
|
|
|
taskstatus := common.IntAll((*cdata)["taskstatus"])
|
|
|
updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -1756,13 +1794,13 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_top_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_topname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_topname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if old_sub_cluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_sub_cluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_subname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_subname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if item != "orders" {
|
|
@@ -1867,11 +1905,12 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
}
|
|
|
+ newPositionId := gconv.Int64(common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))))
|
|
|
if old_sub_cluetype != sub_cluetype {
|
|
|
updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": common.If(trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400, -1, common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"]))),
|
|
|
- "change_field": "sub_cluetype",
|
|
|
+ "change_field": "sub_cluetype", //444
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
|
"new_value": common.If(subname != "", subname, "/"),
|
|
@@ -1879,6 +1918,15 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
"BCPCID": BCPCID,
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
+ if old_position_id != newPositionId && newPositionId > 0 {
|
|
|
+ LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ } else {
|
|
|
+ LabelHandel(tx, label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if old_position_id != newPositionId && newPositionId > 0 {
|
|
|
+ LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), 0)
|
|
|
+ }
|
|
|
}
|
|
|
return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
|
|
|
}) {
|
|
@@ -1931,6 +1979,9 @@ type ClueMapEntity struct {
|
|
|
Phone string
|
|
|
Source string
|
|
|
PositionId int64
|
|
|
+ Label int64
|
|
|
+ LabelChangeTime string
|
|
|
+ Level string
|
|
|
}
|
|
|
|
|
|
// 基本信息变更
|
|
@@ -1950,13 +2001,13 @@ func clueInfoUpdate(data ClueMapEntity) bool {
|
|
|
if data.OldTopCluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": data.OldTopCluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_topname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_topname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if data.OldSubCluetype != "" {
|
|
|
pcodeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": data.OldSubCluetype}, "", "")
|
|
|
if pcodeData != nil && len(*pcodeData) > 0 {
|
|
|
- old_subname = common.ObjToString((*pcodeData)["name"])
|
|
|
+ old_subname = gconv.String((*pcodeData)["name"])
|
|
|
}
|
|
|
}
|
|
|
if data.Item != "orders" {
|
|
@@ -2061,11 +2112,11 @@ func clueInfoUpdate(data ClueMapEntity) bool {
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
}
|
|
|
- if data.OldTopCluetype != data.NewTopCluetype {
|
|
|
+ if data.OldSubCluetype != data.OldSubCluetype {
|
|
|
updateId13 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": data.ClueId,
|
|
|
"position_id": data.PositionId,
|
|
|
- "change_field": "sub_cluetype",
|
|
|
+ "change_field": "sub_cluetype", //555
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|
|
|
"new_value": common.If(data.Subname != "", data.Subname, "/"),
|
|
@@ -2073,6 +2124,7 @@ func clueInfoUpdate(data ClueMapEntity) bool {
|
|
|
"BCPCID": BCPCID,
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
+ LabelHandel(tx, data.Label, 1, data.UId, data.Level, data.Trailstatus, data.Trailstatus, 0)
|
|
|
}
|
|
|
return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1
|
|
|
}) {
|
|
@@ -2094,3 +2146,54 @@ func clueInfoUpdate(data ClueMapEntity) bool {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// 线索标签修改 label labelChangeTime
|
|
|
+func LabelHandel(tx *sql.Tx, oldlabelType, labelType int64, uId, level, oldTrailstatusCode, trailstatusCode string, status int64) {
|
|
|
+ log.Println("线索标签修改:", "oldlabelType:", oldlabelType, "labelType:", labelType, "uId:", uId, "level:", level, "oldTrailstatusCode:", oldTrailstatusCode, "trailstatusCode:", trailstatusCode, "status:", status)
|
|
|
+ //先查询以前什么类型
|
|
|
+ if trailstatusCode != "01" && oldTrailstatusCode != "01" {
|
|
|
+ log.Println("不属于商机类型", uId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if status != 0 {
|
|
|
+ log.Println("不属于未完成", uId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ updateLabelType := int64(0)
|
|
|
+ nowStr := time.Now().Format("2006-01-02")
|
|
|
+ if labelType == 1 {
|
|
|
+ //直接更新
|
|
|
+ if oldlabelType != 1 {
|
|
|
+ updateLabelType = labelType
|
|
|
+ }
|
|
|
+ } else if labelType == 2 {
|
|
|
+ if level != "A" && level != "B" && level != "C" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //查询以前是什么数据
|
|
|
+ //同一天修改过
|
|
|
+ if oldlabelType != 1 {
|
|
|
+ updateLabelType = labelType
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if updateLabelType > 0 {
|
|
|
+ ok := false
|
|
|
+ if tx == nil {
|
|
|
+ ok = TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
+ "uid": uId,
|
|
|
+ }, map[string]interface{}{
|
|
|
+ "label": updateLabelType,
|
|
|
+ "labelChangeTime": nowStr,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
+ "uid": uId,
|
|
|
+ }, map[string]interface{}{
|
|
|
+ "label": updateLabelType,
|
|
|
+ "labelChangeTime": nowStr,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ log.Println("线索标签修改", ok)
|
|
|
+ }
|
|
|
+}
|