|
@@ -5,7 +5,6 @@ import (
|
|
"log"
|
|
"log"
|
|
"strings"
|
|
"strings"
|
|
"telemarketingEtl/config"
|
|
"telemarketingEtl/config"
|
|
- "telemarketingEtl/util"
|
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
@@ -130,18 +129,17 @@ func GetOpenSea() {
|
|
if userid == "" {
|
|
if userid == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- //根据userid获取线索id
|
|
|
|
- if oneClassA[userid] {
|
|
|
|
|
|
+ clubId := GetClueIdByUserId(userid)
|
|
|
|
+ if clubId == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- uuid := GetClueIdByUserId(userid)
|
|
|
|
- if uuid == "" {
|
|
|
|
|
|
+ //根据userid获取线索id
|
|
|
|
+ if oneClassA[clubId] {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- oneClassA[uuid] = true
|
|
|
|
-
|
|
|
|
|
|
+ oneClassA[clubId] = true
|
|
count++
|
|
count++
|
|
- if count%10 == 0 {
|
|
|
|
|
|
+ if count%100 == 0 {
|
|
log.Printf("已完成%d条数据\n", count)
|
|
log.Printf("已完成%d条数据\n", count)
|
|
}
|
|
}
|
|
thisData = map[string]interface{}{}
|
|
thisData = map[string]interface{}{}
|
|
@@ -186,14 +184,14 @@ func GetOpenSea() {
|
|
if userid == "" {
|
|
if userid == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- //根据userid获取线索id
|
|
|
|
- if oneClassA[userid] {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
clubId := GetClueIdByUserId(userid)
|
|
clubId := GetClueIdByUserId(userid)
|
|
if clubId == "" {
|
|
if clubId == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ //根据userid获取线索id
|
|
|
|
+ if oneClassA[clubId] {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
oneClassA[clubId] = true
|
|
oneClassA[clubId] = true
|
|
|
|
|
|
count++
|
|
count++
|
|
@@ -204,12 +202,12 @@ func GetOpenSea() {
|
|
}
|
|
}
|
|
//更新公海
|
|
//更新公海
|
|
AddOpenSea(oneClassA, 1, "A")
|
|
AddOpenSea(oneClassA, 1, "A")
|
|
- log.Println("一级公海 更新结束。")
|
|
|
|
//
|
|
//
|
|
oneClassB := map[string]bool{}
|
|
oneClassB := map[string]bool{}
|
|
|
|
+ vipendtime := t.AddDate(0, 0, -g.Cfg().MustGet(ctx, "classOneHighSeas_B").Int())
|
|
classB, ok := config.Mgo.Find("user", map[string]interface{}{
|
|
classB, ok := config.Mgo.Find("user", map[string]interface{}{
|
|
"l_vip_endtime": map[string]interface{}{
|
|
"l_vip_endtime": map[string]interface{}{
|
|
- "$gte": t.AddDate(0, 0, -g.Cfg().MustGet(ctx, "classOneHighSeas_B").Int()),
|
|
|
|
|
|
+ "$lt": vipendtime.Unix(),
|
|
},
|
|
},
|
|
"i_vip_status": map[string]interface{}{
|
|
"i_vip_status": map[string]interface{}{
|
|
"$gt": 0,
|
|
"$gt": 0,
|
|
@@ -219,16 +217,17 @@ func GetOpenSea() {
|
|
if classB != nil && ok && len(*classB) > 0 {
|
|
if classB != nil && ok && len(*classB) > 0 {
|
|
for _, v := range *classB {
|
|
for _, v := range *classB {
|
|
userid := mongodb.BsonIdToSId(v["_id"])
|
|
userid := mongodb.BsonIdToSId(v["_id"])
|
|
- if oneClassA[userid] {
|
|
|
|
|
|
+ clubId := GetClueIdByUserId(userid)
|
|
|
|
+ if oneClassA[clubId] {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- clubId := GetClueIdByUserId(userid)
|
|
|
|
oneClassB[clubId] = true
|
|
oneClassB[clubId] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
AddOpenSea(oneClassB, 1, "B")
|
|
AddOpenSea(oneClassB, 1, "B")
|
|
- oneClassC := GetOneSeaC()
|
|
|
|
|
|
+ oneClassC := GetOneSeaC(oneClassA, oneClassB)
|
|
AddOpenSea(oneClassC, 1, "C")
|
|
AddOpenSea(oneClassC, 1, "C")
|
|
|
|
+ log.Println("一级公海 更新结束。")
|
|
//
|
|
//
|
|
twoA, twoB, twoC, twoD := TwoOpenSea(oneClassA, oneClassB, oneClassC)
|
|
twoA, twoB, twoC, twoD := TwoOpenSea(oneClassA, oneClassB, oneClassC)
|
|
AddOpenSea(twoA, 2, "A")
|
|
AddOpenSea(twoA, 2, "A")
|
|
@@ -237,7 +236,9 @@ func GetOpenSea() {
|
|
AddOpenSea(twoD, 2, "D")
|
|
AddOpenSea(twoD, 2, "D")
|
|
//三级公海
|
|
//三级公海
|
|
ThreeOpenSea(oneClassA, oneClassB, oneClassC, twoA, twoB, twoC, twoD)
|
|
ThreeOpenSea(oneClassA, oneClassB, oneClassC, twoA, twoB, twoC, twoD)
|
|
|
|
+ // AddOpenSea(three, 3, "D")
|
|
//
|
|
//
|
|
|
|
+ Recycle()
|
|
log.Println("end")
|
|
log.Println("end")
|
|
}
|
|
}
|
|
|
|
|
|
@@ -298,6 +299,7 @@ func TwoOpenSea(oneClassA, oneClassB, oneClassC map[string]bool) (aMap, bMap, cM
|
|
if ct < 5 && ct >= 1 {
|
|
if ct < 5 && ct >= 1 {
|
|
dMap[clubId] = true
|
|
dMap[clubId] = true
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
// Check for errors during iteration
|
|
// Check for errors during iteration
|
|
err = rows.Err()
|
|
err = rows.Err()
|
|
@@ -309,38 +311,37 @@ func TwoOpenSea(oneClassA, oneClassB, oneClassC map[string]bool) (aMap, bMap, cM
|
|
|
|
|
|
// 三级公海:
|
|
// 三级公海:
|
|
// 最近30天内活跃天数=0天的客户。
|
|
// 最近30天内活跃天数=0天的客户。
|
|
-func ThreeOpenSea(oneA, oneB, oneC, twoA, twoB, twoC, twoD map[string]bool) {
|
|
|
|
|
|
+func ThreeOpenSea(oneA, oneB, oneC, twoA, twoB, twoC, twoD map[string]bool) map[string]bool {
|
|
|
|
+ m := map[string]bool{}
|
|
ctx := gctx.New()
|
|
ctx := gctx.New()
|
|
t := time.Now()
|
|
t := time.Now()
|
|
t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)
|
|
t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)
|
|
day := g.Cfg().MustGet(ctx, "classThreeHighSeaslastDay").Int()
|
|
day := g.Cfg().MustGet(ctx, "classThreeHighSeaslastDay").Int()
|
|
t = t.AddDate(0, 0, -day)
|
|
t = t.AddDate(0, 0, -day)
|
|
- start := util.GetObjectId(t.Unix())
|
|
|
|
- log.Println(t.Format(date.Date_Full_Layout), "~~")
|
|
|
|
|
|
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
|
|
+ ids := []interface{}{}
|
|
|
|
+
|
|
for _, v := range *l {
|
|
for _, v := range *l {
|
|
|
|
+ clubId := gconv.String(v["clue_id"])
|
|
userid := gconv.String(v["userid"])
|
|
userid := gconv.String(v["userid"])
|
|
- query := map[string]interface{}{
|
|
|
|
- "userid": userid,
|
|
|
|
- "_id": map[string]interface{}{
|
|
|
|
- "$gte": start,
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
- id := gconv.Int64(v["id"])
|
|
|
|
- clubId := gconv.String(v["id"])
|
|
|
|
- if r, ok := config.MgoLog.Find("subscribepay_logs", query, nil, `{"_id":1}`, false, 0, 1); ok && r != nil && len(*r) == 0 {
|
|
|
|
- if oneA[clubId] || oneB[clubId] || oneC[clubId] || twoA[clubId] || twoB[clubId] || twoC[clubId] || twoD[clubId] {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- config.JianyuSubjectdb.Update("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": id}, map[string]interface{}{
|
|
|
|
- "LEVEL": 3,
|
|
|
|
- "clue_level": "D",
|
|
|
|
- })
|
|
|
|
|
|
+ q := fmt.Sprintf("SELECT count(1) FROM dwd_f_userbase_visit_info WHERE createtime > '%s' AND contentnum =0 and userid = '%s'", t.Format(date.Date_Full_Layout), userid)
|
|
|
|
+ config.JianyuSubjectdb.SelectBySql(q)
|
|
|
|
+ if oneA[clubId] || oneB[clubId] || oneC[clubId] || twoA[clubId] || twoB[clubId] || twoC[clubId] || twoD[clubId] {
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ids = append(ids, clubId)
|
|
|
|
+ }
|
|
|
|
+ whs := []string{}
|
|
|
|
+ for i := 0; i < len(ids); i++ {
|
|
|
|
+ whs = append(whs, "?")
|
|
}
|
|
}
|
|
|
|
+ wh := strings.Join(whs, ",")
|
|
|
|
+ config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_open_sea SET level = 3,clue_level='D' WHERE clue_id in (`+wh+`)`, ids...)
|
|
return true
|
|
return true
|
|
- }, `select userid,uid,id from dwd_f_crm_clue_info where is_assign !=1`)
|
|
|
|
|
|
+ }, `SELECT a.clue_id,b.userid FROM dwd_f_crm_open_sea a LEFT JOIN dwd_f_crm_clue_info b ON a.clue_id=b.id`)
|
|
|
|
+ return m
|
|
}
|
|
}
|
|
|
|
|
|
// 根据mongodb userid 获取 线索id
|
|
// 根据mongodb userid 获取 线索id
|
|
@@ -361,8 +362,8 @@ func GetClueIdByUserId(userid string) (uuid string) {
|
|
func AddOpenSea(m map[string]bool, level int, clue_level string) {
|
|
func AddOpenSea(m map[string]bool, level int, clue_level string) {
|
|
// createtime := time.Now().Format(date.Date_Full_Layout)
|
|
// createtime := time.Now().Format(date.Date_Full_Layout)
|
|
if len(m) > 0 {
|
|
if len(m) > 0 {
|
|
- for _, v := range m {
|
|
|
|
- config.JianyuSubjectdb.Update("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": v}, map[string]interface{}{
|
|
|
|
|
|
+ for k, _ := range m {
|
|
|
|
+ config.JianyuSubjectdb.Update("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": k}, map[string]interface{}{
|
|
"clue_level": clue_level,
|
|
"clue_level": clue_level,
|
|
"LEVEL": level,
|
|
"LEVEL": level,
|
|
})
|
|
})
|
|
@@ -433,16 +434,21 @@ func ReturnOpenSea() {
|
|
"01": t.AddDate(0, 0, -businessLeads),
|
|
"01": t.AddDate(0, 0, -businessLeads),
|
|
"00": t,
|
|
"00": t,
|
|
} {
|
|
} {
|
|
- sql := `SELECT MAX(c.next_time) nexttime, b.id FROM dwd_f_crm_private_sea a
|
|
|
|
|
|
+ sql := `SELECT a.clue_id,a.position_id,a.seatNumber FROM dwd_f_crm_private_sea a
|
|
LEFT JOIN dwd_f_crm_clue_info b ON a.clue_id=b.id
|
|
LEFT JOIN dwd_f_crm_clue_info b ON a.clue_id=b.id
|
|
- LEFT JOIN dwd_f_crm_trail_content c ON b.id =c.clue_id
|
|
|
|
WHERE b.trailstatus =?`
|
|
WHERE b.trailstatus =?`
|
|
argsSelect := []interface{}{trailstatus}
|
|
argsSelect := []interface{}{trailstatus}
|
|
|
|
+
|
|
|
|
+ intime := ""
|
|
if trailstatus != "00" {
|
|
if trailstatus != "00" {
|
|
- sql += " AND c.createtime <? "
|
|
|
|
- argsSelect = append(argsSelect, nexttime)
|
|
|
|
|
|
+ sql += " AND a.comeintime <?"
|
|
|
|
+ nt, _ := nexttime.(time.Time)
|
|
|
|
+ intime := nt.Format(date.Date_Full_Layout)
|
|
|
|
+ argsSelect = append(argsSelect, intime)
|
|
}
|
|
}
|
|
- sql += " GROUP BY b.id"
|
|
|
|
|
|
+ log.Println(sql)
|
|
|
|
+ log.Println(argsSelect)
|
|
|
|
+ //
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
//1新增 2私海手动退回 3私海高意向客户自动退回 4私海意向客户退回 5私海潜在客户退回 6私海沉睡客户退回 7私海商机线索退回 8私海无意向客户退回
|
|
//1新增 2私海手动退回 3私海高意向客户自动退回 4私海意向客户退回 5私海潜在客户退回 6私海沉睡客户退回 7私海商机线索退回 8私海无意向客户退回
|
|
comeinsource := GetComeSource()[trailstatus]
|
|
comeinsource := GetComeSource()[trailstatus]
|
|
@@ -453,16 +459,32 @@ func ReturnOpenSea() {
|
|
changeArgs3 := []interface{}{}
|
|
changeArgs3 := []interface{}{}
|
|
changeArgs4 := []interface{}{}
|
|
changeArgs4 := []interface{}{}
|
|
for _, v := range *l {
|
|
for _, v := range *l {
|
|
- id := v["id"]
|
|
|
|
|
|
+ id := v["clue_id"] //
|
|
position_id := v["position_id"]
|
|
position_id := v["position_id"]
|
|
seatNumber := gconv.String(v["seatNumber"])
|
|
seatNumber := gconv.String(v["seatNumber"])
|
|
|
|
+
|
|
|
|
+ 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 =? `
|
|
|
|
+ if intime != "" {
|
|
|
|
+ sql2 += ` createime < ?`
|
|
|
|
+ args2 = append(args2, intime)
|
|
|
|
+ }
|
|
|
|
+ //保留未跟进线索
|
|
|
|
+ if c1, c2 := config.JianyuSubjectdb.CountBySql(sql1, id),
|
|
|
|
+ config.JianyuSubjectdb.CountBySql(sql2, args2...); c1 != 0 && c2 <= 0 {
|
|
|
|
+ log.Println("不满足线索过滤", id)
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
ids = append(ids, id)
|
|
ids = append(ids, id)
|
|
//
|
|
//
|
|
args = append(args, id, now, comeinsource)
|
|
args = append(args, id, now, comeinsource)
|
|
changeArgs1 = append(changeArgs1, id, position_id, "trailstatus", "线索状态变更", codeMap[trailstatus], "流失", now, -1)
|
|
changeArgs1 = append(changeArgs1, id, position_id, "trailstatus", "线索状态变更", codeMap[trailstatus], "流失", now, -1)
|
|
changeArgs2 = append(changeArgs2, id, position_id, "position_id", "所属人变更", GetPositionName(seatNumber), "/", now, -1)
|
|
changeArgs2 = append(changeArgs2, id, position_id, "position_id", "所属人变更", GetPositionName(seatNumber), "/", now, -1)
|
|
changeArgs3 = append(changeArgs3, id, position_id, "退出任务车", "未更新跟进记录自动退回公海", now, -1)
|
|
changeArgs3 = append(changeArgs3, id, position_id, "退出任务车", "未更新跟进记录自动退回公海", now, -1)
|
|
- changeArgs3 = append(changeArgs3, id, position_id, "退回公海", "未更新跟进记录自动退回公海", now, -1)
|
|
|
|
|
|
+ changeArgs4 = append(changeArgs3, id, position_id, "退回公海", "未更新跟进记录自动退回公海", now, -1)
|
|
|
|
|
|
}
|
|
}
|
|
whs := []string{}
|
|
whs := []string{}
|
|
@@ -475,15 +497,31 @@ func ReturnOpenSea() {
|
|
//进入公海
|
|
//进入公海
|
|
config.JianyuSubjectdb.InsertIgnoreBatch("dwd_f_crm_open_sea", []string{"clue_id", "comeintime", "comeinsource"}, args)
|
|
config.JianyuSubjectdb.InsertIgnoreBatch("dwd_f_crm_open_sea", []string{"clue_id", "comeintime", "comeinsource"}, args)
|
|
//改线索表 职位id 坐席号 弄成空 分配状态改成未分配
|
|
//改线索表 职位id 坐席号 弄成空 分配状态改成未分配
|
|
- config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_clue_info SET seatNumber ='',position_id=0,is_assign=0 WHERE id in (`+wh+`)`, ids...)
|
|
|
|
-
|
|
|
|
|
|
+ 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.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_field", "change_type", "old_value", "new_value", "createtime", "operator_id"}, changeArgs1)
|
|
|
|
- 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)
|
|
|
|
- config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs3)
|
|
|
|
- config.JianyuSubjectdb.InsertBatch("dwd_f_crm_clue_change_record", []string{"clue_id", "position_id", "change_type", "new_value", "createtime", "operator_id"}, changeArgs4)
|
|
|
|
|
|
+ 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 i1 <= 0 {
|
|
|
|
+ log.Println("i1失败", changeArgs1)
|
|
|
|
+ }
|
|
|
|
+ if i2 <= 0 {
|
|
|
|
+ log.Println("i2失败", changeArgs2)
|
|
|
|
+ }
|
|
|
|
+ if i3 <= 0 {
|
|
|
|
+ log.Println("i3失败", changeArgs3)
|
|
|
|
+ }
|
|
|
|
+ if i4 <= 0 {
|
|
|
|
+ log.Println("i4失败", changeArgs4)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if count > 0 {
|
|
if count > 0 {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
@@ -505,11 +543,15 @@ func GetComeSource() map[string]int {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func GetOneSeaC() map[string]bool {
|
|
|
|
|
|
+func GetOneSeaC(oneClassA, oneClassB map[string]bool) map[string]bool {
|
|
m := map[string]bool{}
|
|
m := map[string]bool{}
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
for _, v := range *l {
|
|
for _, v := range *l {
|
|
- m[gconv.String(v["clue_id"])] = true
|
|
|
|
|
|
+ clueid := gconv.String(v["clue_id"])
|
|
|
|
+ if oneClassA[clueid] || oneClassB[clueid] {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ m[clueid] = true
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
}, `select clue_id from dwd_f_crm_open_sea where comeinsource in(2,3,4)`)
|
|
}, `select clue_id from dwd_f_crm_open_sea where comeinsource in(2,3,4)`)
|
|
@@ -534,3 +576,51 @@ func GetPositionName(seatNumber string) string {
|
|
}
|
|
}
|
|
return ""
|
|
return ""
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//(4)回收站:
|
|
|
|
+//A.5个自然日内被销售人员手动退回公海的客户;
|
|
|
|
+//B.3个自然日内有过“已接听”的通话记录且仍处于“商机线索”状态下的客户。
|
|
|
|
+func Recycle() {
|
|
|
|
+ log.Println("回收站开始")
|
|
|
|
+ ctx := gctx.New()
|
|
|
|
+ t := time.Now()
|
|
|
|
+ t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)
|
|
|
|
+ handReturn := g.Cfg().MustGet(ctx, "handReturn").Int()
|
|
|
|
+ tA := t.AddDate(0, 0, -handReturn)
|
|
|
|
+ recycleB := g.Cfg().MustGet(ctx, "recycleB").Int()
|
|
|
|
+ tB := t.AddDate(0, 0, -recycleB)
|
|
|
|
+ for sql, _ := range map[string]interface{}{
|
|
|
|
+ fmt.Sprintf(`select id from dwd_f_crm_open_sea where comeinsource=%v and comeintime > "%s" ;`, 2, tA.Format(date.Date_Full_Layout)): 1,
|
|
|
|
+ fmt.Sprintf(`SELECT a.uid,b.phone,c.createTime,a.id FROM dwd_f_crm_clue_info a
|
|
|
|
+ LEFT JOIN dwd_f_userbase_contacts b ON b.baseinfo_id=a.uid
|
|
|
|
+ LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = b.phone
|
|
|
|
+ WHERE a.trailstatus=01 AND a.uid !="" AND b.phone IS NOT NULL AND c.State="dealing" AND c.createTime >"%s"
|
|
|
|
+ `, tB.Format(date.Date_Full_Layout)): 2,
|
|
|
|
+ } {
|
|
|
|
+ func(sql string) {
|
|
|
|
+ config.JianyuSubjectdb.SelectByBath(500, func(l *[]map[string]interface{}) bool {
|
|
|
|
+ ids := []interface{}{}
|
|
|
|
+ for _, v := range *l {
|
|
|
|
+ id := v["id"]
|
|
|
|
+ ids = append(ids, id)
|
|
|
|
+ }
|
|
|
|
+ whs := []string{}
|
|
|
|
+ for i := 0; i < len(ids); i++ {
|
|
|
|
+ whs = append(whs, "?")
|
|
|
|
+ }
|
|
|
|
+ wh := strings.Join(whs, ",")
|
|
|
|
+ config.JianyuSubjectdb.UpdateOrDeleteBySql(`UPDATE dwd_f_crm_open_sea SET level = 4 WHERE id in (`+wh+`)`, ids...)
|
|
|
|
+ return true
|
|
|
|
+ }, sql)
|
|
|
|
+ }(sql)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.Println("回收站结束")
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+dwd_f_crm_clue_info.uid trailstatus==01
|
|
|
|
+dwd_f_userbase_contacts.baseinfo_id ==dwd_f_crm_clue_info.uid
|
|
|
|
+ >> dwd_f_userbase_contacts.phone== Call_Accounting.voice_record.CalledNo &&State=="dealing"
|
|
|
|
+*/
|