Browse Source

feat:登录来源日志记录

wangshan 1 year ago
parent
commit
b1d57f67be

+ 1 - 1
src/go.mod

@@ -6,7 +6,7 @@ require (
 	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230308011651-df591d32df88
 	app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
-	app.yhyue.com/moapp/jypkg v0.0.0-20231017032120-01da044f6c92
+	app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/bwmarrin/snowflake v0.3.0

+ 2 - 2
src/go.sum

@@ -9,8 +9,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40 h1:/FcBvpf/KW8g6GB
 app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40/go.mod h1:Hv9U/7oHRucqH315Tr1+d03NCvS9mOKPfk8pwwlOIwQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545 h1:+Lak4m1zgsigQloOsvp8AJ+0XeX/+PGp9QP550xlbBQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545/go.mod h1:uFrsdUBFbETiJlEmr4PtJWPsZlUpPj2bHQRhryu6ggk=
-app.yhyue.com/moapp/jypkg v0.0.0-20231017032120-01da044f6c92 h1:ZEe+lUFbCk+MWUnNxTx4L+lsJmiAEIdFsgFyMT4ua+E=
-app.yhyue.com/moapp/jypkg v0.0.0-20231017032120-01da044f6c92/go.mod h1:76Kz6+MuxcRJRyFad9W8R4AByiQlVGzuGFzklY+2m38=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed h1:rd5FDHAWiM1MLbgi79KBpRTMQfH5e2Y+knkk2JMsFP4=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed/go.mod h1:76Kz6+MuxcRJRyFad9W8R4AByiQlVGzuGFzklY+2m38=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=

+ 24 - 3
src/jfw/front/login.go

@@ -3,6 +3,7 @@ package front
 import (
 	qutil "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/dchest/captcha"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	. "app.yhyue.com/moapp/jybase/mongodb"
@@ -200,7 +201,7 @@ func (l *Login) Login() error {
 						if ok {
 							result["userInfo"] = userInfo
 							go anonymousLogin(l.Session(), l.Cookie("JYTrustedId"))
-							return 1, true
+							return 2, true
 						}
 					}
 				} else {
@@ -229,14 +230,34 @@ func (l *Login) Login() error {
 					if ok {
 						result["userInfo"] = userInfo
 						go anonymousLogin(l.Session(), l.Cookie("JYTrustedId"))
-						return 1, true
+						return 3, true
 					}
 				}
 			}
 		}
 		return 0, false
 	}()
