|
@@ -111,16 +111,17 @@ type SubPushQueryParam struct {
|
|
|
|
|
|
// 关键词参数
|
|
|
type KeyParam struct {
|
|
|
- UserId string //用户id
|
|
|
- EntUserId string //商机管理用户id
|
|
|
- DeptId string //商机管理用户部门id
|
|
|
- NewUserId int64
|
|
|
- IsEnt bool
|
|
|
- VipPower int64
|
|
|
- EntId string //企业id
|
|
|
- MemberPower int64
|
|
|
- PowerSource int64
|
|
|
- UserPower int64
|
|
|
+ UserId string //用户id
|
|
|
+ EntUserId string //商机管理用户id
|
|
|
+ DeptId string //商机管理用户部门id
|
|
|
+ NewUserId int64
|
|
|
+ IsEnt bool
|
|
|
+ VipPower int64
|
|
|
+ EntId string //企业id
|
|
|
+ MemberPower int64
|
|
|
+ PowerSource int64
|
|
|
+ UserPower int64
|
|
|
+ PositionType int64
|
|
|
}
|
|
|
|
|
|
func (spqp *SubPushQueryParam) IsEmpty() bool {
|
|
@@ -1442,18 +1443,89 @@ func (s *subscribePush) IsInTsGuide(userid string) bool {
|
|
|
}
|
|
|
func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
keyData := map[string][]interface{}{}
|
|
|
- if !spqp.IsEnt {
|
|
|
+ if spqp.IsEnt {
|
|
|
+ //企业关键词查找
|
|
|
+ res_, _ := IC.Mgo.Find("entniche_rule", map[string]interface{}{
|
|
|
+ "i_userid": map[string]interface{}{
|
|
|
+ "$exists": false,
|
|
|
+ },
|
|
|
+ "i_entid": common.Int64All(spqp.EntId),
|
|
|
+ }, "", `{"o_entniche":1}`, false, -1, -1)
|
|
|
+ o_entniche := map[string]interface{}{}
|
|
|
+ if res_ == nil || len(*res_) == 0 {
|
|
|
+ return MapToarr(keyData)
|
|
|
+ }
|
|
|
+ for _, ruleV := range *res_ {
|
|
|
+ o_entniche = common.StructToMapMore(ruleV["o_entniche"])
|
|
|
+ if o_entniche["a_items"] != nil {
|
|
|
+ a_item := common.ObjArrToMapArr(o_entniche["a_items"].([]interface{}))
|
|
|
+ for _, v := range a_item {
|
|
|
+ if v["a_key"] != nil {
|
|
|
+ a_key_arr := v["a_key"].([]interface{})
|
|
|
+ s_item := common.InterfaceToStr(v["s_item"])
|
|
|
+ if keyData[s_item] != nil {
|
|
|
+ //第一次搜索存在
|
|
|
+ //去重
|
|
|
+ keyData[s_item] = MergeArray(a_key_arr, keyData[s_item])
|
|
|
+ } else {
|
|
|
+ //第一次搜索不存在
|
|
|
+ keyData[s_item] = a_key_arr
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
//个人关键词查找
|
|
|
//fType:普通用户;vType:超级订阅用户;mType:大会员用户;eType:商机管理用户
|
|
|
- mData, ok := IC.Mgo.FindById("user", spqp.UserId, `{"o_jy":1,"o_vipjy":1,"o_member_jy":1,""i_member_sub_status":1,"s_member_mainid":1}`)
|
|
|
- if s.ModuleFlag == SubVipFlag {
|
|
|
- //从user表中取 o_vipjy.a_items
|
|
|
+ types := 2
|
|
|
+ typeKey := ""
|
|
|
+ switch s.ModuleFlag {
|
|
|
+ case SubVipFlag:
|
|
|
+ types = 1
|
|
|
+ typeKey = "o_vipjy"
|
|
|
+ case MemberFlag:
|
|
|
+ types = 1
|
|
|
+ typeKey = "o_member_jy"
|
|
|
+ case EntnicheFlag:
|
|
|
+ types = 0
|
|
|
+ typeKey = "o_entniche"
|
|
|
+ }
|
|
|
+ if spqp.PositionType == 1 {
|
|
|
+ typeKey = "o_entniche"
|
|
|
+ }
|
|
|
+ o_entniche := &map[string]interface{}{}
|
|
|
+ if spqp.PositionType == 0 {
|
|
|
+ mData, ok := IC.Mgo.FindById("user", spqp.UserId, `{"o_jy":1,"o_vipjy":1,"o_member_jy":1,""i_member_sub_status":1,"s_member_mainid":1}`)
|
|
|
if mData == nil || len(*mData) == 0 || !ok {
|
|
|
return nil
|
|
|
}
|
|
|
- o_vipjy := common.ObjToMap((*mData)["o_vipjy"])
|
|
|
- if (*o_vipjy)["a_items"] != nil {
|
|
|
- a_items := common.ObjArrToMapArr((*o_vipjy)["a_items"].([]interface{}))
|
|
|
+ if s.ModuleFlag == MemberFlag {
|
|
|
+ sub_status := common.Int64All((*mData)["i_member_sub_status"])
|
|
|
+ if sub_status == 1 {
|
|
|
+ //大会员子账号处理
|
|
|
+ mData, ok = IC.Mgo.FindById("user", common.InterfaceToStr((*mData)["s_member_mainid"]), `{"o_jy":1,"o_vipjy":1,"o_member_jy":1,""i_member_sub_status":1,"s_member_mainid":1}`)
|
|
|
+ if mData == nil || len(*mData) == 0 || !ok {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ o_entniche = common.ObjToMap((*mData)[typeKey])
|
|
|
+ } else {
|
|
|
+ res_, _ := IC.Mgo.FindOneByField("entniche_rule", map[string]interface{}{
|
|
|
+ "i_userid": common.Int64All(spqp.EntUserId),
|
|
|
+ "i_entid": common.Int64All(spqp.EntId),
|
|
|
+ "type": types,
|
|
|
+ }, `{"o_entniche":1}`)
|
|
|
+ if res_ != nil {
|
|
|
+ o_entniche = common.ObjToMap((*res_)["o_entniche"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if s.ModuleFlag == SubVipFlag {
|
|
|
+ //从user表中取 o_vipjy.a_items
|
|
|
+ if (*o_entniche)["a_items"] != nil {
|
|
|
+ a_items := common.ObjArrToMapArr((*o_entniche)["a_items"].([]interface{}))
|
|
|
for _, v := range a_items {
|
|
|
if v["a_key"] != nil {
|
|
|
a_key_arr := v["a_key"].([]interface{})
|
|
@@ -1463,20 +1535,9 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
}
|
|
|
} else if s.ModuleFlag == MemberFlag {
|
|
|
//从user表中取 o_member_jy.a_items
|
|
|
- if mData == nil || len(*mData) == 0 || !ok {
|
|
|
- return nil
|
|
|
- }
|
|
|
- sub_status := common.Int64All((*mData)["i_member_sub_status"])
|
|
|
- if sub_status == 1 {
|
|
|
- //大会员子账号处理
|
|
|
- mData, ok = IC.Mgo.FindById("user", common.InterfaceToStr((*mData)["s_member_mainid"]), `{"o_jy":1,"o_vipjy":1,"o_member_jy":1,""i_member_sub_status":1,"s_member_mainid":1}`)
|
|
|
- if mData == nil || len(*mData) == 0 || !ok {
|
|
|
- return nil
|
|
|
- }
|
|
|
- }
|
|
|
- o_memeberjy := common.ObjToMap((*mData)["o_member_jy"])
|
|
|
- if (*o_memeberjy)["a_items"] != nil {
|
|
|
- a_items := common.ObjArrToMapArr((*o_memeberjy)["a_items"].([]interface{}))
|
|
|
+ //o_memeberjy := common.ObjToMap((*mData)["o_member_jy"])
|
|
|
+ if (*o_entniche)["a_items"] != nil {
|
|
|
+ a_items := common.ObjArrToMapArr((*o_entniche)["a_items"].([]interface{}))
|
|
|
for _, v := range a_items {
|
|
|
if v["a_key"] != nil {
|
|
|
a_key_arr := v["a_key"].([]interface{})
|
|
@@ -1485,7 +1546,6 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
}
|
|
|
}
|
|
|
} else if s.ModuleFlag == EntnicheFlag {
|
|
|
- //entniche_rule表,查询条件:{i_entid:123,i_userid:456},取 o_entniche.a_items
|
|
|
res_, _ := IC.Mgo.FindOneByField("entniche_rule", map[string]interface{}{
|
|
|
"i_userid": common.Int64All(spqp.EntUserId),
|
|
|
"i_entid": common.Int64All(spqp.EntId),
|
|
@@ -1504,12 +1564,8 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if mData == nil || len(*mData) == 0 || !ok {
|
|
|
- return nil
|
|
|
- }
|
|
|
- o_jy, _ := (*mData)["o_jy"].(map[string]interface{})
|
|
|
//免费用户
|
|
|
- a_key, _ := o_jy["a_key"].([]interface{})
|
|
|
+ a_key, _ := (*o_entniche)["a_key"].([]interface{})
|
|
|
if len(a_key) > 0 {
|
|
|
for _, v := range a_key {
|
|
|
if keyData["未分类"] != nil {
|
|
@@ -1520,7 +1576,7 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (spqp.VipPower == 1 || spqp.MemberPower == 1) || (spqp.UserPower == 1 && spqp.PowerSource == 0) {
|
|
|
+ if spqp.PositionType == 1 && s.ModuleFlag != SubFreeFlag {
|
|
|
//1、mysql entniche_user_rule表中获取自己的分发规则id
|
|
|
data := IC.MainMysql.SelectBySql(`SELECT rule_id FROM entniche_user_rule a
|
|
|
INNER JOIN entniche_department b ON a.dept_id = b.id AND a.user_id =?
|
|
@@ -1577,43 +1633,8 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
|
keyData[v] = entnicheRule[v]
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //企业关键词查找
|
|
|
- res_, _ := IC.Mgo.Find("entniche_rule", map[string]interface{}{
|
|
|
- "i_userid": map[string]interface{}{
|
|
|
- "$exists": false,
|
|
|
- },
|
|
|
- "i_entid": common.Int64All(spqp.EntId),
|
|
|
- }, "", `{"o_entniche":1}`, false, -1, -1)
|
|
|
- o_entniche := map[string]interface{}{}
|
|
|
- if res_ == nil || len(*res_) == 0 {
|
|
|
-
|
|
|
- return MapToarr(keyData)
|
|
|
- }
|
|
|
- for _, ruleV := range *res_ {
|
|
|
- o_entniche = common.StructToMapMore(ruleV["o_entniche"])
|
|
|
- if o_entniche["a_items"] != nil {
|
|
|
- a_item := common.ObjArrToMapArr(o_entniche["a_items"].([]interface{}))
|
|
|
- for _, v := range a_item {
|
|
|
- if v["a_key"] != nil {
|
|
|
- a_key_arr := v["a_key"].([]interface{})
|
|
|
- s_item := common.InterfaceToStr(v["s_item"])
|
|
|
- if keyData[s_item] != nil {
|
|
|
- //第一次搜索存在
|
|
|
- //去重
|
|
|
- keyData[s_item] = MergeArray(a_key_arr, keyData[s_item])
|
|
|
- } else {
|
|
|
- //第一次搜索不存在
|
|
|
- keyData[s_item] = a_key_arr
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return MapToarr(keyData)
|
|
|
|