|
@@ -364,11 +364,19 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
} else {
|
|
} else {
|
|
if spqp.IsEnt {
|
|
if spqp.IsEnt {
|
|
- if spqp.BuySubject == 1 {
|
|
|
|
|
|
+ isNew := 0
|
|
|
|
+ if spqp.UserType == EntnicheFlag {
|
|
|
|
+ //商机管理判断
|
|
|
|
+ newCount := IC.MainMysql.CountBySql("select count(id) from entniche_info where id =? and isNew=1 and status=1", spqp.EntId)
|
|
|
|
+ if newCount > 0 {
|
|
|
|
+ //新商机管理
|
|
|
|
+ isNew = 1
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if spqp.BuySubject == 1 || isNew == 1 {
|
|
//企业主体是企业的企业查询
|
|
//企业主体是企业的企业查询
|
|
userStr = fmt.Sprintf(" a.entid='%s' and (a.source > 1) ", spqp.EntId)
|
|
userStr = fmt.Sprintf(" a.entid='%s' and (a.source > 1) ", spqp.EntId)
|
|
} else {
|
|
} else {
|
|
- //企业主体是个人的企业查询
|
|
|
|
userStr = fmt.Sprintf(" a.entid='%s' ", spqp.EntId)
|
|
userStr = fmt.Sprintf(" a.entid='%s' ", spqp.EntId)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -1498,7 +1506,10 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
}
|
|
}
|
|
if (spqp.VipPower == 1 || spqp.MemberPower == 1) || (spqp.UserPower == 1 && spqp.PowerSource == 0) {
|
|
if (spqp.VipPower == 1 || spqp.MemberPower == 1) || (spqp.UserPower == 1 && spqp.PowerSource == 0) {
|
|
//1、mysql entniche_user_rule表中获取自己的分发规则id
|
|
//1、mysql entniche_user_rule表中获取自己的分发规则id
|
|
- data := IC.MainMysql.SelectBySql(`select rule_id from entniche_user_rule where user_id =? `, spqp.EntUserId)
|
|
|
|
|
|
+ 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 =?
|
|
|
|
+ ORDER BY b.pid
|
|
|
|
+ LIMIT 1 `, spqp.EntUserId)
|
|
if data == nil || len(*data) == 0 {
|
|
if data == nil || len(*data) == 0 {
|
|
return MapToarr(keyData)
|
|
return MapToarr(keyData)
|
|
}
|
|
}
|
|
@@ -1513,13 +1524,17 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
return MapToarr(keyData)
|
|
return MapToarr(keyData)
|
|
}
|
|
}
|
|
//2、entniche_rule表, 企业订阅关键词查询条件: {i_entid:123,i_deptid:0},取 o_entniche.a_items
|
|
//2、entniche_rule表, 企业订阅关键词查询条件: {i_entid:123,i_deptid:0},取 o_entniche.a_items
|
|
- res_, _ := IC.Mgo.FindOneByField("entniche_rule", map[string]interface{}{
|
|
|
|
- "i_deptid": map[string]interface{}{"$exists": false},
|
|
|
|
- "i_userid": map[string]interface{}{
|
|
|
|
- "$exists": false,
|
|
|
|
- },
|
|
|
|
|
|
+ deptid := common.Int64All((*res)["i_deptid"])
|
|
|
|
+ ruleMap := map[string]interface{}{
|
|
"i_entid": common.Int64All(spqp.EntId),
|
|
"i_entid": common.Int64All(spqp.EntId),
|
|
- }, `{"o_entniche":1}`)
|
|
|
|
|
|
+ }
|
|
|
|
+ if deptid == 0 {
|
|
|
|
+ ruleMap["i_deptid"] = map[string]interface{}{"$exists": false}
|
|
|
|
+ ruleMap["i_userid"] = map[string]interface{}{"$exists": false}
|
|
|
|
+ } else {
|
|
|
|
+ ruleMap["i_deptid"] = deptid
|
|
|
|
+ }
|
|
|
|
+ res_, _ := IC.Mgo.FindOneByField("entniche_rule", ruleMap, `{"o_entniche":1}`)
|
|
o_entniche := &map[string]interface{}{}
|
|
o_entniche := &map[string]interface{}{}
|
|
if res_ != nil {
|
|
if res_ != nil {
|
|
o_entniche = common.ObjToMap((*res_)["o_entniche"])
|
|
o_entniche = common.ObjToMap((*res_)["o_entniche"])
|
|
@@ -1551,26 +1566,39 @@ func (s *subscribePush) Keys(spqp *KeyParam) (result []*bxsubscribe.KeyItems) {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//企业关键词查找
|
|
//企业关键词查找
|
|
- res_, _ := IC.Mgo.FindOneByField("entniche_rule", map[string]interface{}{
|
|
|
|
- "i_deptid": map[string]interface{}{"$exists": false},
|
|
|
|
|
|
+ res_, _ := IC.Mgo.Find("entniche_rule", map[string]interface{}{
|
|
|
|
+ "i_deptid": map[string]interface{}{"$exists": true},
|
|
"i_userid": map[string]interface{}{
|
|
"i_userid": map[string]interface{}{
|
|
"$exists": false,
|
|
"$exists": false,
|
|
},
|
|
},
|
|
"i_entid": common.Int64All(spqp.EntId),
|
|
"i_entid": common.Int64All(spqp.EntId),
|
|
- }, `{"o_entniche":1}`)
|
|
|
|
- o_entniche := &map[string]interface{}{}
|
|
|
|
- if res_ != nil {
|
|
|
|
- o_entniche = common.ObjToMap((*res_)["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{})
|
|
|
|
- keyData[common.InterfaceToStr(v["s_item"])] = a_key_arr
|
|
|
|
|
|
+ }, "", `{"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)
|
|
return MapToarr(keyData)
|