package cygxService import ( "hongze/hongze_mobile_admin/models" "hongze/hongze_mobile_admin/models/cygx" "hongze/hongze_mobile_admin/models/tables/cygx_company_user_type" "hongze/hongze_mobile_admin/utils" "strings" ) // 获取 用户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户 func GetUserType(companyId int) (userType, packageType int, permissionStrnew, companyStatus string, err error) { var permissionStr, permissionZhengShiStr string if companyId <= 1 { userType = 0 } else { total, errs := cygx.GetCountCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } if total == 0 { userType = 0 } else { companyDetail, errs := cygx.GetCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } companyStatus = companyDetail.Status permissionStr, errs = models.GetCompanyPermission(companyId) if errs != nil { err = errs return } permissionStrnew = permissionStr //大套餐客户,数据库添加标识, companyUserTypeDetail, errs := cygx_company_user_type.GetCygxCompanyUserType(companyId) if errs != nil && errs.Error() != utils.ErrNoRow() { err = errs return } if companyUserTypeDetail != nil { packageType = companyUserTypeDetail.PackageType if companyUserTypeDetail.CustomerTypeId != 0 { userType = companyUserTypeDetail.CustomerTypeId return } } permissionZhengShiStr, errs = cygx.GetCompanyPermissionByUserZhengShi(companyId) if errs != nil { err = errs return } //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户 //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if companyDetail.Status == "永续" { userType = 1 } else if companyDetail.Status == "试用" { userType = 5 } else if companyDetail.Status == "冻结" { userType = 6 } else if companyDetail.Status == "流失" { userType = 7 } //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if userType == 0 && companyDetail.Status == "正式" { var permissionZhegnshiNum int if strings.Count(permissionZhengShiStr, "医药") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "消费") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "科技") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "智造") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "策略") == 1 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "路演服务") == 1 { permissionZhegnshiNum++ } //if permissionZhegnshiNum == 6 { // userType = 2 //} else //大套餐客户,数据库添加标识,条件大于等于四的都是 30W套餐客户 if permissionZhegnshiNum >= 4 { userType = 10 } else { userType = 3 } } } } permissionStrnew = permissionStr return }