|
@@ -443,7 +443,7 @@ func ReturnOpenSea() {
|
|
if trailstatus != "00" {
|
|
if trailstatus != "00" {
|
|
sql += " AND a.comeintime <?"
|
|
sql += " AND a.comeintime <?"
|
|
nt, _ := nexttime.(time.Time)
|
|
nt, _ := nexttime.(time.Time)
|
|
- intime := nt.Format(date.Date_Full_Layout)
|
|
|
|
|
|
+ intime = nt.Format(date.Date_Full_Layout)
|
|
argsSelect = append(argsSelect, intime)
|
|
argsSelect = append(argsSelect, intime)
|
|
}
|
|
}
|
|
log.Println(sql)
|
|
log.Println(sql)
|
|
@@ -465,15 +465,14 @@ func ReturnOpenSea() {
|
|
|
|
|
|
args2 := []interface{}{id}
|
|
args2 := []interface{}{id}
|
|
//获取跟进内容
|
|
//获取跟进内容
|
|
- sql1 := `SELECT COUNT(1) FROM dwd_f_crm_trail_content WHERE clue_id =?;`
|
|
|
|
sql2 := `SELECT COUNT(1) FROM dwd_f_crm_trail_content WHERE clue_id =? `
|
|
sql2 := `SELECT COUNT(1) FROM dwd_f_crm_trail_content WHERE clue_id =? `
|
|
if intime != "" {
|
|
if intime != "" {
|
|
sql2 += ` and createtime > ?`
|
|
sql2 += ` and createtime > ?`
|
|
args2 = append(args2, intime)
|
|
args2 = append(args2, intime)
|
|
}
|
|
}
|
|
//保留未跟进线索
|
|
//保留未跟进线索
|
|
- if c1, c2 := config.JianyuSubjectdb.CountBySql(sql1, id),
|
|
|
|
- config.JianyuSubjectdb.CountBySql(sql2, args2...); c1 != 0 && c2 > 0 {
|
|
|
|
|
|
+ log.Println("====<>", config.JianyuSubjectdb.CountBySql(sql2, args2...))
|
|
|
|
+ if config.JianyuSubjectdb.CountBySql(sql2, args2...) > 0 {
|
|
log.Println("不满足线索过滤", id)
|
|
log.Println("不满足线索过滤", id)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -493,38 +492,46 @@ func ReturnOpenSea() {
|
|
}
|
|
}
|
|
wh := strings.Join(whs, ",")
|
|
wh := strings.Join(whs, ",")
|
|
//退出私海
|
|
//退出私海
|
|
- count := config.JianyuSubjectdb.UpdateOrDeleteBySql(`delete from dwd_f_crm_private_sea where clue_id in (`+wh+`)`, ids...)
|
|
|
|
|
|
+ if len(ids) > 0 {
|
|
|
|
+ config.JianyuSubjectdb.UpdateOrDeleteBySql(`delete from dwd_f_crm_private_sea where clue_id in (`+wh+`)`, ids...)
|
|
|
|
+ //改线索表 职位id 坐席号 弄成空 分配状态改成未分配
|
|
|
|
+ up1 := config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET seatNumber ='',position_id=0,is_assign=0 WHERE id in (`+wh+`)`, ids...)
|
|
|
|
+ if up1 == -1 {
|
|
|
|
+ log.Println("修改记录失败", `UPDATE dwd_f_crm_clue_info SET seatNumber ='',position_id=0,is_assign=0 WHERE id in (`+wh+`)`, ids)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//进入公海
|
|
//进入公海
|
|
- config.JianyuSubjectdb.InsertIgnoreBatch("dwd_f_crm_open_sea", []string{"clue_id", "comeintime", "comeinsource"}, args)
|
|
|
|
- //改线索表 职位id 坐席号 弄成空 分配状态改成未分配
|
|
|
|
- up1 := config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET seatNumber ='',position_id=0,is_assign=0 WHERE id in (`+wh+`)`, ids...)
|
|
|
|
- if up1 == -1 {
|
|
|
|
- log.Println("修改记录失败", `UPDATE dwd_f_crm_clue_info SET seatNumber ='',position_id=0,is_assign=0 WHERE id in (`+wh+`)`, ids)
|
|
|
|
|
|
+ if len(args) > 0 {
|
|
|
|
+ config.JianyuSubjectdb.InsertIgnoreBatch("dwd_f_crm_open_sea", []string{"clue_id", "comeintime", "comeinsource"}, args)
|
|
}
|
|
}
|
|
|
|
+
|
|
// 添加线索修改记录
|
|
// 添加线索修改记录
|
|
|
|
|
|
//线索状态变更记录
|
|
//线索状态变更记录
|
|
- i1, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_field", "change_type", "old_value", "new_value", "createtime", "operator_id"}, changeArgs1)
|
|
|
|
- i2, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_field", "change_type", "old_value", "new_value", "createtime", "operator_id"}, changeArgs2)
|
|
|
|
- i3, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs3)
|
|
|
|
- i4, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs4)
|
|
|
|
- if i1 <= 0 || i2 <= 0 || i3 <= 0 || i4 <= 0 {
|
|
|
|
|
|
+ if len(changeArgs1) > 0 {
|
|
|
|
+ i1, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_field", "change_type", "old_value", "new_value", "createtime", "operator_id"}, changeArgs1)
|
|
if i1 <= 0 {
|
|
if i1 <= 0 {
|
|
log.Println("i1失败", changeArgs1)
|
|
log.Println("i1失败", changeArgs1)
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ if len(changeArgs1) > 0 {
|
|
|
|
+ i2, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_field", "change_type", "old_value", "new_value", "createtime", "operator_id"}, changeArgs2)
|
|
if i2 <= 0 {
|
|
if i2 <= 0 {
|
|
log.Println("i2失败", changeArgs2)
|
|
log.Println("i2失败", changeArgs2)
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ if len(changeArgs1) > 0 {
|
|
|
|
+ i3, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs3)
|
|
if i3 <= 0 {
|
|
if i3 <= 0 {
|
|
log.Println("i3失败", changeArgs3)
|
|
log.Println("i3失败", changeArgs3)
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ if len(changeArgs1) > 0 {
|
|
|
|
+ i4, _ := config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs4)
|
|
if i4 <= 0 {
|
|
if i4 <= 0 {
|
|
log.Println("i4失败", changeArgs4)
|
|
log.Println("i4失败", changeArgs4)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if count > 0 {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
return true
|
|
return true
|
|
}, sql, argsSelect...)
|
|
}, sql, argsSelect...)
|
|
}
|
|
}
|