123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240 |
- package cygx
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "github.com/tealeg/xlsx"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/models/system"
- "hongze/hz_crm_api/services"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/utils"
- "os"
- "path/filepath"
- "sort"
- "strconv"
- "strings"
- "time"
- )
- // 权益用户管理
- type UserController struct {
- controllers.BaseAuthController
- }
- // List
- // @Title 用户列表
- // @Description 用户列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Status query string true "状态:”试用','永续','冻结','流失','正式'"
- // @Param IsMaker query int false "是否决策人,1:是,0:否 ,2:全部'"
- // @Param IsRegister query int false "是否决策人,1:是,0:否 ,2:全部'"
- // @Param AdminId query string true "销售id,多个用英文逗号隔开,空字符串为全部"
- // @Param KeyWord query string true "搜索关键词"
- // @Param Label query string true "搜索用户标签"
- // @Param TryStage query int false "试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备。正式:套餐类型,0:无,1:大套餐,2:小套餐"
- // @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
- // @Param IsSubscribeCygx query int true "是否关注了查研观向小助手公众号: -1-默认全部; 0-未关注; 1-已关注"
- // @Success 200 {object} cygx.CompanyUserListResp
- // @router /user/list [get]
- func (this *UserController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- isMaker, _ := this.GetInt("IsMaker")
- isRegister, _ := this.GetInt("IsRegister")
- status := this.GetString("Status")
- adminId := this.GetString("AdminId")
- keyWord := this.GetString("KeyWord")
- label := this.GetString("Label")
- tryStage, _ := this.GetInt("TryStage") //试用客户标签
- sortType := this.GetString("SortType") //试用客户标签
- // 套餐类型
- //packageType, _ := this.GetInt("PackageType")
- keyWord = strings.Trim(keyWord, " ")
- keyWord = strings.Replace(keyWord, "'", "", -1)
- isSubscribeCygx, _ := this.GetInt("IsSubscribeCygx", -1)
- if status == "X类试用" {
- status = "永续"
- }
- var total int
- page := paging.GetPaging(currentIndex, pageSize, total)
- //statusItems := make([]*company.CompanyStatus, 0)
- //var statusArr = [...]string{"全部", "试用", "正式", "冻结", "流失", "永续"}
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var sqlOrder string
- var usercondition string
- var kwywordcondition string
- var pars []interface{}
- var parsUser []interface{}
- //流失
- var lossCondition string
- //var lossPars []interface{}
- //状态分类查询条件
- //var permissionCondition string
- if adminId != "" {
- condition += ` AND b.seller_id IN (` + adminId + `) `
- }
- lossCondition = condition
- //lossPars = pars
- //permissionCondition = condition
- //流失客户统计
- lossCondition += ` AND status='流失' `
- if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER { //权益销售的查询逻辑
- condition += ` AND ( cp.seller_id = ` + strconv.Itoa(sysUser.AdminId) + ` OR cp.share_seller_id = ` + strconv.Itoa(sysUser.AdminId) + `)`
- } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP { // 权益销售组长查询逻辑
- adminList, err := system.GetAdminListByGroupId(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetAdminListByGroupIdErr:" + err.Error()
- return
- }
- var adminIds []string
- var companyIdsStr []string
- for _, v := range adminList {
- adminIds = append(adminIds, strconv.Itoa(v.AdminId))
- }
- //再获取组员下被共享的公司
- var parsShare []interface{}
- var conditionShare string
- conditionShare = " AND share_seller_id IN (" + strings.Join(adminIds, ",") + ") "
- listCompanyProduct, err := company.GetCompanyProductList(conditionShare, parsShare)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetCompanyProductList:" + err.Error()
- return
- }
- for _, v := range listCompanyProduct {
- companyIdsStr = append(companyIdsStr, strconv.Itoa(v.CompanyId))
- }
- companyIdsStr = append(companyIdsStr, "0")
- //本组的或者被分享到本组下面的公司
- condition += ` AND (cp.group_id = ` + strconv.Itoa(sysUser.GroupId) + ` OR cp.company_id IN (` + strings.Join(companyIdsStr, ",") + `) )`
- }
- //状态控制
- if status != "" && status != "全部" {
- condition += ` AND b.status= '` + status + `'`
- usercondition += ` AND cp.status= '` + status + `'`
- } else {
- condition += ` AND b.status IN ('正式','试用','冻结','永续') `
- }
- // 试用客户标签
- if (status == "试用" || status == "永续") && tryStage > 0 {
- condition += ` AND b.try_stage= '` + strconv.Itoa(tryStage) + `'`
- usercondition += ` AND cp.try_stage= '` + strconv.Itoa(tryStage) + `'`
- }
- //套餐类型 权益客户除了大套餐就是小套餐
- if status == "正式" && tryStage > 0 {
- if tryStage == 1 {
- condition += ` AND b.package_type= '` + strconv.Itoa(tryStage) + `'`
- usercondition += ` AND cp.package_type= '` + strconv.Itoa(tryStage) + `'`
- } else {
- condition += ` AND b.package_type!= 1 `
- usercondition += ` AND cp.package_type != 1 `
- }
- }
- if isMaker != 2 {
- if isMaker == 1 {
- usercondition += ` AND u.is_maker = 1 `
- } else {
- //部分脏数据
- usercondition += ` AND u.is_maker != 1 `
- }
- //parsUser = append(parsUser, isMaker)
- }
- if isRegister != 2 {
- if isRegister == 1 {
- usercondition += ` AND u.register_time IS NOT NULL`
- } else {
- //部分脏数据
- usercondition += ` AND u.register_time IS NULL`
- }
- //parsUser = append(parsUser, isRegister)
- }
- kwywordcondition = condition
- if keyWord != "" {
- companyIdStr, err := company.GetCompanyIdByKeyWord(keyWord)
- if err != nil {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- if companyIdStr != "" {
- condition += ` AND (a.company_name LIKE '%` + keyWord + `%' OR a.credit_code LIKE '%` + keyWord + `%' AND a.company_id IN(` + companyIdStr + `)) `
- } else {
- condition += ` AND (a.company_name LIKE '%` + keyWord + `%' OR a.credit_code LIKE '%` + keyWord + `%' ) `
- }
- }
- if label != "" {
- usercondition += ` AND u.user_label LIKE '%` + label + `%'`
- }
- //
- usercondition += ` AND cp.product_id = 2 AND sr.product_id = 2 `
- // 是否关注弘则研究公众号
- if isSubscribeCygx == 0 {
- usercondition += ` AND (u.cygx_subscribe = 0 OR ISNULL(u.cygx_subscribe)) `
- }
- if isSubscribeCygx == 1 {
- usercondition += ` AND u.cygx_subscribe = 1 `
- }
- condition += ` AND cp.product_id = 2 `
- total, err := cygx.GetCompanyListCount(usercondition, keyWord, kwywordcondition, condition, roleTypeCode, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
- return
- }
- if sortType == "" {
- sqlOrder = ` GROUP by u.user_id ORDER BY c.created_time DESC, u.register_time DESC `
- } else {
- if sortType == "asc" {
- sqlOrder = ` GROUP by u.user_id ORDER BY u.interaction_num ASC , u.register_time DESC `
- } else {
- sqlOrder = ` GROUP by u.user_id ORDER BY u.interaction_num DESC , u.register_time DESC `
- }
- }
- list, err := cygx.GetCygxCompanyUserList(usercondition, keyWord, kwywordcondition, condition, roleTypeCode, sqlOrder, parsUser, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- var userIds string
- var userIdArr []int
- var companyIds []int
- var mobilesSlice []string
- if list != nil {
- for k, v := range list {
- if v.RegisterTime != "" {
- list[k].IsRegister = true
- } else {
- list[k].IsRegister = false
- }
- if v.IsShowSeeNum > 0 {
- list[k].IsShowSee = true
- }
- if v.Status == "正式" {
- if v.PackageType == 1 {
- list[k].Status += "(大套餐)"
- } else {
- list[k].Status += "(小套餐)"
- }
- }
- if v.Status == "试用" {
- if v.TryStage == 1 {
- list[k].Status += "(未分类)"
- } else if v.TryStage == 2 {
- list[k].Status += "(推进)"
- } else if v.TryStage == 3 {
- list[k].Status += "(跟踪)"
- } else if v.TryStage == 4 {
- list[k].Status += "(预备)"
- }
- }
- if v.Status == "永续" {
- v.Status = "X类试用"
- }
- userIds += strconv.Itoa(int(v.UserId)) + ","
- userIdArr = append(userIdArr, int(v.UserId))
- if !isAdminRole {
- list[k].CompanyInteractionNum = v.CompanyInteractionNumSeller
- }
- companyIds = append(companyIds, v.CompanyId)
- if v.Mobile != "" {
- mobilesSlice = append(mobilesSlice, v.Mobile)
- }
- }
- userIds = strings.TrimRight(userIds, ",")
- splitList, err := cygx.GetCygxCompanyUserListSplit(userIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- //用户备注
- userRemarksList, err := cygx.GetUserRemarksListByUserIds(userIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- mapUserRemarks := make(map[int]string)
- for _, v := range userRemarksList {
- if mapUserRemarks[v.UserId] == "" {
- mapUserRemarks[v.UserId] = v.Content
- }
- }
- UserRemindListMap := cygxService.GetCygxUserRemindListMap(userIdArr)
- mapIsUserMaker := cygxService.GetCompanyProductIsUserMakerByCompanyIds(companyIds) //根据公司ID获取近四周之内有决策人互动的客户
- userHaveMoveMap := services.GetWxUserHaveMoveMap(mobilesSlice) // 处理用户是否移动过按钮回显
- for k, v := range list {
- for _, vsplit := range splitList {
- if vsplit.UserId == v.UserId {
- list[k].HistoryNum = vsplit.HistoryNum
- list[k].CountNum = vsplit.CountNum
- list[k].IndustryFllowNum = vsplit.IndustryFllowNum
- list[k].DepartmentFollowNum = vsplit.DepartmentFollowNum
- list[k].KeyWordNum = vsplit.KeyWordNum
- list[k].OnLineNum = vsplit.OnLineNum
- list[k].OfficeNum = vsplit.OfficeNum
- list[k].ChartNum = vsplit.ChartNum
- list[k].TripNum = vsplit.TripNum
- list[k].RoadshowVideoNum = vsplit.RoadshowVideoNum
- list[k].ActivityVideoNum = vsplit.ActivityVideoNum
- list[k].ActivityVoiceNum = vsplit.ActivityVoiceNum
- list[k].YanxuanspecialNum = vsplit.YanxuanspecialNum
- }
- }
- if mapUserRemarks[int(v.UserId)] != "" {
- list[k].Content = mapUserRemarks[int(v.UserId)]
- }
- list[k].IsRemind = UserRemindListMap[int(v.UserId)]
- list[k].IsUserMaker = mapIsUserMaker[v.CompanyId]
- if v.Mobile != "" {
- v.HaveMoveButton = userHaveMoveMap[v.Mobile]
- }
- }
- for k := range list {
- 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
- }
- } else {
- list = make([]*cygx.CygxCompanyUser, 0)
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp := new(cygx.CompanyUserListResp)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 新增备注接口
- // @Description 新增备注
- // @Param request body cygx.UserRemarAddReq true "type json string"
- // @Success 200 新增成功
- // @router /user/addRemarks [post]
- func (this *UserController) Add() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.UserRemarAddReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Content == "" {
- br.Msg = "请填写内容"
- return
- }
- item := new(cygx.UserRemarks)
- item.UserId = req.UserId
- item.AdminId = sysUser.AdminId
- item.Content = req.Content
- item.CreateTime = time.Now()
- err = cygx.AddUserRemarks(item)
- if err != nil {
- br.Msg = "新增失败."
- br.ErrMsg = "新增失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "新增成功"
- }
- // @Title 备注列表
- // @Description 备注列表接口
- // @Param UserId query int true "用户id"
- // @Success 200 {object} cygx.UserRemarksListResp
- // @router /user/remark/list [get]
- func (this *UserController) RemarkList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- list, err := cygx.GetUserRemarksList(userId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取备注信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.UserRemarksListResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 互动详情table栏
- // @Description 互动详情table栏接口
- // @Param UserId query int true "用户id"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.UserRemarksListResp
- // @router /user/table/list [get]
- func (this *UserController) TableList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- classType, _ := this.GetInt("ClassType", 1)
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取信息失败"
- return
- }
- comanyDetail, err := company.GetCompanyDetailById(wxUser.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxUserTableListRep)
- if classType == 1 {
- countDetail, err := cygx.GetUserInteractionTableCount(userId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
- return
- }
- calendarTotal, err := roadshow.GetRsCalendarMeetingUserCountByUserId(userId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetCygxUserFeedbackCountByUserId,Err:" + err.Error()
- return
- }
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: countDetail.HistoryNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: countDetail.OnLineNum + countDetail.OfficeNum},
- {PermissionName: "专项调研", Source: 8, TotalNum: countDetail.TripNum},
- {PermissionName: "1v1路演", Source: 15, TotalNum: calendarTotal},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: countDetail.CountNum},
- {PermissionName: "收藏的图表", Source: 4, TotalNum: countDetail.ChartNum},
- {PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum},
- {PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum},
- {PermissionName: "首页标签点击", Source: 10, TotalNum: countDetail.TagNum},
- {PermissionName: "交流反馈", Source: 14, TotalNum: countDetail.FeedbackNum}}
- resp.List = List
- } else {
- countDetail, err := cygx.GetUserInteractionTableCountByYanXuan(userId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
- return
- }
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: countDetail.HistoryNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: countDetail.OnLineNum + countDetail.OfficeNum},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: countDetail.CountNum},
- {PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
- {PermissionName: "关注的作者", Source: 6, TotalNum: countDetail.DepartmentFollowNum},
- {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: countDetail.YanxuanSpecialNum},
- {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: countDetail.YanxuanSpecialCollectNum},
- {PermissionName: "关注的专栏作者", Source: 13, TotalNum: countDetail.YanxuanSpecialFollowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum}}
- resp.List = List
- }
- //阅读记录总数
- resp.UserName = wxUser.RealName
- resp.Mobile = wxUser.Mobile
- resp.ComapnyName = comanyDetail.CompanyName
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 互动详情
- // @Description 互动详情接口
- // @Param UserId query int true "用户id"
- // @Param Source query int true "来源"
- // @Param IdentityType query int true "身份类型,1:用户,2机构。默认1 (图表分页使用)"
- // @Param IsMeeting query string true "是否到会 1到会、2未到会"
- // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param StartDate query string true "开始时间"
- // @Param EndDate query string true "结束时间"
- // @Param KeyWord query string true "搜索关键词"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Param IsExport query bool false "是否导出excel,默认是false"
- // @Success 200 {object} cygx.UserInteractionListResp
- // @router /user/interaction/detail [get]
- func (this *UserController) TableDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- userId, _ := this.GetInt("UserId")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- source, _ := this.GetInt("Source")
- identityType, _ := this.GetInt("IdentityType")
- classType, _ := this.GetInt("ClassType", 1)
- //是否导出报表
- isExport, _ := this.GetBool("IsExport")
- if isExport {
- pageSize = 10000
- currentIndex = 1
- }
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- // 1.标记用户表
- //操作权限校验
- var err error
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- mobile := wxUser.Mobile
- //var checkSource bool
- var MeetingNum int
- var NoMeetingNum int
- var list []*cygx.UserInteraction
- var total int
- var condition string
- var pars []interface{}
- if source == 1 {
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- //total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
- // return
- //}
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- total, list, err = cygx.GetCygxArticleHistoryRecordByUserNew(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- var articleIds string
- var articleIdArr []int
- if len(list) > 0 {
- articleIds = ""
- mapAricleId := make(map[int]int)
- mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if mapAricleId[v.ArticleId] == 0 {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- mapAricleId[v.ArticleId] = v.ArticleId
- }
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- articleIdArr = append(articleIdArr, v.ArticleId)
- }
- articleIds = strings.TrimRight(articleIds, ",")
- listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(listArticleIndustrialSubjectList) > 0 {
- for _, v := range listArticleIndustrialSubjectList {
- mapAricleIndustrialSubjectName[v.ArticleId] = v
- }
- for k, v := range list {
- if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
- list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName // 产业
- list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr // 标的
- }
- }
- }
- //行业
- mapPerssionName := cygxService.GetCygxArticlePerssionNameListMap(articleIdArr)
- for k, v := range list {
- if v.SpecialType > 0 {
- list[k].PermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
- } else {
- list[k].PermissionName = mapPerssionName[v.ArticleId]
- }
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- //导出excel
- if isExport {
- exportListArticle(this, list, 1, br)
- return
- }
- }
- } else if source == 2 {
- if mobile != "" {
- condition = ` AND s.mobile = '` + mobile + `' `
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isMeeting == "1" {
- condition += ` AND s.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND s.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if keyWord != "" {
- condition += ` AND a.activity_name LIKE '%` + keyWord + `%' `
- }
- total, err = cygx.GetActivityMeetByUserCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetActivityMeetByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += "会议提醒"
- }
- }
- if v.IsMeeting == 0 {
- list[k].FirstMeetingTime = ""
- list[k].LastMeetingTime = ""
- }
- if v.FirstMeetingTime == "0000-00-00 00:00:00" {
- list[k].FirstMeetingTime = ""
- list[k].LastMeetingTime = ""
- }
- }
- }
- }
- //导出excel
- if isExport {
- exportListActivity(this, list, 1, br)
- return
- }
- } else if source == 3 {
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- total, err = cygx.GetCygxArticleCollectCount(userId, condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxArticleCollectByUser(userId, startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- }
- } else if source == 4 {
- if identityType == 2 {
- condition += ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
- }
- condition += ` AND a.publish_status = 1 AND user_id = ` + strconv.Itoa(userId)
- var err error
- total, err = cygx.GetChartCountByUser(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetChartListCollectionWithCygx(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.PtagName != "" {
- list[k].CtagNamePc = v.PtagName
- }
- if v.CtagName != "" {
- list[k].CtagNamePc += "," + v.CtagName
- }
- if v.PtagNameTwo != "" {
- list[k].CtagNamePc += "," + v.PtagNameTwo
- }
- if v.CtagNameTwo != "" {
- list[k].CtagNamePc += "," + v.CtagNameTwo
- }
- }
- } else if source == 5 {
- if classType == 1 {
- condition += " AND a.chart_permission_id = 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- total, err = cygx.GetCygxIndustryFllowCount(userId, condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- list, err = cygx.GetCygxIndustryFllowByUser(userId, startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- } else if source == 6 {
- total, err = cygx.GetCygArticleDepartmentFollowCount(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者总数失败"
- return
- }
- list, err = cygx.GetCygArticleDepartmentFollowByUser(userId, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者列表失败"
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- var condition string
- var pars []interface{}
- condition += ` WHERE art.source = 1 AND art.is_summary = 1 AND art.department_id = ` + strconv.Itoa(v.DepartmentId)
- listArt, errList := cygx.GetSummaryManageList(condition, pars, 0, 20)
- if errList != nil && errList.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- if len(listArt) > 0 {
- mapIndustryName := make(map[string]string)
- mapSubjectName := make(map[string]string)
- var articleIdStr string
- for _, vArt := range listArt {
- if vArt.IndustryName != "" && mapIndustryName[vArt.IndustryName] == "" {
- list[k].IndustryName += vArt.IndustryName + "/"
- mapIndustryName[vArt.IndustryName] = vArt.IndustryName
- }
- articleIdStr += strconv.Itoa(vArt.ArticleId) + ","
- }
- list[k].IndustryName = strings.TrimRight(list[k].IndustryName, "/")
- articleIdStr = strings.TrimRight(articleIdStr, ",")
- listSubject, err := cygx.GetArticleSubjectList(articleIdStr)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if len(listSubject) > 0 {
- for _, vSub := range listSubject {
- if vSub.SubjectName != "" && mapSubjectName[vSub.SubjectName] == "" {
- list[k].SubjectNameStr += vSub.SubjectName + "/"
- mapSubjectName[vSub.SubjectName] = vSub.SubjectName
- }
- }
- list[k].SubjectNameStr = strings.TrimRight(list[k].SubjectNameStr, "/")
- }
- }
- }
- }
- } else if source == 7 {
- if classType == 1 {
- condition += " AND register_platform IN (1,2) "
- } else {
- condition += " AND register_platform IN (5,6) "
- }
- total, err = cygx.GetCygxSearchKeyWordCount(userId, condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxSearchKeyWordByUser(condition, userId, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else if source == 8 {
- condition += ` AND h.user_id = ? `
- pars = append(pars, userId)
- total, err = cygx.GetCygxActivitySpecialTripCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxActivitySpecialTripByUser(userId, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else if source == 9 {
- total, err = cygx.GetCygxRoadshowCount(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxRoadshowByUser(userId, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else if source == 10 { //标签点击记录
- total, err = cygx.GetCygxTagHistoryCountByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxTagHistoryByUserId(userId, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else if source == 11 { //专栏文章阅读记录
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- //导出excel
- if isExport {
- exportListYanxuanSpecial(this, list, 1, br)
- return
- }
- } else if source == 12 { //收藏的专栏文章
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- } else if source == 13 { //关注的专栏作者
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
- }
- }
- } else if source == 14 { //交流反馈
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else if source == 15 { //1V1路演
- if startDate != "" {
- condition += ` AND b.start_date >= '` + startDate + `' `
- }
- if endDate != "" {
- condition += ` AND b.start_date <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- totalRsCalendar, listRsCalendar, err := roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,GetRsCalendarMeetingUserByRai Err:" + err.Error()
- return
- }
- total = totalRsCalendar
- list, err = cygxService.HandleListRsCalendar(listRsCalendar)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
- return
- }
- //导出excel
- if isExport {
- exportListRsCalendar(this, list, 1, br)
- return
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(cygx.UserInteractionListResp)
- if len(list) == 0 {
- list = make([]*cygx.UserInteraction, 0)
- }
- resp.MeetingNum = MeetingNum
- resp.NoMeetingNum = NoMeetingNum
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取用户标签详情
- // @Description 获取用户标签详情接口
- // @Param UserId query int true "用户id"
- // @Success 200 {object} cygx.UserLabel
- // @router /user/label/detail [get]
- func (this *UserController) LabelDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取信息失败"
- return
- }
- if userId > 0 {
- resp := new(cygx.UserLabel)
- resp.Label = wxUser.UserLabel
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- list, err := cygx.GetCygxCompanyUserListSplit(strconv.Itoa(userId))
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- mapLabels := make(map[string]string)
- var labelsListStr []*cygx.UserLabel
- mapActivityLabels := make(map[string]string)
- for k := range list {
- labels := list[k].Labels
- labelsList := strings.Split(labels, ",")
- for _, vL := range labelsList {
- if mapLabels[vL] == "" && vL != "" {
- mapLabels[vL] = vL
- item := new(cygx.UserLabel)
- item.Label = vL
- labelsListStr = append(labelsListStr, item)
- }
- }
- }
- dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
- listArticlePv, err := cygx.GetArticlePvCount(wxUser.Mobile, wxUser.Email, dateTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var articleIds string
- mapArticleIdLabelTotal := make(map[string]int)
- mapArticleIdPv := make(map[int]int)
- if len(listArticlePv) > 0 {
- for _, v := range listArticlePv {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- mapArticleIdPv[v.ArticleId] = v.Pv
- }
- articleIds = strings.TrimRight(articleIds, ",")
- //产业、标的标签
- listLabelName, err := cygx.GetArticleGroupyIndustryName(articleIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if len(listLabelName) > 0 {
- for _, v := range listLabelName {
- labelsIndustryList := strings.Split(v.IndustryName, "/")
- labelsSubjectList := strings.Split(v.SubjectName, "/")
- //添加产业统计
- if len(labelsIndustryList) > 0 {
- for _, vIn := range labelsIndustryList {
- if mapActivityLabels[vIn] != "" {
- mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
- } else {
- mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
- mapActivityLabels[vIn] = vIn
- }
- }
- }
- if len(labelsSubjectList) > 0 {
- //添加标的统计
- for _, vIn := range labelsSubjectList {
- if mapActivityLabels[vIn] != "" {
- mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
- } else {
- mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
- mapActivityLabels[vIn] = vIn
- }
- }
- }
- }
- }
- }
- articleIds, err = cygx.GetCygxArticleCollectId(userId, dateTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户搜藏记录失败"
- return
- }
- if articleIds != "" {
- //产业、标的标签
- listLabelName, err := cygx.GetArticleGroupyIndustryName(articleIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if len(listLabelName) > 0 {
- for _, v := range listLabelName {
- labelsIndustryList := strings.Split(v.IndustryName, "/")
- labelsSubjectList := strings.Split(v.SubjectName, "/")
- //添加产业统计
- if len(labelsIndustryList) > 0 {
- for _, vIn := range labelsIndustryList {
- if mapActivityLabels[vIn] != "" {
- mapArticleIdLabelTotal[vIn] += 1
- } else {
- mapArticleIdLabelTotal[vIn] = 1
- mapActivityLabels[vIn] = vIn
- }
- }
- }
- if len(labelsSubjectList) > 0 {
- //添加标的统计
- for _, vIn := range labelsSubjectList {
- if mapActivityLabels[vIn] != "" {
- mapArticleIdLabelTotal[vIn] += 1
- } else {
- mapArticleIdLabelTotal[vIn] = 1
- mapActivityLabels[vIn] = vIn
- }
- }
- }
- }
- }
- }
- //活动标签计算
- listActivityPv, err := cygx.GetActivitySignCount(wxUser.Mobile, dateTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if len(listActivityPv) > 0 {
- for _, v := range listActivityPv {
- labelsList := strings.Split(v.Label, "-")
- for _, v2 := range labelsList {
- labelsListSon := strings.Split(v2, "/")
- for _, v3 := range labelsListSon {
- if mapActivityLabels[v3] != "" {
- mapArticleIdLabelTotal[v3] += 1
- } else {
- mapArticleIdLabelTotal[v3] = 1
- mapActivityLabels[v3] = v3
- }
- }
- }
- }
- }
- //会议提醒部分标签
- listActivityPvByReminder, err := cygx.GetActivityMeetingReminder(wxUser.Mobile, dateTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if len(listActivityPvByReminder) > 0 {
- for _, v := range listActivityPvByReminder {
- labelsList := strings.Split(v.Label, "-")
- for _, v2 := range labelsList {
- labelsListSon := strings.Split(v2, "/")
- for _, v3 := range labelsListSon {
- if mapActivityLabels[v3] != "" {
- mapArticleIdLabelTotal[v3] += 1
- } else {
- mapArticleIdLabelTotal[v3] = 1
- mapActivityLabels[v3] = v3
- }
- }
- }
- }
- }
- //对标签数量进行排序
- type KvPair struct {
- Key string
- Val int
- }
- tmpList := make([]KvPair, 0)
- for k, v := range mapArticleIdLabelTotal {
- tmpList = append(tmpList, KvPair{Key: k, Val: v})
- }
- sort.Slice(tmpList, func(i, j int) bool {
- return tmpList[i].Val > tmpList[j].Val // 降序
- })
- for _, v := range tmpList {
- if v.Key != "" {
- mapLabels[v.Key] = v.Key
- item := new(cygx.UserLabel)
- item.Label = v.Key
- labelsListStr = append(labelsListStr, item)
- }
- }
- var labelNew string
- for _, v := range labelsListStr {
- labelNew += v.Label + ","
- }
- labelNew = strings.TrimRight(labelNew, ",")
- resp := new(cygx.UserLabel)
- resp.Label = labelNew
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 状态搜索栏
- // @Description 状态搜索栏接口
- // @Success 200 {object} cygx.CygxUserTableStatusListRep
- // @router /user/status/table [get]
- func (this *UserController) StatusTable() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- listType := []*cygx.CygxTryStageRep{{Name: "大套餐", TryStage: 1}, {Name: "小套餐", TryStage: 2}}
- listStatus := []*cygx.CygxTryStageRep{{Name: "未分类", TryStage: 1}, {Name: "推进", TryStage: 2}, {Name: "跟踪", TryStage: 3}, {Name: "预备", TryStage: 4}}
- List := []*cygx.CygxUserTableStatusRep{{Name: "正式", List: listType, TryStage: "正式"}, {Name: "试用", List: listStatus, TryStage: "试用"}, {Name: "冻结", List: []*cygx.CygxTryStageRep{}, TryStage: "冻结"}, {Name: "X类试用", List: []*cygx.CygxTryStageRep{}, TryStage: "X类试用"}}
- resp := new(cygx.CygxUserTableStatusListRep)
- resp.List = List
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 用户互动量
- // @Description 状态搜索栏接口
- // @Param UserId query int true "用户id"
- // @Success 200 {object} cygx.CygxUserTableStatusListRep
- // @router /user/interactionNum [get]
- func (this *UserController) InteractionNum() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取信息失败"
- return
- }
- cp, err := company.GetCompanyProductByCompanyIdAndProductId(wxUser.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取客户信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxCygxInteractionNumRespListResp)
- for i := 0; i < 4; i++ {
- item := new(cygx.CygxInteractionNumResp)
- if cp != nil && cp.Status == "正式" {
- //阅读记录总数
- var startDate, endDate string
- item.DateTime = time.Now().AddDate(0, -i, 0).Format("2006.01")
- startDate = utils.GetOneMonthFirstDay(time.Now().AddDate(0, -i, 0)).Format(utils.FormatDate)
- endDate = utils.GetOneMonthLastDay(time.Now().AddDate(0, -i, 0)).Format(utils.FormatDate)
- countDetail, err := cygx.GetCompanyInteractionTableCountBytime(wxUser.CompanyId, startDate, endDate)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
- return
- }
- item.InteractionNum = countDetail.HistoryNum + countDetail.CountNum + countDetail.IndustryFllowNum + countDetail.DepartmentFollowNum + countDetail.KeyWordNum + countDetail.OnLineNum + countDetail.OfficeNum + countDetail.ChartNum
- } else {
- var weekStr string
- switch i {
- case 0:
- weekStr = "本周("
- case 1:
- weekStr = "上周("
- case 2:
- weekStr = "上两周("
- case 3:
- weekStr = "上三周("
- }
- item.DateTime = weekStr + utils.GetNowWeekMonday().AddDate(0, 0, -i*7).Format("01.02") + "~" + utils.GetNowWeekMonday().AddDate(0, 0, -i*7+6).Format("01.02") + ")"
- var startDate, endDate string
- startDate = utils.GetNowWeekMonday().AddDate(0, 0, -i*7).Format(utils.FormatDate)
- endDate = utils.GetNowWeekMonday().AddDate(0, 0, -i*7+6).Format(utils.FormatDate)
- countDetail, err := cygx.GetCompanyInteractionTableCountBytime(wxUser.CompanyId, startDate, endDate)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取各个阅读总数失败,Err:" + err.Error()
- return
- }
- 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
- }
- resp.List = append(resp.List, item)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 标签检索用户相关互动
- // @Description 标签检索用户相关互动接口
- // @Param UserId query int true "用户id"
- // @Param KeyWord query string true "搜索关键词"
- // @Param Source query int true "来源 1:报告阅读,2:报告收藏,3:相关活动,4:专项产业调研"
- // @Success 200 {object} cygx.UserInteractionrelevantListResp
- // @router /user/interaction/relevant [get]
- func (this *UserController) InteractionRelevant() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- source, _ := this.GetInt("Source")
- keyWord := this.GetString("KeyWord")
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取信息失败"
- return
- }
- managementIds, err := cygx.GetManagementIdsByName(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
- return
- }
- subjectIds, err := cygx.GetIndustrialSubjectIdsByName(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.UserInteractionrelevantListResp)
- var condition string
- if source == 1 || source == 2 {
- var articleIds string
- if managementIds != "" || subjectIds != "" {
- var articleIdmanagement string
- var articleIdsubject string
- if managementIds != "" {
- articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- }
- if subjectIds != "" {
- articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- }
- if articleIdmanagement != "" && articleIdsubject != "" {
- articleIds = articleIdmanagement + "," + articleIdsubject
- } else if articleIdmanagement != "" && articleIdsubject == "" {
- articleIds = articleIdmanagement
- } else if articleIdmanagement == "" && articleIdsubject != "" {
- articleIds = articleIdsubject
- }
- } else {
- matchDetail, err := cygx.GetCygxReportMappingCygxDetailByName(keyWord)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetCygxReportMappingCygxDetail,Err:" + err.Error()
- return
- }
- if matchDetail != nil {
- var condition string
- var pars []interface{}
- condition = ` AND id_cygx = ? `
- pars = append(pars, matchDetail.Id)
- listGroup, err := cygx.GetCygxReportMappingGroupList(condition, pars, 0, 999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var categoryIds []int
- for _, v := range listGroup {
- categoryIds = append(categoryIds, v.CategoryIdCelue)
- }
- pars = make([]interface{}, 0)
- condition = ` AND category_id IN (` + utils.GetOrmInReplace(len(categoryIds)) + `)`
- pars = append(pars, categoryIds)
- listArticle, err := cygx.GetArticlList(condition, pars, 0, 999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range listArticle {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- articleIds = strings.TrimRight(articleIds, ",")
- }
- }
- if articleIds != "" {
- condition = ` AND r.article_id IN (` + articleIds + `)`
- if source == 1 {
- condition += ` AND r.stop_time > 4 `
- resp.List, err = cygx.GetCygxArticleHistoryRecordByUser(wxUser.Mobile, wxUser.Email, condition, 0, 0)
- } else {
- resp.List, err = cygx.GetCygxArticleCollectByUser(userId, 0, 0, condition)
- }
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户阅读记录"
- return
- }
- if len(resp.List) > 0 {
- for k, v := range resp.List {
- resp.List[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- resp.List[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- if v.ArticleId >= utils.SummaryArticleId {
- resp.List[k].ArticleType = 1
- } else {
- resp.List[k].ArticleType = 2
- }
- }
- }
- }
- } else if source == 3 {
- activityIdByLabel, err := cygx.GetactivityIdsByLabel(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- activityId := activityIdByLabel
- if activityId != "" {
- condition = ` AND s.is_meeting = 1 AND s.activity_id IN (` + activityId + `) AND s.mobile = ` + wxUser.Mobile
- resp.List, err = cygx.GetActivityMeetByUser(condition, 0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- }
- } else if source == 4 {
- activityIdByLabel, err := cygx.GetactivitySpecilIdsByLabel(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- activityId := activityIdByLabel
- if activityId != "" {
- condition = ` AND s.is_meeting = 1 AND s.activity_id IN (` + activityId + `) AND s.mobile = ` + wxUser.Mobile
- resp.List, err = cygx.GetActivitySpecialMeetByUser(condition, 0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- }
- }
- if len(resp.List) == 0 {
- resp.List = make([]*cygx.UserInteraction, 0)
- }
- resp.IndustryName = keyWord
- if managementIds != "" {
- count, err := cygx.GetCygxIndustryFllowCountByUser(userId, managementIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户是否关注失败,Err:" + err.Error()
- return
- }
- if count > 0 {
- resp.IsFllow = true
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 用户相关互动下载
- // @Description 用户相关互动下载接口
- // @Param UserId query int true "用户id"
- // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
- // @Param IsMeeting query string true "是否到会 1到会、2未到会"
- // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
- // @Param StartDate query string true "开始时间"
- // @Param EndDate query string true "结束时间"
- // @Param KeyWord query string true "搜索关键词"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.CygxUserTableStatusListRep
- // @router /user/export/interaction [get]
- func (this *UserController) ExportInteraction() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- userId, _ := this.GetInt("UserId")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- source, _ := this.GetInt("Source")
- classType, _ := this.GetInt("ClassType", 1)
- if userId < 1 {
- br.Msg = "用户不存在"
- return
- }
- wxUser, err := models.GetWxUserByUserId(userId)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取信息失败"
- return
- }
- mobile := wxUser.Mobile
- var list []*cygx.UserInteraction
- var condition string
- var sheetName string
- if source == 1 {
- sheetName = "报告阅读列表"
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- //total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
- // return
- //}
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- _, list, err = cygx.GetCygxArticleHistoryRecordByUserNew(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- var articleIds []int
- if len(list) > 0 {
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if list[k].PermissionName == "" {
- list[k].PermissionName = v.CategoryName
- }
- if v.SpecialType == 0 {
- articleIds = append(articleIds, v.ArticleId)
- }
- }
- mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByArticleId(articleIds) // 关联产业
- mapSubjectLabel := cygxService.GetArticleSubjectLabelByArticleId(articleIds) // 关联标的
- for _, v := range list {
- v.IndustryName = strings.Join(mapIndustrialLabel[v.ArticleId], "/")
- v.SubjectNameStr = strings.Join(mapSubjectLabel[v.ArticleId], "/")
- }
- }
- } else if source == 2 {
- sheetName = "到会管理名单"
- if mobile != "" {
- condition = ` AND s.mobile = '` + mobile + `' `
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isMeeting == "1" {
- condition += ` AND s.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND s.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if keyWord != "" {
- condition += ` AND a.activity_name LIKE '%` + keyWord + `%' `
- }
- list, err = cygx.GetActivityMeetByUser(condition, 0, 0)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += ",会议提醒"
- }
- }
- }
- }
- }
- } else if source == 11 {
- sheetName = "专栏文章阅读记录"
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if wxUser.Mobile == "" {
- wxUser.Mobile = wxUser.Email
- }
- condition += " AND (r.mobile = '" + wxUser.Mobile + "' OR r.email = '" + wxUser.Mobile + "') "
- _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- if source == 1 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "报告标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属行业"
- cellC := rowTitle.AddCell()
- cellC.Value = "所属产业"
- cellD := rowTitle.AddCell()
- cellD.Value = "关联标的"
- cellE := rowTitle.AddCell()
- cellE.Value = "发布时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时间"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.Title
- cellB := row.AddCell()
- cellB.Value = item.PermissionName
- cellC := row.AddCell()
- cellC.Value = item.IndustryName
- cellD := row.AddCell()
- cellD.Value = item.SubjectNameStr
- cellE := row.AddCell()
- cellE.Value = item.PublishDate
- cellF := row.AddCell()
- cellF.Value = item.CreateTime
- cellG := row.AddCell()
- cellG.Value = item.StopTime
- }
- } else if source == 2 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "活动名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属行业"
- cellC := rowTitle.AddCell()
- cellC.Value = "活动类型"
- cellD := rowTitle.AddCell()
- cellD.Value = "活动主题"
- cellE := rowTitle.AddCell()
- cellE.Value = "活动时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "是否到会"
- cellG := rowTitle.AddCell()
- cellG.Value = "首次入会时间"
- cellH := rowTitle.AddCell()
- cellH.Value = "最后退出时间"
- cellI := rowTitle.AddCell()
- cellI.Value = "参与总时长"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "参会方式"
- cellK := rowTitle.AddCell()
- cellK.Value = "参会权鉴"
- cellL := rowTitle.AddCell()
- cellL.Value = "参会状态"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.ActivityName
- cellB := row.AddCell()
- cellB.Value = item.PermissionName
- cellC := row.AddCell()
- cellC.Value = item.ActivityTypeName
- cellD := row.AddCell()
- cellD.Value = item.Label
- cellE := row.AddCell()
- cellE.Value = item.ActivityTime
- cellF := row.AddCell()
- if item.IsMeeting == 1 {
- cellF.Value = "到会"
- cellG := row.AddCell()
- cellG.Value = item.FirstMeetingTime
- cellH := row.AddCell()
- cellH.Value = item.LastMeetingTime
- cellI := row.AddCell()
- cellI.Value = item.Duration
- cellJ := row.AddCell()
- cellJ.Value = item.LastMeetingTime
- cellK := row.AddCell()
- cellK.Value = item.MeetingTypeStr
- cellL := row.AddCell()
- cellL.Value = item.MeetingStatusStr
- } else {
- cellF.Value = "未到会"
- }
- }
- } else if source == 11 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "文章类型"
- cellC := rowTitle.AddCell()
- cellC.Value = "标签"
- cellD := rowTitle.AddCell()
- cellD.Value = "发布时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时长"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读来源"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.Title
- cellB := row.AddCell()
- if item.SpecialType == 1 {
- cellB.Value = "笔记"
- } else {
- cellB.Value = "观点"
- }
- cellC := row.AddCell()
- cellC.Value = item.IndustryName
- cellD := row.AddCell()
- cellD.Value = item.PublishDate
- cellE := row.AddCell()
- cellE.Value = item.CreateTime
- cellF := row.AddCell()
- cellF.Value = item.StopTime
- cellG := row.AddCell()
- cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
- }
- } else if source == 11 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "文章类型"
- cellC := rowTitle.AddCell()
- cellC.Value = "标签"
- cellD := rowTitle.AddCell()
- cellD.Value = "发布时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时长"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读来源"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.Title
- cellB := row.AddCell()
- if item.SpecialType == 1 {
- cellB.Value = "笔记"
- } else {
- cellB.Value = "观点"
- }
- cellC := row.AddCell()
- cellC.Value = item.IndustryName
- cellD := row.AddCell()
- cellD.Value = item.PublishDate
- cellE := row.AddCell()
- cellE.Value = item.CreateTime
- cellF := row.AddCell()
- cellF.Value = item.StopTime
- cellG := row.AddCell()
- cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := wxUser.RealName + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 机构互动详情table栏
- // @Description 互动详情table栏接口
- // @Param CompanyId query int true "公司ID"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.UserRemarksListResp
- // @router /user/company/table/list [get]
- func (this *UserController) CompanyTableList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- companyId, _ := this.GetInt("CompanyId")
- classType, _ := this.GetInt("ClassType", 1)
- if companyId < 1 {
- br.Msg = "机构不存在"
- return
- }
- comanyDetail, err := company.GetCompanyDetailById(companyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxUserTableListRep)
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- var pars []interface{}
- condition := ` AND r.company_id IN ( ` + strconv.Itoa(companyId) + ` ) AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' ` //过滤当天时间
- //totalEs, _, err := services.SearcCygxArticleHistoryData(utils.IndexNameArticleHistory, "", "", "", strconv.Itoa(companyId), 0, 0)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取Es文章阅读数量失败,Err:" + err.Error()
- // return
- //}
- conditionArtcile := condition //文章搜索条件
- conditionActivityMeet := condition //活动到会搜索条件
- conditionIndustryFllow := condition //产业关注搜索条件
- conditionKeyWord := condition //关键词记录搜索条件
- if classType == 1 {
- conditionArtcile += " AND art.article_type_id = 0 "
- conditionActivityMeet += " AND a.chart_permission_id != 31 "
- conditionIndustryFllow += " AND m.chart_permission_id != 31 "
- conditionKeyWord += " AND r.register_platform IN (1,2) "
- } else {
- conditionArtcile += " AND art.article_type_id > 0 "
- conditionActivityMeet += " AND a.chart_permission_id = 31 "
- conditionIndustryFllow += " AND m.chart_permission_id = 31 "
- conditionKeyWord += " AND r.register_platform IN (5,6) "
- }
- var historyNum int //报告阅读列表
- var activityNum int //活动互动记录
- var triptotal int //专项调研
- var articleCollect int //收藏的报告
- var chartNum int //收藏图表
- var industryFllowNum int //关注的产业
- var departmentFollowNum int //关注的作者
- var keyWordNum int //搜索
- var roadshowTotal int //音视频播放
- var tagNum int //首页标签点击
- var yanxuanSpecialNum int //专栏文章阅读记录
- var yanxuanSpecialCollectNum int //收藏的专栏文章
- var yanxuanSpecialFollowNum int //关注的专栏作者
- var feedbackNum int //交流反馈数量
- var calendarMeetingNum int //1v1 路演数量
- if isAdminRole {
- historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCount(conditionArtcile, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- activityNum, err = cygx.GetActivityMeetByCompanyCount(conditionActivityMeet)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- //获取用户收藏记录总数
- articleCollect, err = cygx.GetCygxArticleCollectCountByCompany(conditionArtcile)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- //获取用户关注总数
- industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompany(conditionIndustryFllow)
- if err != nil {
- br.Msg = "获取信息失败 "
- br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
- return
- }
- //获取关注作者总数
- departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
- return
- }
- //获取搜索记录
- keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompany(conditionKeyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- chartNum, err = cygx.GetChartCountByUserMobile(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- roadshowTotal, err = cygx.GetCygxRoadshowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- tagNum, err = cygx.GetCygxTagHistoryCount(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取研选专栏阅读数量失败"
- return
- }
- yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取收藏的专栏文章数量失败"
- return
- }
- yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注的专栏作者数量失败"
- return
- }
- feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModel(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取交流反馈数量失败"
- return
- }
- calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModel(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModel,Err:" + err.Error()
- return
- }
- } else {
- historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(conditionArtcile, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- activityNum, err = cygx.GetActivityMeetByCompanyCountWeekly(conditionActivityMeet)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- //获取用户收藏记录总数
- articleCollect, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(conditionArtcile)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- //获取用户关注总数
- industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败 "
- br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
- return
- }
- //获取关注作者总数
- departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
- return
- }
- //获取搜索记录
- keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(conditionKeyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- chartNum, err = cygx.GetChartCountByUserMobileWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- roadshowTotal, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- tagNum, err = cygx.GetCygxTagHistoryCountWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCountWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取研选专栏阅读数量失败"
- return
- }
- yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCountWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取收藏的专栏文章数量失败"
- return
- }
- yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCountWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注的专栏作者数量失败"
- return
- }
- feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModelWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取交流反馈数量失败"
- return
- }
- calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModelWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModelWeekly,Err:" + err.Error()
- return
- }
- }
- if classType == 1 {
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
- {PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
- {PermissionName: "1v1路演", Source: 15, TotalNum: calendarMeetingNum},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
- {PermissionName: "收藏图表", Source: 4, TotalNum: chartNum},
- {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
- {PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
- {PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum},
- {PermissionName: "交流反馈", Source: 14, TotalNum: feedbackNum}}
- resp.List = List
- } else {
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
- {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
- {PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
- {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: yanxuanSpecialNum},
- {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: yanxuanSpecialCollectNum},
- {PermissionName: "关注的专栏作者", Source: 13, TotalNum: yanxuanSpecialFollowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum}}
- resp.List = List
- }
- resp.ComapnyName = comanyDetail.CompanyName
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 机构互动详情
- // @Description 机构互动详情接口
- // @Param CompanyId query int true "公司ID"
- // @Param Source query int true "来源"
- // @Param IsMeeting query string false "是否到会 1到会、2未到会"
- // @Param MeetType query string false "参会方式 1线上,2线下 默认为线上"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param StartDate query string false "开始时间"
- // @Param EndDate query string false "结束时间"
- // @Param KeyWord query string false "搜索关键词"
- // @Param ActivityName query string false "活动名称"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Param IsExport query bool false "是否导出excel,默认是false"
- // @Success 200 {object} cygx.UserInteractionListResp
- // @router /user/company/interaction/detail [get]
- func (this *UserController) CompanyTableDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- companyId, _ := this.GetInt("CompanyId")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- activityName := this.GetString("ActivityName")
- source, _ := this.GetInt("Source")
- classType, _ := this.GetInt("ClassType", 1)
- if companyId < 1 {
- br.Msg = "用户不存在"
- return
- }
- isExport, _ := this.GetBool("IsExport")
- if isExport {
- pageSize = 10000
- currentIndex = 1
- }
- // 1.标记用户表
- //操作权限校验
- resp := new(cygx.UserInteractionListResp)
- var err error
- var list []*cygx.UserInteraction
- var total int
- var condition string
- var pars []interface{}
- condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' `
- if keyWord != "" {
- condition += ` AND ( r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%')`
- }
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- if source == 1 {
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- condition += " AND r.source = 'article' "
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- condition += " ORDER BY r.create_time DESC "
- var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
- if isAdminRole {
- total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- //处理查询信息回显
- list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- //导出excel
- if isExport {
- exportListArticle(this, list, 2, br)
- return
- }
- } else if source == 2 {
- if isMeeting == "1" {
- condition += ` AND r.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND r.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if activityName != "" {
- condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
- }
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isAdminRole {
- total, err = cygx.GetActivityMeetByCompanyCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetActivityMeetByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- } else {
- total, err = cygx.GetActivityMeetByCompanyCountWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetActivityMeetByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += ",会议提醒"
- }
- }
- if v.IsMeeting == 0 || v.FirstMeetingTime == "0000-00-00 00:00:00" {
- list[k].FirstMeetingTime = ""
- list[k].LastMeetingTime = ""
- }
- if v.FirstMeetingTime == "0000-00-00 00:00:00" {
- list[k].FirstMeetingTime = ""
- list[k].LastMeetingTime = ""
- }
- }
- }
- //导出excel
- if isExport {
- exportListActivity(this, list, 2, br)
- return
- }
- } else if source == 3 {
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- if isAdminRole {
- total, err = cygx.GetCygxArticleCollectCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxArticleCollectByCompany(startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxArticleCollectByCompanyWeekly(startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- }
- } else if source == 4 {
- if isAdminRole {
- list, err = cygx.GetChartCollectList(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- } else {
- list, err = cygx.GetChartCollectListWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- var err error
- 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) + `' ` //过滤当天时间
- total, err = cygx.GetChartCountByUserMobile(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- listChart, err := cygx.GetChartListCollectionWithCygxByMobile(condition, 0, 18)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k, vChart := range listChart {
- if vChart.PtagName != "" {
- listChart[k].CtagNamePc = vChart.PtagName
- }
- if vChart.CtagName != "" {
- listChart[k].CtagNamePc += "," + vChart.CtagName
- }
- if vChart.PtagNameTwo != "" {
- listChart[k].CtagNamePc += "," + vChart.PtagNameTwo
- }
- if vChart.CtagNameTwo != "" {
- listChart[k].CtagNamePc += "," + vChart.CtagNameTwo
- }
- }
- pageChart := paging.GetPaging(currentIndex, 18, total)
- list[k].ListChart = listChart
- list[k].Paging = pageChart
- list[k].IsEnd = pageChart.IsEnd
- list[k].CurrentIndex = pageChart.CurrentIndex
- }
- }
- } else if source == 5 {
- if classType == 1 {
- condition += " AND m.chart_permission_id != 31 "
- } else {
- condition += " AND m.chart_permission_id = 31 "
- }
- if isAdminRole {
- total, err = cygx.GetCygxIndustryFllowCountByCompany(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- list, err = cygx.GetCygxIndustryFllowByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- } else {
- total, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- list, err = cygx.GetCygxIndustryFllowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- }
- } else if source == 6 {
- if isAdminRole {
- total, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者总数失败"
- return
- }
- list, err = cygx.GetCygArticleDepartmentFollowByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者列表失败"
- return
- }
- } else {
- total, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者总数失败"
- return
- }
- list, err = cygx.GetCygArticleDepartmentFollowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者列表失败"
- return
- }
- }
- if len(list) > 0 {
- var departmentIds []int
- for _, v := range list {
- departmentIds = append(departmentIds, v.DepartmentId)
- }
- mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByDepartmentId(departmentIds) // 关联产业
- for _, v := range list {
- v.SubjectNameStr = strings.Join(mapIndustrialLabel[v.DepartmentId], "/")
- }
- }
- } else if source == 7 {
- if classType == 1 {
- condition += " AND r.register_platform IN (1,2) "
- } else {
- condition += " AND r.register_platform IN (5,6) "
- }
- if isAdminRole {
- total, err = cygx.GetCygxSearchKeyWordCountBuCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxSearchKeyWordByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxSearchKeyWordByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- } else if source == 8 {
- if isAdminRole {
- total, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.CygxActivitySpecialTripByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.CygxActivitySpecialTripByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- } else if source == 9 {
- if isAdminRole {
- total, err = cygx.GetCygxRoadshowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxRoadshowByCompany(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxRoadshowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- } else if source == 10 { //标签点击记录
- if isAdminRole {
- total, err = cygx.GetCygxTagHistoryCount(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxTagHistoryListBycondition(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else {
- total, err = cygx.GetCygxTagHistoryCountWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxTagHistoryListByconditionWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- }
- } else if source == 11 { //专栏文章阅读记录
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- //导出excel
- if isExport {
- exportListYanxuanSpecial(this, list, 2, br)
- return
- }
- } else if source == 12 { //收藏的专栏文章
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuanSpecialCollectByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- } else if source == 13 { //关注的专栏作者
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
- }
- }
- } else if source == 14 { //交流反馈
- if isAdminRole {
- total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户交流反馈,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxUserFeedbackWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户交流反馈,Err:" + err.Error()
- return
- }
- }
- } else if source == 15 { //1V1路演
- if startDate != "" {
- condition += ` AND b.start_date >= '` + startDate + `' `
- }
- if endDate != "" {
- condition += ` AND b.start_date <= '` + endDate + `' `
- }
- var totalRsCalendar int
- var listRsCalendar []*roadshow.RsCalendarMeetingUserByRai
- if isAdminRole {
- totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRaiWeekly(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- total = totalRsCalendar
- list, err = cygxService.HandleListRsCalendar(listRsCalendar)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
- return
- }
- //导出excel
- if isExport {
- exportListRsCalendar(this, list, 2, br)
- return
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- if len(list) == 0 {
- list = make([]*cygx.UserInteraction, 0)
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 机构相关互动下载
- // @Description 机构相关互动下载接口
- // @Param CompanyId query int true "公司id"
- // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
- // @Param IsMeeting query string true "是否到会 1到会、2未到会"
- // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
- // @Param StartDate query string true "开始时间"
- // @Param EndDate query string true "结束时间"
- // @Param KeyWord query string true "搜索关键词"
- // @Param ActivityName query string true "活动名称"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.CygxUserTableStatusListRep
- // @router /user/company/export/interaction [get]
- func (this *UserController) CompanyExportInteraction() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- companyId, _ := this.GetInt("CompanyId")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- activityName := this.GetString("ActivityName")
- source, _ := this.GetInt("Source")
- classType, _ := this.GetInt("ClassType", 1)
- if companyId < 1 {
- br.Msg = "用户不存在"
- return
- }
- //获取企业客户信息
- companyInfo, err := company.GetCompanyById(companyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetCompanyById,Err:" + err.Error()
- return
- }
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- var pageSize = 9999
- var list []*cygx.UserInteraction
- var condition string
- condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
- if keyWord != "" {
- //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 + `%')`
- condition += ` AND ( r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%')`
- }
- if source == 1 {
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- condition += ` ORDER BY r.create_time DESC `
- var pars []interface{}
- var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
- if isAdminRole {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- //处理查询信息回显
- list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- var articleIds string
- mapAricleId := make(map[int]int)
- mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if list[k].PermissionName == "" {
- list[k].PermissionName = v.CategoryName
- }
- if mapAricleId[v.ArticleId] == 0 {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- mapAricleId[v.ArticleId] = v.ArticleId
- }
- }
- articleIds = strings.TrimRight(articleIds, ",")
- if articleIds != "" {
- listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(listArticleIndustrialSubjectList) > 0 {
- for _, v := range listArticleIndustrialSubjectList {
- mapAricleIndustrialSubjectName[v.ArticleId] = v
- }
- for k, v := range list {
- if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
- list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
- list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
- }
- }
- }
- }
- }
- } else if source == 2 {
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isMeeting == "1" {
- condition += ` AND r.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND r.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if activityName != "" {
- condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
- }
- if isAdminRole {
- list, err = cygx.GetActivityMeetByCompany(condition, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- } else {
- list, err = cygx.GetActivityMeetByCompanyWeekly(condition, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += ",会议提醒"
- }
- }
- }
- }
- } else if source == 11 {
- if isAdminRole {
- _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("用户名单")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- var excelName string
- if source == 1 {
- excelName = "阅读记录"
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "报告标题"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属行业"
- cellE := rowTitle.AddCell()
- cellE.Value = "所属产业"
- cellF := rowTitle.AddCell()
- cellF.Value = "关联标的"
- cellG := rowTitle.AddCell()
- cellG.Value = "发布时间"
- cellH := rowTitle.AddCell()
- cellH.Value = "阅读时间"
- cellI := rowTitle.AddCell()
- cellI.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.Mobile
- cellC := row.AddCell()
- cellC.Value = item.Title
- cellD := row.AddCell()
- cellD.Value = item.PermissionName
- cellE := row.AddCell()
- cellE.Value = item.IndustryName
- cellF := row.AddCell()
- cellF.Value = item.SubjectNameStr
- cellG := row.AddCell()
- cellG.Value = item.PublishDate
- cellH := row.AddCell()
- cellH.Value = item.CreateTime
- cellI := row.AddCell()
- cellI.Value = item.StopTime
- }
- } else if source == 2 {
- excelName = "参会记录"
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "活动名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属行业"
- cellE := rowTitle.AddCell()
- cellE.Value = "活动类型"
- cellF := rowTitle.AddCell()
- cellF.Value = "活动主题"
- cellG := rowTitle.AddCell()
- cellG.Value = "活动时间"
- cellH := rowTitle.AddCell()
- cellH.Value = "是否到会"
- cellI := rowTitle.AddCell()
- cellI.Value = "首次入会时间"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "最后退出时间"
- cellK := rowTitle.AddCell()
- cellK.Value = "参与总时长"
- cellL := rowTitle.AddCell()
- cellL.Value = "参会方式"
- cellM := rowTitle.AddCell()
- cellM.Value = "参会权鉴"
- cellN := rowTitle.AddCell()
- cellN.Value = "参会状态"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.Mobile
- cellC := row.AddCell()
- cellC.Value = item.ActivityName
- cellD := row.AddCell()
- cellD.Value = item.PermissionName
- cellE := row.AddCell()
- cellE.Value = item.ActivityTypeName
- cellF := row.AddCell()
- cellF.Value = item.Label
- cellG := row.AddCell()
- cellG.Value = item.ActivityTime
- cellH := row.AddCell()
- if item.IsMeeting == 1 {
- cellH.Value = "到会"
- } else {
- cellH.Value = "未到会"
- }
- cellI := row.AddCell()
- cellI.Value = item.FirstMeetingTime
- cellJ := row.AddCell()
- cellJ.Value = item.LastMeetingTime
- cellK := row.AddCell()
- cellK.Value = item.Duration
- cellL := row.AddCell()
- cellL.Value = item.LastMeetingTime
- cellM := row.AddCell()
- cellM.Value = item.MeetingTypeStr
- cellN := row.AddCell()
- cellN.Value = item.MeetingStatusStr
- }
- } else if source == 11 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "文章类型"
- cellC := rowTitle.AddCell()
- cellC.Value = "标签"
- cellD := rowTitle.AddCell()
- cellD.Value = "发布时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时长"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读来源"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.Title
- cellB := row.AddCell()
- if item.SpecialType == 1 {
- cellB.Value = "笔记"
- } else {
- cellB.Value = "观点"
- }
- cellC := row.AddCell()
- cellC.Value = item.IndustryName
- cellD := row.AddCell()
- cellD.Value = item.PublishDate
- cellE := row.AddCell()
- cellE.Value = item.CreateTime
- cellF := row.AddCell()
- cellF.Value = item.StopTime
- cellG := row.AddCell()
- cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDate)
- downloadFileName := excelName + companyInfo.CompanyName + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 全机构互动列表
- // @Description 全机构互动列表接口
- // @Param Source query int true "来源"
- // @Param AdminId query string true "销售id,多个用英文逗号隔开,空字符串为全部"
- // @Param IsMeeting query string false "是否到会 1到会、2未到会"
- // @Param MeetType query string false "参会方式 1线上,2线下 默认为线上"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param StartDate query string false "开始时间"
- // @Param EndDate query string false "结束时间"
- // @Param KeyWord query string false "搜索关键词"
- // @Param ActivityName query string false "活动名称"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Param IsExport query bool false "是否导出excel,默认是false"
- // @Success 200 {object} cygx.UserInteractionListResp
- // @router /user/company/list [get]
- func (this *UserController) CompanyList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- adminId := this.GetString("AdminId")
- keyWord := this.GetString("KeyWord")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- activityName := this.GetString("ActivityName")
- source, _ := this.GetInt("Source")
- status := this.GetString("Status")
- classType, _ := this.GetInt("ClassType", 1)
- // 套餐类型
- //packageType, _ := this.GetInt("PackageType")
- keyWord = strings.Trim(keyWord, " ")
- keyWord = strings.Replace(keyWord, "'", "", -1)
- isExport, _ := this.GetBool("IsExport")
- if isExport {
- pageSize = 10000
- currentIndex = 1
- }
- var total int
- //statusItems := make([]*company.CompanyStatus, 0)
- //var statusArr = [...]string{"全部", "试用", "正式", "冻结", "流失", "永续"}
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- resp := new(cygx.UserInteractionListResp)
- var err error
- var list []*cygx.UserInteraction
- //流失
- var lossCondition string
- //var lossPars []interface{}
- //状态分类查询条件
- var permissionCondition string
- if adminId != "" {
- condition += ` AND b.seller_id IN (` + adminId + `) `
- }
- lossCondition = condition
- //lossPars = pars
- permissionCondition = condition
- //流失客户统计
- lossCondition += ` AND status='流失' `
- //productId := services.GetProductId(roleTypeCode)
- productId := 2
- //权限控制
- {
- //如果不是超级管理员或者财务
- if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
- //如果是部门管理员
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- } else {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- if status == "全部" {
- ////如果是筛选了流失客户状态
- if sysUser.Authority <= 0 {
- condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
- permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- } else {
- //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
- if sysUser.Authority <= 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //pars = append(pars, sysUser.AdminId)
- }
- permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //permissionPars = append(permissionPars, sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //pars = append(pars, sysUser.DepartmentId)
- }
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //permissionPars = append(permissionPars, sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- }
- }
- }
- }
- condition += ` AND b.status IN ('正式','试用','冻结') `
- 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 `
- 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 `
- if condition != "" {
- companyCondition += condition
- }
- companyIdsCondition += condition
- var companyIds string
- companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取公司ID数据失败,Err:" + err.Error()
- return
- }
- condition = ` AND r.company_id IN ( ` + companyIds + ` ) AND r.create_time < '` + time.Now().Format(utils.FormatDate) + `' ` // 过滤当天查询时间
- if keyWord != "" {
- condition += ` AND (r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%'` + ` OR r.company_name LIKE '%` + keyWord + `%') `
- }
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- if source == 1 {
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- condition += " AND r.source = 'article' "
- var pars []interface{}
- condition += " ORDER BY r.create_time DESC "
- var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
- if isAdminRole {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- } else {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- total, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- }
- //处理查询信息回显
- list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- //导出excel
- if isExport {
- exportListArticle(this, list, 3, br)
- return
- }
- } else if source == 2 {
- if isMeeting == "1" {
- condition += ` AND r.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND r.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if activityName != "" {
- condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
- }
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isAdminRole {
- total, err = cygx.GetActivityMeetByCompanyCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetActivityMeetByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- } else {
- total, err = cygx.GetActivityMeetByCompanyCountWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetActivityMeetByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- }
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += ",会议提醒"
- }
- }
- if v.IsMeeting == 0 {
- list[k].FirstMeetingTime = ""
- list[k].LastMeetingTime = ""
- }
- v.SellerName = sellNameMap[v.CompanyId]
- }
- }
- //导出excel
- if isExport {
- exportListActivity(this, list, 3, br)
- return
- }
- } else if source == 3 {
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- if isAdminRole {
- total, err = cygx.GetCygxArticleCollectCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxArticleCollectByCompanyList(startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxArticleCollectByCompanyWeekly(startSize, pageSize, condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户搜藏记录失败,Err:" + err.Error()
- return
- }
- }
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- if len(list) > 0 {
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- v.SellerName = sellNameMap[v.CompanyId]
- if classType == 1 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- } else {
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- }
- }
- }
- } else if source == 4 {
- if isAdminRole {
- total, err = cygx.GetChartCountByUserCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- //condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
- list, err = cygx.GetChartCollectBycompanyList(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetChartCountByUserMobileWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- //condition += ` AND r.company_id = ` + strconv.Itoa(companyId) + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
- list, err = cygx.GetChartCollectBycompanyListWeekly(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- var err error
- condition = ` AND a.publish_status = 1 AND r.mobile = ` + v.Mobile + ` AND r.create_time < date_format(now(),'%Y-%m-%d')` //过滤当天时间
- totalUser, err := cygx.GetChartCountByUserMobile(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- listChart, err := cygx.GetChartListCollectionWithCygxByMobile(condition, 0, 18)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k, vChart := range listChart {
- if vChart.PtagName != "" {
- listChart[k].CtagNamePc = vChart.PtagName
- }
- if vChart.CtagName != "" {
- listChart[k].CtagNamePc += "," + vChart.CtagName
- }
- if vChart.PtagNameTwo != "" {
- listChart[k].CtagNamePc += "," + vChart.PtagNameTwo
- }
- if vChart.CtagNameTwo != "" {
- listChart[k].CtagNamePc += "," + vChart.CtagNameTwo
- }
- }
- pageChart := paging.GetPaging(currentIndex, pageSize, totalUser)
- list[k].ListChart = listChart
- list[k].Paging = pageChart
- list[k].IsEnd = pageChart.IsEnd
- list[k].CurrentIndex = pageChart.CurrentIndex
- }
- }
- } else if source == 5 {
- if classType == 1 {
- condition += " AND m.chart_permission_id != 31 "
- } else {
- condition += " AND m.chart_permission_id = 31 "
- }
- if isAdminRole {
- total, err = cygx.GetCygxIndustryFllowCountByCompany(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- list, err = cygx.GetCygxIndustryFllowByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- } else {
- total, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- list, err = cygx.GetCygxIndustryFllowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取用户关注总数失败"
- return
- }
- }
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- for _, v := range list {
- v.SellerName = sellNameMap[v.CompanyId]
- }
- } else if source == 6 {
- if isAdminRole {
- total, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者总数失败"
- return
- }
- list, err = cygx.GetCygArticleDepartmentFollowByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者列表失败"
- return
- }
- } else {
- total, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者总数失败"
- return
- }
- list, err = cygx.GetCygArticleDepartmentFollowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注作者列表失败"
- return
- }
- }
- if len(list) > 0 {
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- var departmentIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- departmentIds = append(departmentIds, v.DepartmentId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- mapIndustrialLabel := cygxService.GetArticleIndustrialLabelByDepartmentId(departmentIds) // 关联产业
- for _, v := range list {
- v.SellerName = sellNameMap[v.CompanyId]
- v.SubjectNameStr = strings.Join(mapIndustrialLabel[v.DepartmentId], "/")
- }
- }
- } else if source == 7 {
- if classType == 1 {
- condition += " AND r.register_platform IN (1,2) "
- } else {
- condition += " AND r.register_platform IN (5,6) "
- }
- if isAdminRole {
- total, err = cygx.GetCygxSearchKeyWordCountBuCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxSearchKeyWordByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxSearchKeyWordByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- for _, v := range list {
- v.SellerName = sellNameMap[v.CompanyId]
- }
- } else if source == 8 {
- if isAdminRole {
- total, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxActivitySpecialTripByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.CygxActivitySpecialTripByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- } else if source == 9 {
- if isAdminRole {
- total, err = cygx.GetCygxRoadshowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxRoadshowByCompanyList(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- } else {
- total, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- list, err = cygx.GetCygxRoadshowByCompanyWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
- return
- }
- }
- //根据公司ID获取对应销售
- var sellerCompanyIds []int
- for _, v := range list {
- sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
- }
- sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
- for _, v := range list {
- v.SellerName = sellNameMap[v.CompanyId]
- }
- } else if source == 10 { //标签点击记录
- if isAdminRole {
- total, err = cygx.GetCygxTagHistoryCount(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxTagHistoryListBycondition(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- } else {
- total, err = cygx.GetCygxTagHistoryCountWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- list, err = cygx.GetCygxTagHistoryListByconditionWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录列表失败"
- return
- }
- }
- } else if source == 11 { //专栏文章阅读记录
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- //导出excel
- if isExport {
- exportListYanxuanSpecial(this, list, 3, br)
- return
- }
- } else if source == 12 { //收藏的专栏文章
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuanSpecialCollectByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuanSpecialCollectByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.ArticleId)
- }
- }
- } else if source == 13 { //关注的专栏作者
- if isAdminRole {
- total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUser(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxYanxuanSpecialAuthorByUserWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- list[k].RegisterPlatform = cygxService.GetArticleSourcePlatform(v.SourcePlatform)
- list[k].RegisterPlatformText = cygxService.GetArticleSourcePlatformText(v.RegisterPlatform)
- list[k].HttpUrl = utils.CYGX_MFYX_URL + "/column/view/" + strconv.Itoa(v.DepartmentId)
- }
- }
- } else if source == 14 { //交流反馈
- if isAdminRole {
- total, list, err = cygx.GetCygxUserFeedback(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- total, list, err = cygx.GetCygxUserFeedbackWeekly(condition, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- } else if source == 15 {
- if startDate != "" {
- condition += ` AND b.start_date >= '` + startDate + `' `
- }
- if endDate != "" {
- condition += ` AND b.start_date <= '` + endDate + `' `
- }
- var totalRsCalendar int
- var listRsCalendar []*roadshow.RsCalendarMeetingUserByRai
- if isAdminRole {
- totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRai(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- totalRsCalendar, listRsCalendar, err = roadshow.GetRsCalendarMeetingUserByRaiWeekly(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- total = totalRsCalendar
- list, err = cygxService.HandleListRsCalendar(listRsCalendar)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "HandleListRsCalendar,Err:" + err.Error()
- return
- }
- //导出excel
- if isExport {
- exportListRsCalendar(this, list, 3, br)
- return
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- if len(list) == 0 {
- list = make([]*cygx.UserInteraction, 0)
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 机构列表相关互动下载
- // @Description 机构相关互动下载接口
- // @Param Source query int true "来源 报告阅读列表: 1, 活动互动记录: 2"
- // @Param IsMeeting query string true "是否到会 1到会、2未到会"
- // @Param MeetType query string true "参会方式 1线上,2线下 默认为线上"
- // @Param StartDate query string true "开始时间"
- // @Param EndDate query string true "结束时间"
- // @Param KeyWord query string true "搜索关键词"
- // @Param ActivityName query string true "活动名称"
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.CygxUserTableStatusListRep
- // @router /user/companyList/export/interaction [get]
- func (this *UserController) CompanyExportInteractionList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- adminId := this.GetString("AdminId")
- keyWord := this.GetString("KeyWord")
- isMeeting := this.GetString("IsMeeting")
- meetType := this.GetString("MeetType")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- activityName := this.GetString("ActivityName")
- source, _ := this.GetInt("Source")
- status := this.GetString("Status")
- classType, _ := this.GetInt("ClassType", 1)
- // 套餐类型
- //packageType, _ := this.GetInt("PackageType")
- keyWord = strings.Trim(keyWord, " ")
- keyWord = strings.Replace(keyWord, "'", "", -1)
- var list []*cygx.UserInteraction
- var err error
- var condition string
- //流失
- var lossCondition string
- //var lossPars []interface{}
- //状态分类查询条件
- var permissionCondition string
- if adminId != "" {
- condition += ` AND b.seller_id IN (` + adminId + `) `
- }
- lossCondition = condition
- //lossPars = pars
- permissionCondition = condition
- //流失客户统计
- lossCondition += ` AND status='流失' `
- //productId := services.GetProductId(roleTypeCode)
- productId := 2
- //权限控制
- {
- //如果不是超级管理员或者财务
- if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
- //如果是部门管理员
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- } else {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- if status == "全部" {
- ////如果是筛选了流失客户状态
- if sysUser.Authority <= 0 {
- condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
- permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- } else {
- //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
- if sysUser.Authority <= 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //pars = append(pars, sysUser.AdminId)
- }
- permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //permissionPars = append(permissionPars, sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //pars = append(pars, sysUser.DepartmentId)
- }
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //permissionPars = append(permissionPars, sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- }
- }
- }
- }
- //condition += ` AND b.status IN ('正式','试用','冻结') `
- //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 `
- //if condition != "" {
- // companyCondition += condition
- //}
- condition += ` AND b.status IN ('正式','试用','冻结') `
- 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 `
- 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 `
- if condition != "" {
- companyCondition += condition
- }
- companyIdsCondition += condition
- var companyIds string
- companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
- companyIds, err = cygx.GetCompanyIdsCondition(companyIdsCondition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取公司ID数据失败,Err:" + err.Error()
- return
- }
- condition = ` AND r.company_id IN ( ` + companyIds + ` )AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
- if keyWord != "" {
- condition += ` AND (r.mobile LIKE '%` + keyWord + `%' OR r.email LIKE '%` + keyWord + `%' OR r.real_name LIKE '%` + keyWord + `%'` + ` OR r.company_name LIKE '%` + keyWord + `%') `
- }
- var isAdminRole bool
- var pageSize = 9999
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- if source == 1 {
- if classType == 1 {
- condition += " AND art.article_type_id = 0 "
- } else {
- condition += " AND art.article_type_id > 0 "
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND r.create_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND r.create_time <= '` + endDate + `' `
- }
- condition += ` ORDER BY r.create_time DESC `
- var pars []interface{}
- var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
- if isAdminRole {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespListWeekly(condition, pars, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- //处理查询信息回显
- list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(list) > 0 {
- var articleIds string
- mapAricleId := make(map[int]int)
- mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
- for k, v := range list {
- if v.ArticleId >= utils.SummaryArticleId {
- list[k].ArticleType = 1
- } else {
- list[k].ArticleType = 2
- }
- if list[k].PermissionName == "" {
- list[k].PermissionName = v.CategoryName
- }
- if mapAricleId[v.ArticleId] == 0 {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- mapAricleId[v.ArticleId] = v.ArticleId
- }
- }
- articleIds = strings.TrimRight(articleIds, ",")
- if articleIds != "" {
- listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- if len(listArticleIndustrialSubjectList) > 0 {
- for _, v := range listArticleIndustrialSubjectList {
- mapAricleIndustrialSubjectName[v.ArticleId] = v
- }
- for k, v := range list {
- if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
- fmt.Println(mapAricleIndustrialSubjectName[v.ArticleId].IndustryName)
- list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
- list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
- }
- }
- }
- }
- }
- } else if source == 2 {
- if classType == 1 {
- condition += " AND a.chart_permission_id != 31 "
- } else {
- condition += " AND a.chart_permission_id = 31 "
- }
- if isMeeting == "1" {
- condition += ` AND r.is_meeting = 1 `
- }
- if isMeeting == "2" {
- condition += ` AND r.is_meeting = 0 `
- }
- if meetType == "1" {
- condition += ` AND t.activity_type = 1 `
- }
- if meetType == "2" {
- condition += ` AND t.activity_type = 0 `
- }
- if startDate != "" {
- startDate += " 00:00:00"
- condition += ` AND a.activity_time >= '` + startDate + `' `
- }
- if endDate != "" {
- endDate += " 23:59:59"
- condition += ` AND a.activity_time <= '` + endDate + `' `
- }
- if activityName != "" {
- condition += ` AND a.activity_name LIKE '%` + activityName + `%' `
- }
- if isAdminRole {
- list, err = cygx.GetActivityMeetByCompany(condition, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- } else {
- list, err = cygx.GetActivityMeetByCompanyWeekly(condition, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取参会人数列表失败"
- return
- }
- }
- if len(list) > 0 {
- for k, v := range list {
- if v.ActivityType == 1 {
- if v.SignupType == "2" {
- list[k].InteractionType = "自主拨入"
- } else {
- list[k].InteractionType = "预约外呼"
- }
- if v.ReminderNum > 0 {
- list[k].InteractionType += ",会议提醒"
- }
- }
- }
- }
- } else if source == 11 {
- if isAdminRole {
- _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUser(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- } else {
- _, list, err = cygx.GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition, 0, 9999)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
- return
- }
- }
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- var excelName string
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("到会管理名单")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- if source == 1 {
- excelName = "客户阅读记录"
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "客户名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属销售"
- cellC := rowTitle.AddCell()
- cellC.Value = "姓名"
- cellD := rowTitle.AddCell()
- cellD.Value = "手机号"
- cellE := rowTitle.AddCell()
- cellE.Value = "报告标题"
- cellF := rowTitle.AddCell()
- cellF.Value = "所属行业"
- cellG := rowTitle.AddCell()
- cellG.Value = "所属产业"
- cellH := rowTitle.AddCell()
- cellH.Value = "关联标的"
- cellI := rowTitle.AddCell()
- cellI.Value = "发布时间"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "阅读时间"
- cellK := rowTitle.AddCell()
- cellK.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.CompanyName
- cellB := row.AddCell()
- cellB.Value = item.SellerName
- cellC := row.AddCell()
- cellC.Value = item.RealName
- cellD := row.AddCell()
- cellD.Value = item.Mobile
- cellE := row.AddCell()
- cellE.Value = item.Title
- cellF := row.AddCell()
- cellF.Value = item.PermissionName
- cellG := row.AddCell()
- cellG.Value = item.IndustryName
- cellH := row.AddCell()
- cellH.Value = item.SubjectNameStr
- cellI := row.AddCell()
- cellI.Value = item.PublishDate
- cellJ := row.AddCell()
- cellJ.Value = item.CreateTime
- cellK := row.AddCell()
- cellK.Value = item.StopTime
- }
- } else if source == 2 {
- excelName = "客户参会记录"
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "客户名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属销售"
- cellC := rowTitle.AddCell()
- cellC.Value = "姓名"
- cellD := rowTitle.AddCell()
- cellD.Value = "手机号"
- cellE := rowTitle.AddCell()
- cellE.Value = "活动名称"
- cellF := rowTitle.AddCell()
- cellF.Value = "所属行业"
- cellG := rowTitle.AddCell()
- cellG.Value = "活动类型"
- cellH := rowTitle.AddCell()
- cellH.Value = "活动主题"
- cellI := rowTitle.AddCell()
- cellI.Value = "活动时间"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "是否到会"
- cellK := rowTitle.AddCell()
- cellK.Value = "首次入会时间"
- cellL := rowTitle.AddCell()
- cellL.Value = "最后退出时间"
- cellM := rowTitle.AddCell()
- cellM.Value = "参与总时长"
- cellN := rowTitle.AddCell()
- cellN.Value = "参会方式"
- cellO := rowTitle.AddCell()
- cellO.Value = "参会权鉴"
- cellP := rowTitle.AddCell()
- cellP.Value = "参会状态"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.CompanyName
- cellB := row.AddCell()
- cellB.Value = item.SellerName
- cellC := row.AddCell()
- cellC.Value = item.RealName
- cellD := row.AddCell()
- cellD.Value = item.Mobile
- cellE := row.AddCell()
- cellE.Value = item.ActivityName
- cellF := row.AddCell()
- cellF.Value = item.PermissionName
- cellG := row.AddCell()
- cellG.Value = item.ActivityTypeName
- cellH := row.AddCell()
- cellH.Value = item.Label
- cellI := row.AddCell()
- cellI.Value = item.ActivityTime
- cellJ := row.AddCell()
- if item.IsMeeting == 1 {
- cellJ.Value = "到会"
- } else {
- cellJ.Value = "未到会"
- }
- cellK := row.AddCell()
- cellK.Value = item.FirstMeetingTime
- cellL := row.AddCell()
- cellL.Value = item.LastMeetingTime
- cellM := row.AddCell()
- cellM.Value = item.Duration
- cellN := row.AddCell()
- cellN.Value = item.LastMeetingTime
- cellO := row.AddCell()
- cellO.Value = item.MeetingTypeStr
- cellP := row.AddCell()
- cellP.Value = item.MeetingStatusStr
- }
- } else if source == 11 {
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "文章类型"
- cellC := rowTitle.AddCell()
- cellC.Value = "标签"
- cellD := rowTitle.AddCell()
- cellD.Value = "发布时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时长"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读来源"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.Title
- cellB := row.AddCell()
- if item.SpecialType == 1 {
- cellB.Value = "笔记"
- } else {
- cellB.Value = "观点"
- }
- cellC := row.AddCell()
- cellC.Value = item.IndustryName
- cellD := row.AddCell()
- cellD.Value = item.PublishDate
- cellE := row.AddCell()
- cellE.Value = item.CreateTime
- cellF := row.AddCell()
- cellF.Value = item.StopTime
- cellG := row.AddCell()
- cellG.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := excelName + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- }
- // @Title 机构列表互动详情table栏
- // @Description 机构列表互动详情table栏接口
- // @Param ClassType query int true "列表类型,1:权益,2:研选,默认1"
- // @Success 200 {object} cygx.CygxUserTableListRep
- // @router /user/table/companyList [get]
- func (this *UserController) TableCompanyList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- roleTypeCode := sysUser.RoleTypeCode
- status := this.GetString("Status")
- classType, _ := this.GetInt("ClassType", 1)
- //流失
- var lossCondition string
- var condition string
- //var lossPars []interface{}
- //状态分类查询条件
- var permissionCondition string
- lossCondition = condition
- //lossPars = pars
- permissionCondition = condition
- //流失客户统计
- lossCondition += ` AND status='流失' `
- //productId := services.GetProductId(roleTypeCode)
- productId := 2
- //权限控制
- {
- //如果不是超级管理员或者财务
- if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && roleTypeCode != utils.ROLE_TYPE_CODE_FINANCE {
- //如果是部门管理员
- if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- } else {
- condition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- lossCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- permissionCondition += ` AND b.product_id= '` + strconv.Itoa(productId) + `'`
- if status == "全部" {
- ////如果是筛选了流失客户状态
- if sysUser.Authority <= 0 {
- condition += ` AND (b.seller_id= '` + strconv.Itoa(sysUser.AdminId) + `' OR status='流失') `
- permissionCondition += ` AND b.seller_id= ` + strconv.Itoa(sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- condition += ` AND (b.department_id=` + strconv.Itoa(sysUser.DepartmentId) + ` OR status='流失')`
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id=` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id =` + strconv.Itoa(sysUser.GroupId) + ` OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- } else {
- //如果没有筛选了流失客户状态,那么需要加客户归属条件加入到查询中去
- if sysUser.Authority <= 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //pars = append(pars, sysUser.AdminId)
- }
- permissionCondition += ` AND b.seller_id=` + strconv.Itoa(sysUser.AdminId)
- //permissionPars = append(permissionPars, sysUser.AdminId)
- } else {
- if sysUser.Authority == 1 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //pars = append(pars, sysUser.DepartmentId)
- }
- permissionCondition += ` AND b.department_id=` + strconv.Itoa(sysUser.DepartmentId)
- //permissionPars = append(permissionPars, sysUser.DepartmentId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id= ` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
- pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "查询父级id异常" + err.Error()
- return
- }
- var ids []*string
- if pid != nil {
- if *pid != 0 {
- //销售主管放在三级列表中
- ids, err = company.GetGroupIdsByParentId(*pid)
- if err != nil {
- fmt.Println(err.Error())
- }
- } else {
- //销售主管放在二级列表中
- ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
- if err != nil {
- fmt.Println(err.Error())
- }
- }
- }
- var idSlice []string
- var sid string
- for _, id := range ids {
- idSlice = append(idSlice, *id)
- }
- //加入父级groupId
- if *pid > 0 {
- idSlice = append(idSlice, strconv.Itoa(*pid))
- } else {
- idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
- }
- sid = strings.Join(idSlice, ",")
- if len(sid) > 0 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + sid + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + sid + `) `
- } else {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND (b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) OR status='流失') `
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id IN (` + strconv.Itoa(sysUser.GroupId) + `) `
- }
- }
- if sysUser.Authority == 4 {
- if status != utils.COMPANY_STATUS_LOSE {
- condition += ` AND b.group_id =` + strconv.Itoa(sysUser.GroupId)
- //pars = append(pars, sysUser.GroupId)
- }
- permissionCondition += ` AND b.group_id=` + strconv.Itoa(sysUser.GroupId)
- //permissionPars = append(permissionPars, sysUser.GroupId)
- }
- }
- }
- }
- }
- }
- condition += ` AND b.status IN ('正式','试用','冻结') `
- companyCondition := ` AND a.enabled=1 `
- if condition != "" {
- companyCondition += condition
- }
- resp := new(cygx.CygxUserTableListRep)
- var isAdminRole bool
- //如果不是管理员身份或者研究员身份则需要添加可见范围处理
- if sysUser.Role == utils.ROLE_TYPE_CODE_ADMIN || sysUser.Role == utils.ROLE_TYPE_CODE_RESEARCHR {
- isAdminRole = true
- }
- var pars []interface{}
- lsitCompany, err := company.GetCompanyProductListBycondition(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,GetCompanyProductListBycondition Err:" + err.Error()
- return
- }
- var companyIds []string
- for _, v := range lsitCompany {
- companyIds = append(companyIds, strconv.Itoa(v.CompanyId))
- }
- condition = " AND r.company_id IN (" + strings.Join(companyIds, ",") + ")"
- condition += ` AND r.create_time < date_format(now(),'%Y-%m-%d') ` //过滤当天时间
- conditionArtcile := condition //文章搜索条件
- conditionActivityMeet := condition //活动到会搜索条件
- conditionIndustryFllow := condition //产业关注搜索条件
- conditionKeyWord := condition //关键词记录搜索条件
- if classType == 1 {
- conditionArtcile += " AND art.article_type_id = 0 "
- conditionActivityMeet += " AND a.chart_permission_id != 31 "
- conditionIndustryFllow += " AND m.chart_permission_id != 31 "
- conditionKeyWord += " AND r.register_platform IN (1,2) "
- } else {
- conditionArtcile += " AND art.article_type_id > 0 "
- conditionActivityMeet += " AND a.chart_permission_id = 31 "
- conditionIndustryFllow += " AND m.chart_permission_id = 31 "
- conditionKeyWord += " AND r.register_platform IN (5,6) "
- }
- var historyNum int //报告阅读列表
- var activityNum int //活动互动记录
- var triptotal int //专项调研
- var articleCollect int //收藏的报告
- var chartNum int //收藏图表
- var industryFllowNum int //关注的产业
- var departmentFollowNum int //关注的作者
- var keyWordNum int //搜索
- var roadshowTotal int //音视频播放
- var tagNum int //首页标签点击
- var yanxuanSpecialNum int //专栏文章阅读记录
- var yanxuanSpecialCollectNum int //收藏的专栏文章
- var yanxuanSpecialFollowNum int //关注的专栏作者
- var feedbackNum int //交流反馈数量
- var calendarMeetingNum int //1v1 路演数量
- if isAdminRole {
- historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCount(conditionArtcile, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- //获取参会总数
- activityNum, err = cygx.GetActivityMeetByCompanyCount(conditionActivityMeet)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- //获取用户收藏记录总数
- articleCollect, err = cygx.GetCygxArticleCollectCountByCompany(conditionArtcile)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- //获取用户关注总数
- industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompany(conditionIndustryFllow)
- if err != nil {
- br.Msg = "获取信息失败 "
- br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
- return
- }
- //获取关注作者总数
- departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
- return
- }
- //获取搜索记录
- keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompany(conditionKeyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- chartNum, err = cygx.GetChartCountByUserMobile(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- roadshowTotal, err = cygx.GetCygxRoadshowCountByCompany(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- tagNum, err = cygx.GetCygxTagHistoryCount(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取研选专栏阅读数量失败"
- return
- }
- yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取收藏的专栏文章数量失败"
- return
- }
- yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCount(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取关注的专栏作者数量失败"
- return
- }
- feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModel(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取交流反馈数量失败"
- return
- }
- calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModel(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModel,Err:" + err.Error()
- return
- }
- } else {
- historyNum, err = cygx.GetCygxArticleAndYanxuanRecordCountWeekly(conditionArtcile, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户阅读记录数量失败,Err:" + err.Error()
- return
- }
- //获取参会总数
- activityNum, err = cygx.GetActivityMeetByCompanyCountWeekly(conditionActivityMeet)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取参会总数失败,Err:" + err.Error()
- return
- }
- //获取用户收藏记录总数
- articleCollect, err = cygx.GetCygxArticleCollectCountByCompanyWeekly(conditionArtcile)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户收藏记录总数失败,Err:" + err.Error()
- return
- }
- //获取用户关注总数
- industryFllowNum, err = cygx.GetCygxIndustryFllowCountByCompanyWeekly(conditionIndustryFllow)
- if err != nil {
- br.Msg = "获取信息失败 "
- br.ErrMsg = "获取用户关注总数失败,Err:" + err.Error()
- return
- }
- //获取关注作者总数
- departmentFollowNum, err = cygx.GetCygArticleDepartmentFollowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关注作者总数失败,Err:" + err.Error()
- return
- }
- //获取搜索记录
- keyWordNum, err = cygx.GetCygxSearchKeyWordCountBuCompanyWeekly(conditionKeyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- chartNum, err = cygx.GetChartCountByUserMobileWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取总数失败,Err:" + err.Error()
- return
- }
- triptotal, err = cygx.GetCygxActivitySpecialTripCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- roadshowTotal, err = cygx.GetCygxRoadshowCountByCompanyWeekly(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
- return
- }
- tagNum, err = cygx.GetCygxTagHistoryCountWeekly(condition)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取搜索记录失败"
- return
- }
- yanxuanSpecialNum, err = cygx.GetCygxYanxuanSpecialRecordCountWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取研选专栏阅读数量失败"
- return
- }
- yanxuanSpecialCollectNum, err = cygx.GetCygxYanxuanSpecialCollectCountWeekly(condition, pars)
- if err != nil {
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- br.Msg = "获取收藏的专栏文章数量失败"
- return
- }
- yanxuanSpecialFollowNum, err = cygx.GetCygxYanxuanSpecialFollowCountWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取关注的专栏作者数量失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- feedbackNum, err = cygx.GetCygxUserFeedbackCountByUserModelWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取交流反馈数量失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- calendarMeetingNum, err = roadshow.GetRsCalendarMeetingUserCountByUserModelWeekly(condition, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetRsCalendarMeetingUserCountByUserModelWeekly,Err:" + err.Error()
- return
- }
- }
- if classType == 1 {
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
- {PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
- {PermissionName: "1v1路演", Source: 15, TotalNum: calendarMeetingNum},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
- {PermissionName: "收藏图表", Source: 4, TotalNum: chartNum},
- {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
- {PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
- {PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum},
- {PermissionName: "交流反馈", Source: 14, TotalNum: feedbackNum}}
- resp.List = List
- } else {
- List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
- {PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
- {PermissionName: "收藏的报告", Source: 3, TotalNum: articleCollect},
- {PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
- {PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
- {PermissionName: "专栏文章阅读记录", Source: 11, TotalNum: yanxuanSpecialNum},
- {PermissionName: "收藏的专栏文章", Source: 12, TotalNum: yanxuanSpecialCollectNum},
- {PermissionName: "关注的专栏作者", Source: 13, TotalNum: yanxuanSpecialFollowNum},
- {PermissionName: "搜索", Source: 7, TotalNum: keyWordNum}}
- resp.List = List
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 添加/取消用户提醒
- // @Description 添加/取消用户提醒
- // @Param request body cygx.UserRemarAddReq true "type json string"
- // @Success 200 新增成功
- // @router /user/remind [post]
- func (this *UserController) UserRemind() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.UserRemarAddReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- userId := req.UserId
- sourceType := req.SourceType
- doType := req.DoType
- wxUser, err := cygx.GetUserAndCompanyNameList(userId)
- if err != nil {
- br.Msg = "设置互动提醒失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if sourceType != 1 && sourceType != 2 {
- br.Msg = "设置互动提醒失败"
- br.ErrMsg = "设置互动提醒失败,sourceType:" + strconv.Itoa(sourceType)
- return
- }
- if doType != 1 && doType != 2 {
- br.Msg = "设置互动提醒失败"
- br.ErrMsg = "设置互动提醒失败,doType:" + strconv.Itoa(doType)
- return
- }
- count, err := cygx.GetCygxUserRemindCount(userId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxUserRemindResp)
- if count <= 0 {
- var items []*cygx.CygxUserRemind
- if sourceType == 1 {
- item := new(cygx.CygxUserRemind)
- item.AdminId = sysUser.AdminId
- item.AdminName = sysUser.RealName
- item.UserId = userId
- item.Mobile = wxUser.Mobile
- item.Email = wxUser.Email
- item.CompanyId = wxUser.CompanyId
- item.CompanyName = wxUser.CompanyName
- item.RealName = wxUser.RealName
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- items = append(items, item)
- } else {
- //获取机构下所有的用户
- listUser, err := models.GetWxUserListCompanyId(wxUser.CompanyId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,GetWxUserListCompanyId Err:" + err.Error()
- return
- }
- //获取已经添加消息提醒的
- listUserRemind, err := cygx.GetCygxUserRemindListByCompanyId(wxUser.CompanyId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,GetCygxUserRemindListByCompanyId Err:" + err.Error()
- return
- }
- mapUserRemind := make(map[int]bool)
- for _, v := range listUserRemind {
- mapUserRemind[v.UserId] = true
- }
- for _, v := range listUser {
- //如果已经添加了提醒的用户就不做添加处理
- if mapUserRemind[v.UserId] {
- continue
- }
- item := new(cygx.CygxUserRemind)
- item.AdminId = sysUser.AdminId
- item.AdminName = sysUser.RealName
- item.UserId = v.UserId
- item.Mobile = v.Mobile
- item.Email = v.Email
- item.CompanyId = v.CompanyId
- item.CompanyName = v.CompanyName
- item.RealName = v.RealName
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- items = append(items, item)
- }
- }
- //批量加入
- err = cygx.AddCygxUserRemindMulti(items)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- } else {
- if sourceType == 1 {
- err = cygx.RemoveCygxUserRemind(userId) //取消个人提醒
- } else {
- err = cygx.RemoveCygxUserRemindByCompanyId(wxUser.CompanyId) //取消整个机构提醒
- }
- if err != nil {
- br.Msg = "取消失败"
- br.ErrMsg = "取消失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // exportListRsCalendar 1v1路演导出Excel
- func exportListRsCalendar(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- border := xlsx.NewBorder("thin", "thin", "thin", "thin")
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- redStyle.Border = *border
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheel, err := xlsxFile.AddSheet("1V1路演")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- sheel.SetColWidth(0, 0, 30)
- sheel.SetColWidth(1, 1, 15)
- sheel.SetColWidth(2, 2, 15)
- sheel.SetColWidth(3, 3, 18)
- titleRow := sheel.AddRow()
- if excelType > 2 {
- cellA := titleRow.AddCell()
- cellA.SetStyle(style)
- cellA.SetValue("客户名称")
- }
- if excelType > 1 {
- cellB := titleRow.AddCell()
- cellB.SetStyle(style)
- cellB.SetValue("姓名")
- cellC := titleRow.AddCell()
- cellC.SetStyle(style)
- cellC.SetValue("手机号")
- }
- cellD := titleRow.AddCell()
- cellD.SetStyle(style)
- cellD.SetValue("路演时间")
- cellE := titleRow.AddCell()
- cellE.SetStyle(style)
- cellE.SetValue("研究员")
- cellF := titleRow.AddCell()
- cellF.SetStyle(style)
- cellF.SetValue("路演形式")
- cellG := titleRow.AddCell()
- cellG.SetStyle(style)
- cellG.SetValue("主题标签")
- for _, v := range list {
- dataRow := sheel.AddRow()
- dataRow.SetHeight(20)
- if excelType > 2 {
- cellAData := dataRow.AddCell()
- cellAData.SetStyle(style)
- cellAData.Value = v.CompanyName
- }
- if excelType > 1 {
- cellBData := dataRow.AddCell()
- cellBData.SetStyle(style)
- cellBData.Value = v.RealName
- cellCData := dataRow.AddCell()
- cellCData.SetStyle(style)
- cellCData.Value = v.Mobile
- }
- cellDData := dataRow.AddCell()
- cellDData.SetStyle(style)
- cellDData.Value = v.ActivityTimeText
- cellEData := dataRow.AddCell()
- cellEData.SetStyle(style)
- cellEData.Value = v.ResearcherName
- cellFData := dataRow.AddCell()
- cellFData.SetStyle(style)
- if v.ActivityType == 1 {
- cellFData.Value = "线上"
- } else {
- cellFData.Value = "线下"
- }
- cellGData := dataRow.AddCell()
- cellGData.SetStyle(style)
- cellGData.Value = v.LabelKeyWord
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "1V1路演导出数据_" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // exportListArticle 文章阅读数据导出
- func exportListArticle(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("报告阅读列表")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- if excelType > 2 {
- cellA := rowTitle.AddCell()
- cellA.Value = "客户名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属销售"
- }
- if excelType > 1 {
- cellC := rowTitle.AddCell()
- cellC.Value = "姓名"
- cellD := rowTitle.AddCell()
- cellD.Value = "手机号"
- }
- cellE := rowTitle.AddCell()
- cellE.Value = "报告标题"
- cellF := rowTitle.AddCell()
- cellF.Value = "所属行业"
- cellG := rowTitle.AddCell()
- cellG.Value = "所属产业"
- cellH := rowTitle.AddCell()
- cellH.Value = "关联标的"
- cellI := rowTitle.AddCell()
- cellI.Value = "发布时间"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "阅读时间"
- cellK := rowTitle.AddCell()
- cellK.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- if excelType > 2 {
- cellA := row.AddCell()
- cellA.Value = item.CompanyName
- cellB := row.AddCell()
- cellB.Value = item.SellerName
- }
- if excelType > 1 {
- cellC := row.AddCell()
- cellC.Value = item.RealName
- cellD := row.AddCell()
- cellD.Value = item.Mobile
- }
- cellEData := row.AddCell()
- cellEData.Value = item.Title
- cellFData := row.AddCell()
- cellFData.Value = item.PermissionName
- cellGData := row.AddCell()
- cellGData.Value = item.IndustryName
- cellHData := row.AddCell()
- cellHData.Value = item.SubjectNameStr
- cellIData := row.AddCell()
- cellIData.Value = item.PublishDate
- cellJData := row.AddCell()
- cellJData.Value = item.CreateTime
- cellKData := row.AddCell()
- cellKData.Value = item.StopTime
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "报告阅读列表导出数据_" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // exportListArticle 文章阅读数据导出
- func exportListActivity(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("客户参会记录")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- if excelType > 2 {
- cellA := rowTitle.AddCell()
- cellA.Value = "客户名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属销售"
- }
- if excelType > 1 {
- cellC := rowTitle.AddCell()
- cellC.Value = "姓名"
- cellD := rowTitle.AddCell()
- cellD.Value = "手机号"
- }
- cellE := rowTitle.AddCell()
- cellE.Value = "活动名称"
- cellF := rowTitle.AddCell()
- cellF.Value = "所属行业"
- cellG := rowTitle.AddCell()
- cellG.Value = "活动类型"
- cellH := rowTitle.AddCell()
- cellH.Value = "活动主题"
- cellI := rowTitle.AddCell()
- cellI.Value = "活动时间"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "是否到会"
- cellK := rowTitle.AddCell()
- cellK.Value = "首次入会时间"
- cellL := rowTitle.AddCell()
- cellL.Value = "最后退出时间"
- cellM := rowTitle.AddCell()
- cellM.Value = "参与总时长"
- cellN := rowTitle.AddCell()
- cellN.Value = "参会方式"
- cellO := rowTitle.AddCell()
- cellO.Value = "参会权鉴"
- cellP := rowTitle.AddCell()
- cellP.Value = "参会状态"
- for _, item := range list {
- row := sheet.AddRow()
- if excelType > 2 {
- cellAData := row.AddCell()
- cellAData.Value = item.CompanyName
- cellBData := row.AddCell()
- cellBData.Value = item.SellerName
- }
- if excelType > 1 {
- cellCData := row.AddCell()
- cellCData.Value = item.RealName
- cellDData := row.AddCell()
- cellDData.Value = item.Mobile
- }
- cellEData := row.AddCell()
- cellEData.Value = item.ActivityName
- cellFData := row.AddCell()
- cellFData.Value = item.PermissionName
- cellGData := row.AddCell()
- cellGData.Value = item.ActivityTypeName
- cellHData := row.AddCell()
- cellHData.Value = item.Label
- cellIData := row.AddCell()
- cellIData.Value = item.ActivityTime
- cellJData := row.AddCell()
- if item.IsMeeting == 1 {
- cellJData.Value = "到会"
- } else {
- cellJData.Value = "未到会"
- }
- cellKData := row.AddCell()
- cellKData.Value = item.FirstMeetingTime
- cellLData := row.AddCell()
- cellLData.Value = item.LastMeetingTime
- cellMData := row.AddCell()
- cellMData.Value = item.Duration
- cellNData := row.AddCell()
- cellNData.Value = item.LastMeetingTime
- cellOData := row.AddCell()
- cellOData.Value = item.MeetingTypeStr
- cellPData := row.AddCell()
- cellPData.Value = item.MeetingStatusStr
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "客户参会记录导出数据_" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // exportListYanxuanSpecial 研选专栏阅读记录
- func exportListYanxuanSpecial(this *UserController, list []*cygx.UserInteraction, excelType int, br *models.BaseResponse) {
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("客户参会记录")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- if excelType > 2 {
- cellAy := rowTitle.AddCell()
- cellAy.Value = "客户名称"
- cellBy := rowTitle.AddCell()
- cellBy.Value = "所属销售"
- }
- if excelType > 1 {
- cellC := rowTitle.AddCell()
- cellC.Value = "姓名"
- cellD := rowTitle.AddCell()
- cellD.Value = "手机号"
- }
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "文章类型"
- cellC := rowTitle.AddCell()
- cellC.Value = "标签"
- cellD := rowTitle.AddCell()
- cellD.Value = "发布时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时间"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时长"
- cellG := rowTitle.AddCell()
- cellG.Value = "阅读来源"
- for _, item := range list {
- row := sheet.AddRow()
- if excelType > 2 {
- cellADatay := row.AddCell()
- cellADatay.Value = item.CompanyName
- cellBDatay := row.AddCell()
- cellBDatay.Value = item.SellerName
- }
- if excelType > 1 {
- cellCData := row.AddCell()
- cellCData.Value = item.RealName
- cellDData := row.AddCell()
- cellDData.Value = item.Mobile
- }
- cellAData := row.AddCell()
- cellAData.Value = item.Title
- cellBData := row.AddCell()
- if item.SpecialType == 1 {
- cellBData.Value = "笔记"
- } else {
- cellBData.Value = "观点"
- }
- cellCData := row.AddCell()
- cellCData.Value = item.IndustryName
- cellDData := row.AddCell()
- cellDData.Value = item.PublishDate
- cellEData := row.AddCell()
- cellEData.Value = item.CreateTime
- cellFData := row.AddCell()
- cellFData.Value = item.StopTime
- cellGData := row.AddCell()
- cellGData.Value = cygxService.GetArticleSourcePlatformText(item.RegisterPlatform)
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "客户参会记录导出数据_" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
|