|
@@ -15,103 +15,10 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
|
)
|
|
|
|
|
|
-// 未支付订单 30分钟一次
|
|
|
-func orders() {
|
|
|
- //一个小时未支付进入线索 A
|
|
|
- log.Println("未支付订单定时任务开始")
|
|
|
- lastOrderId := cfg.LastOrderId
|
|
|
- selectTimeStart := time.Unix(time.Now().Unix()-7200, 0).Format(date.Date_Full_Layout)
|
|
|
- selectTimeEnd := time.Unix(time.Now().Unix()-3600, 0).Format(date.Date_Full_Layout)
|
|
|
- sql := fmt.Sprintf(`select * from dataexport_order where create_time <= "%s" and create_time >= "%s" and id > %s`, selectTimeEnd, selectTimeStart, fmt.Sprint(lastOrderId))
|
|
|
- data := Mysql.SelectBySql(sql)
|
|
|
- if data != nil && *data != nil && len(*data) > 0 {
|
|
|
- for _, v := range *data {
|
|
|
- order_status := common.IntAll(v["order_status"])
|
|
|
- is_backstage_order := common.IntAll(v["is_backstage_order"])
|
|
|
- product_type_str1 := `"大会员","VIP订阅","数据流量包","历史数据"`
|
|
|
- product_type := common.ObjToString(v["product_type"])
|
|
|
- if order_status == 0 && is_backstage_order == 0 && strings.Contains(product_type_str1, product_type) {
|
|
|
- ok1, _ := FormatData(v, "orders")
|
|
|
- if !ok1 {
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- cfg.LastOrderId = common.IntAll(v["id"])
|
|
|
- }
|
|
|
- }
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
- log.Println("未支付订单定时任务结束")
|
|
|
-}
|
|
|
-
|
|
|
-// 新注册用户 5分钟一次
|
|
|
-func users() {
|
|
|
- //判断节假日
|
|
|
- runOk := getRunOk()
|
|
|
- if !runOk {
|
|
|
- log.Println("不是工作日,任务暂停")
|
|
|
- return
|
|
|
- }
|
|
|
- //新用户注册后5分钟内进入线索 C
|
|
|
- log.Println("新注册用户定时任务开始")
|
|
|
- selectTimeEnd := cfg.LastUserId
|
|
|
- sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where createtime > "%s" and source = "0101" and status != 2`, selectTimeEnd)
|
|
|
- data := TiDb.SelectBySql(sql)
|
|
|
- if data != nil && *data != nil && len(*data) > 0 {
|
|
|
- for k, v := range *data {
|
|
|
- createtime := common.ObjToString(v["createtime"])
|
|
|
- FormatData(v, "users")
|
|
|
- if k == len(*data)-1 {
|
|
|
- cfg.LastUserId = createtime
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
- log.Println("新注册用户定时任务结束")
|
|
|
-}
|
|
|
-
|
|
|
-// 留资 5分钟一次
|
|
|
-func saleLeads() {
|
|
|
- //判断节假日
|
|
|
- runOk := getRunOk()
|
|
|
- if !runOk {
|
|
|
- log.Println("不是工作日,任务暂停")
|
|
|
- return
|
|
|
- }
|
|
|
- //留资后5分钟内进入线索
|
|
|
- //分为免费留资和付费留资 付费B 免费C
|
|
|
- log.Println("用户留资定时任务开始")
|
|
|
- session := Mgo.GetMgoConn()
|
|
|
- lastId := cfg.LastId
|
|
|
- defer func() {
|
|
|
- Mgo.DestoryMongoConn(session)
|
|
|
- }()
|
|
|
- query := map[string]interface{}{}
|
|
|
- if lastId != "" {
|
|
|
- query["_id"] = map[string]interface{}{"$gt": mongodb.StringTOBsonId(lastId)}
|
|
|
- }
|
|
|
- log.Println("query :", query)
|
|
|
- iter := session.DB(cfg.Mgo.DbName).C("saleLeads").Find(&query).Sort("_id").Iter()
|
|
|
- thisData := map[string]interface{}{}
|
|
|
- for {
|
|
|
- if !iter.Next(&thisData) {
|
|
|
- break
|
|
|
- }
|
|
|
- ok1, _ := FormatData(thisData, "saleLeads")
|
|
|
- if !ok1 {
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
- break
|
|
|
- }
|
|
|
- cfg.LastId = mongodb.BsonIdToSId(thisData["_id"])
|
|
|
- }
|
|
|
- common.WriteSysConfig(&cfg)
|
|
|
- log.Println("用户留资定时任务结束")
|
|
|
-}
|
|
|
-
|
|
|
func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
userId, uId, positionId, source, cluename, phone, sourceCode, keyword := common.ObjToString(data["user_id"]), "", "", "", "", "", "", []string{}
|
|
|
role, industry, department, departments, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", "", ""
|
|
|
- query, topname, subname, belong_to, sourceName, remark := map[string]interface{}{}, "", "", "01", "", ""
|
|
|
+ query, topname, subname, belong_to, sourceName, remark, sourceId := map[string]interface{}{}, "", "", "01", "", "", int64(0)
|
|
|
nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
if item == "orders" { //订单
|
|
|
if !mongodb.IsObjectIdHex(userId) {
|
|
@@ -216,8 +123,13 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
userId = common.ObjToString((*userInfo)["userid"])
|
|
|
}
|
|
|
} else {
|
|
|
- log.Println("不是剑鱼用户留资,等待用户")
|
|
|
- return false, false
|
|
|
+ if sourceCode == "report_retention" || sourceCode == "marketing_retention" {
|
|
|
+ log.Println("不是剑鱼用户留资,等待用户", phone)
|
|
|
+ return false, false
|
|
|
+ } else if remark != "" {
|
|
|
+ log.Println("留资source过滤", phone, sourceCode)
|
|
|
+ return true, true
|
|
|
+ }
|
|
|
}
|
|
|
} else if item == "eventReg" { //渠道
|
|
|
userId = common.ObjToString(data["userid"])
|
|
@@ -250,8 +162,20 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
if role == "集成商" || role == "设计院" {
|
|
|
role = "其他-" + role
|
|
|
}
|
|
|
+ } else if item == "readClue" {
|
|
|
+ userId = common.ObjToString(data["userId"])
|
|
|
+ query["userid"] = userId
|
|
|
+ userInfo := TiDb.FindOne("dwd_f_userbase_baseinfo", query, "", "")
|
|
|
+ if userInfo != nil && len(*userInfo) > 0 {
|
|
|
+ uId = common.ObjToString((*userInfo)["uid"])
|
|
|
+ source = common.ObjToString((*userInfo)["source"])
|
|
|
+ belong_to = common.ObjToString((*userInfo)["belong_to"])
|
|
|
+ }
|
|
|
+ // cluename = common.ObjToString(data["companyName"])
|
|
|
+ phone = common.ObjToString(data["phone"])
|
|
|
+ sourceId = common.Int64All(data["sourceId"])
|
|
|
}
|
|
|
- if cluename == "" && item != "message" && item != "orders" {
|
|
|
+ if cluename == "" && item != "message" && item != "orders" && item != "readClue" {
|
|
|
cluename = phone
|
|
|
}
|
|
|
isGroup, isCommerce := GetCompanyType(cluename) //判断是否集团公司、工商库
|
|
@@ -291,7 +215,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
|
|
|
name = common.ObjToString(sdata["name"])
|
|
|
}
|
|
|
}
|
|
|
- top_cluetype, sub_cluetype, level, topname, subname = getClueType(item, data, sourceCode) //查留资来源名字
|
|
|
+ top_cluetype, sub_cluetype, level, topname, subname = getClueType(item, data, sourceCode, sourceId) //查留资来源名字
|
|
|
if topname == "市场活动" && item == "saleLeads" {
|
|
|
log.Println("市场活动留资过滤 ", userId, phone)
|
|
|
return true, false
|