cygx_yanxuan_special.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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. if totalData == 0 {
  264. _, e := models.AddCygxResourceData(item)
  265. if e != nil {
  266. err = errors.New("AddCygxResourceData, Err: " + e.Error())
  267. return
  268. }
  269. } else {
  270. e = models.UpdateResourceDataByItem(item)
  271. if e != nil {
  272. err = errors.New("UpdateResourceDataByItem, Err: " + e.Error())
  273. return
  274. }
  275. }
  276. }
  277. return
  278. }
  279. // 获取研选专栏用户信息
  280. func GetYanxuanSpecialAuthorInfo(user *models.WxUserItem) (itemResp *models.SpecialAuthorCheckResp) {
  281. var err error
  282. defer func() {
  283. if err != nil {
  284. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetYanxuanSpecialAuthorInfo Err ", err, "userId", user.UserId), 2)
  285. }
  286. }()
  287. itemResp = new(models.SpecialAuthorCheckResp)
  288. var condition string
  289. condition += ` AND a.status = 1 `
  290. specialUser, e := models.GetYanxuanSpecialAuthor(user.UserId, user.UserId, condition)
  291. if e != nil && e.Error() != utils.ErrNoRow() {
  292. err = errors.New("GetYanxuanSpecialAuthor, Err: " + e.Error())
  293. return
  294. }
  295. if specialUser != nil {
  296. itemResp.IsAuthor = true
  297. itemResp.SpecialColumnId = specialUser.Id
  298. itemResp.HeadImg = specialUser.HeadImg
  299. //如果昵称 、专栏名称、简介 都不为空就表示信息完善
  300. if specialUser.SpecialName != "" && specialUser.Introduction != "" && specialUser.NickName != "" {
  301. itemResp.IsImproveInformation = true
  302. }
  303. }
  304. return
  305. }
  306. // 获取专栏用户最新的一篇文章信息
  307. func GetBestNewYanxuanSpecialByUserId(userIds []int) (mapResp map[int]*models.CygxYanxuanSpecialCenterAuthorResp) {
  308. lenArr := len(userIds)
  309. if lenArr == 0 {
  310. return
  311. }
  312. var err error
  313. defer func() {
  314. if err != nil {
  315. fmt.Println(err)
  316. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetBestNewYanxuanSpecialByUserId Err ", err, "userIds", userIds), 2)
  317. }
  318. }()
  319. var condition string
  320. var pars []interface{}
  321. condition += ` AND user_id IN (` + utils.GetOrmInReplace(lenArr) + `) AND status = 3 GROUP BY user_id ORDER BY publish_time DESC`
  322. pars = append(pars, userIds)
  323. list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, lenArr)
  324. if e != nil && e.Error() != utils.ErrNoRow() {
  325. err = errors.New("GetYanxuanSpecialListBycondition, Err: " + e.Error())
  326. return
  327. }
  328. mapResp = make(map[int]*models.CygxYanxuanSpecialCenterAuthorResp, 0)
  329. for _, v := range list {
  330. item := new(models.CygxYanxuanSpecialCenterAuthorResp)
  331. item.UserId = v.UserId
  332. item.Id = v.Id
  333. item.Title = v.Title
  334. item.PublishTime = v.PublishTime
  335. mapResp[v.UserId] = item
  336. }
  337. return
  338. }
  339. // 研选专栏审批记录
  340. func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, status int, reason string) {
  341. var err error
  342. defer func() {
  343. if err != nil {
  344. go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetYanxuanSpecialAuthorInfo Err ", err, "userId", user.UserId), 2)
  345. }
  346. }()
  347. detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
  348. if e != nil {
  349. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  350. return
  351. }
  352. specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
  353. if e != nil {
  354. err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
  355. return
  356. }
  357. item := new(models.CygxYanxuanSpecialApprovalLog)
  358. item.UserId = detail.UserId
  359. item.Content = detail.Content
  360. item.Tags = detail.Tags
  361. item.ApprovalStatus = status
  362. item.ImgUrl = detail.ImgUrl
  363. item.DocUrl = detail.DocUrl
  364. item.Reason = reason
  365. item.Title = detail.Title
  366. item.Type = detail.Type
  367. item.CompanyTags = detail.CompanyTags
  368. item.IndustryTags = detail.IndustryTags
  369. item.YanxuanSpecialId = specialId
  370. item.AdminName = user.RealName
  371. item.AdminUserId = user.UserId
  372. item.SpecialName = specialAuthor.SpecialName
  373. item.NickName = specialAuthor.NickName
  374. item.CreateTime = time.Now()
  375. item.ModifyTime = time.Now()
  376. e = models.AddCygxYanxuanSpecialApprovalLog(item)
  377. if e != nil {
  378. err = errors.New("AddCygxYanxuanSpecialApprovalLog, Err: " + e.Error())
  379. return
  380. }
  381. return
  382. }
  383. // 更新文章收藏数量
  384. func UdpateYanxuanSpecialCollect(specialId int) {
  385. var err error
  386. defer func() {
  387. if err != nil {
  388. fmt.Println(err)
  389. go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "specialId:", specialId), 2)
  390. }
  391. }()
  392. detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
  393. if e != nil {
  394. err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
  395. return
  396. }
  397. specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
  398. if e != nil {
  399. err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
  400. return
  401. }
  402. var condition string
  403. var pars []interface{}
  404. condition = " AND yanxuan_special_id = ? "
  405. pars = append(pars, specialId)
  406. //专栏被收藏的数量
  407. totalSpecial, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
  408. if e != nil {
  409. err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
  410. return
  411. }
  412. pars = make([]interface{}, 0)
  413. condition = " AND yanxuan_special_id IN (SELECT id FROM cygx_yanxuan_special AS a WHERE user_id = ?) "
  414. pars = append(pars, specialAuthor.UserId)
  415. //作者被收藏的数量
  416. totalAuthor, e := models.GetCygxYanxuanSpecialCollectCount(condition, pars)
  417. if e != nil {
  418. err = errors.New("GetCygxYanxuanSpecialCollectCount, Err: " + e.Error())
  419. return
  420. }
  421. //更新文章被收藏数量
  422. e = models.UpdateYanxuanSpecialarticleCollectNum(totalSpecial, specialId)
  423. if e != nil {
  424. err = errors.New("UpdateYanxuanSpecialarticleCollectNum, Err: " + e.Error())
  425. return
  426. }
  427. //更新作者文章被收藏数量
  428. e = models.UpdateYanxuanSpecialAuthorArticleCollectNum(totalAuthor, specialAuthor.UserId)
  429. if e != nil {
  430. err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNum, Err: " + e.Error())
  431. return
  432. }
  433. return
  434. }
  435. // 更新作者粉丝数量
  436. func UdpateYanxuanSpecialFansNum(specialUserIdId int) {
  437. var err error
  438. defer func() {
  439. if err != nil {
  440. fmt.Println(err)
  441. go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "specialUserIdId", specialUserIdId), 2)
  442. }
  443. }()
  444. var condition string
  445. var pars []interface{}
  446. condition = " AND follow_user_id = ? "
  447. pars = append(pars, specialUserIdId)
  448. //作者粉丝数量
  449. total, e := models.GetCygxYanxuanSpecialFollowCount(condition, pars)
  450. if e != nil {
  451. err = errors.New("GetCygxYanxuanSpecialFollowCount, Err: " + e.Error())
  452. return
  453. }
  454. e = models.UpdateYanxuanSpecialAuthorFansNum(total, specialUserIdId)
  455. if e != nil {
  456. err = errors.New("UpdateYanxuanSpecialAuthorFansNum, Err: " + e.Error())
  457. return
  458. }
  459. return
  460. }
  461. // UdpateYanxuanSpecialauthorArticleNum 更新作者发布文章的数量
  462. func UdpateYanxuanSpecialauthorArticleNum(authoruserId int) {
  463. var err error
  464. defer func() {
  465. if err != nil {
  466. fmt.Println(err)
  467. go utils.SendAlarmMsg(fmt.Sprint("更新作者发布文章的数量失败,UdpateYanxuanSpecialauthorArticleNum Err ", err, "userId", authoruserId), 2)
  468. }
  469. }()
  470. var condition string
  471. var pars []interface{}
  472. condition = ` AND status = 3 AND user_id = ? `
  473. pars = append(pars, authoruserId)
  474. total, e := models.GetCygxYanxuanSpecialCount(condition, pars)
  475. if e != nil {
  476. err = errors.New("GetCygxYanxuanSpecialCount, Err: " + e.Error())
  477. return
  478. }
  479. e = models.UdpateYanxuanSpecialauthorArticleNum(total, authoruserId)
  480. if e != nil {
  481. err = errors.New("UdpateYanxuanSpecialauthorArticleNum, Err: " + e.Error())
  482. return
  483. }
  484. return
  485. }
  486. // GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏
  487. func GetYanxuanSpecialCollectMap(userId int) (mapResp map[int]bool, err error) {
  488. defer func() {
  489. if err != nil {
  490. go utils.SendAlarmMsg("GetYanxuanSpecialCollectMap 根据用户ID获取所有研选专栏的收藏失败 ErrMsg:"+err.Error(), 2)
  491. }
  492. }()
  493. list, e := models.GetCygxYanxuanSpecialCollectByUser(userId)
  494. if e != nil && e.Error() != utils.ErrNoRow() {
  495. err = errors.New("根据用户ID获取所有文章收藏,GetCygxYanxuanSpecialCollectByUser " + e.Error())
  496. return
  497. }
  498. mapResp = make(map[int]bool, 0)
  499. if len(list) > 0 {
  500. for _, v := range list {
  501. mapResp[v.YanxuanSpecialId] = true
  502. }
  503. }
  504. return
  505. }
  506. // GetYanxuanSpecialDetailUserPower 处理用户查看研选专栏详情的权限
  507. func GetYanxuanSpecialDetailUserPower(user *models.WxUserItem) (havePower bool, err error) {
  508. //研选专栏是否需要校验权限
  509. detailChart, e := models.GetConfigByCode("yanxuan_special_power_check")
  510. if e != nil {
  511. err = errors.New("GetConfigByCode, Err: " + e.Error())
  512. return
  513. }
  514. //如果没有开启校验,直接返回true
  515. if detailChart.ConfigValue == "0" {
  516. havePower = true
  517. return
  518. }
  519. userId := user.UserId
  520. companyId := user.CompanyId
  521. //判断用户是否开通了个人研选权限
  522. mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
  523. if mfyxUserPermissionTotal == 1 {
  524. havePower = true
  525. return
  526. }
  527. //是否是权益客户
  528. raiCount, e := company.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
  529. if e != nil {
  530. err = errors.New("GetCompanyProductCount, Err: " + e.Error())
  531. return
  532. }
  533. if raiCount == 0 {
  534. return
  535. }
  536. productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
  537. if e != nil {
  538. err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
  539. return
  540. }
  541. // 永续客户无法查看研选权限
  542. if productDetail.Status == utils.COMPANY_STATUS_FOREVER {
  543. return
  544. }
  545. permissionStr, e := models.GetCompanyPermission(companyId)
  546. if e != nil {
  547. err = errors.New("GetCompanyPermission, Err: " + e.Error())
  548. return
  549. }
  550. if strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
  551. havePower = true
  552. return
  553. }
  554. return
  555. }