package service import ( "encoding/base64" "encoding/json" "strings" "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jybase/redis" "bp.jydev.jianyu360.cn/BaseService/biService/entity" "github.com/gogf/gf/v2/util/gconv" "github.com/tjfoc/gmsm/sm4" ) type InfoService struct { } func (l *InfoService) Myinfo(sid string) []byte { infoMap := map[string]string{} info_i := redis.Get("session", sid) if info_i != nil { info_m, _ := info_i.(map[string]interface{}) entNicheDis := common.Int64All(info_m["entNicheDis"]) depIDArr := "" //if entNicheDis > 0 { //查询所有部门标识 entId := gconv.String(info_m["entId"]) entDeptId := gconv.String(info_m["entDeptId"]) deptArr := entity.JyMysql.SelectBySql("select GROUP_CONCAT(DISTINCT b.id) as depIDArr from entniche_department_parent a INNER JOIN entniche_department b "+ "on (b.ent_id=? and (b.id=? or (a.pid=? and a.id=b.id)))", entId, entDeptId, entDeptId) if len(*deptArr) > 0 { depIDArr = common.InterfaceToStr((*deptArr)[0]["depIDArr"]) } //} //营销版本查询 accountId := gconv.Int64(info_m["accountId"]) entAccountId := gconv.Int64(info_m["entAccountId"]) entUserId := gconv.Int64(info_m["entUserId"]) res := entity.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, gconv.Int64(info_m["entId"]), entUserId) version := "0" for _, pCode := range res.Powers { //0:通用版 1:物业专版 if pCode == "bi_yx_wyzb" { version = "1" } } infoMap = map[string]string{ "nickName": RsaEncrypt([]byte(gconv.String(info_m["s_nickname"]))), "entRole": RsaEncrypt([]byte(gconv.String(info_m["entRole"]))), "entNicheDis": RsaEncrypt([]byte(gconv.String(entNicheDis))), "positionId": RsaEncrypt([]byte(gconv.String(info_m["positionId"]))), "accountId": RsaEncrypt([]byte(gconv.String(info_m["accountId"]))), "entAccountId": RsaEncrypt([]byte(gconv.String(info_m["entAccountId"]))), "entId": RsaEncrypt([]byte(gconv.String(info_m["entId"]))), "entName": RsaEncrypt([]byte(gconv.String(info_m["entName"]))), "entUserName": RsaEncrypt([]byte(gconv.String(info_m["entUserName"]))), "entUserId": RsaEncrypt([]byte(gconv.String(info_m["entUserId"]))), "userId": RsaEncrypt([]byte(gconv.String(info_m["base_user_id"]))), "entDeptId": RsaEncrypt([]byte(gconv.String(info_m["entDeptId"]))), "entChildDept": RsaEncrypt([]byte(depIDArr)), "crmVersion": RsaEncrypt([]byte(version)), "equityMap": RsaEncrypt([]byte(gconv.String(FindEquity(entUserId, gconv.Int64(info_m["entRole"]))))), } } infoByte, _ := json.Marshal(infoMap) return infoByte } // 加密 func RsaEncrypt(data []byte) string { key := []byte(entity.PublicKey) //加密 b, _ := sm4.Sm4Ecb(key, data, true) return base64.StdEncoding.EncodeToString(b) } func FindEquity(entUserId int64, entRole int64) map[string]bool { equityMap := map[string]bool{ "检索工具-收录按钮-显示": false, "潜在商机-情报列表-个人": false, "潜在商机-转发-企业": false, "潜在商机-转发-部门": false, "潜在商机-转发按钮-显示": false, "潜在商机-分发按钮-显示": false, "潜在商机-跟进-显示": false, "潜在商机-不跟进-显示": false, } //查找用户 data := entity.JyMysql.FindOne("entniche_user", map[string]interface{}{ "id": entUserId, }, "role", "") if data != nil && len(*data) > 0 { role := strings.Split(gconv.String((*data)["role"]), ",") for _, v := range role { //角色;1:情报处理岗 2:情报分配岗 3:信息浏览岗 4 :销售管理岗 switch v { case "1": equityMap["检索工具-收录按钮-显示"] = true equityMap["潜在商机-情报列表-个人"] = true equityMap["潜在商机-转发-企业"] = true equityMap["潜在商机-转发按钮-显示"] = true equityMap["潜在商机-跟进-显示"] = true equityMap["潜在商机-不跟进-显示"] = true case "2": if entRole == 1 { equityMap["检索工具-收录按钮-显示"] = true equityMap["潜在商机-情报列表-个人"] = true equityMap["潜在商机-转发-企业"] = true equityMap["潜在商机-转发按钮-显示"] = true equityMap["潜在商机-分发按钮-显示"] = true } else { equityMap["检索工具-收录按钮-显示"] = true equityMap["潜在商机-情报列表-个人"] = true equityMap["潜在商机-转发-部门"] = true equityMap["潜在商机-转发按钮-显示"] = true equityMap["潜在商机-分发按钮-显示"] = true } } } } return equityMap }