struct.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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. u.PushSetFilter()
  213. }
  214. //解析用户的推送设置
  215. func (u *UserInfo) PushSetFilter() {
  216. if u.Subscribe == 0 || u.S_m_openid == "" {
  217. u.PushSet.SubSet.WxPush = -1
  218. u.PushSet.WeekReport.WxPush = -1
  219. u.PushSet.MonthReport.WxPush = -1
  220. u.PushSet.NewprojectForecast.WxPush = -1
  221. u.PushSet.EntInfo.WxPush = -1
  222. u.PushSet.FollowProject.WxPush = -1
  223. u.PushSet.FollowEnt.WxPush = -1
  224. }
  225. if u.Jpushid == "" && u.Opushid == "" {
  226. u.PushSet.SubSet.AppPush = -1
  227. u.PushSet.WeekReport.AppPush = -1
  228. u.PushSet.MonthReport.AppPush = -1
  229. u.PushSet.NewprojectForecast.AppPush = -1
  230. u.PushSet.EntInfo.AppPush = -1
  231. u.PushSet.FollowProject.AppPush = -1
  232. u.PushSet.FollowEnt.AppPush = -1
  233. }
  234. mailPush := true
  235. if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid == "" {
  236. mailPush = false
  237. } else if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid != "" && u.Jpushid == "" && u.Opushid == "" {
  238. mailPush = false
  239. } else if !MailReg.MatchString(u.PushSet.Email) {
  240. mailPush = false
  241. }
  242. if !mailPush {
  243. u.PushSet.SubSet.MailPush = -1
  244. u.PushSet.WeekReport.MailPush = -1
  245. u.PushSet.MonthReport.MailPush = -1
  246. u.PushSet.NewprojectForecast.MailPush = -1
  247. u.PushSet.EntInfo.MailPush = -1
  248. u.PushSet.FollowProject.MailPush = -1
  249. u.PushSet.FollowEnt.MailPush = -1
  250. }
  251. }
  252. //解析用户的订阅设置
  253. func (u *UserInfo) GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) {
  254. subSet := &SubSet{
  255. Keys: []string{},
  256. Notkeys: []string{},
  257. Key_item: map[string]string{},
  258. Key_notkey: map[string]map[string]bool{},
  259. Key_area: map[string]map[string]bool{},
  260. Key_subtype: map[string]map[string]bool{},
  261. OriginalKeys: []string{},
  262. Areas: []string{},
  263. Subtypes: []string{},
  264. Buyerclasss: []string{},
  265. MatchWay: util.IntAllDef(obj["i_matchway"], 1),
  266. Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
  267. ProjectMatch: util.IntAll(obj["i_projectmatch"]),
  268. MaxPushSize: util.IntAll(obj["i_maxpushsize"]),
  269. MaxMailSize: util.IntAll(obj["i_maxmailsize"]),
  270. }
  271. var keySets []*KeySet
  272. if isFreeUser {
  273. var err error
  274. keySets, err = u.GetKeySets(obj["a_key"])
  275. if err != nil {
  276. logger.Error("获取用户关键词错误!", userId, obj["a_key"], err)
  277. return
  278. }
  279. area := obj["o_area"]
  280. if ppStatus := util.IntAll(obj["i_ppstatus"]); ppStatus == 1 {
  281. area = obj["o_area_p"]
  282. }
  283. if newFree := util.IntAll(obj["i_newfree"]); newFree == 1 && area != nil {
  284. subSet.IsUpgrade = true
  285. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  286. subSet.Area, _ = area.(map[string]interface{})
  287. }
  288. } else {
  289. items, _ := obj["a_items"].([]interface{})
  290. for _, v := range items {
  291. item, _ := v.(map[string]interface{})
  292. itemName := strings.TrimSpace(util.ObjToString(item["s_item"]))
  293. subSet.Items = append(subSet.Items, itemName)
  294. kss, err := u.GetKeySets(item["a_key"])
  295. if err != nil {
  296. logger.Error("获取用户关键词错误!", userId, item["a_key"], err)
  297. continue
  298. }
  299. for _, vv := range kss {
  300. if vv == nil {
  301. continue
  302. }
  303. if vv.MatchWay == 1 {
  304. for _, vvv := range vv.Keys {
  305. keySets = append(keySets, &KeySet{
  306. Item: itemName,
  307. Keys: []string{vvv},
  308. NotKeys: vv.NotKeys,
  309. })
  310. }
  311. for _, vvv := range vv.AppendKeys {
  312. keySets = append(keySets, &KeySet{
  313. Item: itemName,
  314. Keys: []string{vvv},
  315. NotKeys: vv.NotKeys,
  316. })
  317. }
  318. } else {
  319. vv.Item = itemName
  320. keySets = append(keySets, vv)
  321. }
  322. }
  323. }
  324. subSet.Buyerclass, _ = obj["a_buyerclass"].([]interface{})
  325. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  326. subSet.Area, _ = obj["o_area"].(map[string]interface{})
  327. }
  328. for _, v := range subSet.Buyerclass {
  329. s_v, _ := v.(string)
  330. if s_v == "" {
  331. continue
  332. }
  333. subSet.Buyerclasss = append(subSet.Buyerclasss, s_v)
  334. }
  335. for _, v := range subSet.Subtype {
  336. s_v, _ := v.(string)
  337. if s_v == "" {
  338. continue
  339. }
  340. subSet.Subtypes = append(subSet.Subtypes, s_v)
  341. }
  342. for area, _ := range subSet.Area {
  343. if area == "" {
  344. continue
  345. }
  346. subSet.Areas = append(subSet.Areas, area)
  347. }
  348. ////////////////
  349. for _, vs := range keySets {
  350. if vs == nil {
  351. logger.Error(userId, "关键词设置异常")
  352. continue
  353. }
  354. var vs_keys []string
  355. for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
  356. for _, vs_vv := range vs_v {
  357. vs_vv = strings.TrimSpace(vs_vv)
  358. if vs_vv == "" {
  359. continue
  360. }
  361. vs_keys = append(vs_keys, vs_vv)
  362. }
  363. }
  364. if len(vs_keys) == 0 {
  365. continue
  366. }
  367. key := strings.Join(vs_keys, "+")
  368. subSet.OriginalKeys = append(subSet.OriginalKeys, key)
  369. if KeyFilterReg.MatchString(key) {
  370. continue
  371. } else if !KeyRetainReg.MatchString(key) {
  372. continue
  373. }
  374. subSet.Keys = append(subSet.Keys, key)
  375. subSet.Notkeys = append(subSet.Notkeys, vs.NotKeys...)
  376. //转大写
  377. upperKey := strings.ToUpper(key)
  378. subSet.Key_item[upperKey] = vs.Item
  379. //建立与排除词的对应关系
  380. for _, notkey := range vs.NotKeys {
  381. upperNotkey := strings.ToUpper(notkey)
  382. if subSet.Key_notkey[upperKey] == nil {
  383. subSet.Key_notkey[upperKey] = map[string]bool{}
  384. }
  385. subSet.Key_notkey[upperKey][upperNotkey] = true
  386. }
  387. //免费用户需要进行映射
  388. if isFreeUser {
  389. //建立与信息范围的对应关系
  390. for _, area := range vs.Areas {
  391. if subSet.Key_area[upperKey] == nil {
  392. subSet.Key_area[upperKey] = map[string]bool{}
  393. }
  394. subSet.Key_area[upperKey][area] = true
  395. }
  396. //建立与信息类型的对应关系
  397. for _, subtype := range vs.SubTypes {
  398. if subSet.Key_subtype[upperKey] == nil {
  399. subSet.Key_subtype[upperKey] = map[string]bool{}
  400. }
  401. subSet.Key_subtype[upperKey][subtype] = true
  402. }
  403. }
  404. }
  405. u.SubSet = subSet
  406. }
  407. //得到用户的关键词
  408. func (u *UserInfo) GetKeySets(a_key interface{}) ([]*KeySet, error) {
  409. var keySets []*KeySet
  410. if a_key == nil {
  411. return keySets, nil
  412. }
  413. _bs, err := json.Marshal(a_key)
  414. if err == nil {
  415. err = json.Unmarshal(_bs, &keySets)
  416. }
  417. if err != nil {
  418. return keySets, err
  419. }
  420. for _, v := range keySets {
  421. if v == nil {
  422. continue
  423. }
  424. keys, appendKeys, notKeys := []string{}, []string{}, []string{}
  425. for _, vv := range v.Keys {
  426. keys = append(keys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  427. }
  428. for _, vv := range v.AppendKeys {
  429. appendKeys = append(appendKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  430. }
  431. for _, vv := range v.NotKeys {
  432. notKeys = append(notKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  433. }
  434. v.Keys = keys
  435. v.AppendKeys = appendKeys
  436. v.NotKeys = notKeys
  437. }
  438. return keySets, err
  439. }
  440. //
  441. type Entniche struct {
  442. EntId int //企业id
  443. EntName string //企业名称
  444. DeptId int //部门id
  445. DisId string //分发id
  446. UserId int
  447. Unique string
  448. OnlyPush int
  449. IsNew int
  450. PowerSource int //权益来源
  451. ProductType string //产品类型
  452. Mail string //邮箱
  453. IsDis int //是否是分发
  454. DisMember int //分发-超级订阅
  455. DisVip int //分发-大会员
  456. }
  457. //用户基本信息-扩展
  458. type UserInfoExtend struct {
  459. CreateTime int64 //
  460. Size int
  461. }
  462. func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
  463. mk := (*m)[k]
  464. if mk == nil {
  465. mk = map[*UserInfo]bool{}
  466. }
  467. mk[u] = true
  468. (*m)[k] = mk
  469. }
  470. //添加信息类型映射关系
  471. func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
  472. if len(u.SubSet.Subtypes) == 0 {
  473. u.Add("", m)
  474. } else {
  475. for _, v := range u.SubSet.Subtypes {
  476. u.Add(v, m)
  477. }
  478. }
  479. }
  480. //添加采购单位类型映射关系
  481. func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
  482. //如果有关键词 有采购单位行业,行业加上“其它”
  483. if len(u.SubSet.Buyerclasss) == 0 {
  484. u.Add("", m)
  485. } else {
  486. if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
  487. u.Add("其它", m)
  488. }
  489. for _, v := range u.SubSet.Buyerclasss {
  490. u.Add(v, m)
  491. }
  492. }
  493. }
  494. //添加区域映射关系
  495. func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
  496. if len(u.SubSet.Areas) == 0 {
  497. u.Add("", m)
  498. } else {
  499. for _, v := range u.SubSet.Areas {
  500. u.Add(v, m)
  501. }
  502. }
  503. }
  504. //添加区域城市映射关系
  505. func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
  506. if len(u.SubSet.Area) == 0 {
  507. u.Add("", area)
  508. } else {
  509. for k, v := range u.SubSet.Area {
  510. if k == "" {
  511. continue
  512. }
  513. vs, _ := v.([]interface{})
  514. if len(vs) == 0 {
  515. u.Add(k, area)
  516. } else {
  517. for _, vv := range vs {
  518. s_vv, _ := vv.(string)
  519. if s_vv == "" {
  520. continue
  521. }
  522. u.Add(s_vv, city)
  523. }
  524. }
  525. }
  526. }
  527. }
  528. //把用户挂在词下面
  529. func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
  530. mp := map[string]bool{}
  531. for _, key := range keys {
  532. v := strings.ToUpper(key)
  533. if v == "" || mp[v] {
  534. continue
  535. }
  536. mp[v] = true
  537. arr := (*key_user)[v]
  538. if arr == nil {
  539. arr = &[]*UserInfo{}
  540. }
  541. *arr = append(*arr, u)
  542. (*key_user)[v] = arr
  543. }
  544. }
  545. type WxTplMsg struct {
  546. Key string
  547. Area string
  548. }
  549. type SortList []*MatchInfo
  550. func (s SortList) Len() int {
  551. return len(s)
  552. }
  553. func (s SortList) Less(i, j int) bool {
  554. return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
  555. }
  556. func (s SortList) Swap(i, j int) {
  557. s[i], s[j] = s[j], s[i]
  558. }
  559. type CSortList []map[string]interface{}
  560. func (s CSortList) Len() int {
  561. return len(s)
  562. }
  563. func (s CSortList) Less(i, j int) bool {
  564. return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
  565. }
  566. func (s CSortList) Swap(i, j int) {
  567. s[i], s[j] = s[j], s[i]
  568. }
  569. type MatchInfo struct {
  570. Info *map[string]interface{}
  571. Keys []string
  572. Items []string
  573. MatchWays []string
  574. DisId string
  575. }
  576. type KeyDfa struct {
  577. Key *dfa.DFA
  578. NotKey *dfa.DFA
  579. Key_user *map[string]*[]*UserInfo
  580. Notkey_user *map[string]*[]*UserInfo
  581. }
  582. //所有用户的关键词和排除词
  583. func (p *KeyDfa) CreateDaf() {
  584. //关键词
  585. p.Key = &dfa.DFA{}
  586. keys := make([]string, 0)
  587. for k, _ := range *p.Key_user {
  588. keys = append(keys, k)
  589. }
  590. p.Key.AddWord(keys...)
  591. //排除关键词
  592. p.NotKey = &dfa.DFA{}
  593. notKeys := make([]string, 0)
  594. for k, _ := range *p.Notkey_user {
  595. notKeys = append(notKeys, k)
  596. }
  597. p.NotKey.AddWord(notKeys...)
  598. }
  599. //
  600. type MatchUser struct {
  601. Keys []string
  602. MatchWays []string
  603. MatchWay map[string]bool
  604. }
  605. //
  606. type RelationProjectUser struct {
  607. TopTypes []string
  608. }
  609. //
  610. type PushInfo struct {
  611. Ids []interface{}
  612. Info map[string]interface{}
  613. }
  614. //推送返回结果
  615. type PushResult struct {
  616. WxStatus int
  617. AppStatus int
  618. MailStatus int
  619. PushDate int64
  620. Infos *SortList
  621. }
  622. //
  623. type PushParam struct {
  624. JpushTitle string
  625. LastInfoDate int64
  626. TitleArray []string
  627. Infos *SortList
  628. InfosLength int
  629. MailHtml string
  630. PushDate int64
  631. PushCount int
  632. IsPush bool
  633. }
  634. //
  635. type BiddingInfo struct {
  636. Id string
  637. Title string
  638. ClearTitle string
  639. HighlightTitle string
  640. AreaTitle string
  641. Area string
  642. Publishtime int64
  643. PublishtimeDiff string
  644. PublishtimeYMD string
  645. Buyerclass string
  646. Subscopeclass string
  647. Bidamount interface{}
  648. Budget interface{}
  649. Acount string
  650. Subtype string
  651. Toptype string
  652. Infotype string
  653. }
  654. //身份信息
  655. type IdentityInfo struct {
  656. Name string
  657. PersonId int64
  658. UserName string
  659. AccountId int64
  660. EntAccountId int64
  661. PositionId int64
  662. PositionType int64
  663. EntId int64
  664. EntUserId int64
  665. EntUserName string
  666. UserId int64
  667. }