Sfoglia il codice sorgente

查研观向4.4版本

xingzai 3 anni fa
parent
commit
58c653c8c4

+ 272 - 62
controllers/activity.go

@@ -158,6 +158,8 @@ func (this *ActivityCoAntroller) ActivityList() {
 		}
 		}
 	}
 	}
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	if userType == 2 {
 	if userType == 2 {
@@ -574,6 +576,14 @@ func (this *ActivityCoAntroller) Detail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
+
+	//获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
 	if user.CompanyId <= 1 {
 	if user.CompanyId <= 1 {
 		companyDetailStatus = ""
 		companyDetailStatus = ""
 	} else {
 	} else {
@@ -587,11 +597,28 @@ func (this *ActivityCoAntroller) Detail() {
 			if applyCount > 0 {
 			if applyCount > 0 {
 				hasPermission = 4
 				hasPermission = 4
 			} else {
 			} else {
-				hasPermission = 3
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
 			}
 			}
 			resp.HasPermission = hasPermission
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Ret = 200
 			br.Success = true
 			br.Success = true
 			br.Msg = "获取成功"
 			br.Msg = "获取成功"
@@ -657,7 +684,8 @@ func (this *ActivityCoAntroller) Detail() {
 	//判断是否已经申请过
 	//判断是否已经申请过
 
 
 	if user.CompanyId > 1 {
 	if user.CompanyId > 1 {
-		permissionStr, err := models.GetCompanyPermission(user.CompanyId)
+		permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
+		fmt.Println(permissionStr)
 		if err != nil {
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
 			br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
@@ -667,9 +695,31 @@ func (this *ActivityCoAntroller) Detail() {
 		//冻结客户
 		//冻结客户
 		if err != nil {
 		if err != nil {
 			if err.Error() == utils.ErrNoRow() {
 			if err.Error() == utils.ErrNoRow() {
-				resp.HasPermission = 4
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+						sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+						if err != nil && err.Error() != utils.ErrNoRow() {
+							br.Msg = "获取信息失败"
+							br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+							return
+						}
+						if sellerItemQy != nil {
+							hasPermission = 2
+							resp.SellerMobile = sellerItemQy.Mobile
+							resp.SellerName = sellerItemQy.RealName
+						} else {
+							hasPermission = 3
+						}
+					}
+				}
+				resp.HasPermission = hasPermission
 				resp.OperationMode = "Apply"
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Ret = 200
 				br.Success = true
 				br.Success = true
 				br.Msg = "获取成功"
 				br.Msg = "获取成功"
@@ -687,25 +737,41 @@ func (this *ActivityCoAntroller) Detail() {
 			resp.HaqveJurisdiction = true
 			resp.HaqveJurisdiction = true
 		} else {
 		} else {
 			if permissionStr == "专家" {
 			if permissionStr == "专家" {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				resp.MsgType = "Type"
 				resp.MsgType = "Type"
 			} else {
 			} else {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动"
+				//if strings.Contains("医药,消费,科技,智造", activityInfo.ChartPermissionName) {
+				//	if activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6 {
+				//		activityInfo.ChartPermissionName += "(主观)"
+				//	} else {
+				//		activityInfo.ChartPermissionName += "(客观)"
+				//	}
+				//}
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				resp.MsgType = "Industry"
 				resp.MsgType = "Industry"
 			}
 			}
-			resp.SellerMobile = companyItem.Mobile
-			resp.SellerName = companyItem.SellerName
-			resp.OperationMode = "Call"
-			hasPermission = 2
+			if companyItem.ProductId == 2 {
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
+				resp.OperationMode = "Call"
+				hasPermission = 2
+			} else {
+				hasPermission = 5
+			}
+
 		}
 		}
 	} else { //潜在客户
 	} else { //潜在客户
 		if applyCount > 0 {
 		if applyCount > 0 {
 			hasPermission = 4
 			hasPermission = 4
 		} else {
 		} else {
-			hasPermission = 3
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
 		}
 		}
 		resp.OperationMode = "Apply"
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	}
 	if hasPermission == 1 {
 	if hasPermission == 1 {
 		//是否展示限免标签
 		//是否展示限免标签
@@ -777,6 +843,15 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
+
+	//获取FICC销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "申请失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+
 	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
 	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
 	if activityInfo == nil {
 	if activityInfo == nil {
 		br.Msg = "操作失败"
 		br.Msg = "操作失败"
@@ -804,11 +879,29 @@ func (this *ActivityCoAntroller) SignupAdd() {
 			if applyCount > 0 {
 			if applyCount > 0 {
 				hasPermission = 4
 				hasPermission = 4
 			} else {
 			} else {
-				hasPermission = 3
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
 			}
 			}
 			resp.HasPermission = hasPermission
 			resp.HasPermission = hasPermission
+			resp.ActivityId = activityId
 			resp.OperationMode = "Apply"
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Ret = 200
 			br.Success = true
 			br.Success = true
 			br.Msg = "获取成功"
 			br.Msg = "获取成功"
@@ -848,9 +941,19 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		//冻结客户
 		//冻结客户
 		if err != nil {
 		if err != nil {
 			if err.Error() == utils.ErrNoRow() {
 			if err.Error() == utils.ErrNoRow() {
-				resp.HasPermission = 4
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						hasPermission = 3
+					}
+				}
+				resp.ActivityId = activityId
+				resp.HasPermission = hasPermission
 				resp.OperationMode = "Apply"
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Ret = 200
 				br.Success = true
 				br.Success = true
 				br.Msg = "获取成功"
 				br.Msg = "获取成功"
@@ -1064,27 +1167,35 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				resp.HaqveJurisdiction = true
 				resp.HaqveJurisdiction = true
 			}
 			}
 		} else {
 		} else {
-			hasPermission = 2
-			resp.SellerMobile = companyItem.Mobile
-			resp.SellerName = companyItem.SellerName
-			resp.MsgType = "Type"
-			resp.OperationMode = "Call"
-			if permissionStr == "专家" {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+			if companyItem.ProductId == 2 {
+				hasPermission = 2
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
 				resp.MsgType = "Type"
 				resp.MsgType = "Type"
+				resp.OperationMode = "Call"
+				if permissionStr == "专家" {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Type"
+				} else {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Industry"
+				}
 			} else {
 			} else {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				resp.MsgType = "Industry"
+				hasPermission = 5
 			}
 			}
 		}
 		}
 	} else { //潜在客户
 	} else { //潜在客户
 		if applyCount > 0 {
 		if applyCount > 0 {
 			hasPermission = 4
 			hasPermission = 4
 		} else {
 		} else {
-			hasPermission = 3
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
 		}
 		}
 		resp.OperationMode = "Apply"
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	}
 	if signupType == 1 && user.IsMsgOutboundMobile == 0 {
 	if signupType == 1 && user.IsMsgOutboundMobile == 0 {
 		resp.GoOutboundMobile = true
 		resp.GoOutboundMobile = true
@@ -1120,9 +1231,9 @@ func (this *ActivityCoAntroller) SignupAdd() {
 	resp.SignupType = signupType
 	resp.SignupType = signupType
 	resp.SignupStatus = signupStatus
 	resp.SignupStatus = signupStatus
 	resp.HasPermission = hasPermission
 	resp.HasPermission = hasPermission
-	if signupStatus == "Success" {
-		resp.ActivityId = activityId
-	}
+	//if signupStatus == "Success" {
+	resp.ActivityId = activityId
+	//}
 	total, err = models.GetUserSignupCount(user.UserId)
 	total, err = models.GetUserSignupCount(user.UserId)
 	if err != nil {
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取信息失败"
@@ -1387,6 +1498,15 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
+
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "申请失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+
 	//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
 	//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
 	item := new(models.CygxActivityMeetingReminder)
 	item := new(models.CygxActivityMeetingReminder)
 	resp := new(models.SignupStatus)
 	resp := new(models.SignupStatus)
@@ -1405,11 +1525,29 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			if applyCount > 0 {
 			if applyCount > 0 {
 				hasPermission = 4
 				hasPermission = 4
 			} else {
 			} else {
-				hasPermission = 3
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
 			}
 			}
+			resp.ActivityId = activityId
 			resp.HasPermission = hasPermission
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Ret = 200
 			br.Success = true
 			br.Success = true
 			br.Msg = "获取成功"
 			br.Msg = "获取成功"
@@ -1452,9 +1590,20 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		//冻结客户
 		//冻结客户
 		if err != nil {
 		if err != nil {
 			if err.Error() == utils.ErrNoRow() {
 			if err.Error() == utils.ErrNoRow() {
-				resp.HasPermission = 4
+				//如果是FICC的客户类型,则默认他申请过
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						hasPermission = 3
+					}
+				}
+				resp.ActivityId = activityId
+				resp.HasPermission = hasPermission
 				resp.OperationMode = "Apply"
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Ret = 200
 				br.Success = true
 				br.Success = true
 				br.Msg = "获取成功"
 				br.Msg = "获取成功"
@@ -1501,27 +1650,35 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			}
 			}
 			resp.HaqveJurisdiction = true
 			resp.HaqveJurisdiction = true
 		} else {
 		} else {
-			hasPermission = 2
-			resp.SellerMobile = companyItem.Mobile
-			resp.SellerName = companyItem.SellerName
-			resp.MsgType = "Type"
-			resp.OperationMode = "Call"
-			if permissionStr == "专家" {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+			if companyItem.ProductId == 2 {
+				hasPermission = 2
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
 				resp.MsgType = "Type"
 				resp.MsgType = "Type"
+				resp.OperationMode = "Call"
+				if permissionStr == "专家" {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Type"
+				} else {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Industry"
+				}
 			} else {
 			} else {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				resp.MsgType = "Industry"
+				hasPermission = 5
 			}
 			}
 		}
 		}
 	} else { //潜在客户
 	} else { //潜在客户
 		if applyCount > 0 {
 		if applyCount > 0 {
 			hasPermission = 4
 			hasPermission = 4
 		} else {
 		} else {
-			hasPermission = 3
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
 		}
 		}
 		resp.OperationMode = "Apply"
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	}
 	resp.HasPermission = hasPermission
 	resp.HasPermission = hasPermission
 	resp.SignupStatus = signupStatus
 	resp.SignupStatus = signupStatus
@@ -1721,6 +1878,8 @@ func (this *ActivityCoAntroller) LabelList() {
 		}
 		}
 	}
 	}
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	if userType == 2 {
 	if userType == 2 {
@@ -1774,7 +1933,7 @@ func (this *ActivityCoAntroller) LabelList() {
 			}
 			}
 		}
 		}
 		resp.Label = label
 		resp.Label = label
-		resp.ImgUrl = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ft-img.51f.com%2Fxf%2Fxw%2F6b0d6f76-650c-4550-b549-8b016709e3b1.JPEG&refer=http%3A%2F%2Ft-img.51f.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640240724&t=1090d681d7d2351c563f2a101e6b842c"
+		resp.ImgUrl = ""
 		br.Ret = 200
 		br.Ret = 200
 		br.Success = true
 		br.Success = true
 		br.Msg = "获取成功"
 		br.Msg = "获取成功"
@@ -2005,6 +2164,8 @@ func (this *ActivityCoAntroller) LabelTypeList() {
 			permissionNameStr += "'" + v + "',"
 			permissionNameStr += "'" + v + "',"
 		}
 		}
 	}
 	}
+	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
+	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
 	list, err := models.GetActivityTypeHomeList()
 	list, err := models.GetActivityTypeHomeList()
 	if err != nil {
 	if err != nil {
@@ -2189,6 +2350,8 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 		}
 		}
 	}
 	}
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	if userType == 2 {
 	if userType == 2 {
@@ -2345,6 +2508,8 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 		}
 		}
 	}
 	}
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
 	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
 	if userType == 2 {
 	if userType == 2 {
@@ -2573,6 +2738,8 @@ func (this *ActivityCoAntroller) LabelTypeListPc() {
 			permissionNameStr += "'" + v + "',"
 			permissionNameStr += "'" + v + "',"
 		}
 		}
 	}
 	}
+	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
+	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
 	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
 	list, err := models.GetActivityTypeHomeListPc()
 	list, err := models.GetActivityTypeHomeListPc()
 	if err != nil {
 	if err != nil {
@@ -2714,6 +2881,13 @@ func (this *ActivityCoAntroller) CheckAsk() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 		return
 	}
 	}
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "申请失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
 	resp := new(models.SignupStatus)
 	resp := new(models.SignupStatus)
 	hasPermission := 0
 	hasPermission := 0
 	var companyDetailStatus string
 	var companyDetailStatus string
@@ -2730,11 +2904,29 @@ func (this *ActivityCoAntroller) CheckAsk() {
 			if applyCount > 0 {
 			if applyCount > 0 {
 				hasPermission = 4
 				hasPermission = 4
 			} else {
 			} else {
-				hasPermission = 3
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
 			}
 			}
+			resp.ActivityId = activityId
 			resp.HasPermission = hasPermission
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Ret = 200
 			br.Success = true
 			br.Success = true
 			br.Msg = "获取成功"
 			br.Msg = "获取成功"
@@ -2772,9 +2964,19 @@ func (this *ActivityCoAntroller) CheckAsk() {
 		//冻结客户
 		//冻结客户
 		if err != nil {
 		if err != nil {
 			if err.Error() == utils.ErrNoRow() {
 			if err.Error() == utils.ErrNoRow() {
-				resp.HasPermission = 4
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						hasPermission = 3
+					}
+				}
+				resp.ActivityId = activityId
+				resp.HasPermission = hasPermission
 				resp.OperationMode = "Apply"
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Ret = 200
 				br.Success = true
 				br.Success = true
 				br.Msg = "获取成功"
 				br.Msg = "获取成功"
@@ -2797,27 +2999,35 @@ func (this *ActivityCoAntroller) CheckAsk() {
 			signupStatus = "Success"
 			signupStatus = "Success"
 			resp.HaqveJurisdiction = true
 			resp.HaqveJurisdiction = true
 		} else {
 		} else {
-			hasPermission = 2
-			resp.SellerMobile = companyItem.Mobile
-			resp.SellerName = companyItem.SellerName
-			resp.MsgType = "Type"
-			resp.OperationMode = "Call"
-			if permissionStr == "专家" {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+			if companyItem.ProductId == 2 {
+				hasPermission = 2
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
 				resp.MsgType = "Type"
 				resp.MsgType = "Type"
+				resp.OperationMode = "Call"
+				if permissionStr == "专家" {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Type"
+				} else {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+					resp.MsgType = "Industry"
+				}
 			} else {
 			} else {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				resp.MsgType = "Industry"
+				hasPermission = 5
 			}
 			}
 		}
 		}
 	} else { //潜在客户
 	} else { //潜在客户
 		if applyCount > 0 {
 		if applyCount > 0 {
 			hasPermission = 4
 			hasPermission = 4
 		} else {
 		} else {
-			hasPermission = 3
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
 		}
 		}
 		resp.OperationMode = "Apply"
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	}
 	resp.HasPermission = hasPermission
 	resp.HasPermission = hasPermission
 	resp.SignupStatus = signupStatus
 	resp.SignupStatus = signupStatus

+ 56 - 1
controllers/article.go

@@ -138,6 +138,34 @@ func (this *ArticleController) Detail() {
 			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
 			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
 				hasPersion = false
 				hasPersion = false
 			}
 			}
+
+			if detail.IsReport == 1 {
+				fmt.Println("报告权限")
+				detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
+					return
+				}
+				fmt.Println(detailCategory)
+				permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+					return
+				}
+				if detailCategory != nil {
+					if detailCategory.PermissionType == 1 {
+						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
+							hasPersion = false
+						}
+					} else if detailCategory.PermissionType == 2 {
+						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
+							hasPersion = false
+						}
+					}
+				}
+			}
 			if hasPersion {
 			if hasPersion {
 				hasPermission = 1
 				hasPermission = 1
 				historyRecord := new(models.CygxArticleHistoryRecord)
 				historyRecord := new(models.CygxArticleHistoryRecord)
@@ -163,7 +191,12 @@ func (this *ArticleController) Detail() {
 					}
 					}
 				}
 				}
 			} else { //无该行业权限
 			} else { //无该行业权限
-				hasPermission = 3
+				companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+				if err == nil && companyDetail.ProductId == 1 {
+					hasPermission = 2
+				} else {
+					hasPermission = 3
+				}
 			}
 			}
 			if hasPermission == 1 {
 			if hasPermission == 1 {
 				key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
 				key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
@@ -264,6 +297,22 @@ Loop:
 		}
 		}
 		haveResearch = true
 		haveResearch = true
 	}
 	}
