user.go 202 KB

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