config.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/utils"
  7. "html"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 是否展示限免标签
  13. func GetShowSustainable() (isShowSustainable bool) {
  14. total, err := models.GetShowSustainable()
  15. if err != nil {
  16. fmt.Println("GetShowSustainable Err:", err.Error())
  17. return
  18. }
  19. if total > 0 {
  20. isShowSustainable = true
  21. }
  22. return
  23. }
  24. func GetShowSustainableNew() (isShowSustainable bool, err error) {
  25. total, err := models.GetShowSustainable()
  26. if err != nil {
  27. fmt.Println("GetShowSustainable Err:", err.Error())
  28. return
  29. }
  30. if total > 0 {
  31. isShowSustainable = true
  32. }
  33. return
  34. }
  35. // 解析活动填写的报告链接
  36. func GetActivityReportLinkToArticleList(item *models.ActivityListResp) (items []*models.ActivityArticleResp, err error) {
  37. reportLink := item.ReportLink
  38. //处理活动的
  39. var articleIds []int
  40. var articleList []string
  41. if strings.Contains(reportLink, ";") {
  42. articleList = strings.Split(reportLink, ";")
  43. } else {
  44. articleList = strings.Split(reportLink, ";")
  45. }
  46. for _, v := range articleList {
  47. linkList := strings.Split(v, "/")
  48. if linkList[len(linkList)-1] != "" {
  49. linkArticleId, _ := strconv.Atoi(linkList[len(linkList)-1])
  50. articleIds = append(articleIds, linkArticleId)
  51. }
  52. }
  53. lenarticleIds := len(articleIds)
  54. if lenarticleIds == 0 {
  55. return
  56. }
  57. var condition string
  58. var pars []interface{}
  59. pars = make([]interface{}, 0)
  60. condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(lenarticleIds) + `)`
  61. pars = append(pars, articleIds)
  62. listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds))
  63. if e != nil {
  64. err = errors.New("GetResourceDataList, Err: " + e.Error())
  65. return
  66. }
  67. if len(listArticle) > 0 {
  68. for _, v := range listArticle {
  69. artItem := new(models.ActivityArticleResp)
  70. artItem.ArticleId = v.ArticleId
  71. artItem.Title = v.Title
  72. items = append(items, artItem)
  73. }
  74. }
  75. return
  76. }
  77. // 添加关于我们浏览记录
  78. func AddCygxAboutUsVideoHistory(user *models.WxUserItem) (err error) {
  79. defer func() {
  80. if err != nil {
  81. go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
  82. }
  83. }()
  84. historyRecord := new(models.CygxAboutUsVideoHistory)
  85. historyRecord.UserId = user.UserId
  86. historyRecord.CreateTime = time.Now()
  87. historyRecord.Mobile = user.Mobile
  88. historyRecord.Email = user.Email
  89. historyRecord.CompanyId = user.CompanyId
  90. historyRecord.CompanyName = user.CompanyName
  91. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  92. if err != nil && err.Error() != utils.ErrNoRow() {
  93. return
  94. }
  95. historyRecord.RealName = user.RealName
  96. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  97. if sellerItem != nil {
  98. historyRecord.SellerName = sellerItem.RealName
  99. }
  100. _, err = models.AddCygxAboutUsVideoHistory(historyRecord)
  101. return
  102. }
  103. // CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员
  104. func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool) {
  105. var err error
  106. defer func() {
  107. if err != nil {
  108. go utils.SendAlarmMsg(fmt.Sprint("CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员失败, mobile:", mobile, "ErrMsg", err.Error()), 2)
  109. }
  110. }()
  111. var configCode string
  112. //获取配置项里面审核人员的手机号
  113. configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
  114. cnf, e := models.GetConfigByCode(configCode)
  115. if e != nil {
  116. err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
  117. return
  118. }
  119. if strings.Contains(cnf.ConfigValue, mobile) {
  120. isApprovalPersonnel = true
  121. }
  122. return
  123. }
  124. // FICC研报获取免责声明
  125. func GetConfigCodeDisclaimer() (configValue string) {
  126. var err error
  127. defer func() {
  128. if err != nil {
  129. go utils.SendAlarmMsg(fmt.Sprint("GetConfigCodeDisclaimer 获取FICC研报获取免责声明 失败, ErrMsg", err.Error()), 2)
  130. }
  131. }()
  132. var configCode string
  133. //获取配置项里面审核人员的手机号
  134. configCode = "Disclaimer"
  135. cnf, e := models.GetConfigByCode(configCode)
  136. if e != nil {
  137. err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
  138. return
  139. }
  140. configValue = html.UnescapeString(cnf.ConfigValue)
  141. return
  142. }