activity.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package cygxService
  2. import (
  3. "hongze/hongze_mobile_admin/models"
  4. "hongze/hongze_mobile_admin/models/cygx"
  5. "hongze/hongze_mobile_admin/models/tables/cygx_company_user_type"
  6. "hongze/hongze_mobile_admin/utils"
  7. "strings"
  8. )
  9. // 获取 用户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
  10. func GetUserType(companyId int) (userType, packageType int, permissionStrnew, companyStatus string, err error) {
  11. var permissionStr, permissionZhengShiStr string
  12. if companyId <= 1 {
  13. userType = 0
  14. } else {
  15. total, errs := cygx.GetCountCompanyDetailByIdGroup(companyId)
  16. if errs != nil {
  17. err = errs
  18. return
  19. }
  20. if total == 0 {
  21. userType = 0
  22. } else {
  23. companyDetail, errs := cygx.GetCompanyDetailByIdGroup(companyId)
  24. if errs != nil {
  25. err = errs
  26. return
  27. }
  28. companyStatus = companyDetail.Status
  29. permissionStr, errs = models.GetCompanyPermission(companyId)
  30. if errs != nil {
  31. err = errs
  32. return
  33. }
  34. permissionStrnew = permissionStr
  35. //大套餐客户,数据库添加标识,
  36. companyUserTypeDetail, errs := cygx_company_user_type.GetCygxCompanyUserType(companyId)
  37. if errs != nil && errs.Error() != utils.ErrNoRow() {
  38. err = errs
  39. return
  40. }
  41. if companyUserTypeDetail != nil {
  42. packageType = companyUserTypeDetail.PackageType
  43. if companyUserTypeDetail.CustomerTypeId != 0 {
  44. userType = companyUserTypeDetail.CustomerTypeId
  45. return
  46. }
  47. }
  48. permissionZhengShiStr, errs = cygx.GetCompanyPermissionByUserZhengShi(companyId)
  49. if errs != nil {
  50. err = errs
  51. return
  52. }
  53. //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户
  54. //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
  55. if companyDetail.Status == "永续" {
  56. userType = 1
  57. } else if companyDetail.Status == "试用" {
  58. userType = 5
  59. } else if companyDetail.Status == "冻结" {
  60. userType = 6
  61. } else if companyDetail.Status == "流失" {
  62. userType = 7
  63. }
  64. //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
  65. if userType == 0 && companyDetail.Status == "正式" {
  66. var permissionZhegnshiNum int
  67. if strings.Count(permissionZhengShiStr, "医药") == 2 {
  68. permissionZhegnshiNum++
  69. }
  70. if strings.Count(permissionZhengShiStr, "消费") == 2 {
  71. permissionZhegnshiNum++
  72. }
  73. if strings.Count(permissionZhengShiStr, "科技") == 2 {
  74. permissionZhegnshiNum++
  75. }
  76. if strings.Count(permissionZhengShiStr, "智造") == 2 {
  77. permissionZhegnshiNum++
  78. }
  79. if strings.Count(permissionZhengShiStr, "策略") == 1 {
  80. permissionZhegnshiNum++
  81. }
  82. if strings.Count(permissionZhengShiStr, "路演服务") == 1 {
  83. permissionZhegnshiNum++
  84. }
  85. //if permissionZhegnshiNum == 6 {
  86. // userType = 2
  87. //} else
  88. //大套餐客户,数据库添加标识,条件大于等于四的都是 30W套餐客户
  89. if permissionZhegnshiNum >= 4 {
  90. userType = 10
  91. } else {
  92. userType = 3
  93. }
  94. }
  95. }
  96. }
  97. permissionStrnew = permissionStr
  98. return
  99. }