-	if status == 1 && isLogin {
+	if status >= 1 && isLogin {
+		//登录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"
+		}
+		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,
+			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.ChannelTableName, qutil.StructToMapMore(us))
+		}(us)
 		//当前用户登录选择 下次自动登录
 		if isAutoLogin && err == nil {
 			baseUserId := qutil.Int64All(l.GetSession("base_user_id"))

+ 29 - 11
src/jfw/front/websocket.go

@@ -20,7 +20,7 @@ import (
 	"time"
 )
 
-//socket对象放在内存中,待rpc回调使用
+// socket对象放在内存中,待rpc回调使用
 type Wss struct {
 	Conn    *websocket.Conn
 	session *httpsession.Session
@@ -47,7 +47,7 @@ func (m *MapSocket) GC() {
 var MSPOOL = 20
 var MapSocketArr = make([]*MapSocket, MSPOOL)
 
-//初始化
+// 初始化
 func init() {
 	for i := 0; i < MSPOOL; i++ {
 		ms := &MapSocket{Map: map[string]*Wss{}}
@@ -57,7 +57,6 @@ func init() {
 	redis.InitRedisLogin(public.DbConf.Redis.Login.Address)
 }
 
-//
 func GetRedisPoolVal() {
 	redis.GetLoginVal("loginCode", GetWsByCode)
 	//	var res string
@@ -71,7 +70,7 @@ func GetRedisPoolVal() {
 	//	}
 }
 
-//根据代码和ws做映射
+// 根据代码和ws做映射
 func PutWsByCode(src string, ws *websocket.Conn, session *httpsession.Session) {
 	defer qutil.Catch()
 	n := HashVal(src) % MSPOOL
@@ -92,7 +91,7 @@ func PutWsByCode(src string, ws *websocket.Conn, session *httpsession.Session) {
 	ms.Lock.Unlock()
 }
 
-//计算代码的hash值
+// 计算代码的hash值
 func HashVal(src string) int {
 	check := 0
 	for i := len(src) / 2; i < len(src); i++ {
@@ -101,7 +100,7 @@ func HashVal(src string) int {
 	return check
 }
 
-//rpc回调,写到前台
+// rpc回调,写到前台
 func GetWsByCode(param []string) bool {
 	if len(param) < 2 {
 		return false
@@ -145,7 +144,26 @@ 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)
 				//收到webSocket消息后,您无法设置cookie.一旦建立了webSocket连接,它就是一个开放的TCP套接字,协议不再是http,因此没有内置的方式来交换cookie.
 				//jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId)  不可用
 				//您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.
@@ -167,7 +185,7 @@ func GetWsByCode(param []string) bool {
 	}
 }
 
-//用户登录信息
+// 用户登录信息
 func LoginInfo(shareid, openid string, Sess interface{}) map[string]interface{} {
 	if Sess == nil {
 		return nil
@@ -216,7 +234,7 @@ func ServeWss(conn *websocket.Conn) {
 
 }
 
-//实验室
+// 实验室
 func QrToLabWss(conn *websocket.Conn) {
 	defer qutil.Catch()
 	var receive, userId string
@@ -286,7 +304,7 @@ func QrToLabWss(conn *websocket.Conn) {
 	}
 }
 
-//电脑端强制分享,扫码分享到朋友圈
+// 电脑端强制分享,扫码分享到朋友圈
 func QrToShareTimeline(conn *websocket.Conn) {
 	defer qutil.Catch()
 	var receive string
@@ -341,7 +359,7 @@ func QrToShareTimeline(conn *websocket.Conn) {
 	}
 }
 
-//pc弹框 最新一条消息
+// pc弹框 最新一条消息
 func GetBuoyMsg(conn *websocket.Conn) {
 	defer qutil.Catch()
 	sess := xweb.RootApp().SessionManager.Session(conn.R, conn.W)

+ 80 - 17
src/jfw/modules/app/src/app/front/login.go

@@ -1,6 +1,7 @@
 package front
 
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"encoding/json"
 	"fmt"
 	"jy/src/jfw/modules/app/src/jfw/config"
@@ -105,13 +106,13 @@ func (l *Login) Login() error {
 	}
 	returnSign := ""
 	userInfo := map[string]interface{}{}
-	status := func() int {
+	status, state := func() (int, int) {
 		reqType := l.GetString("reqType")
 		if reqType == "phoneLogin" {
 			phone := l.GetString("phone")
 			password := l.GetString("password")
 			if strings.TrimSpace(phone) == "" || strings.TrimSpace(password) == "" {
-				return -1
+				return -1, -1
 			}
 			query := map[string]interface{}{
 				"i_appid": 2,
@@ -131,9 +132,9 @@ func (l *Login) Login() error {
 				deviceId := l.GetString("deviceId")
 				phoneType := l.GetString("phoneType")
 				returnSign = afterLogin((*user)[0], l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
-				return 1
+				return 1, 1
 			}
-			return -1 //用户名或密码不正确
+			return -1, -1 //用户名或密码不正确
 		} else if reqType == "signLogin" {
 			returnStatus := 0
 			if l.GetSession("mgoUserId") != nil {
@@ -146,7 +147,7 @@ func (l *Login) Login() error {
 			(userInfo)["s_phone"] = l.GetSession("s_phone")
 			(userInfo)["userid"] = l.GetSession("mgoUserId")
 			(userInfo)["app_name"] = l.GetSession("app_name")
-			return returnStatus
+			return returnStatus, 2
 		} else if reqType == "sendIdentCode" {
 			phone := jy.CheckSendMsg(l.GetString("token"))
 			if phone == "" {
@@ -154,18 +155,18 @@ func (l *Login) Login() error {
 			}
 			//手机号验证不通过
 			if phone == "" {
-				return -2
+				return -2, -1
 			} else if !phoneReg.MatchString(phone) {
-				return -1
+				return -1, -1
 			} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
-				return 1
+				return 1, -1
 			}
-			return 0
+			return 0, -1
 		} else if reqType == "identCodeLogin" {
 			disWord := l.GetString("disWord")
 			phone, _ := l.GetSession("identCodeKey").(string)
 			if phone == "" || l.GetSession("identCodeValue") == nil || l.GetString("identCode") != l.GetSession("identCodeValue") { //验证码不正确
-				return -1
+				return -1, -1
 			} else {
 				RegLock.Lock()
 				reg := RegMap[phone]
@@ -182,7 +183,7 @@ func (l *Login) Login() error {
 				ok, user := getPhoneUser(phone)
 				//登录成功
 				if !ok {
-					return 0
+					return 0, -1
 				}
 				//用户不存在
 				rid := l.GetString("rid")
@@ -230,7 +231,7 @@ func (l *Login) Login() error {
 						data["base_user_id"] = resp.Data.Id
 					} else {
 						log.Println(phone, "调用usercenter失败")
-						return -4
+						return -4, -1
 					}
 					_id := mongodb.Save("user", data)
 					if _id != "" {
@@ -260,7 +261,7 @@ func (l *Login) Login() error {
 								log.Println("nsq队列写入失败-->", err, jy.Jyapp_phone_register, _id)
 							}
 						}
-						return 1
+						return 1, 3
 					}
 				} else {
 					//以s_m_phone登录的 需要把s_m_phone转化为s_phone
@@ -281,12 +282,32 @@ func (l *Login) Login() error {
 					}
 					jy.ClearPhoneIdentSession(l.Session())
 					returnSign = afterLogin(user, l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
-					return 1
+					return 1, 4
 				}
 			}
 		}
-		return 0
+		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"
+	}
+	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,
+		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:手机号一键登录
+		Platform:         qutil.If(strings.Contains(l.Request.Host, "h5"), 4, 3).(int), //登录端;1:PC;2:WX;3:APP;4:H5
+		Ip:               qutil.GetIp(l.Request),
+	}
+	go func(us jy.UserSource) {
+		jy.SaveUserSource(public.BaseMysql, jy.ChannelTableName, qutil.StructToMapMore(us))
+	}(us)
 	result := map[string]interface{}{
 		"status": status,
 		"userId": l.GetSession("mgoUserId"),
@@ -548,6 +569,26 @@ func (l *Login) Register() error {
 				})
 				if errStr == "y" {
 					returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
+					//登录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"
+					}
+					us := jy.UserSource{
+						UserId:           qutil.ObjToString(l.GetSession("userId")),
+						Phone:            qutil.ObjToString(l.GetSession("phone")),
+						State:            2, //注册/登录标志 1:登录;2:注册
+						ChannelCode:      channelCode.Value,
+						EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
+						CreateTime:       time.Now().Format(time.DateTime),
+						LoginWay:         1,                                                            //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
+						Platform:         qutil.If(strings.Contains(l.Request.Host, "h5"), 4, 3).(int), //登录端;1:PC;2:WX;3:APP;4:H5
+						Ip:               qutil.GetIp(l.Request),
+					}
+					go func(us jy.UserSource) {
+						jy.SaveUserSource(public.BaseMysql, jy.ChannelTableName, qutil.StructToMapMore(us))
+					}(us)
 				}
 				return errStr
 			}()
@@ -718,14 +759,36 @@ func (l *Login) WxLogin() {
 						log.Println("nsq队列写入失败-->", jy.Jyapp_wx_register, _id)
 					}
 				}
-				return 1
+				return 2
 			}
 		}
 		return 0
 	}()
+	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"
+		}
+		us := jy.UserSource{
+			UserId:           qutil.ObjToString(l.GetSession("userId")),
+			Phone:            qutil.ObjToString(l.GetSession("phone")),
+			State:            status, //注册/登录标志 1:登录;2:注册
+			ChannelCode:      channelCode.Value,
+			EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
+			CreateTime:       time.Now().Format(time.DateTime),
+			LoginWay:         3,                                                            //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
+			Platform:         qutil.If(strings.Contains(l.Request.Host, "h5"), 4, 3).(int), //登录端;1:PC;2:WX;3:APP;4:H5
+			Ip:               qutil.GetIp(l.Request),
+		}
+		go func(us jy.UserSource) {
+			jy.SaveUserSource(public.BaseMysql, jy.ChannelTableName, qutil.StructToMapMore(us))
+		}(us)
+	}
 	//返回
 	result := map[string]interface{}{
-		"status": status,
+		"status": qutil.If(status > 0, 1, status).(int),
 		"userId": l.GetSession("mgoUserId"),
 	}
 	if returnSign != "" {

+ 2 - 2
src/jfw/modules/app/src/go.mod

@@ -5,7 +5,7 @@ go 1.18
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
-	app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25
+	app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/gogf/gf/v2 v2.3.1
@@ -139,7 +139,7 @@ require (
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	gorm.io/driver/mysql v1.0.5 // indirect
 	gorm.io/gorm v1.21.3 // indirect
-	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1 // indirect
+	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a // indirect
 	k8s.io/api v0.26.3 // indirect
 	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
 	k8s.io/client-go v0.26.3 // indirect

+ 4 - 4
src/jfw/modules/app/src/go.sum

@@ -9,8 +9,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40 h1:/FcBvpf/KW8g6GB
 app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40/go.mod h1:Hv9U/7oHRucqH315Tr1+d03NCvS9mOKPfk8pwwlOIwQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545 h1:+Lak4m1zgsigQloOsvp8AJ+0XeX/+PGp9QP550xlbBQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545/go.mod h1:uFrsdUBFbETiJlEmr4PtJWPsZlUpPj2bHQRhryu6ggk=
-app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25 h1:2q7b1auPihIJD3Ewsd7Zi8ESeLkxuP57avWL8UoBr9U=
-app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25/go.mod h1:gPCOY8bVXdY5bD7nry7th+YNkKC/viG8Dc9+z4fUaRo=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed h1:rd5FDHAWiM1MLbgi79KBpRTMQfH5e2Y+knkk2JMsFP4=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed/go.mod h1:76Kz6+MuxcRJRyFad9W8R4AByiQlVGzuGFzklY+2m38=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=
@@ -1429,8 +1429,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1 h1:BItxi1gkQUs3sjxaBk6tc34fZWSO4hUSXcTM3PcnY4I=
-jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1/go.mod h1:p/595fgbj4r6GhSJhHDpx3Ru1NkD5UASFL8OuIQw09E=
+jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a h1:kwjO4pqB3gnNGrQ9aXyz6f8s9qXAUenPUDWip8gYR/Q=
+jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a/go.mod h1:p/595fgbj4r6GhSJhHDpx3Ru1NkD5UASFL8OuIQw09E=
 k8s.io/api v0.22.9/go.mod h1:rcjO/FPOuvc3x7nQWx29UcDrFJMx82RxDob71ntNH4A=
 k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU=
 k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE=

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

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

+ 10 - 0
src/jfw/modules/publicapply/src/channel/init.go

@@ -0,0 +1,10 @@
+package channel
+
+import (
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"jy/src/jfw/modules/publicapply/src/channel/service"
+)
+
+func init() {
+	xweb.AddAction(&service.ChannelStruct{})
+}

+ 8 - 0
src/jfw/modules/publicapply/src/channel/service/action.go

@@ -0,0 +1,8 @@
+package service
+
+import "app.yhyue.com/moapp/jybase/go-xweb/xweb"
+
+type ChannelStruct struct {
+	*xweb.Action
+	cooperation xweb.Mapper `xweb:"/channel/cooperation"` //招标信息收藏
+}

+ 47 - 0
src/jfw/modules/publicapply/src/channel/service/service.go

@@ -0,0 +1,47 @@
+package service
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	qu "app.yhyue.com/moapp/jybase/common"
+	"jy/src/jfw/modules/publicapply/src/channel/entity"
+	"jy/src/jfw/modules/publicapply/src/db"
+	"log"
+)
+
+// P414
+func (c *ChannelStruct) Cooperation() {
+	defer qu.Catch()
+	r := func() Result {
+		//已登录 不做任何操作
+		if userId, _ := c.GetSession("userId").(string); userId != "" {
+			return Result{Data: nil}
+		}
+		if c.Method() != "POST" {
+			return Result{Data: nil, Error_msg: Error_msg_1005}
+		}
+		var (
+			res = Result{}
+		)
+		channelCode, err := c.Request.Cookie(entity.ChannelCookieName)
+		log.Println("channelCode.Value:", channelCode.Value)
+		if err == nil && channelCode.Value != "" {
+			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
+			}
+		} else {
+			res.Error_msg = Error_msg_1002
+			res.Error_code = Error_code_1002
+		}
+		return res
+	}()
+	c.ServeJson(r)
+}

+ 30 - 0
src/jfw/modules/publicapply/src/filter/cookie.go

@@ -0,0 +1,30 @@
+package filter
+
+import (
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"jy/src/jfw/modules/publicapply/src/channel/entity"
+	"jy/src/jfw/modules/publicapply/src/util"
+	"log"
+	"net/http"
+	"regexp"
+)
+
+var cc = regexp.MustCompile("^/channel/cooperate/(.*)")
+
+// CookieInfo 信息
+type CookieInfo struct {
+	App *xweb.App
+}
+
+// Do 继承过滤器方法
+func (ci *CookieInfo) Do(w http.ResponseWriter, req *http.Request) bool {
+	log.Println(req.Referer())
+	if cc.MatchString(req.Referer()) {
+		match := cc.FindStringSubmatch(req.Referer())
+		if len(match) > 1 {
+			util.SetCookieValue(w, entity.ChannelCookieName, match[1], -1)
+		}
+		log.Println("----------------------------", match)
+	}
+	return true
+}

+ 1 - 0
src/jfw/modules/publicapply/src/filter/filter.go

@@ -7,4 +7,5 @@ import (
 func init() {
 	xweb.AddFilter(&logfilter{App: xweb.RootApp()})
 	xweb.AddFilter(&sessionfilter{App: xweb.RootApp()})
+	xweb.AddFilter(&CookieInfo{App: xweb.RootApp()})
 }

+ 1 - 1
src/jfw/modules/publicapply/src/filter/sessionfilter.go

@@ -22,7 +22,7 @@ var reg_share = regexp.MustCompile("^/publicapply/shareFission/.*")
 var reg_nps = regexp.MustCompile("^/publicapply/nps/.*")
 var regWhiteList = regexp.MustCompile("^/publicapply/userbase/whitelist$")
 var regEntSearch = regexp.MustCompile("^/publicapply/enterpriseSearch/doQuery") //企业搜索接口
-var regOneClick = regexp.MustCompile("^/publicapply/oneClick/.*")
+var regOneClick = regexp.MustCompile("^/publicapply/(oneClick|channel)/.*")
 
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)

+ 2 - 2
src/jfw/modules/publicapply/src/go.mod

@@ -5,7 +5,7 @@ go 1.18
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
-	app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25
+	app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.4
@@ -148,7 +148,7 @@ require (
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	gorm.io/driver/mysql v1.0.5 // indirect
 	gorm.io/gorm v1.21.3 // indirect
-	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1 // indirect
+	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a // indirect
 	k8s.io/api v0.26.3 // indirect
 	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
 	k8s.io/client-go v0.26.3 // indirect

+ 4 - 4
src/jfw/modules/publicapply/src/go.sum

@@ -9,8 +9,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf h1:/Tk5haITmGc5c3/
 app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf/go.mod h1:D40Ae0rQilH8Hc5o2Vtt04Tjh/DNEFpcS3/WkJMPJb8=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545 h1:+Lak4m1zgsigQloOsvp8AJ+0XeX/+PGp9QP550xlbBQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545/go.mod h1:uFrsdUBFbETiJlEmr4PtJWPsZlUpPj2bHQRhryu6ggk=
-app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25 h1:2q7b1auPihIJD3Ewsd7Zi8ESeLkxuP57avWL8UoBr9U=
-app.yhyue.com/moapp/jypkg v0.0.0-20230925120741-9e02619bfe25/go.mod h1:gPCOY8bVXdY5bD7nry7th+YNkKC/viG8Dc9+z4fUaRo=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed h1:rd5FDHAWiM1MLbgi79KBpRTMQfH5e2Y+knkk2JMsFP4=
+app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed/go.mod h1:76Kz6+MuxcRJRyFad9W8R4AByiQlVGzuGFzklY+2m38=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=
@@ -1481,8 +1481,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1 h1:BItxi1gkQUs3sjxaBk6tc34fZWSO4hUSXcTM3PcnY4I=
-jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20230710093759-d9d6c68de8b1/go.mod h1:p/595fgbj4r6GhSJhHDpx3Ru1NkD5UASFL8OuIQw09E=
+jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a h1:kwjO4pqB3gnNGrQ9aXyz6f8s9qXAUenPUDWip8gYR/Q=
+jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a/go.mod h1:p/595fgbj4r6GhSJhHDpx3Ru1NkD5UASFL8OuIQw09E=
 k8s.io/api v0.22.9/go.mod h1:rcjO/FPOuvc3x7nQWx29UcDrFJMx82RxDob71ntNH4A=
 k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU=
 k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE=

+ 1 - 0
src/jfw/modules/publicapply/src/main.go

@@ -26,6 +26,7 @@ import (
 	_ "jy/src/jfw/modules/publicapply/src/transfer"
 	"net/http"
 
+	_ "jy/src/jfw/modules/publicapply/src/channel"
 	_ "jy/src/jfw/modules/publicapply/src/shareFission"
 	_ "jy/src/jfw/modules/publicapply/src/subscribe"
 	_ "jy/src/jfw/modules/publicapply/src/subscribePush"

+ 28 - 2
src/jfw/modules/publicapply/src/oneclick/entity/entity.go

@@ -10,6 +10,7 @@ import (
 	qrpc "app.yhyue.com/moapp/jybase/rpc"
 	"app.yhyue.com/moapp/jybase/usercenter"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"app.yhyue.com/moapp/jypkg/public"
 	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 	"encoding/json"
 	"errors"
@@ -48,6 +49,7 @@ type OneClickInfo struct {
 	Session        *httpsession.Session
 	ResponseWriter *http.ResponseWriter
 	Host           string
+	R              *http.Request
 }
 
 var (
@@ -299,7 +301,6 @@ func (o *OneClickInfo) ProcessPhone(phone string) (map[string]interface{}, error
 		}
 		returnData = rs
 	}
-
 	return returnData, nil
 }
 
@@ -392,7 +393,7 @@ func (o *OneClickInfo) phoneLogin(phone string) (map[string]interface{}, error)
 				}
 				mgoUserId, _ := o.Session.Get("mgoUserId").(string)
 				go o.saveLog(mgoUserId, "o_register")
-				return 1
+				return 2
 			}
 		} else {
 			//以s_m_phone登录的 需要把s_m_phone转化为s_phone
@@ -413,6 +414,31 @@ func (o *OneClickInfo) phoneLogin(phone string) (map[string]interface{}, error)
 		}
 		return 0
 	}()
+	if status > 0 {
+		//登录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"
+		}
+		us := jy.UserSource{
+			UserId:           mgoUserId,
+			Phone:            phone,
+			State:            status, //注册/登录标志 1:登录;2:注册
+			ChannelCode:      channelCode.Value,
+			EncryptionUserId: encrypt.SE.Encode2Hex(mgoUserId),
+			CreateTime:       time.Now().Format(time.DateTime),
+			LoginWay:         4,                                                                  //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
+			Platform:         common.If(strings.Contains(o.Host, "h5.jianyu360.cn"), 4, 3).(int), //登录端;1:PC;2:WX;3:APP;4:H5
+			Ip:               common.GetIp(o.R),
+		}
+		go func(us jy.UserSource) {
+			jy.SaveUserSource(public.BaseMysql, jy.ChannelTableName, common.StructToMapMore(us))
+		}(us)
+		status = 1
+	}
 	result := map[string]interface{}{
 		"status": status,
 		"userId": o.Session.Get("mgoUserId"),

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

@@ -1,11 +1,11 @@
 package service
 
 import (
-	. "app.yhyue.com/moapp/jybase/api"
-	qu "app.yhyue.com/moapp/jybase/common"
-	"errors"
-	"jy/src/jfw/modules/publicapply/src/oneclick/entity"
-	"log"
+    . "app.yhyue.com/moapp/jybase/api"
+    qu "app.yhyue.com/moapp/jybase/common"
+    "errors"
+    "jy/src/jfw/modules/publicapply/src/oneclick/entity"
+    "log"
 )
 
 func (o *OneClick) GetPhoneByToken() {

+ 236 - 216
src/jfw/modules/publicapply/src/util/util.go

@@ -1,37 +1,39 @@
 package util
 
 import (
-    "encoding/json"
-    "fmt"
-    "jy/src/jfw/modules/publicapply/src/config"
-    "jy/src/jfw/modules/publicapply/src/db"
-    "regexp"
-    "strconv"
-    "strings"
-    "time"
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	"encoding/json"
+	"fmt"
+	"jy/src/jfw/modules/publicapply/src/config"
+	"jy/src/jfw/modules/publicapply/src/db"
+	"net/http"
+	"regexp"
+	"strconv"
+	"strings"
+	"time"
 
-    qutil "app.yhyue.com/moapp/jybase/common"
-    . "app.yhyue.com/moapp/jybase/date"
-    "app.yhyue.com/moapp/jybase/encrypt"
-    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 )
 
 var ClearHtml = regexp.MustCompile("<[^>]*>")
 
-//加密
+// 加密
 func EncodeId(sid string) string {
-    if sid == "" {
-        return ""
-    }
-    return encrypt.EncodeArticleId2ByCheck(sid)
+	if sid == "" {
+		return ""
+	}
+	return encrypt.EncodeArticleId2ByCheck(sid)
 }
 
-//解密
+// 解密
 func DecodeId(eid string) string {
-    if eid == "" {
-        return ""
-    }
-    return encrypt.CommonDecodeArticle("content", eid)[0]
+	if eid == "" {
+		return ""
+	}
+	return encrypt.CommonDecodeArticle("content", eid)[0]
 }
 
 //收藏列表
@@ -43,231 +45,249 @@ func DecodeId(eid string) string {
 	   开始时间-结束时间:1622476800-1623859200
 */
 type CollList struct {
-    Pagenum     int    `json:"pagenum"`     //页数
-    Label       string `json:"label"`       //标签 用,分隔开
-    SelectTime  string `json:"selectTime"`  //收藏时间
-    Buyerclass  string `json:"buyerclass"`  //采购单位 用,分隔开
-    BuyerPhone  int    `json:"buyerPhone"`  //是否需要采购单位联系方式 1:需要 -1:不需要 0:未选中
-    WinnerPhone int    `json:"winnerPhone"` //是否需要中标单位联系方式 1:需要 -1:不需要 0:未选中
-    Pagesize    int    `json:"pagesize"`    //每页展示数量
+	Pagenum     int    `json:"pagenum"`     //页数
+	Label       string `json:"label"`       //标签 用,分隔开
+	SelectTime  string `json:"selectTime"`  //收藏时间
+	Buyerclass  string `json:"buyerclass"`  //采购单位 用,分隔开
+	BuyerPhone  int    `json:"buyerPhone"`  //是否需要采购单位联系方式 1:需要 -1:不需要 0:未选中
+	WinnerPhone int    `json:"winnerPhone"` //是否需要中标单位联系方式 1:需要 -1:不需要 0:未选中
+	Pagesize    int    `json:"pagesize"`    //每页展示数量
 }
 
-//搜藏列表
+// 搜藏列表
 func CollListSql(c *CollList, isPay bool, userid string) string {
-    sql := fmt.Sprintf(`select bid from %s where userid ='%s'`, db.DbConf.Bdcollection, userid)
-    limit := config.BidCollConfig.FreeUserCollLimit
-    //个人标签
-    if c.Label != "" {
-        i := 0
-        sql += ` and `
-        if labelArr := strings.Split(c.Label, ","); len(labelArr) > 0 {
-            sql += `(`
-            for _, v := range labelArr {
-                i++
-                labid := encrypt.SE.DecodeString(v)
-                if i == len(labelArr) {
-                    sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid)`, labid)
-                } else {
-                    sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid) or `, labid)
-                }
-            }
-            sql += `)`
-        }
-    }
-    now := time.Now()
-    start, end := "", ""
-    //收藏时间
-    if c.SelectTime == "lately-7" { //最近7天
-        start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
-    } else if c.SelectTime == "lately-30" { //最近30天
-        start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
-    } else if c.SelectTime == "thisyear" { //去年
-        start = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
-        end = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Format(Date_Full_Layout))
-    } else if len(strings.Split(c.SelectTime, "_")) == 2 {
-        if c.SelectTime != "0_0" {
-            starttime := strings.Split(c.SelectTime, "_")[0]
-            startstamp, _ := strconv.Atoi(starttime)
-            start = time.Unix(int64(startstamp), 0).Format(Date_Full_Layout)
-            endtime := strings.Split(c.SelectTime, "_")[1]
-            et, _ := strconv.ParseInt(endtime, 0, 64)
-            etTime := time.Unix(et, 0)
-            end = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
-        }
-    }
-    if start != "" && end != "" {
-        sql += ` and createdate >= '` + start + `' and createdate < '` + end + `'`
-    } else if start != "" && end == "" {
-        sql += ` and createdate >= '` + start + `'`
-    } else if start == "" && end != "" {
-        sql += ` and createdate < '` + end + `'`
-    }
-    if isPay {
+	sql := fmt.Sprintf(`select bid from %s where userid ='%s'`, db.DbConf.Bdcollection, userid)
+	limit := config.BidCollConfig.FreeUserCollLimit
+	//个人标签
+	if c.Label != "" {
+		i := 0
+		sql += ` and `
+		if labelArr := strings.Split(c.Label, ","); len(labelArr) > 0 {
+			sql += `(`
+			for _, v := range labelArr {
+				i++
+				labid := encrypt.SE.DecodeString(v)
+				if i == len(labelArr) {
+					sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid)`, labid)
+				} else {
+					sql += fmt.Sprintf(`FIND_IN_SET(%s,labelid) or `, labid)
+				}
+			}
+			sql += `)`
+		}
+	}
+	now := time.Now()
+	start, end := "", ""
+	//收藏时间
+	if c.SelectTime == "lately-7" { //最近7天
+		start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
+	} else if c.SelectTime == "lately-30" { //最近30天
+		start = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
+	} else if c.SelectTime == "thisyear" { //去年
+		start = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
+		end = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Format(Date_Full_Layout))
+	} else if len(strings.Split(c.SelectTime, "_")) == 2 {
+		if c.SelectTime != "0_0" {
+			starttime := strings.Split(c.SelectTime, "_")[0]
+			startstamp, _ := strconv.Atoi(starttime)
+			start = time.Unix(int64(startstamp), 0).Format(Date_Full_Layout)
+			endtime := strings.Split(c.SelectTime, "_")[1]
+			et, _ := strconv.ParseInt(endtime, 0, 64)
+			etTime := time.Unix(et, 0)
+			end = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Format(Date_Full_Layout))
+		}
+	}
+	if start != "" && end != "" {
+		sql += ` and createdate >= '` + start + `' and createdate < '` + end + `'`
+	} else if start != "" && end == "" {
+		sql += ` and createdate >= '` + start + `'`
+	} else if start == "" && end != "" {
+		sql += ` and createdate < '` + end + `'`
+	}
+	if isPay {
 
-        //采购单位 用,分隔开
-        if c.Buyerclass != "" {
-            i := 0
-            sql += ` and buyerclass in (`
-            if buyClassArr := strings.Split(c.Buyerclass, ","); len(buyClassArr) > 0 {
-                for _, v := range buyClassArr {
-                    i++
-                    buyerclassid := fmt.Sprint(jy.PushMapping.Buyerclass[v])
-                    if i == len(buyClassArr) {
-                        sql += buyerclassid + `)`
-                    } else {
-                        sql += buyerclassid + ","
-                    }
-                }
-            }
-        }
-        //是否存在采购单位电话
-        if c.BuyerPhone == 1 {
-            sql += ` and buyerinfo = 1`
-        } else if c.BuyerPhone == -1 {
-            sql += ` and buyerinfo = 0`
-        }
-        //是否存在中标单位电话
-        if c.WinnerPhone == 1 {
-            sql += ` and winnerinfo = 1`
-        } else if c.WinnerPhone == -1 {
-            sql += ` and winnerinfo = 0`
-        }
-        limit = config.BidCollConfig.PayUserCollLimit
-    }
-    sql += fmt.Sprintf(` order by createdate desc limit %v`, limit)
-    return sql
+		//采购单位 用,分隔开
+		if c.Buyerclass != "" {
+			i := 0
+			sql += ` and buyerclass in (`
+			if buyClassArr := strings.Split(c.Buyerclass, ","); len(buyClassArr) > 0 {
+				for _, v := range buyClassArr {
+					i++
+					buyerclassid := fmt.Sprint(jy.PushMapping.Buyerclass[v])
+					if i == len(buyClassArr) {
+						sql += buyerclassid + `)`
+					} else {
+						sql += buyerclassid + ","
+					}
+				}
+			}
+		}
+		//是否存在采购单位电话
+		if c.BuyerPhone == 1 {
+			sql += ` and buyerinfo = 1`
+		} else if c.BuyerPhone == -1 {
+			sql += ` and buyerinfo = 0`
+		}
+		//是否存在中标单位电话
+		if c.WinnerPhone == 1 {
+			sql += ` and winnerinfo = 1`
+		} else if c.WinnerPhone == -1 {
+			sql += ` and winnerinfo = 0`
+		}
+		limit = config.BidCollConfig.PayUserCollLimit
+	}
+	sql += fmt.Sprintf(` order by createdate desc limit %v`, limit)
+	return sql
 }
 
 func ConfirmIntArr(arr []interface{}) []int {
-    tmp := make([]int, 0)
-    for _, v := range arr {
-        tmp = append(tmp, qutil.IntAll(v))
-    }
-    return tmp
+	tmp := make([]int, 0)
+	for _, v := range arr {
+		tmp = append(tmp, qutil.IntAll(v))
+	}
+	return tmp
 }
 
-//判断同一个数组是否重复
+// 判断同一个数组是否重复
 func IsRepeat(slice1 []string) bool {
-    m := make(map[string]int)
-    for _, v := range slice1 {
-        m[v]++
-        if m[v] > 1 {
-            return true
-        }
-    }
-    return false
+	m := make(map[string]int)
+	for _, v := range slice1 {
+		m[v]++
+		if m[v] > 1 {
+			return true
+		}
+	}
+	return false
 }
 
-//判断数组是否包含
+// 判断数组是否包含
 func IsContain(slice []string, s string) bool {
-    for _, qq := range slice {
-        if qq == s {
-            return true
-        }
-    }
-    return false
+	for _, qq := range slice {
+		if qq == s {
+			return true
+		}
+	}
+	return false
 }
 
 // jsonStr转map
 func JsonToMap(jsonStr string) (map[string]interface{}, error) {
-    m := map[string]interface{}{}
-    err := json.Unmarshal([]byte(jsonStr), &m)
-    if err != nil {
-        fmt.Printf("Unmarshal with error: %+v\n", err)
-        return nil, err
-    }
-    return m, nil
+	m := map[string]interface{}{}
+	err := json.Unmarshal([]byte(jsonStr), &m)
+	if err != nil {
+		fmt.Printf("Unmarshal with error: %+v\n", err)
+		return nil, err
+	}
+	return m, nil
 }
 
-//判断stringArr相等方法
+// 判断stringArr相等方法
 func StringArrEqual(a, b []string) bool {
-    if (len(a) == 0) != (len(b) == 0) {
-        return false
-    }
-    if len(a) != len(b) {
-        return false
-    }
-    for i := range a {
-        if a[i] != b[i] {
-            return false
-        }
-    }
-    return true
+	if (len(a) == 0) != (len(b) == 0) {
+		return false
+	}
+	if len(a) != len(b) {
+		return false
+	}
+	for i := range a {
+		if a[i] != b[i] {
+			return false
+		}
+	}
+	return true
 }
 
-//获取频次信息:fre="周-1"(每周周一);"天-3":每三天一个周期;"日-3":每天三点;
+// 获取频次信息:fre="周-1"(每周周一);"天-3":每三天一个周期;"日-3":每天三点;
 func GetFrequencyInfo(fre string) (string, bool, int) {
-    if fre != "" && len(strings.Split(fre, "-")) > 1 {
-        f := strings.Split(fre, "-")[0]
-        d, _ := strconv.Atoi(strings.Split(fre, "-")[1])
-        switch f {
-        case "月":
-            day := time.Now().Day()
-            return fmt.Sprintf("nps_%s", time.Now().Month().String()), day == d, 31 * 24 * 60 * 60
-        case "周":
-            mi := ConvertWeekday(time.Now().Weekday().String())
-            return fmt.Sprintf("nps_%s", WeekByDate(time.Now())), mi == d, 7 * 24 * 60 * 60
-        case "日":
-            day := time.Now().Day()
-            hour := time.Now().Hour()
-            return fmt.Sprintf("nps_%s", strconv.Itoa(day)), hour == d, 24 * 60 * 60
-        case "天":
-            return fmt.Sprintf("nps_%s", strings.Split(fre, "-")[1]), true, d * 24 * 60 * 60
-        }
-    }
-    return "", false, 0
+	if fre != "" && len(strings.Split(fre, "-")) > 1 {
+		f := strings.Split(fre, "-")[0]
+		d, _ := strconv.Atoi(strings.Split(fre, "-")[1])
+		switch f {
+		case "月":
+			day := time.Now().Day()
+			return fmt.Sprintf("nps_%s", time.Now().Month().String()), day == d, 31 * 24 * 60 * 60
+		case "周":
+			mi := ConvertWeekday(time.Now().Weekday().String())
+			return fmt.Sprintf("nps_%s", WeekByDate(time.Now())), mi == d, 7 * 24 * 60 * 60
+		case "日":
+			day := time.Now().Day()
+			hour := time.Now().Hour()
+			return fmt.Sprintf("nps_%s", strconv.Itoa(day)), hour == d, 24 * 60 * 60
+		case "天":
+			return fmt.Sprintf("nps_%s", strings.Split(fre, "-")[1]), true, d * 24 * 60 * 60
+		}
+	}
+	return "", false, 0
 }
 
-//获取当年第几周
+// 获取当年第几周
 func WeekByDate(t time.Time) string {
-    yearDay := t.YearDay()
-    yearFirstDay := t.AddDate(0, 0, -yearDay+1)
-    firstDayInWeek := int(yearFirstDay.Weekday())
+	yearDay := t.YearDay()
+	yearFirstDay := t.AddDate(0, 0, -yearDay+1)
+	firstDayInWeek := int(yearFirstDay.Weekday())
 
-    //今年第一周有几天
-    firstWeekDays := 1
-    if firstDayInWeek != 0 {
-        firstWeekDays = 7 - firstDayInWeek + 1
-    }
-    var week int
-    if yearDay <= firstWeekDays {
-        week = 1
-    } else {
-        week = (yearDay-firstWeekDays)/7 + 2
-    }
-    return fmt.Sprintf("%d-%d", t.Year(), week)
+	//今年第一周有几天
+	firstWeekDays := 1
+	if firstDayInWeek != 0 {
+		firstWeekDays = 7 - firstDayInWeek + 1
+	}
+	var week int
+	if yearDay <= firstWeekDays {
+		week = 1
+	} else {
+		week = (yearDay-firstWeekDays)/7 + 2
+	}
+	return fmt.Sprintf("%d-%d", t.Year(), week)
 }
 
 func ConvertWeekday(weekday string) int {
-    _weekday := 0
-    if weekday == "Sunday" {
-        _weekday = 7
-    } else if weekday == "Monday" {
-        _weekday = 1
-    } else if weekday == "Tuesday" {
-        _weekday = 2
-    } else if weekday == "Wednesday" {
-        _weekday = 3
-    } else if weekday == "Thursday" {
-        _weekday = 4
-    } else if weekday == "Friday" {
-        _weekday = 5
-    } else if weekday == "Saturday" {
-        _weekday = 6
-    }
-    return _weekday
+	_weekday := 0
+	if weekday == "Sunday" {
+		_weekday = 7
+	} else if weekday == "Monday" {
+		_weekday = 1
+	} else if weekday == "Tuesday" {
+		_weekday = 2
+	} else if weekday == "Wednesday" {
+		_weekday = 3
+	} else if weekday == "Thursday" {
+		_weekday = 4
+	} else if weekday == "Friday" {
+		_weekday = 5
+	} else if weekday == "Saturday" {
+		_weekday = 6
+	}
+	return _weekday
 }
 
-//map转结构体
+// map转结构体
 func JsonUnmarshal(m interface{}, s interface{}) interface{} {
-    var b []byte
-    if v, ok := m.(string); ok {
-        b = []byte(v)
-    } else if v, ok := m.([]byte); ok {
-        b = v
-    } else {
-        b, _ = json.Marshal(m)
-    }
-    json.Unmarshal(b, &s)
-    return s
+	var b []byte
+	if v, ok := m.(string); ok {
+		b = []byte(v)
+	} else if v, ok := m.([]byte); ok {
+		b = v
+	} else {
+		b, _ = json.Marshal(m)
+	}
+	json.Unmarshal(b, &s)
+	return s
+}
+
+// SetCookieValue 更新cookie信息
+func SetCookieValue(rw http.ResponseWriter, name, val string, timeOut int) {
+	http.SetCookie(rw, func() *http.Cookie {
+		maxAge := timeOut //单位秒
+		expires := time.Now().Add(time.Duration(timeOut) * time.Second)
+		cookie := &http.Cookie{
+			Name:     name,
+			Value:    val,
+			Path:     "/",
+			HttpOnly: false,
+			MaxAge:   maxAge,
+			Expires:  expires,
+			Domain:   httpsession.Domain,
+		}
+		return cookie
+	}())
 }

+ 62 - 50
src/jfw/modules/weixin/src/go.mod

@@ -3,76 +3,81 @@ module jy/src/jfw/modules/weixin/src
 go 1.18
 
 require (
-	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
+	app.yhyue.com/moapp/jybase v0.0.0-20230718012114-37013054344b
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
-	app.yhyue.com/moapp/jypkg v0.0.0-20230225014640-5541595140d1
-	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13
+	app.yhyue.com/moapp/jypkg v1.0.4-0.20231108013952-a37ecebda2ed
+	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/gogf/gf/v2 v2.3.1
-	go.mongodb.org/mongo-driver v1.11.1
+	go.mongodb.org/mongo-driver v1.11.6
 )
 
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
+	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547 // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae // indirect
 	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e // indirect
-	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447 // indirect
+	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230225125145-431a4f70093a // indirect
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7 // indirect
 	github.com/BurntSushi/toml v1.1.0 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/clbanning/mxj/v2 v2.5.5 // indirect
-	github.com/coreos/go-semver v0.3.0 // indirect
-	github.com/coreos/go-systemd/v22 v22.3.2 // indirect
+	github.com/coreos/go-semver v0.3.1 // indirect
+	github.com/coreos/go-systemd/v22 v22.5.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
-	github.com/fatih/color v1.13.0 // indirect
-	github.com/felixge/fgprof v0.9.3 // indirect
+	github.com/emicklei/go-restful/v3 v3.9.0 // indirect
+	github.com/fatih/color v1.15.0 // indirect
 	github.com/fsnotify/fsnotify v1.6.0 // indirect
 	github.com/garyburd/redigo v1.6.2 // indirect
 	github.com/go-logr/logr v1.2.4 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-openapi/jsonpointer v0.19.6 // indirect
+	github.com/go-openapi/jsonreference v0.20.1 // indirect
+	github.com/go-openapi/swag v0.22.3 // indirect
 	github.com/go-redis/redis/v8 v8.11.5 // indirect
-	github.com/go-sql-driver/mysql v1.7.0 // indirect
+	github.com/go-sql-driver/mysql v1.7.1 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
-	github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
 	github.com/golang/mock v1.6.0 // indirect
-	github.com/golang/protobuf v1.5.2 // indirect
+	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
-	github.com/gomodule/redigo v1.8.9 // indirect
+	github.com/gomodule/redigo v2.0.0+incompatible // indirect
+	github.com/google/gnostic v0.5.7-v3refs // indirect
 	github.com/google/go-cmp v0.5.9 // indirect
 	github.com/google/gofuzz v1.2.0 // indirect
-	github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
-	github.com/googleapis/gnostic v0.5.5 // indirect
 	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
-	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
+	github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.1 // indirect
+	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/compress v1.15.11 // indirect
+	github.com/klauspost/compress v1.15.15 // indirect
 	github.com/magiconair/properties v1.8.7 // indirect
-	github.com/mattn/go-colorable v0.1.12 // indirect
-	github.com/mattn/go-isatty v0.0.14 // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
+	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-isatty v0.0.17 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
-	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
+	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 	github.com/nsqio/go-nsq v1.1.0 // indirect
 	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
+	github.com/olivere/elastic/v7 v7.0.22 // indirect
 	github.com/openzipkin/zipkin-go v0.4.1 // indirect
-	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
-	github.com/prometheus/client_golang v1.13.0 // indirect
-	github.com/prometheus/client_model v0.2.0 // indirect
-	github.com/prometheus/common v0.37.0 // indirect
-	github.com/prometheus/procfs v0.8.0 // indirect
+	github.com/prometheus/client_golang v1.15.1 // indirect
+	github.com/prometheus/client_model v0.3.0 // indirect
+	github.com/prometheus/common v0.42.0 // indirect
+	github.com/prometheus/procfs v0.9.0 // indirect
 	github.com/rivo/uniseg v0.2.0 // indirect
 	github.com/sirupsen/logrus v1.8.3 // indirect
 	github.com/spaolacci/murmur3 v1.1.0 // indirect
@@ -82,40 +87,44 @@ require (
 	github.com/spf13/pflag v1.0.5 // indirect
 	github.com/spf13/viper v1.15.0 // indirect
 	github.com/subosito/gotenv v1.4.2 // indirect
+	github.com/tealeg/xlsx v1.0.5 // indirect
+	github.com/thinxer/go-word2vec v0.0.0-20150917053916-5c19ec7379ed // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/scram v1.1.1 // indirect
 	github.com/xdg-go/stringprep v1.0.3 // indirect
 	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
-	github.com/zeromicro/go-zero v1.4.4 // indirect
-	go.etcd.io/etcd/api/v3 v3.5.6 // indirect
-	go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
-	go.etcd.io/etcd/client/v3 v3.5.6 // indirect
+	github.com/zeromicro/go-zero v1.5.3 // indirect
+	github.com/ziutek/blas v0.0.0-20190227122918-da4ca23e90bb // indirect
+	go.etcd.io/etcd/api/v3 v3.5.9 // indirect
+	go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
+	go.etcd.io/etcd/client/v3 v3.5.9 // indirect
 	go.opentelemetry.io/otel v1.15.1 // indirect
 	go.opentelemetry.io/otel/exporters/jaeger v1.15.1 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
 	go.opentelemetry.io/otel/exporters/zipkin v1.15.1 // indirect
 	go.opentelemetry.io/otel/sdk v1.15.1 // indirect
 	go.opentelemetry.io/otel/trace v1.15.1 // indirect
 	go.opentelemetry.io/proto/otlp v0.19.0 // indirect
-	go.uber.org/atomic v1.9.0 // indirect
-	go.uber.org/automaxprocs v1.5.1 // indirect
-	go.uber.org/multierr v1.8.0 // indirect
-	go.uber.org/zap v1.21.0 // indirect
-	golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
-	golang.org/x/net v0.8.0 // indirect
-	golang.org/x/oauth2 v0.4.0 // indirect
+	go.uber.org/atomic v1.10.0 // indirect
+	go.uber.org/automaxprocs v1.5.2 // indirect
+	go.uber.org/multierr v1.9.0 // indirect
+	go.uber.org/zap v1.24.0 // indirect
+	golang.org/x/crypto v0.6.0 // indirect
+	golang.org/x/net v0.10.0 // indirect
+	golang.org/x/oauth2 v0.7.0 // indirect
 	golang.org/x/sync v0.1.0 // indirect
-	golang.org/x/sys v0.7.0 // indirect
-	golang.org/x/term v0.6.0 // indirect
-	golang.org/x/text v0.8.0 // indirect
+	golang.org/x/sys v0.8.0 // indirect
+	golang.org/x/term v0.8.0 // indirect
+	golang.org/x/text v0.9.0 // indirect
 	golang.org/x/time v0.3.0 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
-	google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
-	google.golang.org/grpc v1.54.0 // indirect
-	google.golang.org/protobuf v1.30.0 // indirect
+	google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
+	google.golang.org/grpc v1.56.1 // indirect
+	google.golang.org/protobuf v1.31.0 // indirect
 	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect
 	gopkg.in/ini.v1 v1.67.0 // indirect
@@ -124,11 +133,14 @@ require (
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	gorm.io/driver/mysql v1.0.5 // indirect
 	gorm.io/gorm v1.21.3 // indirect
-	k8s.io/api v0.22.9 // indirect
-	k8s.io/apimachinery v0.22.9 // indirect
-	k8s.io/client-go v0.22.9 // indirect
-	k8s.io/klog/v2 v2.80.1 // indirect
-	k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
-	sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
-	sigs.k8s.io/yaml v1.2.0 // indirect
+	jygit.jydev.jianyu360.cn/ApplicationCenter/publicService v0.0.0-20231017031425-45003ca9f35a // indirect
+	k8s.io/api v0.26.3 // indirect
+	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
+	k8s.io/client-go v0.26.3 // indirect
+	k8s.io/klog/v2 v2.90.1 // indirect
+	k8s.io/kube-openapi v0.0.0-20230307230338-69ee2d25a840 // indirect
+	k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
+	sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
+	sigs.k8s.io/yaml v1.3.0 // indirect
 )

File diff suppressed because it is too large
+ 168 - 423
src/jfw/modules/weixin/src/go.sum


+ 25 - 0
src/jfw/modules/weixin/src/service/usersource.go

@@ -0,0 +1,25 @@
+package service
+
+import (
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"jy/src/jfw/modules/weixin/src/tools"
+	"time"
+)
+
+// P414
+func SaveUserSource(channelCode, userId, phone string, state int) {
+	us := jy.UserSource{
+		UserId:           userId,
+		Phone:            phone,
+		State:            state, //注册/登录标志 1:登录;2:注册
+		ChannelCode:      qutil.If(channelCode == "", "WX", channelCode).(string),
+		EncryptionUserId: encrypt.SE.Encode2Hex(userId),
+		CreateTime:       time.Now().Format(time.DateTime),
+		LoginWay:         3, //登录方式;1:手机号密码;2:手机号验证码;3:微信;4:手机号一键登录
+		Platform:         2, //登录端;1:PC;2:WX;3:APP;4:H5
+		Ip:               "",
+	}
+	jy.SaveUserSource(tools.Mysql, jy.ChannelTableName, qutil.StructToMapMore(us))
+}

+ 6 - 6
src/jfw/modules/weixin/src/wx/subscribe.go

@@ -30,7 +30,7 @@ type ReplyStruct struct {
 	User      map[string]interface{}
 }
 
-//ri 0:w.ReplyText;1:w.PostText
+// ri 0:w.ReplyText;1:w.PostText
 // isScan true:扫码;false:关注
 func (rs *ReplyStruct) SubscribeAction() (ReplyText string, ri int) {
 	ri = 0
@@ -67,7 +67,7 @@ func (rs *ReplyStruct) SubscribeAction() (ReplyText string, ri int) {
 		}
 	case "13", "130": //扫码关注项目
 		param := new(jrpc.FollowData)
-		param.UserId = FindUserId(rs.Openid) //查询userid
+		param.UserId, _ = FindUserId(rs.Openid) //查询userid
 		param.Server = fmt.Sprint(config.Sysconfig["webrpcport"])
 		param.Projectname = redis.GetStr("sso", "pc_subscribe_"+rs.Source)
 		if param.Projectname != "" {
@@ -88,7 +88,7 @@ func (rs *ReplyStruct) SubscribeAction() (ReplyText string, ri int) {
 		rs.Subkey = redis.GetStr("sso", "pc_subscribe_"+rs.Source) //企业名称
 		s_id := Findent(rs.Subkey)                                 //查询s_id
 		if rs.Subkey != "" {
-			userId := FindUserId(rs.Openid) //查询userid
+			userId, _ := FindUserId(rs.Openid) //查询userid
 			var url = fmt.Sprintf(config.Sysconfig["proxysess"].(string), tools.SE.EncodeString(fmt.Sprintf(moduleEncode, "entListFollow")))
 			pchints := config.Sysconfig["company"].(map[string]interface{})
 			if tools.MQFW.Count("jylab_followent", `{"s_userid":"`+userId+`","s_id":"`+s_id+`"}`) > 0 {
@@ -116,7 +116,7 @@ func (rs *ReplyStruct) SubscribeAction() (ReplyText string, ri int) {
 	return
 }
 
-//扫码订阅关键词
+// 扫码订阅关键词
 func (rs *ReplyStruct) ScanKeys() {
 	if rs.VipStatus > 0 {
 		if rs.Subkey != "" {
@@ -141,7 +141,7 @@ type KeysWords struct {
 	From   int      `json:"from"`
 }
 
-//免费用户扫码快速订阅关键词
+// 免费用户扫码快速订阅关键词
 func (rs *ReplyStruct) freeFastSubscribe() {
 	rs.Pcresult = "ok"
 	o_jy, _ := rs.User["o_jy"].(map[string]interface{})
@@ -201,7 +201,7 @@ func (rs *ReplyStruct) freeFastSubscribe() {
 	}
 }
 
-//付费用户扫码快速订阅关键词
+// 付费用户扫码快速订阅关键词
 func (rs *ReplyStruct) vipFastSubscribe() {
 	if rs.Subkey == "" {
 		return

+ 37 - 4
src/jfw/modules/weixin/src/wx/wx.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"jy/src/jfw/modules/weixin/src/config"
+	"jy/src/jfw/modules/weixin/src/service"
 	"net/url"
 
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
@@ -701,6 +702,7 @@ func saveUserLog(shareId, openid, activeName string, shareflag bool) {
 	userData := map[string]interface{}{}
 	action := "关注"
 	infoTime := date.Unix()
+	channelCode := ""
 	if userData_redis != nil {
 		infoData := map[string]interface{}{}
 		tmp, _ := json.Marshal(userData_redis)
@@ -714,6 +716,7 @@ func saveUserLog(shareId, openid, activeName string, shareflag bool) {
 		userData["s_activeCode"] = util.ObjToString(infoData["RActiveCode"])
 		userData["s_os"] = util.ObjToString(infoData["Ros"])
 		userData["s_browse"] = util.ObjToString(infoData["Rbrowse"])
+		channelCode = util.ObjToString(infoData["channelCode"])
 	} else {
 		userData["s_module"] = "首页"
 		userData["s_referer"] = "剑鱼标讯网站"
@@ -748,6 +751,11 @@ func saveUserLog(shareId, openid, activeName string, shareflag bool) {
 	} else {
 		log.Println("register-err:", nickname)
 	}
+	//P414
+	go func(openid, channelCode string) {
+		userId, phone := FindUserId(openid)
+		service.SaveUserSource(channelCode, userId, phone, 2)
+	}(openid, channelCode)
 }
 
 // 扫码事件
@@ -917,6 +925,28 @@ func ScanHandler(w ResponseWriter, r *Request) {
 	} else {
 		log.Println("scan-error,mongodb-conn-error")
 	}
+	//P414
+	if r.EventKey != "" {
+		go func(erCode, openid string) {
+			userData := redis.Get("sso", "p_shareData_"+erCode)
+			channelCode := ""
+			if userData != nil {
+				infoData := map[string]interface{}{}
+				tmp, err := json.Marshal(userData)
+				if err == nil {
+					if err = json.Unmarshal(tmp, &infoData); err == nil {
+						channelCode = util.ObjToString(infoData["channelCode"])
+					} else {
+						log.Println("序列化异常 infoData")
+					}
+				} else {
+					log.Println("序列化异常 userData")
+				}
+			}
+			userId, phone := FindUserId(openid)
+			service.SaveUserSource(channelCode, userId, phone, 1)
+		}(r.EventKey, openid)
+	}
 }
 
 func WxBind(code, openId string, w ResponseWriter, newUnionId string) bool {
@@ -1050,14 +1080,17 @@ func Findent(entname string) string {
 }
 
 // 通过openid查userid
-func FindUserId(openid string) string {
+func FindUserId(openid string) (userId, phone string) {
 	defer util.Catch()
-	userId := ""
-	tem, ok := tools.MQFW.FindOneByField("user", `{"s_m_openid":"`+openid+`","s_unionid":{"$ne":"`+openid+`"}}`, `{"_id":1}`)
+	tem, ok := tools.MQFW.FindOneByField("user", `{"s_m_openid":"`+openid+`","s_unionid":{"$ne":"`+openid+`"}}`, `{"_id":1,"s_m_phone":1,"s_phone":1}`)
 	if ok && len(*tem) > 0 {
 		userId = util.ObjToString(BsonIdToSId((*tem)["_id"]))
+		phone = util.ObjToString((*tem)["s_m_phone"])
+		if phone == "" {
+			phone = util.ObjToString((*tem)["s_phone"])
+		}
 	}
-	return userId
+	return
 }
 
 // 取消关注事件

+ 9 - 0
src/jfw/qrmanager/qrmanager.go

@@ -1,7 +1,9 @@
 package qrmanager
 
 import (
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	. "jy/src/jfw/config"
+	"log"
 	"net/http"
 	"regexp"
 	"strings"
@@ -26,6 +28,13 @@ func RedisInfo(oid, action, sione, sitwo string, i int, hsn *httpsession.Session
 		rhdua = rheader["User-Agent"][0]
 	}
 	userData := make(map[string]interface{})
+	//P414
+	channelCode, ckErr := hrt.Cookie(jy.ChannelCookieName)
+	if ckErr != nil {
+		log.Println("获取 合作商 code 异常或 无合作商code:", rheader)
+		channelCode.Value = "jy_pc"
+	}
+	userData["channelCode"] = channelCode.Value
 	userData["Ros"] = util.GetOS(rhdua)
 	userData["Rip"] = util.GetIp(hrt)
 	userData["Rbrowse"] = util.GetBrowse(rhdua)

Some files were not shown because too many files changed in this diff