package services import ( "errors" "fmt" "hongze/hongze_mfyx/models" "hongze/hongze_mfyx/utils" "strconv" "strings" "time" ) // 获取 用户类型 //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户;6、冻结客户;7、流失客户 func GetUserType(companyId int) (userType int, permissionStrnew string, err error) { var permissionStr, permissionZhengShiStr string if companyId <= 1 { userType = 0 } else { total, errs := models.GetCountCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } if total == 0 { userType = 0 } else { companyDetail, errs := models.GetCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } permissionStr, errs = models.GetCompanyPermission(companyId) if errs != nil { err = errs return } permissionStrnew = permissionStr //大套餐客户,数据库添加标识, companyUserTypeDetail, errs := models.GetCygxCompanyUserType(companyId) if errs != nil && errs.Error() != utils.ErrNoRow() { err = errs return } if companyUserTypeDetail != nil { if companyUserTypeDetail.CustomerTypeId != 0 { userType = companyUserTypeDetail.CustomerTypeId return } } permissionZhengShiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId) if errs != nil { err = errs return } //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户 //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if companyDetail.Status == "永续" { userType = 1 } else if companyDetail.Status == "试用" { userType = 5 } else if companyDetail.Status == "冻结" { userType = 6 } else if companyDetail.Status == "流失" { userType = 7 } //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if userType == 0 && companyDetail.Status == "正式" { var permissionZhegnshiNum int if strings.Count(permissionZhengShiStr, "医药") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "消费") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "科技") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "智造") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "策略") == 1 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "路演服务") == 1 { permissionZhegnshiNum++ } //if permissionZhegnshiNum == 6 { // userType = 2 //} else //大套餐客户,数据库添加标识,条件大于等于四的都是 30W套餐客户 if permissionZhegnshiNum >= 4 { userType = 10 } else { userType = 3 } } } } permissionStrnew = permissionStr return } func GetUserTypeZhengShi(companyId int) (userType int, permissionStrnew, permissionStrZhengShinew string, err error) { var permissionStr, permissionZhengShiStr string if companyId <= 1 { userType = 0 } else { total, errs := models.GetCountCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } if total == 0 { userType = 0 } else { companyDetail, errs := models.GetCompanyDetailByIdGroup(companyId) if errs != nil { err = errs return } permissionStr, errs = models.GetCompanyPermission(companyId) if errs != nil { err = errs return } permissionStrnew = permissionStr permissionZhengShiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId) if errs != nil { err = errs return } permissionStrZhengShinew = permissionZhengShiStr //大套餐客户,数据库添加标识, companyUserTypeDetail, errs := models.GetCygxCompanyUserType(companyId) if errs != nil && errs.Error() != utils.ErrNoRow() { err = errs return } if companyUserTypeDetail != nil { if companyUserTypeDetail.CustomerTypeId != 0 { userType = companyUserTypeDetail.CustomerTypeId return } } //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户 //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if companyDetail.Status == "永续" { userType = 1 } else if companyDetail.Status == "试用" { userType = 5 } else if companyDetail.Status == "冻结" { userType = 6 } else if companyDetail.Status == "流失" { userType = 7 } //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开) if userType == 0 && companyDetail.Status == "正式" { var permissionZhegnshiNum int if strings.Count(permissionZhengShiStr, "医药") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "消费") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "科技") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "智造") == 2 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "策略") == 1 { permissionZhegnshiNum++ } if strings.Count(permissionZhengShiStr, "路演服务") == 1 { permissionZhegnshiNum++ } //if permissionZhegnshiNum == 6 { // userType = 2 //} else //大套餐客户,数据库添加标识,条件大于等于四的都是 30W套餐客户 if permissionZhegnshiNum >= 4 { userType = 10 } else { userType = 3 } } } } permissionStrnew = permissionStr permissionStrZhengShinew = permissionZhengShiStr return } // GetSpecialDetailUserPower 处理用户查看详情的权限 func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower, isResearchSpecial bool, err error) { var companyDetailStatus string var userTypeStr string userId := user.UserId activityId := activityInfo.ActivityId activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动 //勾选【研选扣点】且扣点对象为参会人的活动,需要有买方研选的正式权限 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && activityPointsByUserAllMap[activityInfo.ActivityId] { isResearchSpecial = true } //如果是弘则的用户或者宏观的权限不做校验 //if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME { if GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID { havePower = true return } if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑 //用户是否持有有效卡片 userCardTotal := GetCygxOrderUserCardTotal(user.Mobile) if userCardTotal == 1 { havePower = true return } } else { activtyPayTotal := GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) if activtyPayTotal == 1 { havePower = true return } } userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId) if e != nil { err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error()) return } //判断用户是否开通了个人研选权限,如果有权限后缀拼接权限名称 //判断用户是否开通了个人研选权限,如果有权限后缀拼接权限名称 mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId) if mfyxUserPermissionTotal == 1 { permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN } //如果正式权限有开通 研选扣点包 ,那么就拼接一个 研选订阅的权限 if strings.Contains(permissionStrZhengShi, utils.YAN_XUAN_KOU_DIAN_BAO_NAME) { permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN permissionStrZhengShi += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN } //如果测试权限有开通 研选扣点包 ,那么就拼接一个 研选订阅的权限 if strings.Contains(permissionStr, utils.YAN_XUAN_KOU_DIAN_BAO_NAME) { permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN } //如果一个权限都没有就返回无权限 if permissionStr == "" { return } //永续客户,无法查看研选权限,但是下面的联系人,单独开通研选后,也可以查看研选内容 if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && mfyxUserPermissionTotal == 0 { havePower = false return } permissionStr += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限 if permissionStrZhengShi == "" { permissionStrZhengShi = utils.HONG_GUAN_NAME // 添加一个宏观权限 } else { permissionStrZhengShi += "," + utils.HONG_GUAN_NAME // 添加一个宏观权限 } //如果是易董的活动,主、副权限有一个满足即可 if activityInfo.YidongActivityId != "" { if strings.Contains(permissionStr, activityInfo.ChartPermissionName) || strings.Contains(permissionStr, activityInfo.ChartPermissionNameDeputy) { havePower = true return } } //如果权限不包含那么直接返回 if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) { return } //如果是 对用户的研选扣点的必须要有研选的正式权限 if activityInfo.IsResearchPoints { //获取活动对用户要扣的点 userPointsNum, e := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId) if e != nil { err = errors.New("GetActivitySignupSuccessByUserCountNoHz, Err: " + e.Error()) return } if userPointsNum > 0 { //if !strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_YANXUAN) { // //如果连试用权限都没有,那么久按照普通的研选样式展示 // isResearchSpecial = false //} if !strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) { havePower = false return } } } //处理决策人可见权限 if user.IsMaker == 0 && activityInfo.IsMakerShow == 1 { havePower = false return } // 处理本组可见权限 if activityInfo.VisibleRange == 1 { adminIds, e := models.GetSelleridWhichGroup(user.CompanyId, 2) if e != nil { err = errors.New("GetSelleridWhichGroup, Err: " + e.Error()) return } haveVisibleRange := false adminIdSlice := strings.Split(adminIds, ",") for _, v := range adminIdSlice { if v == strconv.Itoa(activityInfo.AdminId) { haveVisibleRange = true } } if !haveVisibleRange { havePower = false return } } if permissionStr == "" { return } //如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情 if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { havePower = true return } //医药消费,科技,智造四大行业,验证主客观。如果主客观校验不通过,那么直接返回 if strings.Contains(utils.YI_YAO_NAME+utils.XIAO_FEI_NAME+utils.KE_JI_NAME+utils.ZHI_ZAO_NAME, activityInfo.ChartPermissionName) { if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 { if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") { havePower = true } else { havePower = false } } else { if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") { havePower = true } else { havePower = false } } if !havePower { return } } if activityInfo.LimitPeopleNum > 0 { mapUserType, e := GetActivityCcustomerTypeList() if e != nil { err = e return } userTypeStr = mapUserType[userType] // 永续客户、大套餐客户、30W套餐客户可以查看行业升级套餐客户 权限 if userTypeStr == "1" || userTypeStr == "2" || userTypeStr == "AA" { if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) && strings.Contains(activityInfo.CustomerTypeIds, "8") { havePower = true //return } } } else { if strings.Contains(permissionStr, activityInfo.ChartPermissionName) { havePower = true return } } //判断管理规模是否满足 companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2) if e != nil { err = e return } if companyProduct != nil && activityInfo.Scale != "" { if strings.Contains(activityInfo.Scale, companyProduct.Scale) { havePower = true } } if user.CompanyId <= 1 { return } else { if permissionStr == "" { return } else { companyDetail, e := models.GetCompanyDetailById(user.CompanyId) if e != nil { err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error()) return } if companyDetail == nil { err = errors.New("客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)) return } companyDetailStatus = companyDetail.Status } } //宏观满足用户可见身份验证权限既满足 2023-9-18 if activityInfo.ChartPermissionId == 1 { if activityInfo.LimitPeopleNum > 0 { if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) { havePower = true return } } else { havePower = true return } } if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 { havePower = true } else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") { havePower = true } else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") { havePower = true } else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") { havePower = true } fmt.Println(permissionStrZhengShi) //if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) { // havePower = true // return //} if strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略" { if strings.Contains(activityInfo.CustomerTypeIds, "5") { if strings.Contains(permissionStr, activityInfo.ChartPermissionName) { havePower = true return } } else { if strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) { havePower = true return } } } permissionShengji, errs := models.GetCompanyPermissionByUserTrip(user.CompanyId) if errs != nil { err = errs return } //fmt.Println("主客观2", havePower) //if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) { // havePower = true //} //fmt.Println("主客观3", havePower) //处理升级权限以及用户身份的 双重判断 if activityInfo.CustomerTypeIds != "" { if !strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) && userTypeStr != "8" { havePower = false if strings.Contains(permissionShengji, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") { havePower = true } } } if havePower && activityInfo.LimitPeopleNum > 0 { //对于一些特殊的活动,即使权限满足也不给产看 noPower, e := GetShareNoPowe(activityInfo, permissionStr, userType, user) if e != nil { err = errors.New("GetShareNoPowe, Err: " + e.Error()) return } if noPower { havePower = false } } return } // 校验被分享的用户是否有查看详情的权限 func GetShareNoPowe(activityInfo *models.ActivityDetail, permissionStr string, userType int, user *models.WxUserItem) (noPower bool, err error) { //如果是弘则的就不进行可见权限校验 if user.CompanyId == utils.HZ_COMPANY_ID { return } //var noPower bool //if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) { // noPower = true //} //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户 //if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) { // noPower = true //} //if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) { // noPower = true //} //if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) { // noPower = true //} //if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) { // noPower = true //} fmt.Println(userType) if userType == 8 { permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId) if errs != nil { err = errs return } if !strings.Contains(permissionShengji, activityInfo.ChartPermissionName) { noPower = true return } } if !noPower { noPower, err = CheckUserPowerByActivityChoose(user, activityInfo) } return } // 处理活动本组们是否决策人权限 func CheckUserPowerByActivityChoose(user *models.WxUserItem, activityInfo *models.ActivityDetail) (noPower bool, err error) { //处理 见范围 1,仅本组可见 、2,全部客户可见 if activityInfo.VisibleRange == 1 { adminIds, errAdmin := models.GetSelleridWhichGroup(user.CompanyId, 2) if errAdmin != nil { err = errAdmin return } sliceAdminIds := strings.Split(adminIds, ",") var haveAdminId bool for _, v := range sliceAdminIds { if v == strconv.Itoa(activityInfo.AdminId) { haveAdminId = true } } if !haveAdminId { noPower = true } } //处理 是否仅决策人可见 0,否 、1,是 if activityInfo.IsMakerShow == 1 { if user.IsMaker == 0 { noPower = true } } return } // 根据用户身份处理活动可见 func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower int) (conditionActivity string, err error) { condition += " AND IF ( art.is_limit_people = 1 , art.customer_type_ids != '' ,1=1 ) " //未登录的用户也可以查看所有活动v12.2.1 if user.UserId == 0 { conditionActivity = ` AND art.publish_status = 1 AND art.yidong_activity_id = '' ` + condition return } // cygx_10.9 未绑定联系方式的客户可以看到部分活动 if user.UserId == 0 || user.CompanyId == 1 { conditionActivity = ` AND art.publish_status = 1 AND art.visible_range != 1 AND (art.is_limit_people = 0 OR (art.is_limit_people=1 AND art.is_all_customer_type=1)) ` + condition return } condition += ` AND art.publish_status = 1 ` conditionActivity = condition //弘则可以查看所有活动 if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || user.UserId == 0 { return } adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2) if err != nil { return } userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId) if err != nil { return } //判断客户规模是否属于可见范围的活动 companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return } isMaker := user.IsMaker slicePer := strings.Split(permissionStr, ",") var permissionSqlStr string var permissionNameStr string for _, v := range slicePer { if userType == 1 { //研选权限处理 if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) { permissionNameStr += "'" + v + "'," } } else { permissionNameStr += "'" + v + "'," } } permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1) permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1) permissionNameStr = strings.TrimRight(permissionNameStr, ",") slicePerZhengShi := strings.Split(permissionStrZhengShi, ",") var permissionNameStrZhengShi string for _, v := range slicePerZhengShi { if userType == 1 { //研选权限处理 if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) { permissionNameStrZhengShi += "'" + v + "'," } } else { permissionNameStrZhengShi += "'" + v + "'," } } permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(主观)", "", -1) permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(客观)", "", -1) permissionNameStrZhengShi = strings.TrimRight(permissionNameStrZhengShi, ",") mapUserType, e := GetActivityCcustomerTypeList() if e != nil { err = e return } var userTypeStr string userTypeStr = mapUserType[userType] // 查研观向7.4-始终查询宏观的权限(无论是否有权限) if permissionNameStr == `` { permissionNameStr = `'宏观'` } else { permissionNameStr += `, '宏观'` } var sqlExport string // 专家权限处理 sqlExport = ` AND (art.customer_type_ids LIKE '%` + userTypeStr + `%' ` if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") { sqlExport += ` OR art.customer_type_ids LIKE '%4%' ` } sqlExport += `) ` if isPower == 1 { //permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionNameStr + `)` //condition += permissionSqlStr } var conditionOr string //查询全部可见的数据(是否全部客户可见) if adminIds != "" { condition += ` AND ( art.visible_range != 1 OR ( art.admin_id IN ( ` + adminIds + ` ) AND art.visible_range = 1 )) ` } //活动仅决策人可见 if isMaker == 0 { condition += ` AND art.is_maker_show = 0 ` } //condition += ` AND art.visible_range != 1 ` if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") { conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) ` } if (userType == 5) && strings.Contains(permissionStr, "专家") { conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) ` } if userType == 1 { conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) ` } else { conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) ` } if userType == 6 || userType == 7 { conditionOr += ` OR ( art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' ` + condition + `) ` } if companyProduct != nil { if companyProduct.Scale != "" { conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) ` } } //if userType == 3 { // condition += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) ` //} condition += ` AND art.is_limit_people = 1 ` conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr return } // 活动标签字符串处理 func LabelStr(label string) (labelNew string) { slicebr := strings.Split(label, "-") if len(slicebr) < 2 { labelNew = label } else { labelNew = slicebr[1] } return labelNew } // 判断预约纪要按钮是否显示 func IsShowAppointment(activityTypeId int, chartPermissionName string) (isShowAppointment bool) { if activityTypeId == 1 || activityTypeId == 2 || activityTypeId == 3 || activityTypeId == 4 { isShowAppointment = true } if activityTypeId == 5 && chartPermissionName == "医药" { isShowAppointment = true } return } // 用户报告操作行为,模板消息推送 (先放在活动模块下,避免代码冲突) func ArticleUserRemind(user *models.WxUserItem, articleDetail *models.ArticleDetail, source int) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg(" 用户报告操作行为,模板消息推送失败"+fmt.Sprint("UserId:", user.UserId, "ArticleId:", articleDetail.ArticleId), 2) } }() countUser, err := models.GetUserRemind(user.UserId) if err != nil { return err } if countUser == 0 { return err } var sourceMsg string if source == 1 { sourceMsg = "阅读报告" } else { sourceMsg = "收藏报告" } //获取销售手机号 sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return err } if sellerItemQy != nil { articleId := articleDetail.ArticleId sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号 if e != nil { err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error()) return } sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",") openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles) if err != nil { err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error()) return err } var keyword1 string var keyword2 string keyword1 = articleDetail.Title keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName) SendWxMsgWithArticleUserRemind(keyword1, keyword2, openIdList, articleDetail.ArticleId) if articleDetail.ArticleTypeId > 0 { // 类目模版买方研选 openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles) if e != nil { err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error()) return err } var redirectUrl string keyword1 = utils.TruncateActivityNameString(user.RealName + "-" + user.CompanyName) keyword2 = fmt.Sprint("互动提醒:", sourceMsg) keyword3 := utils.TruncateActivityNameString(articleDetail.Title) keyword4 := time.Now().Format(utils.FormatDateTimeMinute2) redirectUrl = utils.WX_MSG_PATH_YX_ARTICLE_DETAIL + strconv.Itoa(articleId) SendWxCategoryMsgWithActivityUserRemind(keyword1, keyword2, keyword3, keyword4, redirectUrl, openIdListMfyx, articleId) } } return } // 用户活动操作行为,模板消息推送 func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.ActivityDetail, source int) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg(" 用户活动操作行为,模板消息推送失败"+fmt.Sprint("UserId:", user.UserId, "ActivityId:", activityDetail.ActivityId), 2) } }() //获取销售手机号 countUser, e := models.GetUserRemind(user.UserId) if e != nil { err = errors.New("GetUserRemind, Err: " + e.Error()) return } //获取销售手机号 sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error()) return } if sellerItemQy == nil { err = nil return } //某销售下的所有客户活动报名/预约外呼时,模板消息提醒该销售(可设置销售范围,随时增减销售) conf, e := models.GetConfigByCode("tpl_msg_seller_mobile") if e != nil { err = errors.New("GetConfigByCode, Err: " + e.Error()) return } //如果用户没有设置消息提醒,而且销售的手机号也没有添加到配置中,那么就不推送模版消息 if countUser == 0 && !strings.Contains(conf.ConfigValue, sellerItemQy.Mobile) { err = nil return } var sourceMsg string var redirectUrl string if source == 1 { sourceMsg = "预约外呼" } else if source == 2 { sourceMsg = "设置会议提醒" } else if source == 3 { sourceMsg = "预约纪要" } else if source == 4 { sourceMsg = "活动报名" } sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号 if e != nil { err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error()) return } sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",") openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles) if e != nil { err = errors.New("GetUserRecordListByMobile, Err: " + e.Error()) return err } var keyword1 string var keyword2 string keyword1 = activityDetail.ActivityName keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName) SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId) // 买方研选类目模版 openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles) keyword1 = utils.TruncateActivityNameString(user.RealName + "-" + user.CompanyName) keyword2 = fmt.Sprint("互动提醒:", sourceMsg) keyword3 := utils.TruncateActivityNameString(activityDetail.ActivityName) keyword4 := time.Now().Format(utils.FormatDateTimeMinute2) redirectUrl = utils.WX_MSG_PATH_YX_ACTIVITY_DETAIL + strconv.Itoa(activityDetail.ActivityId) SendWxCategoryMsgWithActivityUserRemind(keyword1, keyword2, keyword3, keyword4, redirectUrl, openIdListMfyx, activityDetail.ActivityId) return } func ActivityButtonShow(item *models.ActivityDetail) (activityDetail *models.ActivityDetail) { if item.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN { item.IsResearch = true } activityDetail = item //IsShowAppointment bool `description:"是否展示预约纪要"` //IsShowOutboundCall bool `description:"是否展示预约外呼"` //IsShowMeetingReminder bool `description:"是否展示会议提醒"` //IsShowHelpSsk bool `description:"是否展示帮我带问"` //IsShowSignup bool `description:"是否展示我要报名"` activityTypeIdMap := GetActivityTypeIdMap() activityDetail.ActivityType = activityTypeIdMap[activityDetail.ActivityTypeId] // 线上还是线下 activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动 activityDetail.IsResearchPoints = activityPointsByUserAllMap[activityDetail.ActivityId] if activityDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理 activityDetail.SiginupDeadline = "" } //如果报名截止时间不规范,或者是非研选扣点活动就把截止时间设置为空 if activityDetail.CancelDeadline == utils.FormatDateTimeInit || !activityDetail.IsResearchPoints { activityDetail.CancelDeadline = "" } activityTimeText := activityDetail.ActivityTimeText activityTimeText = strings.Replace(activityTimeText, "(", "(", -1) activityTimeText = strings.Replace(activityTimeText, ")", ")", -1) activityDetail.ActivityTimeText = activityTimeText if activityDetail.SourceType != 2 { activityDetail.SourceType = 1 } activityDetail.IsShowAppointment = false //易董的操作按钮都隐藏 if activityDetail.YidongActivityId != "" { activityDetail.SourceType = 1 activityDetail.IsShowSignup = false activityDetail.IsShowDetails = true activityDetail.IsExternalLabel = true activityDetail.IsResearch = false activityDetail.IsResearchSpecial = false return } //专家电话会 1 if activityDetail.ActivityTypeId == 1 && activityDetail.IsLimitPeople == 0 && (activityDetail.ActiveState == "1" || activityDetail.ActiveState == "2") { activityDetail.IsShowHelpSsk = true } //新的是否展示规则 if activityDetail.IsCanAppointmentMinutes == 1 { activityDetail.IsShowAppointment = true } else { activityDetail.IsShowAppointment = false } if activityDetail.ActiveState == "1" { //专家电话会 1 //专家电话会限制人数的展示我要报名,不限制的展示预约外外呼 if activityDetail.ActivityTypeId == 1 { //articleDetail.IsShowOutboundCall = true if activityDetail.LimitPeopleNum == 0 { activityDetail.IsShowOutboundCall = true //articleDetail.IsShowHelpSsk = true } else { activityDetail.IsShowSignup = true } activityDetail.IsShowMeetingReminder = true activityDetail.IsShowHelpSsk = true } //分析师电话会 2 if activityDetail.ActivityTypeId == 2 { if activityDetail.LimitPeopleNum == 0 { activityDetail.IsShowOutboundCall = true //articleDetail.IsShowHelpSsk = true } else { activityDetail.IsShowSignup = true } activityDetail.IsShowMeetingReminder = true } //公司调研电话会 3 if activityDetail.ActivityTypeId == 3 { if activityDetail.IsResearchPoints || activityDetail.LimitPeopleNum > 0 { activityDetail.IsShowSignup = true } else { activityDetail.IsShowMeetingReminder = true activityDetail.IsShowOutboundCall = true } } //公司线下调研 4 if activityDetail.ActivityTypeId == 4 { activityDetail.IsShowSignup = true } //专家线下沙龙 5 if activityDetail.ActivityTypeId == 5 { activityDetail.IsShowSignup = true } //分析师线下沙龙 6 if activityDetail.ActivityTypeId == 6 { activityDetail.IsShowSignup = true } //分析师电话会(C类) 7 if activityDetail.ActivityTypeId == 7 { activityDetail.IsShowSignup = true activityDetail.IsShowMeetingReminder = true activityDetail.ActivityTypeName = "分析师电话会" } //买方线下交流 8 // 查研观向 11.0 if activityDetail.ActivityTypeId == 8 { activityDetail.IsShowSignup = true } } //如果是易董创建的活动,展示我要报名,不展示预约外呼 if activityDetail.IsYidongConduct { activityDetail.IsShowSignup = true activityDetail.IsShowOutboundCall = false } if activityDetail.ActivityTypeName == "买方线下交流" { activityDetail.LabelKeyword = utils.LABEL_L1_2 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_1 } if activityDetail.ActivityTypeName == "专家电话会" || activityDetail.ActivityTypeName == "专家线下沙龙" { activityDetail.LabelKeyword = utils.LABEL_L1_3 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_2 } if activityDetail.ActivityTypeName == "公司调研电话会" { activityDetail.LabelKeyword = utils.LABEL_L1_4 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_3 } return } func ActivityArrButtonShow(items []*models.ActivityDetail) (activityDetails []*models.ActivityDetail) { activityPointsByUserAllMap := GetActivityPointsByUserAllMap() // 获取对用户进行研选扣点的活动 activityTypeIdMap := GetActivityTypeIdMap() for _, activityDetail := range items { activityDetail.ActivityType = activityTypeIdMap[activityDetail.ActivityTypeId] // 线上还是线下 if activityDetail.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN { activityDetail.IsResearch = true } //勾选【研选扣点】且扣点对象为参会人的活动,需要有买方研选的正式权限 if strings.Contains(activityDetail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && activityPointsByUserAllMap[activityDetail.ActivityId] { activityDetail.IsResearchSpecial = true } //IsShowAppointment bool `description:"是否展示预约纪要"` //IsShowOutboundCall bool `description:"是否展示预约外呼"` //IsShowMeetingReminder bool `description:"是否展示会议提醒"` //IsShowHelpSsk bool `description:"是否展示帮我带问"` //IsShowSignup bool `description:"是否展示我要报名"` activityDetail.IsResearchPoints = activityPointsByUserAllMap[activityDetail.ActivityId] if activityDetail.SiginupDeadline == utils.FormatDateTimeInit { //报名截止时间处理 activityDetail.SiginupDeadline = "" } //如果报名截止时间不规范,或者是非研选扣点活动就把截止时间设置为空 if activityDetail.CancelDeadline == utils.FormatDateTimeInit || !activityDetail.IsResearchPoints { activityDetail.CancelDeadline = "" } activityTimeText := activityDetail.ActivityTimeText activityTimeText = strings.Replace(activityTimeText, "(", "(", -1) activityTimeText = strings.Replace(activityTimeText, ")", ")", -1) activityDetail.ActivityTimeText = activityTimeText if activityDetail.SourceType != 2 { activityDetail.SourceType = 1 } activityDetail.IsShowAppointment = false //易董的操作按钮都隐藏 if activityDetail.YidongActivityId != "" { activityDetail.SourceType = 1 activityDetail.IsShowSignup = false activityDetail.IsShowDetails = true } else { //专家电话会 1 if activityDetail.ActivityTypeId == 1 && activityDetail.IsLimitPeople == 0 && (activityDetail.ActiveState == "1" || activityDetail.ActiveState == "2") { activityDetail.IsShowHelpSsk = true } //新的是否展示规则 if activityDetail.IsCanAppointmentMinutes == 1 { activityDetail.IsShowAppointment = true } else { activityDetail.IsShowAppointment = false } if activityDetail.ActiveState == "1" { //专家电话会 1 //专家电话会限制人数的展示我要报名,不限制的展示预约外外呼 if activityDetail.ActivityTypeId == 1 { //articleDetail.IsShowOutboundCall = true if activityDetail.LimitPeopleNum == 0 { activityDetail.IsShowOutboundCall = true //articleDetail.IsShowHelpSsk = true } else { activityDetail.IsShowSignup = true } activityDetail.IsShowMeetingReminder = true activityDetail.IsShowHelpSsk = true } //分析师电话会 2 if activityDetail.ActivityTypeId == 2 { if activityDetail.LimitPeopleNum == 0 { activityDetail.IsShowOutboundCall = true //articleDetail.IsShowHelpSsk = true } else { activityDetail.IsShowSignup = true } activityDetail.IsShowMeetingReminder = true } //公司调研电话会 3 if activityDetail.ActivityTypeId == 3 { if activityDetail.IsResearchPoints || activityDetail.LimitPeopleNum > 0 { activityDetail.IsShowSignup = true } else { activityDetail.IsShowMeetingReminder = true activityDetail.IsShowOutboundCall = true } } //公司线下调研 4 if activityDetail.ActivityTypeId == 4 { activityDetail.IsShowSignup = true } //专家线下沙龙 5 if activityDetail.ActivityTypeId == 5 { activityDetail.IsShowSignup = true } //分析师线下沙龙 6 if activityDetail.ActivityTypeId == 6 { activityDetail.IsShowSignup = true } //分析师电话会(C类) 7 if activityDetail.ActivityTypeId == 7 { activityDetail.IsShowSignup = true activityDetail.IsShowMeetingReminder = true activityDetail.ActivityTypeName = "分析师电话会" } //买方线下交流 8 // 查研观向 11.0 if activityDetail.ActivityTypeId == 8 { activityDetail.IsShowSignup = true } } //如果是易董创建的活动,展示我要报名,不展示预约外呼 if activityDetail.IsYidongConduct { activityDetail.IsShowSignup = true activityDetail.IsShowOutboundCall = false } } //如果是易董同步过来的,只展示外部资源标签 if activityDetail.YidongActivityId != "" { activityDetail.IsExternalLabel = true activityDetail.IsResearch = false activityDetail.IsResearchSpecial = false } if activityDetail.ActivityTypeName == "买方线下交流" { activityDetail.LabelKeyword = utils.LABEL_L1_2 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_1 } if activityDetail.ActivityTypeName == "专家电话会" || activityDetail.ActivityTypeName == "专家线下沙龙" { activityDetail.LabelKeyword = utils.LABEL_L1_3 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_2 } if activityDetail.ActivityTypeName == "公司调研电话会" { activityDetail.LabelKeyword = utils.LABEL_L1_4 activityDetail.LabelKeywordImgLink = utils.LABEL_ICO_3 } activityDetails = append(activityDetails, activityDetail) } return } // GetActivityNewLabelMap 获取活动【新】标签Map func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) { labelMap = make(map[int]bool, 0) industryNewMap = make(map[int]bool, 0) if len(activityIds) == 0 { return } // 获取活动关联的产业 var groupCond string var groupPars []interface{} groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 ` groupPars = append(groupPars, activityIds) groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars) if e != nil { err = errors.New("获取活动产业关联列表失败, Err: " + e.Error()) return } activityIndustryMap := make(map[int][]int, 0) industryIds := make([]int, 0) for i := range groups { industryIds = append(industryIds, groups[i].IndustrialManagementId) activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId) } // 获取新产业Map industryLabelMap, e := GetIndustryNewLabelMap(industryIds) if e != nil { err = errors.New("获取产业新标签Map失败, Err: " + e.Error()) return } // 判断活动是否为新 for k := range industryLabelMap { for k2, v2 := range activityIndustryMap { if labelMap[k2] { continue } // 活动的产业ID中存在一个新产业即为新活动 if utils.InArrayByInt(v2, k) { labelMap[k2] = true } } } ////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签 //articNewLabel, e := GetArticNewLabelWhithActivity3Month() //if e != nil { // err = errors.New("获取产业新标签Map失败, Err: " + e.Error()) // return //} //for k := range articNewLabel { // labelMap[k] = true //} return } // GetActivityVoiceResp 处理活动音频回放 func GetActivityVoiceResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVoiceReq, err error) { activityVoiceList, err := models.GetCygxActivityVoiceReqList(mapActivityId) if err != nil && err.Error() != utils.ErrNoRow() { return } mapActivityVoice := make(map[int]*models.CygxActivityVoiceReq) if len(activityVoiceList) > 0 { for _, v := range activityVoiceList { mapActivityVoice[v.ActivityId] = v } } mapItem = mapActivityVoice return } // GetActivityVideoResp 处理活动视频频回放 func GetActivityVideoResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVideoListResp, err error) { var condition string var ativityVIdstr string for _, v := range mapActivityId { ativityVIdstr += strconv.Itoa(v) + "," } if ativityVIdstr == "" { return } ativityVIdstr = strings.TrimRight(ativityVIdstr, ",") condition += ` AND art.activity_id IN (` + ativityVIdstr + `) ` var pars []interface{} //endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05") //condition += ` AND art.activity_time > ? ` //pars = append(pars, endTime) videoList, e := models.GetActivityVideoListAll(condition, pars, 0, 1000) if e != nil && e.Error() != utils.ErrNoRow() { err = e return } mapActivityVideo := make(map[int]*models.CygxActivityVideoListResp) if len(videoList) > 0 { for _, v := range videoList { mapActivityVideo[v.ActivityId] = v } } mapItem = mapActivityVideo return } // 解析活动填写的报告链接 func GetActivityReportLinkToArticleList(item *models.ActivityDetail) (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 GetActivityTypeIdMap() (mapResp map[int]int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg("获取活动线上还是线下的类型,失败,GetActivityTypeIdMap:Err "+err.Error(), 2) } }() list, e := models.GetActivityTypeList("") if e != nil { err = errors.New("GetActivityTypeList, Err: " + e.Error()) return } mapResp = make(map[int]int, 0) for _, v := range list { mapResp[v.ActivityTypeId] = v.ActivityType } return } // GetYanxuanActivityIds 获取研选活动ID func GetYanxuanActivityIds(user *models.WxUserItem, activeState string) (activityIds []int) { var err error defer func() { if err != nil { fmt.Println(err) go utils.SendAlarmMsg("获取研选活动ID GetYanxuanActivityIds,失败:"+err.Error(), 2) } }() var condition string var pars []interface{} condition = ` AND chart_permission_id = 31 AND art.publish_status = 1 ` if activeState != "" { condition += ` AND active_state IN (` + activeState + `) ` } //pars = append(pars, utils.CHART_PERMISSION_ID_YANXUAN) if user.CompanyId > 1 { conditionActivity, e := ActivityConditioninitSql(user, condition, 0) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("ActivityConditioninitSql, Err: " + e.Error()) return } condition += conditionActivity } condition += ` ORDER BY art.activity_time DESC , art.active_state ASC ` list, e := models.GetCygxActivityList(condition, pars, 0, 2000) if e != nil { err = errors.New("GetCygxActivityIdList, Err: " + e.Error()) return } for _, v := range list { activityIds = append(activityIds, v.ActivityId) } return } func ActivityVideoUserRmind(user *models.WxUserItem, activityId, fileType int) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg("用户音视频回放操作操作行为,模板消息推送失败"+err.Error(), 2) } }() countUser, err := models.GetUserRemind(user.UserId) if err != nil { return err } if countUser == 0 { return err } var first string var keyword1 string var keyword2 string var keyword3 string var keyword4 string var remark string //获取销售手机号 sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return err } if sellerItemQy != nil { openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile) if e != nil { err = errors.New("GetSellerByAdminId, Err: " + e.Error()) return } //TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"` if fileType == 1 { activityInfo, e := models.GetCygxActivityVideoByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error()) return } if activityInfo == nil { return } keyword1 = activityInfo.VideoName keyword2 = fmt.Sprint("互动:播放视频,", user.RealName, "--", user.CompanyName) first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放视频") } else { activityInfo, e := models.GetCygxActivityVoiceByActivityId(activityId) if e != nil { err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error()) return } if activityInfo == nil { return } keyword1 = activityInfo.VoiceName keyword2 = fmt.Sprint("互动:播放音频,", user.RealName, "--", user.CompanyName) first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放音频") } //keyword2 = "__" //remark = "点击查看活动详情" openIdArr := make([]string, 0) for _, v := range openIdList { openIdArr = append(openIdArr, v.OpenId) } redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId) sendInfo := new(SendWxTemplate) sendInfo.First = first sendInfo.Keyword1 = keyword1 sendInfo.Keyword2 = keyword2 sendInfo.Keyword3 = keyword3 sendInfo.Keyword4 = keyword4 sendInfo.Remark = remark sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind sendInfo.RedirectUrl = redirectUrl sendInfo.RedirectTarget = 3 sendInfo.Resource = strconv.Itoa(activityId) sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD sendInfo.OpenIdArr = openIdArr err = PublicSendTemplateMsg(sendInfo) if err != nil { return } } return }