infoService.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package service
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "strings"
  6. "app.yhyue.com/moapp/jybase/common"
  7. "app.yhyue.com/moapp/jybase/redis"
  8. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
  9. "github.com/gogf/gf/v2/util/gconv"
  10. "github.com/tjfoc/gmsm/sm4"
  11. )
  12. type InfoService struct {
  13. }
  14. func (l *InfoService) Myinfo(sid string) []byte {
  15. infoMap := map[string]string{}
  16. info_i := redis.Get("session", sid)
  17. if info_i != nil {
  18. info_m, _ := info_i.(map[string]interface{})
  19. entNicheDis := common.Int64All(info_m["entNicheDis"])
  20. depIDArr := ""
  21. //if entNicheDis > 0 {
  22. //查询所有部门标识
  23. entId := gconv.String(info_m["entId"])
  24. entDeptId := gconv.String(info_m["entDeptId"])
  25. deptArr := entity.JyMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a INNER JOIN entniche_department b "+
  26. "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", entId, entDeptId, entDeptId)
  27. if len(*deptArr) > 0 {
  28. depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"])
  29. }
  30. //}
  31. //营销版本查询
  32. accountId := gconv.Int64(info_m["accountId"])
  33. entAccountId := gconv.Int64(info_m["entAccountId"])
  34. entUserId := gconv.Int64(info_m["entUserId"])
  35. res := entity.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, gconv.Int64(info_m["entId"]), entUserId)
  36. version := "0"
  37. for _, pCode := range res.Powers {
  38. //0:通用版 1:物业专版
  39. if pCode == "bi_yx_wyzb" {
  40. version = "1"
  41. }
  42. }
  43. infoMap = map[string]string{
  44. "nickName": RsaEncrypt([]byte(gconv.String(info_m["s_nickname"]))),
  45. "entRole": RsaEncrypt([]byte(gconv.String(info_m["entRole"]))),
  46. "entNicheDis": RsaEncrypt([]byte(gconv.String(entNicheDis))),
  47. "positionId": RsaEncrypt([]byte(gconv.String(info_m["positionId"]))),
  48. "accountId": RsaEncrypt([]byte(gconv.String(info_m["accountId"]))),
  49. "entAccountId": RsaEncrypt([]byte(gconv.String(info_m["entAccountId"]))),
  50. "entId": RsaEncrypt([]byte(gconv.String(info_m["entId"]))),
  51. "entName": RsaEncrypt([]byte(gconv.String(info_m["entName"]))),
  52. "entUserName": RsaEncrypt([]byte(gconv.String(info_m["entUserName"]))),
  53. "entUserId": RsaEncrypt([]byte(gconv.String(info_m["entUserId"]))),
  54. "userId": RsaEncrypt([]byte(gconv.String(info_m["base_user_id"]))),
  55. "entDeptId": RsaEncrypt([]byte(gconv.String(info_m["entDeptId"]))),
  56. "entChildDept": RsaEncrypt([]byte(depIDArr)),
  57. "crmVersion": RsaEncrypt([]byte(version)),
  58. "equityMap": RsaEncrypt([]byte(gconv.String(FindEquity(entUserId, gconv.Int64(info_m["entRole"]))))),
  59. }
  60. }
  61. infoByte, _ := json.Marshal(infoMap)
  62. return infoByte
  63. }
  64. // 加密
  65. func RsaEncrypt(data []byte) string {
  66. key := []byte(entity.PublicKey)
  67. //加密
  68. b, _ := sm4.Sm4Ecb(key, data, true)
  69. return base64.StdEncoding.EncodeToString(b)
  70. }
  71. func FindEquity(entUserId int64, entRole int64) map[string]bool {
  72. equityMap := map[string]bool{
  73. "检索工具-收录按钮-显示": false,
  74. "潜在商机-情报列表-企业": false,
  75. "潜在商机-情报列表-部门": false,
  76. "潜在商机-情报列表-个人": false,
  77. "潜在商机-转发-企业": false,
  78. "潜在商机-转发-部门": false,
  79. "潜在商机-转发按钮-显示": false,
  80. "潜在商机-分发按钮-显示": false,
  81. "潜在商机-跟进-显示": false,
  82. "潜在商机-不跟进-显示": false,
  83. "潜在商机-是否分发-显示": false,
  84. "潜在商机-数据归属-显示": false,
  85. "创建商机-已关联商机-企业": false,
  86. "创建商机-已关联商机-部门": false,
  87. "创建商机-已关联商机-个人": false,
  88. }
  89. //查找用户
  90. data := entity.JyMysql.FindOne("entniche_user", map[string]interface{}{
  91. "id": entUserId,
  92. }, "role", "")
  93. if data != nil && len(*data) > 0 {
  94. role := strings.Split(gconv.String((*data)["role"]), ",")
  95. fool1 := false
  96. fool2 := false
  97. for _, v := range role {
  98. //角色;1:情报处理岗 2:情报分配岗 3:信息浏览岗 4 :销售管理岗
  99. switch v {
  100. case "1":
  101. fool1 = true
  102. equityMap["检索工具-收录按钮-显示"] = true
  103. equityMap["潜在商机-情报列表-个人"] = true
  104. equityMap["潜在商机-转发-企业"] = true
  105. equityMap["潜在商机-跟进-显示"] = true
  106. equityMap["潜在商机-不跟进-显示"] = true
  107. equityMap["创建商机-已关联商机-个人"] = true
  108. equityMap["潜在商机-转发按钮-显示"] = true
  109. case "2":
  110. fool2 = true
  111. if entRole == 1 {
  112. //企业
  113. equityMap["检索工具-收录按钮-显示"] = true
  114. equityMap["潜在商机-情报列表-企业"] = true
  115. equityMap["潜在商机-转发-企业"] = true
  116. equityMap["潜在商机-是否分发-显示"] = true
  117. equityMap["创建商机-已关联商机-企业"] = true
  118. equityMap["潜在商机-转发按钮-显示"] = true
  119. equityMap["潜在商机-分发按钮-显示"] = true
  120. } else {
  121. //部门
  122. equityMap["检索工具-收录按钮-显示"] = true
  123. equityMap["潜在商机-情报列表-部门"] = true
  124. equityMap["潜在商机-转发-部门"] = true
  125. equityMap["潜在商机-是否分发-显示"] = true
  126. equityMap["创建商机-已关联商机-部门"] = true
  127. equityMap["潜在商机-转发按钮-显示"] = true
  128. equityMap["潜在商机-分发按钮-显示"] = true
  129. }
  130. case "4":
  131. if entRole == 1 {
  132. equityMap["潜在商机-情报列表-企业"] = true
  133. } else {
  134. equityMap["潜在商机-情报列表-部门"] = true
  135. }
  136. }
  137. }
  138. if fool1 && fool2 {
  139. equityMap["潜在商机-数据归属-显示"] = true
  140. }
  141. }
  142. return equityMap
  143. }