activity.go 154 KB

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