package services import ( "errors" "hongze/hongze_mfyx/models" "hongze/hongze_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("20,21,26") // fmt.Println(err) // fmt.Println() // fmt.Println(conditionInit) //} //const ( // LABEL_L1_1 string = "全部活动" // 全部活动 // LABEL_L1_2 string = "买方交流" // 买方交流 // LABEL_L1_3 string = "专家调研" // 专家调研 // LABEL_L1_4 string = "上市公司小范围" // 上市公司小范围 // LABEL_L2_1 string = "全部报告" // 全部报告 // LABEL_L2_2 string = "专栏" // 专栏 // LABEL_L2_3 string = "纪要" // 纪要 // LABEL_L2_4 string = "买方沙龙" // 买方沙龙 // LABEL_L3_1 string = "主题a" // 主题a // LABEL_L3_2 string = "主题b" // 主题b // LABEL_L3_3 string = "主题c" // 主题c //) 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 ` 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) // } } yanxuanActivityIdsPerssion := GetYanxuanActivityIds(user, "1,2") // 获取所有有权限的研选活动ID mapyanxuanActivityIds := make(map[int]bool) for _, v := range yanxuanActivityIdsPerssion { mapyanxuanActivityIds[v] = true } for _, v := range yanxuanActivityIds { if mapyanxuanActivityIds[v] { yanxuanActivityIdsResp = append(yanxuanActivityIdsResp, v) } } yanxuanArticleIdsResp = yanxuanArticleIds return }