package services import ( "errors" "fmt" "hongze/hongze_clpt/models" "hongze/hongze_clpt/utils" "html" "strconv" "strings" "time" ) // 是否展示限免标签 func GetShowSustainable() (isShowSustainable bool) { total, err := models.GetShowSustainable() if err != nil { fmt.Println("GetShowSustainable Err:", err.Error()) return } if total > 0 { isShowSustainable = true } return } func GetShowSustainableNew() (isShowSustainable bool, err error) { total, err := models.GetShowSustainable() if err != nil { fmt.Println("GetShowSustainable Err:", err.Error()) return } if total > 0 { isShowSustainable = true } return } // 解析活动填写的报告链接 func GetActivityReportLinkToArticleList(item *models.ActivityListResp) (items []*models.ActivityArticleResp, err error) { reportLink := item.ReportLink //处理活动的 var articleIds []int var articleList []string if strings.Contains(reportLink, ";") { articleList = strings.Split(reportLink, ";") } else { articleList = strings.Split(reportLink, ";") } for _, v := range articleList { linkList := strings.Split(v, "/") if linkList[len(linkList)-1] != "" { linkArticleId, _ := strconv.Atoi(linkList[len(linkList)-1]) articleIds = append(articleIds, linkArticleId) } } lenarticleIds := len(articleIds) if lenarticleIds == 0 { return } var condition string var pars []interface{} pars = make([]interface{}, 0) condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(lenarticleIds) + `)` pars = append(pars, articleIds) listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds)) if e != nil { err = errors.New("GetResourceDataList, Err: " + e.Error()) return } if len(listArticle) > 0 { for _, v := range listArticle { artItem := new(models.ActivityArticleResp) artItem.ArticleId = v.ArticleId artItem.Title = v.Title items = append(items, artItem) } } return } // 添加关于我们浏览记录 func AddCygxAboutUsVideoHistory(user *models.WxUserItem) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2) } }() historyRecord := new(models.CygxAboutUsVideoHistory) historyRecord.UserId = user.UserId historyRecord.CreateTime = time.Now() historyRecord.Mobile = user.Mobile historyRecord.Email = user.Email historyRecord.CompanyId = user.CompanyId historyRecord.CompanyName = user.CompanyName sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return } historyRecord.RealName = user.RealName historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM if sellerItem != nil { historyRecord.SellerName = sellerItem.RealName } _, err = models.AddCygxAboutUsVideoHistory(historyRecord) return } // CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员 func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool) { var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员失败, mobile:", mobile, "ErrMsg", err.Error()), 2) } }() var configCode string //获取配置项里面审核人员的手机号 configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL cnf, e := models.GetConfigByCode(configCode) if e != nil { err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode) return } if strings.Contains(cnf.ConfigValue, mobile) { isApprovalPersonnel = true } return } // FICC研报获取免责声明 func GetConfigCodeDisclaimer() (configValue string) { var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("GetConfigCodeDisclaimer 获取FICC研报获取免责声明 失败, ErrMsg", err.Error()), 2) } }() var configCode string //获取配置项里面审核人员的手机号 configCode = "Disclaimer" cnf, e := models.GetConfigByCode(configCode) if e != nil { err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode) return } configValue = html.UnescapeString(cnf.ConfigValue) return }