struct.go 19 KB

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