123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- package p
- import (
- "strings"
- util "app.yhyue.com/moapp/jybase/common"
- "bp.jydev.jianyu360.cn/pushpkg/dfa"
- )
- //
- type MgoConf struct {
- Address string
- Size int
- DbName string
- ReplSet string
- UserName string
- Password string
- Collection string
- ExperienceDbName string
- }
- //
- type RedisConf struct {
- Address string
- }
- //
- type MysqlConf struct {
- DbName string
- Address string
- UserName string
- PassWord string
- MaxOpenConns int
- MaxIdleConns int
- }
- //
- type EsConf struct {
- Address string
- Size int
- }
- //
- type MemberService struct {
- IsBuy bool
- Services map[int]*memberService
- }
- //
- type memberService struct {
- Id int
- StartTime string
- }
- //关键词
- type KeySet struct {
- Item string `json:"item"` //分类名称
- Keys []string `json:"key"` //关键词
- NotKeys []string `json:"notkey"` //排除词
- SubTypes []string `json:"infotype"` //信息类型
- Areas []string `json:"area"` //地区
- AppendKeys []string `json:"appendkey"` //附加词
- MatchWay int `json:"matchway"` //匹配模式 0:精准匹配 1:模糊匹配
- }
- //解析订阅词
- type SubSet struct {
- WxPush int //是否开启微信推送
- AppPush int //是否开启app推送
- MailPush int //是否开启邮箱推送
- RateMode int //推送时间
- Email string //邮箱
- MatchWay int //匹配方式 1-标题 2-正文
- Matchbuyerclass_other int //是否开启其他按钮
- ProjectMatch int //项目关联推送
- Items []string //关键词分类
- Keys []string //过滤后的关键词
- Notkeys []string //排除词
- Key_item map[string]string //关键词对应的分类名称
- Key_notkey map[string]map[string]bool //关键词所对应的排除词
- Key_area map[string]map[string]bool //关键词所对应的信息范围
- Key_subtype map[string]map[string]bool //关键词所对应的信息类型
- OriginalKeys []string //原始关键词
- Areas []string //区域-省份
- Area map[string]interface{} //区域-省份
- Subtype []interface{} //信息类型-二级分类
- Subtypes []string //信息类型-二级分类
- Buyerclass []interface{} //采购单位行业
- Buyerclasss []string //采购单位行业
- IsUpgrade bool //免费用户是否订阅升级
- MaxPushSize int //推送最大条数
- MaxMailSize int //邮件最大条数
- }
- //用户基本信息
- type UserInfo struct {
- Id string //mongoid
- BaseUserId int64 //mysql用户id
- S_m_openid string //公众号openid
- A_m_openid string //app微信登录openid
- Phone string //app手机号登录
- Jpushid string //极光推送id
- Opushid string //厂商推送id
- AppPhoneType string //手机型号
- ApplyStatus int //是否申请打开订阅推送
- Subscribe int //是否关注
- UserType int //用户类型
- VipStatus int // 1--试用 2--正式
- MemberStatus int //
- IsMainAccount bool //是否是主账号
- SonAccountStatus int //子账号状态 0-禁用 1-启用
- MainId string //主账号id
- Entniche *Entniche
- MemberMainid string
- WxTplMsg *WxTplMsg
- SubSet *SubSet
- Extend *UserInfoExtend
- }
- //
- type Entniche struct {
- EntId int //企业id
- EntName string //企业名称
- DeptId int //部门id
- //DeptName string //部门名称
- DisId string //分发id
- UserId int
- Unique string
- OnlyPush int
- IsNew int
- PowerSource int //权益来源
- ProductType string //产品类型
- Mail string //邮箱
- IsDis int //是否是分发
- DisMember int //分发-超级订阅
- DisVip int //分发-大会员
- }
- //用户基本信息-扩展
- type UserInfoExtend struct {
- CreateTime int64 //
- Size int
- }
- func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
- mk := (*m)[k]
- if mk == nil {
- mk = map[*UserInfo]bool{}
- }
- mk[u] = true
- (*m)[k] = mk
- }
- //添加信息类型映射关系
- func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
- if len(u.SubSet.Subtypes) == 0 {
- u.Add("", m)
- } else {
- for _, v := range u.SubSet.Subtypes {
- u.Add(v, m)
- }
- }
- }
- //添加采购单位类型映射关系
- func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
- //如果有关键词 有采购单位行业,行业加上“其它”
- if len(u.SubSet.Buyerclasss) == 0 {
- u.Add("", m)
- } else {
- if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
- u.Add("其它", m)
- }
- for _, v := range u.SubSet.Buyerclasss {
- u.Add(v, m)
- }
- }
- }
- //添加区域映射关系
- func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
- if len(u.SubSet.Areas) == 0 {
- u.Add("", m)
- } else {
- for _, v := range u.SubSet.Areas {
- u.Add(v, m)
- }
- }
- }
- //添加区域城市映射关系
- func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
- if len(u.SubSet.Area) == 0 {
- u.Add("", area)
- } else {
- for k, v := range u.SubSet.Area {
- if k == "" {
- continue
- }
- vs, _ := v.([]interface{})
- if len(vs) == 0 {
- u.Add(k, area)
- } else {
- for _, vv := range vs {
- s_vv, _ := vv.(string)
- if s_vv == "" {
- continue
- }
- u.Add(s_vv, city)
- }
- }
- }
- }
- }
- //把用户挂在词下面
- func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
- mp := map[string]bool{}
- for _, key := range keys {
- v := strings.ToUpper(key)
- if v == "" || mp[v] {
- continue
- }
- mp[v] = true
- arr := (*key_user)[v]
- if arr == nil {
- arr = &[]*UserInfo{}
- }
- *arr = append(*arr, u)
- (*key_user)[v] = arr
- }
- }
- type WxTplMsg struct {
- Key string
- Area string
- }
- type SortList []*MatchInfo
- func (s SortList) Len() int {
- return len(s)
- }
- func (s SortList) Less(i, j int) bool {
- return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
- }
- func (s SortList) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
- }
- type CSortList []map[string]interface{}
- func (s CSortList) Len() int {
- return len(s)
- }
- func (s CSortList) Less(i, j int) bool {
- return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
- }
- func (s CSortList) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
- }
- type MatchInfo struct {
- Info *map[string]interface{}
- Keys []string
- Items []string
- MatchWays []string
- DisId string
- }
- type KeyDfa struct {
- Key *dfa.DFA
- NotKey *dfa.DFA
- Key_user *map[string]*[]*UserInfo
- Notkey_user *map[string]*[]*UserInfo
- }
- //所有用户的关键词和排除词
- func (p *KeyDfa) CreateDaf() {
- //关键词
- p.Key = &dfa.DFA{}
- keys := make([]string, 0)
- for k, _ := range *p.Key_user {
- keys = append(keys, k)
- }
- p.Key.AddWord(keys...)
- //排除关键词
- p.NotKey = &dfa.DFA{}
- notKeys := make([]string, 0)
- for k, _ := range *p.Notkey_user {
- notKeys = append(notKeys, k)
- }
- p.NotKey.AddWord(notKeys...)
- }
- //
- type MatchUser struct {
- Keys []string
- MatchWays []string
- MatchWay map[string]bool
- }
- //
- type RelationProjectUser struct {
- TopTypes []string
- }
- //
- type PushInfo struct {
- Ids []interface{}
- Info map[string]interface{}
- }
- //推送返回结果
- type PushResult struct {
- WxStatus int
- AppStatus int
- MailStatus int
- PushDate int64
- Infos *SortList
- }
- //
- type PushWay struct {
- WxPush bool
- AppPush bool
- MailPush bool
- }
- //
- type PushParam struct {
- JpushTitle string
- LastInfoDate int64
- TitleArray []string
- Infos *SortList
- InfosLength int
- MailHtml string
- PushDate int64
- PushCount int
- IsPush bool
- }
- //
- type BiddingInfo struct {
- Id string
- Title string
- ClearTitle string
- HighlightTitle string
- AreaTitle string
- Area string
- Publishtime int64
- PublishtimeDiff string
- PublishtimeYMD string
- Buyerclass string
- Subscopeclass string
- Bidamount interface{}
- Budget interface{}
- Acount string
- Subtype string
- Toptype string
- Infotype string
- }
|