user.go 202 KB

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