浏览代码

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 7 月之前
父节点
当前提交
41a8f1843d
共有 3 个文件被更改,包括 21 次插入11 次删除
  1. 14 10
      controllers/yanxuan_special.go
  2. 1 1
      models/wx_user.go
  3. 6 0
      services/rai_serve_count.go

+ 14 - 10
controllers/yanxuan_special.go

@@ -150,8 +150,8 @@ func (this *YanxuanSpecialController) Detail() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -167,7 +167,7 @@ func (this *YanxuanSpecialController) Detail() {
 		return
 	}
 
-	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, user.UserId)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -213,12 +213,12 @@ func (this *YanxuanSpecialController) 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
 	}
@@ -249,12 +249,12 @@ func (this *YanxuanSpecialController) Detail() {
 		resp.ContentHasStyle = true
 	}
 
-	if resp.HasPermission != 1 || sysUser.UserId == 0 {
+	if resp.HasPermission != 1 || user.UserId == 0 {
 		resp.Content = services.AnnotationHtml(resp.Content)
 	}
 
-	if sysUser.UserId > 0 {
-		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(sysUser.UserId, item.UserId)
+	if user.UserId > 0 {
+		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(user.UserId, item.UserId)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败, Err:" + err.Error()
@@ -268,17 +268,21 @@ func (this *YanxuanSpecialController) Detail() {
 	}
 
 	//校验研选专栏权限,以及无权限的时候的对应状态码
-	havePower, err := services.GetYanxuanSpecialDetailUserPower(sysUser)
+	havePower, err := services.GetYanxuanSpecialDetailUserPower(user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	//看自己的文章时不设权限限制,不需要判断是否有研选订阅权限,都可以看。
+	if user.UserId == item.UserId {
+		havePower = true
+	}
 	var hasPermission int
 	if havePower {
 		hasPermission = 1
 	} else {
-		hasPermission, err = services.GetUserDetailPermissionCode(sysUser.UserId, sysUser.CompanyId)
+		hasPermission, err = services.GetUserDetailPermissionCode(user.UserId, user.CompanyId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户权限状态失败,Err:" + err.Error()

+ 1 - 1
models/wx_user.go

@@ -662,7 +662,7 @@ func GetWxUserisMakerByCompanyIds(companyIds []int) (items []*WxUser, err error)
 	if lenArr == 0 {
 		return
 	}
-	sql := `SELECT user_id  FROM wx_user  WHERE company_id in (` + utils.GetOrmInReplace(lenArr) + `) AND is_maker = 1   `
+	sql := `SELECT user_id,mobile FROM wx_user  WHERE company_id in (` + utils.GetOrmInReplace(lenArr) + `) AND is_maker = 1   `
 	o := orm.NewOrmUsingDB("weekly_report")
 	_, err = o.Raw(sql, companyIds).QueryRows(&items)
 	return

+ 6 - 0
services/rai_serve_count.go

@@ -447,8 +447,10 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 		return
 	}
 	mapUserMaker := make(map[int]bool)
+	mapUserMobileUserId := make(map[string]int)
 	for _, v := range listisMakeruser {
 		mapUserMaker[v.UserId] = true
+		mapUserMobileUserId[v.Mobile] = v.UserId
 	}
 
 	var condition string
@@ -664,6 +666,10 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 				item.ServeTypeId = 2
 				item.ServeTypeName = "线下活动"
 			}
+			if v.UserId == 0 && v.Mobile != "" {
+				v.UserId = mapUserMobileUserId[v.Mobile] // 空降的部分联系人 userid 为0这里做一下修复
+			}
+
 			item.UserId = v.UserId
 			item.Mobile = v.Mobile
 			item.Email = v.Email