struct.go 20 KB

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