|
@@ -274,8 +274,8 @@ func saleLeads() {
|
|
|
}
|
|
|
|
|
|
func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
- userId, uId, positionId, source, cluename, phone := common.ObjToString(data["user_id"]), "", "", 0, "", ""
|
|
|
- role, industry, department, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", ""
|
|
|
+ userId, uId, positionId, source, cluename, phone, sourceCode, keyword := common.ObjToString(data["user_id"]), "", "", 0, "", "", "", []string{}
|
|
|
+ role, industry, department, departments, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", "", ""
|
|
|
query, topname, subname := map[string]interface{}{}, "", ""
|
|
|
if item == "orders" {
|
|
|
if !mongodb.IsObjectIdHex(userId) {
|
|
@@ -333,9 +333,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
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"])
|
|
|
+ sourceCode = common.ObjToString(data["source"])
|
|
|
+ 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"]) != "" {
|
|
@@ -390,6 +392,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
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"])
|
|
|
}
|
|
@@ -410,9 +413,9 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
if position_id > 0 && seatNumber != "" {
|
|
|
uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true
|
|
|
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, source)
|
|
|
+ oks = UpdateClue(*uCount, saleData, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, position_id, source, sourceCode, keyword)
|
|
|
} 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, source)
|
|
|
+ oks = SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, position_id, source, sourceCode, keyword)
|
|
|
}
|
|
|
if oks {
|
|
|
TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
|
|
@@ -424,12 +427,18 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
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, source int) bool {
|
|
|
+func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber string, positionId int64, source int, sourceCode string, keyword []string) bool {
|
|
|
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")
|
|
|
clueId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5, uodateId6 := int64(0), int64(0), int64(0), int64(0), int64(0), int64(0), int64(0)
|
|
|
// BCPCID := common.GetRandom(32)
|
|
|
if TiDb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
|
+ keywords := ""
|
|
|
+ if sourceCode == "app_xzcyh" {
|
|
|
+ if len(keyword) > 0 && keyword[0] != "" {
|
|
|
+ keywords = strings.Join(keyword, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
//线索
|
|
|
clueId = TiDb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
"userid": userId,
|
|
@@ -447,7 +456,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"name": name,
|
|
|
"phone": phone,
|
|
|
"position": position,
|
|
|
- "department": department,
|
|
|
+ "department": common.If(sourceCode == "app_xzcyh", departments, department),
|
|
|
"industry": industry,
|
|
|
"follow_project_area": follow_project_area,
|
|
|
"role": role,
|
|
@@ -457,6 +466,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"tasktime": common.If(item == "users", nowTimes, nowTime),
|
|
|
"taskstatus": 0,
|
|
|
"tasksource": "线索自动分配" + "-" + topname + "-" + subname,
|
|
|
+ "business_scope": common.If(sourceCode == "app_xzcyh", keywords, nil),
|
|
|
})
|
|
|
//变更记录
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
@@ -542,7 +552,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, source int) 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, departments, industry, follow_project_area, role, seatNumber string, positionId int64, source int, sourceCode string, keyword []string) bool {
|
|
|
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 = 无意向 为变更线索状态
|
|
@@ -636,12 +646,38 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
clueUpdateData["cluename"] = cluename
|
|
|
}
|
|
|
if item != "orders" && item != "users" {
|
|
|
- clueUpdateData["name"] = name
|
|
|
- clueUpdateData["position"] = position
|
|
|
- clueUpdateData["department"] = department
|
|
|
- clueUpdateData["industry"] = industry
|
|
|
- clueUpdateData["follow_project_area"] = follow_project_area
|
|
|
- clueUpdateData["role"] = role
|
|
|
+ if name != "" {
|
|
|
+ clueUpdateData["name"] = name
|
|
|
+ }
|
|
|
+ if position != "" {
|
|
|
+ clueUpdateData["position"] = position
|
|
|
+ }
|
|
|
+ if department != "" {
|
|
|
+ clueUpdateData["department"] = department
|
|
|
+ }
|
|
|
+ if follow_project_area != "" {
|
|
|
+ clueUpdateData["follow_project_area"] = follow_project_area
|
|
|
+ }
|
|
|
+ if role != "" {
|
|
|
+ clueUpdateData["role"] = role
|
|
|
+ }
|
|
|
+ // clueUpdateData["industry"] = industry
|
|
|
+ }
|
|
|
+ if sourceCode == "app_xzcyh" {
|
|
|
+ if departments != "" {
|
|
|
+ clueUpdateData["department"] = departments
|
|
|
+ department = departments
|
|
|
+ }
|
|
|
+ business_scope := common.ObjToString(data["business_scope"])
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if trailstatus == "00" || old_position_id == 0 || is_assign != 1 {
|
|
|
if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
@@ -911,7 +947,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
}
|
|
|
- if old_follow_project_area != follow_project_area {
|
|
|
+ if old_follow_project_area != follow_project_area && follow_project_area != "" {
|
|
|
old_area, old_area_arr := "", []string{}
|
|
|
new_area, new_area_arr := "", []string{}
|
|
|
for _, v := range strings.Split(old_follow_project_area, ",") {
|