|
@@ -182,7 +182,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
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, false
|
|
|
+ return true, true
|
|
|
}
|
|
|
if uId == "" { //没有进用户归集,等待进入,结束任务,放在下次继续执行
|
|
|
if isExists, _ := redis.Exists("bidx", "bidx_userId_"+userId); isExists {
|
|
@@ -218,13 +218,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
top_cluetype, sub_cluetype, level, topname, subname = getClueType(item, data, sourceCode, sourceId) //查留资来源名字
|
|
|
if topname == "市场活动" && item == "saleLeads" { //市场活动的不要
|
|
|
log.Println("市场活动留资过滤 ", userId, phone)
|
|
|
- return true, false
|
|
|
+ return true, true
|
|
|
}
|
|
|
if strings.HasPrefix(belong_to, "03") { //一切都好的不进
|
|
|
isOk := saveEverything(userId, phone, item, subname, sourceCode)
|
|
|
log.Println("渠道线索电销", userId, phone, item, subname, sourceCode)
|
|
|
if !isOk {
|
|
|
- return true, false
|
|
|
+ return true, true
|
|
|
}
|
|
|
}
|
|
|
follow_project_area = getAreaCode(userId) //关注项目区域
|
|
@@ -233,8 +233,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
log.Println("线索分配失败,线索过滤top_cluetype!!", item, uId, phone, userId)
|
|
|
return true, true
|
|
|
}
|
|
|
- position_id, seatNumber, saleName, saleData, pIsOk := autoDraw(level, cluename, phone, isGroup, isCommerce) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
|
|
|
+ position_id, seatNumber, saleName, saleData, pIsOk, isFreeze, isWait := autoDraw(level, cluename, phone, isGroup, isCommerce) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
|
|
|
log.Println("data -------", position_id, seatNumber, saleName)
|
|
|
+ if isWait {
|
|
|
+ return true, false
|
|
|
+ }
|
|
|
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 { //已存在,走更新
|
|
@@ -244,7 +247,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
}
|
|
|
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, level, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce, pIsOk)
|
|
|
} else { //不存在走新增
|
|
|
- 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, remark, keyword, belong_to, isGroup, isCommerce)
|
|
|
+ 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, remark, keyword, belong_to, isGroup, isCommerce, isFreeze)
|
|
|
if oks { //新增成功,销售分配次数+1
|
|
|
TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, position_id, level)
|
|
|
}
|
|
@@ -253,11 +256,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
log.Println("线索分配失败!!", item, position_id, seatNumber, uId, userId, phone)
|
|
|
return false, false
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return true, false
|
|
|
}
|
|
|
return true, true
|
|
|
}
|
|
|
|
|
|
-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, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce 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, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce int, isFreeze bool) 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)
|
|
@@ -271,12 +276,13 @@ 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,
|
|
|
"seatNumber": seatNumber,
|
|
|
"position_id": positionId,
|
|
|
- "is_assign": 1,
|
|
|
+ "is_assign": common.If(isFreeze, -3, 1),
|
|
|
"comeintime": nowTime,
|
|
|
"createtime": nowTime,
|
|
|
"updatetime": nowTime,
|
|
@@ -301,6 +307,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"company_nature": isGroup,
|
|
|
"company_verification": isCommerce,
|
|
|
"remark": remark,
|
|
|
+ "FREEZE_TIME": nowTime,
|
|
|
})
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
@@ -364,6 +371,20 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
|
})
|
|
|
+ //冻结处理
|
|
|
+ if isFreeze {
|
|
|
+ TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
+ "createtime": nowTime,
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
+ "operator_id": -1,
|
|
|
+ "clue_id": clueId,
|
|
|
+ "position_id": positionId,
|
|
|
+ "change_type": "线索冻结",
|
|
|
+ "new_value": "线索冻结",
|
|
|
+ })
|
|
|
+ //消息发送
|
|
|
+ AssFail(positionId, cluename, phone)
|
|
|
+ }
|
|
|
return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
|
|
|
}) {
|
|
|
log.Println("线索分配成功")
|