|
@@ -111,55 +111,89 @@ func userbase() {
|
|
|
if phone != "" {
|
|
|
contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
|
|
|
if contactsData == nil || len(*contactsData) == 0 {
|
|
|
- registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
|
|
|
- count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where phone = ?", phone)
|
|
|
- if time.Now().Unix()-registedates.Unix() > 7*86400 {
|
|
|
- if count == 0 {
|
|
|
- FormatData(v, "users")
|
|
|
- } else {
|
|
|
- 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,
|
|
|
- })
|
|
|
- }
|
|
|
+ contactsData2 := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1", uId)
|
|
|
+ if contactsData2 != nil && len(*contactsData2) > 0 {
|
|
|
+ log.Println("userbase uid不为空 新增通讯录", uId)
|
|
|
+ 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,
|
|
|
+ })
|
|
|
} else {
|
|
|
- if count == 0 {
|
|
|
- clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
- "userid": userId,
|
|
|
- "uid": uId,
|
|
|
- "is_assign": 0,
|
|
|
- "comeintime": nowTime,
|
|
|
- "createtime": nowTime,
|
|
|
- "updatetime": nowTime,
|
|
|
- "cluename": phone,
|
|
|
- "top_cluetype": "",
|
|
|
- "sub_cluetype": "",
|
|
|
- "trailstatus": "01",
|
|
|
- "name": name,
|
|
|
- "phone": phone,
|
|
|
- })
|
|
|
- if clueId > 0 {
|
|
|
- TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
|
|
|
- "clue_id": clueId,
|
|
|
+ registedates, _ := time.Parse(date.Date_Full_Layout, registedate)
|
|
|
+ count := TiDb.CountBySql("select count(1) as count from dwd_f_crm_clue_info where uid = ?", uId)
|
|
|
+ log.Println("userbase uid 线索数量 ", count)
|
|
|
+ log.Println("userbase uid 注册时间 ", registedates)
|
|
|
+ if time.Now().Unix()-registedates.Unix() > int64(cfg.RegTimes)*86400 {
|
|
|
+ if count == 0 {
|
|
|
+ clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
+ "userid": userId,
|
|
|
+ "uid": uId,
|
|
|
+ "is_assign": 0,
|
|
|
"comeintime": nowTime,
|
|
|
- "comeinsource": 2,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "updatetime": nowTime,
|
|
|
+ "cluename": phone,
|
|
|
+ "top_cluetype": "379",
|
|
|
+ "sub_cluetype": "380",
|
|
|
+ "trailstatus": "01",
|
|
|
+ "name": name,
|
|
|
+ "phone": phone,
|
|
|
+ })
|
|
|
+ if clueId > 0 {
|
|
|
+ TiDb.Insert("dwd_f_crm_open_sea", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "comeintime": nowTime,
|
|
|
+ "comeinsource": 2,
|
|
|
+ })
|
|
|
+ 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,
|
|
|
+ })
|
|
|
+ TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": -1,
|
|
|
+ "change_type": "创建线索",
|
|
|
+ "new_value": "系统自动创建",
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ 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,
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- 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,
|
|
|
- })
|
|
|
+ if count == 0 {
|
|
|
+ FormatData(v, "users")
|
|
|
+ } else {
|
|
|
+ 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,
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -397,7 +431,7 @@ func FormatData(data map[string]interface{}, item string) (bool, 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")
|
|
|
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, uodateId5, uodateId6 := int64(0), 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 {
|
|
|
//线索
|
|
@@ -476,7 +510,29 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
- return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1
|
|
|
+ uodateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "top_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": "/",
|
|
|
+ "new_value": topname,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ uodateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_field": "sub_cluetype",
|
|
|
+ "change_type": "基本信息变更",
|
|
|
+ "old_value": "/",
|
|
|
+ "new_value": subname,
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ })
|
|
|
+ return clueId > -1 && seaId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
|
|
|
}) {
|
|
|
log.Println("线索分配成功")
|
|
|
if TiDb.Count("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}) == 0 {
|
|
@@ -492,7 +548,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
}
|
|
|
return true
|
|
|
} else {
|
|
|
- log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
|
|
|
+ log.Println("线索分配失败!!!", clueId, seaId, uodateId1, uodateId2, uodateId3, uodateId4, uodateId5, uodateId6, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
@@ -503,6 +559,11 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
//trailstatus = 无意向 为变更线索状态
|
|
|
//没有变更所属人查任务车,有车不变
|
|
|
trailstatus := common.ObjToString(data["trailstatus"])
|
|
|
+ trailstatusTime := common.ObjToString(data["trailstatus_time"])
|
|
|
+ var trailstatusTimes time.Time
|
|
|
+ if trailstatusTime != "" {
|
|
|
+ trailstatusTimes, _ = time.ParseInLocation(date.Date_Full_Layout, trailstatusTime, time.Local)
|
|
|
+ }
|
|
|
clueId := common.Int64All(data["id"])
|
|
|
is_assign := common.IntAll(data["is_assign"])
|
|
|
oldsaleName, oldTaskTime, taskTime, is_task, taskstatus := "", "", "", 0, 0
|
|
@@ -561,7 +622,6 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
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{}{
|
|
|
- "is_assign": 1,
|
|
|
"updatetime": nowTime,
|
|
|
"top_cluetype": top_cluetype,
|
|
|
"sub_cluetype": sub_cluetype,
|
|
@@ -593,17 +653,21 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
clueUpdateData["role"] = role
|
|
|
}
|
|
|
if trailstatus == "00" || old_position_id == 0 || is_assign != 1 {
|
|
|
- clueUpdateData["seatNumber"] = seatNumber
|
|
|
- clueUpdateData["position_id"] = positionId
|
|
|
- clueUpdateData["comeintime"] = nowTime
|
|
|
- seaUpdateData["seatNumber"] = seatNumber
|
|
|
- seaUpdateData["position_id"] = positionId
|
|
|
- seaUpdateData["comeintime"] = nowTime
|
|
|
- insertSeaData["seatNumber"] = seatNumber
|
|
|
- insertSeaData["position_id"] = positionId
|
|
|
- for _, v := range saleData {
|
|
|
- if common.ObjToString(data["seatNumber"]) == common.ObjToString(v["seatNumber"]) {
|
|
|
- oldsaleName = common.ObjToString(v["name"])
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else {
|
|
|
+ clueUpdateData["seatNumber"] = seatNumber
|
|
|
+ clueUpdateData["position_id"] = positionId
|
|
|
+ clueUpdateData["comeintime"] = nowTime
|
|
|
+ clueUpdateData["is_assign"] = 1
|
|
|
+ seaUpdateData["seatNumber"] = seatNumber
|
|
|
+ seaUpdateData["position_id"] = positionId
|
|
|
+ seaUpdateData["comeintime"] = nowTime
|
|
|
+ insertSeaData["seatNumber"] = seatNumber
|
|
|
+ insertSeaData["position_id"] = positionId
|
|
|
+ for _, v := range saleData {
|
|
|
+ if common.ObjToString(data["seatNumber"]) == common.ObjToString(v["seatNumber"]) {
|
|
|
+ oldsaleName = common.ObjToString(v["name"])
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -611,13 +675,20 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
insertSeaData["position_id"] = old_position_id
|
|
|
}
|
|
|
if trailstatus != "08" && is_assign == 0 {
|
|
|
- clueUpdateData["trailstatus"] = "01"
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else {
|
|
|
+ clueUpdateData["trailstatus"] = "01"
|
|
|
+ clueUpdateData["trailstatus_time"] = nowTime
|
|
|
+ }
|
|
|
}
|
|
|
if (trailstatus != "08" && recordCount <= 0) || is_assign == 0 {
|
|
|
- seaUpdateData["is_task"] = 1
|
|
|
- seaUpdateData["task_time"] = nowTime
|
|
|
- seaUpdateData["tasktime"] = taskTime
|
|
|
- seaUpdateData["taskstatus"] = 0
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else {
|
|
|
+ seaUpdateData["is_task"] = 1
|
|
|
+ seaUpdateData["task_time"] = nowTime
|
|
|
+ seaUpdateData["tasktime"] = taskTime
|
|
|
+ seaUpdateData["taskstatus"] = 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)
|
|
@@ -629,30 +700,23 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if is_assign == 1 {
|
|
|
ok1 = TiDb.UpdateByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{"clue_id": clueId}, seaUpdateData)
|
|
|
} else {
|
|
|
- ok2 = TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
|
|
|
- seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else {
|
|
|
+ ok2 = TiDb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
|
|
|
+ seaId = TiDb.InsertByTx(tx, "dwd_f_crm_private_sea", insertSeaData)
|
|
|
+ }
|
|
|
}
|
|
|
//变更记录
|
|
|
if (trailstatus == "00" || old_position_id == 0) && is_assign == 1 {
|
|
|
- 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 == "00" {
|
|
|
- updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else if old_position_id == 0 {
|
|
|
+ updateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.Int64All(data["position_id"]),
|
|
|
- "change_field": "trailstatus",
|
|
|
- "change_type": "基本信息变更",
|
|
|
- "old_value": "无意向客户",
|
|
|
- "new_value": "流失",
|
|
|
+ "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,
|
|
@@ -662,74 +726,72 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
"position_id": positionId,
|
|
|
"change_field": "trailstatus",
|
|
|
"change_type": "基本信息变更",
|
|
|
- "old_value": "商机线索",
|
|
|
+ "old_value": CodeTrail[trailstatus],
|
|
|
"new_value": "新增",
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
- updateId4 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ } else {
|
|
|
+ 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,
|
|
|
+ })
|
|
|
+ updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": common.Int64All(data["position_id"]),
|
|
|
"change_field": "trailstatus",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": "无意向客户",
|
|
|
- "new_value": "商机线索",
|
|
|
+ "new_value": "流失",
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
- } else if old_position_id == 0 {
|
|
|
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": CodeTrail[trailstatus],
|
|
|
+ "old_value": "商机线索",
|
|
|
"new_value": "新增",
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
- } else {
|
|
|
- if common.Int64All(data["position_id"]) > 0 {
|
|
|
- updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
- "clue_id": clueId,
|
|
|
- "position_id": common.Int64All(data["position_id"]),
|
|
|
- "change_field": "trailstatus",
|
|
|
- "change_type": "基本信息变更",
|
|
|
- "old_value": "商机线索",
|
|
|
- "new_value": "流失",
|
|
|
- "createtime": nowTime,
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
- "operator_id": -1,
|
|
|
- })
|
|
|
- }
|
|
|
- updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ 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": "商机线索",
|
|
|
- "new_value": "新增",
|
|
|
+ "old_value": "无意向客户",
|
|
|
+ "new_value": "商机线索",
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"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" {
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else if trailstatus != "01" {
|
|
|
+ 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,
|
|
|
+ })
|
|
|
updateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": positionId,
|
|
@@ -754,16 +816,21 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("trailstatusTime ", trailstatusTime)
|
|
|
+ log.Println("trailstatusTimes.Unix() ", trailstatusTimes.Unix(), time.Now().Unix()-trailstatusTimes.Unix())
|
|
|
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" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
- "change_type": "加入任务车",
|
|
|
- "new_value": "线索来源自动更新" + "-" + topname + "-" + subname,
|
|
|
- "createtime": nowTime,
|
|
|
- "BCPCID": common.GetRandom(32),
|
|
|
- "operator_id": -1,
|
|
|
- })
|
|
|
+ if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
|
|
|
+ } else {
|
|
|
+ updateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": common.If(trailstatus == "00" || is_assign == 0, 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)
|
|
|
old_name := common.ObjToString(data["name"])
|
|
@@ -791,7 +858,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_name != name && name != "" {
|
|
|
updateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "name",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_name != "", old_name, "/"),
|
|
@@ -804,7 +871,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_position != position && position != "" {
|
|
|
updateId7 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "position",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_position != "", old_position, "/"),
|
|
@@ -817,7 +884,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_department != department && department != "" {
|
|
|
updateId8 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "department",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_department != "", old_department, "/"),
|
|
@@ -830,7 +897,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_role != role && role != "" {
|
|
|
updateId9 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "role",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_role != "", old_role, "/"),
|
|
@@ -853,7 +920,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
new_area = strings.Join(new_area_arr, ",")
|
|
|
updateId10 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "follow_project_area",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_area != "", old_area, "/"),
|
|
@@ -866,7 +933,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_cluename != cluename && cluename != "" {
|
|
|
updateId11 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "cluename",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_cluename != "", old_cluename, "/"),
|
|
@@ -880,7 +947,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
if old_top_cluetype != top_cluetype {
|
|
|
updateId12 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
- "position_id": common.If(trailstatus == "00" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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": "top_cluetype",
|
|
|
"change_type": "基本信息变更",
|
|
|
"old_value": common.If(old_topname != "", old_topname, "/"),
|
|
@@ -893,7 +960,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
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" || is_assign == 0, positionId, common.Int64All(data["position_id"])),
|
|
|
+ "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_type": "基本信息变更",
|
|
|
"old_value": common.If(old_subname != "", old_subname, "/"),
|