Browse Source

no message

xingzai 1 year ago
parent
commit
ed98e16da3
2 changed files with 50 additions and 8 deletions
  1. 3 2
      controllers/base_auth_mobile.go
  2. 47 6
      controllers/yanxuan_special.go

+ 3 - 2
controllers/base_auth_mobile.go

@@ -46,7 +46,7 @@ func (this *BaseAuthMobileController) Prepare() {
 				nilWxUser := new(models.WxUserItem)
 				this.User = nilWxUser
 			} else {
-				session, err := models.GetCygxSessionMobile(authorization)
+				session, err := models.GetSessionByToken(authorization)
 				if err != nil {
 					if err.Error() == utils.ErrNoRow() {
 						this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
@@ -62,8 +62,9 @@ func (this *BaseAuthMobileController) Prepare() {
 					this.StopRun()
 					return
 				}
+				wxUser, err := services.GetWxUserItemByOpenId(session.OpenId)
 				//wxUser, err := models.GetWxUserItemByUserId(session.UserId)
-				wxUser, err := models.GetWxUserAouthByMobile(session.Mobile)
+				//wxUser, err := models.GetWxUserAouthByMobile(session.Mobile)
 				if err != nil && err != services.ERR_USER_NOT_BIND {
 					if err.Error() == utils.ErrNoRow() {
 						this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "获取信息失败 " + strconv.Itoa(session.UserId)}, false, false)

+ 47 - 6
controllers/yanxuan_special.go

@@ -148,7 +148,7 @@ func (this *BaseAuthMobileController) Detail() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
+	user := this.User
 	//if sysUser == nil {
 	//	br.Msg = "请登录"
 	//	br.ErrMsg = "请登录1,SysUser Is Empty"
@@ -164,8 +164,8 @@ func (this *BaseAuthMobileController) Detail() {
 		br.ErrMsg = "参数错误"
 		return
 	}
-	userId := sysUser.UserId
-	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	userId := user.UserId
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, user.UserId)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -177,7 +177,6 @@ func (this *BaseAuthMobileController) Detail() {
 
 	var resp models.CygxYanxuanSpecialResp
 
-	resp.HasPermission = 1
 	resp.CygxYanxuanSpecialItem = *item
 	if item.DocUrl != "" {
 		var docs []models.Doc
@@ -211,12 +210,12 @@ func (this *BaseAuthMobileController) Detail() {
 		return
 	}
 
-	if isSendWx == 1 && strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
+	if isSendWx == 1 && strings.Contains(cnf.ConfigValue, user.Mobile) {
 		resp.IsShowExamine = true
 		resp.ExamineStatus = item.Status
 	}
 	resp.ExamineStatus = item.Status
-	if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
+	if item.UserId != user.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, user.Mobile) {
 		resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
 		resp.HasPermission = 2
 	}
@@ -234,6 +233,48 @@ func (this *BaseAuthMobileController) Detail() {
 		resp.ContentHasStyle = true
 	}
 
+	var hasPermission int
+	if user.CompanyId > 1 {
+		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
+		}
+		if companyItem != nil && companyItem.CompanyId > 0 {
+
+			//查询研选的权限状态
+			var condition string
+			var pars []interface{}
+			condition += " AND company_id = ?  AND status  IN ('正式','试用')  AND chart_permission_id = ?   ORDER BY company_report_permission_id DESC LIMIT 1  "
+			pars = append(pars, user.CompanyId, utils.CHART_PERMISSION_ID_YANXUAN)
+			companyReportPermissionDetail, err := models.GetCompanyReportPermissionDetailByCondition(condition, pars)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户所在公司剩余的点失败,Err:" + err.Error()
+				return
+			}
+			if companyReportPermissionDetail == nil {
+				hasPermission = 1
+			}
+		} else {
+			hasPermission = 1
+		}
+	} else {
+		//判断是否已经申请过
+		applyCount, err := models.GetApplyRecordCount(userId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		if applyCount > 0 {
+			hasPermission = 3
+		} else {
+			hasPermission = 2
+		}
+	}
+	resp.HasPermission = hasPermission
 	if userId == 0 {
 		resp.Content = utils.InterceptHtmlLength(resp.Content, 240) // 截取前80个字
 	}