wangshan 1 жил өмнө
parent
commit
d47f902dc0

+ 7 - 6
src/jfw/front/login.go

@@ -210,7 +210,7 @@ func (l *Login) Login() error {
 								"baseUserId": resp.Data.Id,
 								"positionId": l.GetSession("positionId"),
 							})
-                            return 2, true
+							return 2, true
 						}
 					}
 				} else {
@@ -247,17 +247,18 @@ func (l *Login) Login() error {
 		return 0, false
 	}()
 	if status >= 1 && isLogin {
+		status = 1
 		//登录source 更新 p414
-		channelCode, ckErr := l.Request.Cookie(jy.ChannelCookieName)
-		if ckErr != nil {
-			log.Println("获取 合作商 code 异常或 无合作商code:", qutil.ObjToString(l.GetSession("phone")))
-			channelCode.Value = "jy_pc"
+		channelCode := "jy_pc"
+		cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
+		if ckErr == nil {
+			channelCode = cc.Value
 		}
 		us := jy.UserSource{
 			UserId:           qutil.ObjToString(l.GetSession("userId")),
 			Phone:            qutil.ObjToString(l.GetSession("phone")),
 			State:            qutil.If(status == 2, status, 1).(int), //注册/登录标志 1:登录;2:注册
-			ChannelCode:      channelCode.Value,
+			ChannelCode:      channelCode,
 			EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
 			CreateTime:       time.Now().Format(time.DateTime),
 			LoginWay:         qutil.If(status == 1, status, 2).(int), //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录

+ 6 - 0
src/jfw/front/supsearch.go

@@ -571,10 +571,16 @@ func (p *Pcsearch) PcSearchIndex(module string) error {
 	p.T["isEntService"] = userInfo.EntService
 	p.T["vipBefore202209"] = userInfo.VipState > 0 && userInfo.VipStartData < util.Int64All(config.Sysconfig["contextOldVipLimit"]) //超级订阅 超强项目
 	//
+	cooperateCode := ""
 	if userId != "" {
 		//企业画像 权限
 		p.T["portraitpower"] = jylabutil.IsAuthorized(userId, "i_portraitpower")
+	} else {
+		if cc, err := p.GetCookie(jy.ChannelCookieName); err == nil {
+			cooperateCode = cc.Value
+		}
 	}
+	p.T["cooperateCode"] = cooperateCode
 	p.T["isLimit"] = isLimit
 	if module == "supsearch" {
 		p.T["simpleTemplateData"] = map[string]interface{}{

+ 1 - 20
src/jfw/front/websocket.go

@@ -144,26 +144,7 @@ func GetWsByCode(param []string) bool {
 				if ok := redis.Del("newother", fmt.Sprintf(jyutil.KeepLoginTimeKey, src)) && redis.Del("newother", fmt.Sprintf(jyutil.KeepLoginTimeKey, erStr)); !ok {
 					log.Println(fmt.Sprintf("%d 清除用户登录延期标识 异常", baseUserId))
 				}
-				////登录source 更新
-				//channelCode, ckErr := session.Request.Cookie(entity.ChannelCookieName)
-				//if ckErr != nil {
-				//    log.Println("获取 合作商 code 异常或 无合作商code:", qutil.ObjToString(l.GetSession("phone")))
-				//    channelCode.Value = "jy"
-				//}
-				//us := jy.UserSource{
-				//    UserId:           qutil.ObjToString(session.Get("userId")),
-				//    Phone:            qutil.ObjToString(session.Get("phone")),
-				//    State:            1, //注册/登录标志 1:登录;2:注册
-				//    ChannelCode:      channelCode.Value,
-				//    EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
-				//    CreateTime:       time.Now().Format(time.DateTime),
-				//    LoginWay:         qutil.If(status == 1, status, 2).(int), //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
-				//    Platform:         1,
-				//    Ip:               qutil.GetIp(l.Request),
-				//}
-				//go func(us jy.UserSource) {
-				//    jy.SaveUserSource(public.BaseMysql, jy.TableName, qutil.StructToMapMore(us))
-				//}(us)
+				//登录source 更新
 				//收到webSocket消息后,您无法设置cookie.一旦建立了webSocket连接,它就是一个开放的TCP套接字,协议不再是http,因此没有内置的方式来交换cookie.
 				//jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId)  不可用
 				//您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.

+ 21 - 21
src/jfw/modules/app/src/app/front/login.go

@@ -106,7 +106,7 @@ func (l *Login) Login() error {
 	}
 	returnSign := ""
 	userInfo := map[string]interface{}{}
-    status, state := func() (int, int) {
+	status, state := func() (int, int) {
 		nsqPath, _ := config.Sysconfig["nsq"].(string)
 		nsq_topic, _ := config.Sysconfig["nsq_topic"].(string)
 		reqType := l.GetString("reqType")
@@ -141,7 +141,7 @@ func (l *Login) Login() error {
 					"baseUserId": l.GetSession("base_user_id"),
 					"positionId": l.GetSession("positionId"),
 				})
-                return 1, 1
+				return 1, 1
 			}
 			return -1, -1 //用户名或密码不正确
 		} else if reqType == "signLogin" {
@@ -275,7 +275,7 @@ func (l *Login) Login() error {
 							"baseUserId": l.GetSession("base_user_id"),
 							"positionId": l.GetSession("positionId"),
 						})
-                        return 1, 3
+						return 1, 3
 					}
 				} else {
 					//以s_m_phone登录的 需要把s_m_phone转化为s_phone
@@ -303,23 +303,23 @@ func (l *Login) Login() error {
 						"baseUserId": l.GetSession("base_user_id"),
 						"positionId": l.GetSession("positionId"),
 					})
-                    return 1, 4
+					return 1, 4
 				}
 			}
 		}
 		return 0, -1
 	}()
 	//登录source 更新 p414
-	channelCode, ckErr := l.Request.Cookie(jy.ChannelCookieName)
-	if ckErr != nil {
-		log.Println("获取 合作商 code 异常或 无合作商code:", qutil.ObjToString(l.GetSession("phone")))
-		channelCode.Value = "jy_app"
+	channelCode := "jy_app"
+	cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
+	if ckErr == nil {
+		channelCode = cc.Value
 	}
 	us := jy.UserSource{
 		UserId:           qutil.ObjToString(l.GetSession("userId")),
 		Phone:            qutil.ObjToString(l.GetSession("phone")),
 		State:            qutil.If(state == 3, 2, 1).(int), //注册/登录标志 1:登录;2:注册
-		ChannelCode:      channelCode.Value,
+		ChannelCode:      channelCode,
 		EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
 		CreateTime:       time.Now().Format(time.DateTime),
 		LoginWay:         qutil.If(state == 1, state, 2).(int),                         //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
@@ -587,7 +587,7 @@ func (l *Login) Register() error {
 					}()
 					l.DelSession("registerStep")
 					jy.ClearPhoneIdentSession(l.Session())
-
+					//剑鱼币
 					jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
 						"code":       1014, //下载app任务
 						"types":      "downloadApp",
@@ -598,7 +598,7 @@ func (l *Login) Register() error {
 				})
 				if errStr == "y" {
 					returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
-
+					//剑鱼币
 					jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
 						"code":       1014, //下载app任务
 						"types":      "downloadApp",
@@ -607,16 +607,16 @@ func (l *Login) Register() error {
 						"positionId": l.GetSession("positionId"),
 					})
 					//登录source 更新 p414
-					channelCode, ckErr := l.Request.Cookie(jy.ChannelCookieName)
-					if ckErr != nil {
-						log.Println("获取 合作商 code 异常或 无合作商code:", qutil.ObjToString(l.GetSession("phone")))
-						channelCode.Value = "jy_app"
+					channelCode := "jy_app"
+					cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
+					if ckErr == nil {
+						channelCode = cc.Value
 					}
 					us := jy.UserSource{
 						UserId:           qutil.ObjToString(l.GetSession("userId")),
 						Phone:            qutil.ObjToString(l.GetSession("phone")),
 						State:            2, //注册/登录标志 1:登录;2:注册
-						ChannelCode:      channelCode.Value,
+						ChannelCode:      channelCode,
 						EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
 						CreateTime:       time.Now().Format(time.DateTime),
 						LoginWay:         1,                                                            //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
@@ -813,16 +813,16 @@ func (l *Login) WxLogin() {
 	})
 	if status > 0 {
 		//登录source 更新 p414
-		channelCode, ckErr := l.Request.Cookie(jy.ChannelCookieName)
-		if ckErr != nil {
-			log.Println("获取 合作商 code 异常或 无合作商code:", qutil.ObjToString(l.GetSession("phone")))
-			channelCode.Value = "jy_app"
+		channelCode := "jy_app"
+		cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
+		if ckErr == nil {
+			channelCode = cc.Value
 		}
 		us := jy.UserSource{
 			UserId:           qutil.ObjToString(l.GetSession("userId")),
 			Phone:            qutil.ObjToString(l.GetSession("phone")),
 			State:            status, //注册/登录标志 1:登录;2:注册
-			ChannelCode:      channelCode.Value,
+			ChannelCode:      channelCode,
 			EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
 			CreateTime:       time.Now().Format(time.DateTime),
 			LoginWay:         3,                                                            //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录

+ 0 - 4
src/jfw/modules/publicapply/src/channel/entity/entity.go

@@ -1,5 +1 @@
 package entity
-
-var (
-	ChannelCookieName = "channelCode"
-)

+ 6 - 11
src/jfw/modules/publicapply/src/channel/service/service.go

@@ -3,7 +3,7 @@ package service
 import (
 	. "app.yhyue.com/moapp/jybase/api"
 	qu "app.yhyue.com/moapp/jybase/common"
-	"jy/src/jfw/modules/publicapply/src/channel/entity"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"jy/src/jfw/modules/publicapply/src/db"
 	"log"
 )
@@ -22,24 +22,19 @@ func (c *ChannelStruct) Cooperation() {
 		var (
 			res = Result{}
 		)
-		channelCode, err := c.Request.Cookie(entity.ChannelCookieName)
-		log.Println("channelCode.Value:", channelCode.Value)
-		if err == nil && channelCode.Value != "" {
+		channelCode, err := c.Request.Cookie(jy.ChannelCookieName)
+		log.Println(err, "---channelCode.Value:--", channelCode)
+		if err == nil {
 			selectSql := `SELECT * FROM thirdparty.ent_channel_info WHERE channel_code = ?`
 			data := db.BaseMysql.SelectBySql(selectSql, channelCode.Value)
 			if data != nil && len(*data) > 0 {
 				customInfo := (*data)[0]["custom_info"]
-				if customInfo != nil {
-					qu.ObjToMap(customInfo)
-				}
 				res.Data = qu.If(customInfo != nil, qu.ObjToMap(customInfo), "").(interface{})
 			} else {
-				res.Error_msg = Error_msg_1004
-				res.Error_code = Error_code_1004
+				log.Println("未查到相关数据")
 			}
 		} else {
-			res.Error_msg = Error_msg_1002
-			res.Error_code = Error_code_1002
+			log.Println("不是 渠道合作商")
 		}
 		return res
 	}()

+ 2 - 2
src/jfw/modules/publicapply/src/filter/cookie.go

@@ -2,7 +2,7 @@ package filter
 
 import (
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"jy/src/jfw/modules/publicapply/src/channel/entity"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"jy/src/jfw/modules/publicapply/src/util"
 	"log"
 	"net/http"
@@ -22,7 +22,7 @@ func (ci *CookieInfo) Do(w http.ResponseWriter, req *http.Request) bool {
 	if cc.MatchString(req.Referer()) {
 		match := cc.FindStringSubmatch(req.Referer())
 		if len(match) > 1 {
-			util.SetCookieValue(w, entity.ChannelCookieName, match[1], -1)
+			util.SetCookieValue(w, jy.ChannelCookieName, match[1], -1)
 		}
 		log.Println("----------------------------", match)
 	}

+ 5 - 5
src/jfw/modules/publicapply/src/oneclick/entity/entity.go

@@ -433,16 +433,16 @@ func (o *OneClickInfo) phoneLogin(phone string) (map[string]interface{}, error)
 		//登录source 更新 p414
 		mgoUserId, _ := o.Session.Get("mgoUserId").(string)
 		phone, _ := o.Session.Get("phone").(string)
-		channelCode, ckErr := o.R.Cookie(jy.ChannelCookieName)
-		if ckErr != nil {
-			log.Println("获取 合作商 code 异常或 无合作商code:", phone)
-			channelCode.Value = "jy_app"
+		channelCode := "jy_app"
+		cc, ckErr := o.R.Cookie(jy.ChannelCookieName)
+		if ckErr == nil {
+			channelCode = cc.Value
 		}
 		us := jy.UserSource{
 			UserId:           mgoUserId,
 			Phone:            phone,
 			State:            status, //注册/登录标志 1:登录;2:注册
-			ChannelCode:      channelCode.Value,
+			ChannelCode:      channelCode,
 			EncryptionUserId: encrypt.SE.Encode2Hex(mgoUserId),
 			CreateTime:       time.Now().Format(time.DateTime),
 			LoginWay:         4,                                                                  //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录

+ 1 - 1
src/jfw/modules/weixin/src/service/usersource.go

@@ -14,7 +14,7 @@ func SaveUserSource(channelCode, userId, phone string, state int) {
 		UserId:           userId,
 		Phone:            phone,
 		State:            state, //注册/登录标志 1:登录;2:注册
-		ChannelCode:      qutil.If(channelCode == "", "WX", channelCode).(string),
+		ChannelCode:      qutil.If(channelCode == "", "jy_wx", channelCode).(string),
 		EncryptionUserId: encrypt.SE.Encode2Hex(userId),
 		CreateTime:       time.Now().Format(time.DateTime),
 		LoginWay:         3, //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录