user.go 201 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "github.com/tealeg/xlsx"
  7. "hongze/hz_crm_api/controllers"
  8. "hongze/hz_crm_api/models"
  9. "hongze/hz_crm_api/models/company"
  10. "hongze/hz_crm_api/models/cygx"
  11. "hongze/hz_crm_api/models/roadshow"
  12. "hongze/hz_crm_api/models/system"
  13. "hongze/hz_crm_api/services"
  14. cygxService "hongze/hz_crm_api/services/cygx"
  15. "hongze/hz_crm_api/utils"
  16. "os"
  17. "path/filepath"
  18. "sort"
  19. "strconv"
  20. "strings"
  21. "time"
  22. )
  23. // 权益用户管理
  24. type UserController struct {
  25. controllers.BaseAuthController
  26. }
  27. // List
  28. // @Title 用户列表
  29. // @Description 用户列表接口
  30. // @Param PageSize query int true "每页数据条数"
  31. // @Param CurrentIndex query int true "当前页页码,从1开始"
  32. // @Param Status query string true "状态:”试用','永续','冻结','流失','正式'"
  33. // @Param IsMaker query int false "是否决策人,1:是,0:否 ,2:全部'"
  34. // @Param IsRegister query int false "是否决策人,1:是,0:否 ,2:全部'"
  35. // @Param AdminId query string true "销售id,多个用英文逗号隔开,空字符串为全部"
  36. // @Param KeyWord query string true "搜索关键词"
  37. // @Param Label query string true "搜索用户标签"
  38. // @Param TryStage query int false "试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备。正式:套餐类型,0:无,1:大套餐,2:小套餐"
  39. // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
  40. // @Param IsSubscribeCygx query int true "是否关注了查研观向小助手公众号: -1-默认全部; 0-未关注; 1-已关注"
  41. // @Success 200 {object} cygx.CompanyUserListResp
  42. // @router /user/list [get]
  43. func (this *UserController) List() {
  44. br := new(models.BaseResponse).Init()
  45. defer func() {
  46. this.Data["json"] = br
  47. this.ServeJSON()
  48. }()
  49. sysUser := this.SysUser
  50. if sysUser == nil {
  51. br.Msg = "请登录"
  52. br.ErrMsg = "请登录,SysUser Is Empty"
  53. br.Ret = 408
  54. return
  55. }
  56. roleTypeCode := sysUser.RoleTypeCode
  57. pageSize, _ := this.GetInt("PageSize")
  58. currentIndex, _ := this.GetInt("CurrentIndex")
  59. isMaker, _ := this.GetInt("IsMaker")
  60. isRegister, _ := this.GetInt("IsRegister")
  61. status := this.GetString("Status")
  62. adminId := this.GetString("AdminId")
  63. keyWord := this.GetString("KeyWord")
  64. label := this.GetString("Label")
  65. tryStage, _ := this.GetInt("TryStage") //试用客户标签
  66. sortType := this.GetString("SortType") //试用客户标签
  67. // 套餐类型
  68. //packageType, _ := this.GetInt("PackageType")
  69. keyWord = strings.Trim(keyWord, " ")
  70. keyWord = strings.Replace(keyWord, "'", "", -1)
  71. isSubscribeCygx, _ := this.GetInt("IsSubscribeCygx", -1)
  72. if status == "X类试用" {
  73. status = "永续"
  74. }
  75. var total int
  76. page := paging.GetPaging(currentIndex, pageSize, total)
  77. //statusItems := make([]*company.CompanyStatus, 0)
  78. //var statusArr = [...]string{"全部", "试用", "正式", "冻结", "流失", "永续"}
  79. var startSize int
  80. if pageSize <= 0 {
  81. pageSize = utils.PageSize20
  82. }
  83. if currentIndex <= 0 {
  84. currentIndex = 1
  85. }
  86. startSize = paging.StartIndex(currentIndex, pageSize)
  87. var condition string
  88. var sqlOrder string
  89. var usercondition string
  90. var kwywordcondition string
  91. var pars []interface{}
  92. var parsUser []interface{}
  93. //流失
  94. var lossCondition string
  95. //var lossPars []interface{}
  96. //状态分类查询条件
  97. //var permissionCondition string
  98. if adminId != "" {
  99. condition += ` AND b.seller_id IN (` + adminId + `) `
  100. }
  101. lossCondition = condition
  102. //lossPars = pars
  103. //permissionCondition = condition
  104. //流失客户统计
  105. lossCondition += ` AND status='流失' `
  106. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER { //权益销售的查询逻辑
  107. condition += ` AND ( cp.seller_id = ` + strconv.Itoa(sysUser.AdminId) + ` OR cp.share_seller_id = ` + strconv.Itoa(sysUser.AdminId) + `)`
  108. } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP { // 权益销售组长查询逻辑
  109. adminList, err := system.GetAdminListByGroupId(sysUser.GroupId)
  110. if err != nil {
  111. br.Msg = "获取失败"
  112. br.ErrMsg = "获取失败,GetAdminListByGroupIdErr:" + err.Error()
  113. return
  114. }
  115. var adminIds []string
  116. var companyIdsStr []string
  117. for _, v := range adminList {
  118. adminIds = append(adminIds, strconv.Itoa(v.AdminId))
  119. }
  120. //再获取组员下被共享的公司
  121. var parsShare []interface{}
  122. var conditionShare string
  123. conditionShare = " AND share_seller_id IN (" + strings.Join(adminIds, ",") + ") "
  124. listCompanyProduct, err := company.GetCompanyProductList(conditionShare, parsShare)
  125. if err != nil {
  126. br.Msg = "获取失败"
  127. br.ErrMsg = "获取失败,GetCompanyProductList:" + err.Error()
  128. return
  129. }
  130. for _, v := range listCompanyProduct {
  131. companyIdsStr = append(companyIdsStr, strconv.Itoa(v.CompanyId))
  132. }
  133. companyIdsStr = append(companyIdsStr, "0")
  134. //本组的或者被分享到本组下面的公司
  135. condition += ` AND (cp.group_id = ` + strconv.Itoa(sysUser.GroupId) + ` OR cp.company_id IN (` + strings.Join(companyIdsStr, ",") + `) )`
  136. }
  137. //状态控制
  138. if status != "" && status != "全部" {
  139. condition += ` AND b.status= '` + status + `'`
  140. usercondition += ` AND cp.status= '` + status + `'`
  141. } else {
  142. condition += ` AND b.status IN ('正式','试用','冻结','永续') `
  143. }
  144. // 试用客户标签
  145. if (status == "试用" || status == "永续") && tryStage > 0 {
  146. condition += ` AND b.try_stage= '` + strconv.Itoa(tryStage) + `'`
  147. usercondition += ` AND cp.try_stage= '` + strconv.Itoa(tryStage) + `'`
  148. }
  149. //套餐类型 权益客户除了大套餐就是小套餐
  150. if status == "正式" && tryStage > 0 {
  151. if tryStage == 1 {
  152. condition += ` AND b.package_type= '` + strconv.Itoa(tryStage) + `'`
  153. usercondition += ` AND cp.package_type= '` + strconv.Itoa(tryStage) + `'`
  154. } else {
  155. condition += ` AND b.package_type!= 1 `
  156. usercondition += ` AND cp.package_type != 1 `
  157. }
  158. }
  159. if isMaker != 2 {
  160. if isMaker == 1 {
  161. usercondition += ` AND u.is_maker = 1 `
  162. } else {
  163. //部分脏数据
  164. usercondition += ` AND u.is_maker != 1 `
  165. }
  166. //parsUser = append(parsUser, isMaker)
  167. }
  168. if isRegister != 2 {
  169. if isRegister == 1 {
  170. usercondition += ` AND u.register_time IS NOT NULL`
  171. } else {
  172. //部分脏数据
  173. usercondition += ` AND u.register_time IS NULL`
  174. }
  175. //parsUser = append(parsUser, isRegister)
  176. }
  177. kwywordcondition = condition
  178. if keyWord != "" {
  179. companyIdStr, err := company.GetCompanyIdByKeyWord(keyWord)
  180. if err != nil {
  181. br.Msg = "获取客户信息失败"
  182. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  183. return
  184. }
  185. if companyIdStr != "" {
  186. condition += ` AND (a.company_name LIKE '%` + keyWord + `%' OR a.credit_code LIKE '%` + keyWord + `%' AND a.company_id IN(` + companyIdStr + `)) `
  187. } else {
  188. condition += ` AND (a.company_name LIKE '%` + keyWord + `%' OR a.credit_code LIKE '%` + keyWord + `%' ) `
  189. }
  190. }
  191. if label != "" {
  192. usercondition += ` AND u.user_label LIKE '%` + label + `%'`
  193. }
  194. //
  195. usercondition += ` AND cp.product_id = 2 AND sr.product_id = 2 `
  196. // 是否关注弘则研究公众号
  197. if isSubscribeCygx == 0 {
  198. usercondition += ` AND (u.cygx_subscribe = 0 OR ISNULL(u.cygx_subscribe)) `
  199. }
  200. if isSubscribeCygx == 1 {
  201. usercondition += ` AND u.cygx_subscribe = 1 `
  202. }
  203. condition += ` AND cp.product_id = 2 `
  204. total, err := cygx.GetCompanyListCount(usercondition, keyWord, kwywordcondition, condition, roleTypeCode, pars)
  205. if err != nil {
  206. br.Msg = "获取失败"
  207. br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
  208. return
  209. }
  210. if sortType == "" {
  211. sqlOrder = ` GROUP by u.user_id ORDER BY c.created_time DESC, u.register_time DESC `
  212. } else {
  213. if sortType == "asc" {
  214. sqlOrder = ` GROUP by u.user_id ORDER BY u.interaction_num ASC , u.register_time DESC `
  215. } else {
  216. sqlOrder = ` GROUP by u.user_id ORDER BY u.interaction_num DESC , u.register_time DESC `
  217. }
  218. }
  219. list, err := cygx.GetCygxCompanyUserList(usercondition, keyWord, kwywordcondition, condition, roleTypeCode, sqlOrder, parsUser, startSize, pageSize)
  220. if err != nil {
  221. br.Msg = "获取失败"
  222. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  223. return
  224. }
  225. var isAdminRole bool
  226. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  227. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  228. isAdminRole = true
  229. }
  230. var userIds string
  231. var userIdArr []int
  232. var companyIds []int
  233. if list != nil {
  234. for k, v := range list {
  235. if v.RegisterTime != "" {
  236. list[k].IsRegister = true
  237. } else {
  238. list[k].IsRegister = false
  239. }
  240. if v.IsShowSeeNum > 0 {
  241. list[k].IsShowSee = true
  242. }
  243. if v.Status == "正式" {
  244. if v.PackageType == 1 {
  245. list[k].Status += "(大套餐)"
  246. } else {
  247. list[k].Status += "(小套餐)"
  248. }
  249. }
  250. if v.Status == "试用" {
  251. if v.TryStage == 1 {
  252. list[k].Status += "(未分类)"
  253. } else if v.TryStage == 2 {
  254. list[k].Status += "(推进)"
  255. } else if v.TryStage == 3 {
  256. list[k].Status += "(跟踪)"
  257. } else if v.TryStage == 4 {
  258. list[k].Status += "(预备)"
  259. }
  260. }
  261. if v.Status == "永续" {
  262. v.Status = "X类试用"
  263. }
  264. userIds += strconv.Itoa(int(v.UserId)) + ","
  265. userIdArr = append(userIdArr, int(v.UserId))
  266. if !isAdminRole {
  267. list[k].CompanyInteractionNum = v.CompanyInteractionNumSeller
  268. }
  269. companyIds = append(companyIds, v.CompanyId)
  270. }
  271. userIds = strings.TrimRight(userIds, ",")
  272. splitList, err := cygx.GetCygxCompanyUserListSplit(userIds)
  273. if err != nil && err.Error() != utils.ErrNoRow() {
  274. br.Msg = "获取失败"
  275. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  276. return
  277. }
  278. //用户备注
  279. userRemarksList, err := cygx.GetUserRemarksListByUserIds(userIds)
  280. if err != nil && err.Error() != utils.ErrNoRow() {
  281. br.Msg = "获取失败"
  282. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  283. return
  284. }
  285. mapUserRemarks := make(map[int]string)
  286. for _, v := range userRemarksList {
  287. if mapUserRemarks[v.UserId] == "" {
  288. mapUserRemarks[v.UserId] = v.Content
  289. }
  290. }
  291. UserRemindListMap := cygxService.GetCygxUserRemindListMap(userIdArr)
  292. mapIsUserMaker := cygxService.GetCompanyProductIsUserMakerByCompanyIds(companyIds) //根据公司ID获取近四周之内有决策人互动的客户
  293. for k, v := range list {
  294. for _, vsplit := range splitList {
  295. if vsplit.UserId == v.UserId {
  296. list[k].HistoryNum = vsplit.HistoryNum
  297. list[k].CountNum = vsplit.CountNum
  298. list[k].IndustryFllowNum = vsplit.IndustryFllowNum
  299. list[k].DepartmentFollowNum = vsplit.DepartmentFollowNum
  300. list[k].KeyWordNum = vsplit.KeyWordNum
  301. list[k].OnLineNum = vsplit.OnLineNum
  302. list[k].OfficeNum = vsplit.OfficeNum
  303. list[k].ChartNum = vsplit.ChartNum
  304. list[k].TripNum = vsplit.TripNum
  305. list[k].RoadshowVideoNum = vsplit.RoadshowVideoNum
  306. list[k].ActivityVideoNum = vsplit.ActivityVideoNum
  307. list[k].ActivityVoiceNum = vsplit.ActivityVoiceNum
  308. list[k].YanxuanspecialNum = vsplit.YanxuanspecialNum
  309. }
  310. }
  311. if mapUserRemarks[int(v.UserId)] != "" {
  312. list[k].Content = mapUserRemarks[int(v.UserId)]
  313. }
  314. list[k].IsRemind = UserRemindListMap[int(v.UserId)]
  315. list[k].IsUserMaker = mapIsUserMaker[v.CompanyId]
  316. }
  317. for k := range list {
  318. list[k].InteractionNum = list[k].HistoryNum + list[k].CountNum + list[k].IndustryFllowNum + list[k].DepartmentFollowNum + list[k].KeyWordNum + list[k].OnLineNum + list[k].OfficeNum + list[k].ChartNum + list[k].TripNum + list[k].RoadshowVideoNum + list[k].ActivityVideoNum + list[k].ActivityVoiceNum + list[k].YanxuanspecialNum
  319. }
  320. } else {
  321. list = make([]*cygx.CygxCompanyUser, 0)
  322. }
  323. page = paging.GetPaging(currentIndex, pageSize, total)
  324. resp := new(cygx.CompanyUserListResp)
  325. resp.List = list
  326. resp.Paging = page
  327. br.Ret = 200
  328. br.Success = true
  329. br.Msg = "获取成功"
  330. br.Data = resp
  331. }
  332. // @Title 新增备注接口
  333. // @Description 新增备注
  334. // @Param request body cygx.UserRemarAddReq true "type json string"
  335. // @Success 200 新增成功
  336. // @router /user/addRemarks [post]
  337. func (this *UserController) Add() {
  338. br := new(models.BaseResponse).Init()
  339. defer func() {
  340. this.Data["json"] = br
  341. this.ServeJSON()
  342. }()
  343. sysUser := this.SysUser
  344. if sysUser == nil {
  345. br.Msg = "请登录"
  346. br.ErrMsg = "请登录,SysUser Is Empty"
  347. br.Ret = 408
  348. return
  349. }
  350. var req cygx.UserRemarAddReq
  351. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  352. if err != nil {
  353. br.Msg = "参数解析异常!"
  354. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  355. return
  356. }
  357. if req.Content == "" {
  358. br.Msg = "请填写内容"
  359. return
  360. }
  361. item := new(cygx.UserRemarks)
  362. item.UserId = req.UserId
  363. item.AdminId = sysUser.AdminId
  364. item.Content = req.Content
  365. item.CreateTime = time.Now()
  366. err = cygx.AddUserRemarks(item)
  367. if err != nil {
  368. br.Msg = "新增失败."
  369. br.ErrMsg = "新增失败,Err:" + err.Error()
  370. return
  371. }
  372. br.Ret = 200
  373. br.Success = true
  374. br.Msg = "新增成功"
  375. }
  376. // @Title 备注列表
  377. // @Description 备注列表接口
  378. // @Param UserId query int true "用户id"
  379. // @Success 200 {object} cygx.UserRemarksListResp
  380. // @router /user/remark/list [get]
  381. func (this *UserController) RemarkList() {
  382. br := new(models.BaseResponse).Init()
  383. defer func() {
  384. this.Data["json"] = br
  385. this.ServeJSON()
  386. }()
  387. sysUser := this.SysUser
  388. if sysUser == nil {
  389. br.Msg = "请登录"
  390. br.ErrMsg = "请登录,SysUser Is Empty"
  391. br.Ret = 408
  392. return
  393. }
  394. userId, _ := this.GetInt("UserId")
  395. if userId < 1 {
  396. br.Msg = "用户不存在"
  397. return
  398. }
  399. list, err := cygx.GetUserRemarksList(userId)
  400. if err != nil && err.Error() != utils.ErrNoRow() {
  401. br.Msg = "获取信息失败"
  402. br.ErrMsg = "获取备注信息失败,Err:" + err.Error()
  403. return
  404. }
  405. resp := new(cygx.UserRemarksListResp)
  406. resp.List = list
  407. br.Ret = 200
  408. br.Success = true
  409. br.Msg = "获取成功"
  410. br.Data = resp
  411. }
  412. // @Title 互动详情table栏
  413. // @Description 互动详情table栏接口
  414. // @Param UserId query int true "用户id"
  415. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  416. // @Success 200 {object} cygx.UserRemarksListResp
  417. // @router /user/table/list [get]
  418. func (this *UserController) TableList() {
  419. br := new(models.BaseResponse).Init()
  420. defer func() {
  421. this.Data["json"] = br
  422. this.ServeJSON()
  423. }()
  424. sysUser := this.SysUser
  425. if sysUser == nil {
  426. br.Msg = "请登录"
  427. br.ErrMsg = "请登录,SysUser Is Empty"
  428. br.Ret = 408
  429. return
  430. }
  431. userId, _ := this.GetInt("UserId")
  432. if userId < 1 {
  433. br.Msg = "用户不存在"
  434. return
  435. }
  436. classType, _ := this.GetInt("ClassType", 1)
  437. wxUser, err := models.GetWxUserByUserId(userId)
  438. if err != nil {
  439. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  440. br.Msg = "获取信息失败"
  441. return
  442. }
  443. comanyDetail, err := company.GetCompanyDetailById(wxUser.CompanyId)
  444. if err != nil {
  445. br.Msg = "获取信息失败"
  446. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  447. return
  448. }
  449. resp := new(cygx.CygxUserTableListRep)
  450. if classType == 1 {
  451. countDetail, err := cygx.GetUserInteractionTableCount(userId)
  452. if err != nil {
  453. br.Msg = "获取信息失败"
  454. br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
  455. return
  456. }
  457. calendarTotal, err := roadshow.GetRsCalendarMeetingUserCountByUserId(userId)
  458. if err != nil {
  459. br.Msg = "获取信息失败"
  460. br.ErrMsg = "GetCygxUserFeedbackCountByUserId,Err:" + err.Error()
  461. return
  462. }
  463. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: countDetail.HistoryNum},
  464. {PermissionName: "活动互动记录", Source: 2, TotalNum: countDetail.OnLineNum + countDetail.OfficeNum},
  465. {PermissionName: "专项调研", Source: 8, TotalNum: countDetail.TripNum},
  466. {PermissionName: "1v1路演", Source: 15, TotalNum: calendarTotal},
  467. {PermissionName: "收藏的报告", Source: 3, TotalNum: countDetail.CountNum},
  468. {PermissionName: "收藏的图表", Source: 4, TotalNum: countDetail.ChartNum},
  469. {PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
  470. {PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum},
  471. {PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum},
  472. {PermissionName: "首页标签点击", Source: 10, TotalNum: countDetail.TagNum},
  473. {PermissionName: "交流反馈", Source: 14, TotalNum: countDetail.FeedbackNum}}
  474. resp.List = List
  475. } else {
  476. countDetail, err := cygx.GetUserInteractionTableCountByYanXuan(userId)
  477. if err != nil {
  478. br.Msg = "获取信息失败"
  479. br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
  480. return
  481. }
  482. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: countDetail.HistoryNum},
  483. {PermissionName: "活动互动记录", Source: 2, TotalNum: countDetail.OnLineNum + countDetail.OfficeNum},
  484. {PermissionName: "收藏的报告", Source: 3, TotalNum: countDetail.CountNum},
  485. {PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
  486. {PermissionName: "关注的作者", Source: 6, TotalNum: countDetail.DepartmentFollowNum},
  487. {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: countDetail.YanxuanSpecialNum},
  488. {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: countDetail.YanxuanSpecialCollectNum},
  489. {PermissionName: "关注的专栏作者", Source: 13, TotalNum: countDetail.YanxuanSpecialFollowNum},
  490. {PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum}}
  491. resp.List = List
  492. }
  493. //阅读记录总数
  494. resp.UserName = wxUser.RealName
  495. resp.Mobile = wxUser.Mobile
  496. resp.ComapnyName = comanyDetail.CompanyName
  497. br.Ret = 200
  498. br.Success = true
  499. br.Msg = "获取成功"
  500. br.Data = resp
  501. }
  502. // @Title 互动详情
  503. // @Description 互动详情接口
  504. // @Param UserId query int true "用户id"
  505. // @Param Source query int true "来源"
  506. // @Param IdentityType query int true "身份类型,1:用户,2机构。默认1 (图表分页使用)"
  507. // @Param IsMeeting query string true "是否到会 1到会、2未到会"
  508. // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
  509. // @Param PageSize query int true "每页数据条数"
  510. // @Param CurrentIndex query int true "当前页页码,从1开始"
  511. // @Param StartDate query string true "开始时间"
  512. // @Param EndDate query string true "结束时间"
  513. // @Param KeyWord query string true "搜索关键词"
  514. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  515. // @Param IsExport query bool false "是否导出excel,默认是false"
  516. // @Success 200 {object} cygx.UserInteractionListResp
  517. // @router /user/interaction/detail [get]
  518. func (this *UserController) TableDetail() {
  519. br := new(models.BaseResponse).Init()
  520. defer func() {
  521. this.Data["json"] = br
  522. this.ServeJSON()
  523. }()
  524. sysUser := this.SysUser
  525. if sysUser == nil {
  526. br.Msg = "请登录"
  527. br.ErrMsg = "请登录,SysUser Is Empty"
  528. br.Ret = 408
  529. return
  530. }
  531. pageSize, _ := this.GetInt("PageSize")
  532. currentIndex, _ := this.GetInt("CurrentIndex")
  533. var startSize int
  534. if pageSize <= 0 {
  535. pageSize = utils.PageSize20
  536. }
  537. if currentIndex <= 0 {
  538. currentIndex = 1
  539. }
  540. startSize = paging.StartIndex(currentIndex, pageSize)
  541. userId, _ := this.GetInt("UserId")
  542. isMeeting := this.GetString("IsMeeting")
  543. meetType := this.GetString("MeetType")
  544. startDate := this.GetString("StartDate")
  545. endDate := this.GetString("EndDate")
  546. keyWord := this.GetString("KeyWord")
  547. source, _ := this.GetInt("Source")
  548. identityType, _ := this.GetInt("IdentityType")
  549. classType, _ := this.GetInt("ClassType", 1)
  550. //是否导出报表
  551. isExport, _ := this.GetBool("IsExport")
  552. if isExport {
  553. pageSize = 10000
  554. currentIndex = 1
  555. }
  556. if userId < 1 {
  557. br.Msg = "用户不存在"
  558. return
  559. }
  560. // 1.标记用户表
  561. //操作权限校验
  562. var err error
  563. wxUser, err := models.GetWxUserByUserId(userId)
  564. if err != nil {
  565. br.Msg = "获取信息失败"
  566. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  567. return
  568. }
  569. mobile := wxUser.Mobile
  570. //var checkSource bool
  571. var MeetingNum int
  572. var NoMeetingNum int
  573. var list []*cygx.UserInteraction
  574. var total int
  575. var condition string
  576. var pars []interface{}
  577. if source == 1 {
  578. if startDate != "" {
  579. startDate += " 00:00:00"
  580. condition += ` AND r.create_time >= '` + startDate + `' `
  581. }
  582. if endDate != "" {
  583. endDate += " 23:59:59"
  584. condition += ` AND r.create_time <= '` + endDate + `' `
  585. }
  586. if wxUser.Mobile == "" {
  587. wxUser.Mobile = wxUser.Email
  588. }
  589. //total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
  590. //if err != nil {
  591. // br.Msg = "获取信息失败"
  592. // br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
  593. // return
  594. //}
  595. if classType == 1 {
  596. condition += " AND art.article_type_id = 0 "
  597. } else {
  598. condition += " AND art.article_type_id > 0 "
  599. }
  600. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  601. total, list, err = cygx.GetCygxArticleHistoryRecordByUserNew(condition, startSize, pageSize)
  602. if err != nil && err.Error() != utils.ErrNoRow() {
  603. br.Msg = "获取信息失败"
  604. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  605. return
  606. }
  607. var articleIds string
  608. var articleIdArr []int
  609. if len(list) > 0 {
  610. articleIds = ""
  611. mapAricleId := make(map[int]int)
  612. mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
  613. for k, v := range list {
  614. if v.ArticleId >= utils.SummaryArticleId {
  615. list[k].ArticleType = 1
  616. } else {
  617. list[k].ArticleType = 2
  618. }
  619. if mapAricleId[v.ArticleId] == 0 {
  620. articleIds += strconv.Itoa(v.ArticleId) + ","
  621. mapAricleId[v.ArticleId] = v.ArticleId
  622. }
  623. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  624. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  625. articleIdArr = append(articleIdArr, v.ArticleId)
  626. }
  627. articleIds = strings.TrimRight(articleIds, ",")
  628. listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
  629. if err != nil && err.Error() != utils.ErrNoRow() {
  630. br.Msg = "获取信息失败"
  631. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  632. return
  633. }
  634. if len(listArticleIndustrialSubjectList) > 0 {
  635. for _, v := range listArticleIndustrialSubjectList {
  636. mapAricleIndustrialSubjectName[v.ArticleId] = v
  637. }
  638. for k, v := range list {
  639. if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
  640. list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName // 产业
  641. list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr // 标的
  642. }
  643. }
  644. }
  645. //行业
  646. mapPerssionName := cygxService.GetCygxArticlePerssionNameListMap(articleIdArr)
  647. for k, v := range list {
  648. if v.SpecialType > 0 {
  649. list[k].PermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
  650. } else {
  651. list[k].PermissionName = mapPerssionName[v.ArticleId]
  652. }
  653. if classType == 1 {
  654. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  655. } else {
  656. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  657. }
  658. if v.ReportId > 0 {
  659. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  660. }
  661. }
  662. //导出excel
  663. if isExport {
  664. exportListArticle(this, list, 1, br)
  665. return
  666. }
  667. }
  668. } else if source == 2 {
  669. if mobile != "" {
  670. condition = ` AND s.mobile = '` + mobile + `' `
  671. if classType == 1 {
  672. condition += " AND a.chart_permission_id != 31 "
  673. } else {
  674. condition += " AND a.chart_permission_id = 31 "
  675. }
  676. if isMeeting == "1" {
  677. condition += ` AND s.is_meeting = 1 `
  678. }
  679. if isMeeting == "2" {
  680. condition += ` AND s.is_meeting = 0 `
  681. }
  682. if meetType == "1" {
  683. condition += ` AND t.activity_type = 1 `
  684. }
  685. if meetType == "2" {
  686. condition += ` AND t.activity_type = 0 `
  687. }
  688. if startDate != "" {
  689. startDate += " 00:00:00"
  690. condition += ` AND a.activity_time >= '` + startDate + `' `
  691. }
  692. if endDate != "" {
  693. endDate += " 23:59:59"
  694. condition += ` AND a.activity_time <= '` + endDate + `' `
  695. }
  696. if keyWord != "" {
  697. condition += ` AND a.activity_name LIKE '%` + keyWord + `%' `
  698. }
  699. total, err = cygx.GetActivityMeetByUserCount(condition)
  700. if err != nil {
  701. br.Msg = "获取信息失败"
  702. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  703. return
  704. }
  705. list, err = cygx.GetActivityMeetByUser(condition, startSize, pageSize)
  706. if err != nil && err.Error() != utils.ErrNoRow() {
  707. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  708. br.Msg = "获取参会人数列表失败"
  709. return
  710. }
  711. if len(list) > 0 {
  712. for k, v := range list {
  713. if v.ActivityType == 1 {
  714. if v.SignupType == "2" {
  715. list[k].InteractionType = "自主拨入"
  716. } else {
  717. list[k].InteractionType = "预约外呼"
  718. }
  719. if v.ReminderNum > 0 {
  720. list[k].InteractionType += "会议提醒"
  721. }
  722. }
  723. if v.IsMeeting == 0 {
  724. list[k].FirstMeetingTime = ""
  725. list[k].LastMeetingTime = ""
  726. }
  727. if v.FirstMeetingTime == "0000-00-00 00:00:00" {
  728. list[k].FirstMeetingTime = ""
  729. list[k].LastMeetingTime = ""
  730. }
  731. }
  732. }
  733. }
  734. //导出excel
  735. if isExport {
  736. exportListActivity(this, list, 1, br)
  737. return
  738. }
  739. } else if source == 3 {
  740. if classType == 1 {
  741. condition += " AND art.article_type_id = 0 "
  742. } else {
  743. condition += " AND art.article_type_id > 0 "
  744. }
  745. total, err = cygx.GetCygxArticleCollectCount(userId, condition)
  746. if err != nil {
  747. br.Msg = "获取信息失败"
  748. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  749. return
  750. }
  751. list, err = cygx.GetCygxArticleCollectByUser(userId, startSize, pageSize, condition)
  752. if err != nil && err.Error() != utils.ErrNoRow() {
  753. br.Msg = "获取信息失败"
  754. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  755. return
  756. }
  757. if len(list) > 0 {
  758. for k, v := range list {
  759. if v.ArticleId >= utils.SummaryArticleId {
  760. list[k].ArticleType = 1
  761. } else {
  762. list[k].ArticleType = 2
  763. }
  764. if classType == 1 {
  765. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  766. } else {
  767. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  768. }
  769. if v.ReportId > 0 {
  770. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  771. }
  772. }
  773. }
  774. } else if source == 4 {
  775. if identityType == 2 {
  776. condition += ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
  777. }
  778. condition += ` AND a.publish_status = 1 AND user_id = ` + strconv.Itoa(userId)
  779. var err error
  780. total, err = cygx.GetChartCountByUser(condition)
  781. if err != nil {
  782. br.Msg = "获取信息失败"
  783. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  784. return
  785. }
  786. list, err = cygx.GetChartListCollectionWithCygx(condition, startSize, pageSize)
  787. if err != nil {
  788. br.Msg = "获取信息失败"
  789. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  790. return
  791. }
  792. for k, v := range list {
  793. if v.PtagName != "" {
  794. list[k].CtagNamePc = v.PtagName
  795. }
  796. if v.CtagName != "" {
  797. list[k].CtagNamePc += "," + v.CtagName
  798. }
  799. if v.PtagNameTwo != "" {
  800. list[k].CtagNamePc += "," + v.PtagNameTwo
  801. }
  802. if v.CtagNameTwo != "" {
  803. list[k].CtagNamePc += "," + v.CtagNameTwo
  804. }
  805. }
  806. } else if source == 5 {
  807. if classType == 1 {
  808. condition += " AND a.chart_permission_id = 31 "
  809. } else {
  810. condition += " AND a.chart_permission_id = 31 "
  811. }
  812. total, err = cygx.GetCygxIndustryFllowCount(userId, condition)
  813. if err != nil {
  814. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  815. br.Msg = "获取用户关注总数失败"
  816. return
  817. }
  818. list, err = cygx.GetCygxIndustryFllowByUser(userId, startSize, pageSize, condition)
  819. if err != nil && err.Error() != utils.ErrNoRow() {
  820. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  821. br.Msg = "获取用户关注总数失败"
  822. return
  823. }
  824. } else if source == 6 {
  825. total, err = cygx.GetCygArticleDepartmentFollowCount(userId)
  826. if err != nil {
  827. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  828. br.Msg = "获取关注作者总数失败"
  829. return
  830. }
  831. list, err = cygx.GetCygArticleDepartmentFollowByUser(userId, startSize, pageSize)
  832. if err != nil && err.Error() != utils.ErrNoRow() {
  833. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  834. br.Msg = "获取关注作者列表失败"
  835. return
  836. }
  837. if len(list) > 0 {
  838. for k, v := range list {
  839. var condition string
  840. var pars []interface{}
  841. condition += ` WHERE art.source = 1 AND art.is_summary = 1 AND art.department_id = ` + strconv.Itoa(v.DepartmentId)
  842. listArt, errList := cygx.GetSummaryManageList(condition, pars, 0, 20)
  843. if errList != nil && errList.Error() != utils.ErrNoRow() {
  844. br.Msg = "获取失败"
  845. br.ErrMsg = "获取失败,Err:" + errList.Error()
  846. return
  847. }
  848. if len(listArt) > 0 {
  849. mapIndustryName := make(map[string]string)
  850. mapSubjectName := make(map[string]string)
  851. var articleIdStr string
  852. for _, vArt := range listArt {
  853. if vArt.IndustryName != "" && mapIndustryName[vArt.IndustryName] == "" {
  854. list[k].IndustryName += vArt.IndustryName + "/"
  855. mapIndustryName[vArt.IndustryName] = vArt.IndustryName
  856. }
  857. articleIdStr += strconv.Itoa(vArt.ArticleId) + ","
  858. }
  859. list[k].IndustryName = strings.TrimRight(list[k].IndustryName, "/")
  860. articleIdStr = strings.TrimRight(articleIdStr, ",")
  861. listSubject, err := cygx.GetArticleSubjectList(articleIdStr)
  862. if err != nil {
  863. br.Msg = "获取失败"
  864. br.ErrMsg = "获取失败,Err:" + err.Error()
  865. return
  866. }
  867. if len(listSubject) > 0 {
  868. for _, vSub := range listSubject {
  869. if vSub.SubjectName != "" && mapSubjectName[vSub.SubjectName] == "" {
  870. list[k].SubjectNameStr += vSub.SubjectName + "/"
  871. mapSubjectName[vSub.SubjectName] = vSub.SubjectName
  872. }
  873. }
  874. list[k].SubjectNameStr = strings.TrimRight(list[k].SubjectNameStr, "/")
  875. }
  876. }
  877. }
  878. }
  879. } else if source == 7 {
  880. if classType == 1 {
  881. condition += " AND register_platform IN (1,2) "
  882. } else {
  883. condition += " AND register_platform IN (5,6) "
  884. }
  885. total, err = cygx.GetCygxSearchKeyWordCount(userId, condition)
  886. if err != nil {
  887. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  888. br.Msg = "获取搜索记录失败"
  889. return
  890. }
  891. list, err = cygx.GetCygxSearchKeyWordByUser(condition, userId, startSize, pageSize)
  892. if err != nil && err.Error() != utils.ErrNoRow() {
  893. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  894. br.Msg = "获取搜索记录列表失败"
  895. return
  896. }
  897. } else if source == 8 {
  898. condition += ` AND h.user_id = ? `
  899. pars = append(pars, userId)
  900. total, err = cygx.GetCygxActivitySpecialTripCount(condition, pars)
  901. if err != nil {
  902. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  903. br.Msg = "获取搜索记录失败"
  904. return
  905. }
  906. list, err = cygx.GetCygxActivitySpecialTripByUser(userId, startSize, pageSize)
  907. if err != nil && err.Error() != utils.ErrNoRow() {
  908. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  909. br.Msg = "获取搜索记录列表失败"
  910. return
  911. }
  912. } else if source == 9 {
  913. total, err = cygx.GetCygxRoadshowCount(userId)
  914. if err != nil {
  915. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  916. br.Msg = "获取搜索记录失败"
  917. return
  918. }
  919. list, err = cygx.GetCygxRoadshowByUser(userId, startSize, pageSize)
  920. if err != nil && err.Error() != utils.ErrNoRow() {
  921. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  922. br.Msg = "获取搜索记录列表失败"
  923. return
  924. }
  925. } else if source == 10 { //标签点击记录
  926. total, err = cygx.GetCygxTagHistoryCountByUserId(userId)
  927. if err != nil {
  928. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  929. br.Msg = "获取搜索记录失败"
  930. return
  931. }
  932. list, err = cygx.GetCygxTagHistoryByUserId(userId, startSize, pageSize)
  933. if err != nil && err.Error() != utils.ErrNoRow() {
  934. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  935. br.Msg = "获取搜索记录列表失败"
  936. return
  937. }
  938. } else if source == 11 { //专栏文章阅读记录
  939. if startDate != "" {
  940. startDate += " 00:00:00"
  941. condition += ` AND r.create_time >= '` + startDate + `' `
  942. }
  943. if endDate != "" {
  944. endDate += " 23:59:59"
  945. condition += ` AND r.create_time <= '` + endDate + `' `
  946. }
  947. if wxUser.Mobile == "" {
  948. wxUser.Mobile = wxUser.Email
  949. }
  950. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  951. total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
  952. if err != nil && err.Error() != utils.ErrNoRow() {
  953. br.Msg = "获取信息失败"
  954. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  955. return
  956. }
  957. if len(list) > 0 {
  958. for k, v := range list {
  959. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  960. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  961. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  962. }
  963. }
  964. //导出excel
  965. if isExport {
  966. exportListYanxuanSpecial(this, list, 1, br)
  967. return
  968. }
  969. } else if source == 12 { //收藏的专栏文章
  970. if startDate != "" {
  971. startDate += " 00:00:00"
  972. condition += ` AND r.create_time >= '` + startDate + `' `
  973. }
  974. if endDate != "" {
  975. endDate += " 23:59:59"
  976. condition += ` AND r.create_time <= '` + endDate + `' `
  977. }
  978. if wxUser.Mobile == "" {
  979. wxUser.Mobile = wxUser.Email
  980. }
  981. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  982. total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
  983. if err != nil && err.Error() != utils.ErrNoRow() {
  984. br.Msg = "获取信息失败"
  985. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  986. return
  987. }
  988. if len(list) > 0 {
  989. for k, v := range list {
  990. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  991. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  992. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  993. }
  994. }
  995. } else if source == 13 { //关注的专栏作者
  996. if startDate != "" {
  997. startDate += " 00:00:00"
  998. condition += ` AND r.create_time >= '` + startDate + `' `
  999. }
  1000. if endDate != "" {
  1001. endDate += " 23:59:59"
  1002. condition += ` AND r.create_time <= '` + endDate + `' `
  1003. }
  1004. if wxUser.Mobile == "" {
  1005. wxUser.Mobile = wxUser.Email
  1006. }
  1007. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  1008. total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
  1009. if err != nil && err.Error() != utils.ErrNoRow() {
  1010. br.Msg = "获取信息失败"
  1011. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  1012. return
  1013. }
  1014. if len(list) > 0 {
  1015. for k, v := range list {
  1016. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
  1017. }
  1018. }
  1019. } else if source == 14 { //交流反馈
  1020. if startDate != "" {
  1021. startDate += " 00:00:00"
  1022. condition += ` AND r.create_time >= '` + startDate + `' `
  1023. }
  1024. if endDate != "" {
  1025. endDate += " 23:59:59"
  1026. condition += ` AND r.create_time <= '` + endDate + `' `
  1027. }
  1028. if wxUser.Mobile == "" {
  1029. wxUser.Mobile = wxUser.Email
  1030. }
  1031. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  1032. total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
  1033. if err != nil {
  1034. br.Msg = "获取信息失败"
  1035. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  1036. return
  1037. }
  1038. } else if source == 15 { //1V1路演
  1039. if startDate != "" {
  1040. condition += ` AND b.start_date >= '` + startDate + `' `
  1041. }
  1042. if endDate != "" {
  1043. condition += ` AND b.start_date <= '` + endDate + `' `
  1044. }
  1045. if wxUser.Mobile == "" {
  1046. wxUser.Mobile = wxUser.Email
  1047. }
  1048. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  1049. totalRsCalendar, listRsCalendar, err := roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
  1050. if err != nil {
  1051. br.Msg = "获取信息失败"
  1052. br.ErrMsg = "获取用户阅读记录,GetRsCalendarMeetingUserByRai Err:" + err.Error()
  1053. return
  1054. }
  1055. total = totalRsCalendar
  1056. list, err = cygxService.HandleListRsCalendar(listRsCalendar)
  1057. if err != nil {
  1058. br.Msg = "获取信息失败"
  1059. br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
  1060. return
  1061. }
  1062. //导出excel
  1063. if isExport {
  1064. exportListRsCalendar(this, list, 1, br)
  1065. return
  1066. }
  1067. }
  1068. page := paging.GetPaging(currentIndex, pageSize, total)
  1069. resp := new(cygx.UserInteractionListResp)
  1070. if len(list) == 0 {
  1071. list = make([]*cygx.UserInteraction, 0)
  1072. }
  1073. resp.MeetingNum = MeetingNum
  1074. resp.NoMeetingNum = NoMeetingNum
  1075. resp.List = list
  1076. resp.Paging = page
  1077. br.Ret = 200
  1078. br.Success = true
  1079. br.Msg = "获取成功"
  1080. br.Data = resp
  1081. }
  1082. // @Title 获取用户标签详情
  1083. // @Description 获取用户标签详情接口
  1084. // @Param UserId query int true "用户id"
  1085. // @Success 200 {object} cygx.UserLabel
  1086. // @router /user/label/detail [get]
  1087. func (this *UserController) LabelDetail() {
  1088. br := new(models.BaseResponse).Init()
  1089. defer func() {
  1090. this.Data["json"] = br
  1091. this.ServeJSON()
  1092. }()
  1093. sysUser := this.SysUser
  1094. if sysUser == nil {
  1095. br.Msg = "请登录"
  1096. br.ErrMsg = "请登录,SysUser Is Empty"
  1097. br.Ret = 408
  1098. return
  1099. }
  1100. userId, _ := this.GetInt("UserId")
  1101. if userId < 1 {
  1102. br.Msg = "用户不存在"
  1103. return
  1104. }
  1105. wxUser, err := models.GetWxUserByUserId(userId)
  1106. if err != nil {
  1107. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1108. br.Msg = "获取信息失败"
  1109. return
  1110. }
  1111. if userId > 0 {
  1112. resp := new(cygx.UserLabel)
  1113. resp.Label = wxUser.UserLabel
  1114. br.Ret = 200
  1115. br.Success = true
  1116. br.Msg = "获取成功"
  1117. br.Data = resp
  1118. return
  1119. }
  1120. list, err := cygx.GetCygxCompanyUserListSplit(strconv.Itoa(userId))
  1121. if err != nil {
  1122. br.Msg = "获取失败"
  1123. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1124. return
  1125. }
  1126. mapLabels := make(map[string]string)
  1127. var labelsListStr []*cygx.UserLabel
  1128. mapActivityLabels := make(map[string]string)
  1129. for k := range list {
  1130. labels := list[k].Labels
  1131. labelsList := strings.Split(labels, ",")
  1132. for _, vL := range labelsList {
  1133. if mapLabels[vL] == "" && vL != "" {
  1134. mapLabels[vL] = vL
  1135. item := new(cygx.UserLabel)
  1136. item.Label = vL
  1137. labelsListStr = append(labelsListStr, item)
  1138. }
  1139. }
  1140. }
  1141. dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
  1142. listArticlePv, err := cygx.GetArticlePvCount(wxUser.Mobile, wxUser.Email, dateTime)
  1143. if err != nil && err.Error() != utils.ErrNoRow() {
  1144. br.Msg = "获取失败"
  1145. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. var articleIds string
  1149. mapArticleIdLabelTotal := make(map[string]int)
  1150. mapArticleIdPv := make(map[int]int)
  1151. if len(listArticlePv) > 0 {
  1152. for _, v := range listArticlePv {
  1153. articleIds += strconv.Itoa(v.ArticleId) + ","
  1154. mapArticleIdPv[v.ArticleId] = v.Pv
  1155. }
  1156. articleIds = strings.TrimRight(articleIds, ",")
  1157. //产业、标的标签
  1158. listLabelName, err := cygx.GetArticleGroupyIndustryName(articleIds)
  1159. if err != nil && err.Error() != utils.ErrNoRow() {
  1160. br.Msg = "获取失败"
  1161. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1162. return
  1163. }
  1164. if len(listLabelName) > 0 {
  1165. for _, v := range listLabelName {
  1166. labelsIndustryList := strings.Split(v.IndustryName, "/")
  1167. labelsSubjectList := strings.Split(v.SubjectName, "/")
  1168. //添加产业统计
  1169. if len(labelsIndustryList) > 0 {
  1170. for _, vIn := range labelsIndustryList {
  1171. if mapActivityLabels[vIn] != "" {
  1172. mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
  1173. } else {
  1174. mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
  1175. mapActivityLabels[vIn] = vIn
  1176. }
  1177. }
  1178. }
  1179. if len(labelsSubjectList) > 0 {
  1180. //添加标的统计
  1181. for _, vIn := range labelsSubjectList {
  1182. if mapActivityLabels[vIn] != "" {
  1183. mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
  1184. } else {
  1185. mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
  1186. mapActivityLabels[vIn] = vIn
  1187. }
  1188. }
  1189. }
  1190. }
  1191. }
  1192. }
  1193. articleIds, err = cygx.GetCygxArticleCollectId(userId, dateTime)
  1194. if err != nil && err.Error() != utils.ErrNoRow() {
  1195. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1196. br.Msg = "获取用户搜藏记录失败"
  1197. return
  1198. }
  1199. if articleIds != "" {
  1200. //产业、标的标签
  1201. listLabelName, err := cygx.GetArticleGroupyIndustryName(articleIds)
  1202. if err != nil && err.Error() != utils.ErrNoRow() {
  1203. br.Msg = "获取失败"
  1204. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1205. return
  1206. }
  1207. if len(listLabelName) > 0 {
  1208. for _, v := range listLabelName {
  1209. labelsIndustryList := strings.Split(v.IndustryName, "/")
  1210. labelsSubjectList := strings.Split(v.SubjectName, "/")
  1211. //添加产业统计
  1212. if len(labelsIndustryList) > 0 {
  1213. for _, vIn := range labelsIndustryList {
  1214. if mapActivityLabels[vIn] != "" {
  1215. mapArticleIdLabelTotal[vIn] += 1
  1216. } else {
  1217. mapArticleIdLabelTotal[vIn] = 1
  1218. mapActivityLabels[vIn] = vIn
  1219. }
  1220. }
  1221. }
  1222. if len(labelsSubjectList) > 0 {
  1223. //添加标的统计
  1224. for _, vIn := range labelsSubjectList {
  1225. if mapActivityLabels[vIn] != "" {
  1226. mapArticleIdLabelTotal[vIn] += 1
  1227. } else {
  1228. mapArticleIdLabelTotal[vIn] = 1
  1229. mapActivityLabels[vIn] = vIn
  1230. }
  1231. }
  1232. }
  1233. }
  1234. }
  1235. }
  1236. //活动标签计算
  1237. listActivityPv, err := cygx.GetActivitySignCount(wxUser.Mobile, dateTime)
  1238. if err != nil && err.Error() != utils.ErrNoRow() {
  1239. br.Msg = "获取失败"
  1240. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1241. return
  1242. }
  1243. if len(listActivityPv) > 0 {
  1244. for _, v := range listActivityPv {
  1245. labelsList := strings.Split(v.Label, "-")
  1246. for _, v2 := range labelsList {
  1247. labelsListSon := strings.Split(v2, "/")
  1248. for _, v3 := range labelsListSon {
  1249. if mapActivityLabels[v3] != "" {
  1250. mapArticleIdLabelTotal[v3] += 1
  1251. } else {
  1252. mapArticleIdLabelTotal[v3] = 1
  1253. mapActivityLabels[v3] = v3
  1254. }
  1255. }
  1256. }
  1257. }
  1258. }
  1259. //会议提醒部分标签
  1260. listActivityPvByReminder, err := cygx.GetActivityMeetingReminder(wxUser.Mobile, dateTime)
  1261. if err != nil && err.Error() != utils.ErrNoRow() {
  1262. br.Msg = "获取失败"
  1263. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1264. return
  1265. }
  1266. if len(listActivityPvByReminder) > 0 {
  1267. for _, v := range listActivityPvByReminder {
  1268. labelsList := strings.Split(v.Label, "-")
  1269. for _, v2 := range labelsList {
  1270. labelsListSon := strings.Split(v2, "/")
  1271. for _, v3 := range labelsListSon {
  1272. if mapActivityLabels[v3] != "" {
  1273. mapArticleIdLabelTotal[v3] += 1
  1274. } else {
  1275. mapArticleIdLabelTotal[v3] = 1
  1276. mapActivityLabels[v3] = v3
  1277. }
  1278. }
  1279. }
  1280. }
  1281. }
  1282. //对标签数量进行排序
  1283. type KvPair struct {
  1284. Key string
  1285. Val int
  1286. }
  1287. tmpList := make([]KvPair, 0)
  1288. for k, v := range mapArticleIdLabelTotal {
  1289. tmpList = append(tmpList, KvPair{Key: k, Val: v})
  1290. }
  1291. sort.Slice(tmpList, func(i, j int) bool {
  1292. return tmpList[i].Val > tmpList[j].Val // 降序
  1293. })
  1294. for _, v := range tmpList {
  1295. if v.Key != "" {
  1296. mapLabels[v.Key] = v.Key
  1297. item := new(cygx.UserLabel)
  1298. item.Label = v.Key
  1299. labelsListStr = append(labelsListStr, item)
  1300. }
  1301. }
  1302. var labelNew string
  1303. for _, v := range labelsListStr {
  1304. labelNew += v.Label + ","
  1305. }
  1306. labelNew = strings.TrimRight(labelNew, ",")
  1307. resp := new(cygx.UserLabel)
  1308. resp.Label = labelNew
  1309. br.Ret = 200
  1310. br.Success = true
  1311. br.Msg = "获取成功"
  1312. br.Data = resp
  1313. }
  1314. // @Title 状态搜索栏
  1315. // @Description 状态搜索栏接口
  1316. // @Success 200 {object} cygx.CygxUserTableStatusListRep
  1317. // @router /user/status/table [get]
  1318. func (this *UserController) StatusTable() {
  1319. br := new(models.BaseResponse).Init()
  1320. defer func() {
  1321. this.Data["json"] = br
  1322. this.ServeJSON()
  1323. }()
  1324. sysUser := this.SysUser
  1325. if sysUser == nil {
  1326. br.Msg = "请登录"
  1327. br.ErrMsg = "请登录,SysUser Is Empty"
  1328. br.Ret = 408
  1329. return
  1330. }
  1331. listType := []*cygx.CygxTryStageRep{{Name: "大套餐", TryStage: 1}, {Name: "小套餐", TryStage: 2}}
  1332. listStatus := []*cygx.CygxTryStageRep{{Name: "未分类", TryStage: 1}, {Name: "推进", TryStage: 2}, {Name: "跟踪", TryStage: 3}, {Name: "预备", TryStage: 4}}
  1333. List := []*cygx.CygxUserTableStatusRep{{Name: "正式", List: listType, TryStage: "正式"}, {Name: "试用", List: listStatus, TryStage: "试用"}, {Name: "冻结", List: []*cygx.CygxTryStageRep{}, TryStage: "冻结"}, {Name: "X类试用", List: []*cygx.CygxTryStageRep{}, TryStage: "X类试用"}}
  1334. resp := new(cygx.CygxUserTableStatusListRep)
  1335. resp.List = List
  1336. br.Ret = 200
  1337. br.Success = true
  1338. br.Msg = "获取成功"
  1339. br.Data = resp
  1340. }
  1341. // @Title 用户互动量
  1342. // @Description 状态搜索栏接口
  1343. // @Param UserId query int true "用户id"
  1344. // @Success 200 {object} cygx.CygxUserTableStatusListRep
  1345. // @router /user/interactionNum [get]
  1346. func (this *UserController) InteractionNum() {
  1347. br := new(models.BaseResponse).Init()
  1348. defer func() {
  1349. this.Data["json"] = br
  1350. this.ServeJSON()
  1351. }()
  1352. sysUser := this.SysUser
  1353. if sysUser == nil {
  1354. br.Msg = "请登录"
  1355. br.ErrMsg = "请登录,SysUser Is Empty"
  1356. br.Ret = 408
  1357. return
  1358. }
  1359. userId, _ := this.GetInt("UserId")
  1360. if userId < 1 {
  1361. br.Msg = "用户不存在"
  1362. return
  1363. }
  1364. wxUser, err := models.GetWxUserByUserId(userId)
  1365. if err != nil {
  1366. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1367. br.Msg = "获取信息失败"
  1368. return
  1369. }
  1370. cp, err := company.GetCompanyProductByCompanyIdAndProductId(wxUser.CompanyId, 2)
  1371. if err != nil && err.Error() != utils.ErrNoRow() {
  1372. br.Msg = "获取客户信息失败"
  1373. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1374. return
  1375. }
  1376. resp := new(cygx.CygxCygxInteractionNumRespListResp)
  1377. for i := 0; i < 4; i++ {
  1378. item := new(cygx.CygxInteractionNumResp)
  1379. if cp != nil && cp.Status == "正式" {
  1380. //阅读记录总数
  1381. var startDate, endDate string
  1382. item.DateTime = time.Now().AddDate(0, -i, 0).Format("2006.01")
  1383. startDate = utils.GetOneMonthFirstDay(time.Now().AddDate(0, -i, 0)).Format(utils.FormatDate)
  1384. endDate = utils.GetOneMonthLastDay(time.Now().AddDate(0, -i, 0)).Format(utils.FormatDate)
  1385. countDetail, err := cygx.GetCompanyInteractionTableCountBytime(wxUser.CompanyId, startDate, endDate)
  1386. if err != nil {
  1387. br.Msg = "获取信息失败"
  1388. br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
  1389. return
  1390. }
  1391. item.InteractionNum = countDetail.HistoryNum + countDetail.CountNum + countDetail.IndustryFllowNum + countDetail.DepartmentFollowNum + countDetail.KeyWordNum + countDetail.OnLineNum + countDetail.OfficeNum + countDetail.ChartNum
  1392. } else {
  1393. var weekStr string
  1394. switch i {
  1395. case 0:
  1396. weekStr = "本周("
  1397. case 1:
  1398. weekStr = "上周("
  1399. case 2:
  1400. weekStr = "上两周("
  1401. case 3:
  1402. weekStr = "上三周("
  1403. }
  1404. item.DateTime = weekStr + utils.GetNowWeekMonday().AddDate(0, 0, -i*7).Format("01.02") + "~" + utils.GetNowWeekMonday().AddDate(0, 0, -i*7+6).Format("01.02") + ")"
  1405. var startDate, endDate string
  1406. startDate = utils.GetNowWeekMonday().AddDate(0, 0, -i*7).Format(utils.FormatDate)
  1407. endDate = utils.GetNowWeekMonday().AddDate(0, 0, -i*7+6).Format(utils.FormatDate)
  1408. countDetail, err := cygx.GetCompanyInteractionTableCountBytime(wxUser.CompanyId, startDate, endDate)
  1409. if err != nil {
  1410. br.Msg = "获取信息失败"
  1411. br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
  1412. return
  1413. }
  1414. item.InteractionNum = countDetail.HistoryNum + countDetail.CountNum + countDetail.IndustryFllowNum + countDetail.DepartmentFollowNum + countDetail.KeyWordNum + countDetail.OnLineNum + countDetail.OfficeNum + countDetail.ChartNum + countDetail.TripNum + countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum
  1415. }
  1416. resp.List = append(resp.List, item)
  1417. }
  1418. br.Ret = 200
  1419. br.Success = true
  1420. br.Msg = "获取成功"
  1421. br.Data = resp
  1422. }
  1423. // @Title 标签检索用户相关互动
  1424. // @Description 标签检索用户相关互动接口
  1425. // @Param UserId query int true "用户id"
  1426. // @Param KeyWord query string true "搜索关键词"
  1427. // @Param Source query int true "来源 1:报告阅读,2:报告收藏,3:相关活动,4:专项产业调研"
  1428. // @Success 200 {object} cygx.UserInteractionrelevantListResp
  1429. // @router /user/interaction/relevant [get]
  1430. func (this *UserController) InteractionRelevant() {
  1431. br := new(models.BaseResponse).Init()
  1432. defer func() {
  1433. this.Data["json"] = br
  1434. this.ServeJSON()
  1435. }()
  1436. sysUser := this.SysUser
  1437. if sysUser == nil {
  1438. br.Msg = "请登录"
  1439. br.ErrMsg = "请登录,SysUser Is Empty"
  1440. br.Ret = 408
  1441. return
  1442. }
  1443. userId, _ := this.GetInt("UserId")
  1444. source, _ := this.GetInt("Source")
  1445. keyWord := this.GetString("KeyWord")
  1446. if userId < 1 {
  1447. br.Msg = "用户不存在"
  1448. return
  1449. }
  1450. wxUser, err := models.GetWxUserByUserId(userId)
  1451. if err != nil {
  1452. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1453. br.Msg = "获取信息失败"
  1454. return
  1455. }
  1456. managementIds, err := cygx.GetManagementIdsByName(keyWord)
  1457. if err != nil {
  1458. br.Msg = "获取信息失败"
  1459. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  1460. return
  1461. }
  1462. subjectIds, err := cygx.GetIndustrialSubjectIdsByName(keyWord)
  1463. if err != nil {
  1464. br.Msg = "获取信息失败"
  1465. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  1466. return
  1467. }
  1468. resp := new(cygx.UserInteractionrelevantListResp)
  1469. var condition string
  1470. if source == 1 || source == 2 {
  1471. var articleIds string
  1472. if managementIds != "" || subjectIds != "" {
  1473. var articleIdmanagement string
  1474. var articleIdsubject string
  1475. if managementIds != "" {
  1476. articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds)
  1477. if err != nil {
  1478. br.Msg = "获取信息失败"
  1479. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  1480. return
  1481. }
  1482. }
  1483. if subjectIds != "" {
  1484. articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds)
  1485. if err != nil {
  1486. br.Msg = "获取信息失败"
  1487. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  1488. return
  1489. }
  1490. }
  1491. if articleIdmanagement != "" && articleIdsubject != "" {
  1492. articleIds = articleIdmanagement + "," + articleIdsubject
  1493. } else if articleIdmanagement != "" && articleIdsubject == "" {
  1494. articleIds = articleIdmanagement
  1495. } else if articleIdmanagement == "" && articleIdsubject != "" {
  1496. articleIds = articleIdsubject
  1497. }
  1498. } else {
  1499. matchDetail, err := cygx.GetCygxReportMappingCygxDetailByName(keyWord)
  1500. if err != nil && err.Error() != utils.ErrNoRow() {
  1501. br.Msg = "获取信息失败"
  1502. br.ErrMsg = "GetCygxReportMappingCygxDetail,Err:" + err.Error()
  1503. return
  1504. }
  1505. if matchDetail != nil {
  1506. var condition string
  1507. var pars []interface{}
  1508. condition = ` AND id_cygx = ? `
  1509. pars = append(pars, matchDetail.Id)
  1510. listGroup, err := cygx.GetCygxReportMappingGroupList(condition, pars, 0, 999)
  1511. if err != nil && err.Error() != utils.ErrNoRow() {
  1512. br.Msg = "获取失败"
  1513. br.ErrMsg = "获取失败,Err:" + err.Error()
  1514. return
  1515. }
  1516. var categoryIds []int
  1517. for _, v := range listGroup {
  1518. categoryIds = append(categoryIds, v.CategoryIdCelue)
  1519. }
  1520. pars = make([]interface{}, 0)
  1521. condition = ` AND category_id IN (` + utils.GetOrmInReplace(len(categoryIds)) + `)`
  1522. pars = append(pars, categoryIds)
  1523. listArticle, err := cygx.GetArticlList(condition, pars, 0, 999)
  1524. if err != nil && err.Error() != utils.ErrNoRow() {
  1525. br.Msg = "获取失败"
  1526. br.ErrMsg = "获取失败,Err:" + err.Error()
  1527. return
  1528. }
  1529. for _, v := range listArticle {
  1530. articleIds += strconv.Itoa(v.ArticleId) + ","
  1531. }
  1532. articleIds = strings.TrimRight(articleIds, ",")
  1533. }
  1534. }
  1535. if articleIds != "" {
  1536. condition = ` AND r.article_id IN (` + articleIds + `)`
  1537. if source == 1 {
  1538. condition += ` AND r.stop_time > 4 `
  1539. resp.List, err = cygx.GetCygxArticleHistoryRecordByUser(wxUser.Mobile, wxUser.Email, condition, 0, 0)
  1540. } else {
  1541. resp.List, err = cygx.GetCygxArticleCollectByUser(userId, 0, 0, condition)
  1542. }
  1543. if err != nil && err.Error() != utils.ErrNoRow() {
  1544. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1545. br.Msg = "获取用户阅读记录"
  1546. return
  1547. }
  1548. if len(resp.List) > 0 {
  1549. for k, v := range resp.List {
  1550. resp.List[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  1551. resp.List[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  1552. if v.ArticleId >= utils.SummaryArticleId {
  1553. resp.List[k].ArticleType = 1
  1554. } else {
  1555. resp.List[k].ArticleType = 2
  1556. }
  1557. }
  1558. }
  1559. }
  1560. } else if source == 3 {
  1561. activityIdByLabel, err := cygx.GetactivityIdsByLabel(keyWord)
  1562. if err != nil {
  1563. br.Msg = "获取信息失败"
  1564. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  1565. return
  1566. }
  1567. activityId := activityIdByLabel
  1568. if activityId != "" {
  1569. condition = ` AND s.is_meeting = 1 AND s.activity_id IN (` + activityId + `) AND s.mobile = ` + wxUser.Mobile
  1570. resp.List, err = cygx.GetActivityMeetByUser(condition, 0, 0)
  1571. if err != nil && err.Error() != utils.ErrNoRow() {
  1572. br.Msg = "获取信息失败"
  1573. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  1574. return
  1575. }
  1576. }
  1577. } else if source == 4 {
  1578. activityIdByLabel, err := cygx.GetactivitySpecilIdsByLabel(keyWord)
  1579. if err != nil {
  1580. br.Msg = "获取信息失败"
  1581. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  1582. return
  1583. }
  1584. activityId := activityIdByLabel
  1585. if activityId != "" {
  1586. condition = ` AND s.is_meeting = 1 AND s.activity_id IN (` + activityId + `) AND s.mobile = ` + wxUser.Mobile
  1587. resp.List, err = cygx.GetActivitySpecialMeetByUser(condition, 0, 0)
  1588. if err != nil && err.Error() != utils.ErrNoRow() {
  1589. br.Msg = "获取信息失败"
  1590. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  1591. return
  1592. }
  1593. }
  1594. }
  1595. if len(resp.List) == 0 {
  1596. resp.List = make([]*cygx.UserInteraction, 0)
  1597. }
  1598. resp.IndustryName = keyWord
  1599. if managementIds != "" {
  1600. count, err := cygx.GetCygxIndustryFllowCountByUser(userId, managementIds)
  1601. if err != nil {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "获取用户是否关注失败,Err:" + err.Error()
  1604. return
  1605. }
  1606. if count > 0 {
  1607. resp.IsFllow = true
  1608. }
  1609. }
  1610. br.Ret = 200
  1611. br.Success = true
  1612. br.Msg = "获取成功"
  1613. br.Data = resp
  1614. }
  1615. // @Title 用户相关互动下载
  1616. // @Description 用户相关互动下载接口
  1617. // @Param UserId query int true "用户id"
  1618. // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
  1619. // @Param IsMeeting query string true "是否到会 1到会、2未到会"
  1620. // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
  1621. // @Param StartDate query string true "开始时间"
  1622. // @Param EndDate query string true "结束时间"
  1623. // @Param KeyWord query string true "搜索关键词"
  1624. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  1625. // @Success 200 {object} cygx.CygxUserTableStatusListRep
  1626. // @router /user/export/interaction [get]
  1627. func (this *UserController) ExportInteraction() {
  1628. br := new(models.BaseResponse).Init()
  1629. defer func() {
  1630. this.Data["json"] = br
  1631. this.ServeJSON()
  1632. }()
  1633. sysUser := this.SysUser
  1634. if sysUser == nil {
  1635. br.Msg = "请登录"
  1636. br.ErrMsg = "请登录,SysUser Is Empty"
  1637. br.Ret = 408
  1638. return
  1639. }
  1640. userId, _ := this.GetInt("UserId")
  1641. isMeeting := this.GetString("IsMeeting")
  1642. meetType := this.GetString("MeetType")
  1643. startDate := this.GetString("StartDate")
  1644. endDate := this.GetString("EndDate")
  1645. keyWord := this.GetString("KeyWord")
  1646. source, _ := this.GetInt("Source")
  1647. classType, _ := this.GetInt("ClassType", 1)
  1648. if userId < 1 {
  1649. br.Msg = "用户不存在"
  1650. return
  1651. }
  1652. wxUser, err := models.GetWxUserByUserId(userId)
  1653. if err != nil {
  1654. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1655. br.Msg = "获取信息失败"
  1656. return
  1657. }
  1658. mobile := wxUser.Mobile
  1659. var list []*cygx.UserInteraction
  1660. var condition string
  1661. var sheetName string
  1662. if source == 1 {
  1663. sheetName = "报告阅读列表"
  1664. if startDate != "" {
  1665. startDate += " 00:00:00"
  1666. condition += ` AND r.create_time >= '` + startDate + `' `
  1667. }
  1668. if endDate != "" {
  1669. endDate += " 23:59:59"
  1670. condition += ` AND r.create_time <= '` + endDate + `' `
  1671. }
  1672. if wxUser.Mobile == "" {
  1673. wxUser.Mobile = wxUser.Email
  1674. }
  1675. //total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
  1676. //if err != nil {
  1677. // br.Msg = "获取信息失败"
  1678. // br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
  1679. // return
  1680. //}
  1681. if classType == 1 {
  1682. condition += " AND art.article_type_id = 0 "
  1683. } else {
  1684. condition += " AND art.article_type_id > 0 "
  1685. }
  1686. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  1687. _, list, err = cygx.GetCygxArticleHistoryRecordByUserNew(condition, 0, 9999)
  1688. if err != nil && err.Error() != utils.ErrNoRow() {
  1689. br.Msg = "获取信息失败"
  1690. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  1691. return
  1692. }
  1693. var articleIds []int
  1694. if len(list) > 0 {
  1695. for k, v := range list {
  1696. if v.ArticleId >= utils.SummaryArticleId {
  1697. list[k].ArticleType = 1
  1698. } else {
  1699. list[k].ArticleType = 2
  1700. }
  1701. if list[k].PermissionName == "" {
  1702. list[k].PermissionName = v.CategoryName
  1703. }
  1704. if v.SpecialType == 0 {
  1705. articleIds = append(articleIds, v.ArticleId)
  1706. }
  1707. }
  1708. mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByArticleId(articleIds) // 关联产业
  1709. mapSubjectLabel := cygxService.GetArticleSubjectLabelByArticleId(articleIds) // 关联标的
  1710. for _, v := range list {
  1711. v.IndustryName = strings.Join(mapIndustrialLabel[v.ArticleId], "/")
  1712. v.SubjectNameStr = strings.Join(mapSubjectLabel[v.ArticleId], "/")
  1713. }
  1714. }
  1715. } else if source == 2 {
  1716. sheetName = "到会管理名单"
  1717. if mobile != "" {
  1718. condition = ` AND s.mobile = '` + mobile + `' `
  1719. if classType == 1 {
  1720. condition += " AND a.chart_permission_id != 31 "
  1721. } else {
  1722. condition += " AND a.chart_permission_id = 31 "
  1723. }
  1724. if isMeeting == "1" {
  1725. condition += ` AND s.is_meeting = 1 `
  1726. }
  1727. if isMeeting == "2" {
  1728. condition += ` AND s.is_meeting = 0 `
  1729. }
  1730. if meetType == "1" {
  1731. condition += ` AND t.activity_type = 1 `
  1732. }
  1733. if meetType == "2" {
  1734. condition += ` AND t.activity_type = 0 `
  1735. }
  1736. if startDate != "" {
  1737. startDate += " 00:00:00"
  1738. condition += ` AND a.activity_time >= '` + startDate + `' `
  1739. }
  1740. if endDate != "" {
  1741. endDate += " 23:59:59"
  1742. condition += ` AND a.activity_time <= '` + endDate + `' `
  1743. }
  1744. if keyWord != "" {
  1745. condition += ` AND a.activity_name LIKE '%` + keyWord + `%' `
  1746. }
  1747. list, err = cygx.GetActivityMeetByUser(condition, 0, 0)
  1748. if err != nil && err.Error() != utils.ErrNoRow() {
  1749. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1750. br.Msg = "获取参会人数列表失败"
  1751. return
  1752. }
  1753. if len(list) > 0 {
  1754. for k, v := range list {
  1755. if v.ActivityType == 1 {
  1756. if v.SignupType == "2" {
  1757. list[k].InteractionType = "自主拨入"
  1758. } else {
  1759. list[k].InteractionType = "预约外呼"
  1760. }
  1761. if v.ReminderNum > 0 {
  1762. list[k].InteractionType += ",会议提醒"
  1763. }
  1764. }
  1765. }
  1766. }
  1767. }
  1768. } else if source == 11 {
  1769. sheetName = "专栏文章阅读记录"
  1770. if startDate != "" {
  1771. startDate += " 00:00:00"
  1772. condition += ` AND r.create_time >= '` + startDate + `' `
  1773. }
  1774. if endDate != "" {
  1775. endDate += " 23:59:59"
  1776. condition += ` AND r.create_time <= '` + endDate + `' `
  1777. }
  1778. if wxUser.Mobile == "" {
  1779. wxUser.Mobile = wxUser.Email
  1780. }
  1781. condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
  1782. _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
  1783. if err != nil && err.Error() != utils.ErrNoRow() {
  1784. br.Msg = "获取信息失败"
  1785. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  1786. return
  1787. }
  1788. }
  1789. //创建excel
  1790. dir, err := os.Executable()
  1791. exPath := filepath.Dir(dir)
  1792. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1793. xlsxFile := xlsx.NewFile()
  1794. if err != nil {
  1795. br.Msg = "生成文件失败"
  1796. br.ErrMsg = "生成文件失败"
  1797. return
  1798. }
  1799. style := xlsx.NewStyle()
  1800. alignment := xlsx.Alignment{
  1801. Horizontal: "center",
  1802. Vertical: "center",
  1803. WrapText: true,
  1804. }
  1805. style.Alignment = alignment
  1806. style.ApplyAlignment = true
  1807. sheet, err := xlsxFile.AddSheet(sheetName)
  1808. if err != nil {
  1809. br.Msg = "新增Sheet失败"
  1810. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1811. return
  1812. }
  1813. if source == 1 {
  1814. //标头
  1815. rowTitle := sheet.AddRow()
  1816. cellA := rowTitle.AddCell()
  1817. cellA.Value = "报告标题"
  1818. cellB := rowTitle.AddCell()
  1819. cellB.Value = "所属行业"
  1820. cellC := rowTitle.AddCell()
  1821. cellC.Value = "所属产业"
  1822. cellD := rowTitle.AddCell()
  1823. cellD.Value = "关联标的"
  1824. cellE := rowTitle.AddCell()
  1825. cellE.Value = "发布时间"
  1826. cellF := rowTitle.AddCell()
  1827. cellF.Value = "阅读时间"
  1828. cellG := rowTitle.AddCell()
  1829. cellG.Value = "阅读时长"
  1830. for _, item := range list {
  1831. row := sheet.AddRow()
  1832. cellA := row.AddCell()
  1833. cellA.Value = item.Title
  1834. cellB := row.AddCell()
  1835. cellB.Value = item.PermissionName
  1836. cellC := row.AddCell()
  1837. cellC.Value = item.IndustryName
  1838. cellD := row.AddCell()
  1839. cellD.Value = item.SubjectNameStr
  1840. cellE := row.AddCell()
  1841. cellE.Value = item.PublishDate
  1842. cellF := row.AddCell()
  1843. cellF.Value = item.CreateTime
  1844. cellG := row.AddCell()
  1845. cellG.Value = item.StopTime
  1846. }
  1847. } else if source == 2 {
  1848. //标头
  1849. rowTitle := sheet.AddRow()
  1850. cellA := rowTitle.AddCell()
  1851. cellA.Value = "活动名称"
  1852. cellB := rowTitle.AddCell()
  1853. cellB.Value = "所属行业"
  1854. cellC := rowTitle.AddCell()
  1855. cellC.Value = "活动类型"
  1856. cellD := rowTitle.AddCell()
  1857. cellD.Value = "活动主题"
  1858. cellE := rowTitle.AddCell()
  1859. cellE.Value = "活动时间"
  1860. cellF := rowTitle.AddCell()
  1861. cellF.Value = "是否到会"
  1862. cellG := rowTitle.AddCell()
  1863. cellG.Value = "首次入会时间"
  1864. cellH := rowTitle.AddCell()
  1865. cellH.Value = "最后退出时间"
  1866. cellI := rowTitle.AddCell()
  1867. cellI.Value = "参与总时长"
  1868. cellJ := rowTitle.AddCell()
  1869. cellJ.Value = "参会方式"
  1870. cellK := rowTitle.AddCell()
  1871. cellK.Value = "参会权鉴"
  1872. cellL := rowTitle.AddCell()
  1873. cellL.Value = "参会状态"
  1874. for _, item := range list {
  1875. row := sheet.AddRow()
  1876. cellA := row.AddCell()
  1877. cellA.Value = item.ActivityName
  1878. cellB := row.AddCell()
  1879. cellB.Value = item.PermissionName
  1880. cellC := row.AddCell()
  1881. cellC.Value = item.ActivityTypeName
  1882. cellD := row.AddCell()
  1883. cellD.Value = item.Label
  1884. cellE := row.AddCell()
  1885. cellE.Value = item.ActivityTime
  1886. cellF := row.AddCell()
  1887. if item.IsMeeting == 1 {
  1888. cellF.Value = "到会"
  1889. cellG := row.AddCell()
  1890. cellG.Value = item.FirstMeetingTime
  1891. cellH := row.AddCell()
  1892. cellH.Value = item.LastMeetingTime
  1893. cellI := row.AddCell()
  1894. cellI.Value = item.Duration
  1895. cellJ := row.AddCell()
  1896. cellJ.Value = item.LastMeetingTime
  1897. cellK := row.AddCell()
  1898. cellK.Value = item.MeetingTypeStr
  1899. cellL := row.AddCell()
  1900. cellL.Value = item.MeetingStatusStr
  1901. } else {
  1902. cellF.Value = "未到会"
  1903. }
  1904. }
  1905. } else if source == 11 {
  1906. //标头
  1907. rowTitle := sheet.AddRow()
  1908. cellA := rowTitle.AddCell()
  1909. cellA.Value = "文章标题"
  1910. cellB := rowTitle.AddCell()
  1911. cellB.Value = "文章类型"
  1912. cellC := rowTitle.AddCell()
  1913. cellC.Value = "标签"
  1914. cellD := rowTitle.AddCell()
  1915. cellD.Value = "发布时间"
  1916. cellE := rowTitle.AddCell()
  1917. cellE.Value = "阅读时间"
  1918. cellF := rowTitle.AddCell()
  1919. cellF.Value = "阅读时长"
  1920. cellG := rowTitle.AddCell()
  1921. cellG.Value = "阅读来源"
  1922. for _, item := range list {
  1923. row := sheet.AddRow()
  1924. cellA := row.AddCell()
  1925. cellA.Value = item.Title
  1926. cellB := row.AddCell()
  1927. if item.SpecialType == 1 {
  1928. cellB.Value = "笔记"
  1929. } else {
  1930. cellB.Value = "观点"
  1931. }
  1932. cellC := row.AddCell()
  1933. cellC.Value = item.IndustryName
  1934. cellD := row.AddCell()
  1935. cellD.Value = item.PublishDate
  1936. cellE := row.AddCell()
  1937. cellE.Value = item.CreateTime
  1938. cellF := row.AddCell()
  1939. cellF.Value = item.StopTime
  1940. cellG := row.AddCell()
  1941. cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
  1942. }
  1943. } else if source == 11 {
  1944. //标头
  1945. rowTitle := sheet.AddRow()
  1946. cellA := rowTitle.AddCell()
  1947. cellA.Value = "文章标题"
  1948. cellB := rowTitle.AddCell()
  1949. cellB.Value = "文章类型"
  1950. cellC := rowTitle.AddCell()
  1951. cellC.Value = "标签"
  1952. cellD := rowTitle.AddCell()
  1953. cellD.Value = "发布时间"
  1954. cellE := rowTitle.AddCell()
  1955. cellE.Value = "阅读时间"
  1956. cellF := rowTitle.AddCell()
  1957. cellF.Value = "阅读时长"
  1958. cellG := rowTitle.AddCell()
  1959. cellG.Value = "阅读来源"
  1960. for _, item := range list {
  1961. row := sheet.AddRow()
  1962. cellA := row.AddCell()
  1963. cellA.Value = item.Title
  1964. cellB := row.AddCell()
  1965. if item.SpecialType == 1 {
  1966. cellB.Value = "笔记"
  1967. } else {
  1968. cellB.Value = "观点"
  1969. }
  1970. cellC := row.AddCell()
  1971. cellC.Value = item.IndustryName
  1972. cellD := row.AddCell()
  1973. cellD.Value = item.PublishDate
  1974. cellE := row.AddCell()
  1975. cellE.Value = item.CreateTime
  1976. cellF := row.AddCell()
  1977. cellF.Value = item.StopTime
  1978. cellG := row.AddCell()
  1979. cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
  1980. }
  1981. }
  1982. err = xlsxFile.Save(downLoadnFilePath)
  1983. if err != nil {
  1984. br.Msg = "保存文件失败"
  1985. br.ErrMsg = "保存文件失败"
  1986. return
  1987. }
  1988. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1989. downloadFileName := wxUser.RealName + randStr + ".xlsx"
  1990. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1991. defer func() {
  1992. os.Remove(downLoadnFilePath)
  1993. }()
  1994. br.Ret = 200
  1995. br.Success = true
  1996. br.Msg = "获取成功"
  1997. }
  1998. // @Title 机构互动详情table栏
  1999. // @Description 互动详情table栏接口
  2000. // @Param CompanyId query int true "公司ID"
  2001. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  2002. // @Success 200 {object} cygx.UserRemarksListResp
  2003. // @router /user/company/table/list [get]
  2004. func (this *UserController) CompanyTableList() {
  2005. br := new(models.BaseResponse).Init()
  2006. defer func() {
  2007. this.Data["json"] = br
  2008. this.ServeJSON()
  2009. }()
  2010. sysUser := this.SysUser
  2011. if sysUser == nil {
  2012. br.Msg = "请登录"
  2013. br.ErrMsg = "请登录,SysUser Is Empty"
  2014. br.Ret = 408
  2015. return
  2016. }
  2017. companyId, _ := this.GetInt("CompanyId")
  2018. classType, _ := this.GetInt("ClassType", 1)
  2019. if companyId < 1 {
  2020. br.Msg = "机构不存在"
  2021. return
  2022. }
  2023. comanyDetail, err := company.GetCompanyDetailById(companyId)
  2024. if err != nil {
  2025. br.Msg = "获取信息失败"
  2026. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2027. return
  2028. }
  2029. resp := new(cygx.CygxUserTableListRep)
  2030. var isAdminRole bool
  2031. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  2032. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  2033. isAdminRole = true
  2034. }
  2035. var pars []interface{}
  2036. condition := ` AND r.company_id IN ( ` + strconv.Itoa(companyId) + ` ) AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' ` //过滤当天时间
  2037. //totalEs, _, err := services.SearcCygxArticleHistoryData(utils.IndexNameArticleHistory, "", "", "", strconv.Itoa(companyId), 0, 0)
  2038. //if err != nil {
  2039. // br.Msg = "获取信息失败"
  2040. // br.ErrMsg = "获取Es文章阅读数量失败,Err:" + err.Error()
  2041. // return
  2042. //}
  2043. conditionArtcile := condition //文章搜索条件
  2044. conditionActivityMeet := condition //活动到会搜索条件
  2045. conditionIndustryFllow := condition //产业关注搜索条件
  2046. conditionKeyWord := condition //关键词记录搜索条件
  2047. if classType == 1 {
  2048. conditionArtcile += " AND art.article_type_id = 0 "
  2049. conditionActivityMeet += " AND a.chart_permission_id != 31 "
  2050. conditionIndustryFllow += " AND m.chart_permission_id != 31 "
  2051. conditionKeyWord += " AND r.register_platform IN (1,2) "
  2052. } else {
  2053. conditionArtcile += " AND art.article_type_id > 0 "
  2054. conditionActivityMeet += " AND a.chart_permission_id = 31 "
  2055. conditionIndustryFllow += " AND m.chart_permission_id = 31 "
  2056. conditionKeyWord += " AND r.register_platform IN (5,6) "
  2057. }
  2058. var historyNum int //报告阅读列表
  2059. var activityNum int //活动互动记录
  2060. var triptotal int //专项调研
  2061. var articleCollect int //收藏的报告
  2062. var chartNum int //收藏图表
  2063. var industryFllowNum int //关注的产业
  2064. var departmentFollowNum int //关注的作者
  2065. var keyWordNum int //搜索
  2066. var roadshowTotal int //音视频播放
  2067. var tagNum int //首页标签点击
  2068. var yanxuanSpecialNum int //专栏文章阅读记录
  2069. var yanxuanSpecialCollectNum int //收藏的专栏文章
  2070. var yanxuanSpecialFollowNum int //关注的专栏作者
  2071. var feedbackNum int //交流反馈数量
  2072. var calendarMeetingNum int //1v1 路演数量
  2073. if isAdminRole {
  2074. historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCount(conditionArtcile, pars)
  2075. if err != nil {
  2076. br.Msg = "获取信息失败"
  2077. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  2078. return
  2079. }
  2080. activityNum, err = cygx.GetActivityMeetByCompanyCount(conditionActivityMeet)
  2081. if err != nil {
  2082. br.Msg = "获取信息失败"
  2083. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  2084. return
  2085. }
  2086. //获取用户收藏记录总数
  2087. articleCollect, err = cygx.GetCygxArticleCollectCountByCompany(conditionArtcile)
  2088. if err != nil {
  2089. br.Msg = "获取信息失败"
  2090. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  2091. return
  2092. }
  2093. //获取用户关注总数
  2094. industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompany(conditionIndustryFllow)
  2095. if err != nil {
  2096. br.Msg = "获取信息失败 "
  2097. br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
  2098. return
  2099. }
  2100. //获取关注作者总数
  2101. departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
  2102. if err != nil {
  2103. br.Msg = "获取信息失败"
  2104. br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
  2105. return
  2106. }
  2107. //获取搜索记录
  2108. keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompany(conditionKeyWord)
  2109. if err != nil {
  2110. br.Msg = "获取信息失败"
  2111. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2112. return
  2113. }
  2114. chartNum, err = cygx.GetChartCountByUserMobile(condition)
  2115. if err != nil {
  2116. br.Msg = "获取信息失败"
  2117. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  2118. return
  2119. }
  2120. triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
  2121. if err != nil {
  2122. br.Msg = "获取信息失败"
  2123. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2124. return
  2125. }
  2126. roadshowTotal, err = cygx.GetCygxRoadshowCountByCompany(condition)
  2127. if err != nil {
  2128. br.Msg = "获取信息失败"
  2129. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2130. return
  2131. }
  2132. tagNum, err = cygx.GetCygxTagHistoryCount(condition)
  2133. if err != nil {
  2134. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2135. br.Msg = "获取搜索记录失败"
  2136. return
  2137. }
  2138. yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCount(condition, pars)
  2139. if err != nil {
  2140. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2141. br.Msg = "获取研选专栏阅读数量失败"
  2142. return
  2143. }
  2144. yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCount(condition, pars)
  2145. if err != nil {
  2146. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2147. br.Msg = "获取收藏的专栏文章数量失败"
  2148. return
  2149. }
  2150. yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCount(condition, pars)
  2151. if err != nil {
  2152. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2153. br.Msg = "获取关注的专栏作者数量失败"
  2154. return
  2155. }
  2156. feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModel(condition, pars)
  2157. if err != nil {
  2158. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2159. br.Msg = "获取交流反馈数量失败"
  2160. return
  2161. }
  2162. calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModel(condition, pars)
  2163. if err != nil {
  2164. br.Msg = "获取信息失败"
  2165. br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModel,Err:" + err.Error()
  2166. return
  2167. }
  2168. } else {
  2169. historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(conditionArtcile, pars)
  2170. if err != nil {
  2171. br.Msg = "获取信息失败"
  2172. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  2173. return
  2174. }
  2175. activityNum, err = cygx.GetActivityMeetByCompanyCountWeekly(conditionActivityMeet)
  2176. if err != nil {
  2177. br.Msg = "获取信息失败"
  2178. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  2179. return
  2180. }
  2181. //获取用户收藏记录总数
  2182. articleCollect, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(conditionArtcile)
  2183. if err != nil {
  2184. br.Msg = "获取信息失败"
  2185. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  2186. return
  2187. }
  2188. //获取用户关注总数
  2189. industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
  2190. if err != nil {
  2191. br.Msg = "获取信息失败 "
  2192. br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
  2193. return
  2194. }
  2195. //获取关注作者总数
  2196. departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
  2197. if err != nil {
  2198. br.Msg = "获取信息失败"
  2199. br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
  2200. return
  2201. }
  2202. //获取搜索记录
  2203. keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(conditionKeyWord)
  2204. if err != nil {
  2205. br.Msg = "获取信息失败"
  2206. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2207. return
  2208. }
  2209. chartNum, err = cygx.GetChartCountByUserMobileWeekly(condition)
  2210. if err != nil {
  2211. br.Msg = "获取信息失败"
  2212. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  2213. return
  2214. }
  2215. triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
  2216. if err != nil {
  2217. br.Msg = "获取信息失败"
  2218. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2219. return
  2220. }
  2221. roadshowTotal, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
  2222. if err != nil {
  2223. br.Msg = "获取信息失败"
  2224. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2225. return
  2226. }
  2227. tagNum, err = cygx.GetCygxTagHistoryCountWeekly(condition)
  2228. if err != nil {
  2229. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2230. br.Msg = "获取搜索记录失败"
  2231. return
  2232. }
  2233. yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCountWeekly(condition, pars)
  2234. if err != nil {
  2235. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2236. br.Msg = "获取研选专栏阅读数量失败"
  2237. return
  2238. }
  2239. yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCountWeekly(condition, pars)
  2240. if err != nil {
  2241. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2242. br.Msg = "获取收藏的专栏文章数量失败"
  2243. return
  2244. }
  2245. yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCountWeekly(condition, pars)
  2246. if err != nil {
  2247. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2248. br.Msg = "获取关注的专栏作者数量失败"
  2249. return
  2250. }
  2251. feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModelWeekly(condition, pars)
  2252. if err != nil {
  2253. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2254. br.Msg = "获取交流反馈数量失败"
  2255. return
  2256. }
  2257. calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModelWeekly(condition, pars)
  2258. if err != nil {
  2259. br.Msg = "获取信息失败"
  2260. br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModelWeekly,Err:" + err.Error()
  2261. return
  2262. }
  2263. }
  2264. if classType == 1 {
  2265. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
  2266. {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
  2267. {PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
  2268. {PermissionName: "1v1路演", Source: 15, TotalNum: calendarMeetingNum},
  2269. {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
  2270. {PermissionName: "收藏图表", Source: 4, TotalNum: chartNum},
  2271. {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
  2272. {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
  2273. {PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
  2274. {PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum},
  2275. {PermissionName: "交流反馈", Source: 14, TotalNum: feedbackNum}}
  2276. resp.List = List
  2277. } else {
  2278. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
  2279. {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
  2280. {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
  2281. {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
  2282. {PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
  2283. {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: yanxuanSpecialNum},
  2284. {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: yanxuanSpecialCollectNum},
  2285. {PermissionName: "关注的专栏作者", Source: 13, TotalNum: yanxuanSpecialFollowNum},
  2286. {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum}}
  2287. resp.List = List
  2288. }
  2289. resp.ComapnyName = comanyDetail.CompanyName
  2290. br.Ret = 200
  2291. br.Success = true
  2292. br.Msg = "获取成功"
  2293. br.Data = resp
  2294. }
  2295. // @Title 机构互动详情
  2296. // @Description 机构互动详情接口
  2297. // @Param CompanyId query int true "公司ID"
  2298. // @Param Source query int true "来源"
  2299. // @Param IsMeeting query string false "是否到会 1到会、2未到会"
  2300. // @Param MeetType query string false "参会方式 1线上,2线下 默认为线上"
  2301. // @Param PageSize query int true "每页数据条数"
  2302. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2303. // @Param StartDate query string false "开始时间"
  2304. // @Param EndDate query string false "结束时间"
  2305. // @Param KeyWord query string false "搜索关键词"
  2306. // @Param ActivityName query string false "活动名称"
  2307. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  2308. // @Param IsExport query bool false "是否导出excel,默认是false"
  2309. // @Success 200 {object} cygx.UserInteractionListResp
  2310. // @router /user/company/interaction/detail [get]
  2311. func (this *UserController) CompanyTableDetail() {
  2312. br := new(models.BaseResponse).Init()
  2313. defer func() {
  2314. this.Data["json"] = br
  2315. this.ServeJSON()
  2316. }()
  2317. sysUser := this.SysUser
  2318. if sysUser == nil {
  2319. br.Msg = "请登录"
  2320. br.ErrMsg = "请登录,SysUser Is Empty"
  2321. br.Ret = 408
  2322. return
  2323. }
  2324. pageSize, _ := this.GetInt("PageSize")
  2325. currentIndex, _ := this.GetInt("CurrentIndex")
  2326. var startSize int
  2327. if pageSize <= 0 {
  2328. pageSize = utils.PageSize20
  2329. }
  2330. if currentIndex <= 0 {
  2331. currentIndex = 1
  2332. }
  2333. startSize = paging.StartIndex(currentIndex, pageSize)
  2334. companyId, _ := this.GetInt("CompanyId")
  2335. isMeeting := this.GetString("IsMeeting")
  2336. meetType := this.GetString("MeetType")
  2337. startDate := this.GetString("StartDate")
  2338. endDate := this.GetString("EndDate")
  2339. keyWord := this.GetString("KeyWord")
  2340. activityName := this.GetString("ActivityName")
  2341. source, _ := this.GetInt("Source")
  2342. classType, _ := this.GetInt("ClassType", 1)
  2343. if companyId < 1 {
  2344. br.Msg = "用户不存在"
  2345. return
  2346. }
  2347. isExport, _ := this.GetBool("IsExport")
  2348. if isExport {
  2349. pageSize = 10000
  2350. currentIndex = 1
  2351. }
  2352. // 1.标记用户表
  2353. //操作权限校验
  2354. resp := new(cygx.UserInteractionListResp)
  2355. var err error
  2356. var list []*cygx.UserInteraction
  2357. var total int
  2358. var condition string
  2359. var pars []interface{}
  2360. condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' `
  2361. if keyWord != "" {
  2362. condition += ` AND ( r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%')`
  2363. }
  2364. var isAdminRole bool
  2365. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  2366. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  2367. isAdminRole = true
  2368. }
  2369. if source == 1 {
  2370. if startDate != "" {
  2371. startDate += " 00:00:00"
  2372. condition += ` AND r.create_time >= '` + startDate + `' `
  2373. }
  2374. if endDate != "" {
  2375. endDate += " 23:59:59"
  2376. condition += ` AND r.create_time <= '` + endDate + `' `
  2377. }
  2378. condition += " AND r.source = 'article' "
  2379. if classType == 1 {
  2380. condition += " AND art.article_type_id = 0 "
  2381. } else {
  2382. condition += " AND art.article_type_id > 0 "
  2383. }
  2384. condition += " ORDER BY r.create_time DESC "
  2385. var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
  2386. if isAdminRole {
  2387. total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
  2388. if err != nil {
  2389. br.Msg = "获取信息失败"
  2390. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  2391. return
  2392. }
  2393. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
  2394. if err != nil && err.Error() != utils.ErrNoRow() {
  2395. br.Msg = "获取信息失败"
  2396. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2397. return
  2398. }
  2399. } else {
  2400. total, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(condition, pars)
  2401. if err != nil {
  2402. br.Msg = "获取信息失败"
  2403. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  2404. return
  2405. }
  2406. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, startSize, pageSize)
  2407. if err != nil && err.Error() != utils.ErrNoRow() {
  2408. br.Msg = "获取信息失败"
  2409. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2410. return
  2411. }
  2412. }
  2413. //处理查询信息回显
  2414. list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
  2415. if err != nil && err.Error() != utils.ErrNoRow() {
  2416. br.Msg = "获取信息失败"
  2417. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2418. return
  2419. }
  2420. for k, v := range list {
  2421. if classType == 1 {
  2422. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  2423. } else {
  2424. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  2425. }
  2426. if v.ReportId > 0 {
  2427. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  2428. }
  2429. }
  2430. //导出excel
  2431. if isExport {
  2432. exportListArticle(this, list, 2, br)
  2433. return
  2434. }
  2435. } else if source == 2 {
  2436. if isMeeting == "1" {
  2437. condition += ` AND r.is_meeting = 1 `
  2438. }
  2439. if isMeeting == "2" {
  2440. condition += ` AND r.is_meeting = 0 `
  2441. }
  2442. if meetType == "1" {
  2443. condition += ` AND t.activity_type = 1 `
  2444. }
  2445. if meetType == "2" {
  2446. condition += ` AND t.activity_type = 0 `
  2447. }
  2448. if startDate != "" {
  2449. startDate += " 00:00:00"
  2450. condition += ` AND a.activity_time >= '` + startDate + `' `
  2451. }
  2452. if endDate != "" {
  2453. endDate += " 23:59:59"
  2454. condition += ` AND a.activity_time <= '` + endDate + `' `
  2455. }
  2456. if activityName != "" {
  2457. condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
  2458. }
  2459. if classType == 1 {
  2460. condition += " AND a.chart_permission_id != 31 "
  2461. } else {
  2462. condition += " AND a.chart_permission_id = 31 "
  2463. }
  2464. if isAdminRole {
  2465. total, err = cygx.GetActivityMeetByCompanyCount(condition)
  2466. if err != nil {
  2467. br.Msg = "获取信息失败"
  2468. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  2469. return
  2470. }
  2471. list, err = cygx.GetActivityMeetByCompany(condition, startSize, pageSize)
  2472. if err != nil && err.Error() != utils.ErrNoRow() {
  2473. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2474. br.Msg = "获取参会人数列表失败"
  2475. return
  2476. }
  2477. } else {
  2478. total, err = cygx.GetActivityMeetByCompanyCountWeekly(condition)
  2479. if err != nil {
  2480. br.Msg = "获取信息失败"
  2481. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  2482. return
  2483. }
  2484. list, err = cygx.GetActivityMeetByCompanyWeekly(condition, startSize, pageSize)
  2485. if err != nil && err.Error() != utils.ErrNoRow() {
  2486. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2487. br.Msg = "获取参会人数列表失败"
  2488. return
  2489. }
  2490. }
  2491. if len(list) > 0 {
  2492. for k, v := range list {
  2493. if v.ActivityType == 1 {
  2494. if v.SignupType == "2" {
  2495. list[k].InteractionType = "自主拨入"
  2496. } else {
  2497. list[k].InteractionType = "预约外呼"
  2498. }
  2499. if v.ReminderNum > 0 {
  2500. list[k].InteractionType += ",会议提醒"
  2501. }
  2502. }
  2503. if v.IsMeeting == 0 || v.FirstMeetingTime == "0000-00-00 00:00:00" {
  2504. list[k].FirstMeetingTime = ""
  2505. list[k].LastMeetingTime = ""
  2506. }
  2507. if v.FirstMeetingTime == "0000-00-00 00:00:00" {
  2508. list[k].FirstMeetingTime = ""
  2509. list[k].LastMeetingTime = ""
  2510. }
  2511. }
  2512. }
  2513. //导出excel
  2514. if isExport {
  2515. exportListActivity(this, list, 2, br)
  2516. return
  2517. }
  2518. } else if source == 3 {
  2519. if classType == 1 {
  2520. condition += " AND art.article_type_id = 0 "
  2521. } else {
  2522. condition += " AND art.article_type_id > 0 "
  2523. }
  2524. if isAdminRole {
  2525. total, err = cygx.GetCygxArticleCollectCountByCompany(condition)
  2526. if err != nil {
  2527. br.Msg = "获取信息失败"
  2528. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  2529. return
  2530. }
  2531. list, err = cygx.GetCygxArticleCollectByCompany(startSize, pageSize, condition)
  2532. if err != nil && err.Error() != utils.ErrNoRow() {
  2533. br.Msg = "获取信息失败"
  2534. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  2535. return
  2536. }
  2537. } else {
  2538. total, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(condition)
  2539. if err != nil {
  2540. br.Msg = "获取信息失败"
  2541. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  2542. return
  2543. }
  2544. list, err = cygx.GetCygxArticleCollectByCompanyWeekly(startSize, pageSize, condition)
  2545. if err != nil && err.Error() != utils.ErrNoRow() {
  2546. br.Msg = "获取信息失败"
  2547. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  2548. return
  2549. }
  2550. }
  2551. if len(list) > 0 {
  2552. for k, v := range list {
  2553. if v.ArticleId >= utils.SummaryArticleId {
  2554. list[k].ArticleType = 1
  2555. } else {
  2556. list[k].ArticleType = 2
  2557. }
  2558. if classType == 1 {
  2559. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  2560. } else {
  2561. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  2562. }
  2563. if v.ReportId > 0 {
  2564. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  2565. }
  2566. }
  2567. }
  2568. } else if source == 4 {
  2569. if isAdminRole {
  2570. list, err = cygx.GetChartCollectList(condition)
  2571. if err != nil {
  2572. br.Msg = "获取信息失败"
  2573. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2574. return
  2575. }
  2576. } else {
  2577. list, err = cygx.GetChartCollectListWeekly(condition)
  2578. if err != nil {
  2579. br.Msg = "获取信息失败"
  2580. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2581. return
  2582. }
  2583. }
  2584. if len(list) > 0 {
  2585. for k, v := range list {
  2586. var err error
  2587. condition = ` AND a.publish_status = 1 AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.mobile = ` + v.Mobile + ` AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' ` //过滤当天时间
  2588. total, err = cygx.GetChartCountByUserMobile(condition)
  2589. if err != nil {
  2590. br.Msg = "获取信息失败"
  2591. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  2592. return
  2593. }
  2594. listChart, err := cygx.GetChartListCollectionWithCygxByMobile(condition, 0, 18)
  2595. if err != nil {
  2596. br.Msg = "获取信息失败"
  2597. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2598. return
  2599. }
  2600. for k, vChart := range listChart {
  2601. if vChart.PtagName != "" {
  2602. listChart[k].CtagNamePc = vChart.PtagName
  2603. }
  2604. if vChart.CtagName != "" {
  2605. listChart[k].CtagNamePc += "," + vChart.CtagName
  2606. }
  2607. if vChart.PtagNameTwo != "" {
  2608. listChart[k].CtagNamePc += "," + vChart.PtagNameTwo
  2609. }
  2610. if vChart.CtagNameTwo != "" {
  2611. listChart[k].CtagNamePc += "," + vChart.CtagNameTwo
  2612. }
  2613. }
  2614. pageChart := paging.GetPaging(currentIndex, 18, total)
  2615. list[k].ListChart = listChart
  2616. list[k].Paging = pageChart
  2617. list[k].IsEnd = pageChart.IsEnd
  2618. list[k].CurrentIndex = pageChart.CurrentIndex
  2619. }
  2620. }
  2621. } else if source == 5 {
  2622. if classType == 1 {
  2623. condition += " AND m.chart_permission_id != 31 "
  2624. } else {
  2625. condition += " AND m.chart_permission_id = 31 "
  2626. }
  2627. if isAdminRole {
  2628. total, err = cygx.GetCygxIndustryFllowCountByCompany(condition)
  2629. if err != nil {
  2630. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2631. br.Msg = "获取用户关注总数失败"
  2632. return
  2633. }
  2634. list, err = cygx.GetCygxIndustryFllowByCompany(condition, startSize, pageSize)
  2635. if err != nil && err.Error() != utils.ErrNoRow() {
  2636. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2637. br.Msg = "获取用户关注总数失败"
  2638. return
  2639. }
  2640. } else {
  2641. total, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
  2642. if err != nil {
  2643. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2644. br.Msg = "获取用户关注总数失败"
  2645. return
  2646. }
  2647. if err != nil {
  2648. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2649. br.Msg = "获取用户关注总数失败"
  2650. return
  2651. }
  2652. list, err = cygx.GetCygxIndustryFllowByCompanyWeekly(condition, startSize, pageSize)
  2653. if err != nil && err.Error() != utils.ErrNoRow() {
  2654. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2655. br.Msg = "获取用户关注总数失败"
  2656. return
  2657. }
  2658. }
  2659. } else if source == 6 {
  2660. if isAdminRole {
  2661. total, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
  2662. if err != nil {
  2663. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2664. br.Msg = "获取关注作者总数失败"
  2665. return
  2666. }
  2667. list, err = cygx.GetCygArticleDepartmentFollowByCompany(condition, startSize, pageSize)
  2668. if err != nil && err.Error() != utils.ErrNoRow() {
  2669. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2670. br.Msg = "获取关注作者列表失败"
  2671. return
  2672. }
  2673. } else {
  2674. total, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
  2675. if err != nil {
  2676. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2677. br.Msg = "获取关注作者总数失败"
  2678. return
  2679. }
  2680. list, err = cygx.GetCygArticleDepartmentFollowByCompanyWeekly(condition, startSize, pageSize)
  2681. if err != nil && err.Error() != utils.ErrNoRow() {
  2682. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2683. br.Msg = "获取关注作者列表失败"
  2684. return
  2685. }
  2686. }
  2687. if len(list) > 0 {
  2688. var departmentIds []int
  2689. for _, v := range list {
  2690. departmentIds = append(departmentIds, v.DepartmentId)
  2691. }
  2692. mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByDepartmentId(departmentIds) // 关联产业
  2693. for _, v := range list {
  2694. v.SubjectNameStr = strings.Join(mapIndustrialLabel[v.DepartmentId], "/")
  2695. }
  2696. }
  2697. } else if source == 7 {
  2698. if classType == 1 {
  2699. condition += " AND r.register_platform IN (1,2) "
  2700. } else {
  2701. condition += " AND r.register_platform IN (5,6) "
  2702. }
  2703. if isAdminRole {
  2704. total, err = cygx.GetCygxSearchKeyWordCountBuCompany(condition)
  2705. if err != nil {
  2706. br.Msg = "获取信息失败"
  2707. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2708. return
  2709. }
  2710. list, err = cygx.GetCygxSearchKeyWordByCompany(condition, startSize, pageSize)
  2711. if err != nil && err.Error() != utils.ErrNoRow() {
  2712. br.Msg = "获取信息失败"
  2713. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2714. return
  2715. }
  2716. } else {
  2717. total, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(condition)
  2718. if err != nil {
  2719. br.Msg = "获取信息失败"
  2720. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2721. return
  2722. }
  2723. list, err = cygx.GetCygxSearchKeyWordByCompanyWeekly(condition, startSize, pageSize)
  2724. if err != nil && err.Error() != utils.ErrNoRow() {
  2725. br.Msg = "获取信息失败"
  2726. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2727. return
  2728. }
  2729. }
  2730. } else if source == 8 {
  2731. if isAdminRole {
  2732. total, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
  2733. if err != nil {
  2734. br.Msg = "获取信息失败"
  2735. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2736. return
  2737. }
  2738. list, err = cygx.CygxActivitySpecialTripByCompany(condition, startSize, pageSize)
  2739. if err != nil && err.Error() != utils.ErrNoRow() {
  2740. br.Msg = "获取信息失败"
  2741. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2742. return
  2743. }
  2744. } else {
  2745. total, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
  2746. if err != nil {
  2747. br.Msg = "获取信息失败"
  2748. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2749. return
  2750. }
  2751. list, err = cygx.CygxActivitySpecialTripByCompanyWeekly(condition, startSize, pageSize)
  2752. if err != nil && err.Error() != utils.ErrNoRow() {
  2753. br.Msg = "获取信息失败"
  2754. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2755. return
  2756. }
  2757. }
  2758. } else if source == 9 {
  2759. if isAdminRole {
  2760. total, err = cygx.GetCygxRoadshowCountByCompany(condition)
  2761. if err != nil {
  2762. br.Msg = "获取信息失败"
  2763. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2764. return
  2765. }
  2766. list, err = cygx.GetCygxRoadshowByCompany(condition, startSize, pageSize)
  2767. if err != nil && err.Error() != utils.ErrNoRow() {
  2768. br.Msg = "获取信息失败"
  2769. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2770. return
  2771. }
  2772. } else {
  2773. total, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
  2774. if err != nil {
  2775. br.Msg = "获取信息失败"
  2776. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  2777. return
  2778. }
  2779. list, err = cygx.GetCygxRoadshowByCompanyWeekly(condition, startSize, pageSize)
  2780. if err != nil && err.Error() != utils.ErrNoRow() {
  2781. br.Msg = "获取信息失败"
  2782. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  2783. return
  2784. }
  2785. }
  2786. } else if source == 10 { //标签点击记录
  2787. if isAdminRole {
  2788. total, err = cygx.GetCygxTagHistoryCount(condition)
  2789. if err != nil {
  2790. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2791. br.Msg = "获取搜索记录失败"
  2792. return
  2793. }
  2794. list, err = cygx.GetCygxTagHistoryListBycondition(condition, startSize, pageSize)
  2795. if err != nil && err.Error() != utils.ErrNoRow() {
  2796. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2797. br.Msg = "获取搜索记录列表失败"
  2798. return
  2799. }
  2800. } else {
  2801. total, err = cygx.GetCygxTagHistoryCountWeekly(condition)
  2802. if err != nil {
  2803. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2804. br.Msg = "获取搜索记录失败"
  2805. return
  2806. }
  2807. list, err = cygx.GetCygxTagHistoryListByconditionWeekly(condition, startSize, pageSize)
  2808. if err != nil && err.Error() != utils.ErrNoRow() {
  2809. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2810. br.Msg = "获取搜索记录列表失败"
  2811. return
  2812. }
  2813. }
  2814. } else if source == 11 { //专栏文章阅读记录
  2815. if isAdminRole {
  2816. total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
  2817. if err != nil && err.Error() != utils.ErrNoRow() {
  2818. br.Msg = "获取信息失败"
  2819. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2820. return
  2821. }
  2822. } else {
  2823. total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, startSize, pageSize)
  2824. if err != nil && err.Error() != utils.ErrNoRow() {
  2825. br.Msg = "获取信息失败"
  2826. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2827. return
  2828. }
  2829. }
  2830. if len(list) > 0 {
  2831. for k, v := range list {
  2832. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  2833. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  2834. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  2835. }
  2836. }
  2837. //导出excel
  2838. if isExport {
  2839. exportListYanxuanSpecial(this, list, 2, br)
  2840. return
  2841. }
  2842. } else if source == 12 { //收藏的专栏文章
  2843. if isAdminRole {
  2844. total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
  2845. if err != nil && err.Error() != utils.ErrNoRow() {
  2846. br.Msg = "获取信息失败"
  2847. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2848. return
  2849. }
  2850. } else {
  2851. total, list, err = cygx.GetCygxYanxuanSpecialCollectByUserWeekly(condition, startSize, pageSize)
  2852. if err != nil && err.Error() != utils.ErrNoRow() {
  2853. br.Msg = "获取信息失败"
  2854. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2855. return
  2856. }
  2857. }
  2858. if len(list) > 0 {
  2859. for k, v := range list {
  2860. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  2861. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  2862. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  2863. }
  2864. }
  2865. } else if source == 13 { //关注的专栏作者
  2866. if isAdminRole {
  2867. total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
  2868. if err != nil && err.Error() != utils.ErrNoRow() {
  2869. br.Msg = "获取信息失败"
  2870. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2871. return
  2872. }
  2873. } else {
  2874. total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUserWeekly(condition, startSize, pageSize)
  2875. if err != nil && err.Error() != utils.ErrNoRow() {
  2876. br.Msg = "获取信息失败"
  2877. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2878. return
  2879. }
  2880. }
  2881. if len(list) > 0 {
  2882. for k, v := range list {
  2883. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  2884. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  2885. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
  2886. }
  2887. }
  2888. } else if source == 14 { //交流反馈
  2889. if isAdminRole {
  2890. total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
  2891. if err != nil && err.Error() != utils.ErrNoRow() {
  2892. br.Msg = "获取信息失败"
  2893. br.ErrMsg = "获取用户交流反馈,Err:" + err.Error()
  2894. return
  2895. }
  2896. } else {
  2897. total, list, err = cygx.GetCygxUserFeedbackWeekly(condition, startSize, pageSize)
  2898. if err != nil && err.Error() != utils.ErrNoRow() {
  2899. br.Msg = "获取信息失败"
  2900. br.ErrMsg = "获取用户交流反馈,Err:" + err.Error()
  2901. return
  2902. }
  2903. }
  2904. } else if source == 15 { //1V1路演
  2905. if startDate != "" {
  2906. condition += ` AND b.start_date >= '` + startDate + `' `
  2907. }
  2908. if endDate != "" {
  2909. condition += ` AND b.start_date <= '` + endDate + `' `
  2910. }
  2911. var totalRsCalendar int
  2912. var listRsCalendar []*roadshow.RsCalendarMeetingUserByRai
  2913. if isAdminRole {
  2914. totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
  2915. if err != nil {
  2916. br.Msg = "获取信息失败"
  2917. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2918. return
  2919. }
  2920. } else {
  2921. totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRaiWeekly(condition, startSize, pageSize)
  2922. if err != nil {
  2923. br.Msg = "获取信息失败"
  2924. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  2925. return
  2926. }
  2927. }
  2928. total = totalRsCalendar
  2929. list, err = cygxService.HandleListRsCalendar(listRsCalendar)
  2930. if err != nil {
  2931. br.Msg = "获取信息失败"
  2932. br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
  2933. return
  2934. }
  2935. //导出excel
  2936. if isExport {
  2937. exportListRsCalendar(this, list, 2, br)
  2938. return
  2939. }
  2940. }
  2941. page := paging.GetPaging(currentIndex, pageSize, total)
  2942. if len(list) == 0 {
  2943. list = make([]*cygx.UserInteraction, 0)
  2944. }
  2945. resp.List = list
  2946. resp.Paging = page
  2947. br.Ret = 200
  2948. br.Success = true
  2949. br.Msg = "获取成功"
  2950. br.Data = resp
  2951. }
  2952. // @Title 机构相关互动下载
  2953. // @Description 机构相关互动下载接口
  2954. // @Param CompanyId query int true "公司id"
  2955. // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
  2956. // @Param IsMeeting query string true "是否到会 1到会、2未到会"
  2957. // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
  2958. // @Param StartDate query string true "开始时间"
  2959. // @Param EndDate query string true "结束时间"
  2960. // @Param KeyWord query string true "搜索关键词"
  2961. // @Param ActivityName query string true "活动名称"
  2962. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  2963. // @Success 200 {object} cygx.CygxUserTableStatusListRep
  2964. // @router /user/company/export/interaction [get]
  2965. func (this *UserController) CompanyExportInteraction() {
  2966. br := new(models.BaseResponse).Init()
  2967. defer func() {
  2968. this.Data["json"] = br
  2969. this.ServeJSON()
  2970. }()
  2971. sysUser := this.SysUser
  2972. if sysUser == nil {
  2973. br.Msg = "请登录"
  2974. br.ErrMsg = "请登录,SysUser Is Empty"
  2975. br.Ret = 408
  2976. return
  2977. }
  2978. companyId, _ := this.GetInt("CompanyId")
  2979. isMeeting := this.GetString("IsMeeting")
  2980. meetType := this.GetString("MeetType")
  2981. startDate := this.GetString("StartDate")
  2982. endDate := this.GetString("EndDate")
  2983. keyWord := this.GetString("KeyWord")
  2984. activityName := this.GetString("ActivityName")
  2985. source, _ := this.GetInt("Source")
  2986. classType, _ := this.GetInt("ClassType", 1)
  2987. if companyId < 1 {
  2988. br.Msg = "用户不存在"
  2989. return
  2990. }
  2991. //获取企业客户信息
  2992. companyInfo, err := company.GetCompanyById(companyId)
  2993. if err != nil {
  2994. br.Msg = "获取信息失败"
  2995. br.ErrMsg = "GetCompanyById,Err:" + err.Error()
  2996. return
  2997. }
  2998. var isAdminRole bool
  2999. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  3000. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  3001. isAdminRole = true
  3002. }
  3003. var pageSize = 9999
  3004. var list []*cygx.UserInteraction
  3005. var condition string
  3006. condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
  3007. if keyWord != "" {
  3008. //condition += ` AND r.user_id IN (SELECT user_id FROM wx_user WHERE mobile LIKE '%` + keyWord + `%' OR email LIKE '%` + keyWord + `%' OR real_name LIKE '%` + keyWord + `%')`
  3009. condition += ` AND ( r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%')`
  3010. }
  3011. if source == 1 {
  3012. if classType == 1 {
  3013. condition += " AND art.article_type_id = 0 "
  3014. } else {
  3015. condition += " AND art.article_type_id > 0 "
  3016. }
  3017. if startDate != "" {
  3018. startDate += " 00:00:00"
  3019. condition += ` AND r.create_time >= '` + startDate + `' `
  3020. }
  3021. if endDate != "" {
  3022. endDate += " 23:59:59"
  3023. condition += ` AND r.create_time <= '` + endDate + `' `
  3024. }
  3025. condition += ` ORDER BY r.create_time DESC `
  3026. var pars []interface{}
  3027. var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
  3028. if isAdminRole {
  3029. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
  3030. if err != nil && err.Error() != utils.ErrNoRow() {
  3031. br.Msg = "获取信息失败"
  3032. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3033. return
  3034. }
  3035. } else {
  3036. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, 0, pageSize)
  3037. if err != nil && err.Error() != utils.ErrNoRow() {
  3038. br.Msg = "获取信息失败"
  3039. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3040. return
  3041. }
  3042. }
  3043. //处理查询信息回显
  3044. list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
  3045. if err != nil && err.Error() != utils.ErrNoRow() {
  3046. br.Msg = "获取信息失败"
  3047. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3048. return
  3049. }
  3050. if len(list) > 0 {
  3051. var articleIds string
  3052. mapAricleId := make(map[int]int)
  3053. mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
  3054. for k, v := range list {
  3055. if v.ArticleId >= utils.SummaryArticleId {
  3056. list[k].ArticleType = 1
  3057. } else {
  3058. list[k].ArticleType = 2
  3059. }
  3060. if list[k].PermissionName == "" {
  3061. list[k].PermissionName = v.CategoryName
  3062. }
  3063. if mapAricleId[v.ArticleId] == 0 {
  3064. articleIds += strconv.Itoa(v.ArticleId) + ","
  3065. mapAricleId[v.ArticleId] = v.ArticleId
  3066. }
  3067. }
  3068. articleIds = strings.TrimRight(articleIds, ",")
  3069. if articleIds != "" {
  3070. listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
  3071. if err != nil && err.Error() != utils.ErrNoRow() {
  3072. br.Msg = "获取信息失败"
  3073. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3074. return
  3075. }
  3076. if len(listArticleIndustrialSubjectList) > 0 {
  3077. for _, v := range listArticleIndustrialSubjectList {
  3078. mapAricleIndustrialSubjectName[v.ArticleId] = v
  3079. }
  3080. for k, v := range list {
  3081. if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
  3082. list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
  3083. list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
  3084. }
  3085. }
  3086. }
  3087. }
  3088. }
  3089. } else if source == 2 {
  3090. if classType == 1 {
  3091. condition += " AND a.chart_permission_id != 31 "
  3092. } else {
  3093. condition += " AND a.chart_permission_id = 31 "
  3094. }
  3095. if isMeeting == "1" {
  3096. condition += ` AND r.is_meeting = 1 `
  3097. }
  3098. if isMeeting == "2" {
  3099. condition += ` AND r.is_meeting = 0 `
  3100. }
  3101. if meetType == "1" {
  3102. condition += ` AND t.activity_type = 1 `
  3103. }
  3104. if meetType == "2" {
  3105. condition += ` AND t.activity_type = 0 `
  3106. }
  3107. if startDate != "" {
  3108. startDate += " 00:00:00"
  3109. condition += ` AND a.activity_time >= '` + startDate + `' `
  3110. }
  3111. if endDate != "" {
  3112. endDate += " 23:59:59"
  3113. condition += ` AND a.activity_time <= '` + endDate + `' `
  3114. }
  3115. if activityName != "" {
  3116. condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
  3117. }
  3118. if isAdminRole {
  3119. list, err = cygx.GetActivityMeetByCompany(condition, 0, pageSize)
  3120. if err != nil && err.Error() != utils.ErrNoRow() {
  3121. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3122. br.Msg = "获取参会人数列表失败"
  3123. return
  3124. }
  3125. } else {
  3126. list, err = cygx.GetActivityMeetByCompanyWeekly(condition, 0, pageSize)
  3127. if err != nil && err.Error() != utils.ErrNoRow() {
  3128. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3129. br.Msg = "获取参会人数列表失败"
  3130. return
  3131. }
  3132. }
  3133. if len(list) > 0 {
  3134. for k, v := range list {
  3135. if v.ActivityType == 1 {
  3136. if v.SignupType == "2" {
  3137. list[k].InteractionType = "自主拨入"
  3138. } else {
  3139. list[k].InteractionType = "预约外呼"
  3140. }
  3141. if v.ReminderNum > 0 {
  3142. list[k].InteractionType += ",会议提醒"
  3143. }
  3144. }
  3145. }
  3146. }
  3147. } else if source == 11 {
  3148. if isAdminRole {
  3149. _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
  3150. if err != nil && err.Error() != utils.ErrNoRow() {
  3151. br.Msg = "获取信息失败"
  3152. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3153. return
  3154. }
  3155. } else {
  3156. _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, 0, 9999)
  3157. if err != nil && err.Error() != utils.ErrNoRow() {
  3158. br.Msg = "获取信息失败"
  3159. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3160. return
  3161. }
  3162. }
  3163. }
  3164. //创建excel
  3165. dir, err := os.Executable()
  3166. exPath := filepath.Dir(dir)
  3167. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3168. xlsxFile := xlsx.NewFile()
  3169. if err != nil {
  3170. br.Msg = "生成文件失败"
  3171. br.ErrMsg = "生成文件失败"
  3172. return
  3173. }
  3174. style := xlsx.NewStyle()
  3175. alignment := xlsx.Alignment{
  3176. Horizontal: "center",
  3177. Vertical: "center",
  3178. WrapText: true,
  3179. }
  3180. style.Alignment = alignment
  3181. style.ApplyAlignment = true
  3182. sheet, err := xlsxFile.AddSheet("用户名单")
  3183. if err != nil {
  3184. br.Msg = "新增Sheet失败"
  3185. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  3186. return
  3187. }
  3188. var excelName string
  3189. if source == 1 {
  3190. excelName = "阅读记录"
  3191. //标头
  3192. rowTitle := sheet.AddRow()
  3193. cellA := rowTitle.AddCell()
  3194. cellA.Value = "姓名"
  3195. cellB := rowTitle.AddCell()
  3196. cellB.Value = "手机号"
  3197. cellC := rowTitle.AddCell()
  3198. cellC.Value = "报告标题"
  3199. cellD := rowTitle.AddCell()
  3200. cellD.Value = "所属行业"
  3201. cellE := rowTitle.AddCell()
  3202. cellE.Value = "所属产业"
  3203. cellF := rowTitle.AddCell()
  3204. cellF.Value = "关联标的"
  3205. cellG := rowTitle.AddCell()
  3206. cellG.Value = "发布时间"
  3207. cellH := rowTitle.AddCell()
  3208. cellH.Value = "阅读时间"
  3209. cellI := rowTitle.AddCell()
  3210. cellI.Value = "阅读时长"
  3211. for _, item := range list {
  3212. row := sheet.AddRow()
  3213. cellA := row.AddCell()
  3214. cellA.Value = item.RealName
  3215. cellB := row.AddCell()
  3216. cellB.Value = item.Mobile
  3217. cellC := row.AddCell()
  3218. cellC.Value = item.Title
  3219. cellD := row.AddCell()
  3220. cellD.Value = item.PermissionName
  3221. cellE := row.AddCell()
  3222. cellE.Value = item.IndustryName
  3223. cellF := row.AddCell()
  3224. cellF.Value = item.SubjectNameStr
  3225. cellG := row.AddCell()
  3226. cellG.Value = item.PublishDate
  3227. cellH := row.AddCell()
  3228. cellH.Value = item.CreateTime
  3229. cellI := row.AddCell()
  3230. cellI.Value = item.StopTime
  3231. }
  3232. } else if source == 2 {
  3233. excelName = "参会记录"
  3234. //标头
  3235. rowTitle := sheet.AddRow()
  3236. cellA := rowTitle.AddCell()
  3237. cellA.Value = "姓名"
  3238. cellB := rowTitle.AddCell()
  3239. cellB.Value = "手机号"
  3240. cellC := rowTitle.AddCell()
  3241. cellC.Value = "活动名称"
  3242. cellD := rowTitle.AddCell()
  3243. cellD.Value = "所属行业"
  3244. cellE := rowTitle.AddCell()
  3245. cellE.Value = "活动类型"
  3246. cellF := rowTitle.AddCell()
  3247. cellF.Value = "活动主题"
  3248. cellG := rowTitle.AddCell()
  3249. cellG.Value = "活动时间"
  3250. cellH := rowTitle.AddCell()
  3251. cellH.Value = "是否到会"
  3252. cellI := rowTitle.AddCell()
  3253. cellI.Value = "首次入会时间"
  3254. cellJ := rowTitle.AddCell()
  3255. cellJ.Value = "最后退出时间"
  3256. cellK := rowTitle.AddCell()
  3257. cellK.Value = "参与总时长"
  3258. cellL := rowTitle.AddCell()
  3259. cellL.Value = "参会方式"
  3260. cellM := rowTitle.AddCell()
  3261. cellM.Value = "参会权鉴"
  3262. cellN := rowTitle.AddCell()
  3263. cellN.Value = "参会状态"
  3264. for _, item := range list {
  3265. row := sheet.AddRow()
  3266. cellA := row.AddCell()
  3267. cellA.Value = item.RealName
  3268. cellB := row.AddCell()
  3269. cellB.Value = item.Mobile
  3270. cellC := row.AddCell()
  3271. cellC.Value = item.ActivityName
  3272. cellD := row.AddCell()
  3273. cellD.Value = item.PermissionName
  3274. cellE := row.AddCell()
  3275. cellE.Value = item.ActivityTypeName
  3276. cellF := row.AddCell()
  3277. cellF.Value = item.Label
  3278. cellG := row.AddCell()
  3279. cellG.Value = item.ActivityTime
  3280. cellH := row.AddCell()
  3281. if item.IsMeeting == 1 {
  3282. cellH.Value = "到会"
  3283. } else {
  3284. cellH.Value = "未到会"
  3285. }
  3286. cellI := row.AddCell()
  3287. cellI.Value = item.FirstMeetingTime
  3288. cellJ := row.AddCell()
  3289. cellJ.Value = item.LastMeetingTime
  3290. cellK := row.AddCell()
  3291. cellK.Value = item.Duration
  3292. cellL := row.AddCell()
  3293. cellL.Value = item.LastMeetingTime
  3294. cellM := row.AddCell()
  3295. cellM.Value = item.MeetingTypeStr
  3296. cellN := row.AddCell()
  3297. cellN.Value = item.MeetingStatusStr
  3298. }
  3299. } else if source == 11 {
  3300. //标头
  3301. rowTitle := sheet.AddRow()
  3302. cellA := rowTitle.AddCell()
  3303. cellA.Value = "文章标题"
  3304. cellB := rowTitle.AddCell()
  3305. cellB.Value = "文章类型"
  3306. cellC := rowTitle.AddCell()
  3307. cellC.Value = "标签"
  3308. cellD := rowTitle.AddCell()
  3309. cellD.Value = "发布时间"
  3310. cellE := rowTitle.AddCell()
  3311. cellE.Value = "阅读时间"
  3312. cellF := rowTitle.AddCell()
  3313. cellF.Value = "阅读时长"
  3314. cellG := rowTitle.AddCell()
  3315. cellG.Value = "阅读来源"
  3316. for _, item := range list {
  3317. row := sheet.AddRow()
  3318. cellA := row.AddCell()
  3319. cellA.Value = item.Title
  3320. cellB := row.AddCell()
  3321. if item.SpecialType == 1 {
  3322. cellB.Value = "笔记"
  3323. } else {
  3324. cellB.Value = "观点"
  3325. }
  3326. cellC := row.AddCell()
  3327. cellC.Value = item.IndustryName
  3328. cellD := row.AddCell()
  3329. cellD.Value = item.PublishDate
  3330. cellE := row.AddCell()
  3331. cellE.Value = item.CreateTime
  3332. cellF := row.AddCell()
  3333. cellF.Value = item.StopTime
  3334. cellG := row.AddCell()
  3335. cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
  3336. }
  3337. }
  3338. err = xlsxFile.Save(downLoadnFilePath)
  3339. if err != nil {
  3340. br.Msg = "保存文件失败"
  3341. br.ErrMsg = "保存文件失败"
  3342. return
  3343. }
  3344. randStr := time.Now().Format(utils.FormatDate)
  3345. downloadFileName := excelName + companyInfo.CompanyName + randStr + ".xlsx"
  3346. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  3347. defer func() {
  3348. os.Remove(downLoadnFilePath)
  3349. }()
  3350. br.Ret = 200
  3351. br.Success = true
  3352. br.Msg = "获取成功"
  3353. }
  3354. // @Title 全机构互动列表
  3355. // @Description 全机构互动列表接口
  3356. // @Param Source query int true "来源"
  3357. // @Param AdminId query string true "销售id,多个用英文逗号隔开,空字符串为全部"
  3358. // @Param IsMeeting query string false "是否到会 1到会、2未到会"
  3359. // @Param MeetType query string false "参会方式 1线上,2线下 默认为线上"
  3360. // @Param PageSize query int true "每页数据条数"
  3361. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3362. // @Param StartDate query string false "开始时间"
  3363. // @Param EndDate query string false "结束时间"
  3364. // @Param KeyWord query string false "搜索关键词"
  3365. // @Param ActivityName query string false "活动名称"
  3366. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  3367. // @Param IsExport query bool false "是否导出excel,默认是false"
  3368. // @Success 200 {object} cygx.UserInteractionListResp
  3369. // @router /user/company/list [get]
  3370. func (this *UserController) CompanyList() {
  3371. br := new(models.BaseResponse).Init()
  3372. defer func() {
  3373. this.Data["json"] = br
  3374. this.ServeJSON()
  3375. }()
  3376. sysUser := this.SysUser
  3377. if sysUser == nil {
  3378. br.Msg = "请登录"
  3379. br.ErrMsg = "请登录,SysUser Is Empty"
  3380. br.Ret = 408
  3381. return
  3382. }
  3383. roleTypeCode := sysUser.RoleTypeCode
  3384. pageSize, _ := this.GetInt("PageSize")
  3385. currentIndex, _ := this.GetInt("CurrentIndex")
  3386. adminId := this.GetString("AdminId")
  3387. keyWord := this.GetString("KeyWord")
  3388. isMeeting := this.GetString("IsMeeting")
  3389. meetType := this.GetString("MeetType")
  3390. startDate := this.GetString("StartDate")
  3391. endDate := this.GetString("EndDate")
  3392. activityName := this.GetString("ActivityName")
  3393. source, _ := this.GetInt("Source")
  3394. status := this.GetString("Status")
  3395. classType, _ := this.GetInt("ClassType", 1)
  3396. // 套餐类型
  3397. //packageType, _ := this.GetInt("PackageType")
  3398. keyWord = strings.Trim(keyWord, " ")
  3399. keyWord = strings.Replace(keyWord, "'", "", -1)
  3400. isExport, _ := this.GetBool("IsExport")
  3401. if isExport {
  3402. pageSize = 10000
  3403. currentIndex = 1
  3404. }
  3405. var total int
  3406. //statusItems := make([]*company.CompanyStatus, 0)
  3407. //var statusArr = [...]string{"全部", "试用", "正式", "冻结", "流失", "永续"}
  3408. var startSize int
  3409. if pageSize <= 0 {
  3410. pageSize = utils.PageSize20
  3411. }
  3412. if currentIndex <= 0 {
  3413. currentIndex = 1
  3414. }
  3415. startSize = paging.StartIndex(currentIndex, pageSize)
  3416. var condition string
  3417. resp := new(cygx.UserInteractionListResp)
  3418. var err error
  3419. var list []*cygx.UserInteraction
  3420. //流失
  3421. var lossCondition string
  3422. //var lossPars []interface{}
  3423. //状态分类查询条件
  3424. var permissionCondition string
  3425. if adminId != "" {
  3426. condition += ` AND b.seller_id IN (` + adminId + `) `
  3427. }
  3428. lossCondition = condition
  3429. //lossPars = pars
  3430. permissionCondition = condition
  3431. //流失客户统计
  3432. lossCondition += ` AND status='流失' `
  3433. //productId := services.GetProductId(roleTypeCode)
  3434. productId := 2
  3435. //权限控制
  3436. {
  3437. //如果不是超级管理员或者财务
  3438. if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
  3439. //如果是部门管理员
  3440. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  3441. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3442. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3443. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3444. } else {
  3445. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3446. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3447. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  3448. if status == "全部" {
  3449. ////如果是筛选了流失客户状态
  3450. if sysUser.Authority <= 0 {
  3451. condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
  3452. permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
  3453. } else {
  3454. if sysUser.Authority == 1 {
  3455. condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
  3456. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  3457. }
  3458. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  3459. if status != utils.COMPANY_STATUS_LOSE {
  3460. condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  3461. }
  3462. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  3463. }
  3464. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  3465. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  3466. if err != nil {
  3467. br.Msg = "获取失败"
  3468. br.ErrMsg = "查询父级id异常" + err.Error()
  3469. return
  3470. }
  3471. var ids []*string
  3472. if pid != nil {
  3473. if *pid != 0 {
  3474. //销售主管放在三级列表中
  3475. ids, err = company.GetGroupIdsByParentId(*pid)
  3476. if err != nil {
  3477. fmt.Println(err.Error())
  3478. }
  3479. } else {
  3480. //销售主管放在二级列表中
  3481. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  3482. if err != nil {
  3483. fmt.Println(err.Error())
  3484. }
  3485. }
  3486. }
  3487. var idSlice []string
  3488. var sid string
  3489. for _, id := range ids {
  3490. idSlice = append(idSlice, *id)
  3491. }
  3492. //加入父级groupId
  3493. if *pid > 0 {
  3494. idSlice = append(idSlice, strconv.Itoa(*pid))
  3495. } else {
  3496. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  3497. }
  3498. sid = strings.Join(idSlice, ",")
  3499. if len(sid) > 0 {
  3500. if status != utils.COMPANY_STATUS_LOSE {
  3501. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  3502. }
  3503. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  3504. } else {
  3505. if status != utils.COMPANY_STATUS_LOSE {
  3506. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  3507. }
  3508. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  3509. }
  3510. }
  3511. if sysUser.Authority == 4 {
  3512. if status != utils.COMPANY_STATUS_LOSE {
  3513. condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  3514. //pars = append(pars, sysUser.GroupId)
  3515. }
  3516. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  3517. //permissionPars = append(permissionPars, sysUser.GroupId)
  3518. }
  3519. }
  3520. } else {
  3521. //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
  3522. if sysUser.Authority <= 0 {
  3523. if status != utils.COMPANY_STATUS_LOSE {
  3524. condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  3525. //pars = append(pars, sysUser.AdminId)
  3526. }
  3527. permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  3528. //permissionPars = append(permissionPars, sysUser.AdminId)
  3529. } else {
  3530. if sysUser.Authority == 1 {
  3531. if status != utils.COMPANY_STATUS_LOSE {
  3532. condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  3533. //pars = append(pars, sysUser.DepartmentId)
  3534. }
  3535. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  3536. //permissionPars = append(permissionPars, sysUser.DepartmentId)
  3537. }
  3538. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  3539. if status != utils.COMPANY_STATUS_LOSE {
  3540. condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
  3541. //pars = append(pars, sysUser.GroupId)
  3542. }
  3543. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  3544. //permissionPars = append(permissionPars, sysUser.GroupId)
  3545. }
  3546. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  3547. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  3548. if err != nil {
  3549. br.Msg = "获取失败"
  3550. br.ErrMsg = "查询父级id异常" + err.Error()
  3551. return
  3552. }
  3553. var ids []*string
  3554. if pid != nil {
  3555. if *pid != 0 {
  3556. //销售主管放在三级列表中
  3557. ids, err = company.GetGroupIdsByParentId(*pid)
  3558. if err != nil {
  3559. fmt.Println(err.Error())
  3560. }
  3561. } else {
  3562. //销售主管放在二级列表中
  3563. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  3564. if err != nil {
  3565. fmt.Println(err.Error())
  3566. }
  3567. }
  3568. }
  3569. var idSlice []string
  3570. var sid string
  3571. for _, id := range ids {
  3572. idSlice = append(idSlice, *id)
  3573. }
  3574. //加入父级groupId
  3575. if *pid > 0 {
  3576. idSlice = append(idSlice, strconv.Itoa(*pid))
  3577. } else {
  3578. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  3579. }
  3580. sid = strings.Join(idSlice, ",")
  3581. if len(sid) > 0 {
  3582. if status != utils.COMPANY_STATUS_LOSE {
  3583. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  3584. //pars = append(pars, sysUser.GroupId)
  3585. }
  3586. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  3587. } else {
  3588. if status != utils.COMPANY_STATUS_LOSE {
  3589. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  3590. //pars = append(pars, sysUser.GroupId)
  3591. }
  3592. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  3593. }
  3594. }
  3595. if sysUser.Authority == 4 {
  3596. if status != utils.COMPANY_STATUS_LOSE {
  3597. condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
  3598. //pars = append(pars, sysUser.GroupId)
  3599. }
  3600. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  3601. //permissionPars = append(permissionPars, sysUser.GroupId)
  3602. }
  3603. }
  3604. }
  3605. }
  3606. }
  3607. }
  3608. condition += ` AND b.status IN ('正式','试用','冻结') `
  3609. companyCondition := `SELECT a.company_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  3610. companyIdsCondition := `SELECT GROUP_CONCAT( DISTINCT a.company_id SEPARATOR ',' ) AS company_ids FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  3611. if condition != "" {
  3612. companyCondition += condition
  3613. }
  3614. companyIdsCondition += condition
  3615. var companyIds string
  3616. companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
  3617. if err != nil {
  3618. br.Msg = "获取失败"
  3619. br.ErrMsg = "获取公司ID数据失败,Err:" + err.Error()
  3620. return
  3621. }
  3622. condition = ` AND r.company_id IN ( ` + companyIds + ` ) AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' ` // 过滤当天查询时间
  3623. if keyWord != "" {
  3624. condition += ` AND (r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%'` + ` OR r.company_name LIKE '%` + keyWord + `%') `
  3625. }
  3626. var isAdminRole bool
  3627. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  3628. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  3629. isAdminRole = true
  3630. }
  3631. if source == 1 {
  3632. if startDate != "" {
  3633. startDate += " 00:00:00"
  3634. condition += ` AND r.create_time >= '` + startDate + `' `
  3635. }
  3636. if endDate != "" {
  3637. endDate += " 23:59:59"
  3638. condition += ` AND r.create_time <= '` + endDate + `' `
  3639. }
  3640. if classType == 1 {
  3641. condition += " AND art.article_type_id = 0 "
  3642. } else {
  3643. condition += " AND art.article_type_id > 0 "
  3644. }
  3645. condition += " AND r.source = 'article' "
  3646. var pars []interface{}
  3647. condition += " ORDER BY r.create_time DESC "
  3648. var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
  3649. if isAdminRole {
  3650. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
  3651. if err != nil && err.Error() != utils.ErrNoRow() {
  3652. br.Msg = "获取信息失败"
  3653. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3654. return
  3655. }
  3656. total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
  3657. if err != nil {
  3658. br.Msg = "获取信息失败"
  3659. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  3660. return
  3661. }
  3662. } else {
  3663. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, startSize, pageSize)
  3664. if err != nil && err.Error() != utils.ErrNoRow() {
  3665. br.Msg = "获取信息失败"
  3666. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3667. return
  3668. }
  3669. total, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(condition, pars)
  3670. if err != nil {
  3671. br.Msg = "获取信息失败"
  3672. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  3673. return
  3674. }
  3675. }
  3676. //处理查询信息回显
  3677. list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
  3678. if err != nil && err.Error() != utils.ErrNoRow() {
  3679. br.Msg = "获取信息失败"
  3680. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  3681. return
  3682. }
  3683. for k, v := range list {
  3684. if classType == 1 {
  3685. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  3686. } else {
  3687. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  3688. }
  3689. if v.ReportId > 0 {
  3690. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  3691. }
  3692. }
  3693. //导出excel
  3694. if isExport {
  3695. exportListArticle(this, list, 3, br)
  3696. return
  3697. }
  3698. } else if source == 2 {
  3699. if isMeeting == "1" {
  3700. condition += ` AND r.is_meeting = 1 `
  3701. }
  3702. if isMeeting == "2" {
  3703. condition += ` AND r.is_meeting = 0 `
  3704. }
  3705. if meetType == "1" {
  3706. condition += ` AND t.activity_type = 1 `
  3707. }
  3708. if meetType == "2" {
  3709. condition += ` AND t.activity_type = 0 `
  3710. }
  3711. if startDate != "" {
  3712. startDate += " 00:00:00"
  3713. condition += ` AND a.activity_time >= '` + startDate + `' `
  3714. }
  3715. if endDate != "" {
  3716. endDate += " 23:59:59"
  3717. condition += ` AND a.activity_time <= '` + endDate + `' `
  3718. }
  3719. if activityName != "" {
  3720. condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
  3721. }
  3722. if classType == 1 {
  3723. condition += " AND a.chart_permission_id != 31 "
  3724. } else {
  3725. condition += " AND a.chart_permission_id = 31 "
  3726. }
  3727. if isAdminRole {
  3728. total, err = cygx.GetActivityMeetByCompanyCount(condition)
  3729. if err != nil {
  3730. br.Msg = "获取信息失败"
  3731. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  3732. return
  3733. }
  3734. list, err = cygx.GetActivityMeetByCompanyList(condition, startSize, pageSize)
  3735. if err != nil && err.Error() != utils.ErrNoRow() {
  3736. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3737. br.Msg = "获取参会人数列表失败"
  3738. return
  3739. }
  3740. } else {
  3741. total, err = cygx.GetActivityMeetByCompanyCountWeekly(condition)
  3742. if err != nil {
  3743. br.Msg = "获取信息失败"
  3744. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  3745. return
  3746. }
  3747. list, err = cygx.GetActivityMeetByCompanyWeekly(condition, startSize, pageSize)
  3748. if err != nil && err.Error() != utils.ErrNoRow() {
  3749. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3750. br.Msg = "获取参会人数列表失败"
  3751. return
  3752. }
  3753. }
  3754. //根据公司ID获取对应销售
  3755. var sellerCompanyIds []int
  3756. for _, v := range list {
  3757. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  3758. }
  3759. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  3760. if len(list) > 0 {
  3761. for k, v := range list {
  3762. if v.ActivityType == 1 {
  3763. if v.SignupType == "2" {
  3764. list[k].InteractionType = "自主拨入"
  3765. } else {
  3766. list[k].InteractionType = "预约外呼"
  3767. }
  3768. if v.ReminderNum > 0 {
  3769. list[k].InteractionType += ",会议提醒"
  3770. }
  3771. }
  3772. if v.IsMeeting == 0 {
  3773. list[k].FirstMeetingTime = ""
  3774. list[k].LastMeetingTime = ""
  3775. }
  3776. v.SellerName = sellNameMap[v.CompanyId]
  3777. }
  3778. }
  3779. //导出excel
  3780. if isExport {
  3781. exportListActivity(this, list, 3, br)
  3782. return
  3783. }
  3784. } else if source == 3 {
  3785. if classType == 1 {
  3786. condition += " AND art.article_type_id = 0 "
  3787. } else {
  3788. condition += " AND art.article_type_id > 0 "
  3789. }
  3790. if isAdminRole {
  3791. total, err = cygx.GetCygxArticleCollectCountByCompany(condition)
  3792. if err != nil {
  3793. br.Msg = "获取信息失败"
  3794. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  3795. return
  3796. }
  3797. list, err = cygx.GetCygxArticleCollectByCompanyList(startSize, pageSize, condition)
  3798. if err != nil && err.Error() != utils.ErrNoRow() {
  3799. br.Msg = "获取信息失败"
  3800. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  3801. return
  3802. }
  3803. } else {
  3804. total, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(condition)
  3805. if err != nil {
  3806. br.Msg = "获取信息失败"
  3807. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  3808. return
  3809. }
  3810. list, err = cygx.GetCygxArticleCollectByCompanyWeekly(startSize, pageSize, condition)
  3811. if err != nil && err.Error() != utils.ErrNoRow() {
  3812. br.Msg = "获取信息失败"
  3813. br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
  3814. return
  3815. }
  3816. }
  3817. //根据公司ID获取对应销售
  3818. var sellerCompanyIds []int
  3819. for _, v := range list {
  3820. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  3821. }
  3822. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  3823. if len(list) > 0 {
  3824. for k, v := range list {
  3825. if v.ArticleId >= utils.SummaryArticleId {
  3826. list[k].ArticleType = 1
  3827. } else {
  3828. list[k].ArticleType = 2
  3829. }
  3830. v.SellerName = sellNameMap[v.CompanyId]
  3831. if classType == 1 {
  3832. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  3833. } else {
  3834. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  3835. }
  3836. if v.ReportId > 0 {
  3837. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  3838. }
  3839. }
  3840. }
  3841. } else if source == 4 {
  3842. if isAdminRole {
  3843. total, err = cygx.GetChartCountByUserCount(condition)
  3844. if err != nil {
  3845. br.Msg = "获取信息失败"
  3846. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  3847. return
  3848. }
  3849. //condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
  3850. list, err = cygx.GetChartCollectBycompanyList(condition, startSize, pageSize)
  3851. if err != nil {
  3852. br.Msg = "获取信息失败"
  3853. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3854. return
  3855. }
  3856. } else {
  3857. total, err = cygx.GetChartCountByUserMobileWeekly(condition)
  3858. if err != nil {
  3859. br.Msg = "获取信息失败"
  3860. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  3861. return
  3862. }
  3863. //condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
  3864. list, err = cygx.GetChartCollectBycompanyListWeekly(condition, startSize, pageSize)
  3865. if err != nil {
  3866. br.Msg = "获取信息失败"
  3867. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3868. return
  3869. }
  3870. }
  3871. if len(list) > 0 {
  3872. for k, v := range list {
  3873. var err error
  3874. condition = ` AND a.publish_status = 1 AND r.mobile = ` + v.Mobile + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
  3875. totalUser, err := cygx.GetChartCountByUserMobile(condition)
  3876. if err != nil {
  3877. br.Msg = "获取信息失败"
  3878. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  3879. return
  3880. }
  3881. listChart, err := cygx.GetChartListCollectionWithCygxByMobile(condition, 0, 18)
  3882. if err != nil {
  3883. br.Msg = "获取信息失败"
  3884. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3885. return
  3886. }
  3887. for k, vChart := range listChart {
  3888. if vChart.PtagName != "" {
  3889. listChart[k].CtagNamePc = vChart.PtagName
  3890. }
  3891. if vChart.CtagName != "" {
  3892. listChart[k].CtagNamePc += "," + vChart.CtagName
  3893. }
  3894. if vChart.PtagNameTwo != "" {
  3895. listChart[k].CtagNamePc += "," + vChart.PtagNameTwo
  3896. }
  3897. if vChart.CtagNameTwo != "" {
  3898. listChart[k].CtagNamePc += "," + vChart.CtagNameTwo
  3899. }
  3900. }
  3901. pageChart := paging.GetPaging(currentIndex, pageSize, totalUser)
  3902. list[k].ListChart = listChart
  3903. list[k].Paging = pageChart
  3904. list[k].IsEnd = pageChart.IsEnd
  3905. list[k].CurrentIndex = pageChart.CurrentIndex
  3906. }
  3907. }
  3908. } else if source == 5 {
  3909. if classType == 1 {
  3910. condition += " AND m.chart_permission_id != 31 "
  3911. } else {
  3912. condition += " AND m.chart_permission_id = 31 "
  3913. }
  3914. if isAdminRole {
  3915. total, err = cygx.GetCygxIndustryFllowCountByCompany(condition)
  3916. if err != nil {
  3917. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3918. br.Msg = "获取用户关注总数失败"
  3919. return
  3920. }
  3921. list, err = cygx.GetCygxIndustryFllowByCompanyList(condition, startSize, pageSize)
  3922. if err != nil && err.Error() != utils.ErrNoRow() {
  3923. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3924. br.Msg = "获取用户关注总数失败"
  3925. return
  3926. }
  3927. } else {
  3928. total, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
  3929. if err != nil {
  3930. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3931. br.Msg = "获取用户关注总数失败"
  3932. return
  3933. }
  3934. list, err = cygx.GetCygxIndustryFllowByCompanyWeekly(condition, startSize, pageSize)
  3935. if err != nil && err.Error() != utils.ErrNoRow() {
  3936. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3937. br.Msg = "获取用户关注总数失败"
  3938. return
  3939. }
  3940. }
  3941. //根据公司ID获取对应销售
  3942. var sellerCompanyIds []int
  3943. for _, v := range list {
  3944. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  3945. }
  3946. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  3947. for _, v := range list {
  3948. v.SellerName = sellNameMap[v.CompanyId]
  3949. }
  3950. } else if source == 6 {
  3951. if isAdminRole {
  3952. total, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
  3953. if err != nil {
  3954. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3955. br.Msg = "获取关注作者总数失败"
  3956. return
  3957. }
  3958. list, err = cygx.GetCygArticleDepartmentFollowByCompanyList(condition, startSize, pageSize)
  3959. if err != nil && err.Error() != utils.ErrNoRow() {
  3960. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3961. br.Msg = "获取关注作者列表失败"
  3962. return
  3963. }
  3964. } else {
  3965. total, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
  3966. if err != nil {
  3967. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3968. br.Msg = "获取关注作者总数失败"
  3969. return
  3970. }
  3971. list, err = cygx.GetCygArticleDepartmentFollowByCompanyWeekly(condition, startSize, pageSize)
  3972. if err != nil && err.Error() != utils.ErrNoRow() {
  3973. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3974. br.Msg = "获取关注作者列表失败"
  3975. return
  3976. }
  3977. }
  3978. if len(list) > 0 {
  3979. //根据公司ID获取对应销售
  3980. var sellerCompanyIds []int
  3981. var departmentIds []int
  3982. for _, v := range list {
  3983. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  3984. departmentIds = append(departmentIds, v.DepartmentId)
  3985. }
  3986. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  3987. mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByDepartmentId(departmentIds) // 关联产业
  3988. for _, v := range list {
  3989. v.SellerName = sellNameMap[v.CompanyId]
  3990. v.SubjectNameStr = strings.Join(mapIndustrialLabel[v.DepartmentId], "/")
  3991. }
  3992. }
  3993. } else if source == 7 {
  3994. if classType == 1 {
  3995. condition += " AND r.register_platform IN (1,2) "
  3996. } else {
  3997. condition += " AND r.register_platform IN (5,6) "
  3998. }
  3999. if isAdminRole {
  4000. total, err = cygx.GetCygxSearchKeyWordCountBuCompany(condition)
  4001. if err != nil {
  4002. br.Msg = "获取信息失败"
  4003. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4004. return
  4005. }
  4006. list, err = cygx.GetCygxSearchKeyWordByCompanyList(condition, startSize, pageSize)
  4007. if err != nil && err.Error() != utils.ErrNoRow() {
  4008. br.Msg = "获取信息失败"
  4009. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4010. return
  4011. }
  4012. } else {
  4013. total, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(condition)
  4014. if err != nil {
  4015. br.Msg = "获取信息失败"
  4016. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4017. return
  4018. }
  4019. list, err = cygx.GetCygxSearchKeyWordByCompanyWeekly(condition, startSize, pageSize)
  4020. if err != nil && err.Error() != utils.ErrNoRow() {
  4021. br.Msg = "获取信息失败"
  4022. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4023. return
  4024. }
  4025. }
  4026. //根据公司ID获取对应销售
  4027. var sellerCompanyIds []int
  4028. for _, v := range list {
  4029. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  4030. }
  4031. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  4032. for _, v := range list {
  4033. v.SellerName = sellNameMap[v.CompanyId]
  4034. }
  4035. } else if source == 8 {
  4036. if isAdminRole {
  4037. total, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
  4038. if err != nil {
  4039. br.Msg = "获取信息失败"
  4040. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4041. return
  4042. }
  4043. list, err = cygx.GetCygxActivitySpecialTripByCompanyList(condition, startSize, pageSize)
  4044. if err != nil && err.Error() != utils.ErrNoRow() {
  4045. br.Msg = "获取信息失败"
  4046. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4047. return
  4048. }
  4049. } else {
  4050. total, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
  4051. if err != nil {
  4052. br.Msg = "获取信息失败"
  4053. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4054. return
  4055. }
  4056. list, err = cygx.CygxActivitySpecialTripByCompanyWeekly(condition, startSize, pageSize)
  4057. if err != nil && err.Error() != utils.ErrNoRow() {
  4058. br.Msg = "获取信息失败"
  4059. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4060. return
  4061. }
  4062. }
  4063. } else if source == 9 {
  4064. if isAdminRole {
  4065. total, err = cygx.GetCygxRoadshowCountByCompany(condition)
  4066. if err != nil {
  4067. br.Msg = "获取信息失败"
  4068. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4069. return
  4070. }
  4071. list, err = cygx.GetCygxRoadshowByCompanyList(condition, startSize, pageSize)
  4072. if err != nil && err.Error() != utils.ErrNoRow() {
  4073. br.Msg = "获取信息失败"
  4074. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4075. return
  4076. }
  4077. } else {
  4078. total, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
  4079. if err != nil {
  4080. br.Msg = "获取信息失败"
  4081. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  4082. return
  4083. }
  4084. list, err = cygx.GetCygxRoadshowByCompanyWeekly(condition, startSize, pageSize)
  4085. if err != nil && err.Error() != utils.ErrNoRow() {
  4086. br.Msg = "获取信息失败"
  4087. br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
  4088. return
  4089. }
  4090. }
  4091. //根据公司ID获取对应销售
  4092. var sellerCompanyIds []int
  4093. for _, v := range list {
  4094. sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
  4095. }
  4096. sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
  4097. for _, v := range list {
  4098. v.SellerName = sellNameMap[v.CompanyId]
  4099. }
  4100. } else if source == 10 { //标签点击记录
  4101. if isAdminRole {
  4102. total, err = cygx.GetCygxTagHistoryCount(condition)
  4103. if err != nil {
  4104. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4105. br.Msg = "获取搜索记录失败"
  4106. return
  4107. }
  4108. list, err = cygx.GetCygxTagHistoryListBycondition(condition, startSize, pageSize)
  4109. if err != nil && err.Error() != utils.ErrNoRow() {
  4110. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4111. br.Msg = "获取搜索记录列表失败"
  4112. return
  4113. }
  4114. } else {
  4115. total, err = cygx.GetCygxTagHistoryCountWeekly(condition)
  4116. if err != nil {
  4117. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4118. br.Msg = "获取搜索记录失败"
  4119. return
  4120. }
  4121. list, err = cygx.GetCygxTagHistoryListByconditionWeekly(condition, startSize, pageSize)
  4122. if err != nil && err.Error() != utils.ErrNoRow() {
  4123. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4124. br.Msg = "获取搜索记录列表失败"
  4125. return
  4126. }
  4127. }
  4128. } else if source == 11 { //专栏文章阅读记录
  4129. if isAdminRole {
  4130. total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
  4131. if err != nil && err.Error() != utils.ErrNoRow() {
  4132. br.Msg = "获取信息失败"
  4133. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4134. return
  4135. }
  4136. } else {
  4137. total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, startSize, pageSize)
  4138. if err != nil && err.Error() != utils.ErrNoRow() {
  4139. br.Msg = "获取信息失败"
  4140. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4141. return
  4142. }
  4143. }
  4144. if len(list) > 0 {
  4145. for k, v := range list {
  4146. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  4147. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  4148. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  4149. }
  4150. for k, v := range list {
  4151. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  4152. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  4153. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  4154. }
  4155. }
  4156. //导出excel
  4157. if isExport {
  4158. exportListYanxuanSpecial(this, list, 3, br)
  4159. return
  4160. }
  4161. } else if source == 12 { //收藏的专栏文章
  4162. if isAdminRole {
  4163. total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
  4164. if err != nil && err.Error() != utils.ErrNoRow() {
  4165. br.Msg = "获取信息失败"
  4166. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4167. return
  4168. }
  4169. } else {
  4170. total, list, err = cygx.GetCygxYanxuanSpecialCollectByUserWeekly(condition, startSize, pageSize)
  4171. if err != nil && err.Error() != utils.ErrNoRow() {
  4172. br.Msg = "获取信息失败"
  4173. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4174. return
  4175. }
  4176. }
  4177. if len(list) > 0 {
  4178. for k, v := range list {
  4179. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  4180. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  4181. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
  4182. }
  4183. }
  4184. } else if source == 13 { //关注的专栏作者
  4185. if isAdminRole {
  4186. total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
  4187. if err != nil && err.Error() != utils.ErrNoRow() {
  4188. br.Msg = "获取信息失败"
  4189. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4190. return
  4191. }
  4192. } else {
  4193. total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUserWeekly(condition, startSize, pageSize)
  4194. if err != nil && err.Error() != utils.ErrNoRow() {
  4195. br.Msg = "获取信息失败"
  4196. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4197. return
  4198. }
  4199. }
  4200. if len(list) > 0 {
  4201. for k, v := range list {
  4202. list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
  4203. list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
  4204. list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
  4205. }
  4206. }
  4207. } else if source == 14 { //交流反馈
  4208. if isAdminRole {
  4209. total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
  4210. if err != nil && err.Error() != utils.ErrNoRow() {
  4211. br.Msg = "获取信息失败"
  4212. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4213. return
  4214. }
  4215. } else {
  4216. total, list, err = cygx.GetCygxUserFeedbackWeekly(condition, startSize, pageSize)
  4217. if err != nil && err.Error() != utils.ErrNoRow() {
  4218. br.Msg = "获取信息失败"
  4219. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4220. return
  4221. }
  4222. }
  4223. } else if source == 15 {
  4224. if startDate != "" {
  4225. condition += ` AND b.start_date >= '` + startDate + `' `
  4226. }
  4227. if endDate != "" {
  4228. condition += ` AND b.start_date <= '` + endDate + `' `
  4229. }
  4230. var totalRsCalendar int
  4231. var listRsCalendar []*roadshow.RsCalendarMeetingUserByRai
  4232. if isAdminRole {
  4233. totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
  4234. if err != nil {
  4235. br.Msg = "获取信息失败"
  4236. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4237. return
  4238. }
  4239. } else {
  4240. totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRaiWeekly(condition, startSize, pageSize)
  4241. if err != nil {
  4242. br.Msg = "获取信息失败"
  4243. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4244. return
  4245. }
  4246. }
  4247. total = totalRsCalendar
  4248. list, err = cygxService.HandleListRsCalendar(listRsCalendar)
  4249. if err != nil {
  4250. br.Msg = "获取信息失败"
  4251. br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
  4252. return
  4253. }
  4254. //导出excel
  4255. if isExport {
  4256. exportListRsCalendar(this, list, 3, br)
  4257. return
  4258. }
  4259. }
  4260. page := paging.GetPaging(currentIndex, pageSize, total)
  4261. if len(list) == 0 {
  4262. list = make([]*cygx.UserInteraction, 0)
  4263. }
  4264. resp.List = list
  4265. resp.Paging = page
  4266. br.Ret = 200
  4267. br.Success = true
  4268. br.Msg = "获取成功"
  4269. br.Data = resp
  4270. }
  4271. // @Title 机构列表相关互动下载
  4272. // @Description 机构相关互动下载接口
  4273. // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
  4274. // @Param IsMeeting query string true "是否到会 1到会、2未到会"
  4275. // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
  4276. // @Param StartDate query string true "开始时间"
  4277. // @Param EndDate query string true "结束时间"
  4278. // @Param KeyWord query string true "搜索关键词"
  4279. // @Param ActivityName query string true "活动名称"
  4280. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  4281. // @Success 200 {object} cygx.CygxUserTableStatusListRep
  4282. // @router /user/companyList/export/interaction [get]
  4283. func (this *UserController) CompanyExportInteractionList() {
  4284. br := new(models.BaseResponse).Init()
  4285. defer func() {
  4286. this.Data["json"] = br
  4287. this.ServeJSON()
  4288. }()
  4289. sysUser := this.SysUser
  4290. if sysUser == nil {
  4291. br.Msg = "请登录"
  4292. br.ErrMsg = "请登录,SysUser Is Empty"
  4293. br.Ret = 408
  4294. return
  4295. }
  4296. roleTypeCode := sysUser.RoleTypeCode
  4297. adminId := this.GetString("AdminId")
  4298. keyWord := this.GetString("KeyWord")
  4299. isMeeting := this.GetString("IsMeeting")
  4300. meetType := this.GetString("MeetType")
  4301. startDate := this.GetString("StartDate")
  4302. endDate := this.GetString("EndDate")
  4303. activityName := this.GetString("ActivityName")
  4304. source, _ := this.GetInt("Source")
  4305. status := this.GetString("Status")
  4306. classType, _ := this.GetInt("ClassType", 1)
  4307. // 套餐类型
  4308. //packageType, _ := this.GetInt("PackageType")
  4309. keyWord = strings.Trim(keyWord, " ")
  4310. keyWord = strings.Replace(keyWord, "'", "", -1)
  4311. var list []*cygx.UserInteraction
  4312. var err error
  4313. var condition string
  4314. //流失
  4315. var lossCondition string
  4316. //var lossPars []interface{}
  4317. //状态分类查询条件
  4318. var permissionCondition string
  4319. if adminId != "" {
  4320. condition += ` AND b.seller_id IN (` + adminId + `) `
  4321. }
  4322. lossCondition = condition
  4323. //lossPars = pars
  4324. permissionCondition = condition
  4325. //流失客户统计
  4326. lossCondition += ` AND status='流失' `
  4327. //productId := services.GetProductId(roleTypeCode)
  4328. productId := 2
  4329. //权限控制
  4330. {
  4331. //如果不是超级管理员或者财务
  4332. if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
  4333. //如果是部门管理员
  4334. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  4335. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4336. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4337. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4338. } else {
  4339. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4340. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4341. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4342. if status == "全部" {
  4343. ////如果是筛选了流失客户状态
  4344. if sysUser.Authority <= 0 {
  4345. condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
  4346. permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
  4347. } else {
  4348. if sysUser.Authority == 1 {
  4349. condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
  4350. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  4351. }
  4352. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  4353. if status != utils.COMPANY_STATUS_LOSE {
  4354. condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  4355. }
  4356. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  4357. }
  4358. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  4359. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  4360. if err != nil {
  4361. br.Msg = "获取失败"
  4362. br.ErrMsg = "查询父级id异常" + err.Error()
  4363. return
  4364. }
  4365. var ids []*string
  4366. if pid != nil {
  4367. if *pid != 0 {
  4368. //销售主管放在三级列表中
  4369. ids, err = company.GetGroupIdsByParentId(*pid)
  4370. if err != nil {
  4371. fmt.Println(err.Error())
  4372. }
  4373. } else {
  4374. //销售主管放在二级列表中
  4375. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  4376. if err != nil {
  4377. fmt.Println(err.Error())
  4378. }
  4379. }
  4380. }
  4381. var idSlice []string
  4382. var sid string
  4383. for _, id := range ids {
  4384. idSlice = append(idSlice, *id)
  4385. }
  4386. //加入父级groupId
  4387. if *pid > 0 {
  4388. idSlice = append(idSlice, strconv.Itoa(*pid))
  4389. } else {
  4390. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  4391. }
  4392. sid = strings.Join(idSlice, ",")
  4393. if len(sid) > 0 {
  4394. if status != utils.COMPANY_STATUS_LOSE {
  4395. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  4396. }
  4397. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  4398. } else {
  4399. if status != utils.COMPANY_STATUS_LOSE {
  4400. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  4401. }
  4402. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  4403. }
  4404. }
  4405. if sysUser.Authority == 4 {
  4406. if status != utils.COMPANY_STATUS_LOSE {
  4407. condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  4408. //pars = append(pars, sysUser.GroupId)
  4409. }
  4410. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  4411. //permissionPars = append(permissionPars, sysUser.GroupId)
  4412. }
  4413. }
  4414. } else {
  4415. //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
  4416. if sysUser.Authority <= 0 {
  4417. if status != utils.COMPANY_STATUS_LOSE {
  4418. condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  4419. //pars = append(pars, sysUser.AdminId)
  4420. }
  4421. permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  4422. //permissionPars = append(permissionPars, sysUser.AdminId)
  4423. } else {
  4424. if sysUser.Authority == 1 {
  4425. if status != utils.COMPANY_STATUS_LOSE {
  4426. condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  4427. //pars = append(pars, sysUser.DepartmentId)
  4428. }
  4429. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  4430. //permissionPars = append(permissionPars, sysUser.DepartmentId)
  4431. }
  4432. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  4433. if status != utils.COMPANY_STATUS_LOSE {
  4434. condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
  4435. //pars = append(pars, sysUser.GroupId)
  4436. }
  4437. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  4438. //permissionPars = append(permissionPars, sysUser.GroupId)
  4439. }
  4440. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  4441. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  4442. if err != nil {
  4443. br.Msg = "获取失败"
  4444. br.ErrMsg = "查询父级id异常" + err.Error()
  4445. return
  4446. }
  4447. var ids []*string
  4448. if pid != nil {
  4449. if *pid != 0 {
  4450. //销售主管放在三级列表中
  4451. ids, err = company.GetGroupIdsByParentId(*pid)
  4452. if err != nil {
  4453. fmt.Println(err.Error())
  4454. }
  4455. } else {
  4456. //销售主管放在二级列表中
  4457. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  4458. if err != nil {
  4459. fmt.Println(err.Error())
  4460. }
  4461. }
  4462. }
  4463. var idSlice []string
  4464. var sid string
  4465. for _, id := range ids {
  4466. idSlice = append(idSlice, *id)
  4467. }
  4468. //加入父级groupId
  4469. if *pid > 0 {
  4470. idSlice = append(idSlice, strconv.Itoa(*pid))
  4471. } else {
  4472. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  4473. }
  4474. sid = strings.Join(idSlice, ",")
  4475. if len(sid) > 0 {
  4476. if status != utils.COMPANY_STATUS_LOSE {
  4477. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  4478. //pars = append(pars, sysUser.GroupId)
  4479. }
  4480. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  4481. } else {
  4482. if status != utils.COMPANY_STATUS_LOSE {
  4483. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  4484. //pars = append(pars, sysUser.GroupId)
  4485. }
  4486. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  4487. }
  4488. }
  4489. if sysUser.Authority == 4 {
  4490. if status != utils.COMPANY_STATUS_LOSE {
  4491. condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
  4492. //pars = append(pars, sysUser.GroupId)
  4493. }
  4494. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  4495. //permissionPars = append(permissionPars, sysUser.GroupId)
  4496. }
  4497. }
  4498. }
  4499. }
  4500. }
  4501. }
  4502. //condition += ` AND b.status IN ('正式','试用','冻结') `
  4503. //companyCondition := `SELECT a.company_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  4504. //if condition != "" {
  4505. // companyCondition += condition
  4506. //}
  4507. condition += ` AND b.status IN ('正式','试用','冻结') `
  4508. companyCondition := `SELECT a.company_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  4509. companyIdsCondition := `SELECT GROUP_CONCAT( DISTINCT a.company_id SEPARATOR ',' ) AS company_ids FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  4510. if condition != "" {
  4511. companyCondition += condition
  4512. }
  4513. companyIdsCondition += condition
  4514. var companyIds string
  4515. companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
  4516. companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
  4517. if err != nil {
  4518. br.Msg = "获取失败"
  4519. br.ErrMsg = "获取公司ID数据失败,Err:" + err.Error()
  4520. return
  4521. }
  4522. condition = ` AND r.company_id IN ( ` + companyIds + ` )AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
  4523. if keyWord != "" {
  4524. condition += ` AND (r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%'` + ` OR r.company_name LIKE '%` + keyWord + `%') `
  4525. }
  4526. var isAdminRole bool
  4527. var pageSize = 9999
  4528. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  4529. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  4530. isAdminRole = true
  4531. }
  4532. if source == 1 {
  4533. if classType == 1 {
  4534. condition += " AND art.article_type_id = 0 "
  4535. } else {
  4536. condition += " AND art.article_type_id > 0 "
  4537. }
  4538. if startDate != "" {
  4539. startDate += " 00:00:00"
  4540. condition += ` AND r.create_time >= '` + startDate + `' `
  4541. }
  4542. if endDate != "" {
  4543. endDate += " 23:59:59"
  4544. condition += ` AND r.create_time <= '` + endDate + `' `
  4545. }
  4546. condition += ` ORDER BY r.create_time DESC `
  4547. var pars []interface{}
  4548. var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
  4549. if isAdminRole {
  4550. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
  4551. if err != nil && err.Error() != utils.ErrNoRow() {
  4552. br.Msg = "获取信息失败"
  4553. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4554. return
  4555. }
  4556. } else {
  4557. listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, 0, pageSize)
  4558. if err != nil && err.Error() != utils.ErrNoRow() {
  4559. br.Msg = "获取信息失败"
  4560. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4561. return
  4562. }
  4563. }
  4564. //处理查询信息回显
  4565. list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
  4566. if err != nil && err.Error() != utils.ErrNoRow() {
  4567. br.Msg = "获取信息失败"
  4568. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4569. return
  4570. }
  4571. if len(list) > 0 {
  4572. var articleIds string
  4573. mapAricleId := make(map[int]int)
  4574. mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
  4575. for k, v := range list {
  4576. if v.ArticleId >= utils.SummaryArticleId {
  4577. list[k].ArticleType = 1
  4578. } else {
  4579. list[k].ArticleType = 2
  4580. }
  4581. if list[k].PermissionName == "" {
  4582. list[k].PermissionName = v.CategoryName
  4583. }
  4584. if mapAricleId[v.ArticleId] == 0 {
  4585. articleIds += strconv.Itoa(v.ArticleId) + ","
  4586. mapAricleId[v.ArticleId] = v.ArticleId
  4587. }
  4588. }
  4589. articleIds = strings.TrimRight(articleIds, ",")
  4590. if articleIds != "" {
  4591. listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
  4592. if err != nil && err.Error() != utils.ErrNoRow() {
  4593. br.Msg = "获取信息失败"
  4594. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4595. return
  4596. }
  4597. if len(listArticleIndustrialSubjectList) > 0 {
  4598. for _, v := range listArticleIndustrialSubjectList {
  4599. mapAricleIndustrialSubjectName[v.ArticleId] = v
  4600. }
  4601. for k, v := range list {
  4602. if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
  4603. fmt.Println(mapAricleIndustrialSubjectName[v.ArticleId].IndustryName)
  4604. list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
  4605. list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
  4606. }
  4607. }
  4608. }
  4609. }
  4610. }
  4611. } else if source == 2 {
  4612. if classType == 1 {
  4613. condition += " AND a.chart_permission_id != 31 "
  4614. } else {
  4615. condition += " AND a.chart_permission_id = 31 "
  4616. }
  4617. if isMeeting == "1" {
  4618. condition += ` AND r.is_meeting = 1 `
  4619. }
  4620. if isMeeting == "2" {
  4621. condition += ` AND r.is_meeting = 0 `
  4622. }
  4623. if meetType == "1" {
  4624. condition += ` AND t.activity_type = 1 `
  4625. }
  4626. if meetType == "2" {
  4627. condition += ` AND t.activity_type = 0 `
  4628. }
  4629. if startDate != "" {
  4630. startDate += " 00:00:00"
  4631. condition += ` AND a.activity_time >= '` + startDate + `' `
  4632. }
  4633. if endDate != "" {
  4634. endDate += " 23:59:59"
  4635. condition += ` AND a.activity_time <= '` + endDate + `' `
  4636. }
  4637. if activityName != "" {
  4638. condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
  4639. }
  4640. if isAdminRole {
  4641. list, err = cygx.GetActivityMeetByCompany(condition, 0, pageSize)
  4642. if err != nil && err.Error() != utils.ErrNoRow() {
  4643. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4644. br.Msg = "获取参会人数列表失败"
  4645. return
  4646. }
  4647. } else {
  4648. list, err = cygx.GetActivityMeetByCompanyWeekly(condition, 0, pageSize)
  4649. if err != nil && err.Error() != utils.ErrNoRow() {
  4650. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  4651. br.Msg = "获取参会人数列表失败"
  4652. return
  4653. }
  4654. }
  4655. if len(list) > 0 {
  4656. for k, v := range list {
  4657. if v.ActivityType == 1 {
  4658. if v.SignupType == "2" {
  4659. list[k].InteractionType = "自主拨入"
  4660. } else {
  4661. list[k].InteractionType = "预约外呼"
  4662. }
  4663. if v.ReminderNum > 0 {
  4664. list[k].InteractionType += ",会议提醒"
  4665. }
  4666. }
  4667. }
  4668. }
  4669. } else if source == 11 {
  4670. if isAdminRole {
  4671. _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
  4672. if err != nil && err.Error() != utils.ErrNoRow() {
  4673. br.Msg = "获取信息失败"
  4674. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4675. return
  4676. }
  4677. } else {
  4678. _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, 0, 9999)
  4679. if err != nil && err.Error() != utils.ErrNoRow() {
  4680. br.Msg = "获取信息失败"
  4681. br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
  4682. return
  4683. }
  4684. }
  4685. }
  4686. //创建excel
  4687. dir, err := os.Executable()
  4688. exPath := filepath.Dir(dir)
  4689. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4690. xlsxFile := xlsx.NewFile()
  4691. if err != nil {
  4692. br.Msg = "生成文件失败"
  4693. br.ErrMsg = "生成文件失败"
  4694. return
  4695. }
  4696. style := xlsx.NewStyle()
  4697. alignment := xlsx.Alignment{
  4698. Horizontal: "center",
  4699. Vertical: "center",
  4700. WrapText: true,
  4701. }
  4702. var excelName string
  4703. style.Alignment = alignment
  4704. style.ApplyAlignment = true
  4705. sheet, err := xlsxFile.AddSheet("到会管理名单")
  4706. if err != nil {
  4707. br.Msg = "新增Sheet失败"
  4708. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  4709. return
  4710. }
  4711. if source == 1 {
  4712. excelName = "客户阅读记录"
  4713. //标头
  4714. rowTitle := sheet.AddRow()
  4715. cellA := rowTitle.AddCell()
  4716. cellA.Value = "客户名称"
  4717. cellB := rowTitle.AddCell()
  4718. cellB.Value = "所属销售"
  4719. cellC := rowTitle.AddCell()
  4720. cellC.Value = "姓名"
  4721. cellD := rowTitle.AddCell()
  4722. cellD.Value = "手机号"
  4723. cellE := rowTitle.AddCell()
  4724. cellE.Value = "报告标题"
  4725. cellF := rowTitle.AddCell()
  4726. cellF.Value = "所属行业"
  4727. cellG := rowTitle.AddCell()
  4728. cellG.Value = "所属产业"
  4729. cellH := rowTitle.AddCell()
  4730. cellH.Value = "关联标的"
  4731. cellI := rowTitle.AddCell()
  4732. cellI.Value = "发布时间"
  4733. cellJ := rowTitle.AddCell()
  4734. cellJ.Value = "阅读时间"
  4735. cellK := rowTitle.AddCell()
  4736. cellK.Value = "阅读时长"
  4737. for _, item := range list {
  4738. row := sheet.AddRow()
  4739. cellA := row.AddCell()
  4740. cellA.Value = item.CompanyName
  4741. cellB := row.AddCell()
  4742. cellB.Value = item.SellerName
  4743. cellC := row.AddCell()
  4744. cellC.Value = item.RealName
  4745. cellD := row.AddCell()
  4746. cellD.Value = item.Mobile
  4747. cellE := row.AddCell()
  4748. cellE.Value = item.Title
  4749. cellF := row.AddCell()
  4750. cellF.Value = item.PermissionName
  4751. cellG := row.AddCell()
  4752. cellG.Value = item.IndustryName
  4753. cellH := row.AddCell()
  4754. cellH.Value = item.SubjectNameStr
  4755. cellI := row.AddCell()
  4756. cellI.Value = item.PublishDate
  4757. cellJ := row.AddCell()
  4758. cellJ.Value = item.CreateTime
  4759. cellK := row.AddCell()
  4760. cellK.Value = item.StopTime
  4761. }
  4762. } else if source == 2 {
  4763. excelName = "客户参会记录"
  4764. //标头
  4765. rowTitle := sheet.AddRow()
  4766. cellA := rowTitle.AddCell()
  4767. cellA.Value = "客户名称"
  4768. cellB := rowTitle.AddCell()
  4769. cellB.Value = "所属销售"
  4770. cellC := rowTitle.AddCell()
  4771. cellC.Value = "姓名"
  4772. cellD := rowTitle.AddCell()
  4773. cellD.Value = "手机号"
  4774. cellE := rowTitle.AddCell()
  4775. cellE.Value = "活动名称"
  4776. cellF := rowTitle.AddCell()
  4777. cellF.Value = "所属行业"
  4778. cellG := rowTitle.AddCell()
  4779. cellG.Value = "活动类型"
  4780. cellH := rowTitle.AddCell()
  4781. cellH.Value = "活动主题"
  4782. cellI := rowTitle.AddCell()
  4783. cellI.Value = "活动时间"
  4784. cellJ := rowTitle.AddCell()
  4785. cellJ.Value = "是否到会"
  4786. cellK := rowTitle.AddCell()
  4787. cellK.Value = "首次入会时间"
  4788. cellL := rowTitle.AddCell()
  4789. cellL.Value = "最后退出时间"
  4790. cellM := rowTitle.AddCell()
  4791. cellM.Value = "参与总时长"
  4792. cellN := rowTitle.AddCell()
  4793. cellN.Value = "参会方式"
  4794. cellO := rowTitle.AddCell()
  4795. cellO.Value = "参会权鉴"
  4796. cellP := rowTitle.AddCell()
  4797. cellP.Value = "参会状态"
  4798. for _, item := range list {
  4799. row := sheet.AddRow()
  4800. cellA := row.AddCell()
  4801. cellA.Value = item.CompanyName
  4802. cellB := row.AddCell()
  4803. cellB.Value = item.SellerName
  4804. cellC := row.AddCell()
  4805. cellC.Value = item.RealName
  4806. cellD := row.AddCell()
  4807. cellD.Value = item.Mobile
  4808. cellE := row.AddCell()
  4809. cellE.Value = item.ActivityName
  4810. cellF := row.AddCell()
  4811. cellF.Value = item.PermissionName
  4812. cellG := row.AddCell()
  4813. cellG.Value = item.ActivityTypeName
  4814. cellH := row.AddCell()
  4815. cellH.Value = item.Label
  4816. cellI := row.AddCell()
  4817. cellI.Value = item.ActivityTime
  4818. cellJ := row.AddCell()
  4819. if item.IsMeeting == 1 {
  4820. cellJ.Value = "到会"
  4821. } else {
  4822. cellJ.Value = "未到会"
  4823. }
  4824. cellK := row.AddCell()
  4825. cellK.Value = item.FirstMeetingTime
  4826. cellL := row.AddCell()
  4827. cellL.Value = item.LastMeetingTime
  4828. cellM := row.AddCell()
  4829. cellM.Value = item.Duration
  4830. cellN := row.AddCell()
  4831. cellN.Value = item.LastMeetingTime
  4832. cellO := row.AddCell()
  4833. cellO.Value = item.MeetingTypeStr
  4834. cellP := row.AddCell()
  4835. cellP.Value = item.MeetingStatusStr
  4836. }
  4837. } else if source == 11 {
  4838. //标头
  4839. rowTitle := sheet.AddRow()
  4840. cellA := rowTitle.AddCell()
  4841. cellA.Value = "文章标题"
  4842. cellB := rowTitle.AddCell()
  4843. cellB.Value = "文章类型"
  4844. cellC := rowTitle.AddCell()
  4845. cellC.Value = "标签"
  4846. cellD := rowTitle.AddCell()
  4847. cellD.Value = "发布时间"
  4848. cellE := rowTitle.AddCell()
  4849. cellE.Value = "阅读时间"
  4850. cellF := rowTitle.AddCell()
  4851. cellF.Value = "阅读时长"
  4852. cellG := rowTitle.AddCell()
  4853. cellG.Value = "阅读来源"
  4854. for _, item := range list {
  4855. row := sheet.AddRow()
  4856. cellA := row.AddCell()
  4857. cellA.Value = item.Title
  4858. cellB := row.AddCell()
  4859. if item.SpecialType == 1 {
  4860. cellB.Value = "笔记"
  4861. } else {
  4862. cellB.Value = "观点"
  4863. }
  4864. cellC := row.AddCell()
  4865. cellC.Value = item.IndustryName
  4866. cellD := row.AddCell()
  4867. cellD.Value = item.PublishDate
  4868. cellE := row.AddCell()
  4869. cellE.Value = item.CreateTime
  4870. cellF := row.AddCell()
  4871. cellF.Value = item.StopTime
  4872. cellG := row.AddCell()
  4873. cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
  4874. }
  4875. }
  4876. err = xlsxFile.Save(downLoadnFilePath)
  4877. if err != nil {
  4878. br.Msg = "保存文件失败"
  4879. br.ErrMsg = "保存文件失败"
  4880. return
  4881. }
  4882. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  4883. downloadFileName := excelName + randStr + ".xlsx"
  4884. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  4885. defer func() {
  4886. os.Remove(downLoadnFilePath)
  4887. }()
  4888. br.Ret = 200
  4889. br.Success = true
  4890. br.Msg = "获取成功"
  4891. }
  4892. // @Title 机构列表互动详情table栏
  4893. // @Description 机构列表互动详情table栏接口
  4894. // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
  4895. // @Success 200 {object} cygx.CygxUserTableListRep
  4896. // @router /user/table/companyList [get]
  4897. func (this *UserController) TableCompanyList() {
  4898. br := new(models.BaseResponse).Init()
  4899. defer func() {
  4900. this.Data["json"] = br
  4901. this.ServeJSON()
  4902. }()
  4903. sysUser := this.SysUser
  4904. if sysUser == nil {
  4905. br.Msg = "请登录"
  4906. br.ErrMsg = "请登录,SysUser Is Empty"
  4907. br.Ret = 408
  4908. return
  4909. }
  4910. roleTypeCode := sysUser.RoleTypeCode
  4911. status := this.GetString("Status")
  4912. classType, _ := this.GetInt("ClassType", 1)
  4913. //流失
  4914. var lossCondition string
  4915. var condition string
  4916. //var lossPars []interface{}
  4917. //状态分类查询条件
  4918. var permissionCondition string
  4919. lossCondition = condition
  4920. //lossPars = pars
  4921. permissionCondition = condition
  4922. //流失客户统计
  4923. lossCondition += ` AND status='流失' `
  4924. //productId := services.GetProductId(roleTypeCode)
  4925. productId := 2
  4926. //权限控制
  4927. {
  4928. //如果不是超级管理员或者财务
  4929. if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
  4930. //如果是部门管理员
  4931. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  4932. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4933. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4934. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4935. } else {
  4936. condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4937. lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4938. permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
  4939. if status == "全部" {
  4940. ////如果是筛选了流失客户状态
  4941. if sysUser.Authority <= 0 {
  4942. condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
  4943. permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
  4944. } else {
  4945. if sysUser.Authority == 1 {
  4946. condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
  4947. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  4948. }
  4949. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  4950. if status != utils.COMPANY_STATUS_LOSE {
  4951. condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  4952. }
  4953. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  4954. }
  4955. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  4956. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  4957. if err != nil {
  4958. br.Msg = "获取失败"
  4959. br.ErrMsg = "查询父级id异常" + err.Error()
  4960. return
  4961. }
  4962. var ids []*string
  4963. if pid != nil {
  4964. if *pid != 0 {
  4965. //销售主管放在三级列表中
  4966. ids, err = company.GetGroupIdsByParentId(*pid)
  4967. if err != nil {
  4968. fmt.Println(err.Error())
  4969. }
  4970. } else {
  4971. //销售主管放在二级列表中
  4972. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  4973. if err != nil {
  4974. fmt.Println(err.Error())
  4975. }
  4976. }
  4977. }
  4978. var idSlice []string
  4979. var sid string
  4980. for _, id := range ids {
  4981. idSlice = append(idSlice, *id)
  4982. }
  4983. //加入父级groupId
  4984. if *pid > 0 {
  4985. idSlice = append(idSlice, strconv.Itoa(*pid))
  4986. } else {
  4987. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  4988. }
  4989. sid = strings.Join(idSlice, ",")
  4990. if len(sid) > 0 {
  4991. if status != utils.COMPANY_STATUS_LOSE {
  4992. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  4993. }
  4994. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  4995. } else {
  4996. if status != utils.COMPANY_STATUS_LOSE {
  4997. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  4998. }
  4999. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  5000. }
  5001. }
  5002. if sysUser.Authority == 4 {
  5003. if status != utils.COMPANY_STATUS_LOSE {
  5004. condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
  5005. //pars = append(pars, sysUser.GroupId)
  5006. }
  5007. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  5008. //permissionPars = append(permissionPars, sysUser.GroupId)
  5009. }
  5010. }
  5011. } else {
  5012. //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
  5013. if sysUser.Authority <= 0 {
  5014. if status != utils.COMPANY_STATUS_LOSE {
  5015. condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  5016. //pars = append(pars, sysUser.AdminId)
  5017. }
  5018. permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
  5019. //permissionPars = append(permissionPars, sysUser.AdminId)
  5020. } else {
  5021. if sysUser.Authority == 1 {
  5022. if status != utils.COMPANY_STATUS_LOSE {
  5023. condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  5024. //pars = append(pars, sysUser.DepartmentId)
  5025. }
  5026. permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
  5027. //permissionPars = append(permissionPars, sysUser.DepartmentId)
  5028. }
  5029. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  5030. if status != utils.COMPANY_STATUS_LOSE {
  5031. condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
  5032. //pars = append(pars, sysUser.GroupId)
  5033. }
  5034. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  5035. //permissionPars = append(permissionPars, sysUser.GroupId)
  5036. }
  5037. if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  5038. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  5039. if err != nil {
  5040. br.Msg = "获取失败"
  5041. br.ErrMsg = "查询父级id异常" + err.Error()
  5042. return
  5043. }
  5044. var ids []*string
  5045. if pid != nil {
  5046. if *pid != 0 {
  5047. //销售主管放在三级列表中
  5048. ids, err = company.GetGroupIdsByParentId(*pid)
  5049. if err != nil {
  5050. fmt.Println(err.Error())
  5051. }
  5052. } else {
  5053. //销售主管放在二级列表中
  5054. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  5055. if err != nil {
  5056. fmt.Println(err.Error())
  5057. }
  5058. }
  5059. }
  5060. var idSlice []string
  5061. var sid string
  5062. for _, id := range ids {
  5063. idSlice = append(idSlice, *id)
  5064. }
  5065. //加入父级groupId
  5066. if *pid > 0 {
  5067. idSlice = append(idSlice, strconv.Itoa(*pid))
  5068. } else {
  5069. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  5070. }
  5071. sid = strings.Join(idSlice, ",")
  5072. if len(sid) > 0 {
  5073. if status != utils.COMPANY_STATUS_LOSE {
  5074. condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
  5075. //pars = append(pars, sysUser.GroupId)
  5076. }
  5077. permissionCondition += ` AND b.group_id IN (` + sid + `) `
  5078. } else {
  5079. if status != utils.COMPANY_STATUS_LOSE {
  5080. condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
  5081. //pars = append(pars, sysUser.GroupId)
  5082. }
  5083. permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
  5084. }
  5085. }
  5086. if sysUser.Authority == 4 {
  5087. if status != utils.COMPANY_STATUS_LOSE {
  5088. condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
  5089. //pars = append(pars, sysUser.GroupId)
  5090. }
  5091. permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
  5092. //permissionPars = append(permissionPars, sysUser.GroupId)
  5093. }
  5094. }
  5095. }
  5096. }
  5097. }
  5098. }
  5099. condition += ` AND b.status IN ('正式','试用','冻结') `
  5100. companyCondition := ` AND a.enabled=1 `
  5101. if condition != "" {
  5102. companyCondition += condition
  5103. }
  5104. resp := new(cygx.CygxUserTableListRep)
  5105. var isAdminRole bool
  5106. //如果不是管理员身份或者研究员身份则需要添加可见范围处理
  5107. if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
  5108. isAdminRole = true
  5109. }
  5110. var pars []interface{}
  5111. lsitCompany, err := company.GetCompanyProductListBycondition(condition, pars)
  5112. if err != nil {
  5113. br.Msg = "获取失败"
  5114. br.ErrMsg = "获取数据失败,GetCompanyProductListBycondition Err:" + err.Error()
  5115. return
  5116. }
  5117. var companyIds []string
  5118. for _, v := range lsitCompany {
  5119. companyIds = append(companyIds, strconv.Itoa(v.CompanyId))
  5120. }
  5121. condition = " AND r.company_id IN (" + strings.Join(companyIds, ",") + ")"
  5122. condition += ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
  5123. conditionArtcile := condition //文章搜索条件
  5124. conditionActivityMeet := condition //活动到会搜索条件
  5125. conditionIndustryFllow := condition //产业关注搜索条件
  5126. conditionKeyWord := condition //关键词记录搜索条件
  5127. if classType == 1 {
  5128. conditionArtcile += " AND art.article_type_id = 0 "
  5129. conditionActivityMeet += " AND a.chart_permission_id != 31 "
  5130. conditionIndustryFllow += " AND m.chart_permission_id != 31 "
  5131. conditionKeyWord += " AND r.register_platform IN (1,2) "
  5132. } else {
  5133. conditionArtcile += " AND art.article_type_id > 0 "
  5134. conditionActivityMeet += " AND a.chart_permission_id = 31 "
  5135. conditionIndustryFllow += " AND m.chart_permission_id = 31 "
  5136. conditionKeyWord += " AND r.register_platform IN (5,6) "
  5137. }
  5138. var historyNum int //报告阅读列表
  5139. var activityNum int //活动互动记录
  5140. var triptotal int //专项调研
  5141. var articleCollect int //收藏的报告
  5142. var chartNum int //收藏图表
  5143. var industryFllowNum int //关注的产业
  5144. var departmentFollowNum int //关注的作者
  5145. var keyWordNum int //搜索
  5146. var roadshowTotal int //音视频播放
  5147. var tagNum int //首页标签点击
  5148. var yanxuanSpecialNum int //专栏文章阅读记录
  5149. var yanxuanSpecialCollectNum int //收藏的专栏文章
  5150. var yanxuanSpecialFollowNum int //关注的专栏作者
  5151. var feedbackNum int //交流反馈数量
  5152. var calendarMeetingNum int //1v1 路演数量
  5153. if isAdminRole {
  5154. historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCount(conditionArtcile, pars)
  5155. if err != nil {
  5156. br.Msg = "获取信息失败"
  5157. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  5158. return
  5159. }
  5160. //获取参会总数
  5161. activityNum, err = cygx.GetActivityMeetByCompanyCount(conditionActivityMeet)
  5162. if err != nil {
  5163. br.Msg = "获取信息失败"
  5164. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  5165. return
  5166. }
  5167. //获取用户收藏记录总数
  5168. articleCollect, err = cygx.GetCygxArticleCollectCountByCompany(conditionArtcile)
  5169. if err != nil {
  5170. br.Msg = "获取信息失败"
  5171. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  5172. return
  5173. }
  5174. //获取用户关注总数
  5175. industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompany(conditionIndustryFllow)
  5176. if err != nil {
  5177. br.Msg = "获取信息失败 "
  5178. br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
  5179. return
  5180. }
  5181. //获取关注作者总数
  5182. departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
  5183. if err != nil {
  5184. br.Msg = "获取信息失败"
  5185. br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
  5186. return
  5187. }
  5188. //获取搜索记录
  5189. keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompany(conditionKeyWord)
  5190. if err != nil {
  5191. br.Msg = "获取信息失败"
  5192. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5193. return
  5194. }
  5195. chartNum, err = cygx.GetChartCountByUserMobile(condition)
  5196. if err != nil {
  5197. br.Msg = "获取信息失败"
  5198. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  5199. return
  5200. }
  5201. triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
  5202. if err != nil {
  5203. br.Msg = "获取信息失败"
  5204. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5205. return
  5206. }
  5207. roadshowTotal, err = cygx.GetCygxRoadshowCountByCompany(condition)
  5208. if err != nil {
  5209. br.Msg = "获取信息失败"
  5210. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5211. return
  5212. }
  5213. tagNum, err = cygx.GetCygxTagHistoryCount(condition)
  5214. if err != nil {
  5215. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5216. br.Msg = "获取搜索记录失败"
  5217. return
  5218. }
  5219. yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCount(condition, pars)
  5220. if err != nil {
  5221. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5222. br.Msg = "获取研选专栏阅读数量失败"
  5223. return
  5224. }
  5225. yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCount(condition, pars)
  5226. if err != nil {
  5227. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5228. br.Msg = "获取收藏的专栏文章数量失败"
  5229. return
  5230. }
  5231. yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCount(condition, pars)
  5232. if err != nil {
  5233. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5234. br.Msg = "获取关注的专栏作者数量失败"
  5235. return
  5236. }
  5237. feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModel(condition, pars)
  5238. if err != nil {
  5239. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5240. br.Msg = "获取交流反馈数量失败"
  5241. return
  5242. }
  5243. calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModel(condition, pars)
  5244. if err != nil {
  5245. br.Msg = "获取信息失败"
  5246. br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModel,Err:" + err.Error()
  5247. return
  5248. }
  5249. } else {
  5250. historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(conditionArtcile, pars)
  5251. if err != nil {
  5252. br.Msg = "获取信息失败"
  5253. br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
  5254. return
  5255. }
  5256. //获取参会总数
  5257. activityNum, err = cygx.GetActivityMeetByCompanyCountWeekly(conditionActivityMeet)
  5258. if err != nil {
  5259. br.Msg = "获取信息失败"
  5260. br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
  5261. return
  5262. }
  5263. //获取用户收藏记录总数
  5264. articleCollect, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(conditionArtcile)
  5265. if err != nil {
  5266. br.Msg = "获取信息失败"
  5267. br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
  5268. return
  5269. }
  5270. //获取用户关注总数
  5271. industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(conditionIndustryFllow)
  5272. if err != nil {
  5273. br.Msg = "获取信息失败 "
  5274. br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
  5275. return
  5276. }
  5277. //获取关注作者总数
  5278. departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
  5279. if err != nil {
  5280. br.Msg = "获取信息失败"
  5281. br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
  5282. return
  5283. }
  5284. //获取搜索记录
  5285. keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(conditionKeyWord)
  5286. if err != nil {
  5287. br.Msg = "获取信息失败"
  5288. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5289. return
  5290. }
  5291. chartNum, err = cygx.GetChartCountByUserMobileWeekly(condition)
  5292. if err != nil {
  5293. br.Msg = "获取信息失败"
  5294. br.ErrMsg = "获取总数失败,Err:" + err.Error()
  5295. return
  5296. }
  5297. triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
  5298. if err != nil {
  5299. br.Msg = "获取信息失败"
  5300. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5301. return
  5302. }
  5303. roadshowTotal, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
  5304. if err != nil {
  5305. br.Msg = "获取信息失败"
  5306. br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
  5307. return
  5308. }
  5309. tagNum, err = cygx.GetCygxTagHistoryCountWeekly(condition)
  5310. if err != nil {
  5311. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5312. br.Msg = "获取搜索记录失败"
  5313. return
  5314. }
  5315. yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCountWeekly(condition, pars)
  5316. if err != nil {
  5317. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5318. br.Msg = "获取研选专栏阅读数量失败"
  5319. return
  5320. }
  5321. yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCountWeekly(condition, pars)
  5322. if err != nil {
  5323. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5324. br.Msg = "获取收藏的专栏文章数量失败"
  5325. return
  5326. }
  5327. yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCountWeekly(condition, pars)
  5328. if err != nil {
  5329. br.Msg = "获取关注的专栏作者数量失败"
  5330. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5331. return
  5332. }
  5333. feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModelWeekly(condition, pars)
  5334. if err != nil {
  5335. br.Msg = "获取交流反馈数量失败"
  5336. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5337. return
  5338. }
  5339. calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModelWeekly(condition, pars)
  5340. if err != nil {
  5341. br.Msg = "获取信息失败"
  5342. br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModelWeekly,Err:" + err.Error()
  5343. return
  5344. }
  5345. }
  5346. if classType == 1 {
  5347. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
  5348. {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
  5349. {PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
  5350. {PermissionName: "1v1路演", Source: 15, TotalNum: calendarMeetingNum},
  5351. {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
  5352. {PermissionName: "收藏图表", Source: 4, TotalNum: chartNum},
  5353. {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
  5354. {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
  5355. {PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
  5356. {PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum},
  5357. {PermissionName: "交流反馈", Source: 14, TotalNum: feedbackNum}}
  5358. resp.List = List
  5359. } else {
  5360. List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
  5361. {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
  5362. {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
  5363. {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
  5364. {PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
  5365. {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: yanxuanSpecialNum},
  5366. {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: yanxuanSpecialCollectNum},
  5367. {PermissionName: "关注的专栏作者", Source: 13, TotalNum: yanxuanSpecialFollowNum},
  5368. {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum}}
  5369. resp.List = List
  5370. }
  5371. br.Ret = 200
  5372. br.Success = true
  5373. br.Msg = "获取成功"
  5374. br.Data = resp
  5375. }
  5376. // @Title 添加/取消用户提醒
  5377. // @Description 添加/取消用户提醒
  5378. // @Param request body cygx.UserRemarAddReq true "type json string"
  5379. // @Success 200 新增成功
  5380. // @router /user/remind [post]
  5381. func (this *UserController) UserRemind() {
  5382. br := new(models.BaseResponse).Init()
  5383. defer func() {
  5384. this.Data["json"] = br
  5385. this.ServeJSON()
  5386. }()
  5387. sysUser := this.SysUser
  5388. if sysUser == nil {
  5389. br.Msg = "请登录"
  5390. br.ErrMsg = "请登录,SysUser Is Empty"
  5391. br.Ret = 408
  5392. return
  5393. }
  5394. var req cygx.UserRemarAddReq
  5395. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  5396. if err != nil {
  5397. br.Msg = "参数解析异常!"
  5398. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  5399. return
  5400. }
  5401. userId := req.UserId
  5402. sourceType := req.SourceType
  5403. doType := req.DoType
  5404. wxUser, err := cygx.GetUserAndCompanyNameList(userId)
  5405. if err != nil {
  5406. br.Msg = "设置互动提醒失败"
  5407. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  5408. return
  5409. }
  5410. if sourceType != 1 && sourceType != 2 {
  5411. br.Msg = "设置互动提醒失败"
  5412. br.ErrMsg = "设置互动提醒失败,sourceType:" + strconv.Itoa(sourceType)
  5413. return
  5414. }
  5415. if doType != 1 && doType != 2 {
  5416. br.Msg = "设置互动提醒失败"
  5417. br.ErrMsg = "设置互动提醒失败,doType:" + strconv.Itoa(doType)
  5418. return
  5419. }
  5420. count, err := cygx.GetCygxUserRemindCount(userId)
  5421. if err != nil {
  5422. br.Msg = "获取数据失败!"
  5423. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  5424. return
  5425. }
  5426. resp := new(cygx.CygxUserRemindResp)
  5427. if count <= 0 {
  5428. var items []*cygx.CygxUserRemind
  5429. if sourceType == 1 {
  5430. item := new(cygx.CygxUserRemind)
  5431. item.AdminId = sysUser.AdminId
  5432. item.AdminName = sysUser.RealName
  5433. item.UserId = userId
  5434. item.Mobile = wxUser.Mobile
  5435. item.Email = wxUser.Email
  5436. item.CompanyId = wxUser.CompanyId
  5437. item.CompanyName = wxUser.CompanyName
  5438. item.RealName = wxUser.RealName
  5439. item.CreateTime = time.Now()
  5440. item.ModifyTime = time.Now()
  5441. items = append(items, item)
  5442. } else {
  5443. //获取机构下所有的用户
  5444. listUser, err := models.GetWxUserListCompanyId(wxUser.CompanyId)
  5445. if err != nil {
  5446. br.Msg = "获取数据失败!"
  5447. br.ErrMsg = "获取数据失败,GetWxUserListCompanyId Err:" + err.Error()
  5448. return
  5449. }
  5450. //获取已经添加消息提醒的
  5451. listUserRemind, err := cygx.GetCygxUserRemindListByCompanyId(wxUser.CompanyId)
  5452. if err != nil {
  5453. br.Msg = "获取数据失败!"
  5454. br.ErrMsg = "获取数据失败,GetCygxUserRemindListByCompanyId Err:" + err.Error()
  5455. return
  5456. }
  5457. mapUserRemind := make(map[int]bool)
  5458. for _, v := range listUserRemind {
  5459. mapUserRemind[v.UserId] = true
  5460. }
  5461. for _, v := range listUser {
  5462. //如果已经添加了提醒的用户就不做添加处理
  5463. if mapUserRemind[v.UserId] {
  5464. continue
  5465. }
  5466. item := new(cygx.CygxUserRemind)
  5467. item.AdminId = sysUser.AdminId
  5468. item.AdminName = sysUser.RealName
  5469. item.UserId = v.UserId
  5470. item.Mobile = v.Mobile
  5471. item.Email = v.Email
  5472. item.CompanyId = v.CompanyId
  5473. item.CompanyName = v.CompanyName
  5474. item.RealName = v.RealName
  5475. item.CreateTime = time.Now()
  5476. item.ModifyTime = time.Now()
  5477. items = append(items, item)
  5478. }
  5479. }
  5480. //批量加入
  5481. err = cygx.AddCygxUserRemindMulti(items)
  5482. if err != nil {
  5483. br.Msg = "添加失败"
  5484. br.ErrMsg = "添加失败,Err:" + err.Error()
  5485. return
  5486. }
  5487. br.Msg = "收藏成功"
  5488. resp.Status = 1
  5489. } else {
  5490. if sourceType == 1 {
  5491. err = cygx.RemoveCygxUserRemind(userId) //取消个人提醒
  5492. } else {
  5493. err = cygx.RemoveCygxUserRemindByCompanyId(wxUser.CompanyId) //取消整个机构提醒
  5494. }
  5495. if err != nil {
  5496. br.Msg = "取消失败"
  5497. br.ErrMsg = "取消失败,Err:" + err.Error()
  5498. return
  5499. }
  5500. br.Msg = "已取消收藏"
  5501. resp.Status = 2
  5502. }
  5503. br.Ret = 200
  5504. br.Success = true
  5505. br.Data = resp
  5506. }
  5507. // exportListRsCalendar 1v1路演导出Excel
  5508. func exportListRsCalendar(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
  5509. dir, err := os.Executable()
  5510. exPath := filepath.Dir(dir)
  5511. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  5512. xlsxFile := xlsx.NewFile()
  5513. if err != nil {
  5514. br.Msg = "生成文件失败"
  5515. br.ErrMsg = "生成文件失败"
  5516. return
  5517. }
  5518. style := xlsx.NewStyle()
  5519. border := xlsx.NewBorder("thin", "thin", "thin", "thin")
  5520. alignment := xlsx.Alignment{
  5521. Horizontal: "center",
  5522. Vertical: "center",
  5523. WrapText: true,
  5524. }
  5525. redStyle := xlsx.NewStyle()
  5526. redStyle.Alignment = alignment
  5527. redStyle.ApplyAlignment = true
  5528. redStyle.Font.Color = "ff0000"
  5529. redStyle.Border = *border
  5530. style.Alignment = alignment
  5531. style.ApplyAlignment = true
  5532. sheel, err := xlsxFile.AddSheet("1V1路演")
  5533. if err != nil {
  5534. br.Msg = "新增Sheet失败"
  5535. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  5536. return
  5537. }
  5538. sheel.SetColWidth(0, 0, 30)
  5539. sheel.SetColWidth(1, 1, 15)
  5540. sheel.SetColWidth(2, 2, 15)
  5541. sheel.SetColWidth(3, 3, 18)
  5542. titleRow := sheel.AddRow()
  5543. if excelType > 2 {
  5544. cellA := titleRow.AddCell()
  5545. cellA.SetStyle(style)
  5546. cellA.SetValue("客户名称")
  5547. }
  5548. if excelType > 1 {
  5549. cellB := titleRow.AddCell()
  5550. cellB.SetStyle(style)
  5551. cellB.SetValue("姓名")
  5552. cellC := titleRow.AddCell()
  5553. cellC.SetStyle(style)
  5554. cellC.SetValue("手机号")
  5555. }
  5556. cellD := titleRow.AddCell()
  5557. cellD.SetStyle(style)
  5558. cellD.SetValue("路演时间")
  5559. cellE := titleRow.AddCell()
  5560. cellE.SetStyle(style)
  5561. cellE.SetValue("研究员")
  5562. cellF := titleRow.AddCell()
  5563. cellF.SetStyle(style)
  5564. cellF.SetValue("路演形式")
  5565. cellG := titleRow.AddCell()
  5566. cellG.SetStyle(style)
  5567. cellG.SetValue("主题标签")
  5568. for _, v := range list {
  5569. dataRow := sheel.AddRow()
  5570. dataRow.SetHeight(20)
  5571. if excelType > 2 {
  5572. cellAData := dataRow.AddCell()
  5573. cellAData.SetStyle(style)
  5574. cellAData.Value = v.CompanyName
  5575. }
  5576. if excelType > 1 {
  5577. cellBData := dataRow.AddCell()
  5578. cellBData.SetStyle(style)
  5579. cellBData.Value = v.RealName
  5580. cellCData := dataRow.AddCell()
  5581. cellCData.SetStyle(style)
  5582. cellCData.Value = v.Mobile
  5583. }
  5584. cellDData := dataRow.AddCell()
  5585. cellDData.SetStyle(style)
  5586. cellDData.Value = v.ActivityTimeText
  5587. cellEData := dataRow.AddCell()
  5588. cellEData.SetStyle(style)
  5589. cellEData.Value = v.ResearcherName
  5590. cellFData := dataRow.AddCell()
  5591. cellFData.SetStyle(style)
  5592. if v.ActivityType == 1 {
  5593. cellFData.Value = "线上"
  5594. } else {
  5595. cellFData.Value = "线下"
  5596. }
  5597. cellGData := dataRow.AddCell()
  5598. cellGData.SetStyle(style)
  5599. cellGData.Value = v.LabelKeyWord
  5600. }
  5601. err = xlsxFile.Save(downLoadnFilePath)
  5602. if err != nil {
  5603. br.Msg = "保存文件失败"
  5604. br.ErrMsg = "保存文件失败"
  5605. return
  5606. }
  5607. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  5608. downloadFileName := "1V1路演导出数据_" + randStr + ".xlsx"
  5609. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  5610. defer func() {
  5611. os.Remove(downLoadnFilePath)
  5612. }()
  5613. br.Ret = 200
  5614. br.Success = true
  5615. br.Msg = "导出成功"
  5616. }
  5617. // exportListArticle 文章阅读数据导出
  5618. func exportListArticle(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
  5619. //创建excel
  5620. dir, err := os.Executable()
  5621. exPath := filepath.Dir(dir)
  5622. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  5623. xlsxFile := xlsx.NewFile()
  5624. if err != nil {
  5625. br.Msg = "生成文件失败"
  5626. br.ErrMsg = "生成文件失败"
  5627. return
  5628. }
  5629. style := xlsx.NewStyle()
  5630. alignment := xlsx.Alignment{
  5631. Horizontal: "center",
  5632. Vertical: "center",
  5633. WrapText: true,
  5634. }
  5635. style.Alignment = alignment
  5636. style.ApplyAlignment = true
  5637. sheet, err := xlsxFile.AddSheet("报告阅读列表")
  5638. if err != nil {
  5639. br.Msg = "新增Sheet失败"
  5640. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  5641. return
  5642. }
  5643. //标头
  5644. rowTitle := sheet.AddRow()
  5645. if excelType > 2 {
  5646. cellA := rowTitle.AddCell()
  5647. cellA.Value = "客户名称"
  5648. cellB := rowTitle.AddCell()
  5649. cellB.Value = "所属销售"
  5650. }
  5651. if excelType > 1 {
  5652. cellC := rowTitle.AddCell()
  5653. cellC.Value = "姓名"
  5654. cellD := rowTitle.AddCell()
  5655. cellD.Value = "手机号"
  5656. }
  5657. cellE := rowTitle.AddCell()
  5658. cellE.Value = "报告标题"
  5659. cellF := rowTitle.AddCell()
  5660. cellF.Value = "所属行业"
  5661. cellG := rowTitle.AddCell()
  5662. cellG.Value = "所属产业"
  5663. cellH := rowTitle.AddCell()
  5664. cellH.Value = "关联标的"
  5665. cellI := rowTitle.AddCell()
  5666. cellI.Value = "发布时间"
  5667. cellJ := rowTitle.AddCell()
  5668. cellJ.Value = "阅读时间"
  5669. cellK := rowTitle.AddCell()
  5670. cellK.Value = "阅读时长"
  5671. for _, item := range list {
  5672. row := sheet.AddRow()
  5673. if excelType > 2 {
  5674. cellA := row.AddCell()
  5675. cellA.Value = item.CompanyName
  5676. cellB := row.AddCell()
  5677. cellB.Value = item.SellerName
  5678. }
  5679. if excelType > 1 {
  5680. cellC := row.AddCell()
  5681. cellC.Value = item.RealName
  5682. cellD := row.AddCell()
  5683. cellD.Value = item.Mobile
  5684. }
  5685. cellEData := row.AddCell()
  5686. cellEData.Value = item.Title
  5687. cellFData := row.AddCell()
  5688. cellFData.Value = item.PermissionName
  5689. cellGData := row.AddCell()
  5690. cellGData.Value = item.IndustryName
  5691. cellHData := row.AddCell()
  5692. cellHData.Value = item.SubjectNameStr
  5693. cellIData := row.AddCell()
  5694. cellIData.Value = item.PublishDate
  5695. cellJData := row.AddCell()
  5696. cellJData.Value = item.CreateTime
  5697. cellKData := row.AddCell()
  5698. cellKData.Value = item.StopTime
  5699. }
  5700. err = xlsxFile.Save(downLoadnFilePath)
  5701. if err != nil {
  5702. br.Msg = "保存文件失败"
  5703. br.ErrMsg = "保存文件失败"
  5704. return
  5705. }
  5706. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  5707. downloadFileName := "报告阅读列表导出数据_" + randStr + ".xlsx"
  5708. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  5709. defer func() {
  5710. os.Remove(downLoadnFilePath)
  5711. }()
  5712. br.Ret = 200
  5713. br.Success = true
  5714. br.Msg = "导出成功"
  5715. }
  5716. // exportListArticle 文章阅读数据导出
  5717. func exportListActivity(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
  5718. //创建excel
  5719. dir, err := os.Executable()
  5720. exPath := filepath.Dir(dir)
  5721. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  5722. xlsxFile := xlsx.NewFile()
  5723. if err != nil {
  5724. br.Msg = "生成文件失败"
  5725. br.ErrMsg = "生成文件失败"
  5726. return
  5727. }
  5728. style := xlsx.NewStyle()
  5729. alignment := xlsx.Alignment{
  5730. Horizontal: "center",
  5731. Vertical: "center",
  5732. WrapText: true,
  5733. }
  5734. style.Alignment = alignment
  5735. style.ApplyAlignment = true
  5736. sheet, err := xlsxFile.AddSheet("客户参会记录")
  5737. if err != nil {
  5738. br.Msg = "新增Sheet失败"
  5739. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  5740. return
  5741. }
  5742. //标头
  5743. rowTitle := sheet.AddRow()
  5744. if excelType > 2 {
  5745. cellA := rowTitle.AddCell()
  5746. cellA.Value = "客户名称"
  5747. cellB := rowTitle.AddCell()
  5748. cellB.Value = "所属销售"
  5749. }
  5750. if excelType > 1 {
  5751. cellC := rowTitle.AddCell()
  5752. cellC.Value = "姓名"
  5753. cellD := rowTitle.AddCell()
  5754. cellD.Value = "手机号"
  5755. }
  5756. cellE := rowTitle.AddCell()
  5757. cellE.Value = "活动名称"
  5758. cellF := rowTitle.AddCell()
  5759. cellF.Value = "所属行业"
  5760. cellG := rowTitle.AddCell()
  5761. cellG.Value = "活动类型"
  5762. cellH := rowTitle.AddCell()
  5763. cellH.Value = "活动主题"
  5764. cellI := rowTitle.AddCell()
  5765. cellI.Value = "活动时间"
  5766. cellJ := rowTitle.AddCell()
  5767. cellJ.Value = "是否到会"
  5768. cellK := rowTitle.AddCell()
  5769. cellK.Value = "首次入会时间"
  5770. cellL := rowTitle.AddCell()
  5771. cellL.Value = "最后退出时间"
  5772. cellM := rowTitle.AddCell()
  5773. cellM.Value = "参与总时长"
  5774. cellN := rowTitle.AddCell()
  5775. cellN.Value = "参会方式"
  5776. cellO := rowTitle.AddCell()
  5777. cellO.Value = "参会权鉴"
  5778. cellP := rowTitle.AddCell()
  5779. cellP.Value = "参会状态"
  5780. for _, item := range list {
  5781. row := sheet.AddRow()
  5782. if excelType > 2 {
  5783. cellAData := row.AddCell()
  5784. cellAData.Value = item.CompanyName
  5785. cellBData := row.AddCell()
  5786. cellBData.Value = item.SellerName
  5787. }
  5788. if excelType > 1 {
  5789. cellCData := row.AddCell()
  5790. cellCData.Value = item.RealName
  5791. cellDData := row.AddCell()
  5792. cellDData.Value = item.Mobile
  5793. }
  5794. cellEData := row.AddCell()
  5795. cellEData.Value = item.ActivityName
  5796. cellFData := row.AddCell()
  5797. cellFData.Value = item.PermissionName
  5798. cellGData := row.AddCell()
  5799. cellGData.Value = item.ActivityTypeName
  5800. cellHData := row.AddCell()
  5801. cellHData.Value = item.Label
  5802. cellIData := row.AddCell()
  5803. cellIData.Value = item.ActivityTime
  5804. cellJData := row.AddCell()
  5805. if item.IsMeeting == 1 {
  5806. cellJData.Value = "到会"
  5807. } else {
  5808. cellJData.Value = "未到会"
  5809. }
  5810. cellKData := row.AddCell()
  5811. cellKData.Value = item.FirstMeetingTime
  5812. cellLData := row.AddCell()
  5813. cellLData.Value = item.LastMeetingTime
  5814. cellMData := row.AddCell()
  5815. cellMData.Value = item.Duration
  5816. cellNData := row.AddCell()
  5817. cellNData.Value = item.LastMeetingTime
  5818. cellOData := row.AddCell()
  5819. cellOData.Value = item.MeetingTypeStr
  5820. cellPData := row.AddCell()
  5821. cellPData.Value = item.MeetingStatusStr
  5822. }
  5823. err = xlsxFile.Save(downLoadnFilePath)
  5824. if err != nil {
  5825. br.Msg = "保存文件失败"
  5826. br.ErrMsg = "保存文件失败"
  5827. return
  5828. }
  5829. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  5830. downloadFileName := "客户参会记录导出数据_" + randStr + ".xlsx"
  5831. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  5832. defer func() {
  5833. os.Remove(downLoadnFilePath)
  5834. }()
  5835. br.Ret = 200
  5836. br.Success = true
  5837. br.Msg = "导出成功"
  5838. }
  5839. // exportListYanxuanSpecial 研选专栏阅读记录
  5840. func exportListYanxuanSpecial(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
  5841. //创建excel
  5842. dir, err := os.Executable()
  5843. exPath := filepath.Dir(dir)
  5844. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  5845. xlsxFile := xlsx.NewFile()
  5846. if err != nil {
  5847. br.Msg = "生成文件失败"
  5848. br.ErrMsg = "生成文件失败"
  5849. return
  5850. }
  5851. style := xlsx.NewStyle()
  5852. alignment := xlsx.Alignment{
  5853. Horizontal: "center",
  5854. Vertical: "center",
  5855. WrapText: true,
  5856. }
  5857. style.Alignment = alignment
  5858. style.ApplyAlignment = true
  5859. sheet, err := xlsxFile.AddSheet("客户参会记录")
  5860. if err != nil {
  5861. br.Msg = "新增Sheet失败"
  5862. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  5863. return
  5864. }
  5865. //标头
  5866. rowTitle := sheet.AddRow()
  5867. if excelType > 2 {
  5868. cellAy := rowTitle.AddCell()
  5869. cellAy.Value = "客户名称"
  5870. cellBy := rowTitle.AddCell()
  5871. cellBy.Value = "所属销售"
  5872. }
  5873. if excelType > 1 {
  5874. cellC := rowTitle.AddCell()
  5875. cellC.Value = "姓名"
  5876. cellD := rowTitle.AddCell()
  5877. cellD.Value = "手机号"
  5878. }
  5879. cellA := rowTitle.AddCell()
  5880. cellA.Value = "文章标题"
  5881. cellB := rowTitle.AddCell()
  5882. cellB.Value = "文章类型"
  5883. cellC := rowTitle.AddCell()
  5884. cellC.Value = "标签"
  5885. cellD := rowTitle.AddCell()
  5886. cellD.Value = "发布时间"
  5887. cellE := rowTitle.AddCell()
  5888. cellE.Value = "阅读时间"
  5889. cellF := rowTitle.AddCell()
  5890. cellF.Value = "阅读时长"
  5891. cellG := rowTitle.AddCell()
  5892. cellG.Value = "阅读来源"
  5893. for _, item := range list {
  5894. row := sheet.AddRow()
  5895. if excelType > 2 {
  5896. cellADatay := row.AddCell()
  5897. cellADatay.Value = item.CompanyName
  5898. cellBDatay := row.AddCell()
  5899. cellBDatay.Value = item.SellerName
  5900. }
  5901. if excelType > 1 {
  5902. cellCData := row.AddCell()
  5903. cellCData.Value = item.RealName
  5904. cellDData := row.AddCell()
  5905. cellDData.Value = item.Mobile
  5906. }
  5907. cellAData := row.AddCell()
  5908. cellAData.Value = item.Title
  5909. cellBData := row.AddCell()
  5910. if item.SpecialType == 1 {
  5911. cellBData.Value = "笔记"
  5912. } else {
  5913. cellBData.Value = "观点"
  5914. }
  5915. cellCData := row.AddCell()
  5916. cellCData.Value = item.IndustryName
  5917. cellDData := row.AddCell()
  5918. cellDData.Value = item.PublishDate
  5919. cellEData := row.AddCell()
  5920. cellEData.Value = item.CreateTime
  5921. cellFData := row.AddCell()
  5922. cellFData.Value = item.StopTime
  5923. cellGData := row.AddCell()
  5924. cellGData.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
  5925. }
  5926. err = xlsxFile.Save(downLoadnFilePath)
  5927. if err != nil {
  5928. br.Msg = "保存文件失败"
  5929. br.ErrMsg = "保存文件失败"
  5930. return
  5931. }
  5932. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  5933. downloadFileName := "客户参会记录导出数据_" + randStr + ".xlsx"
  5934. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  5935. defer func() {
  5936. os.Remove(downLoadnFilePath)
  5937. }()
  5938. br.Ret = 200
  5939. br.Success = true
  5940. br.Msg = "导出成功"
  5941. }