package controllers import ( "encoding/json" "fmt" "hongze/hongze_mfyx/models" "hongze/hongze_mfyx/models/order" "hongze/hongze_mfyx/services" "hongze/hongze_mfyx/utils" "strconv" "strings" "time" "github.com/medivhzhan/weapp/v2" "github.com/rdlucklib/rdluck_tools/paging" ) // 活动 type ActivityCoAntroller struct { BaseAuthController } type ActivityABaseController struct { BaseCommonController } type ActivityNoLoginController struct { BaseAuthMobileController } // @Title 活动类型列表 // @Description活动类型列表接口 // @Param IsResearch query bool true "是否为研选" // @Success 200 {object} models.ActivityTypeListResp // @router /activityTypelist [get] func (this *ActivityCoAntroller) List() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } resp := new(models.ActivityTypeListResp) isResearch, _ := this.GetBool("IsResearch", false) var condition string //是否仅展示研选下的活动类型 if isResearch { condition = " AND source_type IN (0,2) " } list, err := models.GetActivityTypeList(condition) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 我的日程 // @Description 我的日程列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Param Source query int false "来源 0:手机 ,1:Pc 默认0" // @Success 200 {object} models.GetCygxActivityListRep // @router /scheduleList [get] func (this *ActivityCoAntroller) ScheduleList() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" return } uid := user.UserId pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") source, _ := this.GetInt("Source") var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) var condition string var conditionCount string var pars []interface{} condition += ` AND art.publish_status = 1 AND chart_permission_id = 31 ` if source == 1 { condition += ` AND art.yidong_activity_id = '' ` conditionCount += ` AND art.yidong_activity_id = '' ` } total, err := models.GetScheduleCount(conditionCount+condition, uid) page := paging.GetPaging(currentIndex, pageSize, total) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } conditionCount = ` AND art.active_state = 2 AND chart_permission_id = 31 ` totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量 if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } var list []*models.ActivityDetail //全部都是进行中的活动 if totalCount > currentIndex*pageSize { condition += ` AND art.active_state IN(2) ` if source == 1 { condition += ` AND art.yidong_activity_id = '' ` } listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) list = listHave if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动 condition += ` AND art.publish_status = 1 AND art.active_state IN(2) ` if source == 1 { condition += ` AND art.yidong_activity_id = '' ` } listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) list = listHave if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } pageSize = pageSize - len(listHave) condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) AND chart_permission_id = 31` if source == 1 { condition += ` AND art.yidong_activity_id = '' ` } //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize) if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } if len(listOther) > 0 { for _, v := range listOther { list = append(list, v) } } } else { condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动 //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize) listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize) list = listOther if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } } var isShow bool isShow = services.GetShowSustainable() detail, err := models.GetConfigByCode("city_img_url") if err != nil { br.Msg = "获取数据失败" br.ErrMsg = "城市配置信息失败,Err:" + err.Error() return } detailChart, err := models.GetConfigByCode("chart_img_url") if err != nil { br.Msg = "获取数据失败" br.ErrMsg = "行业配置信息失败,Err:" + err.Error() return } addressList := strings.Split(detail.ConfigValue, "{|}") mapAddress := make(map[string]string) chartList := strings.Split(detailChart.ConfigValue, "{|}") mapChart := make(map[string]string) var cityName string var chartName string var imgUrl string var imgUrlChart string var mapActivityId []int for _, v := range addressList { vslice := strings.Split(v, "_") cityName = vslice[0] imgUrl = vslice[len(vslice)-1] mapAddress[cityName] = imgUrl } for _, v := range chartList { vslice := strings.Split(v, "_") chartName = vslice[0] imgUrlChart = vslice[len(vslice)-1] mapChart[chartName] = imgUrlChart } for k, v := range list { if strings.Contains(v.ActivityName, "【") { list[k].IsBrackets = 1 } if v.SignupNum > v.LimitPeopleNum { list[k].SignupNum = v.LimitPeopleNum } //是否展示限免标签 if isShow && strings.Contains(v.ChartPermissionName, "研选") { list[k].IsShowSustainable = true } if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 { //list[k].ActivityTypeName = "买方研选电话会" list[k].ImgUrlText = utils.YAN_XUAN_IMG } if v.ActivityType == 0 { if mapAddress[v.City] != "" { list[k].ImgUrl = mapAddress[v.City] } else { list[k].ImgUrl = mapAddress["其它"] } } else { if mapChart[v.ChartPermissionName] != "" { list[k].ImgUrl = mapChart[v.ChartPermissionName] } } expertTxt, _ := services.GetReportContentTextSub(v.Expert) list[k].Expert = expertTxt if v.IsHideAppointment == 0 { list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName) } if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID { list[k].IsCClassMeeting = true } mapActivityId = append(mapActivityId, v.ActivityId) } //添加我的日程访问记录 //item := new(models.CygxPageHistoryRecord) //item.UserId = user.UserId //item.CreateTime = time.Now() //item.Mobile = user.Mobile //item.Email = user.Email //item.CompanyId = user.CompanyId //item.CompanyName = user.CompanyName //item.PageType = "MySchedule" //go models.AddCygxPageHistoryRecord(item) resp := new(models.GetCygxActivityListRep) //处理音频回放 mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() return } //处理视频回放 mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error() return } //处理不同的报名方式按钮回显 mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } for k, v := range list { if mapActivityVoice[v.ActivityId] != nil { list[k].FileType = 1 list[k].AudioLink = true list[k].VoiceList = mapActivityVoice[v.ActivityId] } if mapActivityVideo[v.ActivityId] != nil { list[k].FileType = 2 list[k].AudioLink = true list[k].VideoDetail = mapActivityVideo[v.ActivityId] } v.SignupType = mapActivitySignup[v.ActivityId] //处理列表的标签是否展示逻辑 resp.List = append(resp.List, services.ActivityButtonShow(v)) } resp.Paging = page br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 活动详情 // @Description 获取活动详情接口 // @Param ActivityId query int true "活动ID" // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否" // @Param InviteShareCode query string false "销售账号邀请码" // @Success Ret=200 {object} models.CygxActivityResp // @router /detail [get] func (this *ActivityCoAntroller) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId activityId, _ := this.GetInt("ActivityId") isSendWx, _ := this.GetInt("IsSendWx") if activityId < 1 { br.Msg = "请输入活动ID" return } inviteShareCode := this.GetString("InviteShareCode") resp := new(models.CygxActivityResp) activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error() return } if activityInfo == nil { br.Msg = "活动不存在" br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId) return } if activityInfo.IsResearchPoints { //获取活动对用户要扣的点 userPointsNum, err := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取活动详情获取活动对用户要扣的点信息失败,Err:" + err.Error() return } if userPointsNum > 0 { activityInfo.IsResearchPointsByUser = true } } //记录分享来源 if inviteShareCode != "" { go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITY, activityInfo.ActivityName, inviteShareCode, activityId) } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId) if err != nil { br.Msg = "获取信息" br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error() return } activityInfo.SignupNum = signupCount havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial //处理活动关联的产业 industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } if activityInfo.TemporaryLabel != "" { industrialList = make([]*models.IndustrialManagementRep, 0) item := new(models.IndustrialManagementRep) item.IndustryName = activityInfo.Label industrialList = append(industrialList, item) } else { industryIds := make([]int, 0) var industrialManagementId string for k, v := range industrialList { if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN { industrialList[k].IsResearch = true } industryIds = append(industryIds, v.IndustrialManagementId) industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + "," } // 查研观向7.4-行业新标签 industryNewMap, e := services.GetIndustryNewLabelMap(industryIds) if e != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取产业新标签失败, Err: " + e.Error() return } //判断产业下是否有关联的报告,并处理是否跳转 industrialManagementId = strings.TrimRight(industrialManagementId, ",") if industrialManagementId != "" { var condition string condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)` condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) listIndustrialGrop, err := models.GetSearchResourceList(user.UserId, condition, 0, 0) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } mapIndustrial := make(map[int]int) if len(listIndustrialGrop) > 0 { for _, v := range listIndustrialGrop { mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId } } for k, v := range industrialList { if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch { industrialList[k].IsJump = true } //非买方研选下的才展示New标签 if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN { industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId] } } } } activityInfo.Listndustrial = industrialList var mapActivityId []int mapActivityId = append(mapActivityId, activityId) if havePower { //是否展示限免标签 if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { activityInfo.IsShowSustainable = true } resp.HasPermission = 1 configCode := "description_of_research" detail, err := models.GetConfigByCode(configCode) if err != nil { br.Msg = "获取数据失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } activityInfo.Description = detail.ConfigValue if activityInfo.SignupNum > activityInfo.LimitPeopleNum { activityInfo.SignupNum = activityInfo.LimitPeopleNum } if activityInfo.ChartPermissionNames != "" { activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames } if activityInfo.IsHideAppointment == 0 { activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName) } activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1) if activityInfo.YidongActivityId != "" { ydTgc, _ := services.GetYiDongCreateUserInfo(user) yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } //yidongKwy := activityInfo.YidongActivityUrl //activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc } //8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签 if activityInfo.ActivityTypeName != "专家电话会" { for _, rep := range activityInfo.Listndustrial { rep.IndustryNewLabel = false } } //8.5 买方研选的活动去掉限免标签 if strings.Contains(activityInfo.ChartPermissionName, "研选") { activityInfo.IsShowSustainable = false } //处理不同的报名方式按钮回显 mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } activityInfo.SignupType = mapActivitySignup[activityId] //处理活动关联的产业 industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } //判断是不是通过微信模版推送消息进来的 if isSendWx == 1 && len(industrialListNew) > 0 { industryUserFollowMap, err := services.GetIndustryUserFollowMap(user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error() return } for _, v := range industrialListNew { if industryUserFollowMap[v.IndustrialManagementId] { activityInfo.IsFollowButton = true } } activityInfo.IsShowFollowButton = true } if activityInfo.ReportLink != "" { artList, err := services.GetActivityReportLinkToArticleList(activityInfo) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink return } activityInfo.ArticleList = artList } else { activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0) } if services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" { activityInfo.IsShowSigninButton = true activityInfo.IsShowSignUpDetail = true } //处理按钮是否展示问题 resp.Detail = services.ActivityButtonShow(activityInfo) } else { //用户未登录(绑定登录信息)的时候也能展示 v12.2.1 if user.UserId == 0 { resp.HasPermission = 1 resp.Detail = services.ActivityButtonShow(activityInfo) } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败1,Err:" + err.Error() return } resp.Detail = services.ActivityButtonShow(activityInfo) resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile //if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑 // resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息 //} else { // resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息 // resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时 //} //for _, v := range resp.GoodsList { // resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息 //} resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮 resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录 resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片 } } //处理音频回放 mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId) return } if mapActivityVoice[activityId] != nil { activityInfo.FileType = 1 activityInfo.AudioLink = true activityInfo.VoiceList = mapActivityVoice[activityId] } //处理视频回放 mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error() return } if mapActivityVideo[activityId] != nil { activityInfo.FileType = 2 activityInfo.AudioLink = true activityInfo.VideoDetail = mapActivityVideo[activityId] } //已结束的活动,音视频作为商品的价格处理 if activityInfo.ActiveState == "3" { resp.GoodsList = services.GetGoodsInfoByActivityVivo(activityInfo) //音视频回放商品信息 resp.VivoPoints = services.GetActivityVivoPoints(activityInfo, user, havePower) //单场活动信息 if resp.VivoPoints.PointPermission == 2 || resp.VivoPoints.PointPermission == 3 { resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮 } resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, activityId) //截止支付时间倒计时 } else { if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑 resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息 } else { resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息 resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时 } } if len(resp.GoodsList) == 0 { resp.GoodsList = make([]*order.CygxGoodsResp, 0) } else { for _, v := range resp.GoodsList { resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息 } } collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId) return } collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId) return } if collectCount1+collectCount2 > 0 { resp.Detail.IsCollect = true } resp.Detail.IsResearchSpecial = resp.IsResearchSpecial br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 活动报名 // @Description 活动报名接口 // @Param request body models.ActivitySingnupRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /signup/add [post] func (this *ActivityCoAntroller) SignupAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId signupStatus := "" var req models.ActivitySingnupRep resp := new(models.SignupStatus) //var total int err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if user.Mobile == "" { user.Mobile = user.OutboundMobile } activityId := req.ActivityId signupType := req.SignupType hasPermission := 0 if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" { resp.GoBindEmail = true } activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error() return } // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会 if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 { signupType = 4 } //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"` //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"` var userType int userType, _, err = services.GetUserType(user.CompanyId) if err != nil { br.Msg = "获取信息失败!" br.ErrMsg = "获取失败,Err:" + err.Error() return } if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") { br.Msg = "您暂无查看该活动权限" br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业" return } item := new(models.CygxActivitySignup) // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 signupStatus = "Success" resp.HasPermission = hasPermission resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 if time.Now().After(resultTime.Add(-time.Minute * 60)) { signupStatus = "Overtime" resp.SignupType = signupType resp.SignupStatus = signupStatus resp.HasPermission = hasPermission resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理" br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } var sellerName string sellerName, err = models.GetCompanySellerName(user.CompanyId) if err != nil { br.Msg = "报名失败!" br.ErrMsg = "获取对应销售失败,Err:" + err.Error() return } popupMsg, err := services.CheckActivityUserAll(activityInfo, user) if err != nil { br.Msg = "报名失败!" br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error() return } if popupMsg != "" { br.Msg = popupMsg br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg) return } //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"` //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙) //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 { if activityInfo.IsLimitPeople == 1 { signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo) //判断优先级:总人数限制→单机构2人限制→爽约3次限制 totalRestrict, err := models.GetUserRestrictCount(user.Mobile) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取客户信息失败,Err:" + err.Error() return } totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } //解除报名限制之后二次报名相同活动 if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true { item.UserId = uid item.RealName = user.RealName item.SellerName = sellerName item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.SignupType = signupType item.FailType = 0 item.DoFailType = 0 _, errSignup := models.AddActivitySignupByRestrict(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } resp.HaqveJurisdiction = true resp.SignupType = signupType resp.SignupStatus = "Success" resp.HasPermission = hasPermission resp.ActivityId = activityId //total, err = models.GetUserMeetingReminderCount(user.UserId) //if err != nil { // br.Msg = "获取信息失败" // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error() // return //} //if total == 0 { // resp.GoFollow = true //} br.Ret = 200 br.Success = true br.Msg = "操作成功" br.Data = resp return } totalMy, err := models.GetActivitySignupByUserCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true { item.UserId = uid item.RealName = user.RealName item.SellerName = sellerName item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.SignupType = signupType item.DoFailType = item.FailType if user.OutboundMobile != "" { item.OutboundMobile = user.OutboundMobile if user.OutboundCountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.OutboundCountryCode } } else { item.OutboundMobile = user.Mobile if user.CountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.CountryCode } } //添加报名信息,但是不加入日程 _, errSignup := models.AddActivitySignupNoSchedule(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } } } totalMySuccess, err := models.GetActivitySignupCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if totalMySuccess > 0 { br.Msg = "您已报名这个活动" return } if signupStatus == "Success" && resp.GoBindEmail != true { item.UserId = uid item.RealName = user.RealName item.SellerName = sellerName item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.SignupType = signupType item.FailType = 0 item.DoFailType = 0 item.OutboundMobile = user.Mobile if user.OutboundMobile != "" { item.OutboundMobile = user.OutboundMobile if user.OutboundCountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.OutboundCountryCode } } else { item.OutboundMobile = user.Mobile if user.CountryCode == "" { item.CountryCode = "86" } else { item.CountryCode = user.CountryCode } } _, errSignup := models.AddActivitySignup(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } resp.HaqveJurisdiction = true //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名 if signupType == 1 { go services.ActivityUserRemind(user, activityInfo, 1) //resp.PopupMsg = "预约成功,已加入您的活动日程

