|
@@ -25,24 +25,31 @@ import (
|
|
|
func everythingSync() {
|
|
|
lastEverythingTime := cfg.LastEverythingTime
|
|
|
nowTime := time.Now().Format(dates.Date_Full_Layout)
|
|
|
- sql := fmt.Sprintf(`select * from user_source where channel_code = "JyChCoopA" and create_time > "%s" order by create_time asc`, lastEverythingTime)
|
|
|
+ codeArr := []string{}
|
|
|
+ if len(UserChannel) > 0 {
|
|
|
+ for i, _ := range UserChannel {
|
|
|
+ codeArr = append(codeArr, fmt.Sprintf(`"%s"`, i))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(`select * from user_source where channel_code in (%s) and create_time > "%s" order by create_time asc`, strings.Join(codeArr, ","), lastEverythingTime)
|
|
|
log.Println("三方渠道数据定时任务开始", sql)
|
|
|
data := ThirdParty.SelectBySql(sql)
|
|
|
if data != nil && *data != nil && len(*data) > 0 {
|
|
|
for _, v := range *data {
|
|
|
+ channel_code := gconv.String("channel_code")
|
|
|
+ channelName := UserChannel[channel_code]
|
|
|
user_id := common.ObjToString(v["user_id"])
|
|
|
position_id := common.Int64All(v["position_id"])
|
|
|
phone := common.ObjToString(v["phone"])
|
|
|
state := common.IntAll(v["state"])
|
|
|
user_mold, is_assign, is_transfer, last_login_time, registe_time, mailbox, source, clueId, order_type := 4, 0, 0, "", "", "", "", int64(0), ""
|
|
|
- owner, sales_lead_phone, sales_ent_name, sales_position, sales_dep, data_request, unique_id, belongTo, sales_leads_source := "", "", "", "", "", "", "", "", ""
|
|
|
+ owner, sales_lead_phone, sales_ent_name, sales_position, sales_dep, data_request, sales_leads_source := "", "", "", "", "", "", ""
|
|
|
cData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if cData != nil {
|
|
|
is_assign = common.IntAll((*cData)["is_assign"])
|
|
|
is_transfer = common.IntAll((*cData)["is_transfer"])
|
|
|
clueId = common.Int64All((*cData)["id"])
|
|
|
}
|
|
|
- //
|
|
|
udata := TiDb.FindOne("dwd_f_userbase_baseinfo", map[string]interface{}{"userid": user_id}, "", "")
|
|
|
if udata != nil {
|
|
|
userSource := common.ObjToString((*udata)["source"])
|
|
@@ -98,42 +105,20 @@ func everythingSync() {
|
|
|
}
|
|
|
}
|
|
|
if state == 1 {
|
|
|
- sales_leads_source = "一切都好登录"
|
|
|
+ sales_leads_source = fmt.Sprintf("%s登录", channelName)
|
|
|
if is_assign == 1 || is_transfer == 1 || owner != "" {
|
|
|
user_mold = 1
|
|
|
} else {
|
|
|
user_mold = 2
|
|
|
}
|
|
|
} else if state == 2 {
|
|
|
- sales_leads_source = "一切都好注册"
|
|
|
+ sales_leads_source = fmt.Sprintf("%s注册", channelName)
|
|
|
if is_assign == 1 || is_transfer == 1 || owner != "" {
|
|
|
user_mold = 3
|
|
|
} else {
|
|
|
user_mold = 4
|
|
|
}
|
|
|
}
|
|
|
- if owner == "" && unique_id != "" && belongTo == "市场部" {
|
|
|
- token := getToken()
|
|
|
- if token != "" {
|
|
|
- sss := url.QueryEscape("合作渠道一切都好")
|
|
|
- urls := `https://a1.7x24cc.com/commonInte?flag=1008&account=N000000029739&accessToken=` + token + `&cusObj={"unique_id":"` + unique_id + `","empNo":"8049","owner":"8049","source":"` + sss + `"}&dbType=0001`
|
|
|
- bs, err := doGet(urls)
|
|
|
- if err != nil {
|
|
|
- log.Println("调用接口失败", unique_id, err)
|
|
|
- }
|
|
|
- resMap := common.StringToMap(string(bs))
|
|
|
- if resMap["success"] != nil && resMap["success"].(bool) {
|
|
|
- /*ok := TiDbData.Update("customer", map[string]interface{}{"unique_id": unique_id}, map[string]interface{}{"empNo": "8049", "owner": "8049", "source": "合作渠道一切都好"})
|
|
|
- if ok {
|
|
|
- log.Println("更新成功", unique_id)
|
|
|
- } else {
|
|
|
- log.Println("更新失败", unique_id)
|
|
|
- }*/
|
|
|
- } else {
|
|
|
- log.Println("调用接口失败!!", unique_id)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
if ThirdParty.Count("user_channel_info", map[string]interface{}{"user_id": user_id}) > 0 {
|
|
|
ThirdParty.Update("user_channel_info", map[string]interface{}{"user_id": user_id}, map[string]interface{}{
|
|
|
"user_mold": user_mold,
|
|
@@ -175,7 +160,7 @@ func everythingSync() {
|
|
|
"clue_id": clueId,
|
|
|
"position_id": common.If(position_id > 0, position_id, -1),
|
|
|
"change_type": "退出公海",
|
|
|
- "new_value": "通过合作渠道一切就好" + fmt.Sprint(common.If(user_mold == 1 || user_mold == 2, "登录", "注册")),
|
|
|
+ "new_value": fmt.Sprintf("通过合作渠道%s", channelName) + fmt.Sprint(common.If(user_mold == 1 || user_mold == 2, "登录", "注册")),
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|
|
@@ -188,10 +173,13 @@ func everythingSync() {
|
|
|
log.Println("三方渠道数据定时任务结束")
|
|
|
}
|
|
|
|
|
|
-func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
|
|
|
+func saveEverything(user_id, phone, item, sourceName, sourceCode, channelName string) bool {
|
|
|
+ if channelName == "" {
|
|
|
+ channelName = "一切都好"
|
|
|
+ }
|
|
|
nowTime, isOk := time.Now().Format(dates.Date_Full_Layout), false
|
|
|
user_mold, is_assign, is_transfer, last_login_time, registe_time, mailbox, source, order_type, sales_leads_source := 4, 0, 0, "", "", "", "", "", ""
|
|
|
- owner, sales_lead_phone, sales_ent_name, sales_position, sales_dep, data_request, unique_id, belongTo, clueId, position_id := "", "", "", "", "", "", "", "", int64(0), int64(0)
|
|
|
+ owner, sales_lead_phone, sales_ent_name, sales_position, sales_dep, data_request, clueId, position_id := "", "", "", "", "", "", int64(0), int64(0)
|
|
|
cData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if cData != nil {
|
|
|
is_assign = common.IntAll((*cData)["is_assign"])
|
|
@@ -199,11 +187,10 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
|
|
|
clueId = common.Int64All((*cData)["is_transfer"])
|
|
|
position_id = common.Int64All((*cData)["position_id"])
|
|
|
}
|
|
|
- /*cuData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
|
|
|
+ cuData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
|
|
|
if cuData != nil {
|
|
|
- unique_id = common.ObjToString((*cuData)["unique_id"])
|
|
|
owner = common.ObjToString((*cuData)["owner"])
|
|
|
- }*/
|
|
|
+ }
|
|
|
dData := Mysql.Find("dataexport_order", map[string]interface{}{"user_id": user_id}, "", "", -1, -1)
|
|
|
if dData != nil && len(*dData) > 0 {
|
|
|
pMap := map[string]string{}
|
|
@@ -262,7 +249,7 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
|
|
|
} else {
|
|
|
user_mold = 2
|
|
|
}
|
|
|
- if owner == "" && unique_id != "" && belongTo == "市场部" {
|
|
|
+ /*if owner == "" && unique_id != "" && belongTo == "市场部" {
|
|
|
token := getToken()
|
|
|
if token != "" {
|
|
|
sss := url.QueryEscape("合作渠道一切都好")
|
|
@@ -283,7 +270,7 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
|
|
|
log.Println("调用接口失败!!", unique_id)
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
if ThirdParty.Count("user_channel_info", map[string]interface{}{"user_id": user_id}) > 0 {
|
|
|
ThirdParty.Update("user_channel_info", map[string]interface{}{"user_id": user_id}, map[string]interface{}{
|
|
|
"user_mold": user_mold,
|
|
@@ -324,7 +311,7 @@ func saveEverything(user_id, phone, item, sourceName, sourceCode string) bool {
|
|
|
"clue_id": clueId,
|
|
|
"position_id": common.If(position_id > 0, position_id, -1),
|
|
|
"change_type": "退出公海",
|
|
|
- "new_value": "通过合作渠道一切就好登录",
|
|
|
+ "new_value": fmt.Sprintf("通过合作渠道%s登录", channelName),
|
|
|
"createtime": nowTime,
|
|
|
"BCPCID": common.GetRandom(32),
|
|
|
"operator_id": -1,
|