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