GroupsController.cs 424 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly GrpScheduleRepository _grpScheduleRep;
  76. private readonly IMapper _mapper;
  77. private readonly DelegationInfoRepository _groupRepository;
  78. private readonly TaskAssignmentRepository _taskAssignmentRep;
  79. private readonly AirTicketResRepository _airTicketResRep;
  80. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  81. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  82. private readonly DelegationEnDataRepository _delegationEnDataRep;
  83. private readonly DelegationVisaRepository _delegationVisaRep;
  84. private readonly VisaPriceRepository _visaPriceRep;
  85. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  86. private readonly HotelPriceRepository _hotelPriceRep;
  87. private readonly CustomersRepository _customersRep;
  88. private readonly MessageRepository _message;
  89. private readonly SqlSugarClient _sqlSugar;
  90. private readonly TourClientListRepository _tourClientListRep;
  91. private readonly TeamRateRepository _teamRateRep;
  92. #region 成本相关
  93. private readonly CheckBoxsRepository _checkBoxs;
  94. private readonly GroupCostRepository _GroupCostRepository;
  95. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  96. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  97. #endregion
  98. private readonly SetDataRepository _setDataRep;
  99. private string url;
  100. private string path;
  101. private readonly EnterExitCostRepository _enterExitCostRep;
  102. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  103. private readonly UsersRepository _usersRep;
  104. private readonly IJuHeApiService _juHeApi;
  105. private readonly InvertedListRepository _invertedListRep;
  106. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  107. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  108. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  109. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  110. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  111. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  112. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  113. InvertedListRepository invertedListRep)
  114. {
  115. _mapper = mapper;
  116. _grpScheduleRep = grpScheduleRep;
  117. _groupRepository = groupRepository;
  118. _taskAssignmentRep = taskAssignmentRep;
  119. _airTicketResRep = airTicketResRep;
  120. _sqlSugar = sqlSugar;
  121. url = AppSettingsHelper.Get("ExcelBaseUrl");
  122. path = AppSettingsHelper.Get("ExcelBasePath");
  123. if (!System.IO.Directory.Exists(path))
  124. {
  125. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  126. }
  127. _decreasePaymentsRep = decreasePaymentsRep;
  128. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  129. _delegationEnDataRep = delegationEnDataRep;
  130. _enterExitCostRep = enterExitCostRep;
  131. _delegationVisaRep = delegationVisaRep;
  132. _message = message;
  133. _visaPriceRep = visaPriceRep;
  134. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  135. _checkBoxs = checkBoxs;
  136. _GroupCostRepository = GroupCostRepository;
  137. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  138. _GroupCostParameterRepository = GroupCostParameterRepository;
  139. _hotelPriceRep = hotelPriceRep;
  140. _customersRep = customersRep;
  141. _setDataRep = setDataRep;
  142. _tourClientListRep = tourClientListRep;
  143. _teamRateRep = teamRateRep;
  144. _hubContext = hubContext;
  145. _usersRep = usersRep;
  146. _juHeApi = juHeApi;
  147. _invertedListRep = invertedListRep;
  148. }
  149. #region 流程管控
  150. /// <summary>
  151. /// 获取团组流程管控信息
  152. /// </summary>
  153. /// <param name="paras">参数Json字符串</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  158. {
  159. if (string.IsNullOrEmpty(_jsonDto.Paras))
  160. {
  161. return Ok(JsonView(false, "参数为空"));
  162. }
  163. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  164. if (_ScheduleDto != null)
  165. {
  166. if (_ScheduleDto.SearchType == 2)//获取列表
  167. {
  168. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  169. return Ok(JsonView(_grpScheduleViewList));
  170. }
  171. else//获取对象
  172. {
  173. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  174. if (_grpScheduleView != null)
  175. {
  176. return Ok(JsonView(_grpScheduleView));
  177. }
  178. }
  179. }
  180. else
  181. {
  182. return Ok(JsonView(false, "参数反序列化失败"));
  183. }
  184. return Ok(JsonView(false, "暂无数据!"));
  185. }
  186. /// <summary>
  187. /// 修改团组流程管控详细表数据
  188. /// </summary>
  189. /// <param name="paras"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  193. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  194. {
  195. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  196. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  197. .SetColumns(it => it.Duty == _detail.Duty)
  198. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  199. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  200. .SetColumns(it => it.JobContent == _detail.JobContent)
  201. .SetColumns(it => it.Remark == _detail.Remark)
  202. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  203. .Where(s => s.Id == dto.Id)
  204. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  205. .ExecuteCommandAsync();
  206. if (result > 0)
  207. {
  208. return Ok(JsonView(true, "保存成功!"));
  209. }
  210. return Ok(JsonView(false, "保存失败!"));
  211. }
  212. /// <summary>
  213. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  214. /// </summary>
  215. /// <param name="dto"></param>
  216. /// <returns></returns>
  217. [HttpPost]
  218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  219. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  220. {
  221. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  222. _detail.IsDel = 1;
  223. _detail.DeleteUserId = dto.Duty;
  224. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  225. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  226. .SetColumns(it => it.IsDel == _detail.IsDel)
  227. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  228. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  229. .Where(it => it.Id == dto.Id)
  230. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  231. //.WhereColumns(s => s.Id == dto.Id)
  232. .ExecuteCommandAsync();
  233. if (result > 0)
  234. {
  235. return Ok(JsonView(true, "删除成功!"));
  236. }
  237. return Ok(JsonView(false, "删除失败!"));
  238. }
  239. /// <summary>
  240. /// 增加团组流程管控详细表数据
  241. /// </summary>
  242. /// <param name="dto"></param>
  243. /// <returns></returns>
  244. [HttpPost]
  245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  246. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  247. {
  248. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  249. if (DateTime.Now < _detail.ExpectBeginDt)
  250. {
  251. _detail.StepStatus = 0;
  252. }
  253. else
  254. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  255. _detail.StepStatus = 1;
  256. }
  257. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  258. if (result > 0)
  259. {
  260. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  261. return Ok(JsonView(true, "添加成功!", _result));
  262. }
  263. return Ok(JsonView(false, "添加失败!"));
  264. }
  265. #endregion
  266. #region 团组基本信息
  267. /// <summary>
  268. /// 接团信息列表
  269. /// </summary>
  270. /// <param name="dto">团组列表请求dto</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  275. {
  276. var groupData = await _groupRepository.GetGroupList(dto);
  277. if (groupData.Code != 0)
  278. {
  279. return Ok(JsonView(false, groupData.Msg));
  280. }
  281. return Ok(JsonView(groupData.Data));
  282. }
  283. /// <summary>
  284. /// 接团信息列表 Page
  285. /// </summary>
  286. /// <param name="dto">团组列表请求dto</param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  290. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  291. {
  292. #region 参数验证
  293. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  294. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  295. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  296. #region 页面操作权限验证
  297. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  298. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  299. #endregion
  300. #endregion
  301. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  302. {
  303. string sqlWhere = string.Empty;
  304. if (dto.IsSure == 0) //未完成
  305. {
  306. sqlWhere += string.Format(@" And IsSure = 0");
  307. }
  308. else if (dto.IsSure == 1) //已完成
  309. {
  310. sqlWhere += string.Format(@" And IsSure = 1");
  311. }
  312. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  313. {
  314. string tj = dto.SearchCriteria;
  315. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  316. tj, tj, tj, tj, tj);
  317. }
  318. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  319. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  320. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  321. JietuanOperator,IsSure,CreateTime
  322. From (
  323. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  324. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  325. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  326. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  327. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  328. From Grp_DelegationInfo gdi
  329. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  330. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  331. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  332. Where gdi.IsDel = 0 {0}
  333. ) temp", sqlWhere);
  334. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  335. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  336. #region 处理所属部门
  337. /*
  338. * 1.sq 和 gyy 等显示 市场部
  339. * 2.王鸽和主管及张总还有管理员号统一国交部
  340. * 2-1. 4 管理员 ,21 张海麟
  341. */
  342. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  343. List<int> userIds1 = new List<int>() { 4, 21 };
  344. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  345. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  346. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  347. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  348. .ToList();
  349. foreach (var item in _DelegationList)
  350. {
  351. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  352. }
  353. #endregion
  354. var _view = new
  355. {
  356. PageFuncAuth = pageFunAuthView,
  357. Data = _DelegationList
  358. };
  359. return Ok(JsonView(true, "查询成功!", _view, total));
  360. }
  361. else
  362. {
  363. return Ok(JsonView(false, "查询失败"));
  364. }
  365. }
  366. /// <summary>
  367. /// 团组列表
  368. /// </summary>
  369. /// <returns></returns>
  370. [HttpPost]
  371. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  372. {
  373. #region 参数验证
  374. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  375. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  376. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  377. #region 页面操作权限验证
  378. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  379. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  380. #endregion
  381. #endregion
  382. if (dto.PortType != 1 && dto.PortType != 2)
  383. {
  384. return Ok(JsonView(false, "查询失败!"));
  385. }
  386. string orderbyStr = "order by gdi.CreateTime Desc";
  387. string sqlWhere = string.Empty;
  388. if (dto.IsSure == 0) //未完成
  389. {
  390. sqlWhere += string.Format(@" And IsSure = 0");
  391. }
  392. else if (dto.IsSure == 1) //已完成
  393. {
  394. sqlWhere += string.Format(@" And IsSure = 1");
  395. }
  396. //团组类型
  397. if (dto.TeamDid > 0)
  398. {
  399. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  400. }
  401. //团组名称
  402. if (!string.IsNullOrEmpty(dto.TeamName))
  403. {
  404. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  405. }
  406. //客户名称
  407. if (!string.IsNullOrEmpty(dto.ClientName))
  408. {
  409. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  410. }
  411. //客户单位
  412. if (!string.IsNullOrEmpty(dto.ClientUnit))
  413. {
  414. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  415. }
  416. //出访时间
  417. if (!string.IsNullOrEmpty(dto.visitDataTime))
  418. {
  419. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  420. orderbyStr = "order by gdi.VisitDate";
  421. }
  422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  424. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  425. JietuanOperator,IsSure,CreateTime
  426. From (
  427. Select row_number() over({0}) as Row_Number,
  428. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  429. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  430. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  431. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  432. From Grp_DelegationInfo gdi
  433. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  434. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  435. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  436. Where gdi.IsDel = 0 {1}
  437. ) temp ", orderbyStr, sqlWhere);
  438. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  439. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  440. #region 处理所属部门
  441. /*
  442. * 1.sq 和 gyy 等显示 市场部
  443. * 2.王鸽和主管及张总还有管理员号统一国交部
  444. * 2-1. 4 管理员 ,21 张海麟
  445. */
  446. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  447. List<int> userIds1 = new List<int>() { 4, 21 };
  448. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  449. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  450. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  451. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  452. .ToList();
  453. foreach (var item in _DelegationList)
  454. {
  455. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  456. }
  457. #endregion
  458. var _view = new
  459. {
  460. PageFuncAuth = pageFunAuthView,
  461. Data = _DelegationList
  462. };
  463. return Ok(JsonView(true, "查询成功!", _view, total));
  464. }
  465. /// <summary>
  466. /// 接团信息详情
  467. /// </summary>
  468. /// <param name="dto">团组info请求dto</param>
  469. /// <returns></returns>
  470. [HttpPost]
  471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  472. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  473. {
  474. var groupData = await _groupRepository.GetGroupInfo(dto);
  475. if (groupData.Code != 0)
  476. {
  477. return Ok(JsonView(false, groupData.Msg));
  478. }
  479. return Ok(JsonView(groupData.Data));
  480. }
  481. /// <summary>
  482. /// 接团信息 编辑添加
  483. /// 基础信息数据源
  484. /// </summary>
  485. /// <param name="dto"></param>
  486. /// <returns></returns>
  487. [HttpPost]
  488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  489. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  490. {
  491. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  492. if (groupData.Code != 0)
  493. {
  494. return Ok(JsonView(false, groupData.Msg));
  495. }
  496. return Ok(JsonView(groupData.Data));
  497. }
  498. /// <summary>
  499. /// 接团信息 操作(增改)
  500. /// </summary>
  501. /// <param name="dto"></param>
  502. /// <returns></returns>
  503. [HttpPost]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  506. {
  507. try
  508. {
  509. var groupData = await _groupRepository.GroupOperation(dto);
  510. if (groupData.Code != 0)
  511. {
  512. return Ok(JsonView(false, groupData.Msg));
  513. }
  514. int diId = 0;
  515. //添加时 默认加入团组汇率
  516. if (dto.Status == 1) //添加
  517. {
  518. diId = groupData.Data;
  519. //添加默认币种
  520. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  521. //默认分配权限
  522. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  523. //消息提示 王鸽 主管号
  524. List<int> _managerIds = new List<int>() { 22, 32 };
  525. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  526. if (userIds.Count > 0)
  527. {
  528. userIds.Add(208);
  529. //创建团组管控
  530. GroupStepForDelegation.CreateWorkStep(diId);
  531. //发送消息
  532. string groupName = dto.TeamName;
  533. string createGroupUser = string.Empty;
  534. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  535. if (userInfo != null) createGroupUser = userInfo.CnName;
  536. string title = $"系统通知";
  537. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  538. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  539. }
  540. //默认创建倒推表
  541. await _invertedListRep._Create(dto.UserId, diId);
  542. }
  543. else if (dto.Status == 2)
  544. {
  545. diId = dto.Id;
  546. }
  547. return Ok(JsonView(true, "操作成功!", diId));
  548. }
  549. catch (Exception ex)
  550. {
  551. Logs("[response]" + JsonConvert.SerializeObject(dto));
  552. Logs(ex.Message);
  553. return Ok(JsonView(false, ex.Message));
  554. }
  555. }
  556. /// <summary>
  557. /// 接团流程操作(增改)
  558. /// 安卓端使用 建团时添加客户名单
  559. /// </summary>
  560. /// <param name="dto"></param>
  561. /// <returns></returns>
  562. [HttpPost]
  563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  564. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  565. {
  566. try
  567. {
  568. #region 参数验证
  569. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  571. #region 页面操作权限验证
  572. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  573. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  574. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  575. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  576. #endregion
  577. #endregion
  578. _sqlSugar.BeginTran();
  579. var _dto = new GroupOperationDto();
  580. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  581. var groupData = await _groupRepository.GroupOperation(_dto);
  582. if (groupData.Code != 0)
  583. {
  584. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  585. }
  586. int diId = 0;
  587. //添加时 默认加入团组汇率
  588. if (dto.Status == 1) //添加
  589. {
  590. diId = groupData.Data;
  591. //添加默认币种
  592. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  593. //默认分配权限
  594. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  595. //消息提示 王鸽 主管号
  596. List<int> _managerIds = new List<int>() { 22, 32 };
  597. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  598. if (userIds.Count > 0)
  599. {
  600. userIds.Add(208);
  601. //创建团组管控
  602. GroupStepForDelegation.CreateWorkStep(diId);
  603. //发送消息
  604. string groupName = dto.TeamName;
  605. string createGroupUser = string.Empty;
  606. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  607. if (userInfo != null) createGroupUser = userInfo.CnName;
  608. string title = $"系统通知";
  609. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  610. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  611. }
  612. }
  613. if (dto.Status == 2)
  614. {
  615. diId = dto.Id;
  616. if (diId == 0)
  617. {
  618. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  619. }
  620. }
  621. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  622. if (viewData.Code != 0)
  623. {
  624. _sqlSugar.RollbackTran();
  625. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  626. }
  627. _sqlSugar.CommitTran();
  628. return Ok(JsonView(true, "添加成功"));
  629. }
  630. catch (Exception ex)
  631. {
  632. _sqlSugar.RollbackTran();
  633. return Ok(JsonView(false, ex.Message));
  634. }
  635. }
  636. /// <summary>
  637. /// 接团信息 操作(删除)
  638. /// </summary>
  639. /// <param name="dto"></param>
  640. /// <returns></returns>
  641. [HttpPost]
  642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  643. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  644. {
  645. try
  646. {
  647. var groupData = await _groupRepository.GroupDel(dto);
  648. if (groupData.Code != 0)
  649. {
  650. return Ok(JsonView(false, groupData.Msg));
  651. }
  652. return Ok(JsonView(true));
  653. }
  654. catch (Exception ex)
  655. {
  656. Logs("[response]" + JsonConvert.SerializeObject(dto));
  657. Logs(ex.Message);
  658. return Ok(JsonView(false, ex.Message));
  659. }
  660. }
  661. /// <summary>
  662. /// 获取团组销售报价号
  663. /// 团组添加时 使用
  664. /// </summary>
  665. /// <returns></returns>
  666. [HttpPost]
  667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  668. public async Task<IActionResult> GetGroupSalesQuoteNo()
  669. {
  670. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  671. if (groupData.Code != 0)
  672. {
  673. return Ok(JsonView(false, groupData.Msg));
  674. }
  675. object salesQuoteNo = new
  676. {
  677. SalesQuoteNo = groupData.Data
  678. };
  679. return Ok(JsonView(salesQuoteNo));
  680. }
  681. /// <summary>
  682. /// 设置确认出团
  683. /// </summary>
  684. /// <param name="dto"></param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  689. {
  690. var groupData = await _groupRepository.ConfirmationGroup(dto);
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, groupData.Msg));
  694. }
  695. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  696. return Ok(JsonView(true, "操作成功!", groupData.Data));
  697. }
  698. /// <summary>
  699. /// 获取团组名称data And 签证国别Data
  700. /// </summary>
  701. /// <param name="dto"></param>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  706. {
  707. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. return Ok(JsonView(groupData.Data));
  713. }
  714. /// <summary>
  715. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  716. /// </summary>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  721. {
  722. try
  723. {
  724. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  725. if (groupData.Code != 0)
  726. {
  727. return Ok(JsonView(false, groupData.Msg));
  728. }
  729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  730. }
  731. catch (Exception ex)
  732. {
  733. return Ok(JsonView(false, "程序错误!"));
  734. throw;
  735. }
  736. }
  737. #endregion
  738. #region 团组&签证
  739. /// <summary>
  740. /// 根据团组Id获取签证客户信息List
  741. /// </summary>
  742. /// <param name="dto">请求dto</param>
  743. /// <returns></returns>
  744. [HttpPost]
  745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  746. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  747. {
  748. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  749. if (groupData.Code != 0)
  750. {
  751. return Ok(JsonView(false, groupData.Msg));
  752. }
  753. return Ok(JsonView(groupData.Data));
  754. }
  755. /// <summary>
  756. /// IOS获取团组签证拍照上传进度01(团组列表)
  757. /// </summary>
  758. /// <param name="dto">请求dto</param>
  759. /// <returns></returns>
  760. [HttpPost]
  761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  762. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  763. {
  764. if (dto == null)
  765. {
  766. return Ok(JsonView(false, "参数为空"));
  767. }
  768. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  769. return Ok(JsonView(visaList));
  770. }
  771. /// <summary>
  772. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  773. /// </summary>
  774. /// <returns></returns>
  775. [HttpPost]
  776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  777. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  778. {
  779. if (dto == null)
  780. {
  781. return Ok(JsonView(false, "请求错误:"));
  782. }
  783. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  784. return Ok(JsonView(list));
  785. }
  786. /// <summary>
  787. /// IOS获取团组签证拍照上传进度03(相册)
  788. /// </summary>
  789. /// <returns></returns>
  790. [HttpPost]
  791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  792. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  793. {
  794. if (dto == null)
  795. {
  796. return Ok(JsonView(false, "请求错误:"));
  797. }
  798. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  799. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  800. list.ForEach(s => s.url = url);
  801. return Ok(JsonView(list));
  802. }
  803. /// <summary>
  804. /// IOS获取团组签证拍照上传进度04(图片上传)
  805. /// </summary>
  806. /// <param name="dto"></param>
  807. /// <returns></returns>
  808. [HttpPost]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  811. {
  812. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  813. //if (!string.IsNullOrEmpty(result))
  814. //{
  815. //}
  816. //else {
  817. // return Ok(JsonView(false, "上传失败"));
  818. //}
  819. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  820. int sucNum = 0;
  821. try
  822. {
  823. foreach (var item in dto.base64DataList)
  824. {
  825. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  826. string result = decodeBase64ToImage(item, imageName);
  827. if (!string.IsNullOrEmpty(result))
  828. {
  829. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  830. pic.CreateUserId = dto.CreateUserId;
  831. pic.PicName = imageName;
  832. pic.PicPath = result;
  833. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  834. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  835. if (insertResult > 0)
  836. {
  837. sucNum++;
  838. }
  839. }
  840. }
  841. }
  842. catch (Exception ex)
  843. {
  844. return Ok(JsonView(false, ex.Message));
  845. }
  846. string msg = string.Format(@"成功上传{0}张", sucNum);
  847. return Ok(JsonView(true, msg));
  848. }
  849. private string decodeBase64ToImage(string base64DataURL, string imgName)
  850. {
  851. string filename = "";//声明一个string类型的相对路径
  852. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  853. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  854. try//会有异常抛出,try,catch一下
  855. {
  856. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  857. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  858. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  859. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  860. //文件名称
  861. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  862. //上传的文件的路径
  863. string filePath = "";
  864. if (!Directory.Exists(fileDir))
  865. {
  866. Directory.CreateDirectory(fileDir);
  867. }
  868. //上传的文件的路径
  869. filePath = fileDir + filename;
  870. //string url = HttpRuntime.AppDomainAppPath.ToString();
  871. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  872. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  873. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  874. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  875. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  876. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  877. ms.Close();//关闭当前流,并释放所有与之关联的资源
  878. bitmap.Dispose();
  879. }
  880. catch (Exception e)
  881. {
  882. string massage = e.Message;
  883. Logs("IOS图片上传Error:" + massage);
  884. //filename = e.Message;
  885. }
  886. return filename;//返回相对路径
  887. }
  888. /// <summary>
  889. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  890. /// </summary>
  891. /// <param name="dto"></param>
  892. /// <returns></returns>
  893. [HttpPost]
  894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  895. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  896. {
  897. if (dto == null)
  898. {
  899. return Ok(JsonView(false, "请求错误:"));
  900. }
  901. string msg = "参数错误";
  902. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  903. {
  904. try
  905. {
  906. //_delegationVisaRep.BeginTran();
  907. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  908. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  909. .Where(s => s.Id == dto.visaProgressCustomerId)
  910. .ExecuteCommandAsync();
  911. if (updCount > 0 && dto.publishCode == 1)
  912. {
  913. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  914. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  915. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  916. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  917. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  918. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  919. if (groupData == null)
  920. {
  921. _delegationVisaRep.RollbackTran();
  922. }
  923. string title = string.Format(@"[签证进度更新]");
  924. string content = string.Format(@"测试文本");
  925. bool rst = await _message.AddMsg(new MessageDto()
  926. {
  927. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  928. IssuerId = dto.publisher,
  929. Title = title,
  930. Content = content,
  931. ReleaseTime = DateTime.Now,
  932. UIdList = new List<int> {
  933. 234
  934. }
  935. });
  936. if (rst)
  937. {
  938. return Ok(JsonView(true, "发送通知成功"));
  939. }
  940. }
  941. //_delegationVisaRep.CommitTran();
  942. }
  943. catch (Exception)
  944. {
  945. //_delegationVisaRep.RollbackTran();
  946. }
  947. }
  948. return Ok(JsonView(true, msg));
  949. }
  950. #endregion
  951. #region 团组任务分配
  952. /// <summary>
  953. /// 团组任务分配初始化
  954. /// </summary>
  955. /// <param name="dto"></param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<IActionResult> GetTaskAssignmen()
  960. {
  961. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  962. if (groupData.Code != 0)
  963. {
  964. return Ok(JsonView(false, groupData.Msg));
  965. }
  966. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  967. }
  968. /// <summary>
  969. /// 团组任务分配查询
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  976. {
  977. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  983. }
  984. /// <summary>
  985. /// 团组任务分配操作
  986. /// </summary>
  987. /// <param name="dto"></param>
  988. /// <returns></returns>
  989. [HttpPost]
  990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  991. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  992. {
  993. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  994. if (groupData.Code != 0)
  995. {
  996. return Ok(JsonView(false, groupData.Msg));
  997. }
  998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  999. }
  1000. #endregion
  1001. #region 团组费用审核
  1002. /// <summary>
  1003. /// 费用审核
  1004. /// 团组列表 Page
  1005. /// </summary>
  1006. /// <param name="_dto">团组列表请求dto</param>
  1007. /// <returns></returns>
  1008. [HttpPost]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1011. {
  1012. #region 参数验证
  1013. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1014. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1015. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1016. #region 页面操作权限验证
  1017. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1018. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1019. #endregion
  1020. #endregion
  1021. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1022. {
  1023. string sqlWhere = string.Empty;
  1024. if (_dto.IsSure == 0) //未完成
  1025. {
  1026. sqlWhere += string.Format(@" And IsSure = 0");
  1027. }
  1028. else if (_dto.IsSure == 1) //已完成
  1029. {
  1030. sqlWhere += string.Format(@" And IsSure = 1");
  1031. }
  1032. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1033. {
  1034. string tj = _dto.SearchCriteria;
  1035. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  1036. tj, tj, tj, tj, tj);
  1037. }
  1038. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1039. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1040. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1041. From (
  1042. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1043. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1044. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1045. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1046. From Grp_DelegationInfo gdi
  1047. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1048. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1049. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1050. Where gdi.IsDel = 0 {0}
  1051. ) temp ", sqlWhere);
  1052. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1053. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1054. var _view = new
  1055. {
  1056. PageFuncAuth = pageFunAuthView,
  1057. Data = _DelegationList
  1058. };
  1059. return Ok(JsonView(true, "查询成功!", _view, total));
  1060. }
  1061. else
  1062. {
  1063. return Ok(JsonView(false, "查询失败"));
  1064. }
  1065. }
  1066. /// <summary>
  1067. /// 获取团组费用审核
  1068. /// </summary>
  1069. /// <param name="paras">参数Json字符串</param>
  1070. /// <returns></returns>
  1071. [HttpPost]
  1072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1073. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1074. {
  1075. try
  1076. {
  1077. #region 参数验证
  1078. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1079. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1080. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1082. #region 页面操作权限验证
  1083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1084. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1085. #endregion
  1086. #endregion
  1087. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1088. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1089. #region 费用清单
  1090. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1091. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1092. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1093. List<Grp_CreditCardPayment> entityList = _groupRepository
  1094. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1095. .Where(exp.ToExpression())
  1096. .ToList();
  1097. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1098. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1099. /*
  1100. * 76://酒店预订
  1101. */
  1102. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1103. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1104. .ToListAsync();
  1105. /*
  1106. * 79://车/导游地接
  1107. */
  1108. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1109. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1110. .ToListAsync();
  1111. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1112. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1113. .ToListAsync();
  1114. /*
  1115. * 80: //签证
  1116. */
  1117. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1118. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1119. .ToListAsync();
  1120. /*
  1121. *81: //邀请/公务活动
  1122. */
  1123. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1124. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1125. .ToListAsync();
  1126. /*
  1127. * 82: //团组客户保险
  1128. */
  1129. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1130. /*
  1131. * Lable = 85 机票预订
  1132. */
  1133. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1134. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1135. .ToListAsync();
  1136. /*
  1137. * 85 机票预定
  1138. */
  1139. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1140. /*
  1141. * 98 其他款项
  1142. */
  1143. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1144. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1145. .ToListAsync();
  1146. /*
  1147. * 285:收款退还
  1148. */
  1149. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1150. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1151. .ToListAsync();
  1152. /*
  1153. * 1015: //超支费用
  1154. */
  1155. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1156. /*
  1157. * 币种信息
  1158. */
  1159. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1160. /*
  1161. * 车/导游地接 费用类型
  1162. */
  1163. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1164. /*
  1165. * 用户信息
  1166. */
  1167. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1168. /*
  1169. * 费用模块
  1170. */
  1171. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1172. string priceModule = string.Empty;
  1173. if (sdPriceName != null)
  1174. {
  1175. priceModule = sdPriceName.Name;
  1176. }
  1177. /*
  1178. * 处理详情数据
  1179. */
  1180. foreach (var entity in entityList)
  1181. {
  1182. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1183. _detail.Id = entity.Id;
  1184. _detail.PriceName = priceModule;
  1185. /*
  1186. * 应付款金额
  1187. */
  1188. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1189. string PaymentCurrency_WaitPay = "Unknown";
  1190. string hotelCurrncyCode = "Unknown";
  1191. string hotelCurrncyName = "Unknown";
  1192. if (sdPaymentCurrency_WaitPay != null)
  1193. {
  1194. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1195. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1196. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1197. if (hotelCurrncyCode.Equals("CNY"))
  1198. {
  1199. entity.DayRate = 1.0000M;
  1200. }
  1201. }
  1202. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1203. /*
  1204. * 此次付款金额
  1205. */
  1206. decimal CurrPayStr = 0;
  1207. if (entity.PayPercentage == 0)
  1208. {
  1209. if (entity.PayThenMoney != 0)
  1210. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1211. }
  1212. else
  1213. {
  1214. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1215. }
  1216. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1217. /*
  1218. * 剩余尾款
  1219. */
  1220. decimal BalanceStr = 0;
  1221. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1222. BalanceStr = 0;
  1223. else
  1224. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1225. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1226. /*
  1227. * Bus名称
  1228. */
  1229. _detail.BusName = "待增加";
  1230. /*
  1231. *费用所属
  1232. */
  1233. switch (entity.CTable)
  1234. {
  1235. case 76://酒店预订
  1236. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1237. if (hotelReservations != null)
  1238. {
  1239. string GovernmentRentCode = "", GovernmentRentName = "", CityTaxCode = "", CityTaxName = "", BreakfastCode = "", BreakfastName = "";
  1240. Sys_SetData sdPaymentCurrency_GovernmentRent = currencyItems.Where(s => s.Id == hotelReservations.GovernmentRentCurrency).FirstOrDefault();
  1241. if (sdPaymentCurrency_GovernmentRent != null)
  1242. {
  1243. GovernmentRentCode = sdPaymentCurrency_GovernmentRent.Name;
  1244. GovernmentRentName = sdPaymentCurrency_GovernmentRent.Remark;
  1245. }
  1246. Sys_SetData sdPaymentCurrency_CityTax = currencyItems.Where(s => s.Id == hotelReservations.CityTaxCurrency).FirstOrDefault();
  1247. if (sdPaymentCurrency_CityTax != null)
  1248. {
  1249. CityTaxCode = sdPaymentCurrency_CityTax.Name;
  1250. CityTaxName = sdPaymentCurrency_CityTax.Remark;
  1251. }
  1252. Sys_SetData sdPaymentCurrency_Breakfast = currencyItems.Where(s => s.Id == hotelReservations.BreakfastCurrency).FirstOrDefault();
  1253. if (sdPaymentCurrency_Breakfast != null)
  1254. {
  1255. BreakfastCode = sdPaymentCurrency_Breakfast.Name;
  1256. BreakfastName = sdPaymentCurrency_Breakfast.Remark;
  1257. }
  1258. string isoppayStr = hotelReservations.Isoppay == 0 ? "是" : "否";
  1259. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1260. $"房间说明: {hotelReservations.Remark} <br/>" +
  1261. $"地税: {hotelReservations.GovernmentRent.ToString("#0.00")} {GovernmentRentCode} ({GovernmentRentName})<br/>" +
  1262. $"城市税: {hotelReservations.CityTax.ToString("#0.00")} {CityTaxCode} ({CityTaxName})<br/>" +
  1263. $"酒店早餐: {hotelReservations.BreakfastPrice.ToString("#0.00")} {BreakfastCode} ({BreakfastName})<br/>" +
  1264. $"酒店早餐是否由地接代付: {isoppayStr}";
  1265. _detail.PriceNameContent = hotelReservations.HotelName;
  1266. }
  1267. break;
  1268. case 79://车/导游地接
  1269. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1270. if (touristGuideGroundReservations != null)
  1271. {
  1272. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1273. {
  1274. _detail.BusName = touristGuideGroundReservations.BusName;
  1275. }
  1276. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1277. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1278. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1279. string priceMsg = string.Empty;
  1280. foreach (var item in touristGuideGroundReservationsContents)
  1281. {
  1282. string typeName = "Unknown";
  1283. string carCurrencyCode = "Unknown";
  1284. string carCurrencyName = "Unknown";
  1285. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1286. if (carTypeData != null) typeName = carTypeData.Name;
  1287. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1288. if (currencyData != null) {
  1289. carCurrencyCode = currencyData.Name;
  1290. carCurrencyName = currencyData.Remark;
  1291. }
  1292. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1293. "明细:" + item.PriceContent + "<br/>" +
  1294. "备注:" + item.Remark + "<br/><br/>";
  1295. }
  1296. _detail.PriceMsgContent = priceMsg;
  1297. }
  1298. break;
  1299. case 80: //签证
  1300. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1301. if (visaInfo != null)
  1302. {
  1303. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1304. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  1305. }
  1306. break;
  1307. case 81: //邀请/公务活动
  1308. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1309. if (_ioa != null)
  1310. {
  1311. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1312. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1313. sendCurrName = "Unknown", //快递费用币种 Name
  1314. sendCurrCode = "Unknown", //快递费用币种 Code
  1315. eventsCurrName = "Unknown", //公务活动费币种 Name
  1316. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1317. translateCurrName = "Unknown", //公务翻译费 Name
  1318. translateCurrCode = "Unknown"; //公务翻译费 Code
  1319. #region 处理费用币种
  1320. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1321. if (inviteCurrData != null)
  1322. {
  1323. inviteCurrName = inviteCurrData.Remark;
  1324. inviteCurrCode = inviteCurrData.Name;
  1325. }
  1326. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1327. if (sendCurrData != null)
  1328. {
  1329. sendCurrName = sendCurrData.Remark;
  1330. sendCurrCode = sendCurrData.Name;
  1331. }
  1332. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1333. if (eventsCurrData != null)
  1334. {
  1335. eventsCurrName = eventsCurrData.Remark;
  1336. eventsCurrCode = eventsCurrData.Name;
  1337. }
  1338. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1339. if (translateCurrData != null)
  1340. {
  1341. translateCurrName = translateCurrData.Remark;
  1342. translateCurrCode = translateCurrData.Name;
  1343. }
  1344. #endregion
  1345. _detail.PriceNameContent = _ioa.InviterArea;
  1346. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1347. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1348. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1349. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1350. $@"备注:" + _ioa.Remark + "<br/>";
  1351. }
  1352. break;
  1353. case 82: //团组客户保险
  1354. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1355. if (customers != null)
  1356. {
  1357. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1358. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1359. }
  1360. break;
  1361. case 85: //机票预订
  1362. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1363. if (jpRes != null)
  1364. {
  1365. string FlightsDescription = jpRes.FlightsDescription;
  1366. string PriceDescription = jpRes.PriceDescription;
  1367. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1368. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1369. }
  1370. break;
  1371. case 98://其他款项
  1372. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1373. if (gdpRes != null)
  1374. {
  1375. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1376. _detail.PriceNameContent = gdpRes.PriceName;
  1377. }
  1378. break;
  1379. case 285://收款退还
  1380. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1381. if (refundAndOtherMoney != null)
  1382. {
  1383. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1384. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1385. }
  1386. break;
  1387. case 751://酒店早餐
  1388. break;
  1389. case 1015://超支费用
  1390. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1391. if (groupExtraCost != null) {
  1392. _detail.PriceNameContent = groupExtraCost.PriceName;
  1393. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1394. }
  1395. break;
  1396. default:
  1397. break;
  1398. }
  1399. /*
  1400. * 申请人
  1401. */
  1402. string operatorName = " - ";
  1403. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1404. if (_opUser != null)
  1405. {
  1406. operatorName = _opUser.CnName;
  1407. }
  1408. _detail.OperatorName = operatorName;
  1409. /*
  1410. * 审核人
  1411. */
  1412. string auditOperatorName = "Unknown";
  1413. if (entity.AuditGMOperate == 0)
  1414. auditOperatorName = " - ";
  1415. else if (entity.AuditGMOperate == 4)
  1416. auditOperatorName = "自动审核";
  1417. else
  1418. {
  1419. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1420. if (_adUser != null)
  1421. {
  1422. auditOperatorName = _adUser.CnName;
  1423. }
  1424. }
  1425. _detail.AuditOperatorName = auditOperatorName;
  1426. /*
  1427. * 超预算比例
  1428. */
  1429. string overBudgetStr = "";
  1430. if (entity.ExceedBudget == -1)
  1431. overBudgetStr = sdPriceName.Name + "尚无预算";
  1432. else if (entity.ExceedBudget == 0)
  1433. overBudgetStr = "未超预算";
  1434. else
  1435. overBudgetStr = entity.ExceedBudget.ToString("P");
  1436. _detail.OverBudget = overBudgetStr;
  1437. /*
  1438. * 费用总计
  1439. */
  1440. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1441. {
  1442. CurrencyId = entity.PaymentCurrency,
  1443. CurrencyName = PaymentCurrency_WaitPay,
  1444. AmountPayable = entity.PayMoney,
  1445. ThisPayment = CurrPayStr,
  1446. BalancePayment = BalanceStr,
  1447. AuditedFunds = CurrPayStr
  1448. });
  1449. _detail.IsAuditGM = entity.IsAuditGM;
  1450. detailList.Add(_detail);
  1451. }
  1452. #endregion
  1453. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1454. /*
  1455. * 下方描述处理
  1456. */
  1457. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1458. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1459. if (ccpCurrencyPrice != null)
  1460. {
  1461. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1462. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1463. }
  1464. else
  1465. {
  1466. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1467. }
  1468. string amountPayableStr = string.Format(@"应付款总金额: ");
  1469. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1470. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1471. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1472. foreach (var item in nonDuplicat)
  1473. {
  1474. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1475. if (strs.Count > 0)
  1476. {
  1477. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1478. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1479. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1480. //单独处理此次付款金额
  1481. if (item.CurrencyId == 836) //人民币
  1482. {
  1483. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1484. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1485. }
  1486. else
  1487. {
  1488. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1489. }
  1490. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1491. //单独处理已审核费用
  1492. if (item.CurrencyId == 836) //人民币
  1493. {
  1494. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1495. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1496. }
  1497. else
  1498. {
  1499. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1500. }
  1501. }
  1502. }
  1503. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1504. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1505. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1506. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1507. var _view1 = new
  1508. {
  1509. PageFuncAuth = pageFunAuthView,
  1510. Data = _view
  1511. };
  1512. return Ok(JsonView(_view1));
  1513. }
  1514. catch (Exception ex)
  1515. {
  1516. return Ok(JsonView(false, ex.Message));
  1517. }
  1518. }
  1519. /// <summary>
  1520. /// 费用审核
  1521. /// 修改团组费用审核状态
  1522. /// </summary>
  1523. /// <param name="_dto">参数Json字符串</param>
  1524. /// <returns></returns>
  1525. [HttpPost]
  1526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1527. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1528. {
  1529. #region 参数验证
  1530. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1531. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1532. #endregion
  1533. #region 页面操作权限验证
  1534. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1535. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1536. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1537. #endregion
  1538. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1539. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1540. DateTime dtNow = DateTime.Now;
  1541. _groupRepository.BeginTran();
  1542. int rst = 0;
  1543. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1544. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1545. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1546. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1547. List<dynamic> msgDatas = new List<dynamic>();
  1548. foreach (var item in idList)
  1549. {
  1550. int CreditId = int.Parse(item);
  1551. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1552. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1553. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1554. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1555. .Where(s => s.Id == CreditId)
  1556. .ExecuteCommandAsync();
  1557. if (result < 1)
  1558. {
  1559. rst = -1;
  1560. _groupRepository.RollbackTran();
  1561. return Ok(JsonView(false, "操作失败并回滚!"));
  1562. }
  1563. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1564. if (creditData != null)
  1565. {
  1566. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1567. string groupNameStr = string.Empty;
  1568. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1569. if (groupData != null) groupNameStr = groupData.TeamName;
  1570. string creditTypeStr = string.Empty;
  1571. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1572. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1573. string creditCurrency = string.Empty;
  1574. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1575. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1576. if (creditCurrency.Equals("CNY"))
  1577. {
  1578. creditData.DayRate = 1.0000M;
  1579. }
  1580. if (creditData.PayPercentage == 0.00M)
  1581. {
  1582. creditData.PayPercentage = 100M;
  1583. }
  1584. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1585. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1586. string msgContent = "";
  1587. if (creditCurrency.Equals("CNY"))
  1588. {
  1589. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1590. }
  1591. else
  1592. {
  1593. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1594. }
  1595. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1596. }
  1597. }
  1598. if (rst == 0)
  1599. {
  1600. _groupRepository.CommitTran();
  1601. foreach (var item in msgDatas)
  1602. {
  1603. //发送消息
  1604. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1605. }
  1606. return Ok(JsonView(true, "操作成功!"));
  1607. }
  1608. return Ok(JsonView(false, "操作失败!"));
  1609. }
  1610. #endregion
  1611. #region 机票费用录入
  1612. /// <summary>
  1613. /// 机票录入当前登录人可操作团组
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1620. {
  1621. try
  1622. {
  1623. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1624. if (groupData.Code != 0)
  1625. {
  1626. return Ok(JsonView(false, groupData.Msg));
  1627. }
  1628. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1629. }
  1630. catch (Exception ex)
  1631. {
  1632. return Ok(JsonView(false, "程序错误!"));
  1633. throw;
  1634. }
  1635. }
  1636. /// <summary>
  1637. /// 机票费用录入列表
  1638. /// </summary>
  1639. /// <param name="dto"></param>
  1640. /// <returns></returns>
  1641. [HttpPost]
  1642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1643. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1644. {
  1645. try
  1646. {
  1647. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1648. if (groupData.Code != 0)
  1649. {
  1650. return Ok(JsonView(false, groupData.Msg));
  1651. }
  1652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. return Ok(JsonView(false, "程序错误!"));
  1657. throw;
  1658. }
  1659. }
  1660. /// <summary>
  1661. /// 根据id查询费用录入信息
  1662. /// </summary>
  1663. /// <param name="dto"></param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1668. {
  1669. try
  1670. {
  1671. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1672. if (groupData.Code != 0)
  1673. {
  1674. return Ok(JsonView(false, groupData.Msg));
  1675. }
  1676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1677. }
  1678. catch (Exception ex)
  1679. {
  1680. return Ok(JsonView(false, "程序错误!"));
  1681. throw;
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 机票费用录入操作(Status:1.新增,2.修改)
  1686. /// </summary>
  1687. /// <param name="dto"></param>
  1688. /// <returns></returns>
  1689. [HttpPost]
  1690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1691. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1692. {
  1693. try
  1694. {
  1695. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1696. if (groupData.Code != 0)
  1697. {
  1698. return Ok(JsonView(false, groupData.Msg));
  1699. }
  1700. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1701. }
  1702. catch (Exception ex)
  1703. {
  1704. return Ok(JsonView(false, "程序错误!"));
  1705. throw;
  1706. }
  1707. }
  1708. /// <summary>
  1709. /// 根据舱位类型查询接团客户名单信息
  1710. /// </summary>
  1711. /// <param name="dto"></param>
  1712. /// <returns></returns>
  1713. [HttpPost]
  1714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1715. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1716. {
  1717. try
  1718. {
  1719. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1720. if (crm_Groups.Count != 0)
  1721. {
  1722. List<dynamic> Customer = new List<dynamic>();
  1723. foreach (var item in crm_Groups)
  1724. {
  1725. var data = new
  1726. {
  1727. Id = item.Id,
  1728. Pinyin = item.Pinyin,
  1729. Name = item.LastName + item.FirstName
  1730. };
  1731. Customer.Add(data);
  1732. }
  1733. return Ok(JsonView(true, "查询成功!", Customer));
  1734. }
  1735. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1736. }
  1737. catch (Exception ex)
  1738. {
  1739. return Ok(JsonView(false, "程序错误!"));
  1740. throw;
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 根据团号获取客户信息
  1745. /// </summary>
  1746. /// <param name="dto"></param>
  1747. /// <returns></returns>
  1748. [HttpPost]
  1749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1750. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1751. {
  1752. var jw = JsonView(false);
  1753. if (dto.DIID < 1)
  1754. {
  1755. jw.Msg += "请输入正确的diid";
  1756. return Ok(jw);
  1757. }
  1758. var arr = getSimplClientList(dto.DIID);
  1759. jw = JsonView(true, "获取成功!", arr);
  1760. return Ok(jw);
  1761. }
  1762. private List<SimplClientInfo> getSimplClientList(int diId) {
  1763. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  1764. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1765. return arr;
  1766. }
  1767. private string getClientNameStr(List<SimplClientInfo> list, string origin) {
  1768. string result = origin;
  1769. if (Regex.Match(origin, @"\d+,?").Value.Length > 0) {
  1770. string[] temparr = origin.Split(',');
  1771. string fistrStr = temparr[0];
  1772. int count = temparr.Count();
  1773. int tempId;
  1774. bool success = int.TryParse(fistrStr, out tempId);
  1775. if (success) {
  1776. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1777. if (tempInfo != null) {
  1778. if (count > 1)
  1779. {
  1780. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1781. }
  1782. else {
  1783. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1784. }
  1785. }
  1786. }
  1787. }
  1788. return result;
  1789. }
  1790. /// <summary>
  1791. /// 机票费用录入,删除
  1792. /// </summary>
  1793. /// <param name="dto"></param>
  1794. /// <returns></returns>
  1795. [HttpPost]
  1796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1797. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1798. {
  1799. try
  1800. {
  1801. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1802. if (res)
  1803. {
  1804. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1805. {
  1806. IsDel = 1,
  1807. DeleteUserId = dto.DeleteUserId,
  1808. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1809. }).ExecuteCommandAsync();
  1810. return Ok(JsonView(true, "删除成功!"));
  1811. }
  1812. return Ok(JsonView(false, "删除失败!"));
  1813. }
  1814. catch (Exception ex)
  1815. {
  1816. return Ok(JsonView(false, "程序错误!"));
  1817. throw;
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// 导出机票录入报表
  1822. /// </summary>
  1823. /// <param name="dto"></param>
  1824. /// <returns></returns>
  1825. [HttpPost]
  1826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1827. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1828. {
  1829. try
  1830. {
  1831. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1832. if (groupData.Code != 0)
  1833. {
  1834. return Ok(JsonView(false, groupData.Msg));
  1835. }
  1836. else
  1837. {
  1838. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1839. if (AirTicketReservations.Count != 0)
  1840. {
  1841. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1842. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1843. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1844. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1845. WorkbookDesigner designer = new WorkbookDesigner();
  1846. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1847. decimal countCost = 0;
  1848. foreach (var item in AirTicketReservations)
  1849. {
  1850. if (item.BankType == "其他")
  1851. {
  1852. item.BankNo = "--";
  1853. }
  1854. else
  1855. {
  1856. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  1857. }
  1858. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1859. item.Price = System.Decimal.Round(item.Price, 2);
  1860. countCost += Convert.ToDecimal(item.Price);
  1861. }
  1862. designer.SetDataSource("Export", AirTicketReservations);
  1863. designer.SetDataSource("ExportDiCode", diCode);
  1864. designer.SetDataSource("ExportDiName", diName);
  1865. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1866. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1867. designer.Process();
  1868. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  1869. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1870. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1871. return Ok(JsonView(true, "成功", url = rst));
  1872. }
  1873. else
  1874. {
  1875. return Ok(JsonView(false, "暂无数据!"));
  1876. }
  1877. }
  1878. }
  1879. catch (Exception ex)
  1880. {
  1881. return Ok(JsonView(false, "程序错误!"));
  1882. throw;
  1883. }
  1884. }
  1885. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1886. /// <summary>
  1887. /// 行程单导出
  1888. /// </summary>
  1889. /// <param name="dto"></param>
  1890. /// <returns></returns>
  1891. [HttpPost]
  1892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1893. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1894. {
  1895. try
  1896. {
  1897. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1898. if (groupData.Code != 0)
  1899. {
  1900. return Ok(JsonView(false, groupData.Msg));
  1901. }
  1902. else
  1903. {
  1904. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1905. if (dto.Language == "CN")
  1906. {
  1907. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1908. DocumentBuilder builder = new DocumentBuilder(doc);
  1909. int tableIndex = 0;//表格索引
  1910. //得到文档中的第一个表格
  1911. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1912. foreach (var item in _AirTicketReservations)
  1913. {
  1914. #region 处理固定数据
  1915. string[] FlightsCode = item.FlightsCode.Split('/');
  1916. if (FlightsCode.Length != 0)
  1917. {
  1918. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1919. if (_AirCompany != null)
  1920. {
  1921. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1922. }
  1923. else
  1924. {
  1925. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1926. }
  1927. }
  1928. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1929. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1930. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1931. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1932. string name = "";
  1933. foreach (string clientName in nameArray)
  1934. {
  1935. if (!name.Contains(clientName))
  1936. {
  1937. name += clientName + ",";
  1938. }
  1939. }
  1940. if (!string.IsNullOrWhiteSpace(name))
  1941. {
  1942. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1943. }
  1944. else
  1945. {
  1946. table.Range.Bookmarks["ClientName"].Text = "--";
  1947. }
  1948. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1949. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1950. table.Range.Bookmarks["JointTicket"].Text = "--";
  1951. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1952. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1953. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1954. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1955. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1956. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1957. #endregion
  1958. #region 循环数据处理
  1959. List<AirInfo> airs = new List<AirInfo>();
  1960. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1961. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1962. for (int i = 0; i < FlightsCode.Length; i++)
  1963. {
  1964. AirInfo air = new AirInfo();
  1965. string[] tempstr = DayArray[i]
  1966. .Replace("\r\n", string.Empty)
  1967. .Replace("\\r\\n", string.Empty)
  1968. .TrimStart().TrimEnd()
  1969. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1970. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1971. string starCity = "";
  1972. if (star_Three != null)
  1973. {
  1974. starCity = star_Three.AirPort;
  1975. }
  1976. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1977. string EndCity = "";
  1978. if (End_Three != null)
  1979. {
  1980. EndCity = End_Three.AirPort;
  1981. }
  1982. air.Destination = starCity + "/" + EndCity;
  1983. air.Flight = FlightsCode[i];
  1984. air.SeatingClass = item.CTypeName;
  1985. string dateTime = tempstr[2];
  1986. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1987. air.FlightDate = DateTemp;
  1988. air.DepartureTime = tempstr[5];
  1989. air.LandingTime = tempstr[6];
  1990. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1991. air.TicketStatus = "--";
  1992. air.Luggage = "--";
  1993. air.DepartureTerminal = "--";
  1994. air.LandingTerminal = "--";
  1995. airs.Add(air);
  1996. }
  1997. int row = 13;
  1998. for (int i = 0; i < airs.Count; i++)
  1999. {
  2000. if (airs.Count > 2)
  2001. {
  2002. for (int j = 0; j < airs.Count - 2; j++)
  2003. {
  2004. var CopyRow = table.Rows[12].Clone(true);
  2005. table.Rows.Add(CopyRow);
  2006. }
  2007. }
  2008. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2009. int index = 0;
  2010. foreach (PropertyInfo property in properties)
  2011. {
  2012. string value = property.GetValue(airs[i]).ToString();
  2013. Cell ishcel0 = table.Rows[row].Cells[index];
  2014. Paragraph p = new Paragraph(doc);
  2015. string s = value;
  2016. p.AppendChild(new Run(doc, s));
  2017. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2018. ishcel0.AppendChild(p);
  2019. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2020. index++;
  2021. }
  2022. row++;
  2023. }
  2024. #endregion
  2025. Paragraph lastParagraph = new Paragraph(doc);
  2026. //第一个表格末尾加段落
  2027. table.ParentNode.InsertAfter(lastParagraph, table);
  2028. //复制第一个表格
  2029. Table cloneTable = (Table)table.Clone(true);
  2030. //在文档末尾段落后面加入复制的表格
  2031. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2032. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2033. {
  2034. int rownewsIndex = 13;
  2035. for (int i = 0; i < 2; i++)
  2036. {
  2037. var CopyRow = table.Rows[12].Clone(true);
  2038. table.Rows.RemoveAt(13);
  2039. table.Rows.Add(CopyRow);
  2040. rownewsIndex++;
  2041. }
  2042. }
  2043. else
  2044. {
  2045. table.Rows.RemoveAt(12);
  2046. }
  2047. cloneTable.Rows.RemoveAt(12);
  2048. }
  2049. if (_AirTicketReservations.Count != 0)
  2050. {
  2051. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2052. if (FlightsCode.Length != 0)
  2053. {
  2054. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2055. if (_AirCompany != null)
  2056. {
  2057. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2058. }
  2059. else
  2060. {
  2061. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2062. }
  2063. }
  2064. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2065. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2066. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2067. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2068. string name = "";
  2069. foreach (string clientName in nameArray)
  2070. {
  2071. if (!name.Contains(clientName))
  2072. {
  2073. name += clientName + ",";
  2074. }
  2075. }
  2076. if (!string.IsNullOrWhiteSpace(name))
  2077. {
  2078. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2079. }
  2080. else
  2081. {
  2082. table.Range.Bookmarks["ClientName"].Text = "--";
  2083. }
  2084. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2085. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2086. table.Range.Bookmarks["JointTicket"].Text = "--";
  2087. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2088. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2089. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2090. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2091. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2092. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2093. }
  2094. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2095. //保存合并后的文档
  2096. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2097. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2098. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2099. return Ok(JsonView(true, "成功!", rst));
  2100. }
  2101. else
  2102. {
  2103. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2104. DocumentBuilder builder = new DocumentBuilder(doc);
  2105. int tableIndex = 0;//表格索引
  2106. //得到文档中的第一个表格
  2107. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2108. List<string> texts = new List<string>();
  2109. foreach (var item in _AirTicketReservations)
  2110. {
  2111. string[] FlightsCode = item.FlightsCode.Split('/');
  2112. if (FlightsCode.Length != 0)
  2113. {
  2114. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2115. if (_AirCompany != null)
  2116. {
  2117. if (!transDic.ContainsKey(_AirCompany.CnName))
  2118. {
  2119. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2120. }
  2121. }
  2122. else
  2123. {
  2124. if (!transDic.ContainsKey("--"))
  2125. {
  2126. transDic.Add("--", "--");
  2127. }
  2128. }
  2129. }
  2130. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2131. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2132. string name = "";
  2133. foreach (string clientName in nameArray)
  2134. {
  2135. name += clientName + ",";
  2136. }
  2137. if (!texts.Contains(name))
  2138. {
  2139. texts.Add(name);
  2140. }
  2141. List<AirInfo> airs = new List<AirInfo>();
  2142. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2143. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2144. for (int i = 0; i < FlightsCode.Length; i++)
  2145. {
  2146. AirInfo air = new AirInfo();
  2147. string[] tempstr = DayArray[i]
  2148. .Replace("\r\n", string.Empty)
  2149. .Replace("\\r\\n", string.Empty)
  2150. .TrimStart().TrimEnd()
  2151. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2152. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2153. if (star_Three != null)
  2154. {
  2155. if (!transDic.ContainsKey(star_Three.AirPort))
  2156. {
  2157. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2158. }
  2159. }
  2160. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2161. if (End_Three != null)
  2162. {
  2163. if (!transDic.ContainsKey(End_Three.AirPort))
  2164. {
  2165. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2166. }
  2167. }
  2168. if (!texts.Contains(item.CTypeName))
  2169. {
  2170. texts.Add(item.CTypeName);
  2171. }
  2172. }
  2173. }
  2174. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2175. if (transData.Count > 0)
  2176. {
  2177. foreach (TranslateResult item in transData)
  2178. {
  2179. if (!transDic.ContainsKey(item.Query))
  2180. {
  2181. transDic.Add(item.Query, item.Translation);
  2182. }
  2183. }
  2184. }
  2185. foreach (var item in _AirTicketReservations)
  2186. {
  2187. #region 处理固定数据
  2188. string[] FlightsCode = item.FlightsCode.Split('/');
  2189. if (FlightsCode.Length != 0)
  2190. {
  2191. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2192. if (_AirCompany != null)
  2193. {
  2194. string str = "--";
  2195. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2196. if (!string.IsNullOrEmpty(translateResult))
  2197. {
  2198. str = translateResult;
  2199. str = _airTicketResRep.Processing(str);
  2200. }
  2201. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2202. }
  2203. else
  2204. {
  2205. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2206. }
  2207. }
  2208. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2209. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2210. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2211. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2212. string names = "";
  2213. foreach (string clientName in nameArray)
  2214. {
  2215. names += clientName + ",";
  2216. }
  2217. if (!string.IsNullOrWhiteSpace(names))
  2218. {
  2219. string str = "--";
  2220. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2221. if (!string.IsNullOrEmpty(translateResult))
  2222. {
  2223. str = translateResult;
  2224. str = _airTicketResRep.Processing(str);
  2225. }
  2226. table.Range.Bookmarks["ClientName"].Text = str;
  2227. }
  2228. else
  2229. {
  2230. table.Range.Bookmarks["ClientName"].Text = "--";
  2231. }
  2232. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2233. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2234. table.Range.Bookmarks["JointTicket"].Text = "--";
  2235. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2236. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2237. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2238. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2239. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2240. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2241. #endregion
  2242. #region 循环数据处理
  2243. List<AirInfo> airs = new List<AirInfo>();
  2244. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2245. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2246. for (int i = 0; i < FlightsCode.Length; i++)
  2247. {
  2248. AirInfo air = new AirInfo();
  2249. string[] tempstr = DayArray[i]
  2250. .Replace("\r\n", string.Empty)
  2251. .Replace("\\r\\n", string.Empty)
  2252. .TrimStart().TrimEnd()
  2253. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2254. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2255. string starCity = "";
  2256. if (star_Three != null)
  2257. {
  2258. string str2 = "--";
  2259. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2260. if (!string.IsNullOrEmpty(translateResult2))
  2261. {
  2262. str2 = translateResult2;
  2263. str2 = _airTicketResRep.Processing(str2);
  2264. }
  2265. starCity = str2;
  2266. }
  2267. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2268. string EndCity = "";
  2269. if (End_Three != null)
  2270. {
  2271. string str1 = "--";
  2272. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2273. if (!string.IsNullOrEmpty(translateResult1))
  2274. {
  2275. str1 = translateResult1;
  2276. str1 = _airTicketResRep.Processing(str1);
  2277. }
  2278. EndCity = str1;
  2279. }
  2280. air.Destination = starCity + "/" + EndCity;
  2281. air.Flight = FlightsCode[i];
  2282. string str = "--";
  2283. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2284. if (!string.IsNullOrEmpty(translateResult))
  2285. {
  2286. str = translateResult;
  2287. str = _airTicketResRep.Processing(str);
  2288. }
  2289. air.SeatingClass = str;
  2290. string dateTime = tempstr[2];
  2291. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2292. air.FlightDate = DateTemp;
  2293. air.DepartureTime = tempstr[5];
  2294. air.LandingTime = tempstr[6];
  2295. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2296. air.TicketStatus = "--";
  2297. air.Luggage = "--";
  2298. air.DepartureTerminal = "--";
  2299. air.LandingTerminal = "--";
  2300. airs.Add(air);
  2301. }
  2302. int row = 13;
  2303. for (int i = 0; i < airs.Count; i++)
  2304. {
  2305. if (airs.Count > 2)
  2306. {
  2307. for (int j = 0; j < airs.Count - 2; j++)
  2308. {
  2309. var CopyRow = table.Rows[12].Clone(true);
  2310. table.Rows.Add(CopyRow);
  2311. }
  2312. }
  2313. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2314. int index = 0;
  2315. foreach (PropertyInfo property in properties)
  2316. {
  2317. string value = property.GetValue(airs[i]).ToString();
  2318. Cell ishcel0 = table.Rows[row].Cells[index];
  2319. Paragraph p = new Paragraph(doc);
  2320. string s = value;
  2321. p.AppendChild(new Run(doc, s));
  2322. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2323. ishcel0.AppendChild(p);
  2324. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2325. //ishcel0.CellFormat.VerticalAlignment=
  2326. index++;
  2327. }
  2328. row++;
  2329. }
  2330. #endregion
  2331. Paragraph lastParagraph = new Paragraph(doc);
  2332. //第一个表格末尾加段落
  2333. table.ParentNode.InsertAfter(lastParagraph, table);
  2334. //复制第一个表格
  2335. Table cloneTable = (Table)table.Clone(true);
  2336. //在文档末尾段落后面加入复制的表格
  2337. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2338. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2339. {
  2340. int rownewsIndex = 13;
  2341. for (int i = 0; i < 2; i++)
  2342. {
  2343. var CopyRow = table.Rows[12].Clone(true);
  2344. table.Rows.RemoveAt(13);
  2345. table.Rows.Add(CopyRow);
  2346. rownewsIndex++;
  2347. }
  2348. }
  2349. else
  2350. {
  2351. table.Rows.RemoveAt(12);
  2352. }
  2353. cloneTable.Rows.RemoveAt(12);
  2354. }
  2355. if (_AirTicketReservations.Count != 0)
  2356. {
  2357. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2358. if (FlightsCode.Length != 0)
  2359. {
  2360. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2361. if (_AirCompany != null)
  2362. {
  2363. string str = "--";
  2364. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2365. if (!string.IsNullOrEmpty(translateResult))
  2366. {
  2367. str = translateResult;
  2368. str = _airTicketResRep.Processing(str);
  2369. }
  2370. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2371. }
  2372. else
  2373. {
  2374. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2375. }
  2376. }
  2377. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2378. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2379. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2380. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2381. string names = "";
  2382. foreach (string clientName in nameArray)
  2383. {
  2384. names += clientName + ",";
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(names))
  2387. {
  2388. string str = "--";
  2389. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2390. if (!string.IsNullOrEmpty(translateResult))
  2391. {
  2392. str = translateResult;
  2393. str = _airTicketResRep.Processing(str);
  2394. }
  2395. table.Range.Bookmarks["ClientName"].Text = str;
  2396. }
  2397. else
  2398. {
  2399. table.Range.Bookmarks["ClientName"].Text = "--";
  2400. }
  2401. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2402. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2403. table.Range.Bookmarks["JointTicket"].Text = "--";
  2404. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2405. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2406. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2407. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2408. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2409. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2410. }
  2411. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2412. //保存合并后的文档
  2413. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2414. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2415. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2416. return Ok(JsonView(true, "成功!", rst));
  2417. }
  2418. }
  2419. }
  2420. catch (Exception ex)
  2421. {
  2422. return Ok(JsonView(false, "程序错误!"));
  2423. throw;
  2424. }
  2425. }
  2426. #endregion
  2427. #region 团组增减款项 --> 其他款项
  2428. /// <summary>
  2429. /// 团组增减款项下拉框绑定
  2430. /// </summary>
  2431. /// <param name="dto"></param>
  2432. /// <returns></returns>
  2433. [HttpPost]
  2434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2435. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2436. {
  2437. try
  2438. {
  2439. #region 参数验证
  2440. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2441. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2442. #endregion
  2443. //var groupData = await GeneralMethod.PostOperationAuthReturnGroupInfosAsync(dto.UserId, dto.CTId);
  2444. ////支付方式
  2445. //List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  2446. //List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  2447. //var data = new
  2448. //{
  2449. // Payment = _Payment,
  2450. // GroupName = groupData,
  2451. //};
  2452. var res = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2453. if (res.Code != 0)
  2454. {
  2455. return Ok(JsonView(false, res.Msg));
  2456. }
  2457. return Ok(JsonView(true, "操作成功!", res.Data));
  2458. }
  2459. catch (Exception ex)
  2460. {
  2461. return Ok(JsonView(false, ex.Message));
  2462. }
  2463. }
  2464. /// <summary>
  2465. /// 根据团组Id查询团组增减款项
  2466. /// </summary>
  2467. /// <param name="dto"></param>
  2468. /// <returns></returns>
  2469. [HttpPost]
  2470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2471. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2472. {
  2473. try
  2474. {
  2475. #region 参数验证
  2476. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2477. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2478. #endregion
  2479. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2480. if (groupData.Code != 0)
  2481. {
  2482. return Ok(JsonView(false, groupData.Msg));
  2483. }
  2484. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2485. }
  2486. catch (Exception ex)
  2487. {
  2488. return Ok(JsonView(false, "程序错误!"));
  2489. }
  2490. }
  2491. /// <summary>
  2492. /// 团组增减款项操作(Status:1.新增,2.修改)
  2493. /// </summary>
  2494. /// <param name="dto"></param>
  2495. /// <returns></returns>
  2496. [HttpPost]
  2497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2498. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2499. {
  2500. try
  2501. {
  2502. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2503. if (groupData.Code != 0)
  2504. {
  2505. return Ok(JsonView(false, groupData.Msg));
  2506. }
  2507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2508. }
  2509. catch (Exception ex)
  2510. {
  2511. return Ok(JsonView(false, "程序错误!"));
  2512. throw;
  2513. }
  2514. }
  2515. /// <summary>
  2516. /// 团组增减款项操作 删除
  2517. /// </summary>
  2518. /// <param name="dto"></param>
  2519. /// <returns></returns>
  2520. [HttpPost]
  2521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2522. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2523. {
  2524. try
  2525. {
  2526. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2527. if (!res)
  2528. {
  2529. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2530. {
  2531. IsDel = 1,
  2532. DeleteUserId = dto.DeleteUserId,
  2533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2534. }).ExecuteCommandAsync();
  2535. return Ok(JsonView(false, "删除失败"));
  2536. }
  2537. return Ok(JsonView(true, "删除成功!"));
  2538. }
  2539. catch (Exception ex)
  2540. {
  2541. return Ok(JsonView(false, "程序错误!"));
  2542. throw;
  2543. }
  2544. }
  2545. /// <summary>
  2546. /// 根据团组增减款项Id查询
  2547. /// </summary>
  2548. /// <param name="dto"></param>
  2549. /// <returns></returns>
  2550. [HttpPost]
  2551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2552. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2553. {
  2554. try
  2555. {
  2556. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2557. if (groupData.Code != 0)
  2558. {
  2559. return Ok(JsonView(false, groupData.Msg));
  2560. }
  2561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2562. }
  2563. catch (Exception ex)
  2564. {
  2565. return Ok(JsonView(false, "程序错误!"));
  2566. throw;
  2567. }
  2568. }
  2569. #endregion
  2570. #region 文件上传、删除
  2571. /// <summary>
  2572. /// region 文件上传 可以带参数
  2573. /// </summary>
  2574. /// <param name="file"></param>
  2575. /// <returns></returns>
  2576. [HttpPost]
  2577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2578. public async Task<IActionResult> UploadProject(IFormFile file)
  2579. {
  2580. try
  2581. {
  2582. var TypeName = Request.Headers["TypeName"].ToString();
  2583. if (file != null)
  2584. {
  2585. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2586. //文件名称
  2587. string projectFileName = file.FileName;
  2588. //上传的文件的路径
  2589. string filePath = "";
  2590. if (TypeName == "A")//A代表团组增减款项
  2591. {
  2592. if (!Directory.Exists(fileDir))
  2593. {
  2594. Directory.CreateDirectory(fileDir);
  2595. }
  2596. //上传的文件的路径
  2597. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2598. }
  2599. else if (TypeName == "B")//B代表商邀相关文件
  2600. {
  2601. if (!Directory.Exists(fileDir))
  2602. {
  2603. Directory.CreateDirectory(fileDir);
  2604. }
  2605. //上传的文件的路径
  2606. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2607. }
  2608. using (FileStream fs = System.IO.File.Create(filePath))
  2609. {
  2610. file.CopyTo(fs);
  2611. fs.Flush();
  2612. }
  2613. return Ok(JsonView(true, "上传成功!", projectFileName));
  2614. }
  2615. else
  2616. {
  2617. return Ok(JsonView(false, "上传失败!"));
  2618. }
  2619. }
  2620. catch (Exception ex)
  2621. {
  2622. return Ok(JsonView(false, "程序错误!"));
  2623. throw;
  2624. }
  2625. }
  2626. /// <summary>
  2627. /// 删除指定文件
  2628. /// </summary>
  2629. /// <param name="dto"></param>
  2630. /// <returns></returns>
  2631. [HttpPost]
  2632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2633. public async Task<IActionResult> DelFile(DelFileDto dto)
  2634. {
  2635. try
  2636. {
  2637. var TypeName = Request.Headers["TypeName"].ToString();
  2638. string filePath = "";
  2639. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2640. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2641. int id = 0;
  2642. if (TypeName == "A")
  2643. {
  2644. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2645. // 删除该文件
  2646. System.IO.File.Delete(filePath);
  2647. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2648. }
  2649. else if (TypeName == "B")
  2650. {
  2651. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2652. // 删除该文件
  2653. System.IO.File.Delete(filePath);
  2654. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2655. }
  2656. if (id != 0)
  2657. {
  2658. return Ok(JsonView(true, "成功!"));
  2659. }
  2660. else
  2661. {
  2662. return Ok(JsonView(false, "失败!"));
  2663. }
  2664. }
  2665. catch (Exception ex)
  2666. {
  2667. return Ok(JsonView(false, "程序错误!"));
  2668. throw;
  2669. }
  2670. }
  2671. #endregion
  2672. #region 商邀费用录入
  2673. /// <summary>
  2674. /// 根据团组Id查询商邀费用列表
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2681. {
  2682. try
  2683. {
  2684. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2685. if (groupData.Code != 0)
  2686. {
  2687. return Ok(JsonView(false, groupData.Msg));
  2688. }
  2689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2690. }
  2691. catch (Exception ex)
  2692. {
  2693. return Ok(JsonView(false, "程序错误!"));
  2694. throw;
  2695. }
  2696. }
  2697. //
  2698. /// <summary>
  2699. /// 商邀费用 Info Page 基础数据源
  2700. /// </summary>
  2701. /// <param name="dto"></param>
  2702. /// <returns></returns>
  2703. [HttpPost]
  2704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2705. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2706. {
  2707. try
  2708. {
  2709. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2710. if (groupData.Code != 0)
  2711. {
  2712. return Ok(JsonView(false, groupData.Msg));
  2713. }
  2714. return Ok(JsonView(true, "操作成功", groupData.Data));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, ex.Message));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据商邀费用ID查询C表和商邀费用数据
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2730. {
  2731. try
  2732. {
  2733. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2734. if (groupData.Code != 0)
  2735. {
  2736. return Ok(JsonView(false, groupData.Msg));
  2737. }
  2738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2739. }
  2740. catch (Exception ex)
  2741. {
  2742. return Ok(JsonView(false, ex.Message));
  2743. throw;
  2744. }
  2745. }
  2746. /// <summary>
  2747. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2748. /// </summary>
  2749. /// <param name="dto"></param>
  2750. /// <returns></returns>
  2751. [HttpPost]
  2752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2753. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2754. {
  2755. try
  2756. {
  2757. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto,_setDataRep.PostCurrencyByDiid);
  2758. if (groupData.Code != 0)
  2759. {
  2760. return Ok(JsonView(false, groupData.Msg));
  2761. }
  2762. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2763. }
  2764. catch (Exception ex)
  2765. {
  2766. return Ok(JsonView(false, "程序错误!"));
  2767. throw;
  2768. }
  2769. }
  2770. /// <summary>
  2771. /// 商邀删除
  2772. /// </summary>
  2773. /// <param name="dto"></param>
  2774. /// <returns></returns>
  2775. [HttpPost]
  2776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2777. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2778. {
  2779. try
  2780. {
  2781. _sqlSugar.BeginTran();
  2782. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2783. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2784. {
  2785. IsDel = 1,
  2786. DeleteUserId = dto.DeleteUserId,
  2787. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2788. })
  2789. .Where(it => it.Id == dto.Id)
  2790. .ExecuteCommand();
  2791. if (res1 > 0)
  2792. {
  2793. int _diId = 0;
  2794. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2795. if (_ioaInfo!=null)
  2796. {
  2797. _diId = _ioaInfo.DiId;
  2798. }
  2799. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2800. .SetColumns(a => new Grp_CreditCardPayment()
  2801. {
  2802. IsDel = 1,
  2803. DeleteUserId = dto.DeleteUserId,
  2804. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2805. })
  2806. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81 )
  2807. .ExecuteCommand();
  2808. if (res2 > 0)
  2809. {
  2810. _sqlSugar.CommitTran();
  2811. return Ok(JsonView(true, "删除成功!"));
  2812. }
  2813. }
  2814. _sqlSugar.RollbackTran();
  2815. return Ok(JsonView(false, "删除失败"));
  2816. }
  2817. catch (Exception ex)
  2818. {
  2819. _sqlSugar.RollbackTran();
  2820. return Ok(JsonView(false, ex.Message));
  2821. }
  2822. }
  2823. #endregion
  2824. #region 团组英文资料
  2825. /// <summary>
  2826. /// 查询团组英文所有资料
  2827. /// </summary>
  2828. /// <param name="dto"></param>
  2829. /// <returns></returns>
  2830. [HttpPost]
  2831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2832. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2833. {
  2834. try
  2835. {
  2836. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2837. if (groupData.Code != 0)
  2838. {
  2839. return Ok(JsonView(false, groupData.Msg));
  2840. }
  2841. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2842. }
  2843. catch (Exception ex)
  2844. {
  2845. return Ok(JsonView(false, "程序错误!"));
  2846. throw;
  2847. }
  2848. }
  2849. /// <summary>
  2850. /// 团组英文资料操作(Status:1.新增,2.修改)
  2851. /// </summary>
  2852. /// <param name="dto"></param>
  2853. /// <returns></returns>
  2854. [HttpPost]
  2855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2856. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2857. {
  2858. try
  2859. {
  2860. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2861. if (groupData.Code != 0)
  2862. {
  2863. return Ok(JsonView(false, groupData.Msg));
  2864. }
  2865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2866. }
  2867. catch (Exception ex)
  2868. {
  2869. return Ok(JsonView(false, "程序错误!"));
  2870. throw;
  2871. }
  2872. }
  2873. /// <summary>
  2874. /// 团组英文资料Id查询数据
  2875. /// </summary>
  2876. /// <param name="dto"></param>
  2877. /// <returns></returns>
  2878. [HttpPost]
  2879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2880. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2881. {
  2882. try
  2883. {
  2884. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2885. if (_DelegationEnData != null)
  2886. {
  2887. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2888. }
  2889. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2890. }
  2891. catch (Exception ex)
  2892. {
  2893. return Ok(JsonView(false, "程序错误!"));
  2894. throw;
  2895. }
  2896. }
  2897. /// <summary>
  2898. /// 团组英文资料删除
  2899. /// </summary>
  2900. /// <param name="dto"></param>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2905. {
  2906. try
  2907. {
  2908. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2909. if (!res)
  2910. {
  2911. return Ok(JsonView(false, "删除失败"));
  2912. }
  2913. return Ok(JsonView(true, "删除成功!"));
  2914. }
  2915. catch (Exception ex)
  2916. {
  2917. return Ok(JsonView(false, "程序错误!"));
  2918. throw;
  2919. }
  2920. }
  2921. #endregion
  2922. #region 导出邀请函
  2923. /// <summary>
  2924. /// 导出邀请函页面初始化
  2925. /// </summary>
  2926. /// <param name="dto"></param>
  2927. /// <returns></returns>
  2928. [HttpPost]
  2929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2930. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2931. {
  2932. try
  2933. {
  2934. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  2935. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2936. if (dto.DiId == 0)
  2937. {
  2938. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2939. }
  2940. else
  2941. {
  2942. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2943. }
  2944. return Ok(JsonView(true, "查询成功!", new
  2945. {
  2946. deleClient = crm_Deles,
  2947. delegations = grp_Delegations
  2948. }));
  2949. }
  2950. catch (Exception ex)
  2951. {
  2952. return Ok(JsonView(false, "程序错误!"));
  2953. throw;
  2954. }
  2955. }
  2956. /// <summary>
  2957. /// 导出邀请函
  2958. /// </summary>
  2959. /// <param name="dto"></param>
  2960. /// <returns></returns>
  2961. [HttpPost]
  2962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2963. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2964. {
  2965. #region 参数验证
  2966. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2967. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2968. #endregion
  2969. try
  2970. {
  2971. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2972. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  2973. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  2974. From Grp_TourClientList tcl
  2975. Left Join
  2976. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  2977. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  2978. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  2979. From Crm_DeleClient dc
  2980. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  2981. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  2982. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  2983. Where dc.IsDel = 0) temp
  2984. On temp.DcId =tcl.ClientId
  2985. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  2986. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  2987. List<string> texts = new List<string>();
  2988. if (datas.Count != 0)
  2989. {
  2990. foreach (TourClientListDetailsView item in datas)
  2991. {
  2992. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2993. {
  2994. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2995. }
  2996. else
  2997. {
  2998. string name = item.LastName + item.FirstName;
  2999. texts.Add(name);
  3000. }
  3001. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3002. {
  3003. if (!transDic.ContainsKey(item.Job))
  3004. {
  3005. texts.Add(item.Job);
  3006. }
  3007. }
  3008. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3009. {
  3010. texts.Add(item.CompanyFullName);
  3011. }
  3012. }
  3013. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3014. if (transData.Count > 0)
  3015. {
  3016. foreach (TranslateResult item in transData)
  3017. {
  3018. if (!transDic.ContainsKey(item.Query))
  3019. {
  3020. transDic.Add(item.Query, item.Translation);
  3021. }
  3022. }
  3023. }
  3024. List<GuestList> list = new List<GuestList>();
  3025. foreach (TourClientListDetailsView dele in datas)
  3026. {
  3027. GuestList guestList = new GuestList();
  3028. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3029. {
  3030. guestList.Name = dele.Pinyin;
  3031. }
  3032. else
  3033. {
  3034. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3035. guestList.Name = Name;
  3036. }
  3037. if (dele.Sex == 0)
  3038. {
  3039. guestList.Sex = "Male";
  3040. }
  3041. else if (dele.Sex == 1)
  3042. {
  3043. guestList.Sex = "Female";
  3044. }
  3045. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3046. if (!string.IsNullOrEmpty(dele.Job))
  3047. {
  3048. guestList.Job = dele.Job;
  3049. }
  3050. list.Add(guestList);
  3051. }
  3052. //载入模板
  3053. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3054. DocumentBuilder builder = new DocumentBuilder(doc);
  3055. //获取word里所有表格
  3056. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3057. //获取所填表格的序数
  3058. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3059. var rowStart = tableOne.Rows[0]; //获取第1行
  3060. //循环赋值
  3061. for (int i = 0; i < list.Count; i++)
  3062. {
  3063. builder.MoveToCell(0, i + 1, 0, 0);
  3064. builder.Write(list[i].Name.ToString());
  3065. builder.MoveToCell(0, i + 1, 1, 0);
  3066. builder.Write(list[i].Sex.ToString());
  3067. builder.MoveToCell(0, i + 1, 2, 0);
  3068. builder.Write(list[i].DOB.ToString());
  3069. builder.MoveToCell(0, i + 1, 3, 0);
  3070. builder.Write(list[i].Job.ToString());
  3071. }
  3072. //删除多余行
  3073. while (tableOne.Rows.Count > list.Count + 1)
  3074. {
  3075. tableOne.Rows.RemoveAt(list.Count + 1);
  3076. }
  3077. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3078. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3079. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3080. doc.Save(filePath);
  3081. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3082. return Ok(JsonView(true, "操作成功!", Url));
  3083. }
  3084. else
  3085. {
  3086. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3087. }
  3088. }
  3089. catch (Exception ex)
  3090. {
  3091. return Ok(JsonView(false, ex.Message));
  3092. throw;
  3093. }
  3094. }
  3095. #endregion
  3096. #region 团组经理模块 出入境费用
  3097. ///// <summary>
  3098. ///// 团组模块 - 出入境费用
  3099. ///// </summary>
  3100. ///// <returns></returns>
  3101. //[HttpPost]
  3102. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3103. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3104. //{
  3105. // try
  3106. // {
  3107. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3108. // if (data.Code != 0)
  3109. // {
  3110. // return Ok(JsonView(false, data.Msg));
  3111. // }
  3112. // return Ok(JsonView(true, "查询成功!"));
  3113. // }
  3114. // catch (Exception ex)
  3115. // {
  3116. // return Ok(JsonView(false, ex.Message));
  3117. // throw;
  3118. // }
  3119. //}
  3120. /// <summary>
  3121. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3122. /// </summary>
  3123. /// <returns></returns>
  3124. [HttpPost]
  3125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3126. public async Task<IActionResult> SetDayAndCostAreaChange()
  3127. {
  3128. try
  3129. {
  3130. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3131. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3132. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3133. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3134. foreach (var item in unite) //处理交集数据
  3135. {
  3136. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3137. }
  3138. foreach (var item in merge) //处理差集数据
  3139. {
  3140. int nationalTravelFeeId = 0;
  3141. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3142. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3143. else
  3144. {
  3145. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3146. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3147. }
  3148. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3149. }
  3150. //只更新dayAndCost 的 nationalTravelFeeId;
  3151. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3152. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3153. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3154. }
  3155. catch (Exception ex)
  3156. {
  3157. return Ok(JsonView(false, ex.Message));
  3158. throw;
  3159. }
  3160. }
  3161. /// <summary>
  3162. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3163. /// </summary>
  3164. /// <returns></returns>
  3165. [HttpPost]
  3166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3167. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3168. {
  3169. try
  3170. {
  3171. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3172. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3173. //SetDataInfoView
  3174. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3175. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3176. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3177. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3178. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3179. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3180. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3181. //默认币种显示
  3182. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3183. {
  3184. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 0.0000M },
  3185. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 0.0000M },
  3186. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 0.0000M },
  3187. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0000M },
  3188. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.0000M },
  3189. };
  3190. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3191. if (_currencyRate.Count > 0)
  3192. {
  3193. foreach (var item in _currencyInfos)
  3194. {
  3195. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3196. if (rateInfo != null)
  3197. {
  3198. item.Rate = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3199. }
  3200. }
  3201. }
  3202. return Ok(JsonView(true, "查询成功!", new
  3203. {
  3204. GroupNameData = groupNameData.Data,
  3205. CurrencyData = _CurrencyData,
  3206. WordTypeData = _WordTypeData,
  3207. ExcelTypeData = _ExcelTypeData,
  3208. CurrencyInit = _currencyInfos
  3209. }));
  3210. }
  3211. catch (Exception ex)
  3212. {
  3213. return Ok(JsonView(false, ex.Message));
  3214. throw;
  3215. }
  3216. }
  3217. /// <summary>
  3218. /// 团组模块 - 出入境费用 - Info
  3219. /// </summary>
  3220. /// <returns></returns>
  3221. [HttpPost]
  3222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3223. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3224. {
  3225. try
  3226. {
  3227. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3228. if (data.Code != 0)
  3229. {
  3230. return Ok(JsonView(false, data.Msg));
  3231. }
  3232. return Ok(JsonView(true, "查询成功!", data.Data));
  3233. }
  3234. catch (Exception ex)
  3235. {
  3236. return Ok(JsonView(false, ex.Message));
  3237. }
  3238. }
  3239. /// <summary>
  3240. /// 团组模块 - 出入境费用 - Add And Update
  3241. /// </summary>
  3242. /// <returns></returns>
  3243. [HttpPost]
  3244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3245. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3246. {
  3247. try
  3248. {
  3249. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3250. if (data.Code != 0)
  3251. {
  3252. return Ok(JsonView(false, data.Msg));
  3253. }
  3254. return Ok(JsonView(true, data.Msg, data.Data));
  3255. }
  3256. catch (Exception ex)
  3257. {
  3258. return Ok(JsonView(false, ex.Message));
  3259. }
  3260. }
  3261. /// <summary>
  3262. /// 团组模块 - 出入境费用 - File downlaod
  3263. /// </summary>
  3264. /// <param name="dto"></param>
  3265. /// <returns></returns>
  3266. [HttpPost]
  3267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3268. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3269. {
  3270. try
  3271. {
  3272. if (dto.DiId < 1)
  3273. {
  3274. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3275. }
  3276. if (dto.ExportType <1)
  3277. {
  3278. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3279. }
  3280. if (dto.SubTypeId < 1)
  3281. {
  3282. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3283. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3284. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3285. 3 团组成员名单 1 团组成员名单"));
  3286. }
  3287. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3288. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3289. if (_EnterExitCosts == null)
  3290. {
  3291. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3292. }
  3293. //数据源
  3294. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3295. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3296. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3297. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3298. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3299. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3300. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3301. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3302. .LeftJoin<Crm_CustomerCompany>((tcl, dc,cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3303. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3304. .Select((tcl, dc, cc) => new
  3305. {
  3306. Name = dc.LastName + dc.FirstName,
  3307. Sex = dc.Sex,
  3308. Birthday = dc.BirthDay,
  3309. Company = cc.CompanyFullName,
  3310. Job = dc.Job
  3311. })
  3312. .ToList();
  3313. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3314. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3315. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3316. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3317. if (dto.ExportType == 1) //明细表
  3318. {
  3319. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3320. {
  3321. //获取模板
  3322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3323. //载入模板
  3324. Document doc = new Document(tempPath);
  3325. DocumentBuilder builder = new DocumentBuilder(doc);
  3326. //利用键值对存放数据
  3327. Dictionary<string, string> dic = new Dictionary<string, string>();
  3328. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3329. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3330. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3331. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3332. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3333. string row1_1 = "";
  3334. if (_EnterExitCosts.Visa > 0)
  3335. {
  3336. //insidePayTotal += _EnterExitCosts.Visa;
  3337. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3338. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3339. {
  3340. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3341. }
  3342. }
  3343. string row1_2 = "";
  3344. if (_EnterExitCosts.YiMiao > 0)
  3345. {
  3346. //insidePayTotal += _EnterExitCosts.YiMiao;
  3347. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3348. }
  3349. if (_EnterExitCosts.HeSuan > 0)
  3350. {
  3351. //insidePayTotal += _EnterExitCosts.HeSuan;
  3352. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3353. }
  3354. if (_EnterExitCosts.Service > 0)
  3355. {
  3356. //insidePayTotal += _EnterExitCosts.Service;
  3357. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3358. }
  3359. string row1_3 = "";
  3360. if (_EnterExitCosts.Safe > 0)
  3361. {
  3362. //insidePayTotal += _EnterExitCosts.Safe;
  3363. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3364. }
  3365. if (_EnterExitCosts.Ticket > 0)
  3366. {
  3367. //insidePayTotal += _EnterExitCosts.Ticket;
  3368. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3369. }
  3370. string row1 = "";
  3371. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3372. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3373. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3374. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3375. dic.Add("Row1Str", row1);
  3376. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3377. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3378. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3379. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3380. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3381. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3382. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3383. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3384. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3385. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3386. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3387. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3388. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3389. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3390. #region 填充word模板书签内容
  3391. foreach (var key in dic.Keys)
  3392. {
  3393. builder.MoveToBookmark(key);
  3394. builder.Write(dic[key]);
  3395. }
  3396. #endregion
  3397. #region 填充word表格内容
  3398. ////获读取指定表格方法二
  3399. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3400. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3401. for (int i = 0; i < dac1.Count; i++)
  3402. {
  3403. Grp_DayAndCost dac = dac1[i];
  3404. if (dac == null) continue;
  3405. builder.MoveToCell(0, i, 0, 0);
  3406. builder.Write("第" + dac.Days.ToString() + "晚:");
  3407. builder.MoveToCell(0, i, 1, 0);
  3408. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3409. builder.Write(dac.Place == null ? "" : dac.Place);
  3410. builder.MoveToCell(0, i, 2, 0);
  3411. builder.Write("费用标准:");
  3412. string curr = "";
  3413. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3414. if (currData != null)
  3415. {
  3416. curr = currData.Name;
  3417. }
  3418. builder.MoveToCell(0, i, 3, 0);
  3419. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3420. builder.MoveToCell(0, i, 4, 0);
  3421. builder.Write("费用小计:");
  3422. builder.MoveToCell(0, i, 5, 0);
  3423. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3424. }
  3425. //删除多余行
  3426. while (table1.Rows.Count > dac1.Count)
  3427. {
  3428. table1.Rows.RemoveAt(dac1.Count);
  3429. }
  3430. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3431. for (int i = 0; i < dac2.Count; i++)
  3432. {
  3433. Grp_DayAndCost dac = dac2[i];
  3434. if (dac == null) continue;
  3435. builder.MoveToCell(1, i, 0, 0);
  3436. builder.Write("第" + dac.Days.ToString() + "天:");
  3437. builder.MoveToCell(1, i, 1, 0);
  3438. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3439. builder.MoveToCell(1, i, 2, 0);
  3440. builder.Write("费用标准:");
  3441. string curr = "";
  3442. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3443. if (currData != null)
  3444. {
  3445. curr = currData.Name;
  3446. }
  3447. builder.MoveToCell(1, i, 3, 0);
  3448. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3449. builder.MoveToCell(1, i, 4, 0);
  3450. builder.Write("费用小计:");
  3451. builder.MoveToCell(1, i, 5, 0);
  3452. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3453. }
  3454. //删除多余行
  3455. while (table2.Rows.Count > dac2.Count)
  3456. {
  3457. table2.Rows.RemoveAt(dac2.Count);
  3458. }
  3459. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3460. for (int i = 0; i < dac3.Count; i++)
  3461. {
  3462. Grp_DayAndCost dac = dac3[i];
  3463. if (dac == null) continue;
  3464. builder.MoveToCell(2, i, 0, 0);
  3465. builder.Write("第" + dac.Days.ToString() + "天:");
  3466. builder.MoveToCell(2, i, 1, 0);
  3467. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3468. builder.MoveToCell(2, i, 2, 0);
  3469. builder.Write("费用标准:");
  3470. string curr = "";
  3471. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3472. if (currData != null)
  3473. {
  3474. curr = currData.Name;
  3475. }
  3476. builder.MoveToCell(2, i, 3, 0);
  3477. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3478. builder.MoveToCell(2, i, 4, 0);
  3479. builder.Write("费用小计:");
  3480. builder.MoveToCell(2, i, 5, 0);
  3481. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3482. }
  3483. //删除多余行
  3484. while (table3.Rows.Count > dac3.Count)
  3485. {
  3486. table3.Rows.RemoveAt(dac3.Count);
  3487. }
  3488. #endregion
  3489. //文件名
  3490. string strFileName = _DelegationInfo.TeamName + "出入境费用.docx";
  3491. //文件流下载
  3492. //byte[] bytes = null;
  3493. //using (MemoryStream stream = new MemoryStream())
  3494. //{
  3495. // doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  3496. // bytes = stream.ToArray();
  3497. //}
  3498. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3499. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3500. return Ok(JsonView(true, "成功", new { Url = url }));
  3501. }
  3502. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3503. {
  3504. //获取模板
  3505. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3506. //载入模板
  3507. Document doc = new Document(tempPath);
  3508. DocumentBuilder builder = new DocumentBuilder(doc);
  3509. Dictionary<string, string> dic = new Dictionary<string, string>();
  3510. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3511. {
  3512. List<string> list = new List<string>();
  3513. try
  3514. {
  3515. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3516. foreach (var item in spilitArr)
  3517. {
  3518. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3519. var depCode = spDotandEmpty[2].Substring(0, 3);
  3520. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3521. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3522. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3523. list.Add(depName);
  3524. list.Add(arrName);
  3525. }
  3526. list = list.Distinct().ToList();
  3527. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3528. }
  3529. catch (Exception)
  3530. {
  3531. dic.Add("ReturnCode", "行程录入不正确!");
  3532. }
  3533. }
  3534. else
  3535. {
  3536. dic.Add("ReturnCode", "未录入行程!");
  3537. }
  3538. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3539. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3540. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3541. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3542. {
  3543. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3544. dic.Add("Day", sp.Days.ToString());
  3545. }
  3546. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3547. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3548. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3549. dic.Add("Names", Names);
  3550. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3551. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3552. decimal dac1totalPrice = 0.00M;
  3553. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3554. foreach (var dac in dac1)
  3555. {
  3556. if (dac.SubTotal == 0.00M)
  3557. {
  3558. continue;
  3559. }
  3560. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3561. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3562. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3563. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3564. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3565. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown";
  3566. builder.Write(currency);//币种
  3567. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3568. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3569. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3570. builder.Write("");//人数
  3571. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3572. builder.Write("");//天数
  3573. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3574. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3575. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3576. decimal rate = 0.00M;
  3577. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3578. builder.Write(rate.ToString("#0.0000"));//汇率
  3579. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3580. decimal rbmPrice = rate * dac.SubTotal;
  3581. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3582. accommodationStartIndex++;
  3583. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3584. }
  3585. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3586. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3587. {
  3588. table1.Rows.RemoveAt(i - 1);
  3589. foodandotherStartIndex--;
  3590. }
  3591. if (dac2.Count == dac3.Count)//国家 币种 金额
  3592. {
  3593. for (int i = 0; i < dac2.Count; i++)
  3594. {
  3595. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3596. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3597. }
  3598. }
  3599. decimal dac2totalPrice = 0.00M;
  3600. foreach (var dac in dac2)
  3601. {
  3602. if (dac.SubTotal == 0)
  3603. {
  3604. continue;
  3605. }
  3606. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3607. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3608. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3609. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown" ;
  3610. builder.Write(currency);//币种
  3611. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3612. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3613. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3614. builder.Write("");//人数
  3615. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3616. builder.Write("");//天数
  3617. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3618. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3619. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3620. decimal rate = 0.00M;
  3621. rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
  3622. builder.Write(rate.ToString("#0.0000"));//汇率
  3623. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3624. decimal rbmPrice = rate * dac.SubTotal;
  3625. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3626. foodandotherStartIndex++;
  3627. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3628. }
  3629. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3630. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3631. {
  3632. table1.Rows.RemoveAt(i - 1);
  3633. }
  3634. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3635. dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3636. dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3637. dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3638. foreach (var key in dic.Keys)
  3639. {
  3640. builder.MoveToBookmark(key);
  3641. builder.Write(dic[key]);
  3642. }
  3643. //模板文件名
  3644. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3645. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3646. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3647. return Ok(JsonView(true, "成功", new { Url = url }));
  3648. }
  3649. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3650. {
  3651. //获取模板
  3652. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3653. //载入模板
  3654. WorkbookDesigner designer = new WorkbookDesigner();
  3655. designer.Workbook = new Workbook(tempPath);
  3656. Dictionary<string, string> dic = new Dictionary<string, string>();
  3657. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3658. {
  3659. List<string> list = new List<string>();
  3660. try
  3661. {
  3662. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3663. foreach (var item in spilitArr)
  3664. {
  3665. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3666. var depCode = spDotandEmpty[2].Substring(0, 3);
  3667. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3668. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3669. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3670. list.Add(depName);
  3671. list.Add(arrName);
  3672. }
  3673. list = list.Distinct().ToList();
  3674. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3675. }
  3676. catch (Exception)
  3677. {
  3678. dic.Add("ReturnCode", "行程录入不正确!");
  3679. }
  3680. }
  3681. else
  3682. {
  3683. dic.Add("ReturnCode", "未录入行程!");
  3684. }
  3685. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3686. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3687. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3688. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3689. {
  3690. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3691. dic.Add("Day", sp.Days.ToString());
  3692. }
  3693. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3694. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3695. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3696. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3697. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3698. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3699. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3700. designer.SetDataSource("Name", Names);
  3701. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3702. designer.SetDataSource("Day", dic["Day"] + "天");
  3703. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3704. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3705. int startIndex = 10;
  3706. const int startIndexcopy = 10;
  3707. if (dac2.Count == dac3.Count)//国家 币种 金额
  3708. {
  3709. for (int i = 0; i < dac2.Count; i++)
  3710. {
  3711. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3712. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3713. }
  3714. }
  3715. DataTable dtdac1 = new DataTable();
  3716. List<string> place = new List<string>();
  3717. dtdac1.Columns.AddRange(new DataColumn[] {
  3718. new DataColumn(){ ColumnName = "city"},
  3719. new DataColumn(){ ColumnName = "curr"},
  3720. new DataColumn(){ ColumnName = "criterion"},
  3721. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3722. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3723. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3724. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3725. new DataColumn(){ ColumnName = "costRMB"},
  3726. });
  3727. DataTable dtdac2 = new DataTable();
  3728. dtdac2.Columns.AddRange(new DataColumn[] {
  3729. new DataColumn(){ ColumnName = "city"},
  3730. new DataColumn(){ ColumnName = "curr"},
  3731. new DataColumn(){ ColumnName = "criterion"},
  3732. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3733. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3734. new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
  3735. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3736. new DataColumn(){ ColumnName = "costRMB"},
  3737. });
  3738. dtdac1.TableName = "tb1";
  3739. dtdac2.TableName = "tb2";
  3740. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3741. foreach (var item in dac1)
  3742. {
  3743. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3744. if (place.Contains(item.Place))
  3745. {
  3746. continue;
  3747. }
  3748. DataRow row = dtdac1.NewRow();
  3749. row["city"] = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3750. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3751. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3752. row["curr"] = currency;
  3753. row["rate"] = rate;
  3754. row["criterion"] = item.Cost;
  3755. row["number"] = 1;
  3756. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3757. //row["costRMB"] = rbmPrice;
  3758. dtdac1.Rows.Add(row);
  3759. place.Add(item.Place);
  3760. }
  3761. place = new List<string>();
  3762. foreach (var item in dac2)
  3763. {
  3764. item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
  3765. if (place.Contains(item.Place))
  3766. {
  3767. continue;
  3768. }
  3769. DataRow row = dtdac2.NewRow();
  3770. row["city"] = item.Place;
  3771. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
  3772. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3773. row["curr"] = currency;
  3774. row["rate"] = rate;
  3775. row["criterion"] = item.Cost;
  3776. row["number"] = 1;
  3777. row["day"] = dac2.FindAll(x => x.Place == item.Place).Count;
  3778. //row["cost"] = item.SubTotal;
  3779. //row["costRMB"] = rbmPrice;
  3780. dtdac2.Rows.Add(row);
  3781. place.Add(item.Place);
  3782. //dac2totalPrice += rbmPrice;
  3783. }
  3784. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  3785. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  3786. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3787. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  3788. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元,公务舱:{_EnterExitCosts.OutsaideGWPay.ToString("#0.00")}元";
  3789. string cellStr = $" 5.其他费用(签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,保险费 :{_EnterExitCosts.Safe.ToString("#0.00")}元)";
  3790. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + _EnterExitCosts.Visa + _EnterExitCosts.Safe;
  3791. string celllastStr = $" 经审核,住宿费 {dac1totalPrice.ToString("#0.00")} 元,伙食费和公杂费 {dac2totalPrice.ToString(".00")} 元,培训费 元,国际旅费 {(_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00")} 元,其他费用 {(_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00")} 元,本次出国经费预算合计为 {s.ToString("#0.00")} 元。其中:市本级安排 。";
  3792. designer.SetDataSource("cell4Str", cell4Str);
  3793. designer.SetDataSource("cellStr", cellStr);
  3794. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  3795. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3796. designer.SetDataSource("celllastStr", celllastStr);
  3797. Workbook wb = designer.Workbook;
  3798. var sheet = wb.Worksheets[0];
  3799. //绑定datatable数据集
  3800. designer.SetDataSource(dtdac1);
  3801. designer.SetDataSource(dtdac2);
  3802. designer.Process();
  3803. var rowStart = dtdac1.Rows.Count;
  3804. while (rowStart > 0)
  3805. {
  3806. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  3807. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3808. startIndex++;
  3809. rowStart--;
  3810. }
  3811. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  3812. startIndex += 1; //总计行
  3813. rowStart = dtdac2.Rows.Count;
  3814. while (rowStart > 0)
  3815. {
  3816. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  3817. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  3818. startIndex++;
  3819. rowStart--;
  3820. }
  3821. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  3822. wb.CalculateFormula(true);
  3823. //模板文件名
  3824. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  3825. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3826. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3827. return Ok(JsonView(true, "成功", new { Url = url }));
  3828. }
  3829. }
  3830. else if (dto.ExportType == 2) //表格
  3831. {
  3832. //利用键值对存放数据
  3833. Dictionary<string, string> dic = new Dictionary<string, string>();
  3834. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3835. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3836. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3837. dic.Add("Day", sp.Days.ToString());
  3838. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3839. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  3840. {
  3841. //获取模板
  3842. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  3843. //载入模板
  3844. Document doc = new Document(tempPath);
  3845. DocumentBuilder builder = new DocumentBuilder(doc);
  3846. dic.Add("TeamName", _DelegationInfo.TeamName);
  3847. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3848. dic.Add("TellPhone", _DelegationInfo.TellPhone);
  3849. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  3850. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  3851. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3852. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3853. int rowCount = 10;//总人数行
  3854. int startRowIndex = 7; //起始行
  3855. for (int i = 0; i < DeleClientList.Count; i++)
  3856. {
  3857. builder.MoveToCell(0, startRowIndex, 0, 0);
  3858. builder.Write(DeleClientList[i].Name); //出国人员姓名
  3859. builder.MoveToCell(0, startRowIndex, 1, 0);
  3860. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  3861. builder.Write(sex);//性别
  3862. builder.MoveToCell(0, startRowIndex, 2, 0);
  3863. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  3864. builder.MoveToCell(0, startRowIndex, 3, 0);
  3865. builder.Write(DeleClientList[i].Company);//工作单位
  3866. builder.MoveToCell(0, startRowIndex, 4, 0);
  3867. builder.Write(DeleClientList[i].Job);//职务及级别
  3868. builder.MoveToCell(0, startRowIndex, 5, 0);
  3869. builder.Write("");//人员属性
  3870. builder.MoveToCell(0, startRowIndex, 6, 0);
  3871. builder.Write("");//上次出国时间
  3872. startRowIndex++;
  3873. }
  3874. int nullRow = rowCount - DeleClientList.Count;//空行
  3875. for (int i = 0; i < nullRow; i++)
  3876. {
  3877. table1.Rows.Remove(table1.Rows[startRowIndex]);
  3878. }
  3879. foreach (var key in dic.Keys)
  3880. {
  3881. builder.MoveToBookmark(key);
  3882. builder.Write(dic[key]);
  3883. }
  3884. //模板文件名
  3885. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  3886. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3887. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3888. return Ok(JsonView(true, "成功", new { Url = url }));
  3889. }
  3890. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  3891. {
  3892. //获取模板
  3893. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  3894. //载入模板
  3895. Document doc = new Document(tempPath);
  3896. DocumentBuilder builder = new DocumentBuilder(doc);
  3897. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  3898. dic.Add("Names", Names);
  3899. int accommodationStartIndex = 6;
  3900. int foodandotherStartIndex = 19;//
  3901. int accommodationRows = 12, foodandotherRows = 12;
  3902. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3903. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  3904. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3905. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3906. decimal dac1totalPrice = 0.00M;
  3907. foreach (var dac in dac1)
  3908. {
  3909. if (dac.SubTotal == 0)
  3910. {
  3911. continue;
  3912. }
  3913. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3914. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3915. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3916. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3917. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3918. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3919. builder.Write(currency);//币种
  3920. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3921. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3922. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3923. builder.Write("");//人数
  3924. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3925. builder.Write("");//天数
  3926. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3927. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3928. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3929. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3930. builder.Write(rate.ToString("#0.0000"));//汇率
  3931. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3932. decimal rbmPrice = rate * dac.SubTotal;
  3933. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3934. accommodationStartIndex++;
  3935. dac1totalPrice += rbmPrice;
  3936. }
  3937. dic.Add("dac1totalPrice", dac1totalPrice.ToString());
  3938. if (dac2.Count == dac3.Count)//国家 币种 金额
  3939. {
  3940. for (int i = 0; i < dac2.Count; i++)
  3941. {
  3942. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3943. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3944. }
  3945. }
  3946. decimal dac2totalPrice = 0.00M;
  3947. foreach (var dac in dac2)
  3948. {
  3949. if (dac.SubTotal == 0)
  3950. {
  3951. continue;
  3952. }
  3953. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3954. builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
  3955. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3956. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
  3957. builder.Write(currency);//币种
  3958. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3959. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3960. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3961. builder.Write("");//人数
  3962. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3963. builder.Write("");//天数
  3964. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3965. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3966. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3967. decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
  3968. builder.Write(rate.ToString());//汇率
  3969. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3970. decimal rbmPrice = rate * dac.SubTotal;
  3971. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3972. foodandotherStartIndex++;
  3973. dac2totalPrice += rbmPrice;
  3974. }
  3975. dic.Add("dac2totalPrice", dac2totalPrice.ToString());
  3976. //删除空行
  3977. if (dac1.Count < accommodationRows)
  3978. {
  3979. int nullRow = accommodationRows - dac1.Count;
  3980. }
  3981. foreach (var key in dic.Keys)
  3982. {
  3983. builder.MoveToBookmark(key);
  3984. builder.Write(dic[key]);
  3985. }
  3986. //模板文件名
  3987. string strFileName = $"省级单位出(境)经费报销单.docx";
  3988. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3990. return Ok(JsonView(true, "成功", new { Url = url }));
  3991. }
  3992. }
  3993. else if (dto.ExportType == 3)
  3994. {
  3995. if (dto.SubTypeId == 1) //团组成员名单
  3996. {
  3997. if (DeleClientList.Count < 1)
  3998. {
  3999. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4000. }
  4001. //获取模板
  4002. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4003. //载入模板
  4004. Document doc = new Document(tempPath);
  4005. DocumentBuilder builder = new DocumentBuilder(doc);
  4006. //获取word里所有表格
  4007. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4008. //获取所填表格的序数
  4009. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4010. var rowStart = tableOne.Rows[0]; //获取第1行
  4011. //循环赋值
  4012. for (int i = 0; i < DeleClientList.Count; i++)
  4013. {
  4014. builder.MoveToCell(0, i + 1, 0, 0);
  4015. builder.Write(DeleClientList[i].Name);
  4016. builder.MoveToCell(0, i + 1, 1, 0);
  4017. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4018. builder.Write(sex);
  4019. builder.MoveToCell(0, i + 1, 2, 0);
  4020. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4021. builder.MoveToCell(0, i + 1, 3, 0);
  4022. builder.Write(DeleClientList[i].Company);
  4023. builder.MoveToCell(0, i + 1, 4, 0);
  4024. builder.Write(DeleClientList[i].Job);
  4025. }
  4026. //删除多余行
  4027. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4028. {
  4029. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4030. }
  4031. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4032. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4033. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4034. return Ok(JsonView(true, "成功", new { Url = url }));
  4035. }
  4036. }
  4037. return Ok(JsonView(false,"操作失败!"));
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. return Ok(JsonView(false, ex.Message));
  4042. }
  4043. }
  4044. /// <summary>
  4045. /// 团组模块 - 出入境费用 - 明细表导出
  4046. /// </summary>
  4047. /// <returns></returns>
  4048. [HttpPost]
  4049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4050. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4051. {
  4052. try
  4053. {
  4054. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4055. if (data.Code != 0)
  4056. {
  4057. return Ok(JsonView(false, data.Msg));
  4058. }
  4059. return Ok(JsonView(true, data.Msg, data.Data));
  4060. }
  4061. catch (Exception ex)
  4062. {
  4063. return Ok(JsonView(false, ex.Message));
  4064. }
  4065. }
  4066. /// <summary>
  4067. /// 团组模块 - 出入境费用 - 子项删除
  4068. /// </summary>
  4069. /// <returns></returns>
  4070. [HttpPost]
  4071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4072. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4073. {
  4074. try
  4075. {
  4076. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4077. if (data.Code != 0)
  4078. {
  4079. return Ok(JsonView(false, data.Msg));
  4080. }
  4081. return Ok(JsonView(true, "操作成功!", data.Data));
  4082. }
  4083. catch (Exception ex)
  4084. {
  4085. return Ok(JsonView(false, ex.Message));
  4086. }
  4087. }
  4088. /// <summary>
  4089. /// 团组模块 - 出入境国家费用标准 List
  4090. /// </summary>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4095. {
  4096. try
  4097. {
  4098. Stopwatch sw = new Stopwatch();
  4099. sw.Start();
  4100. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4101. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4102. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4103. Where gntf.Isdel = 0");
  4104. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4105. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4106. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4107. //foreach (var item in nationalTravel)
  4108. //{
  4109. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4110. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4111. // if (otherData != null)
  4112. // {
  4113. // cityData.Remove(otherData);
  4114. // cityData.Add(otherData);
  4115. // }
  4116. // nationalTravelFeeData1.Add(new
  4117. // {
  4118. // Country = item.Country,
  4119. // CityData = cityData
  4120. // });
  4121. //}
  4122. sw.Stop();
  4123. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, ex.Message));
  4128. throw;
  4129. }
  4130. }
  4131. /// <summary>
  4132. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4133. /// </summary>
  4134. /// <returns></returns>
  4135. [HttpPost]
  4136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4137. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4138. {
  4139. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4140. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4141. List<string> countryData = new List<string>();
  4142. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4143. countryData = countryData.Distinct().ToList();
  4144. List<dynamic> dataSource = new List<dynamic>();
  4145. foreach (var item in countryData)
  4146. {
  4147. List<string> cityData1 = new List<string>();
  4148. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4149. var countryData2 = new
  4150. {
  4151. CountryName = item,
  4152. CityData = cityData1
  4153. };
  4154. dataSource.Add(countryData2);
  4155. }
  4156. return Ok(JsonView(true, "查询成功!", dataSource));
  4157. }
  4158. /// <summary>
  4159. /// 团组模块 - 出入境国家费用标准 Page List
  4160. /// </summary>
  4161. /// <returns></returns>
  4162. [HttpPost]
  4163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4164. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4165. {
  4166. int portId = dto.PortType;
  4167. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4168. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4169. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4170. string whereSql = string.Empty;
  4171. if (!string.IsNullOrEmpty(dto.Country))
  4172. {
  4173. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4174. }
  4175. if (!string.IsNullOrEmpty(dto.City))
  4176. {
  4177. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4178. }
  4179. string pageSql = string.Format(@"Select * From (
  4180. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4181. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4182. From Grp_NationalTravelFee gntf
  4183. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4184. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4185. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4186. RefAsync<int> total = 0;
  4187. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4188. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4189. }
  4190. /// <summary>
  4191. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4192. /// </summary>
  4193. /// <returns></returns>
  4194. [HttpPost]
  4195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4196. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4197. {
  4198. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4199. int portId = dto.PortType;
  4200. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4201. string whereSql = string.Empty;
  4202. if (!string.IsNullOrEmpty(dto.Country))
  4203. {
  4204. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4205. }
  4206. if (!string.IsNullOrEmpty(dto.City))
  4207. {
  4208. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4209. }
  4210. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4211. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4212. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4213. From Grp_NationalTravelFee gntf
  4214. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4215. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4216. Where gntf.Isdel = 0 {0} ", whereSql);
  4217. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4218. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4219. }
  4220. /// <summary>
  4221. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4222. /// </summary>
  4223. /// <returns></returns>
  4224. [HttpPost]
  4225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4226. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4227. {
  4228. try
  4229. {
  4230. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4231. if (data.Code != 0)
  4232. {
  4233. return Ok(JsonView(false, data.Msg));
  4234. }
  4235. return Ok(JsonView(true, "操作成功!", data.Data));
  4236. }
  4237. catch (Exception ex)
  4238. {
  4239. return Ok(JsonView(false, ex.Message));
  4240. }
  4241. }
  4242. /// <summary>
  4243. /// 团组模块 - 出入境国家费用标准 - Del
  4244. /// </summary>
  4245. /// <returns></returns>
  4246. [HttpPost]
  4247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4248. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4249. {
  4250. try
  4251. {
  4252. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4253. {
  4254. Id = dto.Id,
  4255. DeleteUserId = dto.DeleteUserId,
  4256. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4257. IsDel = 1
  4258. };
  4259. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4260. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4261. .WhereColumns(it => new { it.Id })
  4262. .ExecuteCommandAsync();
  4263. if (delStatus <= 0)
  4264. {
  4265. return Ok(JsonView(false, "删除失败!"));
  4266. }
  4267. return Ok(JsonView(true, "操作成功!"));
  4268. }
  4269. catch (Exception ex)
  4270. {
  4271. return Ok(JsonView(false, ex.Message));
  4272. }
  4273. }
  4274. #endregion
  4275. #region 签证费用录入
  4276. /// <summary>
  4277. /// 根据diid查询签证费用列表
  4278. /// </summary>
  4279. /// <param name="dto"></param>
  4280. /// <returns></returns>
  4281. [HttpPost]
  4282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4283. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4284. {
  4285. try
  4286. {
  4287. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4288. if (groupData.Code != 0)
  4289. {
  4290. return Ok(JsonView(false, groupData.Msg));
  4291. }
  4292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4293. }
  4294. catch (Exception ex)
  4295. {
  4296. return Ok(JsonView(false, ex.Message));
  4297. }
  4298. }
  4299. /// <summary>
  4300. /// 根据签证费用Id查询单条数据及c表数据
  4301. /// </summary>
  4302. /// <param name="dto"></param>
  4303. /// <returns></returns>
  4304. [HttpPost]
  4305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4306. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4307. {
  4308. try
  4309. {
  4310. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4311. if (groupData.Code != 0)
  4312. {
  4313. return Ok(JsonView(false, groupData.Msg));
  4314. }
  4315. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4316. }
  4317. catch (Exception ex)
  4318. {
  4319. return Ok(JsonView(false, ex.Message));
  4320. }
  4321. }
  4322. /// <summary>
  4323. /// 签证费用删除
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4330. {
  4331. try
  4332. {
  4333. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4334. if (!res)
  4335. {
  4336. return Ok(JsonView(false, "删除失败"));
  4337. }
  4338. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  4339. {
  4340. IsDel = 1,
  4341. DeleteUserId = dto.DeleteUserId,
  4342. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4343. }).ExecuteCommandAsync();
  4344. return Ok(JsonView(true, "删除成功!"));
  4345. }
  4346. catch (Exception ex)
  4347. {
  4348. return Ok(JsonView(false, "程序错误!"));
  4349. throw;
  4350. }
  4351. }
  4352. /// <summary>
  4353. /// 签证费用录入下拉框初始化
  4354. /// </summary>
  4355. /// <returns></returns>
  4356. [HttpPost]
  4357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4358. public async Task<IActionResult> VisaPriceAddSelect()
  4359. {
  4360. try
  4361. {
  4362. //支付方式
  4363. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4364. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4365. //币种
  4366. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4367. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4368. //乘客类型
  4369. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4370. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4371. //卡类型
  4372. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4373. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4374. var data = new
  4375. {
  4376. Payment = _Payment,
  4377. CurrencyList = _CurrencyList,
  4378. PassengerType = _PassengerType,
  4379. BankCard = _BankCard
  4380. };
  4381. return Ok(JsonView(true, "查询成功!", data));
  4382. }
  4383. catch (Exception ex)
  4384. {
  4385. return Ok(JsonView(false, "程序错误!"));
  4386. throw;
  4387. }
  4388. }
  4389. /// <summary>
  4390. /// 签证费用录入操作(Status:1.新增,2.修改)
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4397. {
  4398. try
  4399. {
  4400. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4401. if (groupData.Code != 0)
  4402. {
  4403. return Ok(JsonView(false, groupData.Msg));
  4404. }
  4405. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4406. }
  4407. catch (Exception ex)
  4408. {
  4409. return Ok(JsonView(false, ex.Message));
  4410. }
  4411. }
  4412. #endregion
  4413. #region op费用录入
  4414. /// <summary>
  4415. /// 根据diid查询op费用列表
  4416. /// </summary>
  4417. /// <param name="dto"></param>
  4418. /// <returns></returns>
  4419. [HttpPost]
  4420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4421. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4422. {
  4423. try
  4424. {
  4425. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4426. if (groupData.Code != 0)
  4427. {
  4428. return Ok(JsonView(false, groupData.Msg));
  4429. }
  4430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4431. }
  4432. catch (Exception ex)
  4433. {
  4434. return Ok(JsonView(false, ex.Message));
  4435. }
  4436. }
  4437. /// <summary>
  4438. /// 根据op费用Id查询单条数据及c表数据
  4439. /// </summary>
  4440. /// <param name="dto"></param>
  4441. /// <returns></returns>
  4442. [HttpPost]
  4443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4444. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4445. {
  4446. try
  4447. {
  4448. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4449. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4450. var data = new
  4451. {
  4452. CarTouristGuideGround = _groupData,
  4453. CreditCardPayment = _creditCardPayment
  4454. };
  4455. return Ok(JsonView(true, "查询成功!", data));
  4456. }
  4457. catch (Exception ex)
  4458. {
  4459. return Ok(JsonView(false, "程序错误!"));
  4460. }
  4461. }
  4462. /// <summary>
  4463. /// op费用删除
  4464. /// </summary>
  4465. /// <param name="dto"></param>
  4466. /// <returns></returns>
  4467. [HttpPost]
  4468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4469. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4470. {
  4471. try
  4472. {
  4473. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4474. if (!res)
  4475. {
  4476. return Ok(JsonView(false, "删除失败"));
  4477. }
  4478. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4479. {
  4480. IsDel = 1,
  4481. DeleteUserId = dto.DeleteUserId,
  4482. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4483. }).ExecuteCommandAsync();
  4484. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4485. {
  4486. IsDel = 1,
  4487. DeleteUserId = dto.DeleteUserId,
  4488. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4489. }).ExecuteCommandAsync();
  4490. return Ok(JsonView(true, "删除成功!"));
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(false, "程序错误!"));
  4495. throw;
  4496. }
  4497. }
  4498. /// <summary>
  4499. /// op费用录入操作(Status:1.新增,2.修改)
  4500. /// </summary>
  4501. /// <param name="dto"></param>
  4502. /// <returns></returns>
  4503. [HttpPost]
  4504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4505. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  4506. {
  4507. try
  4508. {
  4509. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  4510. if (groupData.Code != 0)
  4511. {
  4512. return Ok(JsonView(false, groupData.Msg));
  4513. }
  4514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, ex.Message));
  4519. }
  4520. }
  4521. /// <summary>
  4522. /// 填写费用详细页面初始化绑定
  4523. /// </summary>
  4524. /// <param name="dto"></param>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  4529. {
  4530. try
  4531. {
  4532. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  4533. if (groupData.Code != 0)
  4534. {
  4535. return Ok(JsonView(false, groupData.Msg));
  4536. }
  4537. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4538. }
  4539. catch (Exception ex)
  4540. {
  4541. return Ok(JsonView(false, ex.Message));
  4542. }
  4543. }
  4544. /// <summary>
  4545. /// 根据op费用Id查询详细数据
  4546. /// </summary>
  4547. /// <param name="dto"></param>
  4548. /// <returns></returns>
  4549. [HttpPost]
  4550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4551. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  4552. {
  4553. try
  4554. {
  4555. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  4556. if (groupData.Code != 0)
  4557. {
  4558. return Ok(JsonView(false, groupData.Msg));
  4559. }
  4560. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4561. }
  4562. catch (Exception ex)
  4563. {
  4564. return Ok(JsonView(false, ex.Message));
  4565. }
  4566. }
  4567. /// <summary>
  4568. /// OP费用录入填写详情
  4569. /// </summary>
  4570. /// <param name="dto"></param>
  4571. /// <returns></returns>
  4572. [HttpPost]
  4573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4574. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  4575. {
  4576. try
  4577. {
  4578. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  4579. if (groupData.Code != 0)
  4580. {
  4581. return Ok(JsonView(false, groupData.Msg));
  4582. }
  4583. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4584. }
  4585. catch (Exception ex)
  4586. {
  4587. return Ok(JsonView(false, ex.Message));
  4588. }
  4589. }
  4590. /// <summary>
  4591. /// 获取三公详细所有城市
  4592. /// </summary>
  4593. /// <returns></returns>
  4594. [HttpGet]
  4595. public IActionResult OpCarCityResult()
  4596. {
  4597. var jw = JsonView(false);
  4598. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x=>x.IsDel == 0).Select(x => new
  4599. {
  4600. x.Id,
  4601. x.Country,
  4602. x.City,
  4603. }).ToList();
  4604. if (data.Count > 0)
  4605. {
  4606. jw = JsonView(true, "获取成功!", data);
  4607. }
  4608. else
  4609. {
  4610. jw.Msg = "城市数据未空!";
  4611. jw.Data = new string[0];
  4612. }
  4613. return Ok(jw);
  4614. }
  4615. #endregion
  4616. #region 团组成本
  4617. /// <summary>
  4618. /// 团组成本数据初始化
  4619. /// </summary>
  4620. /// <param name="dto"></param>
  4621. /// <returns></returns>
  4622. [HttpPost]
  4623. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  4624. {
  4625. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  4626. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  4627. WHEN COUNT(*) >= 0 THEN 'True'
  4628. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  4629. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  4630. ").ToList(); //团组列表
  4631. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  4632. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  4633. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  4634. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  4635. if (groupinfoValue != null)
  4636. {
  4637. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  4638. var spArr = new string[1] { countryArr };
  4639. if (countryArr.Contains("|"))
  4640. {
  4641. spArr = countryArr.Split("|");
  4642. }
  4643. else if (countryArr.Contains("、"))
  4644. {
  4645. spArr = countryArr.Split("、");
  4646. }
  4647. foreach (var item in spArr.Where(x=>!string.IsNullOrWhiteSpace(x)).ToList())
  4648. {
  4649. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  4650. if (dbQueryCountry != null)
  4651. {
  4652. visaCountryInfoArr.Add(dbQueryCountry);
  4653. }
  4654. }
  4655. }
  4656. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  4657. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  4658. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  4659. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  4660. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  4661. //GroupCostParameter.Add(new
  4662. // Grp_GroupCostParameter());
  4663. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  4664. return Ok(JsonView(new
  4665. {
  4666. groupList,
  4667. groupInfo,
  4668. groupChecks,
  4669. groupCost = groupCostMap,
  4670. hotelNumber,
  4671. GroupCostParameter = GroupCostParameterMap,
  4672. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  4673. {
  4674. x.VisaCountry,
  4675. x.VisaPrice,
  4676. x.Id,
  4677. }).ToList(),
  4678. baoPi = _GroupCostParameterRepository.GetBaoPi(diid)
  4679. }));
  4680. }
  4681. /// <summary>
  4682. /// 团组成本信息保存
  4683. /// </summary>
  4684. /// <param name="dto"></param>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  4688. {
  4689. if (dto.Diid <= 0 || dto.Userid <= 0)
  4690. {
  4691. return Ok(JsonView(false));
  4692. }
  4693. JsonView jw = null;
  4694. bool isTrue = false;
  4695. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  4696. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  4697. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  4698. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  4699. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  4700. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  4701. try
  4702. {
  4703. _sqlSugar.BeginTran();
  4704. isTrue = await _GroupCostRepository.
  4705. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  4706. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  4707. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  4708. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  4709. _sqlSugar.CommitTran();
  4710. jw = JsonView(true, "保存成功!", isTrue);
  4711. }
  4712. catch (Exception)
  4713. {
  4714. _sqlSugar.RollbackTran();
  4715. jw = JsonView(false);
  4716. }
  4717. return Ok(jw);
  4718. }
  4719. /// <summary>
  4720. /// 司兼导数据
  4721. /// </summary>
  4722. /// <param name="dto"></param>
  4723. /// <returns></returns>
  4724. [HttpPost]
  4725. public IActionResult GetCarGuides(CarGuidesDto dto)
  4726. {
  4727. JsonView jw = null;
  4728. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  4729. jw = JsonView(true, "获取成功!", Data);
  4730. return Ok(jw);
  4731. }
  4732. /// <summary>
  4733. /// 导游数据
  4734. /// </summary>
  4735. /// <param name="dto"></param>
  4736. /// <returns></returns>
  4737. [HttpPost]
  4738. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  4739. {
  4740. JsonView jw = null;
  4741. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  4742. // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
  4743. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  4744. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  4745. jw = JsonView(true, "获取成功!", Data);
  4746. return Ok(jw);
  4747. }
  4748. /// <summary>
  4749. /// 成本车数据
  4750. /// </summary>
  4751. /// <param name="dto"></param>
  4752. /// <returns></returns>
  4753. [HttpPost]
  4754. public IActionResult GetCarInfo(CarGuidesDto dto)
  4755. {
  4756. JsonView jw = null;
  4757. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  4758. jw = JsonView(true, "获取成功!", Data);
  4759. return Ok(jw);
  4760. }
  4761. /// <summary>
  4762. /// 景点数据
  4763. /// </summary>
  4764. /// <param name="dto"></param>
  4765. /// <returns></returns>
  4766. [HttpPost]
  4767. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  4768. {
  4769. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  4770. return Ok(JsonView(true, "获取成功!", Data));
  4771. }
  4772. /// <summary>
  4773. /// 成本通知
  4774. /// </summary>
  4775. /// <param name="dto"></param>
  4776. /// <returns></returns>
  4777. [HttpPost]
  4778. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  4779. {
  4780. if (dto.Diid < 0)
  4781. {
  4782. return Ok(JsonView(false));
  4783. }
  4784. JsonView jw = null;
  4785. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  4786. if (GroupCostParameter != null)
  4787. {
  4788. int IsShare = 0;
  4789. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  4790. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  4791. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id,IsShare);
  4792. string msg = string.Empty;
  4793. if (isTrue)
  4794. {
  4795. if (IsShare == 0)
  4796. {
  4797. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  4798. }
  4799. else
  4800. {
  4801. msg = "通知成功,其他模块操作人员可见此成本信息!";
  4802. }
  4803. jw = JsonView(isTrue, msg);
  4804. }
  4805. else
  4806. {
  4807. msg = "修改失败!";
  4808. jw = JsonView(isTrue, msg);
  4809. }
  4810. }
  4811. else
  4812. {
  4813. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  4814. }
  4815. return Ok(jw);
  4816. }
  4817. /// <summary>
  4818. /// 导出收款账单
  4819. /// </summary>
  4820. /// <param name="dto"></param>
  4821. /// <returns></returns>
  4822. [HttpPost]
  4823. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  4824. {
  4825. if (dto.Diid == 0)
  4826. {
  4827. return Ok(JsonView(false, "请传递团组id"));
  4828. }
  4829. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  4830. if (deleInfo.Code != 0)
  4831. {
  4832. return Ok(JsonView(false, "团组信息查询失败!"));
  4833. }
  4834. var di = deleInfo.Data as DelegationInfoWebView;
  4835. if (di != null)
  4836. {
  4837. //文件名
  4838. string strFileName = di.TeamName + "-收款账单.doc";
  4839. //获取模板
  4840. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  4841. //载入模板
  4842. Document doc = new Document(tmppath);
  4843. decimal TotalPrice = 0.00M;
  4844. string itemStr = string.Empty;
  4845. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  4846. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4847. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  4848. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  4849. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  4850. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  4851. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  4852. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  4853. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x=>x.Key);
  4854. foreach(var cost in groupCostType)
  4855. {
  4856. var List = cost.ToList();
  4857. if (cost.Key == "A")
  4858. {
  4859. foreach (var ListItem in List)
  4860. {
  4861. if (ListItem.number > 0)
  4862. {
  4863. if (ListItem.code.Contains("TBR"))
  4864. {
  4865. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4866. }
  4867. else
  4868. {
  4869. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4870. }
  4871. TotalPrice += (ListItem.number * ListItem.price);
  4872. }
  4873. }
  4874. }
  4875. else
  4876. {
  4877. itemStr = itemStr.Insert(0, "A段\r\n");
  4878. itemStr += "B段\r\n";
  4879. foreach (var ListItem in List)
  4880. {
  4881. if (ListItem.number > 0)
  4882. {
  4883. if (ListItem.code.Contains("TBR"))
  4884. {
  4885. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4886. }
  4887. else
  4888. {
  4889. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  4890. }
  4891. TotalPrice += (ListItem.number * ListItem.price);
  4892. }
  4893. }
  4894. }
  4895. }
  4896. #region 替换Word模板书签内容
  4897. Dictionary<string, string> marks = new Dictionary<string, string>();
  4898. marks.Add("To", di.ClientUnit);//付款方
  4899. marks.Add("ToTel", di.TellPhone);//付款方电话
  4900. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  4901. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  4902. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  4903. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  4904. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  4905. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  4906. marks.Add("PayItemContent", itemStr);//详细信息
  4907. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  4908. #endregion
  4909. ////注
  4910. //if (doc.Range.Bookmarks["Attention"] != null)
  4911. //{
  4912. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  4913. // mark.Text = frList[0].Attention;
  4914. //}
  4915. foreach (var item in marks.Keys)
  4916. {
  4917. if (doc.Range.Bookmarks[item] != null)
  4918. {
  4919. Bookmark mark = doc.Range.Bookmarks[item];
  4920. mark.Text = marks[item];
  4921. }
  4922. }
  4923. byte[] bytes = null;
  4924. using (MemoryStream stream = new MemoryStream())
  4925. {
  4926. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  4927. bytes = stream.ToArray();
  4928. }
  4929. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  4930. return Ok(JsonView(true,"",new
  4931. {
  4932. Data = bytes,
  4933. strFileName,
  4934. }));
  4935. }
  4936. else
  4937. {
  4938. return Ok(JsonView(false,"团组信息不存在!"));
  4939. }
  4940. }
  4941. /// <summary>
  4942. /// 导出团组成本
  4943. /// </summary>
  4944. /// <param name="dto"></param>
  4945. /// <returns></returns>
  4946. [HttpPost]
  4947. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  4948. {
  4949. var jw = JsonView(false);
  4950. if (dto.Diid == 0)
  4951. {
  4952. return Ok(JsonView(false, "请传递团组id"));
  4953. }
  4954. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  4955. if (deleInfo.Code != 0)
  4956. {
  4957. return Ok(JsonView(false, "团组信息查询失败!"));
  4958. }
  4959. var di = deleInfo.Data as DelegationInfoWebView;
  4960. if (di == null)
  4961. {
  4962. return Ok(JsonView(false, "团组信息查询失败!"));
  4963. }
  4964. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  4965. WorkbookDesigner designer = new WorkbookDesigner();
  4966. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  4967. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  4968. for (int i = 0; i < List_GC.Count; i++)
  4969. {
  4970. GroupCost_Excel gc = new GroupCost_Excel();
  4971. gc.Id = List_GC[i].Id;
  4972. gc.Diid = List_GC[i].Diid.ToString();
  4973. gc.DAY = List_GC[i].DAY;
  4974. string week = "";
  4975. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  4976. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  4977. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  4978. gc.ITIN = List_GC[i].ITIN;
  4979. gc.CarType = List_GC[i].CarType;
  4980. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  4981. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  4982. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  4983. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  4984. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  4985. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  4986. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  4987. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  4988. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  4989. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  4990. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  4991. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  4992. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  4993. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  4994. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  4995. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  4996. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  4997. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  4998. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  4999. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  5000. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  5001. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  5002. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  5003. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  5004. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  5005. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  5006. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  5007. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  5008. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  5009. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  5010. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  5011. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  5012. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  5013. List_GC1.Add(gc);
  5014. }
  5015. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  5016. dt.TableName = "TB";
  5017. //报表标题等不用dt的值
  5018. designer.SetDataSource("TeamName", dto.title.TeamName);
  5019. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  5020. designer.SetDataSource("Tax", dto.title.Tax);
  5021. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  5022. designer.SetDataSource("Currency", dto.title.Currency);
  5023. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  5024. designer.SetDataSource("Rate", dto.title.Rate);
  5025. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  5026. var Aparams = hotels.Find(x => x.Type == "Default");
  5027. if (Aparams == null)
  5028. {
  5029. return Ok(jw);
  5030. }
  5031. //酒店数量
  5032. var txtSGRNumber = Aparams.SGR.ToString();
  5033. var txtTBRNumber = Aparams.TBR.ToString();
  5034. var txtJSESNumber = Aparams.JSES.ToString();
  5035. var txtSUITENumbe = Aparams.SUITE.ToString();
  5036. if (dto.costType == "B")
  5037. {
  5038. Aparams = hotels.Find(x => x.Type == "A");
  5039. var Bparams = hotels.Find(x => x.Type == "B");
  5040. if (Aparams == null || Bparams == null)
  5041. {
  5042. return Ok(jw);
  5043. }
  5044. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  5045. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  5046. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  5047. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  5048. }
  5049. designer.SetDataSource("SGRNumber", txtSGRNumber);
  5050. designer.SetDataSource("TBRNumber", txtTBRNumber);
  5051. designer.SetDataSource("JSESNumber", txtJSESNumber);
  5052. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  5053. var ws = designer.Workbook.Worksheets[0];
  5054. int Row = List_GC.Count;
  5055. int startIndex = 11;
  5056. int HideRows = 0;
  5057. List<int> hideRowsList = new List<int>();
  5058. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  5059. #region A段left数据
  5060. var left = dto.leftInfo.Find(x => x.Type == "A");
  5061. if (left == null)
  5062. {
  5063. return Ok(jw);
  5064. }
  5065. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  5066. if (leftBindData != null)
  5067. {
  5068. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  5069. designer.SetDataSource("VisaRS", leftBindData.rs);
  5070. designer.SetDataSource("VisaXS", leftBindData.xs);
  5071. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5072. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5073. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5074. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5075. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5076. }
  5077. else {
  5078. hideRowsList.Add(Row + startIndex + HideRows);
  5079. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5080. }
  5081. HideRows += 2;
  5082. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  5083. if (leftBindData != null)
  5084. {
  5085. designer.SetDataSource("BXDRCB", leftBindData.cb);
  5086. designer.SetDataSource("BXRS", leftBindData.rs);
  5087. designer.SetDataSource("BXXS", leftBindData.xs);
  5088. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5089. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5090. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5091. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5092. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5093. }
  5094. else
  5095. {
  5096. hideRowsList.Add(Row + startIndex + HideRows);
  5097. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5098. }
  5099. HideRows += 2;
  5100. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5101. if (leftBindData != null)
  5102. {
  5103. designer.SetDataSource("HSDRCB", leftBindData.cb);
  5104. designer.SetDataSource("HSRS", leftBindData.rs);
  5105. designer.SetDataSource("HSXS", leftBindData.xs);
  5106. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5107. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5108. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5109. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5110. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5111. }
  5112. else
  5113. {
  5114. hideRowsList.Add(Row + startIndex + HideRows);
  5115. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5116. }
  5117. HideRows += 2;
  5118. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5119. if (leftBindData != null)
  5120. {
  5121. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  5122. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  5123. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  5124. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5125. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5126. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5127. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5128. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5129. }
  5130. else
  5131. {
  5132. hideRowsList.Add(Row + startIndex + HideRows);
  5133. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5134. }
  5135. HideRows += 2;
  5136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5137. if (leftBindData != null)
  5138. {
  5139. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  5140. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  5141. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  5142. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5143. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5144. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5145. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5146. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5147. }
  5148. else
  5149. {
  5150. hideRowsList.Add(Row + startIndex + HideRows);
  5151. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5152. }
  5153. HideRows += 2;
  5154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5155. if (leftBindData != null)
  5156. {
  5157. ////TBR
  5158. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  5159. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  5160. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  5161. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5162. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5163. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5164. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5165. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5166. }
  5167. else
  5168. {
  5169. hideRowsList.Add(Row + startIndex + HideRows);
  5170. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5171. }
  5172. HideRows += 2;
  5173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5174. if (leftBindData != null)
  5175. {
  5176. ////SGR
  5177. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  5178. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  5179. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  5180. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5181. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5182. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5183. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5184. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5185. }
  5186. else
  5187. {
  5188. hideRowsList.Add(Row + startIndex + HideRows);
  5189. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5190. }
  5191. HideRows += 2;
  5192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5193. if (leftBindData != null)
  5194. {
  5195. ////JS/ES
  5196. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  5197. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  5198. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  5199. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5200. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5201. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5202. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5203. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5204. }
  5205. else
  5206. {
  5207. hideRowsList.Add(Row + startIndex + HideRows);
  5208. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5209. }
  5210. HideRows += 2;
  5211. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5212. if (leftBindData != null)
  5213. {
  5214. ////SUITE
  5215. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  5216. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  5217. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  5218. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5219. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5220. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5221. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5222. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5223. }
  5224. else
  5225. {
  5226. hideRowsList.Add(Row + startIndex + HideRows);
  5227. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5228. }
  5229. HideRows += 2;
  5230. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5231. if (leftBindData != null)
  5232. {
  5233. designer.SetDataSource("DJDRCB", leftBindData.cb);
  5234. designer.SetDataSource("DJRS", leftBindData.rs);
  5235. designer.SetDataSource("DJXS", leftBindData.xs);
  5236. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5237. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5238. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5239. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5240. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5241. }
  5242. else
  5243. {
  5244. hideRowsList.Add(Row + startIndex + HideRows);
  5245. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5246. }
  5247. HideRows += 2;
  5248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5249. if (leftBindData != null)
  5250. {
  5251. designer.SetDataSource("HCPCB", leftBindData.cb);
  5252. designer.SetDataSource("HCPRS", leftBindData.rs);
  5253. designer.SetDataSource("HCPXS", leftBindData.xs);
  5254. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5255. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5256. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5257. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5258. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5259. }
  5260. else
  5261. {
  5262. hideRowsList.Add(Row + startIndex + HideRows);
  5263. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5264. }
  5265. HideRows += 2;
  5266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5267. if (leftBindData != null)
  5268. {
  5269. designer.SetDataSource("CPCB", leftBindData.cb);
  5270. designer.SetDataSource("CPRS", leftBindData.rs);
  5271. designer.SetDataSource("CPXS", leftBindData.xs);
  5272. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5273. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5274. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5275. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5276. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5277. }
  5278. else
  5279. {
  5280. hideRowsList.Add(Row + startIndex + HideRows);
  5281. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5282. }
  5283. HideRows += 2;
  5284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5285. if (leftBindData != null)
  5286. {
  5287. designer.SetDataSource("GWDRCD", leftBindData.cb);
  5288. designer.SetDataSource("GWRS", leftBindData.rs);
  5289. designer.SetDataSource("GWXS", leftBindData.xs);
  5290. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5291. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5292. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5293. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5294. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5295. }
  5296. else
  5297. {
  5298. hideRowsList.Add(Row + startIndex + HideRows);
  5299. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5300. }
  5301. HideRows += 2;
  5302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5303. if (leftBindData != null)
  5304. {
  5305. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  5306. designer.SetDataSource("LYJRS", leftBindData.rs);
  5307. designer.SetDataSource("LYJXS", leftBindData.xs);
  5308. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5309. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5310. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5311. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5312. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5313. }
  5314. else
  5315. {
  5316. hideRowsList.Add(Row + startIndex + HideRows);
  5317. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  5318. }
  5319. #endregion
  5320. #region A段Right信息
  5321. var right = dto.rightInfo.Find(x => x.Type == "A");
  5322. if (right == null)
  5323. {
  5324. return Ok(jw);
  5325. }
  5326. HideRows += 4;
  5327. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5328. if (rightBindData!= null)
  5329. {
  5330. //经济舱 + 双人间 TBR
  5331. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  5332. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  5333. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5334. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  5335. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5336. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5337. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5338. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5339. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5340. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5341. }
  5342. else
  5343. {
  5344. hideRowsList.Add(Row + startIndex + HideRows);
  5345. }
  5346. HideRows += 2;
  5347. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5348. if (rightBindData != null)
  5349. {
  5350. //经济舱 + 单人间 SGR
  5351. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  5352. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  5353. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5354. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  5355. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5356. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5357. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5358. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5359. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5360. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5361. }
  5362. else
  5363. {
  5364. hideRowsList.Add(Row + startIndex + HideRows);
  5365. }
  5366. HideRows += 2;
  5367. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5368. if (rightBindData != null)
  5369. {
  5370. //公务舱 + 单人间 SGR
  5371. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  5372. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  5373. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5374. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  5375. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5376. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5377. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5378. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5379. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5380. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5381. }
  5382. else
  5383. {
  5384. hideRowsList.Add(Row + startIndex + HideRows);
  5385. }
  5386. HideRows += 2;
  5387. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5388. if (rightBindData != null)
  5389. {
  5390. //公务舱 + 小套房 JSES
  5391. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  5392. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  5393. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5394. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  5395. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5396. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5397. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5398. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5399. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5400. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5401. }
  5402. else
  5403. {
  5404. hideRowsList.Add(Row + startIndex + HideRows);
  5405. }
  5406. HideRows += 2;
  5407. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5408. if (rightBindData != null)
  5409. {
  5410. //公务舱 + 小套房 JSES
  5411. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  5412. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  5413. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5414. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  5415. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5416. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5417. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5418. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5419. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5420. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5421. }
  5422. else
  5423. {
  5424. hideRowsList.Add(Row + startIndex + HideRows);
  5425. }
  5426. HideRows += 2;
  5427. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5428. if (rightBindData != null)
  5429. {
  5430. //经济舱 + 大套房
  5431. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  5432. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  5433. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5434. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  5435. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5436. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5437. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5438. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5439. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5440. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5441. }
  5442. else
  5443. {
  5444. hideRowsList.Add(Row + startIndex + HideRows);
  5445. }
  5446. #endregion
  5447. #region B段标题清空
  5448. designer.SetDataSource("CostBDRCB", "");
  5449. designer.SetDataSource("CostBRS", "");
  5450. designer.SetDataSource("CostBXS", "");
  5451. designer.SetDataSource("CostBZCB", "");
  5452. designer.SetDataSource("CostBDRBJ", "");
  5453. designer.SetDataSource("CostBZBJ", "");
  5454. designer.SetDataSource("CostBDRLR", "");
  5455. designer.SetDataSource("CostBZLR", "");
  5456. designer.SetDataSource("CostBDRCBOM", "");
  5457. designer.SetDataSource("CostBRSOM", "");
  5458. designer.SetDataSource("CostBZCBOM", "");
  5459. designer.SetDataSource("CostBDRBJOM", "");
  5460. designer.SetDataSource("CostBZBJOM", "");
  5461. designer.SetDataSource("CostBDRLROM", "");
  5462. designer.SetDataSource("CostBZLROM", "");
  5463. #endregion
  5464. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  5465. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  5466. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  5467. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  5468. designer.SetDataSource("DJName", "地接(CNY)");
  5469. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  5470. designer.SetDataSource("CPName", "地接-船票(CNY)");
  5471. designer.SetDataSource("GWName", "公务(CNY)");
  5472. designer.SetDataSource("YQHName", "邀请函(CNY)");
  5473. designer.SetDataSource("LYJName", "零用金(CNY)");
  5474. designer.SetDataSource("HSName", "核酸检测(CNY)");
  5475. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  5476. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  5477. designer.SetDataSource("BXName", "保险(CNY)");
  5478. designer.SetDataSource("VisaName", "签证(CNY)");
  5479. #region B段基本数据
  5480. if (dto.costType == "B")
  5481. {
  5482. left = dto.leftInfo.Find(x => x.Type == "B");
  5483. if (left == null)
  5484. {
  5485. return Ok(jw);
  5486. }
  5487. #region B段left数据
  5488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  5489. if (leftBindData != null)
  5490. {
  5491. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  5492. designer.SetDataSource("BHSRS", leftBindData.rs);
  5493. designer.SetDataSource("BHSXS", leftBindData.xs);
  5494. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5495. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5496. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5497. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5498. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5499. }
  5500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  5501. if (leftBindData != null)
  5502. {
  5503. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  5504. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  5505. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  5506. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5507. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5508. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5509. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5510. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5511. }
  5512. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  5513. if (leftBindData != null)
  5514. {
  5515. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  5516. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  5517. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  5518. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5519. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5520. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5521. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5522. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5523. }
  5524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  5525. if (leftBindData != null)
  5526. {
  5527. designer.SetDataSource("BHCPCB", leftBindData.cb);
  5528. designer.SetDataSource("BHCPRS", leftBindData.rs);
  5529. designer.SetDataSource("BHCPXS", leftBindData.xs);
  5530. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5531. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5532. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5533. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5534. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5535. }
  5536. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  5537. if (leftBindData != null)
  5538. {
  5539. designer.SetDataSource("BCPCB", leftBindData.cb);
  5540. designer.SetDataSource("BCPRS", leftBindData.rs);
  5541. designer.SetDataSource("BCPXS", leftBindData.xs);
  5542. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5543. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5544. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5545. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5546. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5547. }
  5548. //TBR
  5549. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  5550. if (leftBindData != null)
  5551. {
  5552. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  5553. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  5554. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  5555. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5556. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5557. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5558. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5559. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5560. }
  5561. //SGR
  5562. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  5563. if (leftBindData != null)
  5564. {
  5565. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  5566. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  5567. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  5568. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5569. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5570. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5571. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5572. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5573. }
  5574. //JS/ES
  5575. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  5576. if (leftBindData != null)
  5577. {
  5578. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  5579. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  5580. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  5581. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5582. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5583. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5584. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5585. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5586. }
  5587. //SUITE
  5588. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  5589. if (leftBindData != null)
  5590. {
  5591. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  5592. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  5593. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  5594. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5595. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5596. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5597. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5598. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5599. }
  5600. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  5601. if (leftBindData != null)
  5602. {
  5603. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  5604. designer.SetDataSource("BDJRS", leftBindData.rs);
  5605. designer.SetDataSource("BDJXS", leftBindData.xs);
  5606. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5607. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5608. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5609. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5610. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5611. }
  5612. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  5613. if (leftBindData != null)
  5614. {
  5615. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  5616. designer.SetDataSource("BGWRS", leftBindData.rs);
  5617. designer.SetDataSource("BGWXS", leftBindData.xs);
  5618. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5619. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5620. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5621. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5622. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5623. }
  5624. #region 优化方案
  5625. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  5626. //excelBind.Add("零用金", new {
  5627. //cb="",
  5628. //rs="",
  5629. //xs ="",
  5630. //zcb = "",
  5631. //});
  5632. #endregion
  5633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  5634. if (leftBindData != null)
  5635. {
  5636. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  5637. designer.SetDataSource("BLYJRS", leftBindData.rs);
  5638. designer.SetDataSource("BLYJXS", leftBindData.xs);
  5639. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  5640. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  5641. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  5642. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  5643. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  5644. }
  5645. #endregion
  5646. #region B段Right信息
  5647. right = dto.rightInfo.Find(x => x.Type == "B");
  5648. if (right == null)
  5649. {
  5650. return Ok(jw);
  5651. }
  5652. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  5653. if (rightBindData!= null)
  5654. {
  5655. //经济舱 + 双人间 TBR
  5656. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  5657. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  5658. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5659. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  5660. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5661. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5662. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5663. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5664. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5665. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5666. }
  5667. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  5668. if (rightBindData != null)
  5669. {
  5670. //经济舱 + 单人间 SGR
  5671. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  5672. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  5673. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5674. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  5675. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5676. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5677. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5678. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5679. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5680. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5681. }
  5682. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  5683. if (rightBindData != null)
  5684. {
  5685. //公务舱 + 单人间 SGR
  5686. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  5687. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  5688. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5689. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  5690. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5691. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5692. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5693. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5694. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5695. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5696. }
  5697. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  5698. if (rightBindData != null)
  5699. {
  5700. //公务舱 + 小套房 JSES
  5701. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  5702. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  5703. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5704. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  5705. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5706. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5707. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5708. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5709. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5710. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5711. }
  5712. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  5713. if (rightBindData != null)
  5714. {
  5715. //公务舱 + 小套房 JSES
  5716. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  5717. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  5718. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5719. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  5720. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5721. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5722. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5723. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5724. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5725. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5726. }
  5727. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  5728. if (rightBindData != null)
  5729. {
  5730. //经济舱 + 大套房
  5731. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  5732. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  5733. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  5734. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  5735. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  5736. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  5737. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  5738. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  5739. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  5740. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  5741. }
  5742. #endregion
  5743. #region 标题
  5744. designer.SetDataSource("CostBDRCB", "单人成本");
  5745. designer.SetDataSource("CostBRS", "人数");
  5746. designer.SetDataSource("CostBXS", "系数");
  5747. designer.SetDataSource("CostBZCB", "总成本");
  5748. designer.SetDataSource("CostBDRBJ", "单人报价");
  5749. designer.SetDataSource("CostBZBJ", "总报价");
  5750. designer.SetDataSource("CostBDRLR", "单人利润");
  5751. designer.SetDataSource("CostBZLR", "总利润");
  5752. designer.SetDataSource("CostBDRCBOM", "单人成本");
  5753. designer.SetDataSource("CostBRSOM", "人数");
  5754. designer.SetDataSource("CostBZCBOM", "总成本");
  5755. designer.SetDataSource("CostBDRBJOM", "单人报价");
  5756. designer.SetDataSource("CostBZBJOM", "总报价");
  5757. designer.SetDataSource("CostBDRLROM", "单人利润");
  5758. designer.SetDataSource("CostBZLROM", "总利润");
  5759. #endregion
  5760. }
  5761. #endregion
  5762. designer.SetDataSource("TzZCB2", TzZCB2);
  5763. designer.SetDataSource("TzZBJ2", TzZBJ2);
  5764. designer.SetDataSource("TzZLR2", TzZLR2);
  5765. string[] dataSourceKeys = new string[]
  5766. {
  5767. "VF",
  5768. "TGS",
  5769. "TGOF",
  5770. "TGM",
  5771. "TGA",
  5772. "TGTF",
  5773. "TGEF",
  5774. "CFM",
  5775. "CFOF",
  5776. "B",
  5777. "L",
  5778. "D",
  5779. "TBR",
  5780. "SGR",
  5781. "JSES",
  5782. "Suite",
  5783. "TV",
  5784. "1L",
  5785. "IF",
  5786. "EF",
  5787. "BRF",
  5788. "TE",
  5789. "TGT",
  5790. "DRVT",
  5791. "PC",
  5792. "TLF",
  5793. "ECT"
  5794. };
  5795. foreach (var item in dataSourceKeys)
  5796. {
  5797. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  5798. if (find != null)
  5799. {
  5800. designer.SetDataSource(item, find.text);
  5801. }
  5802. else
  5803. {
  5804. designer.SetDataSource(item, 0);
  5805. }
  5806. }
  5807. designer.SetDataSource(dt);
  5808. //根据数据源处理生成报表内容
  5809. designer.Process();
  5810. designer.Workbook.Worksheets[0].Name = "清单";
  5811. Worksheet sheet = designer.Workbook.Worksheets[0];
  5812. foreach (var Rowindex in hideRowsList)
  5813. {
  5814. ws.Cells.HideRows(Rowindex, 2);
  5815. }
  5816. byte[] bytes = null;
  5817. string strFileName = di.TeamName + "-团组-成本.xls";
  5818. using (MemoryStream stream = new MemoryStream())
  5819. {
  5820. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5821. bytes = stream.ToArray();
  5822. }
  5823. return Ok(JsonView(true, "", new
  5824. {
  5825. Data = bytes,
  5826. strFileName,
  5827. }));
  5828. }
  5829. /// <summary>
  5830. /// 导出客户报表
  5831. /// </summary>
  5832. /// <returns></returns>
  5833. [HttpPost]
  5834. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  5835. {
  5836. var jw = JsonView(false);
  5837. if (dto.Diid == 0)
  5838. {
  5839. return Ok(JsonView(false, "请传递团组id"));
  5840. }
  5841. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  5842. if (deleInfo.Code != 0)
  5843. {
  5844. return Ok(JsonView(false, "团组信息查询失败!"));
  5845. }
  5846. var di = deleInfo.Data as DelegationInfoWebView;
  5847. if (di == null)
  5848. {
  5849. return Ok(JsonView(false, "团组信息查询失败!"));
  5850. }
  5851. //文件名
  5852. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  5853. //获取模板
  5854. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  5855. //载入模板
  5856. Document doc = new Document(tmppath);
  5857. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  5858. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  5859. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  5860. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  5861. var AParameter = ParameterList.Find(x => x.CostType == "A");
  5862. var BParameter = ParameterList.Find(x => x.CostType == "B");
  5863. if (AParameter == null)
  5864. {
  5865. return Ok(JsonView(false, "系数不存在!"));
  5866. }
  5867. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  5868. , TzAirDesc, TzZCost;
  5869. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  5870. = TzAirDesc = TzZCost = string.Empty;
  5871. TzNumber = AParameter.CostTypenumber.ToString();
  5872. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  5873. CarGuides1 = dto.CarGuides1;
  5874. Meal = dto.Meal;
  5875. SubsidizedMeals = dto.SubsidizedMeals;
  5876. NightRepair = dto.NightRepair;
  5877. AttractionsTickets = dto.AttractionsTickets;
  5878. MiscellaneousFees = dto.MiscellaneousFees;
  5879. ATip = dto.ATip;
  5880. TzHotelDesc = "";
  5881. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  5882. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  5883. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  5884. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  5885. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  5886. TzAirDesc = "";
  5887. TzZCost = dto.TzZCost;
  5888. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  5889. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  5890. var index = 1;
  5891. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  5892. foreach (var item in TzHotelDescArr)
  5893. {
  5894. if (AinfoArr != null)
  5895. {
  5896. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5897. if (Ainfo != null)
  5898. {
  5899. if (int.Parse(Ainfo.rs) <= 0)
  5900. {
  5901. continue;
  5902. }
  5903. var hotelText = string.Empty;
  5904. switch (item)
  5905. {
  5906. case "SGR":
  5907. hotelText = "单人间";
  5908. break;
  5909. case "JSES":
  5910. hotelText = "小套房";
  5911. break;
  5912. case "SUITE":
  5913. hotelText = "套房";
  5914. break;
  5915. case "TBR":
  5916. hotelText = "双人间";
  5917. break;
  5918. }
  5919. if (item != "TBR")
  5920. {
  5921. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  5922. }
  5923. else
  5924. {
  5925. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  5926. }
  5927. index++;
  5928. }
  5929. }
  5930. }
  5931. index = 1;
  5932. foreach (var item in TzAirDescArr)
  5933. {
  5934. if (AinfoArr != null)
  5935. {
  5936. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5937. if (Ainfo != null)
  5938. {
  5939. if (int.Parse(Ainfo.rs) <= 0)
  5940. {
  5941. continue;
  5942. }
  5943. TzAirDesc += "(" + index + ".) "+item+" " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  5944. index++;
  5945. }
  5946. }
  5947. }
  5948. if (dto.costType == "B")
  5949. {
  5950. if (BParameter == null)
  5951. {
  5952. return Ok(JsonView(false, "B段系数不存在!"));
  5953. }
  5954. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  5955. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  5956. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  5957. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  5958. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  5959. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  5960. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  5961. foreach (var item in TzHotelDescArr)
  5962. {
  5963. if (AinfoArr != null)
  5964. {
  5965. TzHotelDesc += "B段信息 \r\n";
  5966. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  5967. if (Ainfo != null)
  5968. {
  5969. if (int.Parse(Ainfo.rs) <= 0)
  5970. {
  5971. continue;
  5972. }
  5973. var hotelText = string.Empty;
  5974. switch (item)
  5975. {
  5976. case "SGR":
  5977. hotelText = "单人间";
  5978. break;
  5979. case "JSES":
  5980. hotelText = "小套房";
  5981. break;
  5982. case "SUITE":
  5983. hotelText = "套房";
  5984. break;
  5985. case "TBR":
  5986. hotelText = "双人间";
  5987. break;
  5988. }
  5989. if (item != "TBR")
  5990. {
  5991. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  5992. }
  5993. else
  5994. {
  5995. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  5996. }
  5997. index++;
  5998. }
  5999. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  6000. }
  6001. }
  6002. index = 1;
  6003. foreach (var item in TzAirDescArr)
  6004. {
  6005. if (AinfoArr != null)
  6006. {
  6007. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  6008. if (Ainfo != null)
  6009. {
  6010. if (int.Parse(Ainfo.rs) <= 0)
  6011. {
  6012. continue;
  6013. }
  6014. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  6015. index++;
  6016. }
  6017. }
  6018. }
  6019. }
  6020. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  6021. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  6022. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  6023. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  6024. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  6025. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  6026. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  6027. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  6028. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  6029. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  6030. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  6031. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  6032. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  6033. DickeyValue.Add("Visa", Visa); // 签证单人报价
  6034. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  6035. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  6036. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  6037. DickeyValue.Add("TzZCost", TzZCost);
  6038. foreach (var key in DickeyValue.Keys)
  6039. {
  6040. if (doc.Range.Bookmarks[key] != null)
  6041. {
  6042. Bookmark mark = doc.Range.Bookmarks[key];
  6043. mark.Text = DickeyValue[key];
  6044. }
  6045. }
  6046. byte[] bytes = null;
  6047. string strFileName = di.TeamName + "-客户报价.doc";
  6048. using (MemoryStream stream = new MemoryStream())
  6049. {
  6050. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6051. bytes = stream.ToArray();
  6052. }
  6053. return Ok(JsonView(true, "", new
  6054. {
  6055. Data = bytes,
  6056. strFileName,
  6057. }));
  6058. }
  6059. /// <summary>
  6060. /// 团组成本 各模块(酒店,地接,机票)成本提示
  6061. /// </summary>
  6062. /// <param name="dto"></param>
  6063. /// <returns></returns>
  6064. [HttpPost]
  6065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6066. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  6067. {
  6068. try
  6069. {
  6070. #region 参数验证
  6071. if (dto.DiId < 0)
  6072. {
  6073. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6074. }
  6075. List<int> cTableIds = new List<int>() {
  6076. 76 ,//酒店预订
  6077. 77 ,//行程
  6078. 79 ,//车/导游地接
  6079. 80 ,//签证
  6080. 81 ,//邀请/公务活
  6081. 82 ,//团组客户保险
  6082. 85 ,//机票预订
  6083. 98 ,//其他款项
  6084. 285 ,//收款退还
  6085. 751 ,//酒店早餐
  6086. 1015 // 超支费用
  6087. };
  6088. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  6089. {
  6090. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  6091. }
  6092. #endregion
  6093. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  6094. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6095. if (_GroupCostParameters.Count <= 0)
  6096. {
  6097. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  6098. }
  6099. if (_GroupCostParameters[0].IsShare == 0)
  6100. {
  6101. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  6102. }
  6103. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  6104. //处理date为空问题
  6105. if (_GroupCosts.Count > 0)
  6106. {
  6107. for (int i = 0; i < _GroupCosts.Count; i++)
  6108. {
  6109. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  6110. {
  6111. if (i > 0)
  6112. {
  6113. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  6114. }
  6115. }
  6116. }
  6117. }
  6118. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  6119. ;
  6120. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  6121. //op,酒店单段模式存储
  6122. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  6123. {
  6124. CurrencyCode = _GroupCostParameters[0].Currency,
  6125. Rate = _GroupCostParameters[0].Rate,
  6126. CostType = _GroupCostParameters[0].CostType,
  6127. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  6128. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  6129. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  6130. };
  6131. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  6132. if (_GroupCostParameters.Count == 2)
  6133. {
  6134. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  6135. }
  6136. foreach (var item in _GroupCostParameters)
  6137. {
  6138. decimal _rate = item.Rate;
  6139. decimal _scale = 0.95M;
  6140. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  6141. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  6142. if (userInfo != null)
  6143. {
  6144. if (userInfo.DepId == 1 || userInfo.DepId == 7)
  6145. {
  6146. if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  6147. {
  6148. _scale = 1.00M;
  6149. }
  6150. }
  6151. }
  6152. #endregion
  6153. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  6154. {
  6155. CurrencyCode = item.Currency,
  6156. Rate = _rate,
  6157. CostType = item.CostType,
  6158. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  6159. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  6160. CostTypeNumber = item.CostTypenumber
  6161. };
  6162. if (_GroupCostParameters.Count > 1)
  6163. {
  6164. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  6165. }
  6166. else
  6167. {
  6168. modulePromptInfo.CostTypeNumber = item.LYJRS;
  6169. }
  6170. if (dto.CTable == 79)//
  6171. {
  6172. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  6173. modulePromptInfo.TotalCost = item.DJCB;
  6174. }
  6175. List<string> costTypes = new List<string>() { "A","B" };
  6176. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  6177. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  6178. if (_GroupCostsDuplicates.Count() == 1)
  6179. {
  6180. _GroupCostsTypeData = _GroupCosts;
  6181. }
  6182. else
  6183. {
  6184. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  6185. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  6186. }
  6187. /*
  6188. * 76 酒店预订
  6189. * 77 行程
  6190. * 79 车/导游地接
  6191. * 80 签证
  6192. * 81 邀请/公务活动
  6193. * 82 团组客户保险
  6194. * 85 机票预订
  6195. * 98 其他款项
  6196. * 285 收款退还
  6197. * 751 酒店早餐
  6198. * 1015 超支费用
  6199. */
  6200. switch (dto.CTable)
  6201. {
  6202. case 76: // 酒店预订
  6203. _ModuleSubPromptInfo.AddRange(
  6204. _GroupCostsTypeData.Select(it => new
  6205. {
  6206. it.DAY,
  6207. it.Date,
  6208. it.ACCON,
  6209. it.ITIN,
  6210. it.SGR,
  6211. it.TBR,
  6212. it.JS_ES,
  6213. it.Suite
  6214. })
  6215. );
  6216. break;
  6217. case 79: // 车/导游地接
  6218. _ModuleSubPromptInfo.AddRange(
  6219. _GroupCostsTypeData.Select(it => new
  6220. {
  6221. Date = it.Date, //日期
  6222. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  6223. GuideFee = (it.TGS + it.TGOF + it.TGM+ it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  6224. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  6225. TicketFee = it.EF * _rate * _scale, //门票费
  6226. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  6227. AirportTransferFee = 0.00M,
  6228. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  6229. TravelSupplies = it.TE * _rate * _scale, //出行物资
  6230. LeadersFee = it.TLF * _rate * _scale, //领队费
  6231. CarFee1 = it.CarCost * _rate * _scale,
  6232. CarType = it.CarType, //车型
  6233. SpentCash = it.PC * _rate * _scale, //零用金
  6234. })
  6235. );
  6236. break;
  6237. case 85: // 机票
  6238. List<dynamic> datas = new List<dynamic>();
  6239. datas.Add(
  6240. new
  6241. {
  6242. AirType = "经济舱",
  6243. AirNum = item.JJCRS,
  6244. AirDRCB = item.JJCCB,
  6245. AirZCB = (item.JJCRS * item.JJCCB)
  6246. }
  6247. );
  6248. datas.Add(
  6249. new
  6250. {
  6251. AirType = "公务舱",
  6252. AirNum = item.GWCRS,
  6253. AirDRCB = item.GWCCB,
  6254. AirZCB = (item.GWCRS * item.GWCCB)
  6255. }
  6256. );
  6257. modulePromptInfo.Data = datas;
  6258. _ModulePromptInfos.Add(modulePromptInfo);
  6259. break;
  6260. default:
  6261. break;
  6262. }
  6263. }
  6264. if (dto.CTable != 85)
  6265. {
  6266. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  6267. _ModulePromptInfos.Add(_ModulePromptInfo);
  6268. }
  6269. _view.ModulePromptInfos = _ModulePromptInfos;
  6270. return Ok(JsonView(true,"操作成功!", _view));
  6271. }
  6272. catch (Exception ex)
  6273. {
  6274. return Ok(JsonView(false, ex.Message));
  6275. }
  6276. }
  6277. #endregion
  6278. #region 酒店预定 保留
  6279. /// <summary>
  6280. /// 酒店预订页面初始化绑定
  6281. /// </summary>
  6282. /// <param name="dto"></param>
  6283. /// <returns></returns>
  6284. [HttpPost]
  6285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6286. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  6287. {
  6288. try
  6289. {
  6290. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  6291. if (groupData.Code != 0)
  6292. {
  6293. return Ok(JsonView(false, groupData.Msg));
  6294. }
  6295. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6296. }
  6297. catch (Exception ex)
  6298. {
  6299. return Ok(JsonView(false, ex.Message));
  6300. }
  6301. }
  6302. /// <summary>
  6303. /// 根据团组Id查询酒店费用列表
  6304. /// </summary>
  6305. /// <param name="dto"></param>
  6306. /// <returns></returns>
  6307. [HttpPost]
  6308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6309. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  6310. {
  6311. try
  6312. {
  6313. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  6314. if (groupData.Code != 0)
  6315. {
  6316. return Ok(JsonView(false, groupData.Msg));
  6317. }
  6318. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6319. }
  6320. catch (Exception ex)
  6321. {
  6322. return Ok(JsonView(false, ex.Message));
  6323. }
  6324. }
  6325. /// <summary>
  6326. /// 根据酒店费用Id查询酒店费用详细
  6327. /// </summary>
  6328. /// <param name="dto"></param>
  6329. /// <returns></returns>
  6330. [HttpPost]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  6333. {
  6334. try
  6335. {
  6336. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  6337. if (groupData.Code != 0)
  6338. {
  6339. return Ok(JsonView(false, groupData.Msg));
  6340. }
  6341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6342. }
  6343. catch (Exception ex)
  6344. {
  6345. return Ok(JsonView(false, ex.Message));
  6346. }
  6347. }
  6348. /// <summary>
  6349. /// 计算酒店付款总金额
  6350. /// </summary>
  6351. /// <param name="dto"></param>
  6352. /// <returns></returns>
  6353. [HttpPost]
  6354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6355. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  6356. {
  6357. try
  6358. {
  6359. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  6360. if (groupData.Code != 0)
  6361. {
  6362. return Ok(JsonView(false, groupData.Msg));
  6363. }
  6364. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6365. }
  6366. catch (Exception ex)
  6367. {
  6368. return Ok(JsonView(false, ex.Message));
  6369. }
  6370. }
  6371. /// <summary>
  6372. /// 酒店费用操作(Status:1.新增,2.修改)
  6373. /// </summary>
  6374. /// <param name="dto"></param>
  6375. /// <returns></returns>
  6376. [HttpPost]
  6377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6378. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  6379. {
  6380. try
  6381. {
  6382. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  6383. if (groupData.Code != 0)
  6384. {
  6385. return Ok(JsonView(false, groupData.Msg));
  6386. }
  6387. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6388. }
  6389. catch (Exception ex)
  6390. {
  6391. return Ok(JsonView(false, ex.Message));
  6392. }
  6393. }
  6394. /// <summary>
  6395. /// 文件上传
  6396. /// </summary>
  6397. /// <param name="file"></param>
  6398. /// <returns></returns>
  6399. [HttpPost]
  6400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6401. public async Task<IActionResult> UploadHotel(IFormFile file)
  6402. {
  6403. try
  6404. {
  6405. if (file != null)
  6406. {
  6407. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6408. //文件名称
  6409. string projectFileName = file.FileName;
  6410. //上传的文件的路径
  6411. string filePath = "";
  6412. if (!Directory.Exists(fileDir))
  6413. {
  6414. Directory.CreateDirectory(fileDir);
  6415. }
  6416. //上传的文件的路径
  6417. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  6418. using (FileStream fs = System.IO.File.Create(filePath))
  6419. {
  6420. file.CopyTo(fs);
  6421. fs.Flush();
  6422. }
  6423. return Ok(JsonView(true, "上传成功!", projectFileName));
  6424. }
  6425. else
  6426. {
  6427. return Ok(JsonView(false, "上传失败!"));
  6428. }
  6429. }
  6430. catch (Exception ex)
  6431. {
  6432. return Ok(JsonView(false, "程序错误!"));
  6433. throw;
  6434. }
  6435. }
  6436. /// <summary>
  6437. /// 删除指定文件
  6438. /// </summary>
  6439. /// <param name="dto"></param>
  6440. /// <returns></returns>
  6441. [HttpPost]
  6442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6443. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  6444. {
  6445. try
  6446. {
  6447. string filePath = "";
  6448. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6449. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6450. //int id = 0;
  6451. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  6452. // 删除该文件
  6453. try
  6454. {
  6455. System.IO.File.Delete(filePath);
  6456. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6457. {
  6458. Attachment = "",
  6459. }).ExecuteCommandAsync();
  6460. if (result != 0)
  6461. {
  6462. return Ok(JsonView(true, "成功!"));
  6463. }
  6464. else
  6465. {
  6466. return Ok(JsonView(false, "失败!"));
  6467. }
  6468. }
  6469. catch (Exception)
  6470. {
  6471. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  6472. {
  6473. Attachment = "",
  6474. }).ExecuteCommandAsync();
  6475. if (result != 0)
  6476. {
  6477. return Ok(JsonView(true, "成功!"));
  6478. }
  6479. else
  6480. {
  6481. return Ok(JsonView(false, "失败!"));
  6482. }
  6483. throw;
  6484. }
  6485. }
  6486. catch (Exception ex)
  6487. {
  6488. return Ok(JsonView(false, "程序错误!"));
  6489. throw;
  6490. }
  6491. }
  6492. /// <summary>
  6493. /// 生成VOUCHER
  6494. /// </summary>
  6495. /// <param name=""></param>
  6496. /// <returns></returns>
  6497. [HttpPost]
  6498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6499. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  6500. {
  6501. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  6502. //判断数据是否完整
  6503. if (h != null)
  6504. {
  6505. if (!string.IsNullOrEmpty(h.DetermineNo))
  6506. {
  6507. string strFileName = "HotelStatement/";
  6508. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  6509. if (dele != null)
  6510. strFileName += dele.TourCode;
  6511. //载入模板
  6512. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  6513. Document doc = new Document(sss);
  6514. DocumentBuilder builder = new DocumentBuilder(doc);
  6515. try
  6516. {
  6517. #region 替换Word模板书签内容
  6518. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  6519. //入住卷预定号码
  6520. if (doc.Range.Bookmarks["VNO"] != null)
  6521. {
  6522. Bookmark mark = doc.Range.Bookmarks["VNO"];
  6523. mark.Text = h.CheckNumber;
  6524. }
  6525. //酒店时间
  6526. if (doc.Range.Bookmarks["Date"] != null)
  6527. {
  6528. Bookmark mark = doc.Range.Bookmarks["Date"];
  6529. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6530. }
  6531. //团号
  6532. if (doc.Range.Bookmarks["TNo"] != null)
  6533. {
  6534. Bookmark mark = doc.Range.Bookmarks["TNo"];
  6535. mark.Text = dele.TourCode;
  6536. }
  6537. //预定号码
  6538. if (doc.Range.Bookmarks["BookingId"] != null)
  6539. {
  6540. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  6541. mark.Text = h.ReservationsNo;
  6542. }
  6543. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  6544. {
  6545. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  6546. mark.Text = h.DetermineNo;
  6547. }
  6548. //酒店城市
  6549. if (doc.Range.Bookmarks["City"] != null)
  6550. {
  6551. Bookmark mark = doc.Range.Bookmarks["City"];
  6552. mark.Text = h.City;
  6553. }
  6554. //酒店名称
  6555. if (doc.Range.Bookmarks["HName"] != null)
  6556. {
  6557. Bookmark mark = doc.Range.Bookmarks["HName"];
  6558. mark.Text = h.HotelName;
  6559. }
  6560. //酒店地址
  6561. if (doc.Range.Bookmarks["Address"] != null)
  6562. {
  6563. Bookmark mark = doc.Range.Bookmarks["Address"];
  6564. mark.Text = h.HotelAddress;
  6565. }
  6566. //酒店电话
  6567. if (doc.Range.Bookmarks["Tel"] != null)
  6568. {
  6569. Bookmark mark = doc.Range.Bookmarks["Tel"];
  6570. mark.Text = h.HotelTel;
  6571. }
  6572. //酒店传真
  6573. if (doc.Range.Bookmarks["Fax"] != null)
  6574. {
  6575. Bookmark mark = doc.Range.Bookmarks["Fax"];
  6576. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  6577. {
  6578. mark.Text = h.HotelFax;
  6579. }
  6580. }
  6581. //入住时间
  6582. if (doc.Range.Bookmarks["CIn"] != null)
  6583. {
  6584. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6585. Bookmark mark = doc.Range.Bookmarks["CIn"];
  6586. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  6587. }
  6588. //退房时间
  6589. if (doc.Range.Bookmarks["COut"] != null)
  6590. {
  6591. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6592. Bookmark mark = doc.Range.Bookmarks["COut"];
  6593. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6594. }
  6595. //客户名称
  6596. if (doc.Range.Bookmarks["GName"] != null)
  6597. {
  6598. Bookmark mark = doc.Range.Bookmarks["GName"];
  6599. mark.Text = h.GuestName;
  6600. }
  6601. //房间介绍
  6602. if (doc.Range.Bookmarks["ROOM"] != null)
  6603. {
  6604. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  6605. mark.Text = h.RoomExplanation;
  6606. }
  6607. //报价描述
  6608. if (doc.Range.Bookmarks["NOTE"] != null)
  6609. {
  6610. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  6611. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  6612. if (ss != null)
  6613. mark.Text = ss.Name;
  6614. }
  6615. //入住时间
  6616. if (doc.Range.Bookmarks["CheckIn"] != null)
  6617. {
  6618. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  6619. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  6620. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  6621. }
  6622. //退房时间
  6623. if (doc.Range.Bookmarks["CheckOut"] != null)
  6624. {
  6625. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  6626. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  6627. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  6628. }
  6629. //日期
  6630. if (doc.Range.Bookmarks["DT"] != null)
  6631. {
  6632. Bookmark mark = doc.Range.Bookmarks["DT"];
  6633. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  6634. }
  6635. //名称
  6636. if (doc.Range.Bookmarks["VName"] != null)
  6637. {
  6638. Bookmark mark = doc.Range.Bookmarks["VName"];
  6639. mark.Text = h.HotelName;
  6640. }
  6641. //号码
  6642. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  6643. {
  6644. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  6645. mark.Text = h.CheckNumber;
  6646. }
  6647. #endregion
  6648. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  6649. strFileName += "VOUCHER.doc";
  6650. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  6651. doc.Save(fileDir);
  6652. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  6653. return Ok(JsonView(true, "成功!", Url));
  6654. }
  6655. catch (Exception ex)
  6656. {
  6657. throw;
  6658. }
  6659. }
  6660. else
  6661. {
  6662. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6663. }
  6664. }
  6665. else
  6666. {
  6667. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  6668. }
  6669. }
  6670. /// <summary>
  6671. /// 导出确认单
  6672. /// </summary>
  6673. /// <param name=""></param>
  6674. /// <returns></returns>
  6675. [HttpPost]
  6676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6677. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  6678. {
  6679. //团组信息
  6680. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  6681. //酒店数据
  6682. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  6683. //利datatable存储
  6684. DataTable dt = new DataTable();
  6685. dt.Columns.Add("CheckInDate", typeof(string));
  6686. dt.Columns.Add("City", typeof(string));
  6687. dt.Columns.Add("Hotel", typeof(string));
  6688. dt.Columns.Add("Room", typeof(string));
  6689. for (int i = 0; i < listhoteldata.Count; i++)
  6690. {
  6691. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  6692. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  6693. while (dayStart < dayEnd)
  6694. {
  6695. string temp = "";
  6696. DataRow row = dt.NewRow();
  6697. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  6698. row["City"] = listhoteldata[i].City;
  6699. row["Hotel"] = listhoteldata[i].HotelName;
  6700. if (listhoteldata[i].SingleRoomCount > 0)
  6701. {
  6702. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  6703. }
  6704. if (listhoteldata[i].DoubleRoomCount > 0)
  6705. {
  6706. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  6707. }
  6708. if (listhoteldata[i].SuiteRoomCount > 0)
  6709. {
  6710. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  6711. }
  6712. if (listhoteldata[i].OtherRoomCount > 0)
  6713. {
  6714. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  6715. }
  6716. row["Room"] = temp;
  6717. dt.Rows.Add(row);
  6718. dayStart = dayStart.AddDays(1);
  6719. }
  6720. }
  6721. Dictionary<string, string> dic = new Dictionary<string, string>();
  6722. dic.Add("Dele", di.TeamName);
  6723. dic.Add("City", di.VisitCountry);
  6724. //模板路径
  6725. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  6726. //载入模板
  6727. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  6728. DocumentBuilder builder = new DocumentBuilder(doc);
  6729. foreach (var key in dic.Keys)
  6730. {
  6731. builder.MoveToBookmark(key);
  6732. builder.Write(dic[key]);
  6733. }
  6734. //获取word里所有表格
  6735. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6736. //获取所填表格的序数
  6737. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6738. var rowStart = tableOne.Rows[0]; //获取第1行
  6739. try
  6740. {
  6741. //循环赋值
  6742. for (int i = 0; i < dt.Rows.Count; i++)
  6743. {
  6744. builder.MoveToCell(0, i + 1, 0, 0);
  6745. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  6746. builder.MoveToCell(0, i + 1, 1, 0);
  6747. builder.Write(dt.Rows[i]["City"].ToString());
  6748. builder.MoveToCell(0, i + 1, 2, 0);
  6749. builder.Write(dt.Rows[i]["Hotel"].ToString());
  6750. builder.MoveToCell(0, i + 1, 3, 0);
  6751. builder.Write(dt.Rows[i]["Room"].ToString());
  6752. }
  6753. }
  6754. catch
  6755. {
  6756. }
  6757. //删除多余行
  6758. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  6759. {
  6760. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  6761. }
  6762. string strFileName = di.TeamName + "酒店确认单.doc";
  6763. try
  6764. {
  6765. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  6766. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  6767. return Ok(JsonView(true, "成功", Url));
  6768. }
  6769. catch (Exception)
  6770. {
  6771. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  6772. throw;
  6773. }
  6774. }
  6775. /// <summary>
  6776. /// 酒店费用删除
  6777. /// </summary>
  6778. /// <param name="dto"></param>
  6779. /// <returns></returns>
  6780. [HttpPost]
  6781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6782. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  6783. {
  6784. try
  6785. {
  6786. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6787. if (!res)
  6788. {
  6789. return Ok(JsonView(false, "删除失败"));
  6790. }
  6791. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  6792. {
  6793. IsDel = 1,
  6794. DeleteUserId = dto.DeleteUserId,
  6795. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6796. }).ExecuteCommandAsync();
  6797. return Ok(JsonView(true, "删除成功!"));
  6798. }
  6799. catch (Exception ex)
  6800. {
  6801. return Ok(JsonView(false, "程序错误!"));
  6802. throw;
  6803. }
  6804. }
  6805. #endregion
  6806. #region 酒店预订 新 雷怡 2023-12-28 17:45
  6807. /// <summary>
  6808. /// 酒店预订
  6809. /// 酒店费用列表 根据团组Id查询
  6810. /// </summary>
  6811. /// <param name="_dto"></param>
  6812. /// <returns></returns>
  6813. [HttpPost]
  6814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6815. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  6816. {
  6817. try
  6818. {
  6819. #region 参数验证
  6820. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6821. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6822. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6823. #region 团组操作权限验证 76 酒店预定模块
  6824. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6825. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6826. #endregion
  6827. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6828. #region 页面操作权限验证
  6829. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6830. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6831. #endregion
  6832. #endregion
  6833. Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
  6834. if (_view.Code != 0)
  6835. {
  6836. return Ok(JsonView(false, _view.Msg));
  6837. }
  6838. return Ok(JsonView(true, _view.Msg, _view.Data));
  6839. }
  6840. catch (Exception ex)
  6841. {
  6842. return Ok(JsonView(false, ex.Message));
  6843. }
  6844. }
  6845. /// <summary>
  6846. /// 酒店预订
  6847. /// 基础数据
  6848. /// </summary>
  6849. /// <param name="_dto"></param>
  6850. /// <returns></returns>
  6851. [HttpPost]
  6852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6853. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  6854. {
  6855. try
  6856. {
  6857. #region 参数验证
  6858. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6859. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6860. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6861. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6862. #region 页面操作权限验证
  6863. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6864. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6865. #endregion
  6866. #region 团组操作权限验证 76 酒店预定模块
  6867. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6868. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6869. #endregion
  6870. #endregion
  6871. Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
  6872. if (data.Code != 0)
  6873. {
  6874. return Ok(JsonView(false, data.Msg));
  6875. }
  6876. return Ok(JsonView(true, data.Msg, data.Data));
  6877. }
  6878. catch (Exception ex)
  6879. {
  6880. return Ok(JsonView(false, "Catch:"+ex.Message));
  6881. }
  6882. }
  6883. /// <summary>
  6884. /// 酒店预订
  6885. /// 创建 入住卷号码
  6886. /// </summary>
  6887. /// <param name="_dto"></param>
  6888. /// <returns></returns>
  6889. [HttpPost]
  6890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6891. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  6892. {
  6893. try
  6894. {
  6895. #region 参数验证
  6896. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6897. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6898. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6899. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6900. #region 页面操作权限验证
  6901. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6902. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6903. #endregion
  6904. #region 团组操作权限验证 76 酒店预定模块
  6905. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6906. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6907. #endregion
  6908. #endregion
  6909. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  6910. if (data.Code != 0)
  6911. {
  6912. return Ok(JsonView(false, data.Msg));
  6913. }
  6914. return Ok(JsonView(true, data.Msg, data.Data));
  6915. }
  6916. catch (Exception ex)
  6917. {
  6918. return Ok(JsonView(false, ex.Message));
  6919. }
  6920. }
  6921. /// <summary>
  6922. /// 酒店预订
  6923. /// 详情
  6924. /// </summary>
  6925. /// <param name="_dto"></param>
  6926. /// <returns></returns>
  6927. [HttpPost]
  6928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6929. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  6930. {
  6931. try
  6932. {
  6933. #region 参数验证
  6934. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6935. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6936. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6937. #region 团组操作权限验证 76 酒店预定模块
  6938. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6939. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6940. #endregion
  6941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6942. #region 页面操作权限验证
  6943. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6944. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  6945. #endregion
  6946. #endregion
  6947. Result data = await _hotelPriceRep._Details(_dto.PortType,_dto.Id);
  6948. if (data.Code != 0)
  6949. {
  6950. return Ok(JsonView(false, data.Msg));
  6951. }
  6952. return Ok(JsonView(true, data.Msg, data.Data));
  6953. }
  6954. catch (Exception ex)
  6955. {
  6956. return Ok(JsonView(false, ex.Message));
  6957. }
  6958. }
  6959. /// <summary>
  6960. /// 酒店预订
  6961. /// Add Or Edit
  6962. /// </summary>
  6963. /// <param name="_dto"></param>
  6964. /// <returns></returns>
  6965. [HttpPost]
  6966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6967. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  6968. {
  6969. try
  6970. {
  6971. #region 参数验证
  6972. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6973. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  6974. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  6975. #region 团组操作权限验证 76 酒店预定模块
  6976. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  6977. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  6978. #endregion
  6979. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  6980. #region 页面操作权限验证
  6981. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6982. if (_dto.Id == 0) // Add
  6983. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  6984. else if (_dto.Id > 0) // Edit
  6985. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  6986. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  6987. #endregion
  6988. #endregion
  6989. Result data = await _hotelPriceRep._AddOrEdit(_dto);
  6990. if (data.Code != 0)
  6991. {
  6992. return Ok(JsonView(false, data.Msg));
  6993. }
  6994. return Ok(JsonView(true, data.Msg, data.Data));
  6995. }
  6996. catch (Exception ex)
  6997. {
  6998. return Ok(JsonView(false, ex.Message));
  6999. }
  7000. }
  7001. /// <summary>
  7002. /// 酒店预订
  7003. /// Del
  7004. /// </summary>
  7005. /// <param name="_dto"></param>
  7006. /// <returns></returns>
  7007. [HttpPost]
  7008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7009. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  7010. {
  7011. try
  7012. {
  7013. #region 参数验证
  7014. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7015. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7016. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7017. #region 团组操作权限验证 76 酒店预定模块
  7018. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7019. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7020. #endregion
  7021. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7022. #region 页面操作权限验证
  7023. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7024. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7025. #endregion
  7026. #endregion
  7027. Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  7028. if (data.Code != 0)
  7029. {
  7030. return Ok(JsonView(false, data.Msg));
  7031. }
  7032. return Ok(JsonView(true, data.Msg, data.Data));
  7033. }
  7034. catch (Exception ex)
  7035. {
  7036. return Ok(JsonView(false, ex.Message));
  7037. }
  7038. }
  7039. /// <summary>
  7040. /// 酒店预订
  7041. /// 生成VOUCHER
  7042. /// </summary>
  7043. /// <param name="_dto"></param>
  7044. /// <returns></returns>
  7045. [HttpPost]
  7046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7047. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  7048. {
  7049. try
  7050. {
  7051. #region 参数验证
  7052. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7053. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7054. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7055. #region 团组操作权限验证 76 酒店预定模块
  7056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7057. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7058. #endregion
  7059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7060. #region 页面操作权限验证
  7061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7063. #endregion
  7064. #endregion
  7065. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  7066. //判断数据是否完整
  7067. if (hr != null)
  7068. {
  7069. if (!string.IsNullOrEmpty(hr.DetermineNo))
  7070. {
  7071. string strFileName = "HotelStatement/";
  7072. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  7073. if (dele != null)
  7074. strFileName += dele.TourCode;
  7075. //载入模板
  7076. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  7077. Document doc = new Document(sss);
  7078. DocumentBuilder builder = new DocumentBuilder(doc);
  7079. #region 替换Word模板书签内容
  7080. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  7081. //入住卷预定号码
  7082. if (doc.Range.Bookmarks["VNO"] != null)
  7083. {
  7084. Bookmark mark = doc.Range.Bookmarks["VNO"];
  7085. mark.Text = hr.CheckNumber;
  7086. }
  7087. //酒店时间
  7088. if (doc.Range.Bookmarks["Date"] != null)
  7089. {
  7090. Bookmark mark = doc.Range.Bookmarks["Date"];
  7091. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7092. }
  7093. //团号
  7094. if (doc.Range.Bookmarks["TNo"] != null)
  7095. {
  7096. Bookmark mark = doc.Range.Bookmarks["TNo"];
  7097. mark.Text = dele.TourCode;
  7098. }
  7099. //预定号码
  7100. if (doc.Range.Bookmarks["BookingId"] != null)
  7101. {
  7102. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  7103. mark.Text = hr.ReservationsNo;
  7104. }
  7105. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  7106. {
  7107. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  7108. mark.Text = hr.DetermineNo;
  7109. }
  7110. //酒店城市
  7111. if (doc.Range.Bookmarks["City"] != null)
  7112. {
  7113. Bookmark mark = doc.Range.Bookmarks["City"];
  7114. mark.Text = hr.City;
  7115. }
  7116. //酒店名称
  7117. if (doc.Range.Bookmarks["HName"] != null)
  7118. {
  7119. Bookmark mark = doc.Range.Bookmarks["HName"];
  7120. mark.Text = hr.HotelName;
  7121. }
  7122. //酒店地址
  7123. if (doc.Range.Bookmarks["Address"] != null)
  7124. {
  7125. Bookmark mark = doc.Range.Bookmarks["Address"];
  7126. mark.Text = hr.HotelAddress;
  7127. }
  7128. //酒店电话
  7129. if (doc.Range.Bookmarks["Tel"] != null)
  7130. {
  7131. Bookmark mark = doc.Range.Bookmarks["Tel"];
  7132. mark.Text = hr.HotelTel;
  7133. }
  7134. //酒店传真
  7135. if (doc.Range.Bookmarks["Fax"] != null)
  7136. {
  7137. Bookmark mark = doc.Range.Bookmarks["Fax"];
  7138. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  7139. {
  7140. mark.Text = hr.HotelFax;
  7141. }
  7142. }
  7143. //入住时间
  7144. if (doc.Range.Bookmarks["CIn"] != null)
  7145. {
  7146. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7147. Bookmark mark = doc.Range.Bookmarks["CIn"];
  7148. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  7149. }
  7150. //退房时间
  7151. if (doc.Range.Bookmarks["COut"] != null)
  7152. {
  7153. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7154. Bookmark mark = doc.Range.Bookmarks["COut"];
  7155. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7156. }
  7157. //客户名称
  7158. if (doc.Range.Bookmarks["GName"] != null)
  7159. {
  7160. string guestName = "";
  7161. string[] clients = new string[] { };
  7162. if (hr.GuestName.Contains(","))
  7163. {
  7164. clients = hr.GuestName.Split(",");
  7165. }
  7166. else
  7167. {
  7168. clients = new string[] { hr.GuestName };
  7169. }
  7170. List<int> clientIds_int = new List<int>();
  7171. if (clients.Length > 0)
  7172. {
  7173. foreach (var item in clients)
  7174. {
  7175. if (item.IsNumeric())
  7176. {
  7177. clientIds_int.Add(int.Parse(item));
  7178. }
  7179. }
  7180. }
  7181. if (clientIds_int.Count > 0)
  7182. {
  7183. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  7184. foreach (var client in _clientDatas)
  7185. {
  7186. //男
  7187. if (client.Sex == 0) guestName += $"Mr.";
  7188. //女
  7189. else if (client.Sex == 1) guestName += $"Ms.";
  7190. if (!String.IsNullOrEmpty(client.FirstName+ client.LastName))
  7191. {
  7192. guestName += $"{string.Join("",client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  7193. }
  7194. //guestName += $"{client.Pinyin},";
  7195. }
  7196. if (guestName.Length > 0)
  7197. {
  7198. guestName = guestName.Substring(0, guestName.Length - 1);
  7199. }
  7200. }
  7201. else
  7202. {
  7203. guestName = hr.GuestName;
  7204. }
  7205. Bookmark mark = doc.Range.Bookmarks["GName"];
  7206. mark.Text = guestName;
  7207. }
  7208. //房间介绍
  7209. if (doc.Range.Bookmarks["ROOM"] != null)
  7210. {
  7211. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  7212. mark.Text = hr.RoomExplanation;
  7213. }
  7214. //报价描述
  7215. if (doc.Range.Bookmarks["NOTE"] != null)
  7216. {
  7217. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  7218. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  7219. if (ss != null)
  7220. mark.Text = ss.Name;
  7221. }
  7222. //入住时间
  7223. if (doc.Range.Bookmarks["CheckIn"] != null)
  7224. {
  7225. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  7226. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  7227. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  7228. }
  7229. //退房时间
  7230. if (doc.Range.Bookmarks["CheckOut"] != null)
  7231. {
  7232. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  7233. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  7234. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  7235. }
  7236. //日期
  7237. if (doc.Range.Bookmarks["DT"] != null)
  7238. {
  7239. Bookmark mark = doc.Range.Bookmarks["DT"];
  7240. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  7241. }
  7242. //名称
  7243. if (doc.Range.Bookmarks["VName"] != null)
  7244. {
  7245. Bookmark mark = doc.Range.Bookmarks["VName"];
  7246. mark.Text = hr.HotelName;
  7247. }
  7248. //号码
  7249. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  7250. {
  7251. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  7252. mark.Text = hr.CheckNumber;
  7253. }
  7254. #endregion
  7255. strFileName += "VOUCHER.doc";
  7256. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  7257. doc.Save(fileDir);
  7258. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  7259. return Ok(JsonView(true, "操作成功!", Url));
  7260. }
  7261. else
  7262. {
  7263. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  7264. }
  7265. }
  7266. else
  7267. {
  7268. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  7269. }
  7270. }
  7271. catch (Exception ex)
  7272. {
  7273. return Ok(JsonView(false, ex.Message));
  7274. }
  7275. }
  7276. /// <summary>
  7277. /// 酒店预订
  7278. /// 确认单
  7279. /// </summary>
  7280. /// <param name="_dto"></param>
  7281. /// <returns></returns>
  7282. [HttpPost]
  7283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7284. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  7285. {
  7286. try
  7287. {
  7288. #region 参数验证
  7289. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  7290. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  7291. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  7292. #region 团组操作权限验证 76 酒店预定模块
  7293. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  7294. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  7295. #endregion
  7296. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7297. #region 页面操作权限验证
  7298. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7299. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7300. #endregion
  7301. #endregion
  7302. //团组信息
  7303. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  7304. //酒店数据
  7305. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  7306. if (listhoteldata.Count < 0)
  7307. {
  7308. return Ok(JsonView(false, "当前团组暂无酒店预订信息!"));
  7309. }
  7310. //利datatable存储
  7311. DataTable dt = new DataTable();
  7312. dt.Columns.Add("CheckInDate", typeof(string));
  7313. dt.Columns.Add("City", typeof(string));
  7314. dt.Columns.Add("Hotel", typeof(string));
  7315. dt.Columns.Add("Room", typeof(string));
  7316. for (int i = 0; i < listhoteldata.Count; i++)
  7317. {
  7318. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  7319. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  7320. while (dayStart < dayEnd)
  7321. {
  7322. string temp = "";
  7323. DataRow row = dt.NewRow();
  7324. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  7325. row["City"] = listhoteldata[i].City;
  7326. row["Hotel"] = listhoteldata[i].HotelName;
  7327. if (listhoteldata[i].SingleRoomCount > 0)
  7328. {
  7329. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  7330. }
  7331. if (listhoteldata[i].DoubleRoomCount > 0)
  7332. {
  7333. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  7334. }
  7335. if (listhoteldata[i].SuiteRoomCount > 0)
  7336. {
  7337. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  7338. }
  7339. if (listhoteldata[i].OtherRoomCount > 0)
  7340. {
  7341. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  7342. }
  7343. row["Room"] = temp;
  7344. dt.Rows.Add(row);
  7345. dayStart = dayStart.AddDays(1);
  7346. }
  7347. }
  7348. Dictionary<string, string> dic = new Dictionary<string, string>();
  7349. dic.Add("Dele", di.TeamName);
  7350. dic.Add("City", di.VisitCountry);
  7351. //模板路径
  7352. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  7353. //载入模板
  7354. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  7355. DocumentBuilder builder = new DocumentBuilder(doc);
  7356. foreach (var key in dic.Keys)
  7357. {
  7358. builder.MoveToBookmark(key);
  7359. builder.Write(dic[key]);
  7360. }
  7361. //获取word里所有表格
  7362. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7363. //获取所填表格的序数
  7364. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7365. var rowStart = tableOne.Rows[0]; //获取第1行
  7366. //循环赋值
  7367. for (int i = 0; i < dt.Rows.Count; i++)
  7368. {
  7369. builder.MoveToCell(0, i + 1, 0, 0);
  7370. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  7371. builder.MoveToCell(0, i + 1, 1, 0);
  7372. builder.Write(dt.Rows[i]["City"].ToString());
  7373. builder.MoveToCell(0, i + 1, 2, 0);
  7374. builder.Write(dt.Rows[i]["Hotel"].ToString());
  7375. builder.MoveToCell(0, i + 1, 3, 0);
  7376. builder.Write(dt.Rows[i]["Room"].ToString());
  7377. }
  7378. //删除多余行
  7379. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  7380. {
  7381. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  7382. }
  7383. string strFileName = di.TeamName + "酒店确认单.doc";
  7384. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  7385. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  7386. return Ok(JsonView(true, "成功", url));
  7387. }
  7388. catch (Exception ex)
  7389. {
  7390. return Ok(JsonView(false, ex.Message));
  7391. }
  7392. }
  7393. #endregion
  7394. #region 团组状态
  7395. /// <summary>
  7396. /// 团组状态列表 Page
  7397. /// </summary>
  7398. /// <param name="dto">团组列表请求dto</param>
  7399. /// <returns></returns>
  7400. [HttpPost]
  7401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7402. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  7403. {
  7404. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7405. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  7406. {
  7407. string sqlWhere = string.Empty;
  7408. if (dto.IsSure == 0) //未完成
  7409. {
  7410. sqlWhere += string.Format(@" And IsSure = 0");
  7411. }
  7412. else if (dto.IsSure == 1) //已完成
  7413. {
  7414. sqlWhere += string.Format(@" And IsSure = 1");
  7415. }
  7416. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  7417. {
  7418. string tj = dto.SearchCriteria;
  7419. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  7420. tj, tj, tj, tj, tj);
  7421. }
  7422. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  7423. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  7424. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  7425. From (
  7426. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  7427. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  7428. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  7429. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  7430. From Grp_DelegationInfo gdi
  7431. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  7432. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  7433. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  7434. Where gdi.IsDel = 0 {0}
  7435. ) temp ", sqlWhere);
  7436. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  7437. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  7438. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  7439. }
  7440. else
  7441. {
  7442. return Ok(JsonView(false, "查询失败"));
  7443. }
  7444. }
  7445. /// <summary>
  7446. /// 团组状态
  7447. /// 设置操作完成
  7448. /// </summary>
  7449. /// <param name="dto">团组列表请求dto</param>
  7450. /// <returns></returns>
  7451. [HttpPost]
  7452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7453. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  7454. {
  7455. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  7456. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  7457. {
  7458. Id = dto.Id,
  7459. IsSure = 1
  7460. };
  7461. var result = await _sqlSugar.Updateable(_DelegationInfo)
  7462. .UpdateColumns(it => new { it.IsSure })
  7463. .WhereColumns(it => new { it.Id })
  7464. .ExecuteCommandAsync();
  7465. if (result > 0)
  7466. {
  7467. return Ok(JsonView(true, "操作完成!"));
  7468. }
  7469. return Ok(JsonView(false, "操作失败!"));
  7470. }
  7471. #endregion
  7472. #region 保险费用录入
  7473. /// <summary>
  7474. /// 根据团组Id查询保险费用列表
  7475. /// </summary>
  7476. /// <param name="dto"></param>
  7477. /// <returns></returns>
  7478. [HttpPost]
  7479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7480. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  7481. {
  7482. try
  7483. {
  7484. Result groupData = await _customersRep.CustomersByDiId(dto);
  7485. if (groupData.Code != 0)
  7486. {
  7487. return Ok(JsonView(false, groupData.Msg));
  7488. }
  7489. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7490. }
  7491. catch (Exception ex)
  7492. {
  7493. return Ok(JsonView(false, ex.Message));
  7494. }
  7495. }
  7496. /// <summary>
  7497. /// 根据保险费用Id查询保险费用详细
  7498. /// </summary>
  7499. /// <param name="dto"></param>
  7500. /// <returns></returns>
  7501. [HttpPost]
  7502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7503. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  7504. {
  7505. try
  7506. {
  7507. Result groupData = await _customersRep.CustomersById(dto);
  7508. if (groupData.Code != 0)
  7509. {
  7510. return Ok(JsonView(false, groupData.Msg));
  7511. }
  7512. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7513. }
  7514. catch (Exception ex)
  7515. {
  7516. return Ok(JsonView(false, ex.Message));
  7517. }
  7518. }
  7519. /// <summary>
  7520. /// 保险费用录入页面初始化绑定
  7521. /// </summary>
  7522. /// <param name="dto"></param>
  7523. /// <returns></returns>
  7524. [HttpPost]
  7525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7526. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  7527. {
  7528. try
  7529. {
  7530. Result groupData = await _customersRep.CustomersInitialize(dto);
  7531. if (groupData.Code != 0)
  7532. {
  7533. return Ok(JsonView(false, groupData.Msg));
  7534. }
  7535. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7536. }
  7537. catch (Exception ex)
  7538. {
  7539. return Ok(JsonView(false, ex.Message));
  7540. }
  7541. }
  7542. /// <summary>
  7543. /// 保险费用操作(Status:1.新增,2.修改)
  7544. /// </summary>
  7545. /// <param name="dto"></param>
  7546. /// <returns></returns>
  7547. [HttpPost]
  7548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7549. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  7550. {
  7551. try
  7552. {
  7553. Result groupData = await _customersRep.OpCustomers(dto);
  7554. if (groupData.Code != 0)
  7555. {
  7556. return Ok(JsonView(false, groupData.Msg));
  7557. }
  7558. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7559. }
  7560. catch (Exception ex)
  7561. {
  7562. return Ok(JsonView(false, ex.Message));
  7563. }
  7564. }
  7565. /// <summary>
  7566. /// 保险文件上传
  7567. /// </summary>
  7568. /// <param name="file"></param>
  7569. /// <returns></returns>
  7570. [HttpPost]
  7571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7572. public async Task<IActionResult> UploadCus(IFormFile file)
  7573. {
  7574. try
  7575. {
  7576. if (file != null)
  7577. {
  7578. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7579. //文件名称
  7580. string projectFileName = file.FileName;
  7581. //上传的文件的路径
  7582. string filePath = "";
  7583. if (!Directory.Exists(fileDir))
  7584. {
  7585. Directory.CreateDirectory(fileDir);
  7586. }
  7587. //上传的文件的路径
  7588. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  7589. using (FileStream fs = System.IO.File.Create(filePath))
  7590. {
  7591. file.CopyTo(fs);
  7592. fs.Flush();
  7593. }
  7594. return Ok(JsonView(true, "上传成功!", projectFileName));
  7595. }
  7596. else
  7597. {
  7598. return Ok(JsonView(false, "上传失败!"));
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. return Ok(JsonView(false, "程序错误!"));
  7604. throw;
  7605. }
  7606. }
  7607. /// <summary>
  7608. /// 保险删除指定文件
  7609. /// </summary>
  7610. /// <param name="dto"></param>
  7611. /// <returns></returns>
  7612. [HttpPost]
  7613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7614. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  7615. {
  7616. try
  7617. {
  7618. string filePath = "";
  7619. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7620. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  7621. //int id = 0;
  7622. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  7623. // 删除该文件
  7624. try
  7625. {
  7626. System.IO.File.Delete(filePath);
  7627. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  7628. {
  7629. Attachment = "",
  7630. }).ExecuteCommandAsync();
  7631. if (result != 0)
  7632. {
  7633. return Ok(JsonView(true, "成功!"));
  7634. }
  7635. else
  7636. {
  7637. return Ok(JsonView(false, "失败!"));
  7638. }
  7639. }
  7640. catch (Exception)
  7641. {
  7642. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  7643. {
  7644. Attachment = "",
  7645. }).ExecuteCommandAsync();
  7646. if (result != 0)
  7647. {
  7648. return Ok(JsonView(true, "成功!"));
  7649. }
  7650. else
  7651. {
  7652. return Ok(JsonView(false, "失败!"));
  7653. }
  7654. }
  7655. }
  7656. catch (Exception ex)
  7657. {
  7658. return Ok(JsonView(false, "程序错误!"));
  7659. throw;
  7660. }
  7661. }
  7662. /// <summary>
  7663. /// 保险费用操作(删除)
  7664. /// </summary>
  7665. /// <param name="dto"></param>
  7666. /// <returns></returns>
  7667. [HttpPost]
  7668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7669. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  7670. {
  7671. try
  7672. {
  7673. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  7674. if (!res)
  7675. {
  7676. return Ok(JsonView(false, "删除失败"));
  7677. }
  7678. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  7679. {
  7680. IsDel = 1,
  7681. DeleteUserId = dto.DeleteUserId,
  7682. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7683. }).ExecuteCommandAsync();
  7684. return Ok(JsonView(true, "删除成功!"));
  7685. }
  7686. catch (Exception ex)
  7687. {
  7688. return Ok(JsonView(false, "程序错误!"));
  7689. throw;
  7690. }
  7691. }
  7692. #endregion
  7693. #region 接团客户名单 PageId 104
  7694. /// <summary>
  7695. /// 接团客户名单
  7696. /// 根据团组Id查询List
  7697. /// </summary>
  7698. /// <param name="dto"></param>
  7699. /// <returns></returns>
  7700. [HttpPost]
  7701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7702. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  7703. {
  7704. #region 参数验证
  7705. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  7706. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7707. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  7708. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7709. #region 页面操作权限验证
  7710. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7711. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7712. #endregion
  7713. #endregion
  7714. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType,_dto.DiId);
  7715. if (viewData.Code != 0)
  7716. {
  7717. return Ok(JsonView(false, viewData.Msg));
  7718. }
  7719. return Ok(JsonView(viewData.Data));
  7720. }
  7721. /// <summary>
  7722. /// 接团客户名单
  7723. /// 基础数据 Init
  7724. /// </summary>
  7725. /// <param name="_dto"></param>
  7726. /// <returns></returns>
  7727. [HttpPost]
  7728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7729. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  7730. {
  7731. #region 参数验证
  7732. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7733. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7734. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7735. #region 页面操作权限验证
  7736. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7737. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7738. #endregion
  7739. #endregion
  7740. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  7741. if (viewData.Code != 0)
  7742. {
  7743. return Ok(JsonView(false, viewData.Msg));
  7744. }
  7745. return Ok(JsonView(viewData.Data));
  7746. }
  7747. /// <summary>
  7748. /// 接团客户名单
  7749. /// 根据 Id查询 Details
  7750. /// </summary>
  7751. /// <param name="_dto"></param>
  7752. /// <returns></returns>
  7753. [HttpPost]
  7754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7755. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  7756. {
  7757. #region 参数验证
  7758. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7759. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7760. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7762. #region 页面操作权限验证
  7763. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7764. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  7765. #endregion
  7766. #endregion
  7767. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  7768. if (viewData.Code != 0)
  7769. {
  7770. return Ok(JsonView(false, viewData.Msg));
  7771. }
  7772. return Ok(JsonView(viewData.Data));
  7773. }
  7774. /// <summary>
  7775. /// 接团客户名单
  7776. /// Add Or Edit
  7777. /// </summary>
  7778. /// <param name="_dto"></param>
  7779. /// <returns></returns>
  7780. [HttpPost]
  7781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7782. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  7783. {
  7784. #region 参数验证
  7785. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7786. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7787. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7789. #region 页面操作权限验证
  7790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7791. if (_dto.Id == 0) //添加
  7792. {
  7793. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7794. }else if (_dto.Id >= 0) //修改
  7795. {
  7796. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  7797. }
  7798. #endregion
  7799. #endregion
  7800. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  7801. if (viewData.Code != 0)
  7802. {
  7803. return Ok(JsonView(false, viewData.Msg));
  7804. }
  7805. return Ok(JsonView(true));
  7806. }
  7807. /// <summary>
  7808. /// 接团客户名单
  7809. /// AddMultiple(添加多个)
  7810. /// </summary>
  7811. /// <param name="_dto"></param>
  7812. /// <returns></returns>
  7813. [HttpPost]
  7814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7815. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  7816. {
  7817. #region 参数验证
  7818. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7819. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7820. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7821. #region 页面操作权限验证
  7822. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7823. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  7824. #endregion
  7825. #endregion
  7826. var viewData = await _tourClientListRep._AddMultiple(_dto);
  7827. if (viewData.Code != 0)
  7828. {
  7829. return Ok(JsonView(false, viewData.Msg));
  7830. }
  7831. return Ok(JsonView(true));
  7832. }
  7833. /// <summary>
  7834. /// 接团客户名单
  7835. /// Del
  7836. /// </summary>
  7837. /// <param name="_dto"></param>
  7838. /// <returns></returns>
  7839. [HttpPost]
  7840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7841. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  7842. {
  7843. #region 参数验证
  7844. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7845. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7846. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7847. #region 页面操作权限验证
  7848. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7849. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  7850. #endregion
  7851. #endregion
  7852. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  7853. if (viewData.Code != 0)
  7854. {
  7855. return Ok(JsonView(false, viewData.Msg));
  7856. }
  7857. return Ok(JsonView(true));
  7858. }
  7859. /// <summary>
  7860. /// 接团客户名单
  7861. /// 文件下载 客户名单
  7862. /// </summary>
  7863. /// <param name="_dto"></param>
  7864. /// <returns></returns>
  7865. [HttpPost]
  7866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7867. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  7868. {
  7869. #region 参数验证
  7870. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  7871. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  7872. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  7873. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  7874. #region 页面操作权限验证
  7875. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  7876. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  7877. #endregion
  7878. #endregion
  7879. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7880. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7881. From Grp_TourClientList tcl
  7882. Left Join
  7883. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7884. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7885. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7886. From Crm_DeleClient dc
  7887. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7888. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7889. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7890. Where dc.IsDel = 0) temp
  7891. On temp.DcId =tcl.ClientId
  7892. Where tcl.IsDel = 0 And tcl.DiId = {0}",_dto.DiId);
  7893. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  7894. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  7895. //载入模板
  7896. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  7897. //载入模板
  7898. var doc = new Document(tempPath);
  7899. DocumentBuilder builder = new DocumentBuilder(doc);
  7900. //获取word里所有表格
  7901. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7902. //获取所填表格的序数
  7903. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7904. var rowStart = tableOne.Rows[0]; //获取第1行
  7905. //循环赋值
  7906. for (int i = 0; i < DcList.Count; i++)
  7907. {
  7908. builder.MoveToCell(0, i + 1, 0, 0);
  7909. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  7910. builder.MoveToCell(0, i + 1, 1, 0);
  7911. int sex = DcList[i].Sex;
  7912. string sexStr = string.Empty;
  7913. if (sex == 0) sexStr = "男";
  7914. else if (sex == 1) sexStr = "女";
  7915. else sexStr = "未设置";
  7916. builder.Write(sexStr);
  7917. builder.MoveToCell(0, i + 1, 2, 0);
  7918. string birthDay = DcList[i].BirthDay;
  7919. string birthDayStr = string.Empty;
  7920. if (!string.IsNullOrEmpty(birthDay))
  7921. {
  7922. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  7923. }
  7924. builder.Write(birthDayStr);
  7925. builder.MoveToCell(0, i + 1, 3, 0);
  7926. builder.Write(DcList[i].CompanyFullName);
  7927. builder.MoveToCell(0, i + 1, 4, 0);
  7928. builder.Write(DcList[i].Job);
  7929. }
  7930. //删除多余行
  7931. while (tableOne.Rows.Count > DcList.Count + 1)
  7932. {
  7933. tableOne.Rows.RemoveAt(DcList.Count + 1);
  7934. }
  7935. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  7936. var fileDir = AppSettingsHelper.Get("WordBasePath") + fileName;
  7937. doc.Save(fileDir);
  7938. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + fileName;
  7939. return Ok(JsonView(true, "操作成功!", Url));
  7940. }
  7941. #endregion
  7942. #region 团组倒推表
  7943. /// <summary>
  7944. /// 倒推表基础数据
  7945. /// Init
  7946. /// </summary>
  7947. /// <param name="dto"></param>
  7948. /// <returns></returns>
  7949. [HttpPost]
  7950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7951. public async Task<IActionResult> PostInvertedListInit()
  7952. {
  7953. var viewData = await _invertedListRep._Init();
  7954. if (viewData.Code != 0)
  7955. {
  7956. return Ok(JsonView(false, viewData.Msg));
  7957. }
  7958. return Ok(JsonView(viewData.Data));
  7959. }
  7960. /// <summary>
  7961. /// 倒推表
  7962. /// Info
  7963. /// </summary>
  7964. /// <param name="dto"></param>
  7965. /// <returns></returns>
  7966. [HttpPost]
  7967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7968. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  7969. {
  7970. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  7971. if (viewData.Code != 0)
  7972. {
  7973. return Ok(JsonView(false, viewData.Msg));
  7974. }
  7975. return Ok(JsonView(viewData.Data));
  7976. }
  7977. /// <summary>
  7978. /// 倒推表
  7979. /// Create
  7980. /// </summary>
  7981. /// <param name="dto"></param>
  7982. /// <returns></returns>
  7983. [HttpPost]
  7984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7985. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  7986. {
  7987. var viewData = await _invertedListRep._Create(dto.PortType,dto.DiId);
  7988. if (viewData.Code != 0)
  7989. {
  7990. return Ok(JsonView(false, viewData.Msg));
  7991. }
  7992. return Ok(JsonView(viewData.Data));
  7993. }
  7994. /// <summary>
  7995. /// 倒推表
  7996. /// Update
  7997. /// </summary>
  7998. /// <param name="dto"></param>
  7999. /// <returns></returns>
  8000. [HttpPost]
  8001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8002. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  8003. {
  8004. var viewData = await _invertedListRep._Update(dto);
  8005. if (viewData.Code != 0)
  8006. {
  8007. return Ok(JsonView(false, viewData.Msg));
  8008. }
  8009. return Ok(JsonView(viewData.Data));
  8010. }
  8011. /// <summary>
  8012. /// 倒推表
  8013. /// File Download
  8014. /// </summary>
  8015. /// <param name="dto"></param>
  8016. /// <returns></returns>
  8017. [HttpPost]
  8018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8019. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  8020. {
  8021. var info1 = await _invertedListRep._sqlSugar.Queryable<Grp_InvertedList>().Where(it => it.Id == dto.DiId).FirstAsync();
  8022. if (info1 == null)
  8023. {
  8024. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  8025. }
  8026. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  8027. string teamName = "";
  8028. if (info != null) teamName = info.TeamName;
  8029. //载入模板
  8030. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  8031. DocumentBuilder builder = new DocumentBuilder(doc);
  8032. //利用键值对存放数据
  8033. Dictionary<string, string> dic = new Dictionary<string, string>();
  8034. dic.Add("TeamName", teamName);
  8035. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime());
  8036. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  8037. dic.Add("BPRemark", info1.ApprovalDataRemark);
  8038. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  8039. dic.Add("SQRemark", info1.ApprovalRemark);
  8040. dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
  8041. dic.Add("CPJRemark", info1.ApprovalRemark);
  8042. dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  8043. dic.Add("HZRemark", info1.ApplyPassportRemark);
  8044. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  8045. dic.Add("QZRemark", info1.VisaInformationRemark);
  8046. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  8047. dic.Add("SQQZRemark", info1.SendVisaRemark);
  8048. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  8049. dic.Add("SQQZRemark", info1.IssueVisaRemark);
  8050. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  8051. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  8052. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  8053. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  8054. #region 填充word模板书签内容
  8055. foreach (var key in dic.Keys)
  8056. {
  8057. builder.MoveToBookmark(key);
  8058. builder.Write(dic[key]);
  8059. }
  8060. #endregion
  8061. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8062. string fileName = $"{teamName}团出行准备流程表.doc";
  8063. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  8064. doc.Save(filePath);
  8065. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  8066. return Ok(JsonView(true, "操作成功!", Url));
  8067. }
  8068. #endregion
  8069. }
  8070. }