infoService.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. }
  83. //查找用户
  84. data := entity.JyMysql.FindOne("entniche_user", map[string]interface{}{
  85. "id": entUserId,
  86. }, "role", "")
  87. if data != nil && len(*data) > 0 {
  88. role := strings.Split(gconv.String((*data)["role"]), ",")
  89. for _, v := range role {
  90. //角色;1:情报处理岗 2:情报分配岗 3:信息浏览岗 4 :销售管理岗
  91. switch v {
  92. case "1":
  93. equityMap["检索工具-收录按钮-显示"] = true
  94. equityMap["潜在商机-情报列表-个人"] = true
  95. equityMap["潜在商机-转发-企业"] = true
  96. equityMap["潜在商机-转发按钮-显示"] = true
  97. equityMap["潜在商机-跟进-显示"] = true
  98. equityMap["潜在商机-不跟进-显示"] = true
  99. case "2":
  100. if entRole == 1 {
  101. equityMap["检索工具-收录按钮-显示"] = true
  102. equityMap["潜在商机-情报列表-个人"] = true
  103. equityMap["潜在商机-转发-企业"] = true
  104. equityMap["潜在商机-转发按钮-显示"] = true
  105. equityMap["潜在商机-分发按钮-显示"] = true
  106. } else {
  107. equityMap["检索工具-收录按钮-显示"] = true
  108. equityMap["潜在商机-情报列表-个人"] = true
  109. equityMap["潜在商机-转发-部门"] = true
  110. equityMap["潜在商机-转发按钮-显示"] = true
  111. equityMap["潜在商机-分发按钮-显示"] = true
  112. }
  113. case "4":
  114. equityMap["所有商机-跟踪情况-显示"] = true
  115. }
  116. }
  117. }
  118. return equityMap
  119. }