struct.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. package p
  2. import (
  3. "encoding/json"
  4. "sort"
  5. "strings"
  6. util "app.yhyue.com/moapp/jybase/common"
  7. . "app.yhyue.com/moapp/jybase/mongodb"
  8. "bp.jydev.jianyu360.cn/BaseService/pushpkg/dfa"
  9. "github.com/donnie4w/go-logger/logger"
  10. )
  11. //
  12. type MgoConf struct {
  13. Address string
  14. Size int
  15. DbName string
  16. ReplSet string
  17. UserName string
  18. Password string
  19. Collection string
  20. ExperienceDbName string
  21. }
  22. //
  23. type RedisConf struct {
  24. Address string
  25. }
  26. //
  27. type MysqlConf struct {
  28. DbName string
  29. Address string
  30. UserName string
  31. PassWord string
  32. MaxOpenConns int
  33. MaxIdleConns int
  34. }
  35. //
  36. type EsConf struct {
  37. Address string
  38. Size int
  39. }
  40. //
  41. type MemberService struct {
  42. IsBuy bool
  43. Services map[int]*memberService
  44. }
  45. //
  46. type memberService struct {
  47. Id int
  48. StartTime string
  49. }
  50. //关键词
  51. type KeySet struct {
  52. Item string `json:"item"` //分类名称
  53. Keys []string `json:"key"` //关键词
  54. NotKeys []string `json:"notkey"` //排除词
  55. SubTypes []string `json:"infotype"` //信息类型
  56. Areas []string `json:"area"` //地区
  57. AppendKeys []string `json:"appendkey"` //附加词
  58. MatchWay int `json:"matchway"` //匹配模式 0:精准匹配 1:模糊匹配
  59. }
  60. //解析订阅词
  61. type SubSet struct {
  62. MatchWay int //匹配方式 1-标题 2-正文
  63. Matchbuyerclass_other int //是否开启其他按钮
  64. ProjectMatch int //项目关联推送
  65. Items []string //关键词分类
  66. Keys []string //过滤后的关键词
  67. Notkeys []string //排除词
  68. Key_item map[string]string //关键词对应的分类名称
  69. Key_notkey map[string]map[string]bool //关键词所对应的排除词
  70. Key_area map[string]map[string]bool //关键词所对应的信息范围
  71. Key_subtype map[string]map[string]bool //关键词所对应的信息类型
  72. OriginalKeys []string //原始关键词
  73. Areas []string //区域-省份
  74. Area map[string]interface{} //区域-省份
  75. Subtype []interface{} //信息类型-二级分类
  76. Subtypes []string //信息类型-二级分类
  77. Buyerclass []interface{} //采购单位行业
  78. Buyerclasss []string //采购单位行业
  79. IsUpgrade bool //免费用户是否订阅升级
  80. MaxPushSize int //推送最大条数
  81. MaxMailSize int //邮件最大条数
  82. }
  83. //推送设置
  84. type PushSet struct {
  85. Email string //邮箱
  86. SubSet *PushSetChild //订阅推送设置
  87. WeekReport *PushSetChild //周报推送设置
  88. MonthReport *PushSetChild //月报推送设置
  89. NewprojectForecast *PushSetChild //潜在项目预测推送设置
  90. EntInfo *PushSetChild //企业情报监控-企业工商变动推送设置
  91. FollowProject *PushSetChild //项目进度监控推送设置
  92. FollowEnt *PushSetChild //企业情报监控-企业中标动态推送设置
  93. }
  94. func (p *PushSet) ResetSubSet() {
  95. if p.SubSet == nil {
  96. return
  97. }
  98. if p.SubSet.RateMode == 0 || p.SubSet.RateMode == 5 {
  99. p.SubSet.RateMode = 2
  100. if len(p.SubSet.Times) == 0 {
  101. p.SubSet.Times = append(p.SubSet.Times, "09:00", "14:00")
  102. }
  103. } else if p.SubSet.RateMode == 2 && len(p.SubSet.Times) == 0 {
  104. p.SubSet.Times = append(p.SubSet.Times, "09:00")
  105. }
  106. sort.Strings(p.SubSet.Times)
  107. }
  108. type PushSetChild struct {
  109. RateMode int //推送时间
  110. Times []string //自定义推送时间
  111. WxPush int //是否开启微信推送
  112. AppPush int //是否开启app推送
  113. MailPush int //是否开启邮箱推送
  114. }
  115. //用户基本信息
  116. type UserInfo struct {
  117. Id string //mongoid
  118. BaseUserId int64 //mysql用户id
  119. S_m_openid string //公众号openid
  120. A_m_openid string //app微信登录openid
  121. Phone string //app手机号登录
  122. Jpushid string //极光推送id
  123. Opushid string //厂商推送id
  124. AppPhoneType string //手机型号
  125. Subscribe int //是否关注
  126. VipStatus int //超级订阅 1--试用 2--正式
  127. MemberStatus int //大会员
  128. NicheStatus int //商机管理
  129. IsMainAccount bool //是否是主账号
  130. SonAccountStatus int //子账号状态 0-禁用 1-启用
  131. MainId string //主账号id
  132. Entniche *Entniche
  133. MemberMainid string
  134. WxTplMsg *WxTplMsg
  135. SubSet *SubSet
  136. PushSet *PushSet
  137. Extend *UserInfoExtend
  138. }
  139. /*
  140. *获取用户信息
  141. *temp 用户数据
  142. *tp 1-免费 2-超级订阅 3-大会员
  143. */
  144. func NewUserInfo(temp map[string]interface{}, tp int) *UserInfo {
  145. ui := &UserInfo{
  146. Id: BsonIdToSId(temp["_id"]),
  147. BaseUserId: util.Int64All(temp["base_user_id"]),
  148. S_m_openid: util.ObjToString(temp["s_m_openid"]),
  149. A_m_openid: util.ObjToString(temp["a_m_openid"]),
  150. Phone: GetPhone(temp),
  151. Jpushid: util.ObjToString(temp["s_jpushid"]),
  152. Opushid: util.ObjToString(temp["s_opushid"]),
  153. AppPhoneType: util.ObjToString(temp["s_appponetype"]),
  154. Subscribe: util.IntAllDef(temp["i_ispush"], 1),
  155. VipStatus: util.IntAll(temp["i_vip_status"]),
  156. MemberStatus: util.IntAll(temp["i_member_status"]),
  157. }
  158. if ui.MemberStatus > 0 {
  159. ui.IsMainAccount = util.IntAll(temp["i_mainaccount"]) == 1
  160. ui.SonAccountStatus = util.IntAllDef(temp["i_member_sub_status"], -1)
  161. ui.MemberMainid = util.ObjToString(temp["s_member_mainid"])
  162. }
  163. if tp == 3 {
  164. obj, _ := temp["o_member_jy"].(map[string]interface{})
  165. ui.GetSubSet(false, ui.Id, obj)
  166. } else if tp == 2 {
  167. obj, _ := temp["o_vipjy"].(map[string]interface{})
  168. ui.GetSubSet(false, ui.Id, obj)
  169. } else if tp == 1 {
  170. obj, _ := temp["o_jy"].(map[string]interface{})
  171. ui.GetSubSet(true, ui.Id, obj)
  172. }
  173. o_pushset, _ := temp["o_pushset"].(map[string]interface{})
  174. ui.GetPushSet(o_pushset)
  175. return ui
  176. }
  177. //解析用户的推送设置
  178. func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
  179. subSet, _ := obj["o_subset"].(map[string]interface{})
  180. times, _ := subSet["a_times"].([]interface{})
  181. weekReport, _ := obj["o_week_report"].(map[string]interface{})
  182. monthReport, _ := obj["o_month_report"].(map[string]interface{})
  183. newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
  184. entInfo, _ := obj["o_entinfo"].(map[string]interface{})
  185. followProject, _ := obj["o_follow_project"].(map[string]interface{})
  186. followEnt, _ := obj["o_follow_ent"].(map[string]interface{})
  187. u.PushSet = &PushSet{
  188. Email: strings.TrimSpace(util.ObjToString(obj["s_email"])),
  189. SubSet: &PushSetChild{
  190. WxPush: util.IntAllDef(subSet["i_wxpush"], 1),
  191. AppPush: util.IntAllDef(subSet["i_apppush"], 1),
  192. MailPush: util.IntAll(subSet["i_mailpush"]),
  193. RateMode: util.IntAll(subSet["i_ratemode"]),
  194. Times: util.ObjArrToStringArr(times),
  195. },
  196. WeekReport: &PushSetChild{
  197. WxPush: util.IntAllDef(weekReport["i_wxpush"], 1),
  198. AppPush: util.IntAllDef(weekReport["i_apppush"], 1),
  199. MailPush: util.IntAll(weekReport["i_mailpush"]),
  200. },
  201. MonthReport: &PushSetChild{
  202. WxPush: util.IntAllDef(monthReport["i_wxpush"], 1),
  203. AppPush: util.IntAllDef(monthReport["i_apppush"], 1),
  204. MailPush: util.IntAll(monthReport["i_mailpush"]),
  205. },
  206. NewprojectForecast: &PushSetChild{
  207. WxPush: util.IntAllDef(newprojectForecast["i_wxpush"], 1),
  208. AppPush: util.IntAllDef(newprojectForecast["i_apppush"], 1),
  209. MailPush: util.IntAll(newprojectForecast["i_mailpush"]),
  210. },
  211. EntInfo: &PushSetChild{
  212. WxPush: util.IntAllDef(entInfo["i_wxpush"], 1),
  213. AppPush: util.IntAllDef(entInfo["i_apppush"], 1),
  214. MailPush: util.IntAll(entInfo["i_mailpush"]),
  215. },
  216. FollowProject: &PushSetChild{
  217. WxPush: util.IntAllDef(followProject["i_wxpush"], 1),
  218. AppPush: util.IntAllDef(followProject["i_apppush"], 1),
  219. MailPush: util.IntAll(followProject["i_mailpush"]),
  220. },
  221. FollowEnt: &PushSetChild{
  222. WxPush: util.IntAllDef(followEnt["i_wxpush"], 1),
  223. AppPush: util.IntAllDef(followEnt["i_apppush"], 1),
  224. MailPush: util.IntAll(followEnt["i_mailpush"]),
  225. },
  226. }
  227. u.PushSetFilter()
  228. u.PushSet.ResetSubSet()
  229. }
  230. //解析用户的推送设置
  231. func (u *UserInfo) PushSetFilter() {
  232. if u.Subscribe == 0 || u.S_m_openid == "" {
  233. u.PushSet.SubSet.WxPush = -1
  234. u.PushSet.WeekReport.WxPush = -1
  235. u.PushSet.MonthReport.WxPush = -1
  236. u.PushSet.NewprojectForecast.WxPush = -1
  237. u.PushSet.EntInfo.WxPush = -1
  238. u.PushSet.FollowProject.WxPush = -1
  239. u.PushSet.FollowEnt.WxPush = -1
  240. }
  241. if u.Jpushid == "" && u.Opushid == "" {
  242. u.PushSet.SubSet.AppPush = -1
  243. u.PushSet.WeekReport.AppPush = -1
  244. u.PushSet.MonthReport.AppPush = -1
  245. u.PushSet.NewprojectForecast.AppPush = -1
  246. u.PushSet.EntInfo.AppPush = -1
  247. u.PushSet.FollowProject.AppPush = -1
  248. u.PushSet.FollowEnt.AppPush = -1
  249. }
  250. mailPush := true
  251. if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid == "" {
  252. mailPush = false
  253. } else if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid != "" && u.Jpushid == "" && u.Opushid == "" {
  254. mailPush = false
  255. } else if !MailReg.MatchString(u.PushSet.Email) {
  256. mailPush = false
  257. }
  258. if !mailPush {
  259. u.PushSet.SubSet.MailPush = -1
  260. u.PushSet.WeekReport.MailPush = -1
  261. u.PushSet.MonthReport.MailPush = -1
  262. u.PushSet.NewprojectForecast.MailPush = -1
  263. u.PushSet.EntInfo.MailPush = -1
  264. u.PushSet.FollowProject.MailPush = -1
  265. u.PushSet.FollowEnt.MailPush = -1
  266. }
  267. }
  268. //解析用户的订阅设置
  269. func (u *UserInfo) GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) {
  270. subSet := &SubSet{
  271. Keys: []string{},
  272. Notkeys: []string{},
  273. Key_item: map[string]string{},
  274. Key_notkey: map[string]map[string]bool{},
  275. Key_area: map[string]map[string]bool{},
  276. Key_subtype: map[string]map[string]bool{},
  277. OriginalKeys: []string{},
  278. Areas: []string{},
  279. Subtypes: []string{},
  280. Buyerclasss: []string{},
  281. MatchWay: util.IntAllDef(obj["i_matchway"], 1),
  282. Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
  283. ProjectMatch: util.IntAll(obj["i_projectmatch"]),
  284. MaxPushSize: util.IntAll(obj["i_maxpushsize"]),
  285. MaxMailSize: util.IntAll(obj["i_maxmailsize"]),
  286. }
  287. var keySets []*KeySet
  288. if isFreeUser {
  289. var err error
  290. keySets, err = u.GetKeySets(obj["a_key"])
  291. if err != nil {
  292. logger.Error("获取用户关键词错误!", userId, obj["a_key"], err)
  293. return
  294. }
  295. area := obj["o_area"]
  296. if ppStatus := util.IntAll(obj["i_ppstatus"]); ppStatus == 1 {
  297. area = obj["o_area_p"]
  298. }
  299. if newFree := util.IntAll(obj["i_newfree"]); newFree == 1 && area != nil {
  300. subSet.IsUpgrade = true
  301. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  302. subSet.Area, _ = area.(map[string]interface{})
  303. }
  304. } else {
  305. items, _ := obj["a_items"].([]interface{})
  306. for _, v := range items {
  307. item, _ := v.(map[string]interface{})
  308. itemName := strings.TrimSpace(util.ObjToString(item["s_item"]))
  309. subSet.Items = append(subSet.Items, itemName)
  310. kss, err := u.GetKeySets(item["a_key"])
  311. if err != nil {
  312. logger.Error("获取用户关键词错误!", userId, item["a_key"], err)
  313. continue
  314. }
  315. for _, vv := range kss {
  316. if vv == nil {
  317. continue
  318. }
  319. if vv.MatchWay == 1 {
  320. for _, vvv := range vv.Keys {
  321. keySets = append(keySets, &KeySet{
  322. Item: itemName,
  323. Keys: []string{vvv},
  324. NotKeys: vv.NotKeys,
  325. })
  326. }
  327. for _, vvv := range vv.AppendKeys {
  328. keySets = append(keySets, &KeySet{
  329. Item: itemName,
  330. Keys: []string{vvv},
  331. NotKeys: vv.NotKeys,
  332. })
  333. }
  334. } else {
  335. vv.Item = itemName
  336. keySets = append(keySets, vv)
  337. }
  338. }
  339. }
  340. subSet.Buyerclass, _ = obj["a_buyerclass"].([]interface{})
  341. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  342. subSet.Area, _ = obj["o_area"].(map[string]interface{})
  343. }
  344. for _, v := range subSet.Buyerclass {
  345. s_v, _ := v.(string)
  346. if s_v == "" {
  347. continue
  348. }
  349. subSet.Buyerclasss = append(subSet.Buyerclasss, s_v)
  350. }
  351. for _, v := range subSet.Subtype {
  352. s_v, _ := v.(string)
  353. if s_v == "" {
  354. continue
  355. }
  356. subSet.Subtypes = append(subSet.Subtypes, s_v)
  357. }
  358. for area, _ := range subSet.Area {
  359. if area == "" {
  360. continue
  361. }
  362. subSet.Areas = append(subSet.Areas, area)
  363. }
  364. ////////////////
  365. for _, vs := range keySets {
  366. if vs == nil {
  367. logger.Error(userId, "关键词设置异常")
  368. continue
  369. }
  370. var vs_keys []string
  371. for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
  372. for _, vs_vv := range vs_v {
  373. vs_vv = strings.TrimSpace(vs_vv)
  374. if vs_vv == "" {
  375. continue
  376. }
  377. vs_keys = append(vs_keys, vs_vv)
  378. }
  379. }
  380. if len(vs_keys) == 0 {
  381. continue
  382. }
  383. key := strings.Join(vs_keys, "+")
  384. subSet.OriginalKeys = append(subSet.OriginalKeys, key)
  385. if KeyFilterReg.MatchString(key) {
  386. continue
  387. } else if !KeyRetainReg.MatchString(key) {
  388. continue
  389. }
  390. subSet.Keys = append(subSet.Keys, key)
  391. subSet.Notkeys = append(subSet.Notkeys, vs.NotKeys...)
  392. //转大写
  393. upperKey := strings.ToUpper(key)
  394. subSet.Key_item[upperKey] = vs.Item
  395. //建立与排除词的对应关系
  396. for _, notkey := range vs.NotKeys {
  397. upperNotkey := strings.ToUpper(notkey)
  398. if subSet.Key_notkey[upperKey] == nil {
  399. subSet.Key_notkey[upperKey] = map[string]bool{}
  400. }
  401. subSet.Key_notkey[upperKey][upperNotkey] = true
  402. }
  403. //免费用户需要进行映射
  404. if isFreeUser {
  405. //建立与信息范围的对应关系
  406. for _, area := range vs.Areas {
  407. if subSet.Key_area[upperKey] == nil {
  408. subSet.Key_area[upperKey] = map[string]bool{}
  409. }
  410. subSet.Key_area[upperKey][area] = true
  411. }
  412. //建立与信息类型的对应关系
  413. for _, subtype := range vs.SubTypes {
  414. if subSet.Key_subtype[upperKey] == nil {
  415. subSet.Key_subtype[upperKey] = map[string]bool{}
  416. }
  417. subSet.Key_subtype[upperKey][subtype] = true
  418. }
  419. }
  420. }
  421. u.SubSet = subSet
  422. }
  423. //得到用户的关键词
  424. func (u *UserInfo) GetKeySets(a_key interface{}) ([]*KeySet, error) {
  425. var keySets []*KeySet
  426. if a_key == nil {
  427. return keySets, nil
  428. }
  429. _bs, err := json.Marshal(a_key)
  430. if err == nil {
  431. err = json.Unmarshal(_bs, &keySets)
  432. }
  433. if err != nil {
  434. return keySets, err
  435. }
  436. for _, v := range keySets {
  437. if v == nil {
  438. continue
  439. }
  440. keys, appendKeys, notKeys := []string{}, []string{}, []string{}
  441. for _, vv := range v.Keys {
  442. keys = append(keys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  443. }
  444. for _, vv := range v.AppendKeys {
  445. appendKeys = append(appendKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  446. }
  447. for _, vv := range v.NotKeys {
  448. notKeys = append(notKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  449. }
  450. v.Keys = keys
  451. v.AppendKeys = appendKeys
  452. v.NotKeys = notKeys
  453. }
  454. return keySets, err
  455. }
  456. //
  457. type Entniche struct {
  458. EntId int //企业id
  459. EntName string //企业名称
  460. DeptId int //部门id
  461. DisId string //分发id
  462. UserId int
  463. Unique string
  464. OnlyPush int
  465. IsNew int
  466. PowerSource int //权益来源
  467. ProductType string //产品类型
  468. Mail string //邮箱
  469. IsDis int //是否是分发
  470. DisMember int //分发-超级订阅
  471. DisVip int //分发-大会员
  472. }
  473. //用户基本信息-扩展
  474. type UserInfoExtend struct {
  475. CreateTime int64 //
  476. Size int
  477. }
  478. func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
  479. mk := (*m)[k]
  480. if mk == nil {
  481. mk = map[*UserInfo]bool{}
  482. }
  483. mk[u] = true
  484. (*m)[k] = mk
  485. }
  486. //添加信息类型映射关系
  487. func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
  488. if len(u.SubSet.Subtypes) == 0 {
  489. u.Add("", m)
  490. } else {
  491. for _, v := range u.SubSet.Subtypes {
  492. u.Add(v, m)
  493. }
  494. }
  495. }
  496. //添加采购单位类型映射关系
  497. func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
  498. //如果有关键词 有采购单位行业,行业加上“其它”
  499. if len(u.SubSet.Buyerclasss) == 0 {
  500. u.Add("", m)
  501. } else {
  502. if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
  503. u.Add("其它", m)
  504. }
  505. for _, v := range u.SubSet.Buyerclasss {
  506. u.Add(v, m)
  507. }
  508. }
  509. }
  510. //添加区域映射关系
  511. func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
  512. if len(u.SubSet.Areas) == 0 {
  513. u.Add("", m)
  514. } else {
  515. for _, v := range u.SubSet.Areas {
  516. u.Add(v, m)
  517. }
  518. }
  519. }
  520. //添加区域城市映射关系
  521. func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
  522. if len(u.SubSet.Area) == 0 {
  523. u.Add("", area)
  524. } else {
  525. for k, v := range u.SubSet.Area {
  526. if k == "" {
  527. continue
  528. }
  529. vs, _ := v.([]interface{})
  530. if len(vs) == 0 {
  531. u.Add(k, area)
  532. } else {
  533. for _, vv := range vs {
  534. s_vv, _ := vv.(string)
  535. if s_vv == "" {
  536. continue
  537. }
  538. u.Add(s_vv, city)
  539. }
  540. }
  541. }
  542. }
  543. }
  544. //把用户挂在词下面
  545. func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
  546. mp := map[string]bool{}
  547. for _, key := range keys {
  548. v := strings.ToUpper(key)
  549. if v == "" || mp[v] {
  550. continue
  551. }
  552. mp[v] = true
  553. arr := (*key_user)[v]
  554. if arr == nil {
  555. arr = &[]*UserInfo{}
  556. }
  557. *arr = append(*arr, u)
  558. (*key_user)[v] = arr
  559. }
  560. }
  561. type WxTplMsg struct {
  562. Key string
  563. Area string
  564. }
  565. type SortList []*MatchInfo
  566. func (s SortList) Len() int {
  567. return len(s)
  568. }
  569. func (s SortList) Less(i, j int) bool {
  570. return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
  571. }
  572. func (s SortList) Swap(i, j int) {
  573. s[i], s[j] = s[j], s[i]
  574. }
  575. type CSortList []map[string]interface{}
  576. func (s CSortList) Len() int {
  577. return len(s)
  578. }
  579. func (s CSortList) Less(i, j int) bool {
  580. return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
  581. }
  582. func (s CSortList) Swap(i, j int) {
  583. s[i], s[j] = s[j], s[i]
  584. }
  585. type MatchInfo struct {
  586. Info *map[string]interface{}
  587. Keys []string
  588. Items []string
  589. MatchWays []string
  590. DisId string
  591. }
  592. type KeyDfa struct {
  593. Key *dfa.DFA
  594. NotKey *dfa.DFA
  595. Key_user *map[string]*[]*UserInfo
  596. Notkey_user *map[string]*[]*UserInfo
  597. }
  598. //所有用户的关键词和排除词
  599. func (p *KeyDfa) CreateDaf() {
  600. //关键词
  601. p.Key = &dfa.DFA{}
  602. keys := make([]string, 0)
  603. for k, _ := range *p.Key_user {
  604. keys = append(keys, k)
  605. }
  606. p.Key.AddWord(keys...)
  607. //排除关键词
  608. p.NotKey = &dfa.DFA{}
  609. notKeys := make([]string, 0)
  610. for k, _ := range *p.Notkey_user {
  611. notKeys = append(notKeys, k)
  612. }
  613. p.NotKey.AddWord(notKeys...)
  614. }
  615. //
  616. type MatchUser struct {
  617. Keys []string
  618. MatchWays []string
  619. MatchWay map[string]bool
  620. }
  621. //
  622. type RelationProjectUser struct {
  623. TopTypes []string
  624. }
  625. //
  626. type PushInfo struct {
  627. Ids []interface{}
  628. Info map[string]interface{}
  629. }
  630. //推送返回结果
  631. type PushResult struct {
  632. WxStatus int
  633. AppStatus int
  634. MailStatus int
  635. PushDate int64
  636. Infos *SortList
  637. }
  638. //
  639. type PushParam struct {
  640. JpushTitle string
  641. LastInfoDate int64
  642. TitleArray []string
  643. Infos *SortList
  644. InfosLength int
  645. MailHtml string
  646. PushDate int64
  647. PushCount int
  648. IsPush bool
  649. }
  650. //
  651. type BiddingInfo struct {
  652. Id string
  653. Title string
  654. ClearTitle string
  655. HighlightTitle string
  656. AreaTitle string
  657. Area string
  658. Publishtime int64
  659. PublishtimeDiff string
  660. PublishtimeYMD string
  661. Buyerclass string
  662. Subscopeclass string
  663. Bidamount interface{}
  664. Budget interface{}
  665. Acount string
  666. Subtype string
  667. Toptype string
  668. Infotype string
  669. }
  670. //身份信息
  671. type IdentityInfo struct {
  672. Name string
  673. PersonId int64
  674. UserName string
  675. AccountId int64
  676. EntAccountId int64
  677. PositionId int64
  678. PositionType int64
  679. EntId int64
  680. EntUserId int64
  681. EntUserName string
  682. UserId int64
  683. }