activity.go 153 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/medivhzhan/weapp/v2"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "hongze/hongze_cygx/models"
  8. "hongze/hongze_cygx/services"
  9. "hongze/hongze_cygx/utils"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. //活动
  16. type ActivityCoAntroller struct {
  17. BaseAuthController
  18. }
  19. type ActivityABaseController struct {
  20. BaseCommonController
  21. }
  22. // @Title 活动类型列表
  23. // @Description活动类型列表接口
  24. // @Success 200 {object} models.ActivityTypeListResp
  25. // @router /activityTypelist [get]
  26. func (this *ActivityCoAntroller) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. resp := new(models.ActivityTypeListResp)
  40. list, err := models.GetActivityTypeList()
  41. if err != nil {
  42. br.Msg = "获取失败"
  43. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  44. return
  45. }
  46. resp.List = list
  47. br.Ret = 200
  48. br.Success = true
  49. br.Msg = "获取成功"
  50. br.Data = resp
  51. }
  52. // @Title 活动列表
  53. // @Description 获取活动列表接口
  54. // @Param PageSize query int true "每页数据条数"
  55. // @Param CurrentIndex query int true "当前页页码,从1开始"
  56. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  57. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  58. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  59. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  60. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  61. // @Param IsShowJurisdiction query int false "是否仅展示有权限的,1是,2否 默认为零"
  62. // @Param Label query string false "搜索主题 多个用 , 隔开"
  63. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  64. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  65. // @Success 200 {object} models.GetCygxActivityListRep
  66. // @router /list [get]
  67. func (this *ActivityCoAntroller) ActivityList() {
  68. br := new(models.BaseResponse).Init()
  69. defer func() {
  70. this.Data["json"] = br
  71. this.ServeJSON()
  72. }()
  73. user := this.User
  74. if user == nil {
  75. br.Msg = "请登录"
  76. br.ErrMsg = "请登录,SysUser Is Empty"
  77. return
  78. }
  79. uid := user.UserId
  80. pageSize, _ := this.GetInt("PageSize")
  81. currentIndex, _ := this.GetInt("CurrentIndex")
  82. chartPermissionIds := this.GetString("ChartPermissionIds")
  83. activityTypeIds := this.GetString("ActivityTypeIds")
  84. whichDay := this.GetString("WhichDay")
  85. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  86. keyWord := this.GetString("KeyWord")
  87. keyWordSearch := this.GetString("KeyWord")
  88. activeState := this.GetString("ActiveState")
  89. label := this.GetString("Label")
  90. playBack, _ := this.GetInt("PlayBack")
  91. //入参为 undefined 时的处理
  92. if chartPermissionIds == "undefined" {
  93. chartPermissionIds = ""
  94. }
  95. // 查研观向7.4-始终查询宏观的活动
  96. if chartPermissionIds != "" {
  97. chartPermissionIds += ",1"
  98. }
  99. if activityTypeIds == "undefined" {
  100. activityTypeIds = ""
  101. }
  102. if whichDay == "undefined" {
  103. whichDay = ""
  104. }
  105. if activeState == "undefined" {
  106. activeState = ""
  107. }
  108. if label == "undefined" {
  109. label = ""
  110. }
  111. //更新用户的搜索信息
  112. itemSearch := new(models.CygxActivityUserSearchContent)
  113. itemSearch.UserId = uid
  114. itemSearch.CreateTime = time.Now()
  115. itemSearch.Mobile = user.Mobile
  116. itemSearch.Email = user.Email
  117. itemSearch.CompanyId = user.CompanyId
  118. itemSearch.CompanyName = user.CompanyName
  119. itemSearch.ModifyTime = time.Now()
  120. itemSearch.ChartPermissionids = chartPermissionIds
  121. itemSearch.ActivityTypeids = activityTypeIds
  122. itemSearch.ActiveState = activeState
  123. itemSearch.IsShowJurisdiction = isShowJurisdiction
  124. //并发缓存校验
  125. cacheKey := fmt.Sprint("xygx:activity_user_search:add:", uid)
  126. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  127. _, errSearch := models.AddUserSearchContent(itemSearch, ttlTime)
  128. if errSearch != nil {
  129. br.Msg = "操作失败"
  130. br.ErrMsg = "操作失败,Err:" + errSearch.Error()
  131. return
  132. }
  133. utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
  134. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  135. if isShowJurisdiction == 1 && chartPermissionIds == "" && userType == 4 {
  136. activityTypeIds = "1,3"
  137. }
  138. var startSize int
  139. if pageSize <= 0 {
  140. pageSize = utils.PageSize20
  141. }
  142. if currentIndex <= 0 {
  143. currentIndex = 1
  144. }
  145. startSize = utils.StartIndex(currentIndex, pageSize)
  146. var condition string
  147. var pars []interface{}
  148. //活动可见限制
  149. var sqlExport string
  150. slicePer := strings.Split(permissionStr, ",")
  151. var permissionSqlStr string
  152. for _, v := range slicePer {
  153. if userType == 1 {
  154. //if v != "研选" {
  155. if !strings.Contains(v, "研选") {
  156. permissionSqlStr += "'" + v + "',"
  157. }
  158. } else {
  159. permissionSqlStr += "'" + v + "',"
  160. }
  161. }
  162. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  163. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  164. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  165. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  166. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  167. if userType == 2 {
  168. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  169. }
  170. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  171. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  172. }
  173. sqlExport += `) `
  174. if keyWord != "" {
  175. var mirrorword string
  176. var mirrorwordSql string
  177. slicemirrorword := strings.Split(keyWord, ",")
  178. for _, v := range slicemirrorword {
  179. mirrorwordSql += "'" + v + "'" + ","
  180. }
  181. mirrorwordSql = strings.TrimRight(mirrorwordSql, ",")
  182. total, err := models.GetActivityMirrorWordCount(mirrorwordSql)
  183. if err != nil {
  184. br.Msg = "获取失败"
  185. br.ErrMsg = "获取失败,Err:" + err.Error()
  186. return
  187. }
  188. if total > 0 {
  189. mirrorword, err = models.GetMirrorWord(mirrorwordSql)
  190. if err != nil {
  191. br.Msg = "获取信息失败"
  192. br.ErrMsg = "关系词映射获取失败,Err:" + err.Error()
  193. return
  194. }
  195. }
  196. keyWord = keyWord + "," + mirrorword
  197. slicekeyWord := strings.Split(keyWord, ",")
  198. var sqlKeyOr string
  199. if len(slicekeyWord) >= 2 {
  200. for _, v := range slicekeyWord {
  201. if v != "" {
  202. sqlKeyOr += ` OR art.activity_name LIKE '%` + v + `%' `
  203. }
  204. }
  205. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' ` + sqlKeyOr + ` )`
  206. } else {
  207. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' )`
  208. }
  209. }
  210. //主题
  211. if label != "" {
  212. sliceLabel := strings.Split(label, ",")
  213. var labelSqlStr string
  214. for _, v := range sliceLabel {
  215. labelSqlStr += "'" + v + "',"
  216. }
  217. labelSqlStr = strings.TrimRight(labelSqlStr, ",")
  218. condition = ` AND art.label IN (` + labelSqlStr + `)`
  219. }
  220. //行业名称
  221. if len(chartPermissionIds) > 0 {
  222. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  223. }
  224. if activityTypeIds != "" {
  225. condition += ` AND art.activity_type_id IN (` + activityTypeIds + `)`
  226. }
  227. if whichDay != "" {
  228. var startDate string
  229. var endDate string
  230. if whichDay == "1" {
  231. startDate = time.Now().Format(utils.FormatDate)
  232. endDate = startDate
  233. } else if whichDay == "2" {
  234. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  235. endDate = startDate
  236. } else {
  237. startDate = time.Now().Format(utils.FormatDate)
  238. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  239. }
  240. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  241. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  242. }
  243. if activeState != "" {
  244. condition += ` AND art.active_state IN (` + activeState + `)`
  245. }
  246. condition += ` AND art.publish_status = 1 `
  247. var conditionOr string
  248. // 有专家权限的这几种用户,不做行业权限校验
  249. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  250. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  251. }
  252. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  253. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  254. }
  255. if userType == 1 {
  256. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  257. } else {
  258. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  259. }
  260. //判断客户规模是否属于可见范围的活动
  261. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  262. if err != nil && err.Error() != utils.ErrNoRow() {
  263. br.Msg = "获取信息失败"
  264. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  265. return
  266. }
  267. if companyProduct != nil {
  268. if companyProduct.Scale != "" {
  269. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  270. }
  271. }
  272. condition += ` AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  273. total, err := models.GetActivityCount(condition, playBack, pars)
  274. if err != nil {
  275. br.Msg = "获取失败"
  276. br.ErrMsg = "获取失败,Err:" + err.Error()
  277. return
  278. }
  279. if activeState == "2" || activeState == "3" {
  280. condition += ` ORDER BY art.activity_time DESC `
  281. } else {
  282. condition += ` ORDER BY art.active_state ASC, art.activity_time ASC `
  283. }
  284. list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  285. if errList != nil {
  286. br.Msg = "获取失败"
  287. br.ErrMsg = "获取失败,Err:" + errList.Error()
  288. return
  289. }
  290. var isShow bool
  291. isShow = services.GetShowSustainable()
  292. detail, err := models.GetConfigByCode("city_img_url")
  293. if err != nil {
  294. br.Msg = "获取数据失败"
  295. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  296. return
  297. }
  298. detailChart, err := models.GetConfigByCode("chart_img_url")
  299. if err != nil {
  300. br.Msg = "获取数据失败"
  301. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  302. return
  303. }
  304. addressList := strings.Split(detail.ConfigValue, "{|}")
  305. mapAddress := make(map[string]string)
  306. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  307. mapChart := make(map[string]string)
  308. var cityName string
  309. var chartName string
  310. var imgUrl string
  311. var imgUrlChart string
  312. var mapActivityId []int
  313. for _, v := range addressList {
  314. vslice := strings.Split(v, "_")
  315. cityName = vslice[0]
  316. imgUrl = vslice[len(vslice)-1]
  317. mapAddress[cityName] = imgUrl
  318. }
  319. for _, v := range chartList {
  320. vslice := strings.Split(v, "_")
  321. chartName = vslice[0]
  322. imgUrlChart = vslice[len(vslice)-1]
  323. mapChart[chartName] = imgUrlChart
  324. }
  325. for k, v := range list {
  326. if strings.Contains(v.ActivityName, "【") {
  327. list[k].IsBrackets = 1
  328. }
  329. if v.SignupNum > v.LimitPeopleNum {
  330. list[k].SignupNum = v.LimitPeopleNum
  331. }
  332. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  333. list[k].IsShowSustainable = true
  334. }
  335. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  336. list[k].ActivityTypeName = "买方研选电话会"
  337. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  338. }
  339. if v.ActivityType == 0 {
  340. if mapAddress[v.City] != "" {
  341. list[k].ImgUrl = mapAddress[v.City]
  342. } else {
  343. list[k].ImgUrl = mapAddress["其它"]
  344. }
  345. } else {
  346. if mapChart[v.ChartPermissionName] != "" {
  347. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  348. }
  349. }
  350. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  351. list[k].Expert = expertTxt
  352. mapActivityId = append(mapActivityId, v.ActivityId)
  353. }
  354. if keyWordSearch != "" {
  355. keyWordItem := new(models.CygxUserSearchKeyWord)
  356. keyWordItem.UserId = user.UserId
  357. keyWordItem.KeyWord = keyWordSearch
  358. keyWordItem.PageType = "ActivitSearch"
  359. keyWordItem.CreateTime = time.Now()
  360. go models.AddUserSearchKeyWord(keyWordItem)
  361. cacheKey := fmt.Sprint("Search_uid:", user.UserId, "_KeyWord:", keyWordSearch, "_Source:", 6)
  362. isExist := utils.Rc.IsExist(cacheKey)
  363. if !isExist {
  364. setNX := utils.Rc.SetNX(cacheKey, keyWordSearch, time.Minute*1)
  365. if !setNX {
  366. go utils.SendAlarmMsg("记录用户搜索活动关键词失败,设置Redis Key 过期时间失败:key"+cacheKey, 3)
  367. }
  368. go services.AddUserSearchLog(user, keyWordSearch, 6)
  369. }
  370. }
  371. resp := new(models.GetCygxActivityListRep)
  372. //处理音频回放
  373. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  374. if err != nil {
  375. br.Msg = "获取信息失败"
  376. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  377. }
  378. fmt.Println(mapActivityId)
  379. fmt.Println(mapActivityVoice)
  380. //处理列表的标签是否展示逻辑
  381. for k, v := range list {
  382. if mapActivityVoice[v.ActivityId] != nil {
  383. list[k].AudioLink = true
  384. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  385. }
  386. resp.List = append(resp.List, services.ActivityButtonShow(v))
  387. }
  388. page := paging.GetPaging(currentIndex, pageSize, total)
  389. resp.List = list
  390. resp.Paging = page
  391. br.Ret = 200
  392. br.Success = true
  393. br.Msg = "获取成功"
  394. br.Data = resp
  395. }
  396. // @Title 我的日程
  397. // @Description 我的日程列表接口
  398. // @Param PageSize query int true "每页数据条数"
  399. // @Param CurrentIndex query int true "当前页页码,从1开始"
  400. // @Param Source query int false "来源 0:手机 ,1:Pc 默认0"
  401. // @Success 200 {object} models.GetCygxActivityListRep
  402. // @router /scheduleList [get]
  403. func (this *ActivityCoAntroller) ScheduleList() {
  404. br := new(models.BaseResponse).Init()
  405. defer func() {
  406. this.Data["json"] = br
  407. this.ServeJSON()
  408. }()
  409. user := this.User
  410. if user == nil {
  411. br.Msg = "请登录"
  412. br.ErrMsg = "请登录,SysUser Is Empty"
  413. return
  414. }
  415. uid := user.UserId
  416. pageSize, _ := this.GetInt("PageSize")
  417. currentIndex, _ := this.GetInt("CurrentIndex")
  418. source, _ := this.GetInt("Source")
  419. var startSize int
  420. if pageSize <= 0 {
  421. pageSize = utils.PageSize20
  422. }
  423. if currentIndex <= 0 {
  424. currentIndex = 1
  425. }
  426. startSize = utils.StartIndex(currentIndex, pageSize)
  427. var condition string
  428. var conditionCount string
  429. var pars []interface{}
  430. condition += ` AND art.publish_status = 1 `
  431. if source == 1 {
  432. condition += ` AND art.yidong_activity_id = '' `
  433. conditionCount += ` AND art.yidong_activity_id = '' `
  434. }
  435. total, err := models.GetScheduleCount(conditionCount, uid)
  436. page := paging.GetPaging(currentIndex, pageSize, total)
  437. if err != nil {
  438. br.Msg = "获取失败"
  439. br.ErrMsg = "获取失败,Err:" + err.Error()
  440. return
  441. }
  442. conditionCount = ` AND art.active_state = 2 `
  443. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  444. if err != nil {
  445. br.Msg = "获取失败"
  446. br.ErrMsg = "获取失败,Err:" + err.Error()
  447. return
  448. }
  449. var list []*models.ActivityDetail
  450. //全部都是进行中的活动
  451. if totalCount > currentIndex*pageSize {
  452. condition += ` AND art.active_state IN(2) `
  453. if source == 1 {
  454. condition += ` AND art.yidong_activity_id = '' `
  455. }
  456. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  457. list = listHave
  458. if errList != nil {
  459. br.Msg = "获取失败"
  460. br.ErrMsg = "获取失败,Err:" + errList.Error()
  461. return
  462. }
  463. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  464. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  465. if source == 1 {
  466. condition += ` AND art.yidong_activity_id = '' `
  467. }
  468. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  469. list = listHave
  470. if errList != nil {
  471. br.Msg = "获取失败"
  472. br.ErrMsg = "获取失败,Err:" + errList.Error()
  473. return
  474. }
  475. pageSize = pageSize - len(listHave)
  476. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  477. if source == 1 {
  478. condition += ` AND art.yidong_activity_id = '' `
  479. }
  480. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  481. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  482. if errList != nil {
  483. br.Msg = "获取失败"
  484. br.ErrMsg = "获取失败,Err:" + errList.Error()
  485. return
  486. }
  487. if len(listOther) > 0 {
  488. for _, v := range listOther {
  489. list = append(list, v)
  490. }
  491. }
  492. } else {
  493. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  494. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  495. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  496. list = listOther
  497. if errList != nil {
  498. br.Msg = "获取失败"
  499. br.ErrMsg = "获取失败,Err:" + errList.Error()
  500. return
  501. }
  502. }
  503. var isShow bool
  504. isShow = services.GetShowSustainable()
  505. detail, err := models.GetConfigByCode("city_img_url")
  506. if err != nil {
  507. br.Msg = "获取数据失败"
  508. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  509. return
  510. }
  511. detailChart, err := models.GetConfigByCode("chart_img_url")
  512. if err != nil {
  513. br.Msg = "获取数据失败"
  514. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  515. return
  516. }
  517. addressList := strings.Split(detail.ConfigValue, "{|}")
  518. mapAddress := make(map[string]string)
  519. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  520. mapChart := make(map[string]string)
  521. var cityName string
  522. var chartName string
  523. var imgUrl string
  524. var imgUrlChart string
  525. var mapActivityId []int
  526. for _, v := range addressList {
  527. vslice := strings.Split(v, "_")
  528. cityName = vslice[0]
  529. imgUrl = vslice[len(vslice)-1]
  530. mapAddress[cityName] = imgUrl
  531. }
  532. for _, v := range chartList {
  533. vslice := strings.Split(v, "_")
  534. chartName = vslice[0]
  535. imgUrlChart = vslice[len(vslice)-1]
  536. mapChart[chartName] = imgUrlChart
  537. }
  538. for k, v := range list {
  539. if strings.Contains(v.ActivityName, "【") {
  540. list[k].IsBrackets = 1
  541. }
  542. if v.SignupNum > v.LimitPeopleNum {
  543. list[k].SignupNum = v.LimitPeopleNum
  544. }
  545. //是否展示限免标签
  546. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  547. list[k].IsShowSustainable = true
  548. }
  549. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  550. list[k].ActivityTypeName = "买方研选电话会"
  551. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  552. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  553. }
  554. if v.ActivityType == 0 {
  555. if mapAddress[v.City] != "" {
  556. list[k].ImgUrl = mapAddress[v.City]
  557. } else {
  558. list[k].ImgUrl = mapAddress["其它"]
  559. }
  560. } else {
  561. if mapChart[v.ChartPermissionName] != "" {
  562. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  563. }
  564. }
  565. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  566. list[k].Expert = expertTxt
  567. if v.IsHideAppointment == 0 {
  568. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  569. }
  570. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  571. list[k].IsCClassMeeting = true
  572. }
  573. mapActivityId = append(mapActivityId, v.ActivityId)
  574. }
  575. //添加我的日程访问记录
  576. item := new(models.CygxPageHistoryRecord)
  577. item.UserId = user.UserId
  578. item.CreateTime = time.Now()
  579. item.Mobile = user.Mobile
  580. item.Email = user.Email
  581. item.CompanyId = user.CompanyId
  582. item.CompanyName = user.CompanyName
  583. item.PageType = "MySchedule"
  584. go models.AddCygxPageHistoryRecord(item)
  585. resp := new(models.GetCygxActivityListRep)
  586. //处理音频回放
  587. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  588. if err != nil {
  589. br.Msg = "获取信息失败"
  590. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  591. return
  592. }
  593. //处理视频回放
  594. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  595. if err != nil {
  596. br.Msg = "获取信息失败"
  597. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  598. return
  599. }
  600. for k, v := range list {
  601. if mapActivityVoice[v.ActivityId] != nil {
  602. list[k].FileType = 1
  603. list[k].AudioLink = true
  604. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  605. }
  606. if mapActivityVideo[v.ActivityId] != nil {
  607. list[k].FileType = 2
  608. list[k].AudioLink = true
  609. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  610. }
  611. //处理列表的标签是否展示逻辑
  612. resp.List = append(resp.List, services.ActivityButtonShow(v))
  613. }
  614. resp.Paging = page
  615. br.Ret = 200
  616. br.Success = true
  617. br.Msg = "获取成功"
  618. br.Data = resp
  619. }
  620. // @Title 活动详情
  621. // @Description 获取活动详情接口
  622. // @Param ActivityId query int true "活动ID"
  623. // @Success Ret=200 {object} models.CygxActivityResp
  624. // @router /detail [get]
  625. func (this *ActivityCoAntroller) Detail() {
  626. br := new(models.BaseResponse).Init()
  627. defer func() {
  628. this.Data["json"] = br
  629. this.ServeJSON()
  630. }()
  631. user := this.User
  632. if user == nil {
  633. br.Msg = "请登录"
  634. br.ErrMsg = "请登录,用户信息为空"
  635. br.Ret = 408
  636. return
  637. }
  638. uid := user.UserId
  639. activityId, _ := this.GetInt("ActivityId")
  640. if activityId < 1 {
  641. br.Msg = "请输入活动ID"
  642. return
  643. }
  644. resp := new(models.CygxActivityResp)
  645. hasPermission := 0
  646. var companyDetailStatus string
  647. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  648. if err != nil && err.Error() != utils.ErrNoRow() {
  649. br.Msg = "获取信息失败"
  650. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  651. return
  652. }
  653. if activityInfo == nil {
  654. br.Msg = "活动不存在"
  655. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  656. return
  657. }
  658. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  659. activityInfo.IsCClassMeeting = true
  660. }
  661. //处理冻结客户,流失客户的弹窗提示
  662. if user.CompanyId > 1 {
  663. sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
  664. if err != nil && err.Error() != utils.ErrNoRow() {
  665. br.Msg = "获取信息失败"
  666. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  667. return
  668. }
  669. if sellerMobile != "" {
  670. resp.HasPermission = 2
  671. resp.SellerMobile = sellerMobile
  672. resp.SellerName = sellerRealName
  673. br.Ret = 200
  674. br.Success = true
  675. br.Msg = "获取成功"
  676. br.Data = resp
  677. return
  678. }
  679. }
  680. applyCount, err := models.GetApplyRecordCount(uid)
  681. if err != nil && err.Error() != utils.ErrNoRow() {
  682. br.Msg = "获取信息失败"
  683. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  684. return
  685. }
  686. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  687. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  688. if err != nil && err.Error() != utils.ErrNoRow() {
  689. br.Msg = "获取信息失败"
  690. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  691. return
  692. }
  693. if user.CompanyId <= 1 {
  694. companyDetailStatus = ""
  695. } else {
  696. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  697. if err != nil {
  698. br.Msg = "获取信息失败"
  699. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  700. return
  701. }
  702. if companyPermission == "" {
  703. if applyCount > 0 {
  704. hasPermission = 4
  705. } else {
  706. if sellerItem != nil {
  707. hasPermission = 5
  708. } else {
  709. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  710. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  711. if err != nil && err.Error() != utils.ErrNoRow() {
  712. br.Msg = "获取信息失败"
  713. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  714. return
  715. }
  716. if sellerItemQy != nil {
  717. hasPermission = 2
  718. resp.SellerMobile = sellerItemQy.Mobile
  719. resp.SellerName = sellerItemQy.RealName
  720. } else {
  721. hasPermission = 3
  722. }
  723. }
  724. }
  725. resp.HasPermission = hasPermission
  726. resp.OperationMode = "Apply"
  727. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  728. br.Ret = 200
  729. br.Success = true
  730. br.Msg = "获取成功"
  731. br.Data = resp
  732. return
  733. }
  734. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  735. if err != nil {
  736. br.Msg = "获取信息失败!"
  737. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  738. return
  739. }
  740. if companyDetail == nil {
  741. br.Msg = "获取信息失败!"
  742. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  743. return
  744. }
  745. companyDetailStatus = companyDetail.Status
  746. }
  747. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  748. if err != nil {
  749. br.Msg = "获取信息失败"
  750. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  751. return
  752. }
  753. if activityInfo.IsLimitPeople > 0 {
  754. noPower, err := services.GetShareNoPowe(activityInfo, permissionStr, userType, user)
  755. if err != nil {
  756. br.Msg = "获取信息失败"
  757. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  758. return
  759. }
  760. //获取用户的产业规模,判断是否允许可见
  761. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  762. if err != nil && err.Error() != utils.ErrNoRow() {
  763. br.Msg = "获取信息失败"
  764. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  765. return
  766. }
  767. if companyProduct != nil {
  768. if companyProduct.Scale != "" {
  769. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  770. noPower = false
  771. }
  772. }
  773. }
  774. if noPower {
  775. br.Msg = "您暂无查看该活动权限"
  776. br.ErrMsg = "被分享客户不可见,获取信息失败"
  777. return
  778. }
  779. }
  780. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  781. br.Msg = "您暂无查看该活动权限"
  782. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  783. return
  784. }
  785. detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  786. if errDetail != nil {
  787. br.Msg = "获取信息失败"
  788. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  789. return
  790. }
  791. if activityInfo.IsSignup > 0 {
  792. detail, errDetail := models.GetActivitySignupDetail(activityId, uid)
  793. if errDetail != nil {
  794. br.Msg = "获取信息失败"
  795. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  796. return
  797. }
  798. activityInfo.SignupType = detail.SignupType
  799. }
  800. activityInfo.ShowType = detail.ShowType
  801. //判断是否已经申请过
  802. if user.CompanyId > 1 {
  803. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  804. if err != nil {
  805. br.Msg = "获取信息失败"
  806. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  807. return
  808. }
  809. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  810. //冻结客户
  811. if err != nil {
  812. if err.Error() == utils.ErrNoRow() {
  813. if applyCount > 0 {
  814. hasPermission = 4
  815. } else {
  816. if sellerItem != nil {
  817. hasPermission = 5
  818. } else {
  819. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  820. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  821. if err != nil && err.Error() != utils.ErrNoRow() {
  822. br.Msg = "获取信息失败"
  823. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  824. return
  825. }
  826. if sellerItemQy != nil {
  827. hasPermission = 2
  828. resp.SellerMobile = sellerItemQy.Mobile
  829. resp.SellerName = sellerItemQy.RealName
  830. } else {
  831. hasPermission = 3
  832. }
  833. }
  834. }
  835. resp.HasPermission = hasPermission
  836. resp.OperationMode = "Apply"
  837. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  838. br.Ret = 200
  839. br.Success = true
  840. br.Msg = "获取成功"
  841. br.Data = resp
  842. return
  843. } else {
  844. br.Msg = "获取信息失败"
  845. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  846. return
  847. }
  848. }
  849. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  850. if havePower {
  851. hasPermission = 1
  852. resp.HaqveJurisdiction = true
  853. } else {
  854. if permissionStr == "专家" {
  855. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  856. resp.MsgType = "Type"
  857. } else {
  858. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  859. resp.MsgType = "Industry"
  860. }
  861. if companyItem.ProductId == 2 {
  862. resp.SellerMobile = companyItem.Mobile
  863. resp.SellerName = companyItem.SellerName
  864. resp.OperationMode = "Call"
  865. hasPermission = 2
  866. } else {
  867. hasPermission = 5
  868. }
  869. }
  870. } else { //潜在客户
  871. if applyCount > 0 {
  872. hasPermission = 4
  873. } else {
  874. if sellerItem != nil {
  875. hasPermission = 5
  876. } else {
  877. hasPermission = 3
  878. }
  879. }
  880. resp.OperationMode = "Apply"
  881. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  882. }
  883. if hasPermission == 1 {
  884. //是否展示限免标签
  885. if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  886. activityInfo.IsShowSustainable = true
  887. }
  888. configCode := "description_of_research"
  889. detail, err := models.GetConfigByCode(configCode)
  890. if err != nil {
  891. br.Msg = "获取数据失败"
  892. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  893. return
  894. }
  895. activityInfo.Description = detail.ConfigValue
  896. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  897. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  898. }
  899. if activityInfo.ChartPermissionNames != "" {
  900. activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
  901. }
  902. if activityInfo.IsHideAppointment == 0 {
  903. activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
  904. }
  905. if activityInfo.ReportLink != "" {
  906. artList := strings.Split(activityInfo.ReportLink, "{|}")
  907. if len(artList) > 0 {
  908. for _, v := range artList {
  909. artitem := new(models.ActivityArticleResp)
  910. artitem.ReportLink = v
  911. artIdSlice := strings.Split(v, "/")
  912. if len(artIdSlice) > 0 {
  913. articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
  914. artitem.ArticleId = articleId
  915. }
  916. activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
  917. }
  918. }
  919. } else {
  920. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  921. }
  922. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  923. //处理活动关联的产业
  924. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  925. if err != nil && err.Error() != utils.ErrNoRow() {
  926. br.Msg = "获取信息失败"
  927. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  928. return
  929. }
  930. if activityInfo.TemporaryLabel != "" {
  931. industrialList = make([]*models.IndustrialManagementRep, 0)
  932. item := new(models.IndustrialManagementRep)
  933. item.IndustryName = activityInfo.Label
  934. industrialList = append(industrialList, item)
  935. } else {
  936. industryIds := make([]int, 0)
  937. var industrialManagementId string
  938. for k, v := range industrialList {
  939. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  940. industrialList[k].IsResearch = true
  941. }
  942. industryIds = append(industryIds, v.IndustrialManagementId)
  943. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  944. }
  945. // 查研观向7.4-行业新标签
  946. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  947. if e != nil {
  948. br.Msg = "获取信息失败"
  949. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  950. return
  951. }
  952. //判断产业下是否有关联的报告,并处理是否跳转
  953. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  954. if industrialManagementId != "" {
  955. var condition string
  956. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  957. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  958. listIndustrialGrop, err := models.GetSearchResourceList(condition, 0, 0)
  959. if err != nil && err.Error() != utils.ErrNoRow() {
  960. br.Msg = "获取信息失败"
  961. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  962. return
  963. }
  964. mapIndustrial := make(map[int]int)
  965. if len(listIndustrialGrop) > 0 {
  966. for _, v := range listIndustrialGrop {
  967. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  968. }
  969. }
  970. for k, v := range industrialList {
  971. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  972. industrialList[k].IsJump = true
  973. }
  974. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  975. }
  976. }
  977. }
  978. activityInfo.Listndustrial = industrialList
  979. if activityInfo.YidongActivityId != "" {
  980. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  981. yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  982. if err != nil {
  983. br.Msg = "获取信息失败"
  984. br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  985. return
  986. }
  987. //yidongKwy := activityInfo.YidongActivityUrl
  988. //activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
  989. activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  990. }
  991. //处理音频回放
  992. var mapActivityId []int
  993. mapActivityId = append(mapActivityId, activityId)
  994. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  995. if err != nil {
  996. br.Msg = "获取信息失败"
  997. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  998. return
  999. }
  1000. if mapActivityVoice[activityId] != nil {
  1001. activityInfo.FileType = 1
  1002. activityInfo.AudioLink = true
  1003. activityInfo.VoiceList = mapActivityVoice[activityId]
  1004. }
  1005. //处理视频回放
  1006. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  1007. if err != nil {
  1008. br.Msg = "获取信息失败"
  1009. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  1010. return
  1011. }
  1012. if mapActivityVideo[activityId] != nil {
  1013. activityInfo.FileType = 2
  1014. activityInfo.AudioLink = true
  1015. activityInfo.VideoDetail = mapActivityVideo[activityId]
  1016. }
  1017. //8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
  1018. if activityInfo.ActivityTypeName != "专家电话会" {
  1019. for _, rep := range activityInfo.Listndustrial {
  1020. rep.IndustryNewLabel = false
  1021. }
  1022. }
  1023. //8.5 买方研选的活动去掉限免标签
  1024. if strings.Contains(activityInfo.ChartPermissionName, "研选") {
  1025. activityInfo.IsShowSustainable = false
  1026. }
  1027. //处理按钮是否展示问题
  1028. resp.Detail = services.ActivityButtonShow(activityInfo)
  1029. }
  1030. resp.HasPermission = hasPermission
  1031. br.Ret = 200
  1032. br.Success = true
  1033. br.Msg = "获取成功"
  1034. br.Data = resp
  1035. }
  1036. // @Title 活动报名
  1037. // @Description 活动报名接口
  1038. // @Param request body models.ActivitySingnupRep true "type json string"
  1039. // @Success Ret=200 {object} models.SignupStatus
  1040. // @router /signup/add [post]
  1041. func (this *ActivityCoAntroller) SignupAdd() {
  1042. br := new(models.BaseResponse).Init()
  1043. defer func() {
  1044. this.Data["json"] = br
  1045. this.ServeJSON()
  1046. }()
  1047. user := this.User
  1048. if user == nil {
  1049. br.Msg = "请登录"
  1050. br.ErrMsg = "请登录,用户信息为空"
  1051. br.Ret = 408
  1052. return
  1053. }
  1054. uid := user.UserId
  1055. signupStatus := ""
  1056. var req models.ActivitySingnupRep
  1057. resp := new(models.SignupStatus)
  1058. var total int
  1059. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1060. if err != nil {
  1061. br.Msg = "参数解析异常!"
  1062. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1063. return
  1064. }
  1065. activityId := req.ActivityId
  1066. signupType := req.SignupType
  1067. hasPermission := 0
  1068. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1069. resp.GoBindEmail = true
  1070. }
  1071. //处理冻结客户,流失客户的弹窗提示
  1072. if user.CompanyId > 1 {
  1073. sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
  1074. if err != nil && err.Error() != utils.ErrNoRow() {
  1075. br.Msg = "获取信息失败"
  1076. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1077. return
  1078. }
  1079. if sellerMobile != "" {
  1080. resp.HasPermission = 2
  1081. resp.SellerMobile = sellerMobile
  1082. resp.SellerName = sellerRealName
  1083. br.Ret = 200
  1084. br.Success = true
  1085. br.Msg = "获取成功"
  1086. br.Data = resp
  1087. return
  1088. }
  1089. }
  1090. //判断是否已经申请过
  1091. applyCount, err := models.GetApplyRecordCount(uid)
  1092. if err != nil && err.Error() != utils.ErrNoRow() {
  1093. br.Msg = "获取信息失败"
  1094. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1095. return
  1096. }
  1097. //获取FICC销售信息
  1098. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  1099. if err != nil && err.Error() != utils.ErrNoRow() {
  1100. br.Msg = "申请失败"
  1101. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1102. return
  1103. }
  1104. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1105. if activityInfo == nil {
  1106. br.Msg = "操作失败"
  1107. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1108. return
  1109. }
  1110. if errInfo != nil {
  1111. br.Msg = "操作失败"
  1112. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1113. return
  1114. }
  1115. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1116. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  1117. var companyDetailStatus string
  1118. if user.CompanyId <= 1 {
  1119. companyDetailStatus = ""
  1120. } else {
  1121. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1122. if err != nil {
  1123. br.Msg = "获取信息失败"
  1124. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1125. return
  1126. }
  1127. if companyPermission == "" {
  1128. if applyCount > 0 {
  1129. hasPermission = 4
  1130. } else {
  1131. if sellerItem != nil {
  1132. hasPermission = 5
  1133. } else {
  1134. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  1135. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1136. if err != nil && err.Error() != utils.ErrNoRow() {
  1137. br.Msg = "获取信息失败"
  1138. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1139. return
  1140. }
  1141. if sellerItemQy != nil {
  1142. hasPermission = 2
  1143. resp.SellerMobile = sellerItemQy.Mobile
  1144. resp.SellerName = sellerItemQy.RealName
  1145. } else {
  1146. hasPermission = 3
  1147. }
  1148. }
  1149. }
  1150. resp.HasPermission = hasPermission
  1151. resp.ActivityId = activityId
  1152. resp.OperationMode = "Apply"
  1153. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1154. br.Ret = 200
  1155. br.Success = true
  1156. br.Msg = "获取成功"
  1157. br.Data = resp
  1158. return
  1159. }
  1160. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1161. if err != nil {
  1162. br.Msg = "获取信息失败!"
  1163. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1164. return
  1165. }
  1166. if companyDetail == nil {
  1167. br.Msg = "获取信息失败!"
  1168. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  1169. return
  1170. }
  1171. companyDetailStatus = companyDetail.Status
  1172. }
  1173. var userType int
  1174. var permissionStr string
  1175. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  1176. if err != nil {
  1177. br.Msg = "获取信息失败!"
  1178. br.ErrMsg = "获取失败,Err:" + err.Error()
  1179. return
  1180. }
  1181. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  1182. br.Msg = "您暂无查看该活动权限"
  1183. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  1184. return
  1185. }
  1186. item := new(models.CygxActivitySignup)
  1187. if user.CompanyId > 1 {
  1188. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  1189. //冻结客户
  1190. if err != nil {
  1191. if err.Error() == utils.ErrNoRow() {
  1192. if applyCount > 0 {
  1193. hasPermission = 4
  1194. } else {
  1195. if sellerItem != nil {
  1196. hasPermission = 5
  1197. } else {
  1198. hasPermission = 3
  1199. }
  1200. }
  1201. resp.ActivityId = activityId
  1202. resp.HasPermission = hasPermission
  1203. resp.OperationMode = "Apply"
  1204. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1205. br.Ret = 200
  1206. br.Success = true
  1207. br.Msg = "获取成功"
  1208. br.Data = resp
  1209. return
  1210. } else {
  1211. br.Msg = "获取信息失败"
  1212. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  1213. return
  1214. }
  1215. }
  1216. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  1217. //OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  1218. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  1219. if err != nil {
  1220. br.Msg = "获取信息失败!"
  1221. br.ErrMsg = "获取失败,Err:" + err.Error()
  1222. return
  1223. }
  1224. if havePower {
  1225. hasPermission = 1
  1226. signupStatus = "Success"
  1227. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1228. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1229. signupStatus = "Overtime"
  1230. resp.SignupType = signupType
  1231. resp.SignupStatus = signupStatus
  1232. resp.HasPermission = hasPermission
  1233. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  1234. br.Ret = 200
  1235. br.Success = true
  1236. br.Msg = ""
  1237. br.Data = resp
  1238. return
  1239. }
  1240. var sellerName string
  1241. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1242. if err != nil {
  1243. br.Msg = "报名失败!"
  1244. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1245. return
  1246. }
  1247. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1248. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  1249. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  1250. if activityInfo.IsLimitPeople == 1 {
  1251. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  1252. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  1253. if err != nil {
  1254. br.Msg = "获取信息失败"
  1255. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1256. return
  1257. }
  1258. if totalRestrict >= 1 {
  1259. signupStatus = "BreakPromise"
  1260. resp.PopupMsg = "由于爽约次数过多,您暂时被限制报名资格"
  1261. item.FailType = 3
  1262. }
  1263. totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
  1264. if err != nil {
  1265. br.Msg = "获取信息失败"
  1266. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1267. return
  1268. }
  1269. if totalSignupCompany >= 2 {
  1270. signupStatus = "TwoPeople"
  1271. resp.PopupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
  1272. item.FailType = 2
  1273. }
  1274. totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
  1275. if err != nil {
  1276. br.Msg = "获取信息失败"
  1277. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1278. return
  1279. }
  1280. if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
  1281. signupStatus = "FullStarffed"
  1282. resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
  1283. item.FailType = 1
  1284. }
  1285. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  1286. if err != nil {
  1287. br.Msg = "获取失败"
  1288. br.ErrMsg = "获取失败,Err:" + err.Error()
  1289. return
  1290. }
  1291. //解除报名限制之后二次报名相同活动
  1292. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  1293. item.UserId = uid
  1294. item.RealName = user.RealName
  1295. item.SellerName = sellerName
  1296. item.ActivityId = activityId
  1297. item.CreateTime = time.Now()
  1298. item.Mobile = user.Mobile
  1299. item.Email = user.Email
  1300. item.CompanyId = user.CompanyId
  1301. item.CompanyName = user.CompanyName
  1302. item.SignupType = signupType
  1303. item.FailType = 0
  1304. item.DoFailType = 0
  1305. _, errSignup := models.AddActivitySignupByRestrict(item)
  1306. if errSignup != nil {
  1307. br.Msg = "操作失败"
  1308. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1309. return
  1310. }
  1311. resp.HaqveJurisdiction = true
  1312. resp.SignupType = signupType
  1313. resp.SignupStatus = "Success"
  1314. resp.HasPermission = hasPermission
  1315. resp.ActivityId = activityId
  1316. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1317. if err != nil {
  1318. br.Msg = "获取信息失败"
  1319. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1320. return
  1321. }
  1322. if total == 0 {
  1323. resp.GoFollow = true
  1324. }
  1325. br.Ret = 200
  1326. br.Success = true
  1327. br.Msg = "操作成功"
  1328. br.Data = resp
  1329. return
  1330. }
  1331. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1332. if err != nil {
  1333. br.Msg = "获取失败"
  1334. br.ErrMsg = "获取失败,Err:" + err.Error()
  1335. return
  1336. }
  1337. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1338. item.UserId = uid
  1339. item.RealName = user.RealName
  1340. item.SellerName = sellerName
  1341. item.ActivityId = activityId
  1342. item.CreateTime = time.Now()
  1343. item.Mobile = user.Mobile
  1344. item.Email = user.Email
  1345. item.CompanyId = user.CompanyId
  1346. item.CompanyName = user.CompanyName
  1347. item.SignupType = signupType
  1348. item.DoFailType = item.FailType
  1349. if user.OutboundMobile != "" {
  1350. item.OutboundMobile = user.OutboundMobile
  1351. if user.OutboundCountryCode == "" {
  1352. item.CountryCode = "86"
  1353. } else {
  1354. item.CountryCode = user.OutboundCountryCode
  1355. }
  1356. } else {
  1357. item.OutboundMobile = user.Mobile
  1358. if user.CountryCode == "" {
  1359. item.CountryCode = "86"
  1360. } else {
  1361. item.CountryCode = user.CountryCode
  1362. }
  1363. }
  1364. //添加报名信息,但是不加入日程
  1365. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1366. if errSignup != nil {
  1367. br.Msg = "操作失败"
  1368. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1369. return
  1370. }
  1371. }
  1372. }
  1373. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1374. if err != nil {
  1375. br.Msg = "获取失败"
  1376. br.ErrMsg = "获取失败,Err:" + err.Error()
  1377. return
  1378. }
  1379. if totalMySuccess > 0 {
  1380. br.Msg = "您已报名这个活动"
  1381. return
  1382. }
  1383. if signupStatus == "Success" && resp.GoBindEmail != true {
  1384. item.UserId = uid
  1385. item.RealName = user.RealName
  1386. item.SellerName = sellerName
  1387. item.ActivityId = activityId
  1388. item.CreateTime = time.Now()
  1389. item.Mobile = user.Mobile
  1390. item.Email = user.Email
  1391. item.CompanyId = user.CompanyId
  1392. item.CompanyName = user.CompanyName
  1393. item.SignupType = signupType
  1394. item.FailType = 0
  1395. item.DoFailType = 0
  1396. item.OutboundMobile = user.Mobile
  1397. if user.OutboundMobile != "" {
  1398. item.OutboundMobile = user.OutboundMobile
  1399. if user.OutboundCountryCode == "" {
  1400. item.CountryCode = "86"
  1401. } else {
  1402. item.CountryCode = user.OutboundCountryCode
  1403. }
  1404. } else {
  1405. item.OutboundMobile = user.Mobile
  1406. if user.CountryCode == "" {
  1407. item.CountryCode = "86"
  1408. } else {
  1409. item.CountryCode = user.CountryCode
  1410. }
  1411. }
  1412. _, errSignup := models.AddActivitySignup(item)
  1413. if errSignup != nil {
  1414. br.Msg = "操作失败"
  1415. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1416. return
  1417. }
  1418. resp.HaqveJurisdiction = true
  1419. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1420. if signupType == 1 {
  1421. go services.ActivityUserRemind(user, activityInfo, 1)
  1422. resp.PopupMsg = item.CountryCode + "-" + item.Mobile + "<br/>预约成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
  1423. } else {
  1424. go services.ActivityUserRemind(user, activityInfo, 4)
  1425. resp.PopupMsg = "报名成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
  1426. }
  1427. }
  1428. } else {
  1429. if companyItem.ProductId == 2 {
  1430. hasPermission = 2
  1431. resp.SellerMobile = companyItem.Mobile
  1432. resp.SellerName = companyItem.SellerName
  1433. resp.MsgType = "Type"
  1434. resp.OperationMode = "Call"
  1435. if permissionStr == "专家" {
  1436. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1437. resp.MsgType = "Type"
  1438. } else {
  1439. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1440. resp.MsgType = "Industry"
  1441. }
  1442. } else {
  1443. hasPermission = 5
  1444. }
  1445. }
  1446. } else { //潜在客户
  1447. if applyCount > 0 {
  1448. hasPermission = 4
  1449. } else {
  1450. if sellerItem != nil {
  1451. hasPermission = 5
  1452. } else {
  1453. hasPermission = 3
  1454. }
  1455. }
  1456. resp.OperationMode = "Apply"
  1457. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1458. }
  1459. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1460. resp.GoOutboundMobile = true
  1461. if user.Mobile != "" || user.OutboundMobile != "" {
  1462. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1463. }
  1464. }
  1465. if user.OutboundMobile == "" {
  1466. resp.Mobile = user.Mobile
  1467. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1468. resp.CountryCode = "86"
  1469. } else {
  1470. resp.CountryCode = user.CountryCode
  1471. }
  1472. } else {
  1473. resp.Mobile = user.OutboundMobile
  1474. resp.CountryCode = user.OutboundCountryCode
  1475. }
  1476. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1477. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1478. var countryCode string
  1479. if len(user.Mobile) == 8 {
  1480. countryCode = "852"
  1481. } else if len(user.Mobile) == 9 {
  1482. countryCode = "886"
  1483. } else if len(user.Mobile) == 10 {
  1484. countryCode = "1"
  1485. } else if len(user.Mobile) >= 11 {
  1486. countryCode = "86"
  1487. }
  1488. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1489. }
  1490. resp.SignupType = signupType
  1491. resp.SignupStatus = signupStatus
  1492. resp.HasPermission = hasPermission
  1493. //if signupStatus == "Success" {
  1494. resp.ActivityId = activityId
  1495. //}
  1496. total, err = models.GetUserSignupCount(user.UserId)
  1497. if err != nil {
  1498. br.Msg = "获取信息失败"
  1499. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1500. return
  1501. }
  1502. if total <= 1 {
  1503. resp.GoFollow = true
  1504. }
  1505. br.Ret = 200
  1506. br.Success = true
  1507. br.Msg = "操作成功"
  1508. br.Data = resp
  1509. }
  1510. // @Title 活动取消报名
  1511. // @Description 活动取消报名接口
  1512. // @Param request body models.ActivitySingnupRep true "type json string"
  1513. // @Success Ret=200 {object} models.SignupStatus
  1514. // @router /signup/cancel [post]
  1515. func (this *ActivityCoAntroller) SignupCancel() {
  1516. br := new(models.BaseResponse).Init()
  1517. defer func() {
  1518. this.Data["json"] = br
  1519. this.ServeJSON()
  1520. }()
  1521. user := this.User
  1522. if user == nil {
  1523. br.Msg = "请登录"
  1524. br.ErrMsg = "请登录,用户信息为空"
  1525. br.Ret = 408
  1526. return
  1527. }
  1528. uid := user.UserId
  1529. var req models.ActivitySingnupRep
  1530. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1531. if err != nil {
  1532. br.Msg = "参数解析异常!"
  1533. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1534. return
  1535. }
  1536. activityId := req.ActivityId
  1537. signupType := req.SignupType
  1538. item := new(models.CygxActivitySignup)
  1539. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1540. if activityInfo == nil {
  1541. br.Msg = "操作失败"
  1542. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1543. return
  1544. }
  1545. if errInfo != nil {
  1546. br.Msg = "操作失败"
  1547. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1548. return
  1549. }
  1550. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1551. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1552. if signupType == 1 {
  1553. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1554. } else {
  1555. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1556. }
  1557. return
  1558. }
  1559. total, err := models.GetActivitySignupCount(uid, activityId)
  1560. if err != nil {
  1561. br.Msg = "获取失败"
  1562. br.ErrMsg = "获取失败,Err:" + err.Error()
  1563. return
  1564. }
  1565. if total == 0 {
  1566. br.Msg = "您暂未报名这个活动"
  1567. return
  1568. }
  1569. item.UserId = uid
  1570. item.ActivityId = activityId
  1571. item.CreateTime = time.Now()
  1572. item.Mobile = user.Mobile
  1573. item.Email = user.Email
  1574. item.CompanyId = user.CompanyId
  1575. item.CompanyName = user.CompanyName
  1576. resp := new(models.SignupStatus)
  1577. resp.ActivityId = activityId
  1578. _, errSignup := models.CancelActivitySignup(item)
  1579. if errSignup != nil {
  1580. br.Msg = "操作失败"
  1581. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1582. return
  1583. }
  1584. br.Ret = 200
  1585. br.Success = true
  1586. br.Msg = "操作成功"
  1587. br.Data = resp
  1588. }
  1589. // @Title 用户搜索详情
  1590. // @Description 获取用户搜索详情接口
  1591. // @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
  1592. // @Success Ret=200 {object} models.ActivityUserSearchContentList
  1593. // @router /getUserSearchContent [get]
  1594. func (this *ActivityCoAntroller) GetUserSearchContent() {
  1595. br := new(models.BaseResponse).Init()
  1596. defer func() {
  1597. this.Data["json"] = br
  1598. this.ServeJSON()
  1599. }()
  1600. user := this.User
  1601. if user == nil {
  1602. br.Msg = "请登录"
  1603. br.ErrMsg = "请登录,用户信息为空"
  1604. br.Ret = 408
  1605. return
  1606. }
  1607. uid := user.UserId
  1608. detailSeearch := new(models.CygxActivityUserSearchContent)
  1609. detailSeearch.IsShowJurisdiction = 0
  1610. detailSeearch.ChartPermissionids = ""
  1611. detailSeearch.ActiveState = ""
  1612. resp := new(models.ActivityUserSearchContentList)
  1613. detail, _ := models.GetUserSearchContentByUid(uid)
  1614. if detail == nil {
  1615. detail = detailSeearch
  1616. }
  1617. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  1618. listActivityType, errActivityType := models.GetActivityTypeList()
  1619. if errActivityType != nil {
  1620. br.Msg = "获取失败"
  1621. br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
  1622. return
  1623. }
  1624. var listChartPermissionid []*models.ActivityChartPermission
  1625. var errChart error
  1626. if isShowJurisdiction == 1 {
  1627. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  1628. listChartPermissionid = listChartPermissionidAll
  1629. errChart = errChartAll
  1630. } else if isShowJurisdiction == 2 {
  1631. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1632. listChartPermissionid = listChartPermissionidAll
  1633. errChart = errChartAll
  1634. } else {
  1635. if detail.IsShowJurisdiction == 1 {
  1636. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  1637. listChartPermissionid = listChartPermissionidAll
  1638. errChart = errChartAll
  1639. } else {
  1640. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  1641. listChartPermissionid = listChartPermissionidAll
  1642. errChart = errChartAll
  1643. }
  1644. }
  1645. if errChart != nil {
  1646. br.Msg = "获取信息失败"
  1647. br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
  1648. return
  1649. }
  1650. if detail.IsShowJurisdiction == 1 {
  1651. resp.IsShowJurisdiction = true
  1652. }
  1653. if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
  1654. resp.IsShowJurisdiction = true
  1655. for k, _ := range listChartPermissionid {
  1656. listChartPermissionid[k].IsChoose = true
  1657. }
  1658. }
  1659. if isShowJurisdiction == 2 {
  1660. resp.IsShowJurisdiction = false
  1661. }
  1662. activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
  1663. list2, err := models.GetChartPermissionActivity()
  1664. if err != nil {
  1665. br.Msg = "获取信息失败"
  1666. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1667. return
  1668. }
  1669. if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
  1670. activeStateList[0].IsChoose = true
  1671. }
  1672. var userType int
  1673. userType, _, err = services.GetUserType(user.CompanyId)
  1674. if err != nil {
  1675. br.Msg = "获取信息失败!"
  1676. br.ErrMsg = "获取失败,Err:" + err.Error()
  1677. return
  1678. }
  1679. var listChartPermissionidNew2 []*models.ActivityChartPermission
  1680. for _, v := range list2 {
  1681. if userType == 1 {
  1682. //if v.PermissionName != "研选" {
  1683. if !strings.Contains(v.PermissionName, "研选") {
  1684. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1685. }
  1686. } else {
  1687. listChartPermissionidNew2 = append(listChartPermissionidNew2, v)
  1688. }
  1689. }
  1690. resp.ListChartPermission2 = listChartPermissionidNew2
  1691. var listChartPermissionidNew []*models.ActivityChartPermission
  1692. for _, v := range listChartPermissionid {
  1693. if userType == 1 {
  1694. if !strings.Contains(v.PermissionName, "研选") {
  1695. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1696. }
  1697. } else {
  1698. listChartPermissionidNew = append(listChartPermissionidNew, v)
  1699. }
  1700. }
  1701. resp.ListActivityType = listActivityType
  1702. resp.ListChartPermission = listChartPermissionidNew
  1703. resp.ListActivityStaus = activeStateList
  1704. br.Ret = 200
  1705. br.Success = true
  1706. br.Msg = "获取成功"
  1707. br.Data = resp
  1708. }
  1709. // @Title 添加会议提醒
  1710. // @Description 添加会议提醒接口
  1711. // @Param request body models.ActivityIdRep true "type json string"
  1712. // @Success Ret=200 {object} models.SignupStatus
  1713. // @router /meetingReminder/add [post]
  1714. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1715. br := new(models.BaseResponse).Init()
  1716. defer func() {
  1717. this.Data["json"] = br
  1718. this.ServeJSON()
  1719. }()
  1720. user := this.User
  1721. if user == nil {
  1722. br.Msg = "请登录"
  1723. br.ErrMsg = "请登录,用户信息为空"
  1724. br.Ret = 408
  1725. return
  1726. }
  1727. uid := user.UserId
  1728. //var signupStatus string
  1729. signupStatus := "Success"
  1730. var req models.ActivityIdRep
  1731. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1732. if err != nil {
  1733. br.Msg = "参数解析异常!"
  1734. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1735. return
  1736. }
  1737. activityId := req.ActivityId
  1738. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1739. if activityInfo == nil {
  1740. br.Msg = "操作失败"
  1741. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1742. return
  1743. }
  1744. if errInfo != nil {
  1745. br.Msg = "操作失败"
  1746. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1747. return
  1748. }
  1749. //判断是否已经申请过
  1750. applyCount, err := models.GetApplyRecordCount(uid)
  1751. if err != nil && err.Error() != utils.ErrNoRow() {
  1752. br.Msg = "获取信息失败"
  1753. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1754. return
  1755. }
  1756. //获取销售信息
  1757. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  1758. if err != nil && err.Error() != utils.ErrNoRow() {
  1759. br.Msg = "申请失败"
  1760. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1761. return
  1762. }
  1763. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1764. item := new(models.CygxActivityMeetingReminder)
  1765. resp := new(models.SignupStatus)
  1766. hasPermission := 0
  1767. //处理冻结客户,流失客户的弹窗提示
  1768. if user.CompanyId > 1 {
  1769. sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
  1770. if err != nil && err.Error() != utils.ErrNoRow() {
  1771. br.Msg = "获取信息失败"
  1772. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1773. return
  1774. }
  1775. if sellerMobile != "" {
  1776. resp.HasPermission = 2
  1777. resp.SellerMobile = sellerMobile
  1778. resp.SellerName = sellerRealName
  1779. br.Ret = 200
  1780. br.Success = true
  1781. br.Msg = "获取成功"
  1782. br.Data = resp
  1783. return
  1784. }
  1785. }
  1786. var companyDetailStatus string
  1787. if user.CompanyId <= 1 {
  1788. companyDetailStatus = ""
  1789. } else {
  1790. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1791. if err != nil {
  1792. br.Msg = "获取信息失败"
  1793. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1794. return
  1795. }
  1796. if companyPermission == "" {
  1797. if applyCount > 0 {
  1798. hasPermission = 4
  1799. } else {
  1800. if sellerItem != nil {
  1801. hasPermission = 5
  1802. } else {
  1803. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  1804. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1805. if err != nil && err.Error() != utils.ErrNoRow() {
  1806. br.Msg = "获取信息失败"
  1807. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1808. return
  1809. }
  1810. if sellerItemQy != nil {
  1811. hasPermission = 2
  1812. resp.SellerMobile = sellerItemQy.Mobile
  1813. resp.SellerName = sellerItemQy.RealName
  1814. } else {
  1815. hasPermission = 3
  1816. }
  1817. }
  1818. }
  1819. resp.ActivityId = activityId
  1820. resp.HasPermission = hasPermission
  1821. resp.OperationMode = "Apply"
  1822. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1823. br.Ret = 200
  1824. br.Success = true
  1825. br.Msg = "获取成功"
  1826. br.Data = resp
  1827. return
  1828. }
  1829. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1830. if err != nil {
  1831. br.Msg = "获取信息失败!"
  1832. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1833. return
  1834. }
  1835. if companyDetail == nil {
  1836. br.Msg = "获取信息失败!"
  1837. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  1838. return
  1839. }
  1840. companyDetailStatus = companyDetail.Status
  1841. }
  1842. var userType int
  1843. var permissionStr string
  1844. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  1845. if err != nil {
  1846. br.Msg = "获取信息失败!"
  1847. br.ErrMsg = "获取失败,Err:" + err.Error()
  1848. return
  1849. }
  1850. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  1851. br.Msg = "您暂无查看该活动权限"
  1852. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  1853. return
  1854. }
  1855. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1856. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1857. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1858. return
  1859. }
  1860. if user.CompanyId > 1 {
  1861. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  1862. //冻结客户
  1863. if err != nil {
  1864. if err.Error() == utils.ErrNoRow() {
  1865. //如果是FICC的客户类型,则默认他申请过
  1866. if applyCount > 0 {
  1867. hasPermission = 4
  1868. } else {
  1869. if sellerItem != nil {
  1870. hasPermission = 5
  1871. } else {
  1872. hasPermission = 3
  1873. }
  1874. }
  1875. resp.ActivityId = activityId
  1876. resp.HasPermission = hasPermission
  1877. resp.OperationMode = "Apply"
  1878. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1879. br.Ret = 200
  1880. br.Success = true
  1881. br.Msg = "获取成功"
  1882. br.Data = resp
  1883. return
  1884. } else {
  1885. br.Msg = "获取信息失败"
  1886. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  1887. return
  1888. }
  1889. }
  1890. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  1891. if err != nil {
  1892. br.Msg = "获取信息失败!"
  1893. br.ErrMsg = "获取失败,Err:" + err.Error()
  1894. return
  1895. }
  1896. if havePower {
  1897. hasPermission = 1
  1898. signupStatus = "Success"
  1899. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1900. if errMeeting != nil {
  1901. br.Msg = "获取失败"
  1902. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1903. return
  1904. }
  1905. if totalMeeting > 0 {
  1906. br.Msg = "您已预约,请勿重复预约"
  1907. return
  1908. }
  1909. item.UserId = uid
  1910. item.ActivityId = activityId
  1911. item.CreateTime = time.Now()
  1912. item.Mobile = user.Mobile
  1913. item.Email = user.Email
  1914. item.CompanyId = user.CompanyId
  1915. item.CompanyName = user.CompanyName
  1916. _, errSignup := models.AddActivityMeetingReminder(item)
  1917. if errSignup != nil {
  1918. br.Msg = "操作失败"
  1919. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1920. return
  1921. }
  1922. resp.HaqveJurisdiction = true
  1923. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1924. go services.ActivityUserRemind(user, activityInfo, 2)
  1925. } else {
  1926. if companyItem.ProductId == 2 {
  1927. hasPermission = 2
  1928. resp.SellerMobile = companyItem.Mobile
  1929. resp.SellerName = companyItem.SellerName
  1930. resp.MsgType = "Type"
  1931. resp.OperationMode = "Call"
  1932. if permissionStr == "专家" {
  1933. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1934. resp.MsgType = "Type"
  1935. } else {
  1936. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1937. resp.MsgType = "Industry"
  1938. }
  1939. } else {
  1940. hasPermission = 5
  1941. }
  1942. }
  1943. } else { //潜在客户
  1944. if applyCount > 0 {
  1945. hasPermission = 4
  1946. } else {
  1947. if sellerItem != nil {
  1948. hasPermission = 5
  1949. } else {
  1950. hasPermission = 3
  1951. }
  1952. }
  1953. resp.OperationMode = "Apply"
  1954. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  1955. }
  1956. resp.HasPermission = hasPermission
  1957. resp.SignupStatus = signupStatus
  1958. resp.ActivityId = activityId
  1959. var total int
  1960. total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1961. if err != nil {
  1962. br.Msg = "获取信息失败"
  1963. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1964. return
  1965. }
  1966. if total <= 1 {
  1967. resp.GoFollow = true
  1968. }
  1969. br.Ret = 200
  1970. br.Success = true
  1971. if hasPermission == 1 {
  1972. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1973. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1974. }
  1975. br.Data = resp
  1976. }
  1977. // @Title 取消会议提醒
  1978. // @Description 取消会议提醒接口
  1979. // @Param request body models.ActivityIdRep true "type json string"
  1980. // @Success Ret=200 {object} models.SignupStatus
  1981. // @router /meetingReminder/cancel [post]
  1982. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1983. br := new(models.BaseResponse).Init()
  1984. defer func() {
  1985. this.Data["json"] = br
  1986. this.ServeJSON()
  1987. }()
  1988. user := this.User
  1989. if user == nil {
  1990. br.Msg = "请登录"
  1991. br.ErrMsg = "请登录,用户信息为空"
  1992. br.Ret = 408
  1993. return
  1994. }
  1995. uid := user.UserId
  1996. var req models.ActivityIdRep
  1997. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1998. if err != nil {
  1999. br.Msg = "参数解析异常!"
  2000. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2001. return
  2002. }
  2003. activityId := req.ActivityId
  2004. signupStatus := "Success"
  2005. item := new(models.CygxActivityMeetingReminder)
  2006. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2007. if activityInfo == nil {
  2008. br.Msg = "操作失败"
  2009. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2010. return
  2011. }
  2012. if errInfo != nil {
  2013. br.Msg = "操作失败"
  2014. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2015. return
  2016. }
  2017. //if signupStatus == "Success" {
  2018. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  2019. if err != nil {
  2020. br.Msg = "获取失败"
  2021. br.ErrMsg = "获取失败,Err:" + err.Error()
  2022. return
  2023. }
  2024. if total == 0 {
  2025. br.Msg = "您暂未添加该活动会议提醒"
  2026. return
  2027. }
  2028. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  2029. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  2030. br.Msg = "活动开始前15分钟无法取消会议提醒"
  2031. return
  2032. }
  2033. item.UserId = uid
  2034. item.ActivityId = activityId
  2035. item.CreateTime = time.Now()
  2036. item.Mobile = user.Mobile
  2037. item.Email = user.Email
  2038. item.CompanyId = user.CompanyId
  2039. item.CompanyName = user.CompanyName
  2040. _, errSignup := models.CancelActivityMeetingReminder(item)
  2041. if errSignup != nil {
  2042. br.Msg = "操作失败"
  2043. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  2044. return
  2045. }
  2046. //}
  2047. resp := new(models.SignupStatus)
  2048. resp.SignupStatus = signupStatus
  2049. resp.ActivityId = activityId
  2050. br.Ret = 200
  2051. br.Success = true
  2052. br.Msg = "会议提醒已取消"
  2053. br.Data = resp
  2054. }
  2055. // @Title 敏捷搜索关键词的列表
  2056. // @Description 获取敏捷搜索关键词的列表接口
  2057. // @Success 200 {object} models.ActivityFastsearchKeywordsListResp
  2058. // @router /fastSearchKeWord [get]
  2059. func (this *ActivityABaseController) FastSearch() {
  2060. br := new(models.BaseResponse).Init()
  2061. defer func() {
  2062. this.Data["json"] = br
  2063. this.ServeJSON()
  2064. }()
  2065. resp := new(models.ActivityFastsearchKeywordsListResp)
  2066. list, err := models.GetActivityFastsearchKeywordsList()
  2067. if err != nil {
  2068. br.Msg = "获取失败"
  2069. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2070. return
  2071. }
  2072. resp.List = list
  2073. br.Ret = 200
  2074. br.Success = true
  2075. br.Msg = "获取成功"
  2076. br.Data = resp
  2077. }
  2078. // @Title 活动带问
  2079. // @Description 新增活动带问接口
  2080. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  2081. // @Success Ret=200 新增成功
  2082. // @router /askAdd [post]
  2083. func (this *ActivityCoAntroller) AskAdd() {
  2084. br := new(models.BaseResponse).Init()
  2085. defer func() {
  2086. this.Data["json"] = br
  2087. this.ServeJSON()
  2088. }()
  2089. user := this.User
  2090. if user == nil {
  2091. br.Msg = "请登录"
  2092. br.ErrMsg = "请登录,SysUser Is Empty"
  2093. br.Ret = 408
  2094. return
  2095. }
  2096. var req models.CygxActivityHelpAsk
  2097. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2098. if err != nil {
  2099. br.Msg = "参数解析异常!"
  2100. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2101. return
  2102. }
  2103. if req.Content == "" {
  2104. br.Msg = "建议内容不可为空"
  2105. return
  2106. }
  2107. content := req.Content
  2108. itemToken, err := services.WxGetToken()
  2109. if err != nil {
  2110. br.Msg = "GetWxAccessToken Err:" + err.Error()
  2111. return
  2112. }
  2113. if itemToken.AccessToken == "" {
  2114. br.Msg = "accessToken is empty"
  2115. return
  2116. }
  2117. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  2118. if err != nil {
  2119. br.Msg = "内容校验失败!"
  2120. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  2121. return
  2122. }
  2123. if commerr.ErrCode != 0 {
  2124. br.Msg = "内容违规,请重新提交!"
  2125. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  2126. return
  2127. }
  2128. activityId := req.ActivityId
  2129. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2130. if activityInfo == nil {
  2131. br.Msg = "操作失败"
  2132. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2133. return
  2134. }
  2135. if errInfo != nil {
  2136. br.Msg = "操作失败"
  2137. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2138. return
  2139. }
  2140. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  2141. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  2142. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  2143. // br.Msg = "活动开始前15分钟内无法提交问题"
  2144. // return
  2145. // }
  2146. //} else {
  2147. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  2148. // br.Msg = "活动开始前1小时内无法提交问题"
  2149. // return
  2150. // }
  2151. //}
  2152. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  2153. if err != nil {
  2154. br.Msg = "提交失败!"
  2155. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2156. return
  2157. }
  2158. if companyDetail == nil {
  2159. br.Msg = "提交失败!"
  2160. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  2161. return
  2162. }
  2163. item := new(models.CygxActivityHelpAsk)
  2164. item.UserId = user.UserId
  2165. item.ActivityId = req.ActivityId
  2166. item.CompanyId = user.CompanyId
  2167. item.CompanyName = companyDetail.CompanyName
  2168. item.CreateTime = time.Now()
  2169. item.Mobile = user.Mobile
  2170. item.Email = user.Email
  2171. item.Content = content
  2172. _, err = models.AddActivityHelpAsk(item)
  2173. if err != nil {
  2174. br.Msg = "提交失败"
  2175. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  2176. return
  2177. }
  2178. var isSendMsg bool
  2179. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  2180. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  2181. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  2182. isSendMsg = true
  2183. }
  2184. } else {
  2185. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  2186. isSendMsg = true
  2187. }
  2188. }
  2189. if isSendMsg {
  2190. listEmail, err := models.GetAskEmail()
  2191. if err != nil {
  2192. br.Msg = "提交失败"
  2193. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  2194. return
  2195. }
  2196. var sendMobile string
  2197. for _, v := range listEmail {
  2198. if strings.Index(activityInfo.Host, v.Name) > 0 {
  2199. sendMobile = v.Mobile
  2200. }
  2201. }
  2202. if activityInfo.ChartPermissionId == 31 {
  2203. sendMobile = utils.ActSendMsgMobile
  2204. }
  2205. //获取销售信息
  2206. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2207. if err != nil && err.Error() != utils.ErrNoRow() {
  2208. br.Msg = "提交失败"
  2209. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2210. return
  2211. }
  2212. //给研究员发送消息
  2213. if sendMobile != "" {
  2214. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  2215. if openIpItem != nil && openIpItem.OpenId != "" {
  2216. if sellerItem != nil {
  2217. //services.SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
  2218. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  2219. }
  2220. }
  2221. }
  2222. // 给所属销售发送消息
  2223. if sellerItem != nil {
  2224. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  2225. if openIpItem != nil && openIpItem.OpenId != "" {
  2226. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  2227. }
  2228. }
  2229. }
  2230. br.Ret = 200
  2231. br.Success = true
  2232. br.Msg = "提交成功"
  2233. }
  2234. // @Title 更多主题列表(4.3版本)
  2235. // @Description 获取活动更多主题列表接口(4.3版本)
  2236. // @Success 200 {object} models.GetCygxActivityLabelListRep
  2237. // @router /labelMoreList [get]
  2238. func (this *ActivityCoAntroller) LabelMoreList() {
  2239. br := new(models.BaseResponse).Init()
  2240. defer func() {
  2241. this.Data["json"] = br
  2242. this.ServeJSON()
  2243. }()
  2244. user := this.User
  2245. if user == nil {
  2246. br.Msg = "请登录"
  2247. br.ErrMsg = "请登录,SysUser Is Empty"
  2248. return
  2249. }
  2250. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2251. if err != nil {
  2252. br.Msg = "获取失败"
  2253. br.ErrMsg = "获取失败,Err:" + err.Error()
  2254. return
  2255. }
  2256. var startSize, pageSize int
  2257. pageSize = 24
  2258. var condition string
  2259. var sortTime string
  2260. //var conditionStatus string
  2261. var pars []interface{}
  2262. //活动可见限制
  2263. var sqlExport string
  2264. resp := new(models.GetCygxActivityLabelListRep)
  2265. slicePer := strings.Split(permissionStr, ",")
  2266. var permissionSqlStr string
  2267. for _, v := range slicePer {
  2268. if userType == 1 {
  2269. //if v != "研选" {
  2270. if !strings.Contains(v, "研选") {
  2271. permissionSqlStr += "'" + v + "',"
  2272. }
  2273. } else {
  2274. permissionSqlStr += "'" + v + "',"
  2275. }
  2276. }
  2277. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  2278. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  2279. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  2280. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  2281. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  2282. if userType == 2 {
  2283. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  2284. }
  2285. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  2286. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  2287. }
  2288. sqlExport += `) `
  2289. //进行中的活动
  2290. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 2 `
  2291. var conditionOr string
  2292. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2293. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2294. }
  2295. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2296. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2297. }
  2298. if userType == 1 {
  2299. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2300. } else {
  2301. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2302. }
  2303. //判断客户规模是否属于可见范围的活动
  2304. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  2305. if err != nil && err.Error() != utils.ErrNoRow() {
  2306. br.Msg = "获取信息失败"
  2307. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2308. return
  2309. }
  2310. if companyProduct != nil {
  2311. if companyProduct.Scale != "" {
  2312. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  2313. }
  2314. }
  2315. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2316. //进行中的活动
  2317. sortTime = ` mintimesort ASC `
  2318. list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2319. if errList != nil {
  2320. br.Msg = "获取失败"
  2321. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2322. return
  2323. }
  2324. //已结束的活动
  2325. conditionOr = ""
  2326. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
  2327. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  2328. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  2329. }
  2330. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  2331. conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  2332. }
  2333. if userType == 1 {
  2334. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  2335. } else {
  2336. conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  2337. }
  2338. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  2339. startSize = 0
  2340. pageSize = 24 - len(list)
  2341. //已结束的活动
  2342. sortTime = ` timesort DESC `
  2343. listEnd, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  2344. if err != nil {
  2345. br.Msg = "获取失败"
  2346. br.ErrMsg = "获取失败,Err:" + err.Error()
  2347. return
  2348. }
  2349. for _, v := range listEnd {
  2350. list = append(list, v)
  2351. }
  2352. //标签字段关联的产业与标签处理
  2353. for k, v := range list {
  2354. list[k].KeyWord = services.LabelStr(v.KeyWord)
  2355. }
  2356. //添加更多主题访问记录
  2357. item := new(models.CygxPageHistoryRecord)
  2358. item.UserId = user.UserId
  2359. item.CreateTime = time.Now()
  2360. item.Mobile = user.Mobile
  2361. item.Email = user.Email
  2362. item.CompanyId = user.CompanyId
  2363. item.CompanyName = user.CompanyName
  2364. item.PageType = "LabelMore"
  2365. go models.AddCygxPageHistoryRecord(item)
  2366. resp.List = list
  2367. br.Ret = 200
  2368. br.Success = true
  2369. br.Msg = "获取成功"
  2370. br.Data = resp
  2371. }
  2372. // @Title 活动列表(4.3版本)
  2373. // @Description 获取活动列表接口(4.3版本)
  2374. // @Param PageSize query int true "每页数据条数"
  2375. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2376. // @Param Label query string false "搜索主题 多个用 , 隔开"
  2377. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2378. // @Param WhichDay query string false "哪一天 1今天、2明天,3本周,4上周,5本月,6上月 多个用 , 隔开"
  2379. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2380. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  2381. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  2382. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2383. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  2384. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  2385. // @Param ActivityId query int false "活动列表传过来的活动ID"
  2386. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  2387. // @Success 200 {object} models.GetCygxActivityListRep
  2388. // @router /listNew [get]
  2389. func (this *ActivityCoAntroller) ActivityListNew() {
  2390. br := new(models.BaseResponse).Init()
  2391. defer func() {
  2392. this.Data["json"] = br
  2393. this.ServeJSON()
  2394. }()
  2395. user := this.User
  2396. if user == nil {
  2397. br.Msg = "请登录"
  2398. br.ErrMsg = "请登录,SysUser Is Empty"
  2399. return
  2400. }
  2401. uid := user.UserId
  2402. pageSize, _ := this.GetInt("PageSize")
  2403. currentIndex, _ := this.GetInt("CurrentIndex")
  2404. source, _ := this.GetInt("Source")
  2405. label := this.GetString("Label")
  2406. chartPermissionIds := this.GetString("ChartPermissionIds")
  2407. whichDay := this.GetString("WhichDay")
  2408. activeState := this.GetString("ActiveState")
  2409. activityTypeId := this.GetString("ActivityTypeId")
  2410. keyWord := this.GetString("KeyWord")
  2411. playBack, _ := this.GetInt("PlayBack")
  2412. filter, _ := this.GetInt("Filter")
  2413. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  2414. if label == "undefined" {
  2415. label = ""
  2416. }
  2417. if chartPermissionIds == "undefined" {
  2418. chartPermissionIds = ""
  2419. }
  2420. // 查研观向7.4-始终查询宏观的活动
  2421. if chartPermissionIds != "" {
  2422. chartPermissionIds += ",1"
  2423. }
  2424. if whichDay == "undefined" {
  2425. whichDay = ""
  2426. }
  2427. if activeState == "undefined" {
  2428. activeState = ""
  2429. }
  2430. if activityTypeId == "undefined" {
  2431. activityTypeId = ""
  2432. }
  2433. var startSize int
  2434. if pageSize <= 0 {
  2435. pageSize = utils.PageSize20
  2436. }
  2437. if currentIndex <= 0 {
  2438. currentIndex = 1
  2439. }
  2440. startSize = utils.StartIndex(currentIndex, pageSize)
  2441. //userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2442. var condition string
  2443. var pars []interface{}
  2444. var activityList []*models.ActivityDetail
  2445. mapDingActivityId := make(map[int]int)
  2446. //进行中的活动拍在最上面
  2447. //if keyWord != "" {
  2448. // conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, strconv.Itoa(2), label, 0, source, keyWord)
  2449. // if err != nil && err.Error() != utils.ErrNoRow() {
  2450. // br.Msg = "获取失败"
  2451. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2452. // return
  2453. // }
  2454. // if source == 1 {
  2455. // condition += ` AND art.yidong_activity_id = '' `
  2456. // }
  2457. // condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  2458. // condition += ` ORDER BY art.activity_time ASC `
  2459. // listDing, err := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
  2460. // if err != nil && err.Error() != utils.ErrNoRow() {
  2461. // br.Msg = "获取失败"
  2462. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2463. // return
  2464. // }
  2465. // if len(listDing) > 0 {
  2466. // for _, v := range listDing {
  2467. // activityList = append(activityList, v)
  2468. // mapDingActivityId[v.ActivityId] = v.ActivityId
  2469. // }
  2470. // }
  2471. //}
  2472. condition = ""
  2473. //活动可见限制
  2474. conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack)
  2475. if err != nil && err.Error() != utils.ErrNoRow() {
  2476. br.Msg = "获取失败"
  2477. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  2478. return
  2479. }
  2480. if source == 1 {
  2481. condition += ` AND art.yidong_activity_id = '' `
  2482. }
  2483. //
  2484. //if playBack == 1 {
  2485. // //活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
  2486. // endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
  2487. // condition += ` AND art.activity_time > ? `
  2488. // pars = append(pars, endTime)
  2489. //}
  2490. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  2491. total, err := models.GetActivityCount(condition, playBack, pars)
  2492. if err != nil {
  2493. br.Msg = "获取失败"
  2494. br.ErrMsg = "获取失败,Err:" + err.Error()
  2495. return
  2496. }
  2497. var conditionOrder string
  2498. if activeState == "2" || activeState == "3" {
  2499. conditionOrder = ` ORDER BY art.activity_time DESC `
  2500. } else if activeState == "2,3" {
  2501. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  2502. } else {
  2503. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  2504. }
  2505. if label != "" && activeState == "1" {
  2506. conditionOrder = ` ORDER BY art.activity_time ASC `
  2507. }
  2508. if activeState == "1" {
  2509. conditionOrder = ` ORDER BY art.activity_time ASC `
  2510. }
  2511. condition += conditionOrder
  2512. list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
  2513. if errList != nil {
  2514. br.Msg = "获取失败"
  2515. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2516. return
  2517. }
  2518. var isShow bool
  2519. isShow = services.GetShowSustainable()
  2520. detail, err := models.GetConfigByCode("city_img_url")
  2521. if err != nil {
  2522. br.Msg = "获取数据失败"
  2523. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2524. return
  2525. }
  2526. detailChart, err := models.GetConfigByCode("chart_img_url")
  2527. if err != nil {
  2528. br.Msg = "获取数据失败"
  2529. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2530. return
  2531. }
  2532. addressList := strings.Split(detail.ConfigValue, "{|}")
  2533. mapAddress := make(map[string]string)
  2534. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2535. mapChart := make(map[string]string)
  2536. var cityName string
  2537. var chartName string
  2538. var imgUrl string
  2539. var imgUrlChart string
  2540. var mapActivityId []int
  2541. for _, v := range addressList {
  2542. vslice := strings.Split(v, "_")
  2543. cityName = vslice[0]
  2544. imgUrl = vslice[len(vslice)-1]
  2545. mapAddress[cityName] = imgUrl
  2546. }
  2547. for _, v := range chartList {
  2548. vslice := strings.Split(v, "_")
  2549. chartName = vslice[0]
  2550. imgUrlChart = vslice[len(vslice)-1]
  2551. mapChart[chartName] = imgUrlChart
  2552. }
  2553. for k, v := range list {
  2554. if strings.Contains(v.ActivityName, "【") {
  2555. list[k].IsBrackets = 1
  2556. }
  2557. if v.SignupNum > v.LimitPeopleNum {
  2558. list[k].SignupNum = v.LimitPeopleNum
  2559. }
  2560. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2561. list[k].IsShowSustainable = true
  2562. }
  2563. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2564. list[k].ActivityTypeName = "买方研选电话会"
  2565. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2566. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  2567. }
  2568. if v.ActivityType == 0 {
  2569. if mapAddress[v.City] != "" {
  2570. list[k].ImgUrl = mapAddress[v.City]
  2571. } else {
  2572. list[k].ImgUrl = mapAddress["其它"]
  2573. }
  2574. } else {
  2575. if mapChart[v.ChartPermissionName] != "" {
  2576. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2577. }
  2578. }
  2579. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2580. list[k].Expert = expertTxt
  2581. if v.IsHideAppointment == 0 {
  2582. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2583. }
  2584. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2585. list[k].IsCClassMeeting = true
  2586. }
  2587. mapActivityId = append(mapActivityId, v.ActivityId)
  2588. }
  2589. page := paging.GetPaging(currentIndex, pageSize, total)
  2590. resp := new(models.GetCygxActivityListRep)
  2591. resp.Label = label
  2592. if activityTypeId != "" {
  2593. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  2594. if err == nil {
  2595. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  2596. if errDetail != nil {
  2597. br.Msg = "获取信息失败"
  2598. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  2599. return
  2600. }
  2601. resp.ImgUrl = detail.OnlineIco
  2602. resp.Label = detail.ActivityTypeName
  2603. }
  2604. }
  2605. //处理音频回放
  2606. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2607. if err != nil {
  2608. br.Msg = "获取信息失败"
  2609. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2610. return
  2611. }
  2612. //处理视频回放
  2613. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  2614. if err != nil {
  2615. br.Msg = "获取信息失败"
  2616. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  2617. return
  2618. }
  2619. for _, v := range list {
  2620. if mapDingActivityId[v.ActivityId] == 0 {
  2621. activityList = append(activityList, v)
  2622. }
  2623. }
  2624. for _, v := range activityList {
  2625. if v.ActivityType == 0 {
  2626. if mapAddress[v.City] != "" {
  2627. v.ImgUrl = mapAddress[v.City]
  2628. } else {
  2629. v.ImgUrl = mapAddress["其它"]
  2630. }
  2631. } else {
  2632. if mapChart[v.ChartPermissionName] != "" {
  2633. v.ImgUrl = mapChart[v.ChartPermissionName]
  2634. }
  2635. }
  2636. if mapActivityVoice[v.ActivityId] != nil {
  2637. v.AudioLink = true
  2638. v.VoiceList = mapActivityVoice[v.ActivityId]
  2639. }
  2640. }
  2641. for k, v := range activityList {
  2642. if mapActivityVoice[v.ActivityId] != nil {
  2643. list[k].FileType = 1
  2644. list[k].AudioLink = true
  2645. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  2646. }
  2647. if mapActivityVideo[v.ActivityId] != nil {
  2648. list[k].FileType = 2
  2649. list[k].AudioLink = true
  2650. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  2651. }
  2652. resp.List = append(resp.List, services.ActivityButtonShow(v))
  2653. }
  2654. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  2655. if label != "" {
  2656. industry, e := models.GetIndustryByName(label)
  2657. if e != nil && e.Error() != utils.ErrNoRow() {
  2658. br.Msg = "获取信息失败"
  2659. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  2660. return
  2661. }
  2662. if industry != nil {
  2663. sourceIndustry, e := models.GetSourceIndustryByName(label)
  2664. if e != nil && e.Error() != utils.ErrNoRow() {
  2665. br.Msg = "获取信息失败"
  2666. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  2667. return
  2668. }
  2669. if sourceIndustry != nil {
  2670. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  2671. resp.IsJump = true
  2672. // 研选产业不跳资源包
  2673. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  2674. resp.IsJump = false
  2675. }
  2676. }
  2677. }
  2678. // 新标签
  2679. if activityId > 0 {
  2680. activityIds := []int{activityId}
  2681. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  2682. if e != nil {
  2683. br.Msg = "获取信息失败"
  2684. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  2685. return
  2686. }
  2687. resp.IndustryNewLabel = activityNewMap[activityId]
  2688. }
  2689. }
  2690. //添加活动搜索记录
  2691. if keyWord != "" {
  2692. go services.AddActivitykeyWordSearch(keyWord, user)
  2693. }
  2694. resp.Paging = page
  2695. br.Ret = 200
  2696. br.Success = true
  2697. br.Msg = "获取成功"
  2698. br.Data = resp
  2699. }
  2700. // @Title 校验活动带问是否有权限
  2701. // @Description 校验活动带问是否有权限接口
  2702. // @Param request body models.ActivityIdRep true "type json string"
  2703. // @Success Ret=200 {object} models.SignupStatus
  2704. // @router /checkAsk [post]
  2705. func (this *ActivityCoAntroller) CheckAsk() {
  2706. br := new(models.BaseResponse).Init()
  2707. defer func() {
  2708. this.Data["json"] = br
  2709. this.ServeJSON()
  2710. }()
  2711. user := this.User
  2712. if user == nil {
  2713. br.Msg = "请登录"
  2714. br.ErrMsg = "请登录,用户信息为空"
  2715. br.Ret = 408
  2716. return
  2717. }
  2718. uid := user.UserId
  2719. signupStatus := "Success"
  2720. var req models.ActivityIdRep
  2721. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2722. if err != nil {
  2723. br.Msg = "参数解析异常!"
  2724. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2725. return
  2726. }
  2727. activityId := req.ActivityId
  2728. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2729. if activityInfo == nil {
  2730. br.Msg = "操作失败"
  2731. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2732. return
  2733. }
  2734. if errInfo != nil {
  2735. br.Msg = "操作失败"
  2736. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2737. return
  2738. }
  2739. //判断是否已经申请过
  2740. applyCount, err := models.GetApplyRecordCount(uid)
  2741. if err != nil && err.Error() != utils.ErrNoRow() {
  2742. br.Msg = "获取信息失败"
  2743. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2744. return
  2745. }
  2746. //获取销售信息
  2747. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  2748. if err != nil && err.Error() != utils.ErrNoRow() {
  2749. br.Msg = "申请失败"
  2750. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2751. return
  2752. }
  2753. resp := new(models.SignupStatus)
  2754. //处理冻结客户,流失客户的弹窗提示
  2755. if user.CompanyId > 1 {
  2756. sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
  2757. if err != nil && err.Error() != utils.ErrNoRow() {
  2758. br.Msg = "获取信息失败"
  2759. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2760. return
  2761. }
  2762. if sellerMobile != "" {
  2763. resp.HasPermission = 2
  2764. resp.SellerMobile = sellerMobile
  2765. resp.SellerName = sellerRealName
  2766. br.Ret = 200
  2767. br.Success = true
  2768. br.Msg = "获取成功"
  2769. br.Data = resp
  2770. return
  2771. }
  2772. }
  2773. hasPermission := 0
  2774. var companyDetailStatus string
  2775. if user.CompanyId <= 1 {
  2776. companyDetailStatus = ""
  2777. } else {
  2778. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2779. if err != nil {
  2780. br.Msg = "获取信息失败"
  2781. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2782. return
  2783. }
  2784. if companyPermission == "" {
  2785. if applyCount > 0 {
  2786. hasPermission = 4
  2787. } else {
  2788. if sellerItem != nil {
  2789. hasPermission = 5
  2790. } else {
  2791. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  2792. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2793. if err != nil && err.Error() != utils.ErrNoRow() {
  2794. br.Msg = "获取信息失败"
  2795. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2796. return
  2797. }
  2798. if sellerItemQy != nil {
  2799. hasPermission = 2
  2800. resp.SellerMobile = sellerItemQy.Mobile
  2801. resp.SellerName = sellerItemQy.RealName
  2802. } else {
  2803. hasPermission = 3
  2804. }
  2805. }
  2806. }
  2807. resp.ActivityId = activityId
  2808. resp.HasPermission = hasPermission
  2809. resp.OperationMode = "Apply"
  2810. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2811. br.Ret = 200
  2812. br.Success = true
  2813. br.Msg = "获取成功"
  2814. br.Data = resp
  2815. return
  2816. }
  2817. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  2818. if err != nil {
  2819. br.Msg = "获取信息失败!"
  2820. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  2821. return
  2822. }
  2823. if companyDetail == nil {
  2824. br.Msg = "获取信息失败!"
  2825. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  2826. return
  2827. }
  2828. companyDetailStatus = companyDetail.Status
  2829. }
  2830. var userType int
  2831. var permissionStr string
  2832. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  2833. if err != nil {
  2834. br.Msg = "获取信息失败!"
  2835. br.ErrMsg = "获取失败,Err:" + err.Error()
  2836. return
  2837. }
  2838. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  2839. br.Msg = "您暂无查看该活动权限"
  2840. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  2841. return
  2842. }
  2843. if user.CompanyId > 1 {
  2844. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  2845. //冻结客户
  2846. if err != nil {
  2847. if err.Error() == utils.ErrNoRow() {
  2848. if applyCount > 0 {
  2849. hasPermission = 4
  2850. } else {
  2851. if sellerItem != nil {
  2852. hasPermission = 5
  2853. } else {
  2854. hasPermission = 3
  2855. }
  2856. }
  2857. resp.ActivityId = activityId
  2858. resp.HasPermission = hasPermission
  2859. resp.OperationMode = "Apply"
  2860. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2861. br.Ret = 200
  2862. br.Success = true
  2863. br.Msg = "获取成功"
  2864. br.Data = resp
  2865. return
  2866. } else {
  2867. br.Msg = "获取信息失败"
  2868. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  2869. return
  2870. }
  2871. }
  2872. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  2873. if err != nil {
  2874. br.Msg = "获取信息失败!"
  2875. br.ErrMsg = "获取失败,Err:" + err.Error()
  2876. return
  2877. }
  2878. if havePower {
  2879. hasPermission = 1
  2880. signupStatus = "Success"
  2881. resp.HaqveJurisdiction = true
  2882. } else {
  2883. if companyItem.ProductId == 2 {
  2884. hasPermission = 2
  2885. resp.SellerMobile = companyItem.Mobile
  2886. resp.SellerName = companyItem.SellerName
  2887. resp.MsgType = "Type"
  2888. resp.OperationMode = "Call"
  2889. if permissionStr == "专家" {
  2890. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  2891. resp.MsgType = "Type"
  2892. } else {
  2893. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  2894. resp.MsgType = "Industry"
  2895. }
  2896. } else {
  2897. hasPermission = 5
  2898. }
  2899. }
  2900. } else { //潜在客户
  2901. if applyCount > 0 {
  2902. hasPermission = 4
  2903. } else {
  2904. if sellerItem != nil {
  2905. hasPermission = 5
  2906. } else {
  2907. hasPermission = 3
  2908. }
  2909. }
  2910. resp.OperationMode = "Apply"
  2911. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  2912. }
  2913. resp.HasPermission = hasPermission
  2914. resp.SignupStatus = signupStatus
  2915. resp.ActivityId = activityId
  2916. br.Ret = 200
  2917. br.Success = true
  2918. br.Data = resp
  2919. }
  2920. // @Title 活动类型下的主题列表(5.3版本)
  2921. // @Description 获取活动类型下的主题列表接口(5.3版本)
  2922. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  2923. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  2924. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  2925. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  2926. // @Param WhichWeek query string false "哪一周 本周:1 上周:2"
  2927. // @Param WhichMonth query string false "哪一月 本月:1 上月:2"
  2928. // @Param WhichMonth query string false "哪一月 本月:1 上月:2"
  2929. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  2930. // @Success 200 {object} models.ActivityTypeListHomeResp
  2931. // @router /labelTypeListV5 [get]
  2932. func (this *ActivityCoAntroller) LabelTypeListV5() {
  2933. br := new(models.BaseResponse).Init()
  2934. defer func() {
  2935. this.Data["json"] = br
  2936. this.ServeJSON()
  2937. }()
  2938. user := this.User
  2939. if user == nil {
  2940. br.Msg = "请登录"
  2941. br.ErrMsg = "请登录,SysUser Is Empty"
  2942. return
  2943. }
  2944. pageSize, _ := this.GetInt("PageSize")
  2945. isPower, _ := this.GetInt("IsPower")
  2946. chartPermissionIds := this.GetString("ChartPermissionIds")
  2947. whichDay := this.GetString("WhichDay")
  2948. activeState := this.GetString("ActiveState")
  2949. //入参为 undefined 时的处理
  2950. if chartPermissionIds == "undefined" {
  2951. chartPermissionIds = ""
  2952. }
  2953. if whichDay == "undefined" {
  2954. whichDay = ""
  2955. }
  2956. if activeState == "undefined" || activeState == "" {
  2957. activeState = "1"
  2958. }
  2959. // 查研观向7.4-始终查询宏观的活动
  2960. if chartPermissionIds != "" {
  2961. chartPermissionIds += ",1"
  2962. }
  2963. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  2964. if err != nil {
  2965. br.Msg = "获取失败"
  2966. br.ErrMsg = "获取失败,Err:" + err.Error()
  2967. return
  2968. }
  2969. var startSize int
  2970. pageSize = 8
  2971. var sortTime string
  2972. var pars []interface{}
  2973. //活动可见限制
  2974. slicePer := strings.Split(permissionStr, ",")
  2975. //var permissionSqlStr string
  2976. var permissionNameStr string
  2977. for _, v := range slicePer {
  2978. if userType == 1 {
  2979. //if v != "研选" {
  2980. if !strings.Contains(v, "研选") {
  2981. permissionNameStr += "'" + v + "',"
  2982. }
  2983. } else {
  2984. permissionNameStr += "'" + v + "',"
  2985. }
  2986. }
  2987. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  2988. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  2989. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  2990. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  2991. if permissionNameStr == `` {
  2992. permissionNameStr = `'宏观'`
  2993. } else {
  2994. permissionNameStr += `, '宏观'`
  2995. }
  2996. list, err := models.GetActivityTypeHomeList()
  2997. if err != nil {
  2998. br.Msg = "获取失败"
  2999. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  3000. return
  3001. }
  3002. //判断客户规模是否属于可见范围的活动
  3003. //companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3004. //if err != nil && err.Error() != utils.ErrNoRow() {
  3005. // br.Msg = "获取信息失败"
  3006. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3007. // return
  3008. //}
  3009. //isMaker := user.IsMaker
  3010. //var sqlExport string
  3011. resp := new(models.ActivityTypeListHomeResp)
  3012. for k, v := range list {
  3013. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  3014. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  3015. continue
  3016. }
  3017. var condition string
  3018. conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0)
  3019. if err != nil && err.Error() != utils.ErrNoRow() {
  3020. br.Msg = "获取失败"
  3021. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3022. return
  3023. }
  3024. condition += `AND art.is_limit_people = 1 ` + conditionActivity
  3025. sortTime = ` mintimesort ASC `
  3026. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  3027. if err != nil {
  3028. br.Msg = "获取失败"
  3029. br.ErrMsg = "获取失败,Err:" + err.Error()
  3030. return
  3031. }
  3032. //标签字段关联的产业与标签处理
  3033. for k2, v2 := range labelList {
  3034. if v2.YidongActivityId != 0 {
  3035. v2.IsExternalLabel = true
  3036. }
  3037. labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  3038. labelList[k2].ImgUrlBg = v.ImgUrlBgs
  3039. }
  3040. list[k].List = labelList
  3041. list[k].Resource = 1
  3042. }
  3043. //查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
  3044. if whichDay == "" {
  3045. speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
  3046. if err != nil {
  3047. br.Msg = "获取失败"
  3048. br.ErrMsg = "获取失败,Err:" + err.Error()
  3049. return
  3050. }
  3051. if len(speciaItem.List) > 0 {
  3052. list = append(list, speciaItem)
  3053. }
  3054. }
  3055. //获取对应活动的数量并排序
  3056. activityIds := make([]int, 0) // 用于查询活动【新】标签Map
  3057. intArr := make([]int, 0)
  3058. var items []*models.ActivityTypeHome
  3059. for _, v := range list {
  3060. item := new(models.ActivityTypeHome)
  3061. if len(v.List) > 0 {
  3062. for i := range v.List {
  3063. activityIds = append(activityIds, v.List[i].ActivityId)
  3064. }
  3065. item.List = v.List
  3066. item.ActivityTypeName = v.ActivityTypeName
  3067. item.ActivityTypeId = v.ActivityTypeId
  3068. item.ImgUrlBg = v.ImgUrlBg
  3069. item.ImgUrl = v.ImgUrl
  3070. item.Resource = v.Resource
  3071. items = append(items, item)
  3072. intArr = append(intArr, len(v.List))
  3073. }
  3074. }
  3075. sort.Sort(sort.Reverse(sort.IntSlice(intArr)))
  3076. // 活动【新】标签Map
  3077. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  3078. if e != nil {
  3079. br.Msg = "获取失败"
  3080. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  3081. return
  3082. }
  3083. for k, v := range list {
  3084. if v.ActivityTypeId == 1 {
  3085. for k2 := range list[k].List {
  3086. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  3087. }
  3088. }
  3089. }
  3090. var itemsNew []*models.ActivityTypeHome
  3091. activityMap := make(map[int]int)
  3092. for _, v := range intArr {
  3093. for _, v2 := range items {
  3094. item := new(models.ActivityTypeHome)
  3095. if len(v2.List) > 0 && v == len(v2.List) && activityMap[v2.ActivityTypeId] == 0 {
  3096. item.List = v2.List
  3097. item.ActivityTypeName = v2.ActivityTypeName
  3098. item.ActivityTypeId = v2.ActivityTypeId
  3099. item.ImgUrlBg = v2.ImgUrlBg
  3100. item.ImgUrl = v2.ImgUrl
  3101. item.Resource = v2.Resource
  3102. itemsNew = append(itemsNew, item)
  3103. activityMap[v2.ActivityTypeId] = len(v2.List)
  3104. }
  3105. }
  3106. }
  3107. //按照像素进行排序
  3108. rowHeight := 83 //每一行的行高
  3109. basicsHeight := 178 // 基础高度
  3110. position := 1 // 初始化位置 ,1,左边, 2 右边
  3111. var leftPx, rightPx int
  3112. for k, v := range itemsNew {
  3113. if leftPx <= rightPx {
  3114. position = 1
  3115. } else {
  3116. position = 2
  3117. }
  3118. itemsNew[k].Position = position
  3119. if position == 1 {
  3120. leftPx += basicsHeight + rowHeight*len(v.List)
  3121. } else {
  3122. rightPx += basicsHeight + rowHeight*len(v.List)
  3123. }
  3124. }
  3125. //记录用户搜索的筛选条件
  3126. item := new(models.CygxActivitySearchHistory)
  3127. item.UserId = user.UserId
  3128. item.Mobile = user.Mobile
  3129. item.CompanyId = user.CompanyId
  3130. item.CompanyName = user.CompanyName
  3131. item.CreateTime = time.Now()
  3132. item.ChartPermissionIds = chartPermissionIds
  3133. item.IsPower = isPower
  3134. item.WhichDay = whichDay
  3135. go models.AddCygxActivitySearchHistory(item)
  3136. resp.List = itemsNew
  3137. br.Ret = 200
  3138. br.Success = true
  3139. br.Msg = "获取成功"
  3140. br.Data = resp
  3141. }
  3142. // @Title 专项产业调研列表
  3143. // @Description 获取专项产业调研列表接口
  3144. // @Param PageSize query int true "每页数据条数"
  3145. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3146. // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
  3147. // @router /special/list [get]
  3148. func (this *ActivityCoAntroller) SpecialList() {
  3149. br := new(models.BaseResponse).Init()
  3150. defer func() {
  3151. this.Data["json"] = br
  3152. this.ServeJSON()
  3153. }()
  3154. user := this.User
  3155. if user == nil {
  3156. br.Msg = "请登录"
  3157. br.ErrMsg = "请登录,SysUser Is Empty"
  3158. return
  3159. }
  3160. uid := user.UserId
  3161. pageSize, _ := this.GetInt("PageSize")
  3162. currentIndex, _ := this.GetInt("CurrentIndex")
  3163. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3164. var startSize int
  3165. if pageSize <= 0 {
  3166. pageSize = utils.PageSize20
  3167. }
  3168. if currentIndex <= 0 {
  3169. currentIndex = 1
  3170. }
  3171. startSize = utils.StartIndex(currentIndex, pageSize)
  3172. var condition string
  3173. var pars []interface{}
  3174. //活动可见限制
  3175. var sqlExport string
  3176. slicePer := strings.Split(permissionStr, ",")
  3177. var permissionSqlStr string
  3178. for _, v := range slicePer {
  3179. if userType == 1 {
  3180. //if v != "研选" {
  3181. if !strings.Contains(v, "研选") {
  3182. permissionSqlStr += "'" + v + "',"
  3183. }
  3184. } else {
  3185. permissionSqlStr += "'" + v + "',"
  3186. }
  3187. }
  3188. //判断客户规模是否属于可见范围的活动
  3189. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3190. if err != nil && err.Error() != utils.ErrNoRow() {
  3191. br.Msg = "获取信息失败"
  3192. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3193. return
  3194. }
  3195. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  3196. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  3197. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  3198. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  3199. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3200. if userType == 2 {
  3201. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3202. }
  3203. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3204. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3205. }
  3206. sqlExport += `) `
  3207. condition += ` AND art.publish_status = 1 `
  3208. condition = ` AND art.publish_status = 1 AND art.label != '' `
  3209. var conditionOr string
  3210. if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  3211. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  3212. }
  3213. if (userType == 5) && strings.Contains(permissionStr, "专家") {
  3214. conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  3215. }
  3216. if userType == 1 {
  3217. conditionOr += ` OR ( 1=1` + condition + permissionSqlStr + `) `
  3218. }
  3219. if companyProduct != nil {
  3220. if companyProduct.Scale != "" {
  3221. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3222. }
  3223. }
  3224. if companyProduct != nil {
  3225. if companyProduct.Scale != "" {
  3226. conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  3227. }
  3228. }
  3229. condition += sqlExport + conditionOr
  3230. total, err := models.GetActivitySpecialCount(condition, pars)
  3231. if err != nil {
  3232. br.Msg = "获取失败"
  3233. br.ErrMsg = "获取失败,Err:" + err.Error()
  3234. return
  3235. }
  3236. list, errList := models.GetCygxActivitySpecialDetailList(condition, pars, uid, startSize, pageSize)
  3237. if errList != nil {
  3238. br.Msg = "获取失败"
  3239. br.ErrMsg = "获取失败,Err:" + errList.Error()
  3240. return
  3241. }
  3242. detail, err := models.GetConfigByCode("city_img_url")
  3243. if err != nil {
  3244. br.Msg = "获取数据失败"
  3245. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  3246. return
  3247. }
  3248. detailChart, err := models.GetConfigByCode("chart_img_url")
  3249. if err != nil {
  3250. br.Msg = "获取数据失败"
  3251. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  3252. return
  3253. }
  3254. addressList := strings.Split(detail.ConfigValue, "{|}")
  3255. mapAddress := make(map[string]string)
  3256. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  3257. mapChart := make(map[string]string)
  3258. var cityName string
  3259. var chartName string
  3260. var imgUrl string
  3261. var imgUrlChart string
  3262. for _, v := range addressList {
  3263. vslice := strings.Split(v, "_")
  3264. cityName = vslice[0]
  3265. imgUrl = vslice[len(vslice)-1]
  3266. mapAddress[cityName] = imgUrl
  3267. }
  3268. for _, v := range chartList {
  3269. vslice := strings.Split(v, "_")
  3270. chartName = vslice[0]
  3271. imgUrlChart = vslice[len(vslice)-1]
  3272. mapChart[chartName] = imgUrlChart
  3273. }
  3274. for k, v := range list {
  3275. list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  3276. if mapChart[v.ChartPermissionName] != "" {
  3277. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  3278. }
  3279. list[k].ActivityTypeName = "专项调研"
  3280. }
  3281. page := paging.GetPaging(currentIndex, pageSize, total)
  3282. resp := new(models.GetCygxActivitySpecialDetailListResp)
  3283. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  3284. if err != nil {
  3285. br.Msg = "获取数据失败!"
  3286. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3287. return
  3288. }
  3289. if count == 1 && user.UserId > 0 {
  3290. resp.IsFollow = true
  3291. }
  3292. if user.Mobile != "" {
  3293. resp.IsBindingMobile = true
  3294. }
  3295. resp.List = list
  3296. resp.Paging = page
  3297. br.Ret = 200
  3298. br.Success = true
  3299. br.Msg = "获取成功"
  3300. br.Data = resp
  3301. }
  3302. // @Title 专项产业调研详情
  3303. // @Description 获取专项产业调研详情接口
  3304. // @Param ActivityId query int true "活动ID"
  3305. // @Success Ret=200 {object} models.CygxActivitySpecialResp
  3306. // @router /special/detail [get]
  3307. func (this *ActivityCoAntroller) SpecialDetail() {
  3308. br := new(models.BaseResponse).Init()
  3309. defer func() {
  3310. this.Data["json"] = br
  3311. this.ServeJSON()
  3312. }()
  3313. user := this.User
  3314. if user == nil {
  3315. br.Msg = "请登录"
  3316. br.ErrMsg = "请登录,用户信息为空"
  3317. br.Ret = 408
  3318. return
  3319. }
  3320. uid := user.UserId
  3321. activityId, _ := this.GetInt("ActivityId")
  3322. if activityId < 1 {
  3323. br.Msg = "请输入活动ID"
  3324. return
  3325. }
  3326. resp := new(models.CygxActivitySpecialResp)
  3327. hasPermission := 0
  3328. activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
  3329. if err != nil && err.Error() != utils.ErrNoRow() {
  3330. br.Msg = "获取信息失败"
  3331. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3332. return
  3333. }
  3334. if activityInfo == nil {
  3335. br.Msg = "活动不存在"
  3336. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  3337. return
  3338. }
  3339. applyCount, err := models.GetApplyRecordCount(uid)
  3340. if err != nil && err.Error() != utils.ErrNoRow() {
  3341. br.Msg = "获取信息失败"
  3342. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3343. return
  3344. }
  3345. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  3346. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  3347. if err != nil && err.Error() != utils.ErrNoRow() {
  3348. br.Msg = "获取信息失败"
  3349. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3350. return
  3351. }
  3352. if user.CompanyId <= 1 {
  3353. //companyDetailStatus = ""
  3354. } else {
  3355. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  3356. if err != nil {
  3357. br.Msg = "获取信息失败"
  3358. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3359. return
  3360. }
  3361. if companyPermission == "" {
  3362. if applyCount > 0 {
  3363. hasPermission = 4
  3364. } else {
  3365. if sellerItem != nil {
  3366. hasPermission = 5
  3367. } else {
  3368. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  3369. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3370. if err != nil && err.Error() != utils.ErrNoRow() {
  3371. br.Msg = "获取信息失败"
  3372. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3373. return
  3374. }
  3375. if sellerItemQy != nil {
  3376. hasPermission = 2
  3377. resp.SellerMobile = sellerItemQy.Mobile
  3378. resp.SellerName = sellerItemQy.RealName
  3379. } else {
  3380. hasPermission = 3
  3381. }
  3382. }
  3383. }
  3384. resp.HasPermission = hasPermission
  3385. resp.OperationMode = "Apply"
  3386. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3387. br.Ret = 200
  3388. br.Success = true
  3389. br.Msg = "获取成功"
  3390. br.Data = resp
  3391. return
  3392. }
  3393. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3394. if err != nil {
  3395. br.Msg = "获取信息失败!"
  3396. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3397. return
  3398. }
  3399. if companyDetail == nil {
  3400. br.Msg = "获取信息失败!"
  3401. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  3402. return
  3403. }
  3404. }
  3405. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3406. if err != nil {
  3407. br.Msg = "获取信息失败"
  3408. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3409. return
  3410. }
  3411. itemAct := new(models.ActivityDetail)
  3412. itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
  3413. noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
  3414. if err != nil {
  3415. br.Msg = "获取信息失败"
  3416. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3417. return
  3418. }
  3419. //获取用户的产业规模,判断是否允许可见
  3420. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3421. if err != nil && err.Error() != utils.ErrNoRow() {
  3422. br.Msg = "获取信息失败"
  3423. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3424. return
  3425. }
  3426. if companyProduct != nil {
  3427. if companyProduct.Scale != "" {
  3428. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  3429. noPower = false
  3430. }
  3431. }
  3432. }
  3433. if noPower {
  3434. br.Msg = "您暂无查看该活动权限"
  3435. br.ErrMsg = "被分享客户不可见,获取信息失败"
  3436. br.IsSendEmail = false
  3437. return
  3438. }
  3439. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  3440. br.Msg = "您暂无查看该活动权限"
  3441. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  3442. return
  3443. }
  3444. //判断是否已经申请过
  3445. if user.CompanyId > 1 {
  3446. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  3447. if err != nil {
  3448. br.Msg = "获取信息失败"
  3449. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  3450. return
  3451. }
  3452. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  3453. //冻结客户
  3454. if err != nil {
  3455. if err.Error() == utils.ErrNoRow() {
  3456. if applyCount > 0 {
  3457. hasPermission = 4
  3458. } else {
  3459. if sellerItem != nil {
  3460. hasPermission = 5
  3461. } else {
  3462. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  3463. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3464. if err != nil && err.Error() != utils.ErrNoRow() {
  3465. br.Msg = "获取信息失败"
  3466. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3467. return
  3468. }
  3469. if sellerItemQy != nil {
  3470. hasPermission = 2
  3471. resp.SellerMobile = sellerItemQy.Mobile
  3472. resp.SellerName = sellerItemQy.RealName
  3473. } else {
  3474. hasPermission = 3
  3475. }
  3476. }
  3477. }
  3478. resp.HasPermission = hasPermission
  3479. resp.OperationMode = "Apply"
  3480. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3481. br.Ret = 200
  3482. br.Success = true
  3483. br.Msg = "获取成功"
  3484. br.Data = resp
  3485. return
  3486. } else {
  3487. br.Msg = "获取信息失败"
  3488. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  3489. return
  3490. }
  3491. }
  3492. var havePower bool
  3493. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  3494. havePower = true
  3495. }
  3496. if havePower {
  3497. hasPermission = 1
  3498. resp.HaqveJurisdiction = true
  3499. } else {
  3500. if permissionStr == "专家" {
  3501. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3502. resp.MsgType = "Type"
  3503. } else {
  3504. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3505. resp.MsgType = "Industry"
  3506. }
  3507. if companyItem.ProductId == 2 {
  3508. resp.SellerMobile = companyItem.Mobile
  3509. resp.SellerName = companyItem.SellerName
  3510. resp.OperationMode = "Call"
  3511. hasPermission = 2
  3512. } else {
  3513. hasPermission = 5
  3514. }
  3515. }
  3516. } else { //潜在客户
  3517. if applyCount > 0 {
  3518. hasPermission = 4
  3519. } else {
  3520. if sellerItem != nil {
  3521. hasPermission = 5
  3522. } else {
  3523. hasPermission = 3
  3524. }
  3525. }
  3526. resp.OperationMode = "Apply"
  3527. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  3528. }
  3529. if hasPermission == 1 {
  3530. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  3531. if err != nil {
  3532. br.Msg = "获取数据失败!"
  3533. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3534. return
  3535. }
  3536. if count == 1 {
  3537. resp.IsFollow = true
  3538. }
  3539. activityInfo.ActivityTypeName = "专项调研"
  3540. resp.Detail = activityInfo
  3541. }
  3542. resp.HasPermission = hasPermission
  3543. br.Ret = 200
  3544. br.Success = true
  3545. br.Msg = "获取成功"
  3546. br.Data = resp
  3547. }
  3548. // @Title 感兴趣、不感兴趣
  3549. // @Description 感兴趣、不感兴趣接口
  3550. // @Param request body models.ActivityIdRep true "type json string"
  3551. // @Success Ret=200 {object} models.SignupSpecialStatus
  3552. // @router /special/signup/add [post]
  3553. func (this *ActivityCoAntroller) SpecialSignupAdd() {
  3554. br := new(models.BaseResponse).Init()
  3555. defer func() {
  3556. this.Data["json"] = br
  3557. this.ServeJSON()
  3558. }()
  3559. user := this.User
  3560. if user == nil {
  3561. br.Msg = "请登录"
  3562. br.ErrMsg = "请登录,用户信息为空"
  3563. br.Ret = 408
  3564. return
  3565. }
  3566. uid := user.UserId
  3567. var req models.ActivityIdRep
  3568. resp := new(models.SignupSpecialStatus)
  3569. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3570. if err != nil {
  3571. br.Msg = "参数解析异常!"
  3572. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3573. return
  3574. }
  3575. activityId := req.ActivityId
  3576. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  3577. if activityInfo == nil {
  3578. br.Msg = "操作失败"
  3579. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3580. return
  3581. }
  3582. if errInfo != nil {
  3583. br.Msg = "操作失败"
  3584. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3585. return
  3586. }
  3587. havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
  3588. if err != nil {
  3589. br.Msg = "获取信息失败"
  3590. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3591. return
  3592. }
  3593. //判断有没有对应的权限,如果没有则给出对应的状态码
  3594. if havePower {
  3595. resp.HasPermission = 1
  3596. total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
  3597. if err != nil {
  3598. br.Msg = "获取信息失败"
  3599. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  3600. return
  3601. }
  3602. //判断是删除还是添加
  3603. if total == 0 {
  3604. //获取销售信息
  3605. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3606. if err != nil {
  3607. br.Msg = "操作失败"
  3608. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3609. return
  3610. }
  3611. item := new(models.CygxActivitySpecialSignup)
  3612. item.UserId = uid
  3613. item.RealName = user.RealName
  3614. item.ActivityId = activityId
  3615. item.CreateTime = time.Now()
  3616. item.Mobile = user.Mobile
  3617. item.Email = user.Email
  3618. item.CompanyId = user.CompanyId
  3619. item.CompanyName = user.CompanyName
  3620. if sellerItem != nil {
  3621. item.SellerName = sellerItem.RealName
  3622. }
  3623. err = models.AddCygxActivitySpecialSignup(item)
  3624. if err != nil {
  3625. br.Msg = "操作失败"
  3626. br.ErrMsg = "操作失败,Err:" + err.Error()
  3627. return
  3628. }
  3629. resp.Status = 1
  3630. resp.PopupMsg = "感谢反馈"
  3631. resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
  3632. //给所属销售发送消息
  3633. if sellerItem.Mobile != "" {
  3634. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  3635. if openIpItem != nil && openIpItem.OpenId != "" {
  3636. if sellerItem != nil {
  3637. go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
  3638. }
  3639. }
  3640. }
  3641. // 给芳姐发消息
  3642. cnf, _ := models.GetConfigByCode("tpl_msg")
  3643. actList, _ := models.GetActivityListSpecialByActivityId(activityId)
  3644. if cnf != nil {
  3645. openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
  3646. if openIpItem != nil && openIpItem.OpenId != "" {
  3647. if len(actList) == 5 {
  3648. var companyName string
  3649. for _, v := range actList {
  3650. companyName += "【" + v.CompanyName + "】"
  3651. }
  3652. go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
  3653. }
  3654. }
  3655. }
  3656. //感兴趣人数到达10人时,模板消息发送给活动负责人
  3657. if len(actList) == 10 {
  3658. go services.SendWxMsgActivitySpecial10(activityInfo)
  3659. }
  3660. //用户专项调研操作行为,模板消息推送
  3661. go services.SpecialActivityUserRemind(user, activityInfo, 1)
  3662. } else {
  3663. err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
  3664. if err != nil {
  3665. br.Msg = "操作失败"
  3666. br.ErrMsg = "操作失败,Err:" + err.Error()
  3667. return
  3668. }
  3669. resp.Status = 2
  3670. }
  3671. } else {
  3672. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  3673. if err != nil {
  3674. br.Msg = "获取信息失败"
  3675. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3676. return
  3677. }
  3678. resp.PopupMsg = popupMsg
  3679. resp.HasPermission = hasPermission
  3680. resp.SellerName = sellerName
  3681. resp.SellerMobile = sellerMobile
  3682. }
  3683. br.Ret = 200
  3684. br.Success = true
  3685. br.Msg = "操作成功"
  3686. br.Data = resp
  3687. }
  3688. // @Title 新调研通知取消跟添加
  3689. // @Description 新调研通知取消跟添加接口
  3690. // @Param request body models.ArticleCollectResp true "type json string"
  3691. // @Success 200
  3692. // @router /special/follow [post]
  3693. func (this *ActivityCoAntroller) SpecialMsg() {
  3694. br := new(models.BaseResponse).Init()
  3695. defer func() {
  3696. this.Data["json"] = br
  3697. this.ServeJSON()
  3698. }()
  3699. user := this.User
  3700. if user == nil {
  3701. br.Msg = "请重新登录"
  3702. br.Ret = 408
  3703. return
  3704. }
  3705. resp := new(models.ArticleCollectResp)
  3706. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  3707. if err != nil {
  3708. br.Msg = "获取数据失败!"
  3709. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3710. return
  3711. }
  3712. if count == 0 {
  3713. item := new(models.CygxUserFollowSpecial)
  3714. item.UserId = user.UserId
  3715. item.RealName = user.RealName
  3716. item.CreateTime = time.Now()
  3717. item.Mobile = user.Mobile
  3718. item.Email = user.Email
  3719. item.CompanyId = user.CompanyId
  3720. item.CompanyName = user.CompanyName
  3721. item.CreateTime = time.Now()
  3722. err := models.AddUserFollowSpecial(item)
  3723. if err != nil {
  3724. br.Msg = "操作失败!"
  3725. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3726. return
  3727. }
  3728. resp.Status = 1
  3729. } else {
  3730. err := models.DeleteCygxUserFollowSpecial(user.UserId)
  3731. if err != nil {
  3732. br.Msg = "操作失败!"
  3733. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3734. return
  3735. }
  3736. resp.Status = 2
  3737. }
  3738. br.Ret = 200
  3739. br.Data = resp
  3740. br.Success = true
  3741. br.Msg = "操作成功!"
  3742. }
  3743. // @Title 活动类型下的主题列表(6.0Pc版本)
  3744. // @Description 获取活动类型下的主题列表接口(6.0Pc版本)
  3745. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  3746. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  3747. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  3748. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  3749. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  3750. // @Success 200 {object} models.ActivityTypeListHomeRespPc
  3751. // @router /labelTypeListV6Pc [get]
  3752. func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
  3753. br := new(models.BaseResponse).Init()
  3754. defer func() {
  3755. this.Data["json"] = br
  3756. this.ServeJSON()
  3757. }()
  3758. user := this.User
  3759. if user == nil {
  3760. br.Msg = "请登录"
  3761. br.ErrMsg = "请登录,SysUser Is Empty"
  3762. return
  3763. }
  3764. pageSize, _ := this.GetInt("PageSize")
  3765. isPower, _ := this.GetInt("IsPower")
  3766. playBack, _ := this.GetInt("PlayBack")
  3767. //currentIndex, _ := this.GetInt("CurrentIndex")
  3768. chartPermissionIds := this.GetString("ChartPermissionIds")
  3769. //activityTypeIds := this.GetString("ActivityTypeIds")
  3770. whichDay := this.GetString("WhichDay")
  3771. activeState := this.GetString("ActiveState")
  3772. //入参为 undefined 时的处理
  3773. if chartPermissionIds == "undefined" {
  3774. chartPermissionIds = ""
  3775. }
  3776. // 查研观向7.4-始终查询宏观的活动
  3777. if chartPermissionIds != "" {
  3778. chartPermissionIds += ",1"
  3779. }
  3780. if whichDay == "undefined" {
  3781. whichDay = ""
  3782. }
  3783. if activeState == "undefined" || activeState == "" || activeState == "1" {
  3784. activeState = "1,2"
  3785. }
  3786. //adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
  3787. //if err != nil {
  3788. // br.Msg = "获取失败"
  3789. // br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
  3790. // return
  3791. //}
  3792. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  3793. if err != nil {
  3794. br.Msg = "获取失败"
  3795. br.ErrMsg = "获取失败,Err:" + err.Error()
  3796. return
  3797. }
  3798. //isMaker := user.IsMaker
  3799. var startSize int
  3800. pageSize = 8
  3801. var sortTime string
  3802. var pars []interface{}
  3803. //活动可见限制
  3804. slicePer := strings.Split(permissionStr, ",")
  3805. var permissionNameStr string
  3806. for _, v := range slicePer {
  3807. if userType == 1 {
  3808. //if v != "研选" {
  3809. if !strings.Contains(v, "研选") {
  3810. permissionNameStr += "'" + v + "',"
  3811. }
  3812. } else {
  3813. permissionNameStr += "'" + v + "',"
  3814. }
  3815. }
  3816. permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
  3817. permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
  3818. permissionNameStr = strings.TrimRight(permissionNameStr, ",")
  3819. // 查研观向7.4-始终查询宏观的权限(无论是否有权限)
  3820. if permissionNameStr == `` {
  3821. permissionNameStr = `'宏观'`
  3822. } else {
  3823. permissionNameStr += `, '宏观'`
  3824. }
  3825. list, err := models.GetActivityTypeHomeListPc()
  3826. if err != nil {
  3827. br.Msg = "获取失败"
  3828. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  3829. return
  3830. }
  3831. //判断客户规模是否属于可见范围的活动
  3832. //companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  3833. //if err != nil && err.Error() != utils.ErrNoRow() {
  3834. // br.Msg = "获取信息失败"
  3835. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  3836. // return
  3837. //}
  3838. var sqlExport string
  3839. //处理专家权限的查询
  3840. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  3841. if userType == 2 {
  3842. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  3843. }
  3844. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  3845. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  3846. }
  3847. sqlExport += `) `
  3848. resp := new(models.ActivityTypeListHomeRespPc)
  3849. for k, v := range list {
  3850. // 如果是C类电话会就不展示内容,且合并到分析师电话会
  3851. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  3852. continue
  3853. }
  3854. var condition string
  3855. conditionActivity, err := services.GetActivityonditionList(user, strconv.Itoa(v.ActivityTypeId), chartPermissionIds, whichDay, activeState, "", isPower, 1, "", playBack)
  3856. if err != nil && err.Error() != utils.ErrNoRow() {
  3857. br.Msg = "获取失败"
  3858. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  3859. return
  3860. }
  3861. //condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  3862. condition += `AND art.is_limit_people = 1 AND art.yidong_activity_id = '' ` + conditionActivity
  3863. sortTime = ` mintimesort ASC `
  3864. labelList, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  3865. if err != nil {
  3866. br.Msg = "获取失败"
  3867. br.ErrMsg = "获取失败,Err:" + err.Error()
  3868. return
  3869. }
  3870. //标签字段关联的产业与标签处理
  3871. for k2, v2 := range labelList {
  3872. labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
  3873. labelList[k2].Resource = 1
  3874. }
  3875. list[k].List = labelList
  3876. list[k].Resource = 1
  3877. }
  3878. if whichDay == "" {
  3879. //查询专项产业调研展示权限
  3880. //var scale string
  3881. //if companyProduct != nil {
  3882. // scale = companyProduct.Scale
  3883. //}
  3884. speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
  3885. if err != nil {
  3886. br.Msg = "获取失败"
  3887. br.ErrMsg = "获取失败,Err:" + err.Error()
  3888. return
  3889. }
  3890. if len(speciaItem.List) > 0 {
  3891. itemList := new(models.ActivityTypeHomePc)
  3892. itemList.ActivityTypeName = "专项产业调研"
  3893. itemList.Resource = 2
  3894. itemList.List = speciaItem.List
  3895. itemList.ActivityTypeId = 7
  3896. itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
  3897. itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
  3898. list = append(list, itemList)
  3899. }
  3900. }
  3901. // 查研观向7.4-活动【新】标签
  3902. activityIds := make([]int, 0)
  3903. for _, v := range list {
  3904. if len(v.List) > 0 {
  3905. for i := range v.List {
  3906. activityIds = append(activityIds, v.List[i].ActivityId)
  3907. }
  3908. }
  3909. }
  3910. newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
  3911. if e != nil {
  3912. br.Msg = "获取失败"
  3913. br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
  3914. return
  3915. }
  3916. for k := range list {
  3917. for k2 := range list[k].List {
  3918. list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
  3919. }
  3920. }
  3921. //记录用户搜索的筛选条件
  3922. {
  3923. item := new(models.CygxActivitySearchHistory)
  3924. item.UserId = user.UserId
  3925. item.Mobile = user.Mobile
  3926. item.CompanyId = user.CompanyId
  3927. item.CompanyName = user.CompanyName
  3928. item.CreateTime = time.Now()
  3929. item.ChartPermissionIds = chartPermissionIds
  3930. item.IsPower = isPower
  3931. item.WhichDay = whichDay
  3932. go models.AddCygxActivitySearchHistory(item)
  3933. }
  3934. resp.List = list
  3935. br.Ret = 200
  3936. br.Success = true
  3937. br.Msg = "获取成功"
  3938. br.Data = resp
  3939. }
  3940. // @Title 预约纪要
  3941. // @Description 预约纪要接口
  3942. // @Param request body models.ActivityIdRep true "type json string"
  3943. // @Success Ret=200 {object} models.AppointmentResp
  3944. // @router /appointment/add [post]
  3945. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  3946. br := new(models.BaseResponse).Init()
  3947. defer func() {
  3948. this.Data["json"] = br
  3949. this.ServeJSON()
  3950. }()
  3951. user := this.User
  3952. if user == nil {
  3953. br.Msg = "请登录"
  3954. br.ErrMsg = "请登录,用户信息为空"
  3955. br.Ret = 408
  3956. return
  3957. }
  3958. uid := user.UserId
  3959. signupStatus := "Success"
  3960. var req models.ActivityIdRep
  3961. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3962. if err != nil {
  3963. br.Msg = "参数解析异常!"
  3964. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3965. return
  3966. }
  3967. activityId := req.ActivityId
  3968. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  3969. if activityInfo == nil {
  3970. br.Msg = "操作失败"
  3971. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  3972. return
  3973. }
  3974. if errInfo != nil {
  3975. br.Msg = "操作失败"
  3976. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3977. return
  3978. }
  3979. //判断是否已经预约过
  3980. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  3981. if err != nil {
  3982. br.Msg = "获取失败"
  3983. br.ErrMsg = "获取失败,Err:" + err.Error()
  3984. return
  3985. }
  3986. if totalAppointment > 0 {
  3987. br.Msg = "您已预约!"
  3988. return
  3989. }
  3990. //判断是否已经申请过
  3991. applyCount, err := models.GetApplyRecordCount(uid)
  3992. if err != nil && err.Error() != utils.ErrNoRow() {
  3993. br.Msg = "获取信息失败"
  3994. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  3995. return
  3996. }
  3997. //获取销售信息
  3998. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  3999. if err != nil && err.Error() != utils.ErrNoRow() {
  4000. br.Msg = "申请失败"
  4001. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4002. return
  4003. }
  4004. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  4005. item := new(models.CygxActivityAppointment)
  4006. resp := new(models.SignupStatus)
  4007. //处理冻结客户,流失客户的弹窗提示
  4008. if user.CompanyId > 1 {
  4009. sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
  4010. if err != nil && err.Error() != utils.ErrNoRow() {
  4011. br.Msg = "获取信息失败"
  4012. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4013. return
  4014. }
  4015. if sellerMobile != "" {
  4016. resp.HasPermission = 2
  4017. resp.SellerMobile = sellerMobile
  4018. resp.SellerName = sellerRealName
  4019. br.Ret = 200
  4020. br.Success = true
  4021. br.Msg = "获取成功"
  4022. br.Data = resp
  4023. return
  4024. }
  4025. }
  4026. hasPermission := 0
  4027. var companyDetailStatus string
  4028. if user.CompanyId <= 1 {
  4029. companyDetailStatus = ""
  4030. } else {
  4031. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  4032. if err != nil {
  4033. br.Msg = "获取信息失败"
  4034. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4035. return
  4036. }
  4037. if companyPermission == "" {
  4038. if applyCount > 0 {
  4039. hasPermission = 4
  4040. } else {
  4041. if sellerItem != nil {
  4042. hasPermission = 5
  4043. } else {
  4044. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  4045. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  4046. if err != nil && err.Error() != utils.ErrNoRow() {
  4047. br.Msg = "获取信息失败"
  4048. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  4049. return
  4050. }
  4051. if sellerItemQy != nil {
  4052. hasPermission = 2
  4053. resp.SellerMobile = sellerItemQy.Mobile
  4054. resp.SellerName = sellerItemQy.RealName
  4055. } else {
  4056. hasPermission = 3
  4057. }
  4058. }
  4059. }
  4060. resp.ActivityId = activityId
  4061. resp.HasPermission = hasPermission
  4062. resp.OperationMode = "Apply"
  4063. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4064. br.Ret = 200
  4065. br.Success = true
  4066. br.Msg = "获取成功"
  4067. br.Data = resp
  4068. return
  4069. }
  4070. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  4071. if err != nil {
  4072. br.Msg = "获取信息失败!"
  4073. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  4074. return
  4075. }
  4076. if companyDetail == nil {
  4077. br.Msg = "获取信息失败!"
  4078. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  4079. return
  4080. }
  4081. companyDetailStatus = companyDetail.Status
  4082. }
  4083. var userType int
  4084. var permissionStr string
  4085. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  4086. if err != nil {
  4087. br.Msg = "获取信息失败!"
  4088. br.ErrMsg = "获取失败,Err:" + err.Error()
  4089. return
  4090. }
  4091. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  4092. br.Msg = "您暂无查看该活动权限"
  4093. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  4094. return
  4095. }
  4096. if user.CompanyId > 1 {
  4097. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  4098. //冻结客户
  4099. if err != nil {
  4100. if err.Error() == utils.ErrNoRow() {
  4101. //如果是FICC的客户类型,则默认他申请过
  4102. if applyCount > 0 {
  4103. hasPermission = 4
  4104. } else {
  4105. if sellerItem != nil {
  4106. hasPermission = 5
  4107. } else {
  4108. hasPermission = 3
  4109. }
  4110. }
  4111. resp.ActivityId = activityId
  4112. resp.HasPermission = hasPermission
  4113. resp.OperationMode = "Apply"
  4114. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4115. br.Ret = 200
  4116. br.Success = true
  4117. br.Msg = "获取成功"
  4118. br.Data = resp
  4119. return
  4120. } else {
  4121. br.Msg = "获取信息失败"
  4122. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  4123. return
  4124. }
  4125. }
  4126. havePower, err := services.GetHavePower(activityInfo, permissionStr, companyDetailStatus, userType)
  4127. if err != nil {
  4128. br.Msg = "获取信息失败!"
  4129. br.ErrMsg = "获取失败,Err:" + err.Error()
  4130. return
  4131. }
  4132. if havePower {
  4133. hasPermission = 1
  4134. signupStatus = "Success"
  4135. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  4136. if errMeeting != nil {
  4137. br.Msg = "获取失败"
  4138. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  4139. return
  4140. }
  4141. if totalMeeting > 0 {
  4142. br.Msg = "您已预约,请勿重复预约"
  4143. return
  4144. }
  4145. var sellerName string
  4146. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  4147. if err != nil {
  4148. br.Msg = "报名失败!"
  4149. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  4150. return
  4151. }
  4152. item.UserId = uid
  4153. item.ActivityId = activityId
  4154. item.CreateTime = time.Now()
  4155. item.Mobile = user.Mobile
  4156. item.Email = user.Email
  4157. item.CompanyId = user.CompanyId
  4158. item.CompanyName = user.CompanyName
  4159. item.SellerName = sellerName
  4160. item.RealName = user.RealName
  4161. err = models.AddCygxActivityAppointment(item)
  4162. if err != nil {
  4163. br.Msg = "操作失败"
  4164. br.ErrMsg = "操作失败,Err:" + err.Error()
  4165. return
  4166. }
  4167. resp.HaqveJurisdiction = true
  4168. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  4169. go services.ActivityUserRemind(user, activityInfo, 3)
  4170. } else {
  4171. if companyItem.ProductId == 2 {
  4172. hasPermission = 2
  4173. resp.SellerMobile = companyItem.Mobile
  4174. resp.SellerName = companyItem.SellerName
  4175. resp.MsgType = "Type"
  4176. resp.OperationMode = "Call"
  4177. if permissionStr == "专家" {
  4178. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4179. resp.MsgType = "Type"
  4180. } else {
  4181. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  4182. resp.MsgType = "Industry"
  4183. }
  4184. } else {
  4185. hasPermission = 5
  4186. }
  4187. }
  4188. } else { //潜在客户
  4189. if applyCount > 0 {
  4190. hasPermission = 4
  4191. } else {
  4192. if sellerItem != nil {
  4193. hasPermission = 5
  4194. } else {
  4195. hasPermission = 3
  4196. }
  4197. }
  4198. resp.OperationMode = "Apply"
  4199. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  4200. }
  4201. resp.HasPermission = hasPermission
  4202. resp.SignupStatus = signupStatus
  4203. resp.ActivityId = activityId
  4204. var total int
  4205. total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  4206. if err != nil {
  4207. br.Msg = "获取信息失败"
  4208. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  4209. return
  4210. }
  4211. if total <= 1 {
  4212. resp.GoFollow = true
  4213. }
  4214. br.Ret = 200
  4215. br.Success = true
  4216. if hasPermission == 1 {
  4217. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  4218. resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  4219. }
  4220. br.Data = resp
  4221. }
  4222. // @Title 取消预约纪要
  4223. // @Description 取消预约纪要接口
  4224. // @Param request body models.ActivityIdRep true "type json string"
  4225. // @Success Ret=200 {object} models.SignupStatus
  4226. // @router /appointment/cancel [post]
  4227. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  4228. br := new(models.BaseResponse).Init()
  4229. defer func() {
  4230. this.Data["json"] = br
  4231. this.ServeJSON()
  4232. }()
  4233. user := this.User
  4234. if user == nil {
  4235. br.Msg = "请登录"
  4236. br.ErrMsg = "请登录,用户信息为空"
  4237. br.Ret = 408
  4238. return
  4239. }
  4240. uid := user.UserId
  4241. var req models.ActivityIdRep
  4242. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4243. if err != nil {
  4244. br.Msg = "参数解析异常!"
  4245. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4246. return
  4247. }
  4248. activityId := req.ActivityId
  4249. signupStatus := "Success"
  4250. item := new(models.CygxActivityAppointment)
  4251. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  4252. if activityInfo == nil {
  4253. br.Msg = "操作失败"
  4254. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4255. return
  4256. }
  4257. if errInfo != nil {
  4258. br.Msg = "操作失败"
  4259. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4260. return
  4261. }
  4262. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  4263. if err != nil {
  4264. br.Msg = "获取失败"
  4265. br.ErrMsg = "获取失败,Err:" + err.Error()
  4266. return
  4267. }
  4268. if total == 0 {
  4269. br.Msg = "您暂未预约该纪要"
  4270. return
  4271. }
  4272. item.UserId = uid
  4273. item.ActivityId = activityId
  4274. item.CreateTime = time.Now()
  4275. item.Mobile = user.Mobile
  4276. item.Email = user.Email
  4277. item.CompanyId = user.CompanyId
  4278. item.CompanyName = user.CompanyName
  4279. _, errSignup := models.CancelcygxActivityAppointment(item)
  4280. if errSignup != nil {
  4281. br.Msg = "操作失败"
  4282. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  4283. return
  4284. }
  4285. resp := new(models.SignupStatus)
  4286. resp.SignupStatus = signupStatus
  4287. resp.ActivityId = activityId
  4288. br.Ret = 200
  4289. br.Success = true
  4290. br.Msg = "已取消"
  4291. br.Data = resp
  4292. }
  4293. // @Title 记录用户浏览音频回放接口
  4294. // @Description 记录用户浏览音频回放接口
  4295. // @Param request body models.ActivityIdRep true "type json string"
  4296. // @Success Ret=200 {object} models.AppointmentResp
  4297. // @router /voiceHistory/add [post]
  4298. func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
  4299. br := new(models.BaseResponse).Init()
  4300. defer func() {
  4301. this.Data["json"] = br
  4302. this.ServeJSON()
  4303. }()
  4304. user := this.User
  4305. if user == nil {
  4306. br.Msg = "请登录"
  4307. br.ErrMsg = "请登录,用户信息为空"
  4308. br.Ret = 408
  4309. return
  4310. }
  4311. uid := user.UserId
  4312. var req models.ActivityIdRep
  4313. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4314. if err != nil {
  4315. br.Msg = "参数解析异常!"
  4316. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4317. return
  4318. }
  4319. activityId := req.ActivityId
  4320. playSeconds := req.PlaySeconds
  4321. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  4322. if activityInfo == nil {
  4323. br.Msg = "操作失败"
  4324. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4325. return
  4326. }
  4327. if errInfo != nil {
  4328. br.Msg = "操作失败"
  4329. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4330. return
  4331. }
  4332. var sellerName string
  4333. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  4334. if err != nil {
  4335. br.Msg = "报名失败!"
  4336. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  4337. return
  4338. }
  4339. item := models.CygxActivityVoiceHistory{
  4340. ActivityId: activityId,
  4341. UserId: uid,
  4342. CreateTime: time.Now(),
  4343. Mobile: user.Mobile,
  4344. Email: user.Email,
  4345. CompanyId: user.CompanyId,
  4346. CompanyName: user.CompanyName,
  4347. RealName: user.RealName,
  4348. SellerName: sellerName,
  4349. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  4350. ModifyTime: time.Now(),
  4351. }
  4352. if playSeconds != 0 {
  4353. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  4354. if err != nil {
  4355. br.Msg = "操作失败"
  4356. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  4357. return
  4358. }
  4359. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  4360. if err != nil {
  4361. br.Msg = "更新失败"
  4362. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  4363. return
  4364. }
  4365. } else {
  4366. err = models.AddCygxActivityVoiceHistory(&item)
  4367. if err != nil {
  4368. br.Msg = "操作失败"
  4369. br.ErrMsg = "操作失败,Err:" + err.Error()
  4370. return
  4371. }
  4372. err = models.UpdateCygxActivityVoiceCounts(activityId)
  4373. if err != nil {
  4374. br.Msg = "更新失败"
  4375. br.ErrMsg = "更新失败,Err:" + err.Error()
  4376. return
  4377. }
  4378. }
  4379. br.Ret = 200
  4380. br.Success = true
  4381. br.Msg = "操作成功"
  4382. return
  4383. }
  4384. // @Title 记录用户浏览视频回放接口
  4385. // @Description 记录用户浏览音频回放接口
  4386. // @Param request body models.ActivityIdRep true "type json string"
  4387. // @Success Ret=200 {object} models.AppointmentResp
  4388. // @router /videoHistory/add [post]
  4389. func (this *ActivityCoAntroller) ActivityVideoHistoryAdd() {
  4390. br := new(models.BaseResponse).Init()
  4391. defer func() {
  4392. this.Data["json"] = br
  4393. this.ServeJSON()
  4394. }()
  4395. user := this.User
  4396. if user == nil {
  4397. br.Msg = "请登录"
  4398. br.ErrMsg = "请登录,用户信息为空"
  4399. br.Ret = 408
  4400. return
  4401. }
  4402. uid := user.UserId
  4403. var req models.ActivityIdRep
  4404. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  4405. if err != nil {
  4406. br.Msg = "参数解析异常!"
  4407. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  4408. return
  4409. }
  4410. activityId := req.ActivityId
  4411. activityInfo, errInfo := models.GetCygxActivityVideoByActivityId(activityId)
  4412. if activityInfo == nil {
  4413. br.Msg = "操作失败"
  4414. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  4415. return
  4416. }
  4417. if errInfo != nil {
  4418. br.Msg = "操作失败"
  4419. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  4420. return
  4421. }
  4422. var sellerName string
  4423. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  4424. if err != nil {
  4425. br.Msg = "报名失败!"
  4426. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  4427. return
  4428. }
  4429. item := models.CygxActivityVideoHistory{
  4430. ActivityId: activityId,
  4431. VideoId: activityInfo.VideoId,
  4432. UserId: uid,
  4433. CreateTime: time.Now(),
  4434. Mobile: user.Mobile,
  4435. Email: user.Email,
  4436. CompanyId: user.CompanyId,
  4437. CompanyName: user.CompanyName,
  4438. RealName: user.RealName,
  4439. SellerName: sellerName,
  4440. ModifyTime: time.Now(),
  4441. }
  4442. err = models.AddCygxActivityVideoHistory(&item)
  4443. if err != nil {
  4444. br.Msg = "操作失败"
  4445. br.ErrMsg = "操作失败,Err:" + err.Error()
  4446. return
  4447. }
  4448. err = models.UpdateActivityVideoCounts(activityId)
  4449. if err != nil {
  4450. br.Msg = "更新失败"
  4451. br.ErrMsg = "更新失败,Err:" + err.Error()
  4452. return
  4453. }
  4454. br.Ret = 200
  4455. br.Success = true
  4456. br.Msg = "操作成功"
  4457. return
  4458. }
  4459. // @Title 活动、专项调研搜索
  4460. // @Description 活动、专项调研搜索接口
  4461. // @Param PageSize query int true "每页数据条数"
  4462. // @Param CurrentIndex query int true "当前页页码,从1开始"
  4463. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  4464. // @Success 200 {object} models.GetCygxActivityListRep
  4465. // @router /listSearch [get]
  4466. func (this *ActivityCoAntroller) ActivityListSearch() {
  4467. br := new(models.BaseResponse).Init()
  4468. defer func() {
  4469. this.Data["json"] = br
  4470. this.ServeJSON()
  4471. }()
  4472. user := this.User
  4473. if user == nil {
  4474. br.Msg = "请登录"
  4475. br.ErrMsg = "请登录,SysUser Is Empty"
  4476. return
  4477. }
  4478. pageSize, _ := this.GetInt("PageSize")
  4479. currentIndex, _ := this.GetInt("CurrentIndex")
  4480. source, _ := this.GetInt("Source")
  4481. keyWord := this.GetString("KeyWord")
  4482. playBack, _ := this.GetInt("PlayBack")
  4483. var startSize int
  4484. if pageSize <= 0 {
  4485. pageSize = utils.PageSize20
  4486. }
  4487. if currentIndex <= 0 {
  4488. currentIndex = 1
  4489. }
  4490. startSize = utils.StartIndex(currentIndex, pageSize)
  4491. var condition string
  4492. //活动可见限制
  4493. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyWord, playBack)
  4494. if err != nil && err.Error() != utils.ErrNoRow() {
  4495. br.Msg = "获取失败"
  4496. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  4497. return
  4498. }
  4499. if source == 1 {
  4500. condition += ` AND art.yidong_activity_id = '' `
  4501. }
  4502. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  4503. list, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord)
  4504. if err != nil {
  4505. br.Msg = "获取失败"
  4506. br.ErrMsg = "获取失败,Err:" + err.Error()
  4507. return
  4508. }
  4509. page := paging.GetPaging(currentIndex, pageSize, total)
  4510. resp := new(models.GetCygxActivityListRep)
  4511. //添加活动搜索记录
  4512. if keyWord != "" {
  4513. go services.AddActivitykeyWordSearch(keyWord, user)
  4514. }
  4515. resp.Paging = page
  4516. resp.List = list
  4517. br.Ret = 200
  4518. br.Success = true
  4519. br.Msg = "获取成功"
  4520. br.Data = resp
  4521. }
  4522. // @Title 已结束的活动
  4523. // @Description 获取已结束的活动接口
  4524. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  4525. // @Param WhichDay query string false "哪一天 1本周、2上周,3本月,4上月 可多选"
  4526. // @Param IsPower query string false "是否选择有权限行业 ,1是 0 否 默认0"
  4527. // @Param TypeName query string false "电话会类型 ,1专家电话会 2分析师电话会"
  4528. // @Success 200 {object} models.GetCygxActivityLabelListRep
  4529. // @router /overActivityList [get]
  4530. func (this *ActivityCoAntroller) OverActivityList() {
  4531. br := new(models.BaseResponse).Init()
  4532. defer func() {
  4533. this.Data["json"] = br
  4534. this.ServeJSON()
  4535. }()
  4536. user := this.User
  4537. if user == nil {
  4538. br.Msg = "请登录"
  4539. br.ErrMsg = "请登录,SysUser Is Empty"
  4540. return
  4541. }
  4542. isPower, _ := this.GetInt("IsPower")
  4543. chartPermissionIds := this.GetString("ChartPermissionIds")
  4544. whichDay := this.GetString("WhichDay")
  4545. typeName := this.GetString("TypeName")
  4546. //入参为 undefined 时的处理
  4547. if chartPermissionIds == "undefined" {
  4548. chartPermissionIds = ""
  4549. }
  4550. if whichDay == "undefined" {
  4551. whichDay = ""
  4552. }
  4553. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  4554. if err != nil {
  4555. br.Msg = "获取失败"
  4556. br.ErrMsg = "获取失败,Err:" + err.Error()
  4557. return
  4558. }
  4559. var startSize, pageSize int
  4560. pageSize = 24
  4561. var condition string
  4562. var sortTime string
  4563. //var conditionStatus string
  4564. var pars []interface{}
  4565. //活动可见限制
  4566. var sqlExport string
  4567. resp := new(models.GetCygxActivityLabelListRep)
  4568. slicePer := strings.Split(permissionStr, ",")
  4569. var permissionSqlStr string
  4570. for _, v := range slicePer {
  4571. if userType == 1 {
  4572. //if v != "研选" {
  4573. if !strings.Contains(v, "研选") {
  4574. permissionSqlStr += "'" + v + "',"
  4575. }
  4576. } else {
  4577. permissionSqlStr += "'" + v + "',"
  4578. }
  4579. }
  4580. permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
  4581. permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
  4582. permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
  4583. permissionSqlStr = ` AND art.chart_permission_name IN (` + permissionSqlStr + `)`
  4584. sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
  4585. if userType == 2 {
  4586. sqlExport += ` OR art.customer_type_ids LIKE '%3%' `
  4587. }
  4588. if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
  4589. sqlExport += ` OR art.customer_type_ids LIKE '%4%' `
  4590. }
  4591. sqlExport += `) `
  4592. ////进行中的活动
  4593. //condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 2 `
  4594. //var conditionOr string
  4595. //if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  4596. // conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  4597. //}
  4598. //if (userType == 5) && strings.Contains(permissionStr, "专家") {
  4599. // conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  4600. //}
  4601. //if userType == 1 {
  4602. // conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  4603. //} else {
  4604. // conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  4605. //}
  4606. ////判断客户规模是否属于可见范围的活动
  4607. //companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  4608. //if err != nil && err.Error() != utils.ErrNoRow() {
  4609. // br.Msg = "获取信息失败"
  4610. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  4611. // return
  4612. //}
  4613. //
  4614. //if companyProduct != nil {
  4615. // if companyProduct.Scale != "" {
  4616. // conditionOr += ` OR ( art.scale LIKE '%` + companyProduct.Scale + `%' ` + condition + `) `
  4617. // }
  4618. //}
  4619. //condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  4620. //
  4621. ////进行中的活动
  4622. //sortTime = ` mintimesort ASC `
  4623. //list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  4624. //if errList != nil {
  4625. // br.Msg = "获取失败"
  4626. // br.ErrMsg = "获取失败,Err:" + errList.Error()
  4627. // return
  4628. //}
  4629. //已结束的活动
  4630. var conditionOr string
  4631. conditionOr = ""
  4632. condition = ` AND art.publish_status = 1 AND art.label != '' AND art.active_state = 3 `
  4633. //if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
  4634. // conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%' ` + condition + `) `
  4635. //}
  4636. //if (userType == 5) && strings.Contains(permissionStr, "专家") {
  4637. // conditionOr += ` OR ( art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%' ` + condition + `) `
  4638. //}
  4639. //if userType == 1 {
  4640. // conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
  4641. //} else {
  4642. // conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
  4643. //}
  4644. condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
  4645. startSize = 0
  4646. if isPower == 1 {
  4647. condition += permissionSqlStr
  4648. }
  4649. if whichDay != "" {
  4650. var startDate string
  4651. var endDate string
  4652. if whichDay == "1" {
  4653. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  4654. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  4655. } else if whichDay == "2" {
  4656. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  4657. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  4658. } else if whichDay == "3" {
  4659. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  4660. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  4661. } else if whichDay == "4" {
  4662. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  4663. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  4664. } else if whichDay == "1,2" {
  4665. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  4666. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  4667. } else if whichDay == "3,4" {
  4668. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  4669. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  4670. } else {
  4671. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  4672. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  4673. }
  4674. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  4675. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  4676. }
  4677. if len(chartPermissionIds) > 0 {
  4678. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  4679. }
  4680. if typeName != ""{
  4681. typeSlice := strings.Split(typeName, ",")
  4682. tempCondition := ""
  4683. for _, s := range typeSlice {
  4684. if s == "1"{
  4685. tempCondition += "'专家电话会',"
  4686. } else if s == "2" {
  4687. tempCondition += "'分析师电话会',"
  4688. }
  4689. }
  4690. tempCondition = strings.TrimRight(tempCondition, ",")
  4691. condition += ` AND art.activity_type_name IN (` + tempCondition + `)`
  4692. }
  4693. //pageSize = 24 - len(list)
  4694. //已结束的活动
  4695. sortTime = ` timesort DESC `
  4696. list, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
  4697. if err != nil {
  4698. br.Msg = "获取失败"
  4699. br.ErrMsg = "获取失败,Err:" + err.Error()
  4700. return
  4701. }
  4702. //for _, v := range listEnd {
  4703. // list = append(list, v)
  4704. //}
  4705. //标签字段关联的产业与标签处理
  4706. for k, v := range list {
  4707. list[k].KeyWord = services.LabelStr(v.KeyWord)
  4708. }
  4709. //添加更多主题访问记录
  4710. item := new(models.CygxPageHistoryRecord)
  4711. item.UserId = user.UserId
  4712. item.CreateTime = time.Now()
  4713. item.Mobile = user.Mobile
  4714. item.Email = user.Email
  4715. item.CompanyId = user.CompanyId
  4716. item.CompanyName = user.CompanyName
  4717. item.PageType = "OverActivity"
  4718. go models.AddCygxPageHistoryRecord(item)
  4719. resp.List = list
  4720. br.Ret = 200
  4721. br.Success = true
  4722. br.Msg = "获取成功"
  4723. br.Data = resp
  4724. }