|
@@ -1,10 +1,6 @@
|
|
|
package jy
|
|
|
|
|
|
import (
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
- . "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
- "app.yhyue.com/moapp/jybase/mysql"
|
|
|
-
|
|
|
"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
)
|
|
|
|
|
@@ -30,14 +26,15 @@ type switchService struct {
|
|
|
* @param mongodb
|
|
|
* @return string 服务类型
|
|
|
*/
|
|
|
-func (s *switchService) Get(session *httpsession.Session, m MongodbSim) string {
|
|
|
- userId, _ := session.Get("userId").(string)
|
|
|
+func (s *switchService) Get(session *httpsession.Session, appid, host, key string) string {
|
|
|
+ //userId, _ := session.Get("userId").(string)
|
|
|
v, _ := session.Get(s.SessionKey).(string)
|
|
|
- u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
|
|
|
- if ok && u != nil {
|
|
|
- if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
|
|
|
+ data := GetBigVipUserBaseMsg(appid, session, host, key)
|
|
|
+ //u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
|
|
|
+ if data != nil {
|
|
|
+ if i_member_status := data.Status; v == s.Member && i_member_status > 0 {
|
|
|
return s.Member
|
|
|
- } else if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
|
|
|
+ } else if i_vip_status := data.VipStatus; v == s.Vip && i_vip_status > 0 {
|
|
|
return s.Vip
|
|
|
} else if i_member_status > 0 {
|
|
|
session.Set(s.SessionKey, s.Member)
|
|
@@ -51,24 +48,25 @@ func (s *switchService) Get(session *httpsession.Session, m MongodbSim) string {
|
|
|
return s.Free
|
|
|
}
|
|
|
|
|
|
-func (s *switchService) GetEntniche(session *httpsession.Session, m MongodbSim, sql *mysql.Mysql) string {
|
|
|
+func (s *switchService) GetEntniche(session *httpsession.Session, appid, host, key string) string {
|
|
|
sessMap := session.GetMultiple()
|
|
|
- userId, _ := sessMap["userId"].(string)
|
|
|
+ //userId, _ := sessMap["userId"].(string)
|
|
|
v, _ := sessMap[s.SessionKey].(string)
|
|
|
- u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
|
|
|
- entniche := false
|
|
|
- if entId, entUserId := util.IntAll(sessMap["entId"]), util.IntAll(sessMap["entUserId"]); entId > 0 && entUserId > 0 {
|
|
|
- //当前企业是否购买商机管理
|
|
|
- if sql.CountBySql(`SELECT count(1) as count FROM entniche_info a inner join entniche_user b on (a.id=? and a.status=1 and ifnull(a.power_source,0)=0 and b.id=? and b.power=1)`, entId, entUserId) > 0 {
|
|
|
- entniche = true
|
|
|
- }
|
|
|
- }
|
|
|
- if ok && u != nil {
|
|
|
- if i_member_status := util.IntAll((*u)["i_member_status"]); v == s.Member && i_member_status > 0 {
|
|
|
+ //u, ok := m.FindById("user", userId, `{"i_member_status":1,"i_vip_status":1}`)
|
|
|
+ data := GetBigVipUserBaseMsg(appid, session, host, key)
|
|
|
+ /* if entId, entUserId := util.IntAll(sessMap["entId"]), util.IntAll(sessMap["entUserId"]); entId > 0 && entUserId > 0 {
|
|
|
+ //当前企业是否购买商机管理
|
|
|
+ if sql.CountBySql(`SELECT count(1) as count FROM entniche_info a inner join entniche_user b on (a.id=? and a.status=1 and ifnull(a.power_source,0)=0 and b.id=? and b.power=1)`, entId, entUserId) > 0 {
|
|
|
+ entniche = true
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ entniche := data.Data.Entniche.Status > 0
|
|
|
+ if data != nil {
|
|
|
+ if i_member_status := data.Status; v == s.Member && i_member_status > 0 {
|
|
|
return s.Member
|
|
|
} else if v == s.Entniche && entniche {
|
|
|
return s.Entniche
|
|
|
- } else if i_vip_status := util.IntAll((*u)["i_vip_status"]); v == s.Vip && i_vip_status > 0 {
|
|
|
+ } else if i_vip_status := data.VipStatus; v == s.Vip && i_vip_status > 0 {
|
|
|
return s.Vip
|
|
|
} else if i_member_status > 0 {
|
|
|
session.Set(s.SessionKey, s.Member)
|
|
@@ -86,16 +84,16 @@ func (s *switchService) GetEntniche(session *httpsession.Session, m MongodbSim,
|
|
|
}
|
|
|
|
|
|
//所选服务是否是大会员
|
|
|
-func (s *switchService) IsMember(session *httpsession.Session, m MongodbSim, sql *mysql.Mysql) bool {
|
|
|
- return s.GetEntniche(session, m, sql) == s.Member
|
|
|
+func (s *switchService) IsMember(session *httpsession.Session, appid, host, key string) bool {
|
|
|
+ return s.GetEntniche(session, appid, host, key) == s.Member
|
|
|
}
|
|
|
|
|
|
//所选服务是否是超级订阅
|
|
|
-func (s *switchService) IsVip(session *httpsession.Session, m MongodbSim) bool {
|
|
|
- return s.Get(session, m) == s.Vip
|
|
|
+func (s *switchService) IsVip(session *httpsession.Session, appid, host, key string) bool {
|
|
|
+ return s.Get(session, appid, host, key) == s.Vip
|
|
|
}
|
|
|
|
|
|
//所选服务是否是免费
|
|
|
-func (s *switchService) IsFree(session *httpsession.Session, m MongodbSim) bool {
|
|
|
- return s.Get(session, m) == s.Free
|
|
|
+func (s *switchService) IsFree(session *httpsession.Session, appid, host, key string) bool {
|
|
|
+ return s.Get(session, appid, host, key) == s.Free
|
|
|
}
|