|
@@ -3,7 +3,6 @@ package entity
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- "github.com/zeromicro/go-zero/core/logx"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
@@ -22,6 +21,7 @@ const (
|
|
|
UserEntIdKey = "jy_userentid_%s_%d_%s"
|
|
|
UserRegisterTime = "jy_userregistertime_%s"
|
|
|
EntnicheWaitEmpower = "entniche_wait_empower"
|
|
|
+ EntnichePower = "entniche_power"
|
|
|
)
|
|
|
|
|
|
type UserInfo struct {
|
|
@@ -70,10 +70,11 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
//商机管理服务 前提是超级订阅、大会员、医械通
|
|
|
domainBool = false
|
|
|
registerTime int64 = 0
|
|
|
- entnicheRoleId = 0 //企业级服务 企业管理员
|
|
|
- entnicheIsNew = -1 //是否是新版商机管理
|
|
|
- powerSource = 0 //商机管理服务
|
|
|
- memberStatus = 0 //大会员
|
|
|
+ entnicheRoleId = 0 //企业级服务 企业管理员
|
|
|
+ entnicheIsNew = -1 //是否是新版商机管理
|
|
|
+ powerSource = 0 //商机管理服务
|
|
|
+ memberStatus = 0 //大会员
|
|
|
+ serviceIds = map[string][]string{} //大会员服务id集合
|
|
|
)
|
|
|
phone, _ := MC.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string)
|
|
|
if phone != "" {
|
|
@@ -87,6 +88,7 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
isFree = false
|
|
|
UserPowerMap["0"] = memberStatus
|
|
|
UserPowerMap[strconv.Itoa(50+memberStatus)] = 1
|
|
|
+ serviceIds["M"] = append(serviceIds["M"], "0", strconv.Itoa(50+memberStatus))
|
|
|
//是否是子账号 而且 子账号被启用
|
|
|
if (*data)["s_member_mainid"] != nil && MC.ObjToString((*data)["s_member_mainid"]) != "" && MC.IntAllDef((*data)["i_member_sub_status"], 0) > 0 {
|
|
|
mainUserId = MC.ObjToString((*data)["s_member_mainid"])
|
|
@@ -97,6 +99,7 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
if serviceList != nil && len(*serviceList) != 0 {
|
|
|
for _, sv := range *serviceList {
|
|
|
UserPowerMap[MC.ObjToString(sv["s_serviceid"])] = MC.If(MC.IntAll(sv["i_frequency"]) > 0, MC.IntAll(sv["i_frequency"]), memberStatus).(int)
|
|
|
+ serviceIds["M"] = append(serviceIds["M"], MC.ObjToString(sv["s_serviceid"]))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -108,11 +111,13 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
domainBool = true
|
|
|
isFree = false
|
|
|
UserPowerMap["200"] = vipStatus
|
|
|
+ serviceIds["V"] = append(serviceIds["V"], "200")
|
|
|
if vipSet := MC.ObjToMap((*data)["o_vipjy"]); vipSet != nil {
|
|
|
if buySet := MC.ObjToMap((*vipSet)["o_buyset"]); buySet != nil {
|
|
|
//vip 升级用户
|
|
|
if MC.IntAll((*buySet)["upgrade"]) > 0 {
|
|
|
UserPowerMap["201"] = vipStatus
|
|
|
+ serviceIds["V"] = append(serviceIds["V"], "201")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -197,7 +202,6 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
}
|
|
|
//必须是企业管理员-&-购买了企业级应用服务
|
|
|
c := Mysql.CountBySql(fmt.Sprintf(`SELECT COUNT(id) FROM %s WHERE ent_id = ? AND TO_DAYS(end_time) >= TO_DAYS(NOW()) AND (LOCATE('VIP订阅',product_type) OR LOCATE('大会员',product_type))`, EntnicheWaitEmpower), m.EntId)
|
|
|
- logx.Info(entnicheRoleId, "cccccc:", c)
|
|
|
//企业级服务 权限管理(只有企业管理员有权限)
|
|
|
if entnicheRoleId == 1 && c > 0 {
|
|
|
UserPowerMap["700"] = 1
|
|
@@ -220,6 +224,27 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
|
|
|
redis.Put(RedisCode, userRegisterTimeKey, strconv.Itoa(int(registerTime)), int(registerTime))
|
|
|
UserPowerMap["500"] = 1
|
|
|
}
|
|
|
+ //当前用户是否被分配权限
|
|
|
+ entnichePowers := Mysql.SelectBySql(fmt.Sprintf(`SELECT a.product_type,a.ent_id FROM %s a LEFT JOIN %s b ON a.id = b.wait_empower_id WHERE b.status = 1 AND b.ent_user_id = ?`, EntnicheWaitEmpower, EntnichePower), m.EntUserId)
|
|
|
+ if entnichePowers != nil && len(*entnichePowers) > 0 {
|
|
|
+ for _, entnichePower := range *entnichePowers {
|
|
|
+ //排除非当前企业分配的权限
|
|
|
+ if MC.Int64All(entnichePower["ent_id"]) != m.EntId {
|
|
|
+ productType := MC.ObjToString(entnichePower["product_type"])
|
|
|
+ if strings.Contains(productType, "大会员") && len(serviceIds["M"]) > 0 {
|
|
|
+ for _, v := range serviceIds["M"] {
|
|
|
+ UserPowerMap[v] = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(productType, "VIP订阅") && len(serviceIds["V"]) > 0 {
|
|
|
+ for _, v := range serviceIds["V"] {
|
|
|
+ UserPowerMap[v] = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if UserPowerMap != nil {
|
|
|
bytes, err := json.Marshal(UserPowerMap)
|