user.go 201 KB

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