config.go 3.5 KB

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