struct.go 20 KB

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