activity.go 154 KB

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