user.go 203 KB

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