package services import ( "errors" "hongze/hongze_web_mfyx/models" "hongze/hongze_web_mfyx/utils" "strconv" "time" ) func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) { if user.UserId == 0 { return } defer func() { if err != nil { go utils.SendAlarmMsg("tag点击信息记录失败"+err.Error()+"tagId"+strconv.Itoa(tagId)+"userId:"+strconv.Itoa(user.UserId), 2) } }() historyRecord := new(models.CygxTagHistory) historyRecord.UserId = user.UserId historyRecord.TagId = tagId historyRecord.CreateTime = time.Now() historyRecord.Mobile = user.Mobile historyRecord.Email = user.Email historyRecord.CompanyId = user.CompanyId historyRecord.CompanyName = user.CompanyName historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return } historyRecord.RealName = user.RealName if sellerItem != nil { historyRecord.SellerName = sellerItem.RealName } _, err = models.AddCygxTagHistory(historyRecord) return } //func init() { // conditionInit, err := GetConditionInitByTagIds("43") // fmt.Println(err) // fmt.Println() // fmt.Println(conditionInit) //} func GetConditionInitByTagIds(user *models.WxUserItem, labelKeyword string) (yanxuanActivityIdsResp, yanxuanArticleIdsResp []int, conditionresp string, err error) { var yanxuanActivityIds []int var yanxuanArticleIds []int var condition string var pars []interface{} switch labelKeyword { case utils.LABEL_L1_1: // 全部活动 yanxuanActivityIds = GetYanxuanActivityIds(user, "1,2") // 获取所有的研选活动ID case "买方交流": // 买方交流 ->买方线下交流 condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id = 8 AND active_state IN (1,2) ` pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN) list, e := models.GetCygxActivityIdList(condition, pars) if e != nil { err = errors.New("GetCygxActivityIdList, Err: " + e.Error()) return } for _, v := range list { yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId) } case "专家调研": // 专家调研->专家电话会+专家线下沙龙 condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id IN (1,5) AND active_state IN (1,2) ` pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN) list, e := models.GetCygxActivityIdList(condition, pars) if e != nil { err = errors.New("GetCygxActivityIdList, Err: " + e.Error()) return } for _, v := range list { yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId) } case "上市公司小范围": // 上市公司小范围->公司调研电话会 condition = ` AND chart_permission_id = ? AND yidong_activity_id = '' AND activity_type_id = 3 AND active_state IN (1,2) ` pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN) list, e := models.GetCygxActivityIdList(condition, pars) if e != nil { err = errors.New("GetCygxActivityIdList, Err: " + e.Error()) return } for _, v := range list { yanxuanActivityIds = append(yanxuanActivityIds, v.ActivityId) } case "全部报告": // 全部报告 yanxuanArticleIds = GetYanxuanArticleIds() //获取所有研选文章ID conditionresp = ` AND source IN ('article','yanxuanspecial') ` case "专栏": //专栏 conditionresp = ` AND source IN ('yanxuanspecial') ` case "纪要": //纪要 conditionresp = ` AND source IN ('article') ` //condition = ` AND article_type_id > 0 AND article_type_id != 12 ` condition = ` AND article_type_id > 0 ` list, e := models.GetCygxCygxArticleIdList(condition, pars) if e != nil { err = errors.New("GetCygxCygxArticleIdList, Err: " + e.Error()) return } for _, v := range list { yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId) } //case "买方沙龙": // 买方沙龙 // condition = ` AND article_type_id = 12 ` // list, e := models.GetCygxCygxArticleIdList(condition, pars) // if e != nil { // err = errors.New("GetCygxCygxArticleIdList, Err: " + e.Error()) // return // } // for _, v := range list { // yanxuanArticleIds = append(yanxuanArticleIds, v.ArticleId) // } } yanxuanActivityIdsResp = yanxuanActivityIds yanxuanArticleIdsResp = yanxuanArticleIds return }