想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" resp.PopupMsg = "预约成功,已加入您的活动日程

是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?" } else if signupType == 4 { go services.ActivityUserRemind(user, activityInfo, 4) //resp.PopupMsg = "报名成功,请复制腾讯会议号打开腾讯会议app参会
想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" resp.PopupMsg = "报名成功,请复制腾讯会议号打开腾讯会议app参会
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?" } else { go services.ActivityUserRemind(user, activityInfo, 4) //resp.PopupMsg = "报名成功,已加入您的活动日程
想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号" resp.PopupMsg = "报名成功,已加入您的活动日程
是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?" } // 如果是买方研选下的专家沙龙,同时推给内容组四人 if activityInfo.ActivityTypeId == 5 { go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo) go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo) } go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点 } } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情 } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } //公司线下调研活动客户报名后给建会人,所属销售推送模板信息 if signupStatus == "Success" { go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名") } if signupType == 1 && user.IsMsgOutboundMobile == 0 { resp.GoOutboundMobile = true if user.Mobile != "" || user.OutboundMobile != "" { go models.ModifyWxUserIsMsgOutboundMobile(user.UserId) } } if user.OutboundMobile == "" { resp.Mobile = user.Mobile if user.CountryCode == "" && len(user.Mobile) == 11 { resp.CountryCode = "86" } else { resp.CountryCode = user.CountryCode } } else { resp.Mobile = user.OutboundMobile resp.CountryCode = user.OutboundCountryCode } //如果用户有绑定手机号,但是没有绑定外呼手机号 if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" { var countryCode string if len(user.Mobile) == 8 { countryCode = "852" } else if len(user.Mobile) == 9 { countryCode = "886" } else if len(user.Mobile) == 10 { countryCode = "1" } else if len(user.Mobile) >= 11 { countryCode = "86" } models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid) } resp.SignupType = signupType resp.SignupStatus = signupStatus //resp.HasPermission = hasPermission //if signupStatus == "Success" { resp.ActivityId = activityId resp.ActivityTypeName = activityInfo.ActivityName resp.ActivityTime = activityInfo.ActivityTime resp.ActivityType = detailActivityType.ActivityType //} //去关注12.6小程序添加日历 去关注公众号强制取消关注 //total, err = models.GetUserSignupCount(user.UserId) //if err != nil { // br.Msg = "获取信息失败" // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error() // return //} //if total <= 1 { // resp.GoFollow = true //} br.Ret = 200 br.Success = true br.Msg = "操作成功" br.Data = resp } // @Title 活动取消报名 // @Description 活动取消报名接口 // @Param request body models.ActivitySingnupRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /signup/cancel [post] func (this *ActivityCoAntroller) SignupCancel() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId var req models.ActivitySingnupRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId signupType := req.SignupType item := new(models.CygxActivitySignup) activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo) if cancelDeadlineMsg != "" { br.Msg = cancelDeadlineMsg br.ErrMsg = cancelDeadlineMsg return } resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 if time.Now().After(resultTime.Add(-time.Minute * 60)) { if signupType == 1 { br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理" } else { br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理" } return } total, err := models.GetActivitySignupCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if total == 0 { br.Msg = "您暂未报名这个活动" return } item.UserId = uid item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName resp := new(models.SignupStatus) resp.ActivityId = activityId _, errSignup := models.CancelActivitySignup(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } // 如果是买方研选下的专家沙龙,同时推给内容组四人 if activityInfo.ActivityTypeId == 5 { go services.SendActivitieCancelSignTemplateMsg(user, activityInfo) go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo) } go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息 go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点 br.Ret = 200 br.Success = true br.Msg = "操作成功" br.Data = resp } // @Title 添加会议提醒 // @Description 添加会议提醒接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /meetingReminder/add [post] func (this *ActivityCoAntroller) MeetingReminderAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId //var signupStatus string signupStatus := "" var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"` item := new(models.CygxActivityMeetingReminder) resp := new(models.SignupStatus) hasPermission := 0 resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 if time.Now().After(resultTime.Add(-time.Minute * 15)) { br.Msg = "活动开始前15分钟无法设置会议提醒" return } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 signupStatus = "Success" //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId) if errMeeting != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errMeeting.Error() return } if totalMeeting > 0 { br.Msg = "您已预约,请勿重复预约" return } item.UserId = uid item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName resp.HasPermission = hasPermission _, errSignup := models.AddActivityMeetingReminder(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } resp.HaqveJurisdiction = true //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名 go services.ActivityUserRemind(user, activityInfo, 2) } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情 } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } resp.SignupStatus = signupStatus resp.ActivityId = activityId //var total int //total, err = models.GetUserActivityMeetingReminderCount(user.UserId) //if err != nil { // br.Msg = "获取信息失败" // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error() // return //} //if total <= 1 { // resp.GoFollow = true //} detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error() return } resp.ActivityTypeName = activityInfo.ActivityName resp.ActivityTime = activityInfo.ActivityTime resp.ActivityType = detailActivityType.ActivityType br.Ret = 200 br.Success = true if hasPermission == 1 { br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒" resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒

