12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/services"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- "time"
- )
- type ActivityController struct {
- BaseAuthController
- }
- type ActivityNoLoginController struct {
- BaseAuthMobileController
- }
- // @Title 活动类型列表
- // @Description 活动类型列表接口
- // @Param IsResearch query bool true "是否为研选"
- // @Success 200 {object} models.ActivityTypeListResp
- // @router /activityTypelist [get]
- func (this *ActivityNoLoginController) 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 ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
- // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
- // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
- // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
- // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
- // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
- // @Param IsResearch query bool true "是否为研选"
- // @Success 200 {object} models.ActivityTypeListHomeResp
- // @router /labelTypeList [get]
- func (this *ActivityNoLoginController) LabelTypeList() {
- 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
- }
- chartPermissionIds := this.GetString("ChartPermissionIds")
- isPower, _ := this.GetInt("IsPower")
- whichDay := this.GetString("WhichDay")
- activeState := this.GetString("ActiveState")
- isExternalLabel, _ := this.GetInt("IsExternalLabel") //
- isResearchPoints, _ := this.GetInt("IsResearchPoints") //
- isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
- var condition string
- var conditioninit string
- var pars []interface{}
- // 查研观向7.4-始终查询宏观的活动
- if chartPermissionIds != "" {
- chartPermissionIds += ",1"
- }
- //condition += `AND art.activity_time > ? `
- //pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
- if isResearch {
- chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
- } else {
- conditioninit += ` AND ( art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` OR ( art.is_show_hz = 1 AND art.chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `) )`
- conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
- }
- //行业名称
- if len(chartPermissionIds) > 0 {
- //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
- conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
- conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
- }
- //哪一天
- if whichDay != "" {
- var startDate string
- var endDate string
- if whichDay == "1" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "2" {
- startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "3" {
- startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5" {
- startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "1,2" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- } else if whichDay == "3,4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5,6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- }
- conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
- conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
- }
- //活动状态搜索
- if activeState != "" {
- // 默认查看未开始跟进行中
- if activeState == "1" {
- conditioninit += ` AND art.active_state IN (1,2)`
- } else {
- conditioninit += ` AND art.active_state IN (` + activeState + `)`
- }
- } else {
- conditioninit += ` AND art.active_state IN (1,2)`
- }
- //是否为外部资源
- if isExternalLabel == 1 {
- conditioninit += ` AND art.is_external_label = 1 `
- }
- if isResearchPoints == 1 {
- conditioninit += ` AND art.is_research_points = 1 `
- }
- conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
- //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- //condition += ` AND art.is_limit_people = 1 ` + conditionActivity
- condition += conditionActivity
- sortTime := ` mintimesort ASC `
- if activeState == "3" {
- sortTime = ` timesort DESC `
- }
- activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var conditionType string
- if isResearch {
- conditionType = " AND source_type IN (0,2) "
- } else {
- conditionType = " AND source_type IN (0,1) "
- }
- list, err := models.GetActivityTypeHomeList(conditionType)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- list, err = services.HandleActivityTypeHomeList(list, activityList, user)
- //专项产业调研未开始状态不查询
- if activeState == "1" {
- activeState = ""
- }
- conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
- speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if len(speciaItem.List) == 0 {
- speciaItem.List = make([]*models.CygxActivityLabelList, 0)
- }
- if speciaItem.ActivityTypeId > 0 {
- list = append(list, speciaItem)
- }
- resp := new(models.ActivityTypeListHomeResp)
- 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 Label query string false "搜索主题 多个用 , 隔开"
- // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
- // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
- // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
- // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
- // @Param Source query int false "来源 0手机 ,1Pc 默认0"
- // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
- // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
- // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
- // @Param ActivityId query int false "活动列表传过来的活动ID"
- // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
- // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
- // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
- // @Param IsResearch query bool false "是否为研选"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /list [get]
- func (this *ActivityNoLoginController) ActivityListNew() {
- 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")
- label := this.GetString("Label")
- chartPermissionIds := this.GetString("ChartPermissionIds")
- whichDay := this.GetString("WhichDay")
- //whichTime := this.GetString("WhichTime")
- activeState := this.GetString("ActiveState")
- activityTypeId := this.GetString("ActivityTypeId")
- keyWord := this.GetString("KeyWord")
- playBack, _ := this.GetInt("PlayBack")
- filter, _ := this.GetInt("Filter")
- isPower, _ := this.GetInt("IsPower")
- activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
- isExternalLabel, _ := this.GetInt("IsExternalLabel") //
- isResearchPoints, _ := this.GetInt("IsResearchPoints") //
- isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
- if activityTypeId == "5" {
- activityTypeId = "5,8" //专家线下沙龙可以查看买方线下交流
- }
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var conditioninit string //初始化搜索条件
- var pars []interface{}
- //主题
- if label != "" {
- conditioninit += ` AND art.label LIKE "%` + label + `%" `
- }
- //是否是研选
- if isResearch {
- chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
- } else {
- conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `' OR ( art.is_show_hz = 1 AND art.chart_permission_id = '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `') )`
- conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
- }
- //行业名称
- if len(chartPermissionIds) > 0 {
- //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
- conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
- conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
- }
- //哪一天
- if whichDay != "" {
- var startDate string
- var endDate string
- if whichDay == "1" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "2" {
- startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- endDate = startDate
- } else if whichDay == "3" {
- startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5" {
- startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
- } else if whichDay == "1,2" {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- } else if whichDay == "3,4" {
- startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
- endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
- } else if whichDay == "5,6" {
- startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
- endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
- } else {
- startDate = time.Now().Format(utils.FormatDate)
- endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
- }
- conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
- conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
- }
- //活动状态搜索
- if activeState != "" {
- // 默认查看未开始跟进行中
- if activeState == "1" {
- conditioninit += ` AND art.active_state IN (1,2)`
- } else {
- conditioninit += ` AND art.active_state IN (` + activeState + `)`
- }
- } else {
- conditioninit += ` AND art.active_state IN (1,2)`
- }
- // 如果是分析师电话会,那么可以连同C类一起查看
- if activityTypeId != "" {
- if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
- conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
- } else {
- conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)`
- }
- }
- //关键词搜索
- if keyWord != "" {
- conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
- }
- //回放
- if playBack == 1 {
- //获取所有带回放的活动ID
- playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
- }
- //音频视频 1:视频 2:音频
- if filter > 0 {
- videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
- }
- if isExternalLabel == 1 && isResearchPoints == 1 {
- conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
- } else {
- //是否为外部资源
- if isExternalLabel == 1 {
- conditioninit += ` AND art.is_external_label = 1 `
- }
- // 是否为研选扣点
- if isResearchPoints == 1 {
- conditioninit += ` AND art.is_research_points = 1 `
- }
- }
- condition = ""
- //活动可见限制
- conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- condition += ` AND art.publish_status = 1 ` + conditionActivity
- total, err := models.GetActivityCount(condition, playBack, pars, filter)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //return
- var conditionOrder string
- if activeState == "2" || activeState == "3" {
- conditionOrder = ` ORDER BY art.activity_time DESC `
- } else if activeState == "2,3" {
- conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
- } else {
- conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
- }
- if label != "" && activeState == "1" {
- conditionOrder = ` ORDER BY art.activity_time ASC `
- }
- //未开始进行中默认按照时间正序
- if activeState == "1" || activeState == "1,2" || activeState == "" {
- conditionOrder = ` ORDER BY art.top_time DESC , art.activity_time ASC `
- }
- condition += conditionOrder
- list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter, "")
- 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.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- list[k].IsCClassMeeting = true
- }
- mapActivityId = append(mapActivityId, v.ActivityId)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.GetCygxActivityListRep)
- var activityList []*models.ActivityListResp
- resp.Label = label
- if activityTypeId != "" && label == "" {
- activityTypeIdint, err := strconv.Atoi(activityTypeId)
- if err == nil {
- detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
- if errDetail != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
- return
- }
- resp.ImgUrl = detail.OnlineIco
- resp.Label = detail.ActivityTypeName
- }
- }
- //处理音频回放
- 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
- }
- //用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- for k, v := range list {
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
- au.HasPermission = 2
- }
- //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
- if v.YidongActivityId != "" {
- if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
- au.HasPermission = 1
- }
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- list[k].AuthInfo = au
- if mapActivityVoice[v.ActivityId] != nil {
- list[k].FileType = 1
- list[k].AudioLink = true
- if au.HasPermission == 1 {
- list[k].VoiceList = mapActivityVoice[v.ActivityId]
- }
- }
- if mapActivityVideo[v.ActivityId] != nil {
- list[k].FileType = 2
- list[k].AudioLink = true
- if au.HasPermission == 1 {
- list[k].VideoDetail = mapActivityVideo[v.ActivityId]
- }
- }
- //activityList = append(activityList, services.ActivityButtonShow(list[k], user, permissionArr))
- }
- activityList = services.ActivityArrButtonShow(list, user, permissionArr)
- //处理不同的报名方式按钮回显
- mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- for _, v := range activityList {
- v.SignupType = mapActivitySignup[v.ActivityId]
- }
- // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
- if label != "" {
- industry, e := models.GetIndustryByName(label)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
- return
- }
- if industry != nil {
- sourceIndustry, e := models.GetSourceIndustryByName(label)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
- return
- }
- if sourceIndustry != nil {
- resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
- resp.ChartPermissionId = sourceIndustry.ChartPermissionId
- resp.IsJump = true
- // 研选产业不跳资源包
- if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- resp.IsJump = false
- }
- }
- }
- // 新标签
- if activityId > 0 && activeState != "3" {
- activityIds := []int{activityId}
- activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
- return
- }
- resp.IndustryNewLabel = activityNewMap[activityId]
- }
- }
- //添加活动搜索记录
- //if keyWord != "" {
- // go services.AddActivitykeyWordSearch(keyWord, user)
- //}
- if len(activityList) == 0 {
- activityList = make([]*models.ActivityListResp, 0)
- }
- if activityTypeId == "3" || activityTypeId == "5" {
- resp.IsShowResearchPoints = true
- }
- //预处理返给前端的字段
- resp.List = activityList
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 活动详情
- // @Description 获取活动详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.CygxActivityResp
- // @router /detail [get]
- func (this *ActivityController) 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")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- 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 strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- activityInfo.IsResearch = true
- }
- if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
- activityInfo.IsCClassMeeting = 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
- detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
- detailResp, err = services.ActivityDetaailShow(detailResp)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
- return
- }
- if havePower {
- resp.HasPermission = 1
- //permissionArr := make([]string, 0)
- //处理活动关联的产业
- 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(condition)
- 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
- }
- if activityInfo.ActivityTypeId == 1 {
- industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
- }
- }
- }
- }
- //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
- // }
- // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
- //}
- if len(industrialList) > 0 {
- detailResp.Label = ""
- }
- detailResp.Listndustrial = industrialList
- //处理音频回放
- var mapActivityId []int
- mapActivityId = append(mapActivityId, activityId)
- if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN { // 研选的音视频不在查研展示
- 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 {
- detailResp.FileType = 1
- detailResp.AudioLink = true
- detailResp.VoiceDetail = mapActivityVoice[activityId]
- }
- //处理视频回放
- mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
- return
- }
- if mapActivityVideo[activityId] != nil {
- detailResp.FileType = 2
- detailResp.AudioLink = true
- detailResp.VideoDetail = mapActivityVideo[activityId]
- }
- }
- //处理不同的报名方式按钮回显
- mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- detailResp.SignupType = mapActivitySignup[activityId]
- detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
- resp.Detail = detailResp
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- detailResp.AuthInfo.HasPermission = resp.HasPermission
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = 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/add [post]
- func (this *ActivityController) 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
- }
- activityId := req.ActivityId
- signupType := req.SignupType
- email := req.Email
- //如果用户传了邮箱就绑定邮箱
- if email != "" && user.Email == "" {
- if !utils.ValidateEmailFormatat(req.Email) {
- br.Msg = "邮箱格式错误,请重新输入"
- br.ErrMsg = "邮箱格式错误,请重新输入"
- return
- }
- user.Email = req.Email
- err = models.UpdateUserEmail(email, uid)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "绑定客户邮箱失败!"
- }
- }
- 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
- }
- // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
- if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
- signupType = 4
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivitySignup)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- hasPermission = 1
- signupStatus = "Success"
- 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 = "报名失败!"
- 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/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- } else if signupType == 4 {
- go services.ActivityUserRemind(user, activityInfo, 4)
- resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- } else {
- go services.ActivityUserRemind(user, activityInfo, 4)
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- if activityInfo.IsZoom == 1 && activityInfo.IsLimitPeople > 0 {
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><b>届时请通过zoom会议链接或app自主入会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- }
- }
- if activityInfo.IsResearchPoints {
- resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
- }
- // 如果是买方研选下的专家沙龙,同时推给内容组四人
- if activityInfo.ActivityTypeId == 5 && activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo)
- go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo)
- }
- go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- 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)
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
- if signupStatus == "Success" {
- go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
- }
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- //resp.HasPermission = hasPermission
- //if signupStatus == "Success" {
- resp.ActivityId = activityId
- //}
- 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 *ActivityController) 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
- }
- //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
- //if !checkTime {
- // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
- // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
- // 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小时内无法取消报名,请联系对口销售处理"
- }
- br.ErrMsg = br.Msg
- 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
- _, 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 = "操作成功"
- }
- // @Title 添加会议提醒
- // @Description 添加会议提醒接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.SignupStatus
- // @router /meetingReminder/add [post]
- func (this *ActivityController) 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
- signupStatus := ""
- var req models.ActivitySingnupRep
- resp := new(models.SignupStatus)
- 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
- 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
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivityMeetingReminder)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- hasPermission = 1
- signupStatus = "Success"
- resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
- if time.Now().After(resultTime.Add(-time.Minute * 15)) {
- signupStatus = "Overtime"
- resp.SignupType = signupType
- resp.SignupStatus = signupStatus
- resp.HasPermission = hasPermission
- resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
- 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
- }
- 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
- _, errSignup := models.AddActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
- resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- 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/cancel [post]
- func (this *ActivityController) 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
- }
- total, err := models.GetActivityMeetingReminderCount(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.CancelActivityMeetingReminder(item)
- if errSignup != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errSignup.Error()
- return
- }
- resp := new(models.SignupStatus)
- resp.SignupStatus = signupStatus
- resp.HasPermission = 1
- 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.AppointmentResp
- // @router /appointment/add [post]
- func (this *ActivityController) 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
- var req models.ActivitySingnupRep
- resp := new(models.SignupStatus)
- 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
- 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
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- item := new(models.CygxActivityAppointment)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- resp.HasPermission = 1
- //限制人数为1人的专家电话会 用户操作时的消息提示
- if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
- 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.SignupStatus = "Success"
- //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
- //go services.ActivityUserRemind(user, activityInfo, 3)
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- 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 /appointment/cancel [post]
- func (this *ActivityController) 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
- resp.HasPermission = 1
- 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 *ActivityController) 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
- 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)
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- 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
- }
- resp.SignupStatus = "Success"
- resp.HasPermission = 1
- item := new(models.CygxActivityHelpAsk)
- item.RegisterPlatform = utils.REGISTER_PLATFORM
- 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
- }
- 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 {
- listEmail, err := models.GetAskEmail()
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交带问失败,Err:" + err.Error()
- return
- }
- var sendMobile string
- for _, v := range listEmail {
- if strings.Index(activityInfo.Host, v.Name) > 0 {
- sendMobile = v.Mobile
- }
- }
- if activityInfo.ChartPermissionId == 31 {
- sendMobile = utils.ActSendMsgMobile
- }
- //获取销售信息
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "提交失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- //给研究员发送消息
- if sendMobile != "" {
- openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
- if openIpItem != nil && openIpItem.OpenId != "" {
- if sellerItem != nil {
- //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
- services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
- }
- }
- }
- // 给所属销售发送消息
- if sellerItem != nil {
- openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
- if openIpItem != nil && openIpItem.OpenId != "" {
- //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
- services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
- }
- go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
- }
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- resp.IsResearch = true
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- br.Msg = "提交成功"
- }
- // @Title 视频详情
- // @Description 时间线接口
- // @Param VideoId query int true "视频ID"
- // @Success 200 {object} models.IndustryVideoDetailResp
- // @router /detailVideo [get]
- func (this *ActivityController) DetailVideo() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- videoId, _ := this.GetInt("VideoId")
- videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
- return
- }
- resp := new(models.ActivityVideoDetailResp)
- resp.VideoDetail = videoSimple
- resp.AuthInfo = au
- 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 KeyWord query string false "搜索关键词 多个用 , 隔开"
- // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /listSearch [get]
- func (this *ActivityController) ActivityListSearch() {
- 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
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- source, _ := this.GetInt("Source")
- keyWord := this.GetString("KeyWord")
- playBack, _ := this.GetInt("PlayBack")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- //活动可见限制
- conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- return
- }
- if source == 1 {
- condition += ` AND art.yidong_activity_id = '' `
- }
- //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
- //if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
- // return
- //}
- condition += ` AND art.publish_status = 1 ` + conditionActivity
- listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //return
- //用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.HomeResourceDataListResp)
- var list []*models.CygxResourceDataResp
- for _, v := range listActivity {
- var item = new(models.CygxResourceDataResp)
- //resp.List = append(resp.List, &models.CygxResourceDataResp{
- item.SourceId = v.ActivityId
- if v.SourceType == 1 {
- item.Source = "activity"
- } else {
- item.Source = "activityspecial"
- }
- item.Title = v.ActivityName
- item.City = v.City
- item.IsSignup = v.IsSignup
- item.SignupType = v.SignupType
- item.ActivityTypeId = v.ActivityTypeId
- item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
- item.IsAppointment = v.IsAppointment
- item.ActiveState = v.ActiveState
- item.ImgUrlText = v.ImgUrlText
- item.ImgUrl = v.ImgUrl
- item.ActivityType = v.ActivityType
- item.IsShowOutboundCall = v.IsShowOutboundCall
- item.IsShowMeetingReminder = v.IsShowMeetingReminder
- item.IsShowHelpSsk = v.IsShowHelpSsk
- item.IsShowSignup = v.IsShowSignup
- item.IsShowAppointment = v.IsShowAppointment
- item.IsShowDetails = v.IsShowDetails
- item.ActivityTimeText = v.ActivityTimeText
- item.Expert = v.Expert
- item.Speaker = v.Speaker
- item.DistinguishedGuest = v.DistinguishedGuest
- item.PublishDate = v.ActivityTime
- item.TripImgLink = v.TripImgLink
- item.TripStatus = 2
- item.ActiveState = v.ActiveState
- item.PublishDate = v.ActivityTime
- item.FileType = v.FileType
- item.IsYidongConduct = v.IsYidongConduct
- item.IsCanOutboundCall = v.IsCanOutboundCall
- item.IsLimitPeople = v.IsLimitPeople
- item.IsResearchPoints = v.IsResearchPoints
- item.SiginupDeadline = v.SiginupDeadline
- item.IsYidongActivity = v.IsYidongActivity
- // 判断是否属于研选类型的活动
- if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
- item.IsResearch = true
- if (v.ActivityTypeId == 3 || v.ActivityTypeId == 5) && v.YidongActivityId == "" && strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
- item.IsResearchSpecial = true
- }
- }
- if v.VoiceList != nil || v.VideoDetail != nil {
- item.AudioLink = true
- }
- if v.FileType == 1 {
- if v.VoiceList != nil {
- item.VoiceDetail = v.VoiceList
- }
- } else {
- if v.VideoDetail != nil {
- item.VideoDetail = v.VideoDetail
- }
- }
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
- au.HasPermission = 2
- }
- //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
- if v.YidongActivityId != "" {
- if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
- au.HasPermission = 1
- }
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgCallActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- }
- } else {
- if v.FileType == 1 {
- au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- }
- }
- item.AuthInfo = au
- list = append(list, item)
- }
- if len(list) == 0 {
- list = make([]*models.CygxResourceDataResp, 0)
- }
- //添加活动搜索记录
- //if keyWord != "" {
- //go services.AddActivitykeyWordSearch(keyWord, user)
- //}
- resp.Paging = page
- 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开始"
- // @Success 200 {object} models.GetCygxActivityListRep
- // @router /scheduleList [get]
- func (this *ActivityController) 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 `
- //if source == 1 {
- // condition += ` AND art.yidong_activity_id = '' `
- // conditionCount += ` AND art.yidong_activity_id = '' `
- //}
- total, err := models.GetScheduleCount(conditionCount, uid)
- specialtotal, err := models.GetSpecialScheduleCount(uid)
- page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- conditionCount = ` AND art.active_state = 2 `
- 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) `
- //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, utils.CHART_PERMISSION_NAME_YANXUAN) {
- list[k].IsResearch = true
- }
- if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
- //list[k].ActivityTypeName = "买方研选电话会"
- //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
- list[k].ImgUrlText = utils.YAN_XUAN_IMG
- }
- if v.ActivityType == 0 && v.SourceType == 1 {
- 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, user, make([]string, 0)))
- }
- resp.List = services.ActivityArrButtonShow(list, user, make([]string, 0))
- resp.Paging = page
- 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 *ActivityController) 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
- }
- //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
- 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
- if havePower {
- hasPermission = 1
- resp.CheckPermission = true
- resp.HasPermission = hasPermission
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- 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
- }
- }
- if resp.CheckPoints {
- //如果通过点数的校验,就来校验邮箱
- resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
- }
- // 判断是否属于研选类型的活动
- 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} models.AppointmentResp
- // @router /voiceHistory/add [post]
- func (this *ActivityController) ActivityVoiceHistoryAdd() {
- 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
- playSeconds := req.PlaySeconds
- 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
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxActivityVoiceHistory{
- ActivityId: activityId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxActivityVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateCygxActivityVoiceCounts(activityId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- go services.ActivityVideoUserRmind(user, activityId, 2)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 获取易董活动跳转地址详情
- // @Description 获取易董活动跳转地址详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.CygxActivityResp
- // @router /get_yidong_url [get]
- func (this *ActivityController) GetYidongUrl() {
- 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")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- resp := new(models.CygxYidongActivityUrlResp)
- activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
- return
- }
- havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
- return
- }
- resp.IsResearchSpecial = isResearchSpecial
- if havePower {
- resp.HasPermission = 1
- if activityInfo.YidongActivityId != "" {
- ydTgc, _ := services.GetYiDongCreateUserInfo(user)
- yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
- if yidongLongLink != "" {
- resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
- }
- }
- } else {
- hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- 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 /checkAsk [post]
- func (this *ActivityController) 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.GetUserHasPermission(user)
- //hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- popupMsg = "暂无查看权限"
- resp.PopupMsg = popupMsg
- resp.HasPermission = hasPermission
- resp.SellerName = sellerName
- resp.SellerMobile = sellerMobile
- }
- // 判断是否属于研选类型的活动
- 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
- }
|