user.go 201 KB

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