Bläddra i källkod

feat:医疗领域化

wangshan 2 år sedan
förälder
incheckning
5c7619baf6
3 ändrade filer med 28 tillägg och 10 borttagningar
  1. 17 2
      entity/user.go
  2. 4 3
      entity/workDesktop.go
  3. 7 5
      service/workDesktop.go

+ 17 - 2
entity/user.go

@@ -17,6 +17,7 @@ const (
 	RedisMenuKey            = "jy_workdesktopmenu_%s_%s_%s"
 	UserPowerRedisKey       = "jy_userpowerredis_%s_%d_%s"
 	UserEntIdKey            = "jy_userentid_%s_%d_%s"
+	CapitalRetention        = "capital_retention"
 )
 
 /*
@@ -24,7 +25,7 @@ const (
 *测试用例放的地方不对 待调整
  */
 //用户权限 初始化
-func AutoUserPowerInfo(userId, appId string, internalTime int, bigMemberOff bool, entId int64) map[string]int {
+func AutoUserPowerInfo(userId, baseUserId, appId string, internalTime int, bigMemberOff bool, entId int64) map[string]int {
 	/*
 	* 商机管理--》新版商机管理vs老版商机管理
 	* 大会员--》bigmember_service
@@ -43,7 +44,10 @@ func AutoUserPowerInfo(userId, appId string, internalTime int, bigMemberOff bool
 	//查询用户信息
 	data, ok := Mgo.FindById("user", userId, `{"s_phone":1,"s_m_phone":1,i_member_status":1,"s_member_mainid":1,"i_member_sub_status":1,"i_vip_status":1,"o_vipjy":1,"o_jy":1,"l_registedate":1}`)
 	if ok && *data != nil && len(*data) > 0 {
-		var isFree = true
+		var (
+			isFree     = true
+			domainBool = false //第一版领域化权限判断
+		)
 		phone, _ := MC.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string)
 		if phone != "" {
 			//同一个手机号 多个商机管理角色 其中一个是企业管理员或者部门管理员 查的时候按角色权重排序
@@ -82,6 +86,7 @@ func AutoUserPowerInfo(userId, appId string, internalTime int, bigMemberOff bool
 			if memberStatus := MC.IntAll((*data)["i_member_status"]); memberStatus > 0 || bigMemberOff {
 				userId := userId
 				if memberStatus > 0 {
+					domainBool = true
 					isFree = false
 					UserPowerMap["0"] = memberStatus
 					//是否是子账号 而且 子账号被启用
@@ -99,6 +104,7 @@ func AutoUserPowerInfo(userId, appId string, internalTime int, bigMemberOff bool
 			}
 			//VIP用户
 			if vipStatus := MC.IntAll((*data)["i_vip_status"]); vipStatus > 0 {
+				domainBool = true
 				isFree = false
 				UserPowerMap["200"] = vipStatus
 				if vipSet := MC.ObjToMap((*data)["o_vipjy"]); vipSet != nil {
@@ -123,6 +129,15 @@ func AutoUserPowerInfo(userId, appId string, internalTime int, bigMemberOff bool
 			if Mysql.CountBySql(`select count(*) from privatedata where phone = ?`, phone) > 0 {
 				UserPowerMap["400"] = 1
 			}
+			//领域化产品权限
+			//第一版:必须是大会员或者超级订阅用户 且留资 留资表:capital_retention;source = 'medical_domain',未留资提示留资信息
+			//第二版:调资源中台rpc获取用户是否有使用领域化产品的权限 无权限则去购买
+			if domainBool {
+				c := BaseMysql.CountBySql(`SELECT COUNT(id) FROM `+CapitalRetention+` WHERE  source = 'medical_domain' AND user_id = ? AND appid = ?`, baseUserId, appId)
+				if c > 0 {
+					UserPowerMap["500"] = 1
+				}
+			}
 		}
 		if UserPowerMap != nil {
 			bytes, err := json.Marshal(UserPowerMap)

+ 4 - 3
entity/workDesktop.go

@@ -36,6 +36,7 @@ type JYMenu struct {
 	AdditionalInfo Additional
 	AppType        string
 	OpenType       string
+	Status         int
 	Children       []*JYMenu
 }
 
@@ -211,7 +212,7 @@ func (m *WorkDesktopMenu) VerifyPermissions(powerIds string) (b bool) {
 		return true
 	}
 	if len(strings.Split(powerIds, ",")) > 0 {
-		userPower := AutoUserPowerInfo(m.UserId, m.AppId, m.TimeOut, m.BigMemberOff, m.EntId)
+		userPower := AutoUserPowerInfo(m.UserId, m.NewUserId, m.AppId, m.TimeOut, m.BigMemberOff, m.EntId)
 		func(powerIds string) {
 			for _, pv := range strings.Split(powerIds, ",") {
 				if userPower[pv] > 0 {
@@ -283,8 +284,8 @@ func (m *WorkDesktopMenu) CommonlyFormat(childMenus map[int][]*JYMenu) ([]*pb.Th
 	delBool := false //更新因超级订阅用户,又购买大会员得用户 导致附件下载包||采购单位画像记录||企业画像记录 不应该展示
 	var saveIds []string
 	for _, mv := range m.MenuTree {
-		//过滤子级
-		if subLevel[mv.ParentId] {
+		//过滤子级   ++  三级下架菜单:mv.Status == 1
+		if subLevel[mv.ParentId] || mv.Status == 1 {
 			continue
 		}
 		//附件下载包、采购单位画像记录、企业画像记录  如果是大会员+超级订阅  排除此三项菜单

+ 7 - 5
service/workDesktop.go

@@ -82,20 +82,21 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 				for _, mv := range *menuData {
 					//id
 					id := MC.IntAll(mv["id"])
-					//parentid
-					parentid := MC.IntAll(mv["parentid"])
+					//parentId
+					parentId := MC.IntAll(mv["parentid"])
 					parentIsExists[id] = true
 					menu := &entity.JYMenu{
 						Id:        MC.IntAll(mv["id"]),
 						Name:      MC.ObjToString(mv["name"]),
 						Match:     MC.ObjToString(mv["match"]),
 						OrderId:   MC.IntAll(mv["orderid"]),
-						ParentId:  MC.IntAll(mv["parentid"]),
+						ParentId:  parentId,
 						PowerIds:  MC.ObjToString(mv["powerids"]),
 						CheckCode: MC.IntAll(mv["checkcode"]),
 						Icon:      MC.ObjToString(mv["icon"]),
 						AppType:   MC.ObjToString(mv["apptype"]),
 						OpenType:  MC.ObjToString(mv["opentype"]),
+						Status:    MC.IntAll(mv["status"]),
 					}
 					switch in.Platform {
 					case "WX":
@@ -111,8 +112,8 @@ func RenewWorkDesktopMenuModeOrCommonly(in *WorkDesktopComprehensiveReq) (r *Wor
 							menu.AdditionalInfo = additional
 						}
 					}
-					if parentIsExists[parentid] {
-						childMenus[parentid] = append(childMenus[parentid], menu)
+					if parentIsExists[parentId] {
+						childMenus[parentId] = append(childMenus[parentId], menu)
 					} else {
 						m.MenuTree = append(m.MenuTree, menu)
 					}
@@ -223,6 +224,7 @@ func GetWordDesktopMenuTree(in *WorkDesktopMenuInfoReq) ([]*pb.MenuList, error)
 			Icon:      MC.ObjToString(v["icon"]),
 			AppType:   MC.ObjToString(v["apptype"]),
 			OpenType:  MC.ObjToString(v["opentype"]),
+			Status:    MC.IntAll(v["status"]),
 		}
 		switch in.Platform {
 		case "WX":