123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037 |
- 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 = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
- } else if signupType == 4 {
- go services.ActivityUserRemind(user, activityInfo, 4)
- //resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
- } else {
- go services.ActivityUserRemind(user, activityInfo, 4)
- //resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>是否将活动日程加入您的系统日历,\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分钟会为您推送微信消息提醒<br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
- //resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
- }
- 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/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
- }
- 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 = "操作成功"
- }
|