cygx_yanxuan_special.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/models/company"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
  13. func SendWxMsgSpecialFollow(specialId int) (err error) {
  14. defer func() {
  15. if err != nil {
  16. go utils.SendAlarmMsg(fmt.Sprint("研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息失败", specialId, ", specialId", err.Error()), 2)
  17. }
  18. }()
  19. var first string
  20. var keyword1 string
  21. var keyword2 string
  22. var keyword3 string
  23. var keyword4 string
  24. var remark string
  25. followers, e := models.GetYanxuanSpecialFollowUserById(specialId)
  26. if e != nil {
  27. err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
  28. return
  29. }
  30. if len(followers) == 0 {
  31. return
  32. }
  33. specialItem, e := models.GetYanxuanSpecialItemById(specialId)
  34. if e != nil {
  35. err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
  36. return
  37. }
  38. var allInUserId string
  39. for _, v := range followers {
  40. allInUserId += strconv.Itoa(v) + ","
  41. }
  42. allInUserId = strings.TrimRight(allInUserId, ",")
  43. userList, err := models.GetWxUserListByUserIds(allInUserId)
  44. if err != nil && err.Error() != utils.ErrNoRow() {
  45. return err
  46. }
  47. mobile := ``
  48. for _, v := range userList {
  49. mobile += v.Mobile + ","
  50. }
  51. mobile = strings.TrimRight(mobile, ",")
  52. openIdList, e := models.GetWxOpenIdByMobileList(mobile)
  53. if e != nil {
  54. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  55. return
  56. }
  57. if len(openIdList) == 0 {
  58. return
  59. }
  60. //first =
  61. keyword1 = "研选专栏:" + specialItem.SpecialName
  62. keyword2 = "发布了新内容,点击查看详情"
  63. keyword3 = "-"
  64. //keyword4 = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
  65. openIdArr := make([]string, 0)
  66. for _, v := range openIdList {
  67. openIdArr = append(openIdArr, v.OpenId)
  68. }
  69. redirectUrl := ""
  70. redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
  71. sendInfo := new(SendWxTemplate)
  72. sendInfo.First = first
  73. sendInfo.Keyword1 = keyword1
  74. sendInfo.Keyword2 = keyword2
  75. sendInfo.Keyword3 = keyword3
  76. sendInfo.Keyword4 = keyword4
  77. sendInfo.Remark = remark
  78. sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
  79. sendInfo.RedirectUrl = redirectUrl
  80. sendInfo.RedirectTarget = 3
  81. sendInfo.Resource = strconv.Itoa(specialId)
  82. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  83. sendInfo.OpenIdArr = openIdArr
  84. err = PublicSendTemplateMsg(sendInfo)
  85. if err != nil {
  86. return
  87. }
  88. return
  89. }
  90. // SendReviewTemplateMsgAdmin 提交审核时给王芳,葛琳发消息
  91. func SendReviewTemplateMsgAdmin(specialId int) (err error) {
  92. defer func() {
  93. if err != nil {
  94. go utils.SendAlarmMsg(fmt.Sprint("处理试用申请给王芳,汪洋发消息失败, specialId:", specialId, "ErrMsg", err.Error()), 2)
  95. }
  96. }()
  97. var configCode string
  98. //研选专栏修改之后给这些手机号推送审核模版消息
  99. configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
  100. cnf, e := models.GetConfigByCode(configCode)
  101. if e != nil {
  102. err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
  103. return
  104. }
  105. openIdList, e := models.GetUserRecordListByMobile(4, cnf.ConfigValue)
  106. if e != nil && e.Error() != utils.ErrNoRow() {
  107. err = errors.New("GetUserRecordListByMobile, Err: " + e.Error() + cnf.ConfigValue)
  108. return err
  109. }
  110. specialItem, e := models.GetYanxuanSpecialItemById(specialId)
  111. if e != nil {
  112. err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
  113. return
  114. }
  115. user, e := models.GetWxUserItemByUserId(specialItem.UserId)
  116. if e != nil {
  117. err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
  118. return err
  119. }
  120. var keyword1 string
  121. var keyword2 string
  122. var keyword3 string
  123. var keyword4 string
  124. var remark string
  125. keyword1 = specialItem.RealName + "【" + user.CompanyName + "】"
  126. keyword2 = user.Mobile
  127. keyword3 = time.Now().Format(utils.FormatDateTime)
  128. keyword4 = "研选专栏提交了内容待审核"
  129. openIdArr := make([]string, 0)
  130. for _, v := range openIdList {
  131. openIdArr = append(openIdArr, v.OpenId)
  132. }
  133. redirectUrl := ""
  134. redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_ENABLE_DETAIL + strconv.Itoa(specialId)
  135. sendInfo := new(SendWxTemplate)
  136. sendInfo.Keyword1 = keyword1
  137. sendInfo.Keyword2 = keyword2
  138. sendInfo.Keyword3 = keyword3
  139. sendInfo.Keyword4 = keyword4
  140. sendInfo.Remark = remark
  141. sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
  142. sendInfo.RedirectUrl = redirectUrl
  143. sendInfo.RedirectTarget = 3
  144. sendInfo.Resource = strconv.Itoa(specialId)
  145. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  146. sendInfo.OpenIdArr = openIdArr
  147. err = PublicSendTemplateMsg(sendInfo)
  148. if err != nil {
  149. return
  150. }
  151. return
  152. }
  153. // 研选专栏审核完成时,给提交人发送模板消息
  154. func SendWxMsgSpecialAuthor(specialId, status int) (err error) {
  155. defer func() {
  156. if err != nil {
  157. go utils.SendAlarmMsg(fmt.Sprint("研选专栏审核完成时,给提交人发送模板消息", specialId, ", specialId", err.Error()), 2)
  158. }
  159. }()
  160. var first string
  161. var keyword1 string
  162. var keyword2 string
  163. var keyword3 string
  164. var keyword4 string
  165. var remark string
  166. var redirectUrl string
  167. specialItem, e := models.GetYanxuanSpecialItemById(specialId)
  168. if e != nil {
  169. err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
  170. return
  171. }
  172. user, e := models.GetWxUserItemByUserId(specialItem.UserId)
  173. if e != nil {
  174. err = errors.New("GetWxUserItemByUserId, Err: " + e.Error())
  175. return err
  176. }
  177. openIdList, err := models.GetUserRecordListByMobile(4, user.Mobile)
  178. if err != nil && err.Error() != utils.ErrNoRow() {
  179. return err
  180. }
  181. if len(openIdList) == 0 {
  182. err = nil
  183. return
  184. }
  185. keyword1 = "研选专栏内容审核"
  186. if status == 1 {
  187. keyword2 = "已通过审核,点击查看详情"
  188. redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_DETAIL + strconv.Itoa(specialId)
  189. } else {
  190. keyword2 = "未通过审核,点击查看驳回原因"
  191. redirectUrl = utils.WX_MSG_PATH_YX_SPECIAL_CENTER
  192. }
  193. keyword3 = "-"
  194. openIdArr := make([]string, 0)
  195. for _, v := range openIdList {
  196. openIdArr = append(openIdArr, v.OpenId)
  197. }
  198. sendInfo := new(SendWxTemplate)
  199. sendInfo.First = first
  200. sendInfo.Keyword1 = keyword1
  201. sendInfo.Keyword2 = keyword2
  202. sendInfo.Keyword3 = keyword3
  203. sendInfo.Keyword4 = keyword4
  204. sendInfo.Remark = remark
  205. sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
  206. sendInfo.RedirectUrl = redirectUrl
  207. sendInfo.RedirectTarget = 3
  208. sendInfo.Resource = strconv.Itoa(specialId)
  209. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  210. sendInfo.OpenIdArr = openIdArr
  211. err = PublicSendTemplateMsg(sendInfo)
  212. if err != nil {
  213. return
  214. }
  215. return
  216. }
  217. // 更新研选专栏 写入首页最新 cygx_resource_data 表
  218. func UpdateYanxuanSpecialResourceData(sourceId int) {
  219. var err error
  220. defer func() {
  221. if err != nil {
  222. go utils.SendAlarmMsg(fmt.Sprint("更新研选专栏失败ourceId: ", sourceId), 2)
  223. }
  224. }()
  225. var source = utils.CYGX_OBJ_YANXUANSPECIAL
  226. var condition string
  227. var pars []interface{}
  228. condition = ` AND status = 3 AND id = ? `
  229. pars = append(pars, sourceId)
  230. total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
  231. if e != nil {
  232. err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
  233. return
  234. }
  235. //如果取消发布了就做删除处理
  236. if total == 0 {
  237. e = models.DeleteResourceData(sourceId, source)
  238. if e != nil {
  239. err = errors.New("DeleteResourceData, Err: " + e.Error())
  240. return
  241. }
  242. } else {
  243. //判断是否存在,如果不存在就新增,存在就更新
  244. totalData, e := models.GetCygxResourceDataBySourceAndIdCount(sourceId, source)
  245. if e != nil {
  246. err = errors.New("GetCygxReportSelectionBySourceAndId, Err: " + e.Error())
  247. return
  248. }
  249. detail, e := models.GetYanxuanSpecialBySpecialId(sourceId)
  250. if e != nil {
  251. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  252. return
  253. }
  254. publishDate := time.Now().Format(utils.FormatDateTime)
  255. item := new(models.CygxResourceData)
  256. item.SourceId = sourceId
  257. item.Source = source
  258. item.PublishDate = publishDate
  259. item.CreateTime = time.Now()
  260. item.SearchTitle = detail.Title
  261. item.SearchContent = ""
  262. item.SearchOrderTime = publishDate
  263. item.ChartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN //专栏属于研选行业
  264. if totalData == 0 {
  265. _, e := models.AddCygxResourceData(item)
  266. if e != nil {
  267. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  268. return
  269. }
  270. } else {
  271. e = models.UpdateResourceDataByItem(item)
  272. if e != nil {
  273. err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
  274. return
  275. }
  276. }
  277. }
  278. return
  279. }
  280. // 获取研选专栏用户信息
  281. func GetYanxuanSpecialAuthorInfo(user *models.WxUserItem) (itemResp *models.SpecialAuthorCheckResp) {
  282. var err error
  283. defer func() {
  284. if err != nil {
  285. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetYanxuanSpecialAuthorInfo Err ", err, "userId", user.UserId), 2)
  286. }
  287. }()
  288. itemResp = new(models.SpecialAuthorCheckResp)
  289. var condition string
  290. condition += ` AND a.status = 1 `
  291. specialUser, e := models.GetYanxuanSpecialAuthor(user.UserId, user.UserId, condition)
  292. if e != nil && e.Error() != utils.ErrNoRow() {
  293. err = errors.New("GetYanxuanSpecialAuthor, Err: " + e.Error())
  294. return
  295. }
  296. if specialUser != nil {
  297. itemResp.IsAuthor = true
  298. itemResp.SpecialColumnId = specialUser.Id
  299. itemResp.HeadImg = specialUser.HeadImg
  300. //如果昵称 、专栏名称、简介 都不为空就表示信息完善
  301. if specialUser.SpecialName != "" && specialUser.Introduction != "" && specialUser.NickName != "" {
  302. itemResp.IsImproveInformation = true
  303. }
  304. }
  305. return
  306. }
  307. // 获取专栏用户最新的一篇文章信息
  308. func GetBestNewYanxuanSpecialByUserId(userIds []int) (mapResp map[int]*models.CygxYanxuanSpecialCenterAuthorResp) {
  309. lenArr := len(userIds)
  310. if lenArr == 0 {
  311. return
  312. }
  313. var err error
  314. defer func() {
  315. if err != nil {
  316. fmt.Println(err)
  317. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetBestNewYanxuanSpecialByUserId Err ", err, "userIds", userIds), 2)
  318. }
  319. }()
  320. var condition string
  321. var pars []interface{}
  322. condition += ` AND user_id IN (` + utils.GetOrmInReplace(lenArr) + `) AND status = 3 GROUP BY user_id ORDER BY publish_time DESC`
  323. pars = append(pars, userIds)
  324. list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, lenArr)
  325. if e != nil && e.Error() != utils.ErrNoRow() {
  326. err = errors.New("GetYanxuanSpecialListBycondition, Err: " + e.Error())
  327. return
  328. }
  329. mapResp = make(map[int]*models.CygxYanxuanSpecialCenterAuthorResp, 0)
  330. for _, v := range list {
  331. item := new(models.CygxYanxuanSpecialCenterAuthorResp)
  332. item.UserId = v.UserId
  333. item.Id = v.Id
  334. item.Title = v.Title
  335. item.PublishTime = v.PublishTime
  336. mapResp[v.UserId] = item
  337. }
  338. return
  339. }
  340. // 研选专栏审批记录
  341. func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, status int, reason string) {
  342. var err error
  343. defer func() {
  344. if err != nil {
  345. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetYanxuanSpecialAuthorInfo Err ", err, "userId", user.UserId), 2)
  346. }
  347. }()
  348. detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
  349. if e != nil {
  350. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  351. return
  352. }
  353. specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
  354. if e != nil {
  355. err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
  356. return
  357. }
  358. item := new(models.CygxYanxuanSpecialApprovalLog)
  359. item.UserId = detail.UserId
  360. item.Content = detail.Content
  361. item.Tags = detail.Tags
  362. item.ApprovalStatus = status
  363. item.ImgUrl = detail.ImgUrl
  364. item.DocUrl = detail.DocUrl
  365. item.Reason = reason
  366. item.Title = detail.Title
  367. item.Type = detail.Type
  368. item.CompanyTags = detail.CompanyTags
  369. item.IndustryTags = detail.IndustryTags
  370. item.YanxuanSpecialId = specialId
  371. item.AdminName = user.RealName
  372. item.AdminUserId = user.UserId
  373. item.SpecialName = specialAuthor.SpecialName
  374. item.NickName = specialAuthor.NickName
  375. item.CreateTime = time.Now()
  376. item.ModifyTime = time.Now()
  377. e = models.AddCygxYanxuanSpecialApprovalLog(item)
  378. if e != nil {
  379. err = errors.New("AddCygxYanxuanSpecialApprovalLog, Err: " + e.Error())
  380. return
  381. }
  382. return
  383. }
  384. // 更新文章收藏数量
  385. func UdpateYanxuanSpecialCollect(specialId int) {
  386. var err error
  387. defer func() {
  388. if err != nil {
  389. fmt.Println(err)
  390. go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "specialId:", specialId), 2)
  391. }
  392. }()
  393. detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
  394. if e != nil {
  395. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  396. return
  397. }
  398. specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
  399. if e != nil {
  400. err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
  401. return
  402. }
  403. var condition string
  404. var pars []interface{}
  405. condition = " AND yanxuan_special_id = ? "
  406. pars = append(pars, specialId)
  407. //专栏被收藏的数量
  408. totalSpecial, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
  409. if e != nil {
  410. err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
  411. return
  412. }
  413. pars = make([]interface{}, 0)
  414. condition = " AND yanxuan_special_id IN (SELECT id FROM cygx_yanxuan_special AS a WHERE user_id = ?) "
  415. pars = append(pars, specialAuthor.UserId)
  416. //作者被收藏的数量
  417. totalAuthor, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
  418. if e != nil {
  419. err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
  420. return
  421. }
  422. //更新文章被收藏数量
  423. e = models.UpdateYanxuanSpecialarticleCollectNum(totalSpecial, specialId)
  424. if e != nil {
  425. err = errors.New("UpdateYanxuanSpecialarticleCollectNum, Err: " + e.Error())
  426. return
  427. }
  428. //更新作者文章被收藏数量
  429. e = models.UpdateYanxuanSpecialAuthorArticleCollectNum(totalAuthor, specialAuthor.UserId)
  430. if e != nil {
  431. err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNum, Err: " + e.Error())
  432. return
  433. }
  434. return
  435. }
  436. // 更新作者粉丝数量
  437. func UdpateYanxuanSpecialFansNum(specialUserIdId int) {
  438. var err error
  439. defer func() {
  440. if err != nil {
  441. fmt.Println(err)
  442. go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "specialUserIdId", specialUserIdId), 2)
  443. }
  444. }()
  445. var condition string
  446. var pars []interface{}
  447. condition = " AND follow_user_id = ? "
  448. pars = append(pars, specialUserIdId)
  449. //作者粉丝数量
  450. total, e := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
  451. if e != nil {
  452. err = errors.New("GetCygxYanxuanSpecialFollowCount, Err: " + e.Error())
  453. return
  454. }
  455. e = models.UpdateYanxuanSpecialAuthorFansNum(total, specialUserIdId)
  456. if e != nil {
  457. err = errors.New("UpdateYanxuanSpecialAuthorFansNum, Err: " + e.Error())
  458. return
  459. }
  460. return
  461. }
  462. // UdpateYanxuanSpecialauthorArticleNum 更新作者发布文章的数量
  463. func UdpateYanxuanSpecialauthorArticleNum(authoruserId int) {
  464. var err error
  465. defer func() {
  466. if err != nil {
  467. fmt.Println(err)
  468. go utils.SendAlarmMsg(fmt.Sprint("更新作者发布文章的数量失败,UdpateYanxuanSpecialauthorArticleNum Err ", err, "userId", authoruserId), 2)
  469. }
  470. }()
  471. var condition string
  472. var pars []interface{}
  473. condition = ` AND status = 3 AND user_id = ? `
  474. pars = append(pars, authoruserId)
  475. total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
  476. if e != nil {
  477. err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
  478. return
  479. }
  480. e = models.UdpateYanxuanSpecialauthorArticleNum(total, authoruserId)
  481. if e != nil {
  482. err = errors.New("UdpateYanxuanSpecialauthorArticleNum, Err: " + e.Error())
  483. return
  484. }
  485. return
  486. }
  487. // GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏
  488. func GetYanxuanSpecialCollectMap(userId int) (mapResp map[int]bool, err error) {
  489. defer func() {
  490. if err != nil {
  491. go utils.SendAlarmMsg("GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏失败 ErrMsg:"+err.Error(), 2)
  492. }
  493. }()
  494. list, e := models.GetCygxYanxuanSpecialCollectByUser(userId)
  495. if e != nil && e.Error() != utils.ErrNoRow() {
  496. err = errors.New("根据用户ID获取所有文章收藏,GetCygxYanxuanSpecialCollectByUser " + e.Error())
  497. return
  498. }
  499. mapResp = make(map[int]bool, 0)
  500. if len(list) > 0 {
  501. for _, v := range list {
  502. mapResp[v.YanxuanSpecialId] = true
  503. }
  504. }
  505. return
  506. }
  507. // GetYanxuanSpecialDetailUserPower 处理用户查看研选专栏详情的权限
  508. func GetYanxuanSpecialDetailUserPower(user *models.WxUserItem) (havePower bool, err error) {
  509. //研选专栏是否需要校验权限
  510. detailChart, e := models.GetConfigByCode("yanxuan_special_power_check")
  511. if e != nil {
  512. err = errors.New("GetConfigByCode, Err: " + e.Error())
  513. return
  514. }
  515. //如果没有开启校验,直接返回true
  516. if detailChart.ConfigValue == "0" {
  517. havePower = true
  518. return
  519. }
  520. userId := user.UserId
  521. companyId := user.CompanyId
  522. //判断用户是否开通了个人研选权限
  523. mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
  524. if mfyxUserPermissionTotal == 1 {
  525. havePower = true
  526. return
  527. }
  528. //是否是权益客户
  529. raiCount, e := company.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
  530. if e != nil {
  531. err = errors.New("GetCompanyProductCount, Err: " + e.Error())
  532. return
  533. }
  534. if raiCount == 0 {
  535. return
  536. }
  537. productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
  538. if e != nil {
  539. err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
  540. return
  541. }
  542. // 永续客户无法查看研选权限
  543. if productDetail.Status == utils.COMPANY_STATUS_FOREVER {
  544. return
  545. }
  546. permissionStr, e := models.GetCompanyPermission(companyId)
  547. if e != nil {
  548. err = errors.New("GetCompanyPermission, Err: " + e.Error())
  549. return
  550. }
  551. if strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
  552. havePower = true
  553. return
  554. }
  555. return
  556. }