xingzai 3 lat temu
rodzic
commit
7d0c91b5b1
1 zmienionych plików z 22 dodań i 12 usunięć
  1. 22 12
      controllers/activity.go

+ 22 - 12
controllers/activity.go

@@ -101,6 +101,8 @@ func (this *ActivityCoAntroller) ActivityList() {
 	}
 	if isShowJurisdiction == 1 && chartPermissionIds == "" {
 		resp := new(models.GetCygxActivityListRep)
+		page := paging.GetPaging(currentIndex, pageSize, 0)
+		resp.Paging = page
 		br.Ret = 200
 		br.Success = true
 		br.Msg = "获取成功"
@@ -148,6 +150,7 @@ func (this *ActivityCoAntroller) ActivityList() {
 			}
 		}
 	}
+	fmt.Println(userType)
 	var startSize int
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
@@ -293,7 +296,8 @@ func (this *ActivityCoAntroller) Detail() {
 		br.Msg = "请输入活动ID"
 		return
 	}
-
+	resp := new(models.CygxActivityResp)
+	hasPermission := 0
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
 		companyDetailStatus = ""
@@ -319,6 +323,7 @@ func (this *ActivityCoAntroller) Detail() {
 		return
 	}
 	var userType int
+	var permissionStr string
 	if user.CompanyId <= 1 {
 		userType = 0
 	} else {
@@ -343,7 +348,7 @@ func (this *ActivityCoAntroller) Detail() {
 		} else if companyDetail.Status == "试用" {
 			userType = 5
 		} else if companyDetail.Status == "正式" {
-			permissionStr, err := models.GetCompanyPermission(user.CompanyId)
+			permissionStr, err = models.GetCompanyPermission(user.CompanyId)
 			if err != nil {
 				br.Msg = "获取信息失败"
 				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
@@ -351,20 +356,26 @@ func (this *ActivityCoAntroller) Detail() {
 			}
 			if permissionStr == "专家" {
 				userType = 4
-			}
-			if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
+			} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
 				userType = 2
 			} else {
 				userType = 3
 			}
 		}
 	}
-	//if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) && activityInfo.LimitPeopleNum > 0 {
-	//	br.Msg = "您暂无权限查看该活动"
-	//	return
-	//}
-	fmt.Println(userType)
-
+	if userType == 3 {
+		if !strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum > 0 && (!strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) || activityInfo.CustomerTypeIds == "4") {
+			br.Msg = "您暂无权限查看该活动"
+			br.ErrMsg = "您暂无权限查看该活动,uid:" + strconv.Itoa(uid) + "activityId :" + strconv.Itoa(activityId)
+			return
+		}
+	} else {
+		if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) && activityInfo.LimitPeopleNum > 0 {
+			br.Msg = "您暂无权限查看该活动"
+			br.ErrMsg = "您暂无权限查看该活动,uid:" + strconv.Itoa(uid) + "activityId :" + strconv.Itoa(activityId)
+			return
+		}
+	}
 	detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
 	if errDetail != nil {
 		br.Msg = "获取信息失败"
@@ -381,8 +392,7 @@ func (this *ActivityCoAntroller) Detail() {
 		activityInfo.SignupType = detail.SignupType
 	}
 	activityInfo.ShowType = detail.ShowType
-	resp := new(models.CygxActivityResp)
-	hasPermission := 0
+
 	//判断是否已经申请过
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {