Browse Source

正式客户权限区分

xingzai 3 years ago
parent
commit
f52cf091d0
2 changed files with 24 additions and 2 deletions
  1. 16 0
      models/company.go
  2. 8 2
      services/activity.go

+ 16 - 0
models/company.go

@@ -105,6 +105,22 @@ func GetCompanyPermissionByUser(companyId int) (permission string, err error) {
 	return
 }
 
+//获取正式权限
+func GetCompanyPermissionByUserZhengShi(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) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC SEPARATOR '/') AS permission
 			FROM company_report_permission AS a

+ 8 - 2
services/activity.go

@@ -305,7 +305,7 @@ func EditUserOutboundMobile(cont context.Context) (err error) {
 //获取 用户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
 func GetUserType(companyId int) (userType int, permissionStrnew string, err error) {
 
-	var permissionStr string
+	var permissionStr, permissionZhegnshiStr string
 	if companyId <= 1 {
 		userType = 0
 	} else {
@@ -327,6 +327,12 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				err = errs
 				return
 			}
+			permissionZhegnshiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId)
+			if errs != nil {
+				err = errs
+				return
+			}
+
 			//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
 			if companyDetail.Status == "永续" {
 				userType = 1
@@ -335,7 +341,7 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 			} else if companyDetail.Status == "正式" {
 				if permissionStr == "专家" {
 					userType = 4
-				} else if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
+				} else if strings.Contains(permissionZhegnshiStr, "医药") && strings.Contains(permissionZhegnshiStr, "消费") && strings.Contains(permissionZhegnshiStr, "科技") && strings.Contains(permissionZhegnshiStr, "智造") {
 					userType = 2
 				} else {
 					userType = 3