+
+	fmt.Println("hasPermission", hasPermission)
+	if hasPermission == 2 || hasPermission == 4 {
+		//获取销售手机号
+		sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerItemQy != nil {
+			hasPermission = 3
+			detail.SellerMobile = sellerItemQy.Mobile
+			detail.SellerName = sellerItemQy.RealName
+		}
+	}
 	resp := new(models.ArticleDetailResp)
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission
 	resp.HasPermission = hasPermission
 	resp.HaveResearch = haveResearch
 	resp.HaveResearch = haveResearch
@@ -535,6 +584,7 @@ func (this *ArticleController) AddStopTime() {
 	articleId := req.ArticleId
 	articleId := req.ArticleId
 	stopTime := req.StopTime
 	stopTime := req.StopTime
 	outType := req.OutType
 	outType := req.OutType
+	source := req.Source
 	if articleId <= 0 {
 	if articleId <= 0 {
 		br.Msg = "参数错误"
 		br.Msg = "参数错误"
 		br.ErrMsg = "参数错误"
 		br.ErrMsg = "参数错误"
@@ -546,6 +596,10 @@ func (this *ArticleController) AddStopTime() {
 	if outType != 2 {
 	if outType != 2 {
 		outType = 1
 		outType = 1
 	}
 	}
+	if source != "PC" {
+		source = "MOBILE"
+	}
+
 	detail := new(models.ArticleDetail)
 	detail := new(models.ArticleDetail)
 	hasPermission := 0
 	hasPermission := 0
 	hasFree := 0
 	hasFree := 0
@@ -630,6 +684,7 @@ func (this *ArticleController) AddStopTime() {
 					record.CompanyName = user.CompanyName
 					record.CompanyName = user.CompanyName
 					record.StopTime = stopTime
 					record.StopTime = stopTime
 					record.OutType = outType
 					record.OutType = outType
+					record.Source = source
 					if !utils.Rc.IsExist(key) || outType != 2 {
 					if !utils.Rc.IsExist(key) || outType != 2 {
 						//新增浏览记录
 						//新增浏览记录
 						go models.AddCygxArticleViewRecordNewpv(record)
 						go models.AddCygxArticleViewRecordNewpv(record)

+ 44 - 0
controllers/chart_permission.go

@@ -198,3 +198,47 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 	br.Msg = "获取成功"
 	br.Msg = "获取成功"
 	br.Data = resp
 	br.Data = resp
 }
 }
+
+//func init() {
+//
+//	list, err := models.GetCompanyReportPermissionAll()
+//	if err != nil {
+//		fmt.Println("获取品种信息失败,Err:" + err.Error())
+//		return
+//	}
+//	fmt.Println("len", len(list))
+//
+//	for _, v := range list {
+//		var newChartPermissionId int
+//		item := new(models.CompanyReportPermission)
+//		item.CompanyId = v.CompanyId
+//		item.ReportPermissionId = v.ReportPermissionId
+//		item.CreatedTime = time.Now()
+//		item.LastUpdatedTime = time.Now()
+//
+//		if v.ChartPermissionId == 19 {
+//			newChartPermissionId = 34
+//		} else if v.ChartPermissionId == 20 {
+//			newChartPermissionId = 35
+//		} else if v.ChartPermissionId == 21 {
+//			newChartPermissionId = 36
+//		} else if v.ChartPermissionId == 22 {
+//			newChartPermissionId = 37
+//		}
+//		item.ChartPermissionId = newChartPermissionId
+//		item.StartDate = v.StartDate
+//		item.EndDate = v.EndDate
+//		item.ProductId = v.ProductId
+//		item.ProductName = v.ProductName
+//		item.ModifyTime = v.ModifyTime
+//		item.CompanyContractId = v.CompanyContractId
+//		item.Status = v.Status
+//
+//		newId, err := models.AddChartPersion(item)
+//		if err != nil {
+//			fmt.Println("新增品种信息失败,Err:" + err.Error())
+//			//return
+//		}
+//		fmt.Println("新增", newId)
+//	}
+//}

+ 74 - 4
controllers/user.go

@@ -218,12 +218,25 @@ func (this *UserController) Detail() {
 			if companyItem != nil && companyItem.CompanyId > 0 {
 			if companyItem != nil && companyItem.CompanyId > 0 {
 				detail.CompanyName = companyItem.CompanyName
 				detail.CompanyName = companyItem.CompanyName
 				if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
 				if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
-					permissionStr, err := models.GetCompanyPermission(companyItem.CompanyId)
+					permissionStr, err := models.GetCompanyPermissionByUser(companyItem.CompanyId)
 					if err != nil {
 					if err != nil {
 						br.Msg = "获取信息失败"
 						br.Msg = "获取信息失败"
 						br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 						br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 						return
 						return
 					}
 					}
+					permissionStrOld, err := models.GetCompanyPermission(companyItem.CompanyId)
+					if err != nil {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+						return
+					}
+					permissionStrListOld := strings.Split(permissionStrOld, ",")
+					for _, v := range permissionStrListOld {
+						if strings.Count(permissionStr, v) > 1 {
+							permissionStr = strings.Replace(permissionStr, v+"(主观)", v, -1)
+							permissionStr = strings.Replace(permissionStr, v+"(客观),", "", -1)
+						}
+					}
 					detail.PermissionName = permissionStr
 					detail.PermissionName = permissionStr
 				} else {
 				} else {
 					hasPermission = 1
 					hasPermission = 1
@@ -601,6 +614,28 @@ func (this *UserController) ApplyTryOut() {
 	}
 	}
 	uid := user.UserId
 	uid := user.UserId
 
 
+	var title string
+	tryType := req.TryType
+	detailId := req.DetailId
+	if tryType == "Article" {
+		detail, err := models.GetArticleDetailById(detailId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		title = detail.Title
+	} else if tryType == "Activity" {
+		detail, err := models.GetAddActivityInfoById(detailId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(detailId)
+			return
+		}
+		title = detail.ActivityName
+	}
+
+	fmt.Println(title)
 	//缓存校验
 	//缓存校验
 	cacheKey := fmt.Sprint("xygx:apply_record:add:", uid)
 	cacheKey := fmt.Sprint("xygx:apply_record:add:", uid)
 	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
 	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
@@ -693,7 +728,7 @@ func (this *UserController) ApplyTryOut() {
 	}
 	}
 
 
 	//获取销售信息
 	//获取销售信息
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId)
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "申请失败"
 		br.Msg = "申请失败"
 		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
@@ -707,7 +742,6 @@ func (this *UserController) ApplyTryOut() {
 			mobile = user.Email
 			mobile = user.Email
 		}
 		}
 	}
 	}
-
 	applyMethod := ""
 	applyMethod := ""
 	cnf, _ := models.GetConfigByCode("tpl_msg")
 	cnf, _ := models.GetConfigByCode("tpl_msg")
 	if cnf != nil {
 	if cnf != nil {
@@ -721,12 +755,48 @@ func (this *UserController) ApplyTryOut() {
 			}
 			}
 			if companyItem != nil && companyItem.CompanyId > 0 {
 			if companyItem != nil && companyItem.CompanyId > 0 {
 				applyMethod = companyItem.Status + "客户申请"
 				applyMethod = companyItem.Status + "客户申请"
+				if detailId > 0 {
+					companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+						return
+					}
+					if companyProduct != nil && companyProduct.IsSuspend == 1 {
+						applyMethod = "试用暂停客户"
+					} else {
+						if companyItem.Status == "正式" || companyItem.Status == "试用" {
+							applyMethod = companyItem.Status + "客户申请,无对应权限"
+						} else if companyItem.Status == "冻结" || companyItem.Status == "流失" {
+							applyMethod = companyItem.Status + "客户"
+						}
+					}
+					applyMethod = applyMethod + "," + title
+				}
 			}
 			}
 		} else {
 		} else {
-			applyMethod = "潜在客户申请"
+			//获取销售信息
+			sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "申请失败"
+				br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+				return
+			}
+			if sellerItem != nil {
+				applyMethod = "FICC客户"
+			} else {
+				applyMethod = "潜在客户"
+			}
+			if detailId > 0 {
+				applyMethod = applyMethod + "," + title
+			}
 		}
 		}
 		openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
 		openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
 		if openIpItem != nil && openIpItem.OpenId != "" {
 		if openIpItem != nil && openIpItem.OpenId != "" {
+			if req.ApplyMethod != 2 {
+				req.RealName = user.RealName
+				req.CompanyName = user.CompanyName
+			}
 			fmt.Println("推送消息", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			fmt.Println("推送消息", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			utils.FileLog.Info("推送消息 %s %s,%s,%s,%s", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			utils.FileLog.Info("推送消息 %s %s,%s,%s,%s", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
 			go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)

+ 1 - 1
models/activity.go

@@ -101,7 +101,7 @@ type ActivityDetail struct {
 type CygxActivityResp struct {
 type CygxActivityResp struct {
 	HaqveJurisdiction bool   `description:"是否有权限"`
 	HaqveJurisdiction bool   `description:"是否有权限"`
 	OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
 	OperationMode     string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
-	HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
 	PopupMsg          string `description:"权限弹窗信息"`
 	PopupMsg          string `description:"权限弹窗信息"`
 	MsgType           string `description:"Type : 类型 , Industry : 行业"`
 	MsgType           string `description:"Type : 类型 , Industry : 行业"`
 	SellerMobile      string `description:"销售电话"`
 	SellerMobile      string `description:"销售电话"`

+ 4 - 3
models/article_history_record.go

@@ -65,9 +65,10 @@ func GetUserToArticleCount(uid, articleId int) (count int, err error) {
 }
 }
 
 
 type AddStopTimeRep struct {
 type AddStopTimeRep struct {
-	ArticleId int `description:"文章ID"`
-	StopTime  int `description:"停留时间"`
-	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
+	ArticleId int    `description:"文章ID"`
+	StopTime  int    `description:"停留时间"`
+	OutType   int    `description:"退出方式,1正常退出,2强制关闭"`
+	Source    string `description:"来源,MOBILE:手机端,PC:电脑端"`
 }
 }
 
 
 type AddStopTimeNewRep struct {
 type AddStopTimeNewRep struct {

+ 1 - 0
models/article_history_record_newpv.go

@@ -18,6 +18,7 @@ type CygxArticleHistoryRecordNewpv struct {
 	CompanyName string `description:"公司名称"`
 	CompanyName string `description:"公司名称"`
 	StopTime    int    `description:"停留时间"`
 	StopTime    int    `description:"停留时间"`
 	OutType     int    `description:"退出方式,1正常退出,2强制关闭"`
 	OutType     int    `description:"退出方式,1正常退出,2强制关闭"`
+	Source      string `description:"来源,MOBILE:手机端,PC:电脑端"`
 }
 }
 
 
 //添加收藏信息
 //添加收藏信息

+ 71 - 4
models/chart_permission.go

@@ -1,6 +1,10 @@
 package models
 package models
 
 
-import "github.com/beego/beego/v2/client/orm"
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"strings"
+	"time"
+)
 
 
 type ChartPermission struct {
 type ChartPermission struct {
 	ChartPermissionId int    `description:"权限id"`
 	ChartPermissionId int    `description:"权限id"`
@@ -20,7 +24,7 @@ type ChartPermissionResp struct {
 
 
 func GetChartPermissionAll(condition string) (items []*ChartPermission, err error) {
 func GetChartPermissionAll(condition string) (items []*ChartPermission, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1 ` + condition + ` ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1  AND permission_type!=2  ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 	return
 }
 }
@@ -37,7 +41,7 @@ func GetCategoryId(chartPermissionId int) (category_id string, err error) {
 
 
 func GetChartPermissionReportAll(condition string) (items []*ChartPermission, err error) {
 func GetChartPermissionReportAll(condition string) (items []*ChartPermission, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 ` + condition + ` ORDER BY sort ASC `
+	sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND permission_type!=2 ` + condition + ` ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 	return
 }
 }
@@ -56,7 +60,39 @@ func GetChartPermissionActivity() (items []*ActivityChartPermission, err error)
 	return
 	return
 }
 }
 
 
+//处理添加主观客观之后的分类ID错误
 func GetUserCompanyPermission(companyId int) (items []*ActivityChartPermission, err error) {
 func GetUserCompanyPermission(companyId int) (items []*ActivityChartPermission, err error) {
+	list, err := GetUserCompanyPermissionSandO(companyId)
+	if err != nil {
+		return
+	}
+	if len(list) == 0 {
+		return
+	}
+	var chartPermissionName string
+	for _, v := range list {
+		chartPermissionName += "'" + v.PermissionName + "'" + ","
+	}
+	chartPermissionName = strings.Trim(chartPermissionName, ",")
+	sql := ` SELECT b.*
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			WHERE a.product_id=2
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+            AND b.is_other=0
+			AND c.status IN('正式','试用','永续')
+			AND a.status IN('正式','试用','永续') 
+			AND b.chart_permission_name IN (` + chartPermissionName + `)
+			GROUP BY b.chart_permission_name
+			ORDER BY b.sort ASC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetUserCompanyPermissionSandO(companyId int) (items []*ActivityChartPermission, err error) {
 	sql := ` SELECT b.*
 	sql := ` SELECT b.*
 			FROM company_report_permission AS a
 			FROM company_report_permission AS a
 			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
 			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
@@ -68,9 +104,40 @@ func GetUserCompanyPermission(companyId int) (items []*ActivityChartPermission,
             AND b.is_other=0
             AND b.is_other=0
 			AND c.status IN('正式','试用','永续')
 			AND c.status IN('正式','试用','永续')
 			AND a.status IN('正式','试用','永续') 
 			AND a.status IN('正式','试用','永续') 
-			AND b.chart_permission_id IN (19,20,21,22,23,31) 
+			AND b.chart_permission_name != '专家'
+			GROUP BY b.chart_permission_name
 			ORDER BY b.sort ASC `
 			ORDER BY b.sort ASC `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	_, err = o.Raw(sql, companyId).QueryRows(&items)
 	return
 	return
 }
 }
+
+type CompanyReportPermission struct {
+	CompanyReportPermissionId int `orm:"column(company_report_permission_id);pk"`
+	CompanyId                 int `description:"客户id"`
+	ReportPermissionId        int `description:"报告权限id"`
+	CreatedTime               time.Time
+	LastUpdatedTime           time.Time
+	ChartPermissionId         int    `description:"权限id"`
+	StartDate                 string `description:"权限开始日期"`
+	EndDate                   string `description:"权限结束日期"`
+	ProductId                 int    `description:"产品id"`
+	ProductName               string `description:"产品名称"`
+	ModifyTime                string `description:"修改时间"`
+	CompanyContractId         string `description:"合同id"`
+	Status                    string `description:"状态  '正式','试用','关闭','永续','潜在' "`
+}
+
+//获取策略下面的所有分类
+func GetCompanyReportPermissionAll() (items []*CompanyReportPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM company_report_permission WHERE chart_permission_id IN (19,20,21,22) AND status IN ('正式','试用','永续')  AND created_time <= '2021-12-28 15:05:43'`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func AddChartPersion(item *CompanyReportPermission) (newId int64, err error) {
+	o := orm.NewOrm()
+	newId, err = o.Insert(item)
+	return
+}

+ 30 - 2
models/company.go

@@ -9,6 +9,7 @@ type CompanyDetail struct {
 	SellerId    int    `description:"销售id"`
 	SellerId    int    `description:"销售id"`
 	SellerName  string `description:"销售名称"`
 	SellerName  string `description:"销售名称"`
 	Mobile      string `description:"销售手机号"`
 	Mobile      string `description:"销售手机号"`
+	ProductId   int    `description:"1,FICC,2权益"`
 }
 }
 
 
 func GetCompanyDetailById(companyId int) (item *CompanyDetail, err error) {
 func GetCompanyDetailById(companyId int) (item *CompanyDetail, err error) {
@@ -18,7 +19,7 @@ func GetCompanyDetailById(companyId int) (item *CompanyDetail, err error) {
 	//		LEFT JOIN admin AS c ON b.seller_id=c.admin_id
 	//		LEFT JOIN admin AS c ON b.seller_id=c.admin_id
 	//		WHERE a.company_id=? AND  b.product_id=2 `
 	//		WHERE a.company_id=? AND  b.product_id=2 `
 
 
-	sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile 
+	sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile,p.product_id
             FROM company AS a
             FROM company AS a
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
 			INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
 			INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
@@ -53,7 +54,7 @@ func GetCountCompanyDetailByIdGroup(companyId int) (count int, err error) {
 			INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
 			INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
 			INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
 			INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
 			LEFT JOIN admin AS c ON b.seller_id=c.admin_id
 			LEFT JOIN admin AS c ON b.seller_id=c.admin_id
-			WHERE a.company_id=? AND b.product_id = 2   OR (a.company_id = ? AND  cp.permission_name = '策略' )   `
+			WHERE a.company_id=? AND b.product_id = 2    OR (a.company_id = ? AND  cp.permission_name = '策略' )   `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	err = o.Raw(sql, companyId, companyId).QueryRow(&count)
 	err = o.Raw(sql, companyId, companyId).QueryRow(&count)
 	return
 	return
@@ -89,6 +90,21 @@ func GetCompanyPermission(companyId int) (permission string, err error) {
 	return
 	return
 }
 }
 
 
+func GetCompanyPermissionByUser(companyId int) (permission string, err error) {
+	sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark  ORDER BY b.sort ASC  SEPARATOR ',') AS permission
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			WHERE  a.company_id=?
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+			AND c.status IN('正式','试用','永续')
+			AND a.status IN('正式','试用','永续') `
+	o := orm.NewOrm()
+	err = o.Raw(sql, companyId).QueryRow(&permission)
+	return
+}
+
 func GetCompanyPermissionByName(name string) (permission string, err error) {
 func GetCompanyPermissionByName(name string) (permission string, err error) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC SEPARATOR '/') AS permission
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC SEPARATOR '/') AS permission
 			FROM company_report_permission AS a
 			FROM company_report_permission AS a
@@ -143,3 +159,15 @@ func GetCompanySellerName(companyId int) (sellerName string, err error) {
 	err = o.Raw(sql, companyId).QueryRow(&sellerName)
 	err = o.Raw(sql, companyId).QueryRow(&sellerName)
 	return
 	return
 }
 }
+
+type CompanyProduct struct {
+	IsSuspend int `description:"1:暂停,0:启用"`
+}
+
+//获取对应销售以及销售的手机号
+func GetCompanyProductDetail(companyId, productId int) (item *CompanyProduct, err error) {
+	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
+	o := orm.NewOrm()
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}

+ 1 - 0
models/db.go

@@ -85,5 +85,6 @@ func init() {
 		new(CygxActivityRestrictSignup),
 		new(CygxActivityRestrictSignup),
 		new(CygxActivityMeetDetailLog),
 		new(CygxActivityMeetDetailLog),
 		new(CygxUserSearchKeyWord),
 		new(CygxUserSearchKeyWord),
+		new(CompanyReportPermission),
 	)
 	)
 }
 }

+ 9 - 0
models/report_mapping.go

@@ -10,6 +10,7 @@ type ReportMapping struct {
 	MatchTypeName       string `description:"分类名称"`
 	MatchTypeName       string `description:"分类名称"`
 	ChartPermissionName string `description:"行业名称"`
 	ChartPermissionName string `description:"行业名称"`
 	IsRed               bool   `description:"是否标红"`
 	IsRed               bool   `description:"是否标红"`
+	PermissionType      int    `description:"1主观,2客观"`
 }
 }
 
 
 type ReportMappingHome struct {
 type ReportMappingHome struct {
@@ -112,6 +113,14 @@ func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
 	return
 	return
 }
 }
 
 
+//通过分类ID获取详情主观客观
+func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping WHERE permission_type>0 AND category_id=?  LIMIT 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}
+
 //通过分类ID获取详情
 //通过分类ID获取详情
 func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
 func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()

+ 3 - 3
models/seller.go

@@ -30,13 +30,13 @@ func GetSellerByCompanyId(companyId int) (item *AdminItem, err error) {
 	return
 	return
 }
 }
 
 
-func GetSellerByCompanyIdCheckFicc(companyId int) (item *AdminItem, err error) {
+func GetSellerByCompanyIdCheckFicc(companyId, productId int) (item *AdminItem, err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	sql := ` SELECT b.*,c.open_id,c.user_id,a.company_name FROM company_product AS a
 	sql := ` SELECT b.*,c.open_id,c.user_id,a.company_name FROM company_product AS a
 			INNER JOIN admin AS b ON a.seller_id=b.admin_id
 			INNER JOIN admin AS b ON a.seller_id=b.admin_id
 			LEFT JOIN wx_user AS c ON b.mobile=c.mobile
 			LEFT JOIN wx_user AS c ON b.mobile=c.mobile
-			WHERE a.company_id=? AND a.product_id=2 `
-	err = o.Raw(sql, companyId).QueryRow(&item)
+			WHERE a.company_id=? AND a.product_id=?`
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
 	return
 	return
 }
 }
 
 

+ 2 - 0
models/user.go

@@ -199,6 +199,8 @@ type ApplyTryReq struct {
 	RealName        string `description:"姓名"`
 	RealName        string `description:"姓名"`
 	CompanyName     string `description:"公司名称"`
 	CompanyName     string `description:"公司名称"`
 	ApplyMethod     int    `description:"1:已付费客户申请试用,2:非客户申请试用,3:非客户申请试用(ficc下,不需要进行数据校验)"`
 	ApplyMethod     int    `description:"1:已付费客户申请试用,2:非客户申请试用,3:非客户申请试用(ficc下,不需要进行数据校验)"`
+	TryType         string `description:"提交类型,Article:文章、Activity:活动"`
+	DetailId        int    `description:"详情ID"`
 }
 }
 
 
 type CountryCode struct {
 type CountryCode struct {

+ 9 - 1
models/user_record.go

@@ -2,6 +2,7 @@ package models
 
 
 import (
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 	"time"
 )
 )
 
 
@@ -102,9 +103,16 @@ func ModifyUserRecordSessionKey(openId, sessionKey string) (err error) {
 
 
 //根据用户id和平台id获取用户关系
 //根据用户id和平台id获取用户关系
 func GetUserRecordByMobile(platform int, bindAccount string) (item *UserRecord, err error) {
 func GetUserRecordByMobile(platform int, bindAccount string) (item *UserRecord, err error) {
-	sql := `SELECT cr.open_id FROM user_record  as u 
+
+	var sql string
+	if utils.RunMode == "release" {
+		sql = `SELECT cr.open_id FROM user_record  as u 
 			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
 			INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id 
 			WHERE create_platform=? AND bind_account = ?`
 			WHERE create_platform=? AND bind_account = ?`
+	} else {
+		platform = 1
+		sql = `SELECT open_id FROM	user_record  WHERE create_platform =? AND bind_account = ?`
+	}
 	err = orm.NewOrm().Raw(sql, platform, bindAccount).QueryRow(&item)
 	err = orm.NewOrm().Raw(sql, platform, bindAccount).QueryRow(&item)
 	return
 	return
 }
 }

+ 1 - 0
models/wechat.go

@@ -45,6 +45,7 @@ func GetWxAccessToken() (accessTokenStr string, err error) {
 	} else {
 	} else {
 		//判断token是否过期
 		//判断token是否过期
 		if time.Now().Unix() > wxToken.ExpiresIn {
 		if time.Now().Unix() > wxToken.ExpiresIn {
+
 			accessToken, err := GetWxToken()
 			accessToken, err := GetWxToken()
 			fmt.Println(accessToken)
 			fmt.Println(accessToken)
 			if err != nil {
 			if err != nil {

+ 17 - 5
services/activity.go

@@ -322,7 +322,7 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				err = errs
 				err = errs
 				return
 				return
 			}
 			}
-			permissionStr, errs = models.GetCompanyPermission(companyId)
+			permissionStr, errs = models.GetCompanyPermissionByUser(companyId)
 			if errs != nil {
 			if errs != nil {
 				err = errs
 				err = errs
 				return
 				return
@@ -382,11 +382,23 @@ func GetHavePower(activityInfo *models.ActivityDetail, permissionStr, companyDet
 		havePower = true
 		havePower = true
 	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
 	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
 		havePower = true
 		havePower = true
-	} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
+		//} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
+		//	havePower = true
+		//} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
+		//	havePower = true
+	} else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
 		havePower = true
 		havePower = true
-	} else if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
-		havePower = true
-	} else if activityInfo.ActivityTypeId == 5 && strings.Contains(permissionStr, "专家") {
+	}
+	if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 {
+		if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") {
+			havePower = true
+		}
+	} else {
+		if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") {
+			havePower = true
+		}
+	}
+	if (activityInfo.ChartPermissionName == "研选" || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
 		havePower = true
 		havePower = true
 	}
 	}
 	return
 	return

+ 27 - 10
services/wechat_send_msg.go

@@ -109,14 +109,28 @@ func SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId, apply
 			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
 			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
 		}
 		}
 	}()
 	}()
-	accessToken, err := models.GetWxAccessTokenByXzs()
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
+
+	var accessToken string
+	if utils.RunMode == "release" {
+		accessToken, err = models.GetWxAccessTokenByXzs()
+		if err != nil {
+			msg = "GetWxAccessToken Err:" + err.Error()
+			return
+		}
+		if accessToken == "" {
+			msg = "accessToken is empty"
+			return
+		}
+	} else {
+		accessToken, err = models.GetWxAccessToken()
+		if err != nil {
+			msg = "GetWxAccessToken Err:" + err.Error()
+			return
+		}
+		if accessToken == "" {
+			msg = "accessToken is empty"
+			return
+		}
 	}
 	}
 
 
 	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
 	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
@@ -135,8 +149,11 @@ func SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId, apply
 	sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": fontColor}
 	sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": fontColor}
 	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": fontColor}
 	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": fontColor}
 	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
 	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
-
-	sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
+	if utils.RunMode == "release" {
+		sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
+	} else {
+		sendMap["template_id"] = utils.WxMsgTemplateIdApply
+	}
 	sendMap["data"] = sendData
 	sendMap["data"] = sendData
 	sendTemplateMsg(sendUrl, openId, sendMap)
 	sendTemplateMsg(sendUrl, openId, sendMap)
 	fmt.Println("send end")
 	fmt.Println("send end")