user.go 201 KB

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