是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?" //resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒

请关注【查研观向小助手】公众号,以获取微信消息提醒" } br.Data = resp } // @Title 取消会议提醒 // @Description 取消会议提醒接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /meetingReminder/cancel [post] func (this *ActivityCoAntroller) MeetingReminderCancel() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId signupStatus := "Success" item := new(models.CygxActivityMeetingReminder) activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } //if signupStatus == "Success" { total, err := models.GetActivityMeetingReminderCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if total == 0 { br.Msg = "您暂未添加该活动会议提醒" return } resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 if time.Now().After(resultTime.Add(-time.Minute * 15)) { br.Msg = "活动开始前15分钟无法取消会议提醒" return } item.UserId = uid item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName _, errSignup := models.CancelActivityMeetingReminder(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } //} resp := new(models.SignupStatus) resp.SignupStatus = signupStatus resp.ActivityId = activityId br.Ret = 200 br.Success = true br.Msg = "会议提醒已取消" br.Data = resp } // @Title 活动带问 // @Description 新增活动带问接口 // @Param request body models.AddCygxActivityHelpAsk true "type json string" // @Success Ret=200 新增成功 // @router /askAdd [post] func (this *ActivityCoAntroller) AskAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } var req models.CygxActivityHelpAsk err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.Content == "" { br.Msg = "建议内容不可为空" return } content := req.Content itemToken, err := services.WxGetToken() if err != nil { br.Msg = "GetWxAccessToken Err:" + err.Error() return } if itemToken.AccessToken == "" { br.Msg = "accessToken is empty" return } commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content) if err != nil { br.Msg = "内容校验失败!" br.ErrMsg = "内容校验失败,Err:" + err.Error() return } if commerr.ErrCode != 0 { br.Msg = "内容违规,请重新提交!" br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 { // if time.Now().After(resultTime.Add(-time.Minute * 15)) { // br.Msg = "活动开始前15分钟内无法提交问题" // return // } //} else { // if time.Now().After(resultTime.Add(-time.Minute * 60)) { // br.Msg = "活动开始前1小时内无法提交问题" // return // } //} companyDetail, err := models.GetCompanyDetailById(user.CompanyId) if err != nil { br.Msg = "提交失败!" br.ErrMsg = "获取客户详情失败,Err:" + err.Error() return } if companyDetail == nil { br.Msg = "提交失败!" br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) return } item := new(models.CygxActivityHelpAsk) item.UserId = user.UserId item.ActivityId = req.ActivityId item.CompanyId = user.CompanyId item.CompanyName = companyDetail.CompanyName item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.Content = content msgId, err := models.AddActivityHelpAsk(item) if err != nil { br.Msg = "提交失败" br.ErrMsg = "提交带问失败,Err:" + err.Error() return } fmt.Println(msgId) var isSendMsg bool resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式 if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 { if time.Now().After(resultTime.Add(-time.Minute * 15)) { isSendMsg = true } } else { if time.Now().After(resultTime.Add(-time.Minute * 60)) { isSendMsg = true } } if isSendMsg { //获取销售信息 sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "提交失败" br.ErrMsg = "获取销售信息失败,Err:" + err.Error() return } // 给所属销售发送消息 if sellerItem != nil { go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId)) } } br.Ret = 200 br.Success = true br.Msg = "提交成功" } // @Title 校验活动带问是否有权限 // @Description 校验活动带问是否有权限接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /checkAsk [post] func (this *ActivityCoAntroller) CheckAsk() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var signupStatus string var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } resp := new(models.SignupStatus) hasPermission := 0 havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 signupStatus = "Success" //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } resp.HaqveJurisdiction = true resp.HasPermission = hasPermission resp.SignupStatus = signupStatus } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情 } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } resp.ActivityId = activityId br.Ret = 200 br.Success = true br.Data = resp } // @Title 预约纪要 // @Description 预约纪要接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.AppointmentResp // @router /appointment/add [post] func (this *ActivityCoAntroller) ActivityAppointmentAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId signupStatus := "Success" var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } //判断是否已经预约过 totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if totalAppointment > 0 { br.Msg = "您已预约!" return } //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"` item := new(models.CygxActivityAppointment) resp := new(models.SignupStatus) hasPermission := 0 havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial if havePower { hasPermission = 1 signupStatus = "Success" //限制人数为1人的专家电话会 用户操作时的消息提示 if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 { resp.HasPermission = hasPermission resp.SignupStatus = utils.FULLSTARFFED_MSG resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG br.Ret = 200 br.Success = true br.Msg = "" br.Data = resp return } totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId) if errMeeting != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errMeeting.Error() return } if totalMeeting > 0 { br.Msg = "您已预约,请勿重复预约" return } var sellerName string sellerName, err = models.GetCompanySellerName(user.CompanyId) if err != nil { br.Msg = "报名失败!" br.ErrMsg = "获取对应销售失败,Err:" + err.Error() return } item.UserId = uid item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.SellerName = sellerName item.RealName = user.RealName err = models.AddCygxActivityAppointment(item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } resp.HaqveJurisdiction = true //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名 go services.ActivityUserRemind(user, activityInfo, 3) resp.HasPermission = hasPermission resp.SignupStatus = signupStatus } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情 } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } resp.ActivityId = activityId //var total int //total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId) //if err != nil { // br.Msg = "获取信息失败" // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error() // return //} //if total <= 1 { // resp.GoFollow = true //} detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error() return } resp.ActivityTypeName = activityInfo.ActivityName resp.ActivityTime = activityInfo.ActivityTime resp.ActivityType = detailActivityType.ActivityType br.Ret = 200 br.Success = true if hasPermission == 1 { br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息" resp.PopupMsg = "会议纪要预约成功

请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息" } br.Data = resp } // @Title 取消预约纪要 // @Description 取消预约纪要接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /appointment/cancel [post] func (this *ActivityCoAntroller) ActivityAppointmentCancel() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } uid := user.UserId var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId signupStatus := "Success" item := new(models.CygxActivityAppointment) activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } if total == 0 { br.Msg = "您暂未预约该纪要" return } item.UserId = uid item.ActivityId = activityId item.CreateTime = time.Now() item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName _, errSignup := models.CancelcygxActivityAppointment(item) if errSignup != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errSignup.Error() return } resp := new(models.SignupStatus) resp.SignupStatus = signupStatus resp.ActivityId = activityId br.Ret = 200 br.Success = true br.Msg = "已取消" br.Data = resp } // @Title 活动报名之前的校验(权限、时间、点数、邮箱) // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.SignupStatus // @router /check [post] func (this *ActivityCoAntroller) Check() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } //if activityInfo.LimitPeopleNum > 0 { // signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId) // if err != nil { // br.Msg = "获取信息" // br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error() // return // } // if activityInfo.LimitPeopleNum <= signupCount { // br.Msg = "提示报名已满,留意下期活动的弹窗" // return // } //} //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。 resp := new(models.ActivityCheck) resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案 if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } hasPermission := 0 havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "校验用户权限失败,Err:" + err.Error() return } resp.IsResearchSpecial = isResearchSpecial activtyPayTotal := services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) if activtyPayTotal > 0 { resp.IsPayActivity = true } if havePower { hasPermission = 1 resp.CheckPermission = true resp.HasPermission = hasPermission } else { hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error() return } resp.PopupMsg = popupMsg resp.HasPermission = hasPermission resp.SellerName = sellerName resp.SellerMobile = sellerMobile } //if resp.CheckPermission { //如果权限通过了校验,那么就来校验时间 resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo) //} //if resp.CheckTime { // 如果时间通过校验就校验点数 resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "CheckActivityPoints,Err:" + err.Error() return } //如果通过点数的校验,就来校验邮箱 resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user) //} if !resp.CheckPoints { // //如果通过点数的校验,就来校验邮箱 // resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user) //} else { resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息 for _, v := range resp.GoodsList { resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息 } //activtyPayTotal = services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) // 如果是点数不够的人买了付费活动,取消报名,在报名,不弹付费按钮 if activtyPayTotal == 0 { resp.IsShowWxPay = utils.IS_SHOW_WX_PAY } resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录 } resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片 resp.CheckSiginUpNum, resp.PopupMsg, err = services.CheckActivityUserSiginUpNum(activityInfo) // 校验人数是否已满 if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "CheckActivityUserSiginUp,Err:" + err.Error() return } // 判断是否属于研选类型的活动 if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) { resp.IsResearch = true } br.Ret = 200 br.Success = true br.Data = resp } // @Title 查看音视频扣点接口 // @Description 查看音视频扣点接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} // @router /vivo_point_record [post] func (this *ActivityCoAntroller) VivoPointRecord() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req models.ActivityIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } activityId := req.ActivityId activityInfo, errInfo := models.GetAddActivityInfoById(activityId) if activityInfo == nil { br.Msg = "操作失败" br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId) return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } total, err := models.GetCygxActivityVivoPointRecordCount(activityId, user.UserId) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,获取历史记录信息失败Err:" + errInfo.Error() return } if total == 0 { vivoPointsSetDetail, err := models.GetCygxActivityVivoPointsSetByActivityId(activityId) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } item := new(models.CygxActivityVivoPointRecord) item.Source = vivoPointsSetDetail.Source item.SourceId = activityId item.UserId = user.UserId item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.RealName = user.RealName item.SellerName, _ = services.GetSellerName(user) // 销售姓名 item.CreateTime = time.Now() item.ModifyTime = time.Now() item.RegisterPlatform = utils.REGISTER_PLATFORM err = models.AddCygxActivityVivoPointRecord(item) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取信息失败,Err:" + err.Error() return } go services.YanXuanActivityVivoPointsBillSignupAdd(activityId, user.UserId) // 用户观看音视频研选扣点 } br.Ret = 200 br.Success = true br.Msg = "操作成功" }