rdluck 4 years ago
parent
commit
1f1df6e321
3 changed files with 12 additions and 8 deletions
  1. 9 7
      controllers/user.go
  2. 1 1
      models/user_record.go
  3. 2 0
      services/wechat_send_msg.go

+ 9 - 7
controllers/user.go

@@ -398,23 +398,25 @@ func (this *UserController) CheckLogin() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	if this.User == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录"
 		br.Ret = 408
 		return
 	}
-	uid := this.User.UserId
+
+	uid := user.UserId
 	resp := new(models.CheckStatusResp)
 	if uid > 0 {
 		//判断token是否过期
-		userItem, err := models.GetWxUserItemByUserId(uid)
+		userRecord, err := models.GetUserRecordByUserId(uid, utils.WxPlatform)
 		if err != nil {
 			br.Msg = "获取用户信息失败"
 			br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
 			return
 		}
-		permissionStr, err := models.GetCompanyPermission(userItem.CompanyId)
+		permissionStr, err := models.GetCompanyPermission(user.CompanyId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
@@ -422,10 +424,10 @@ func (this *UserController) CheckLogin() {
 		}
 		resp.PermissionName = permissionStr
 
-		if userItem.Mobile == "" && userItem.Email == "" {
+		if user.Mobile == "" && user.Email == "" {
 			resp.IsBind = true
 		}
-		if userItem.UnionId == "" {
+		if userRecord.UnionId == "" {
 			resp.IsAuth = true
 		}
 	} else {
@@ -850,7 +852,7 @@ func (this *UserController) ApplyTryOut() {
 		}
 		cnf, _ := models.GetConfigByCode("tpl_msg")
 		if cnf != nil {
-			openIpItem, _ := models.GetWxUserItemByMobile(cnf.ConfigValue)
+			openIpItem, _ := models.GetUserRecordByUserId(user.UserId, 1)
 			if openIpItem != nil && openIpItem.OpenId != "" {
 				go services.SendPermissionApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			}

+ 1 - 1
models/user_record.go

@@ -59,4 +59,4 @@ func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country
 	sql := `UPDATE user_record SET nick_name=?,headimgurl=?,sex=?,city=?,province=?,country=? WHERE user_id=? and open_id=? `
 	_, err = o.Raw(sql, nickName, headimgUrl, sex, city, province, country, userId, openId).Exec()
 	return
-}
+}

+ 2 - 0
services/wechat_send_msg.go

@@ -11,6 +11,7 @@ import (
 	"time"
 )
 
+//访谈申请
 func SendInterviewApplyTemplateMsg(realName, companyName, mobile, articleTitle, openId string) (err error) {
 	var msg string
 	defer func() {
@@ -59,6 +60,7 @@ func SendInterviewApplyTemplateMsg(realName, companyName, mobile, articleTitle,
 	return
 }
 
+//访谈申请取消
 func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleTitle, openId string) (err error) {
 	var msg string
 	defer func() {