|
@@ -156,19 +156,11 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
|
|
|
}
|
|
|
|
|
|
//pc端招标订阅
|
|
|
-func pcSetUserKeys(user map[string]interface{}, shareid string) (map[string]interface{}, string, string) {
|
|
|
+func pcSetUserKeys(user map[string]interface{}, shareid, pccodepre string) (map[string]interface{}, string, string) {
|
|
|
result := "fail"
|
|
|
subkey := redis.Get("sso", "pc_subscribe_"+shareid)
|
|
|
keys := strings.Split(fmt.Sprint(subkey), ";")
|
|
|
- shareData := redis.Get("sso", "p_shareData_"+shareid)
|
|
|
- infoData := map[string]interface{}{}
|
|
|
- tmp, _ := json.Marshal(shareData)
|
|
|
- json.Unmarshal(tmp, &infoData)
|
|
|
- var pccodepre = ""
|
|
|
if subkey != nil {
|
|
|
- if len(infoData) > 0 && infoData["action"] != nil {
|
|
|
- pccodepre = util.ObjToString(infoData["action"])
|
|
|
- }
|
|
|
if o_jy, ok := user["o_jy"].(map[string]interface{}); ok {
|
|
|
if tmp, ok := o_jy["a_key"].([]interface{}); ok {
|
|
|
if len(tmp)+len(keys) <= 10 {
|
|
@@ -235,18 +227,10 @@ func pcSetUserKeys(user map[string]interface{}, shareid string) (map[string]inte
|
|
|
}
|
|
|
return user, result, fmt.Sprint(subkey)
|
|
|
}
|
|
|
-func saveUser(u *UserInfo, source string) (bool, string, string) {
|
|
|
+func saveUser(u *UserInfo, source, pre string) (bool, string, string) {
|
|
|
defer util.Catch()
|
|
|
pcresult := "" //pc订阅结果
|
|
|
subkey := "" //pc订阅关键词
|
|
|
- pre := "0"
|
|
|
- shareData := redis.Get("sso", "p_shareData_"+source)
|
|
|
- infoData := map[string]interface{}{}
|
|
|
- tmp, _ := json.Marshal(shareData)
|
|
|
- json.Unmarshal(tmp, &infoData)
|
|
|
- if len(infoData) > 0 && infoData["action"] != nil {
|
|
|
- pre = util.ObjToString(infoData["action"])
|
|
|
- }
|
|
|
log.Println("保存用户:", subkey)
|
|
|
fg := false
|
|
|
tuser, ok := tools.MQFW.FindOneByField("user", `{"s_unionid":"`+u.UnionId+`","i_appid":2}`, `{"_id":1,"s_m_openid":1,"o_jy":1}`)
|
|
@@ -284,7 +268,7 @@ func saveUser(u *UserInfo, source string) (bool, string, string) {
|
|
|
}
|
|
|
}
|
|
|
if pre == "11" || pre == "12" || pre == "19" { //11pc订阅,12pc搜索关键词
|
|
|
- newUser, pcresult, subkey = pcSetUserKeys(newUser, source)
|
|
|
+ newUser, pcresult, subkey = pcSetUserKeys(newUser, source, pre)
|
|
|
newUser["i_ts_guide"] = 1 //pc订阅关键词,不再走向导页
|
|
|
oj := newUser["o_jy"].(map[string]interface{})
|
|
|
oj["i_mode"] = 1
|
|
@@ -322,7 +306,7 @@ func saveUser(u *UserInfo, source string) (bool, string, string) {
|
|
|
}, false, false)
|
|
|
fg = true
|
|
|
} else { //针对取消关注的用户,关键词设置
|
|
|
- *tuser, pcresult, subkey = pcSetUserKeys(*tuser, source)
|
|
|
+ *tuser, pcresult, subkey = pcSetUserKeys(*tuser, source, pre)
|
|
|
if subkey != "" {
|
|
|
if pre == "11" || pre == "12" || pre == "19" { //11pc订阅,12pc搜索关键词
|
|
|
tools.MQFW.Update("user",
|
|
@@ -449,7 +433,7 @@ func Subscribe(w ResponseWriter, r *Request) {
|
|
|
if time.Now().After(time.Unix(config.ZqLuckdraw.StartDate, 0)) && time.Now().Before(time.Unix(config.ZqLuckdraw.EndDate, 0)) {
|
|
|
welcomemsg = config.ZqLuckdraw.Welcomemsg
|
|
|
}
|
|
|
- if b, pcresult, subkey := saveUser(user, source); b {
|
|
|
+ if b, pcresult, subkey := saveUser(user, source, pccodepre); b {
|
|
|
//pccodepre := "0" //分享过来source为空
|
|
|
//if len(source) > 3 {
|
|
|
// pccodepre = source[0:2]
|
|
@@ -598,18 +582,8 @@ func Subscribe(w ResponseWriter, r *Request) {
|
|
|
func saveUserLog(shareId, openid string) {
|
|
|
defer util.Catch()
|
|
|
date := time.Now()
|
|
|
- //var w ResponseWriter
|
|
|
- //var r *Request
|
|
|
- userData := redis.Get("sso", "p_userdata_"+shareId)
|
|
|
- //openid := r.FromUserName
|
|
|
- shareData := redis.Get("sso", "p_shareData_"+shareId)
|
|
|
- infoData := map[string]interface{}{}
|
|
|
+ userData := redis.Get("sso", "p_shareData_"+shareId)
|
|
|
var pccodepre = ""
|
|
|
- tmp, _ := json.Marshal(shareData)
|
|
|
- json.Unmarshal(tmp, &infoData)
|
|
|
- if len(infoData) > 0 && infoData["action"] != nil {
|
|
|
- pccodepre = util.ObjToString(infoData["action"])
|
|
|
- }
|
|
|
user, _ := Mux.GetUserInfo(openid)
|
|
|
nickname := user.Nickname
|
|
|
province := user.Province
|
|
@@ -626,6 +600,8 @@ func saveUserLog(shareId, openid string) {
|
|
|
infoData := map[string]interface{}{}
|
|
|
tmp, _ := json.Marshal(userData)
|
|
|
json.Unmarshal(tmp, &infoData)
|
|
|
+ //log.Println("weixinuserdata:", infoData)
|
|
|
+ pccodepre = util.ObjToString(infoData["action"])
|
|
|
model = util.ObjToString(infoData["RModule"])
|
|
|
referer = util.ObjToString(infoData["RReferer"])
|
|
|
usersource = util.ObjToString(infoData["RSource"])
|
|
@@ -692,7 +668,7 @@ func SaveAbnormal(openid string) {
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
} else {
|
|
|
- saveUser(user, "")
|
|
|
+ saveUser(user, "", "")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -705,26 +681,21 @@ func ScanHandler(w ResponseWriter, r *Request) {
|
|
|
defer util.Catch()
|
|
|
openid := r.FromUserName
|
|
|
m, b := tools.MQFW.FindOneByField("user", `{"s_m_openid":"`+openid+`"}`, `{"_id":1,"s_headimage":1,"o_jy":1}`)
|
|
|
- //data, _ := json.Marshal(r)
|
|
|
- //log.Println("SCAN:", openid, string(data), b)
|
|
|
- //redis.Put("sso", "p_usershare_"+r.EventKey, openid, 600)
|
|
|
shareData := redis.Get("sso", "p_shareData_"+r.EventKey)
|
|
|
infoData := map[string]interface{}{}
|
|
|
tmp, _ := json.Marshal(shareData)
|
|
|
json.Unmarshal(tmp, &infoData)
|
|
|
- //log.Println(shareData, "--00--", infoData)
|
|
|
if b {
|
|
|
pccodepre := "0"
|
|
|
if len(r.EventKey) > 1 {
|
|
|
pccodepre = util.ObjToString(infoData["action"])
|
|
|
}
|
|
|
- //log.Println("pccodepre:", pccodepre)
|
|
|
user, err := Mux.GetUserInfo(openid)
|
|
|
if *m == nil {
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
} else {
|
|
|
- if b, _, _ := saveUser(user, r.EventKey); b {
|
|
|
+ if b, _, _ := saveUser(user, r.EventKey, pccodepre); b {
|
|
|
url := fmt.Sprintf(config.Sysconfig["proxysess"].(string), se.EncodeString(openid+","+user.UnionId+","+strconv.Itoa(int(time.Now().Unix()))+",rssset"))
|
|
|
w.ReplyText(fmt.Sprintf(config.Sysconfig["welcomemsg"].(string), url))
|
|
|
}
|
|
@@ -759,7 +730,7 @@ func ScanHandler(w ResponseWriter, r *Request) {
|
|
|
}
|
|
|
}
|
|
|
} else if pccodepre == "11" || pccodepre == "12" || pccodepre == "19" { //101pc订阅,102pc搜索关键词
|
|
|
- pcUser, pcresult, subkey := pcSetUserKeys(*m, r.EventKey)
|
|
|
+ pcUser, pcresult, subkey := pcSetUserKeys(*m, r.EventKey, pccodepre)
|
|
|
go tools.MQFW.Update("user", &map[string]interface{}{
|
|
|
"s_m_openid": openid,
|
|
|
}, &map[string]interface{}{
|