|
@@ -1,6 +1,8 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"jy/src/jfw/modules/app/src/jfw/config"
|
|
"jy/src/jfw/modules/app/src/jfw/config"
|
|
@@ -103,18 +105,24 @@ func (l *Login) Login() error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- returnSign := ""
|
|
|
|
- userInfo := map[string]interface{}{}
|
|
|
|
- status := func() int {
|
|
|
|
|
|
+ var (
|
|
|
|
+ returnSign = ""
|
|
|
|
+ userInfo = map[string]interface{}{}
|
|
|
|
+ channelCode = qutil.If(strings.Contains(l.Request.Host, "h5"), "jy_h5_phone", "jy_app_phone").(string)
|
|
|
|
+ )
|
|
|
|
+ cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
|
|
|
|
+ if ckErr == nil {
|
|
|
|
+ channelCode = cc.Value
|
|
|
|
+ }
|
|
|
|
+ status, state := func() (int, int) {
|
|
nsqPath, _ := config.Sysconfig["nsq"].(string)
|
|
nsqPath, _ := config.Sysconfig["nsq"].(string)
|
|
nsq_topic, _ := config.Sysconfig["nsq_topic"].(string)
|
|
nsq_topic, _ := config.Sysconfig["nsq_topic"].(string)
|
|
-
|
|
|
|
reqType := l.GetString("reqType")
|
|
reqType := l.GetString("reqType")
|
|
if reqType == "phoneLogin" {
|
|
if reqType == "phoneLogin" {
|
|
phone := l.GetString("phone")
|
|
phone := l.GetString("phone")
|
|
password := l.GetString("password")
|
|
password := l.GetString("password")
|
|
if strings.TrimSpace(phone) == "" || strings.TrimSpace(password) == "" {
|
|
if strings.TrimSpace(phone) == "" || strings.TrimSpace(password) == "" {
|
|
- return -1
|
|
|
|
|
|
+ return -1, -1
|
|
}
|
|
}
|
|
query := map[string]interface{}{
|
|
query := map[string]interface{}{
|
|
"i_appid": 2,
|
|
"i_appid": 2,
|
|
@@ -134,7 +142,6 @@ func (l *Login) Login() error {
|
|
deviceId := l.GetString("deviceId")
|
|
deviceId := l.GetString("deviceId")
|
|
phoneType := l.GetString("phoneType")
|
|
phoneType := l.GetString("phoneType")
|
|
returnSign = afterLogin((*user)[0], l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
|
|
returnSign = afterLogin((*user)[0], l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
|
|
-
|
|
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", BsonIdToSId((*user)[0]["_id"]), jy.Jyapp_node1, map[string]interface{}{
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", BsonIdToSId((*user)[0]["_id"]), jy.Jyapp_node1, map[string]interface{}{
|
|
"code": 1014, //下载app任务
|
|
"code": 1014, //下载app任务
|
|
"types": "downloadApp",
|
|
"types": "downloadApp",
|
|
@@ -142,9 +149,9 @@ func (l *Login) Login() error {
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"positionId": l.GetSession("positionId"),
|
|
"positionId": l.GetSession("positionId"),
|
|
})
|
|
})
|
|
- return 1
|
|
|
|
|
|
+ return 1, 1
|
|
}
|
|
}
|
|
- return -1 //用户名或密码不正确
|
|
|
|
|
|
+ return -1, -1 //用户名或密码不正确
|
|
} else if reqType == "signLogin" {
|
|
} else if reqType == "signLogin" {
|
|
returnStatus := 0
|
|
returnStatus := 0
|
|
if l.GetSession("mgoUserId") != nil {
|
|
if l.GetSession("mgoUserId") != nil {
|
|
@@ -157,7 +164,7 @@ func (l *Login) Login() error {
|
|
(userInfo)["s_phone"] = l.GetSession("s_phone")
|
|
(userInfo)["s_phone"] = l.GetSession("s_phone")
|
|
(userInfo)["userid"] = l.GetSession("mgoUserId")
|
|
(userInfo)["userid"] = l.GetSession("mgoUserId")
|
|
(userInfo)["app_name"] = l.GetSession("app_name")
|
|
(userInfo)["app_name"] = l.GetSession("app_name")
|
|
- return returnStatus
|
|
|
|
|
|
+ return returnStatus, 2
|
|
} else if reqType == "sendIdentCode" {
|
|
} else if reqType == "sendIdentCode" {
|
|
phone := jy.CheckSendMsg(l.GetString("token"))
|
|
phone := jy.CheckSendMsg(l.GetString("token"))
|
|
if phone == "" {
|
|
if phone == "" {
|
|
@@ -165,18 +172,18 @@ func (l *Login) Login() error {
|
|
}
|
|
}
|
|
//手机号验证不通过
|
|
//手机号验证不通过
|
|
if phone == "" {
|
|
if phone == "" {
|
|
- return -2
|
|
|
|
|
|
+ return -2, -1
|
|
} else if !phoneReg.MatchString(phone) {
|
|
} else if !phoneReg.MatchString(phone) {
|
|
- return -1
|
|
|
|
|
|
+ return -1, -1
|
|
} else if jy.SendPhoneIdentCode(qutil.ObjToString(config.Sysconfig["smsServiceRpc"]), phone, l.Session()) {
|
|
} 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" {
|
|
} else if reqType == "identCodeLogin" {
|
|
disWord := l.GetString("disWord")
|
|
disWord := l.GetString("disWord")
|
|
phone, _ := l.GetSession("identCodeKey").(string)
|
|
phone, _ := l.GetSession("identCodeKey").(string)
|
|
if phone == "" || l.GetSession("identCodeValue") == nil || l.GetString("identCode") != l.GetSession("identCodeValue") { //验证码不正确
|
|
if phone == "" || l.GetSession("identCodeValue") == nil || l.GetString("identCode") != l.GetSession("identCodeValue") { //验证码不正确
|
|
- return -1
|
|
|
|
|
|
+ return -1, -1
|
|
} else {
|
|
} else {
|
|
RegLock.Lock()
|
|
RegLock.Lock()
|
|
reg := RegMap[phone]
|
|
reg := RegMap[phone]
|
|
@@ -193,7 +200,7 @@ func (l *Login) Login() error {
|
|
ok, user := getPhoneUser(phone)
|
|
ok, user := getPhoneUser(phone)
|
|
//登录成功
|
|
//登录成功
|
|
if !ok {
|
|
if !ok {
|
|
- return 0
|
|
|
|
|
|
+ return 0, -1
|
|
}
|
|
}
|
|
//用户不存在
|
|
//用户不存在
|
|
rid := l.GetString("rid")
|
|
rid := l.GetString("rid")
|
|
@@ -221,6 +228,7 @@ func (l *Login) Login() error {
|
|
"l_modifydate": time.Now().Unix(),
|
|
"l_modifydate": time.Now().Unix(),
|
|
},
|
|
},
|
|
"s_platform": "app",
|
|
"s_platform": "app",
|
|
|
|
+ "s_sourceid": channelCode,
|
|
}
|
|
}
|
|
// 新用户注册 记录活动来源
|
|
// 新用户注册 记录活动来源
|
|
activity := l.GetString("activity")
|
|
activity := l.GetString("activity")
|
|
@@ -241,7 +249,7 @@ func (l *Login) Login() error {
|
|
data["base_user_id"] = resp.Data.Id
|
|
data["base_user_id"] = resp.Data.Id
|
|
} else {
|
|
} else {
|
|
log.Println(phone, "调用usercenter失败")
|
|
log.Println(phone, "调用usercenter失败")
|
|
- return -4
|
|
|
|
|
|
+ return -4, -1
|
|
}
|
|
}
|
|
_id := mongodb.Save("user", data)
|
|
_id := mongodb.Save("user", data)
|
|
if _id != "" {
|
|
if _id != "" {
|
|
@@ -276,7 +284,7 @@ func (l *Login) Login() error {
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"positionId": l.GetSession("positionId"),
|
|
"positionId": l.GetSession("positionId"),
|
|
})
|
|
})
|
|
- return 1
|
|
|
|
|
|
+ return 1, 3
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//以s_m_phone登录的 需要把s_m_phone转化为s_phone
|
|
//以s_m_phone登录的 需要把s_m_phone转化为s_phone
|
|
@@ -297,7 +305,6 @@ func (l *Login) Login() error {
|
|
}
|
|
}
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
returnSign = afterLogin(user, l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
|
|
returnSign = afterLogin(user, l.Session(), rid, oid, phoneType, channel, deviceId, false, l.ResponseWriter)
|
|
-
|
|
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", BsonIdToSId(user["_id"]), jy.Jyapp_node1, map[string]interface{}{
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", BsonIdToSId(user["_id"]), jy.Jyapp_node1, map[string]interface{}{
|
|
"code": 1014, //下载app任务
|
|
"code": 1014, //下载app任务
|
|
"types": "downloadApp",
|
|
"types": "downloadApp",
|
|
@@ -305,12 +312,28 @@ func (l *Login) Login() error {
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"positionId": l.GetSession("positionId"),
|
|
"positionId": l.GetSession("positionId"),
|
|
})
|
|
})
|
|
- return 1
|
|
|
|
|
|
+ return 1, 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return 0
|
|
|
|
|
|
+ return 0, -1
|
|
}()
|
|
}()
|
|
|
|
+ //登录source 更新 p414
|
|
|
|
+ us := jy.UserSource{
|
|
|
|
+ UserId: qutil.ObjToString(l.GetSession("mgoUserId")),
|
|
|
|
+ PositionId: qutil.Int64All(l.GetSession("positionId")),
|
|
|
|
+ Phone: qutil.ObjToString(l.GetSession("phone")),
|
|
|
|
+ State: qutil.If(state == 3, 2, 1).(int), //注册/登录标志 1:登录;2:注册
|
|
|
|
+ ChannelCode: channelCode,
|
|
|
|
+ EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
|
|
|
|
+ CreateTime: time.Now().Format(date.Date_Full_Layout),
|
|
|
|
+ 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{}{
|
|
result := map[string]interface{}{
|
|
"status": status,
|
|
"status": status,
|
|
"userId": l.GetSession("mgoUserId"),
|
|
"userId": l.GetSession("mgoUserId"),
|
|
@@ -486,9 +509,16 @@ func (l *Login) Register() error {
|
|
}
|
|
}
|
|
return l.Render("/me/register.html", &l.T)
|
|
return l.Render("/me/register.html", &l.T)
|
|
}
|
|
}
|
|
- var returnSign string
|
|
|
|
- nsqPath, _ := config.Sysconfig["nsq"].(string)
|
|
|
|
- nsq_topic, _ := config.Sysconfig["nsq_topic"].(string)
|
|
|
|
|
|
+ var (
|
|
|
|
+ returnSign string
|
|
|
|
+ nsqPath, _ = config.Sysconfig["nsq"].(string)
|
|
|
|
+ nsq_topic, _ = config.Sysconfig["nsq_topic"].(string)
|
|
|
|
+ channelCode = qutil.If(strings.Contains(l.Request.Host, "h5"), "jy_h5_phone", "jy_app_phone").(string)
|
|
|
|
+ cc, ckErr = l.Request.Cookie(jy.ChannelCookieName)
|
|
|
|
+ )
|
|
|
|
+ if ckErr == nil {
|
|
|
|
+ channelCode = cc.Value
|
|
|
|
+ }
|
|
status := func() string {
|
|
status := func() string {
|
|
reqType := l.GetString("reqType")
|
|
reqType := l.GetString("reqType")
|
|
if reqType == "sendIdentCode" { //发短信
|
|
if reqType == "sendIdentCode" { //发短信
|
|
@@ -540,6 +570,7 @@ func (l *Login) Register() error {
|
|
"s_opushid": oid,
|
|
"s_opushid": oid,
|
|
"s_appponetype": phoneType,
|
|
"s_appponetype": phoneType,
|
|
"s_company": s_entname,
|
|
"s_company": s_entname,
|
|
|
|
+ "s_sourceid": channelCode,
|
|
}
|
|
}
|
|
email := l.GetString("email")
|
|
email := l.GetString("email")
|
|
registerclient := jy.NewRegister(jyutil.Compatible.Mgo, jyutil.Compatible.BaseService, jyutil.Compatible.MainMysql, jyutil.Compatible.Middleground)
|
|
registerclient := jy.NewRegister(jyutil.Compatible.Mgo, jyutil.Compatible.BaseService, jyutil.Compatible.MainMysql, jyutil.Compatible.Middleground)
|
|
@@ -569,7 +600,7 @@ func (l *Login) Register() error {
|
|
}()
|
|
}()
|
|
l.DelSession("registerStep")
|
|
l.DelSession("registerStep")
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
-
|
|
|
|
|
|
+ //剑鱼币
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
|
|
"code": 1014, //下载app任务
|
|
"code": 1014, //下载app任务
|
|
"types": "downloadApp",
|
|
"types": "downloadApp",
|
|
@@ -580,7 +611,7 @@ func (l *Login) Register() error {
|
|
})
|
|
})
|
|
if errStr == "y" {
|
|
if errStr == "y" {
|
|
returnSign = afterLogin(data, l.Session(), rid, oid, phoneType, channel, deviceId, true, l.ResponseWriter)
|
|
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{}{
|
|
jy.Publish(public.Mgo_Log, nsqPath, nsq_topic, "task", qutil.ObjToString(l.GetSession("mgoUserId")), jy.Jyapp_node1, map[string]interface{}{
|
|
"code": 1014, //下载app任务
|
|
"code": 1014, //下载app任务
|
|
"types": "downloadApp",
|
|
"types": "downloadApp",
|
|
@@ -588,6 +619,22 @@ func (l *Login) Register() error {
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"positionId": l.GetSession("positionId"),
|
|
"positionId": l.GetSession("positionId"),
|
|
})
|
|
})
|
|
|
|
+ //登录source 更新 p414
|
|
|
|
+ us := jy.UserSource{
|
|
|
|
+ UserId: qutil.ObjToString(l.GetSession("mgoUserId")),
|
|
|
|
+ PositionId: qutil.Int64All(l.GetSession("positionId")),
|
|
|
|
+ Phone: qutil.ObjToString(l.GetSession("phone")),
|
|
|
|
+ State: 2, //注册/登录标志 1:登录;2:注册
|
|
|
|
+ ChannelCode: channelCode,
|
|
|
|
+ EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
|
|
|
|
+ CreateTime: time.Now().Format(date.Date_Full_Layout),
|
|
|
|
+ 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
|
|
return errStr
|
|
}()
|
|
}()
|
|
@@ -615,6 +662,11 @@ func (l *Login) WxLogin() {
|
|
disWord := l.GetString("disWord")
|
|
disWord := l.GetString("disWord")
|
|
defer qutil.Catch()
|
|
defer qutil.Catch()
|
|
returnSign := ""
|
|
returnSign := ""
|
|
|
|
+ channelCode := "jy_app_wx"
|
|
|
|
+ cc, ckErr := l.Request.Cookie(jy.ChannelCookieName)
|
|
|
|
+ if ckErr == nil {
|
|
|
|
+ channelCode = cc.Value
|
|
|
|
+ }
|
|
status := func() int {
|
|
status := func() int {
|
|
u, err := jy.GetMsgFromWxSign(l.GetString("param"))
|
|
u, err := jy.GetMsgFromWxSign(l.GetString("param"))
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -716,6 +768,7 @@ func (l *Login) WxLogin() {
|
|
},
|
|
},
|
|
"s_platform": "app", //用户注册平台 app 微信 pc
|
|
"s_platform": "app", //用户注册平台 app 微信 pc
|
|
"s_jyname": jy.GetUserName("newother", config.Sysconfig["namePrefix"].(string)), //剑鱼昵称
|
|
"s_jyname": jy.GetUserName("newother", config.Sysconfig["namePrefix"].(string)), //剑鱼昵称
|
|
|
|
+ "s_sourceid": channelCode,
|
|
}
|
|
}
|
|
//注册邮箱
|
|
//注册邮箱
|
|
email := l.GetString("email")
|
|
email := l.GetString("email")
|
|
@@ -758,7 +811,7 @@ func (l *Login) WxLogin() {
|
|
log.Println("nsq队列写入失败-->", jy.Jyapp_wx_register, _id)
|
|
log.Println("nsq队列写入失败-->", jy.Jyapp_wx_register, _id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return 1
|
|
|
|
|
|
+ return 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0
|
|
return 0
|
|
@@ -773,9 +826,27 @@ func (l *Login) WxLogin() {
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"baseUserId": l.GetSession("base_user_id"),
|
|
"positionId": l.GetSession("positionId"),
|
|
"positionId": l.GetSession("positionId"),
|
|
})
|
|
})
|
|
|
|
+ if status > 0 {
|
|
|
|
+ //登录source 更新 p414
|
|
|
|
+ us := jy.UserSource{
|
|
|
|
+ UserId: qutil.ObjToString(l.GetSession("mgoUserId")),
|
|
|
|
+ PositionId: qutil.Int64All(l.GetSession("positionId")),
|
|
|
|
+ Phone: qutil.ObjToString(l.GetSession("phone")),
|
|
|
|
+ State: status, //注册/登录标志 1:登录;2:注册
|
|
|
|
+ ChannelCode: channelCode,
|
|
|
|
+ EncryptionUserId: encrypt.SE.Encode2Hex(qutil.ObjToString(l.GetSession("userId"))),
|
|
|
|
+ CreateTime: time.Now().Format(date.Date_Full_Layout),
|
|
|
|
+ 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{}{
|
|
result := map[string]interface{}{
|
|
- "status": status,
|
|
|
|
|
|
+ "status": qutil.If(status > 0, 1, status).(int),
|
|
"userId": l.GetSession("mgoUserId"),
|
|
"userId": l.GetSession("mgoUserId"),
|
|
}
|
|
}
|
|
if returnSign != "" {
|
|
if returnSign != "" {
|