|
@@ -257,6 +257,15 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
return false, false
|
|
return false, false
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ if isFreeze {
|
|
|
|
+ //达上限放公海处理
|
|
|
|
+ uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
|
|
|
|
+ if uCount == nil || len(*uCount) == 0 { //已存在,走更新
|
|
|
|
+ oks = SaveClue0(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)
|
|
|
|
+ log.Println(oks)
|
|
|
|
+ }
|
|
|
|
+ return true, true
|
|
|
|
+ }
|
|
return true, false
|
|
return true, false
|
|
}
|
|
}
|
|
return true, true
|
|
return true, true
|
|
@@ -371,8 +380,8 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": -1,
|
|
"operator_id": -1,
|
|
})
|
|
})
|
|
- //冻结处理
|
|
|
|
- if isFreeze {
|
|
|
|
|
|
+ ////冻结处理
|
|
|
|
+ /*if isFreeze {
|
|
TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"createtime": nowTime,
|
|
"createtime": nowTime,
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
@@ -384,7 +393,8 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
})
|
|
})
|
|
//消息发送
|
|
//消息发送
|
|
AssFail(positionId, cluename, phone)
|
|
AssFail(positionId, cluename, phone)
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
+ AssFail(positionId, cluename, phone)
|
|
return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
|
|
return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
|
|
}) {
|
|
}) {
|
|
log.Println("线索分配成功")
|
|
log.Println("线索分配成功")
|
|
@@ -405,6 +415,98 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+func SaveClue0(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")
|
|
|
|
+ clueId, uodateId1, uodateId2, uodateId3 := int64(0), int64(0), int64(0), int64(0)
|
|
|
|
+ if TiDb.ExecTx("保存线索", func(tx *sql.Tx) bool {
|
|
|
|
+ keywords := ""
|
|
|
|
+ if sourceCode == "app_xzcyh" {
|
|
|
|
+ if len(keyword) > 0 && keyword[0] != "" {
|
|
|
|
+ keywords = strings.Join(keyword, ",")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if cluename == "" {
|
|
|
|
+ cluename = phone
|
|
|
|
+ }
|
|
|
|
+ clueId = TiDb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
|
+ "userid": userId,
|
|
|
|
+ "uid": uId,
|
|
|
|
+ "seatNumber": "",
|
|
|
|
+ "position_id": 0,
|
|
|
|
+ "is_assign": 0,
|
|
|
|
+ "comeintime": nowTime,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "updatetime": nowTime,
|
|
|
|
+ "cluename": cluename,
|
|
|
|
+ "top_cluetype": top_cluetype,
|
|
|
|
+ "sub_cluetype": sub_cluetype,
|
|
|
|
+ "trailstatus": "01",
|
|
|
|
+ "name": name,
|
|
|
|
+ "phone": phone,
|
|
|
|
+ "position": position,
|
|
|
|
+ "department": common.If(sourceCode == "app_xzcyh", departments, department),
|
|
|
|
+ "industry": industry,
|
|
|
|
+ "follow_project_area": follow_project_area,
|
|
|
|
+ "role": role,
|
|
|
|
+ "comeinsource_private": 2,
|
|
|
|
+ "business_scope": common.If(sourceCode == "app_xzcyh", keywords, nil),
|
|
|
|
+ "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,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_type": "创建线索",
|
|
|
|
+ "new_value": "系统自动创建",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId2 = 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": "",
|
|
|
|
+ "new_value": "/",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId3 = 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,
|
|
|
|
+ })
|
|
|
|
+ AssFail(positionId, cluename, phone)
|
|
|
|
+ return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1
|
|
|
|
+ }) {
|
|
|
|
+ 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
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("线索分配失败!!!", clueId, uodateId1, uodateId2, uodateId3, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
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, level string, positionId int64, source, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce int, pIsOk bool) 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, level string, positionId int64, source, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce int, pIsOk bool) bool {
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|