|
@@ -3,6 +3,7 @@ package matcher
|
|
|
import (
|
|
|
"strings"
|
|
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
|
)
|
|
|
|
|
@@ -11,6 +12,8 @@ type PayUser struct {
|
|
|
Users map[*UserInfo]bool
|
|
|
Title_KeyDfa *KeyDfa
|
|
|
Detail_KeyDfa *KeyDfa
|
|
|
+ Filetext_KeyDfa *KeyDfa
|
|
|
+ PnP_KeyDfa *KeyDfa
|
|
|
BuyerclassUsers map[string]map[*UserInfo]bool
|
|
|
AreaUsers map[string]map[*UserInfo]bool
|
|
|
CityUsers map[string]map[*UserInfo]bool
|
|
@@ -45,30 +48,78 @@ func (p *PayUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUse
|
|
|
city, _ := info["city"].(string)
|
|
|
district, _ := info["district"].(string)
|
|
|
subtype, _ := info["subtype"].(string)
|
|
|
- title := GetInfoTitle(info)
|
|
|
- //订阅词
|
|
|
- keys := p.Title_KeyDfa.Key.Analy(title)
|
|
|
- //排除词
|
|
|
- notkeys := p.Title_KeyDfa.NotKey.Analy(title)
|
|
|
+ var amount float64
|
|
|
+ if info["bidamount"] != nil {
|
|
|
+ amount = util.Float64All(info["bidamount"])
|
|
|
+ } else if info["budget"] != nil {
|
|
|
+ amount = util.Float64All(info["budget"])
|
|
|
+ }
|
|
|
notUsers := map[*UserInfo]bool{}
|
|
|
- title_users := p.GetFinalUser(MatchWay_Title, keys, notkeys, p.Title_KeyDfa.Key_user, ¬Users)
|
|
|
- //开启智能匹配的用户,匹配projectscope
|
|
|
- detail_users := &map[*UserInfo]*MatchUser{}
|
|
|
+ yesUsers := &map[*UserInfo]*MatchUser{}
|
|
|
+ //匹配标题
|
|
|
+ if p.Title_KeyDfa != nil {
|
|
|
+ if title := GetInfoTitle(info); title != "" {
|
|
|
+ //订阅词
|
|
|
+ keys := p.Title_KeyDfa.Key.Analy(title)
|
|
|
+ //排除词
|
|
|
+ notkeys := p.Title_KeyDfa.NotKey.Analy(title)
|
|
|
+ yesUsers = p.GetFinalUser(MatchWay_Title, keys, notkeys, p.Title_KeyDfa.Key_user, ¬Users)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //匹配项目名称/标的物
|
|
|
+ if p.PnP_KeyDfa != nil {
|
|
|
+ if projectname, _ := info["projectname"].(string); projectname != "" {
|
|
|
+ projectname = strings.ToUpper(projectname)
|
|
|
+ keys := p.PnP_KeyDfa.Key.Analy(projectname)
|
|
|
+ notkeys := p.PnP_KeyDfa.NotKey.Analy(projectname)
|
|
|
+ projectname_users := p.GetFinalUser(MatchWay_Projectname, keys, notkeys, p.PnP_KeyDfa.Key_user, ¬Users)
|
|
|
+ for d_k, d_u := range *projectname_users {
|
|
|
+ if (*yesUsers)[d_k] != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ (*yesUsers)[d_k] = d_u
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if purchasing, _ := info["purchasing"].(string); purchasing != "" {
|
|
|
+ purchasing = strings.ToUpper(purchasing)
|
|
|
+ keys := p.PnP_KeyDfa.Key.Analy(purchasing)
|
|
|
+ notkeys := p.PnP_KeyDfa.NotKey.Analy(purchasing)
|
|
|
+ purchasing_users := p.GetFinalUser(MatchWay_Purchasing, keys, notkeys, p.PnP_KeyDfa.Key_user, ¬Users)
|
|
|
+ for d_k, d_u := range *purchasing_users {
|
|
|
+ if (*yesUsers)[d_k] != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ (*yesUsers)[d_k] = d_u
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //匹配附件
|
|
|
if p.Detail_KeyDfa != nil {
|
|
|
- //detail, _ := (*info)["projectscope"].(string)
|
|
|
- //if detail == "" {
|
|
|
- detail, _ := info["detail"].(string)
|
|
|
- //}
|
|
|
- if detail != "" {
|
|
|
+ if filetext, _ := info["filetext"].(string); filetext != "" {
|
|
|
+ filetext = strings.ToUpper(filetext)
|
|
|
+ keys := p.Filetext_KeyDfa.Key.Analy(filetext)
|
|
|
+ notkeys := p.Filetext_KeyDfa.NotKey.Analy(filetext)
|
|
|
+ filetext_users := p.GetFinalUser(MatchWay_Filetext, keys, notkeys, p.Filetext_KeyDfa.Key_user, ¬Users)
|
|
|
+ for d_k, d_u := range *filetext_users {
|
|
|
+ if (*yesUsers)[d_k] != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ (*yesUsers)[d_k] = d_u
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //匹配正文
|
|
|
+ if p.Detail_KeyDfa != nil {
|
|
|
+ if detail, _ := info["detail"].(string); detail != "" {
|
|
|
detail = strings.ToUpper(detail)
|
|
|
- keys = p.Detail_KeyDfa.Key.Analy(detail)
|
|
|
- notkeys = p.Detail_KeyDfa.NotKey.Analy(detail)
|
|
|
- detail_users = p.GetFinalUser(MatchWay_Detail, keys, notkeys, p.Detail_KeyDfa.Key_user, ¬Users)
|
|
|
+ keys := p.Detail_KeyDfa.Key.Analy(detail)
|
|
|
+ notkeys := p.Detail_KeyDfa.NotKey.Analy(detail)
|
|
|
+ detail_users := p.GetFinalUser(MatchWay_Detail, keys, notkeys, p.Detail_KeyDfa.Key_user, ¬Users)
|
|
|
for d_k, d_u := range *detail_users {
|
|
|
- if (*title_users)[d_k] != nil {
|
|
|
+ if (*yesUsers)[d_k] != nil {
|
|
|
continue
|
|
|
}
|
|
|
- (*title_users)[d_k] = d_u
|
|
|
+ (*yesUsers)[d_k] = d_u
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -77,8 +128,7 @@ func (p *PayUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUse
|
|
|
for k, _ := range p.Users {
|
|
|
if notUsers[k] {
|
|
|
continue
|
|
|
- }
|
|
|
- if (!p.BuyerclassUsers[""][k] && !p.BuyerclassUsers[buyerclass][k]) ||
|
|
|
+ } else if (!p.BuyerclassUsers[""][k] && !p.BuyerclassUsers[buyerclass][k]) ||
|
|
|
(!p.AreaUsers[""][k] && !p.AreaUsers[area][k] && !p.CityUsers[city][k] && (p.DistrictUsers[city] == nil || !p.DistrictUsers[city][district][k])) {
|
|
|
continue
|
|
|
}
|
|
@@ -89,12 +139,16 @@ func (p *PayUser) ToMatch(info map[string]interface{}) (*map[*UserInfo]*MatchUse
|
|
|
if !p.SubtypeUsers[""][k] && !p.SubtypeUsers[subtype][k] {
|
|
|
continue
|
|
|
}
|
|
|
+ if k.SubSet.StartAmount > 0 && k.SubSet.EndAmount > 0 && (amount < k.SubSet.StartAmount || amount > k.SubSet.EndAmount) {
|
|
|
+ continue
|
|
|
+ } else if k.SubSet.StartAmount > 0 && amount < k.SubSet.StartAmount {
|
|
|
+ continue
|
|
|
+ } else if k.SubSet.EndAmount > 0 && amount > k.SubSet.EndAmount {
|
|
|
+ continue
|
|
|
+ }
|
|
|
var matchUser *MatchUser
|
|
|
if len(k.SubSet.Keys) > 0 {
|
|
|
- matchUser = (*title_users)[k]
|
|
|
- if matchUser == nil {
|
|
|
- matchUser = (*detail_users)[k]
|
|
|
- }
|
|
|
+ matchUser = (*yesUsers)[k]
|
|
|
if matchUser == nil {
|
|
|
continue
|
|
|
}
|