GroupsController.cs 579 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834
  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. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. namespace OASystem.API.Controllers
  89. {
  90. /// <summary>
  91. /// 团组相关
  92. /// </summary>
  93. //[Authorize]
  94. [Route("api/[controller]/[action]")]
  95. public class GroupsController : ControllerBase
  96. {
  97. private readonly GrpScheduleRepository _grpScheduleRep;
  98. private readonly IMapper _mapper;
  99. private readonly DelegationInfoRepository _groupRepository;
  100. private readonly TaskAssignmentRepository _taskAssignmentRep;
  101. private readonly AirTicketResRepository _airTicketResRep;
  102. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  103. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  104. private readonly DelegationEnDataRepository _delegationEnDataRep;
  105. private readonly DelegationVisaRepository _delegationVisaRep;
  106. private readonly VisaPriceRepository _visaPriceRep;
  107. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  108. private readonly HotelPriceRepository _hotelPriceRep;
  109. private readonly CustomersRepository _customersRep;
  110. private readonly MessageRepository _message;
  111. private readonly SqlSugarClient _sqlSugar;
  112. private readonly TourClientListRepository _tourClientListRep;
  113. private readonly TeamRateRepository _teamRateRep;
  114. #region 成本相关
  115. private readonly CheckBoxsRepository _checkBoxs;
  116. private readonly GroupCostRepository _GroupCostRepository;
  117. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  118. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  119. #endregion
  120. private readonly SetDataRepository _setDataRep;
  121. private string url;
  122. private string path;
  123. private readonly EnterExitCostRepository _enterExitCostRep;
  124. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  125. private readonly UsersRepository _usersRep;
  126. private readonly IJuHeApiService _juHeApi;
  127. private readonly InvertedListRepository _invertedListRep;
  128. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  129. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  130. private readonly HotelInquiryRepository _hotelInquiryRep;
  131. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  132. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  133. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  134. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  135. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  136. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  137. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  138. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  139. {
  140. _mapper = mapper;
  141. _grpScheduleRep = grpScheduleRep;
  142. _groupRepository = groupRepository;
  143. _taskAssignmentRep = taskAssignmentRep;
  144. _airTicketResRep = airTicketResRep;
  145. _sqlSugar = sqlSugar;
  146. url = AppSettingsHelper.Get("ExcelBaseUrl");
  147. path = AppSettingsHelper.Get("ExcelBasePath");
  148. if (!System.IO.Directory.Exists(path))
  149. {
  150. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  151. }
  152. _decreasePaymentsRep = decreasePaymentsRep;
  153. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  154. _delegationEnDataRep = delegationEnDataRep;
  155. _enterExitCostRep = enterExitCostRep;
  156. _delegationVisaRep = delegationVisaRep;
  157. _message = message;
  158. _visaPriceRep = visaPriceRep;
  159. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  160. _checkBoxs = checkBoxs;
  161. _GroupCostRepository = GroupCostRepository;
  162. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  163. _GroupCostParameterRepository = GroupCostParameterRepository;
  164. _hotelPriceRep = hotelPriceRep;
  165. _customersRep = customersRep;
  166. _setDataRep = setDataRep;
  167. _tourClientListRep = tourClientListRep;
  168. _teamRateRep = teamRateRep;
  169. _hubContext = hubContext;
  170. _usersRep = usersRep;
  171. _juHeApi = juHeApi;
  172. _invertedListRep = invertedListRep;
  173. _visaFeeInfoRep = visaFeeInfoRep;
  174. _ticketBlackCodeRep = ticketBlackCodeRep;
  175. _hotelInquiryRep = hotelInquiryRep;
  176. }
  177. #region 流程管控
  178. /// <summary>
  179. /// 获取团组流程管控信息
  180. /// </summary>
  181. /// <param name="paras">参数Json字符串</param>
  182. /// <returns></returns>
  183. [HttpPost]
  184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  185. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  186. {
  187. if (string.IsNullOrEmpty(_jsonDto.Paras))
  188. {
  189. return Ok(JsonView(false, "参数为空"));
  190. }
  191. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  192. if (_ScheduleDto != null)
  193. {
  194. if (_ScheduleDto.SearchType == 2)//获取列表
  195. {
  196. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  197. return Ok(JsonView(_grpScheduleViewList));
  198. }
  199. else//获取对象
  200. {
  201. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  202. if (_grpScheduleView != null)
  203. {
  204. return Ok(JsonView(_grpScheduleView));
  205. }
  206. }
  207. }
  208. else
  209. {
  210. return Ok(JsonView(false, "参数反序列化失败"));
  211. }
  212. return Ok(JsonView(false, "暂无数据!"));
  213. }
  214. /// <summary>
  215. /// 修改团组流程管控详细表数据
  216. /// </summary>
  217. /// <param name="paras"></param>
  218. /// <returns></returns>
  219. [HttpPost]
  220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  221. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  222. {
  223. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  224. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  225. .SetColumns(it => it.Duty == _detail.Duty)
  226. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  227. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  228. .SetColumns(it => it.JobContent == _detail.JobContent)
  229. .SetColumns(it => it.Remark == _detail.Remark)
  230. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  231. .Where(s => s.Id == dto.Id)
  232. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  233. .ExecuteCommandAsync();
  234. if (result > 0)
  235. {
  236. return Ok(JsonView(true, "保存成功!"));
  237. }
  238. return Ok(JsonView(false, "保存失败!"));
  239. }
  240. /// <summary>
  241. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  242. /// </summary>
  243. /// <param name="dto"></param>
  244. /// <returns></returns>
  245. [HttpPost]
  246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  247. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  248. {
  249. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  250. _detail.IsDel = 1;
  251. _detail.DeleteUserId = dto.Duty;
  252. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  253. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  254. .SetColumns(it => it.IsDel == _detail.IsDel)
  255. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  256. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  257. .Where(it => it.Id == dto.Id)
  258. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  259. //.WhereColumns(s => s.Id == dto.Id)
  260. .ExecuteCommandAsync();
  261. if (result > 0)
  262. {
  263. return Ok(JsonView(true, "删除成功!"));
  264. }
  265. return Ok(JsonView(false, "删除失败!"));
  266. }
  267. /// <summary>
  268. /// 增加团组流程管控详细表数据
  269. /// </summary>
  270. /// <param name="dto"></param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  275. {
  276. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  277. if (DateTime.Now < _detail.ExpectBeginDt)
  278. {
  279. _detail.StepStatus = 0;
  280. }
  281. else
  282. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  283. _detail.StepStatus = 1;
  284. }
  285. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  286. if (result > 0)
  287. {
  288. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  289. return Ok(JsonView(true, "添加成功!", _result));
  290. }
  291. return Ok(JsonView(false, "添加失败!"));
  292. }
  293. #endregion
  294. #region 团组基本信息
  295. /// <summary>
  296. /// 接团信息列表
  297. /// </summary>
  298. /// <param name="dto">团组列表请求dto</param>
  299. /// <returns></returns>
  300. [HttpPost]
  301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  302. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  303. {
  304. var groupData = await _groupRepository.GetGroupList(dto);
  305. if (groupData.Code != 0)
  306. {
  307. return Ok(JsonView(false, groupData.Msg));
  308. }
  309. return Ok(JsonView(groupData.Data));
  310. }
  311. /// <summary>
  312. /// 接团信息列表 Page
  313. /// </summary>
  314. /// <param name="dto">团组列表请求dto</param>
  315. /// <returns></returns>
  316. [HttpPost]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  319. {
  320. #region 参数验证
  321. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  322. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  323. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  324. #region 页面操作权限验证
  325. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  326. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  327. #endregion
  328. #endregion
  329. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  330. {
  331. string sqlWhere = string.Empty;
  332. if (dto.IsSure == 0) //未完成
  333. {
  334. sqlWhere += string.Format(@" And IsSure = 0");
  335. }
  336. else if (dto.IsSure == 1) //已完成
  337. {
  338. sqlWhere += string.Format(@" And IsSure = 1");
  339. }
  340. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  341. {
  342. string tj = dto.SearchCriteria;
  343. 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}%')",
  344. tj, tj, tj, tj, tj);
  345. }
  346. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  347. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  348. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  349. JietuanOperator,IsSure,CreateTime
  350. From (
  351. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  352. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  353. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  354. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  355. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  356. From Grp_DelegationInfo gdi
  357. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  358. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  359. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  360. Where gdi.IsDel = 0 {0}
  361. ) temp", sqlWhere);
  362. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  363. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  364. #region 处理所属部门
  365. /*
  366. * 1.sq 和 gyy 等显示 市场部
  367. * 2.王鸽和主管及张总还有管理员号统一国交部
  368. * 2-1. 4 管理员 ,21 张海麟
  369. */
  370. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  371. List<int> userIds1 = new List<int>() { 4, 21 };
  372. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  373. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  374. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  375. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  376. .ToList();
  377. foreach (var item in _DelegationList)
  378. {
  379. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  380. }
  381. #endregion
  382. var _view = new
  383. {
  384. PageFuncAuth = pageFunAuthView,
  385. Data = _DelegationList
  386. };
  387. return Ok(JsonView(true, "查询成功!", _view, total));
  388. }
  389. else
  390. {
  391. return Ok(JsonView(false, "查询失败"));
  392. }
  393. }
  394. /// <summary>
  395. /// 团组列表
  396. /// </summary>
  397. /// <returns></returns>
  398. [HttpPost]
  399. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  400. {
  401. #region 参数验证
  402. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  403. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  404. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  405. #region 页面操作权限验证
  406. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  407. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  408. #endregion
  409. #endregion
  410. if (dto.PortType != 1 && dto.PortType != 2)
  411. {
  412. return Ok(JsonView(false, "查询失败!"));
  413. }
  414. string orderbyStr = "order by gdi.CreateTime Desc";
  415. string sqlWhere = string.Empty;
  416. if (dto.IsSure == 0) //未完成
  417. {
  418. sqlWhere += string.Format(@" And IsSure = 0");
  419. }
  420. else if (dto.IsSure == 1) //已完成
  421. {
  422. sqlWhere += string.Format(@" And IsSure = 1");
  423. }
  424. //团组类型
  425. if (dto.TeamDid > 0)
  426. {
  427. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  428. }
  429. //团组名称
  430. if (!string.IsNullOrEmpty(dto.TeamName))
  431. {
  432. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  433. }
  434. //客户名称
  435. if (!string.IsNullOrEmpty(dto.ClientName))
  436. {
  437. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  438. }
  439. //客户单位
  440. if (!string.IsNullOrEmpty(dto.ClientUnit))
  441. {
  442. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  443. }
  444. //出访时间
  445. if (!string.IsNullOrEmpty(dto.visitDataTime))
  446. {
  447. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  448. orderbyStr = "order by gdi.VisitDate";
  449. }
  450. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  451. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  452. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  453. JietuanOperator,IsSure,CreateTime
  454. From (
  455. Select row_number() over({0}) as Row_Number,
  456. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  457. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  458. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  459. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  460. From Grp_DelegationInfo gdi
  461. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  462. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  463. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  464. Where gdi.IsDel = 0 {1}
  465. ) temp ", orderbyStr, sqlWhere);
  466. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  467. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  468. #region 处理所属部门
  469. /*
  470. * 1.sq 和 gyy 等显示 市场部
  471. * 2.王鸽和主管及张总还有管理员号统一国交部
  472. * 2-1. 4 管理员 ,21 张海麟
  473. */
  474. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  475. List<int> userIds1 = new List<int>() { 4, 21 };
  476. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  477. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  478. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  479. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  480. .ToList();
  481. foreach (var item in _DelegationList)
  482. {
  483. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  484. }
  485. #endregion
  486. var _view = new
  487. {
  488. PageFuncAuth = pageFunAuthView,
  489. Data = _DelegationList
  490. };
  491. return Ok(JsonView(true, "查询成功!", _view, total));
  492. }
  493. /// <summary>
  494. /// 接团信息详情
  495. /// </summary>
  496. /// <param name="dto">团组info请求dto</param>
  497. /// <returns></returns>
  498. [HttpPost]
  499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  500. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  501. {
  502. var groupData = await _groupRepository.GetGroupInfo(dto);
  503. if (groupData.Code != 0)
  504. {
  505. return Ok(JsonView(false, groupData.Msg));
  506. }
  507. return Ok(JsonView(groupData.Data));
  508. }
  509. /// <summary>
  510. /// 接团信息 编辑添加
  511. /// 基础信息数据源
  512. /// </summary>
  513. /// <param name="dto"></param>
  514. /// <returns></returns>
  515. [HttpPost]
  516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  517. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  518. {
  519. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  520. if (groupData.Code != 0)
  521. {
  522. return Ok(JsonView(false, groupData.Msg));
  523. }
  524. return Ok(JsonView(groupData.Data));
  525. }
  526. /// <summary>
  527. /// 接团信息 操作(增改)
  528. /// </summary>
  529. /// <param name="dto"></param>
  530. /// <returns></returns>
  531. [HttpPost]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  534. {
  535. try
  536. {
  537. var groupData = await _groupRepository.GroupOperation(dto);
  538. if (groupData.Code != 0)
  539. {
  540. return Ok(JsonView(false, groupData.Msg));
  541. }
  542. int diId = 0;
  543. //添加时 默认加入团组汇率
  544. if (dto.Status == 1) //添加
  545. {
  546. diId = groupData.Data;
  547. //添加默认币种
  548. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  549. //默认分配权限
  550. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  551. //消息提示 王鸽 主管号
  552. List<int> _managerIds = new List<int>() { 22, 32 };
  553. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  554. if (userIds.Count > 0)
  555. {
  556. userIds.Add(208);
  557. //创建团组管控
  558. GroupStepForDelegation.CreateWorkStep(diId);
  559. //发送消息
  560. string groupName = dto.TeamName;
  561. string createGroupUser = string.Empty;
  562. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  563. if (userInfo != null) createGroupUser = userInfo.CnName;
  564. string title = $"系统通知";
  565. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  566. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  567. }
  568. //默认创建倒推表
  569. await _invertedListRep._Create(dto.UserId, diId);
  570. }
  571. else if (dto.Status == 2)
  572. {
  573. diId = dto.Id;
  574. }
  575. return Ok(JsonView(true, "操作成功!", diId));
  576. }
  577. catch (Exception ex)
  578. {
  579. Logs("[response]" + JsonConvert.SerializeObject(dto));
  580. Logs(ex.Message);
  581. return Ok(JsonView(false, ex.Message));
  582. }
  583. }
  584. /// <summary>
  585. /// 接团流程操作(增改)
  586. /// 安卓端使用 建团时添加客户名单
  587. /// </summary>
  588. /// <param name="dto"></param>
  589. /// <returns></returns>
  590. [HttpPost]
  591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  592. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  593. {
  594. try
  595. {
  596. #region 参数验证
  597. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  598. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  599. #region 页面操作权限验证
  600. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  601. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  602. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  603. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  604. #endregion
  605. #endregion
  606. _sqlSugar.BeginTran();
  607. var _dto = new GroupOperationDto();
  608. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  609. var groupData = await _groupRepository.GroupOperation(_dto);
  610. if (groupData.Code != 0)
  611. {
  612. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  613. }
  614. int diId = 0;
  615. //添加时 默认加入团组汇率
  616. if (dto.Status == 1) //添加
  617. {
  618. diId = groupData.Data;
  619. //添加默认币种
  620. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  621. //默认分配权限
  622. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  623. //消息提示 王鸽 主管号
  624. List<int> _managerIds = new List<int>() { 22, 32 };
  625. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  626. if (userIds.Count > 0)
  627. {
  628. userIds.Add(208);
  629. //创建团组管控
  630. GroupStepForDelegation.CreateWorkStep(diId);
  631. //发送消息
  632. string groupName = dto.TeamName;
  633. string createGroupUser = string.Empty;
  634. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  635. if (userInfo != null) createGroupUser = userInfo.CnName;
  636. string title = $"系统通知";
  637. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  638. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  639. }
  640. }
  641. if (dto.Status == 2)
  642. {
  643. diId = dto.Id;
  644. if (diId == 0)
  645. {
  646. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  647. }
  648. }
  649. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  650. if (viewData.Code != 0)
  651. {
  652. _sqlSugar.RollbackTran();
  653. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  654. }
  655. _sqlSugar.CommitTran();
  656. return Ok(JsonView(true, "添加成功"));
  657. }
  658. catch (Exception ex)
  659. {
  660. _sqlSugar.RollbackTran();
  661. return Ok(JsonView(false, ex.Message));
  662. }
  663. }
  664. /// <summary>
  665. /// 接团信息 操作(删除)
  666. /// </summary>
  667. /// <param name="dto"></param>
  668. /// <returns></returns>
  669. [HttpPost]
  670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  671. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  672. {
  673. try
  674. {
  675. var groupData = await _groupRepository.GroupDel(dto);
  676. if (groupData.Code != 0)
  677. {
  678. return Ok(JsonView(false, groupData.Msg));
  679. }
  680. return Ok(JsonView(true));
  681. }
  682. catch (Exception ex)
  683. {
  684. Logs("[response]" + JsonConvert.SerializeObject(dto));
  685. Logs(ex.Message);
  686. return Ok(JsonView(false, ex.Message));
  687. }
  688. }
  689. /// <summary>
  690. /// 获取团组销售报价号
  691. /// 团组添加时 使用
  692. /// </summary>
  693. /// <returns></returns>
  694. [HttpPost]
  695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  696. public async Task<IActionResult> GetGroupSalesQuoteNo()
  697. {
  698. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  699. if (groupData.Code != 0)
  700. {
  701. return Ok(JsonView(false, groupData.Msg));
  702. }
  703. object salesQuoteNo = new
  704. {
  705. SalesQuoteNo = groupData.Data
  706. };
  707. return Ok(JsonView(salesQuoteNo));
  708. }
  709. /// <summary>
  710. /// 设置确认出团
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  717. {
  718. var groupData = await _groupRepository.ConfirmationGroup(dto);
  719. if (groupData.Code != 0)
  720. {
  721. return Ok(JsonView(false, groupData.Msg));
  722. }
  723. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  724. #region OA消息推送
  725. try
  726. {
  727. string groupName = groupInfo.TeamName;
  728. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  729. List<int> userIds = new List<int>();
  730. listUser.ForEach(s => userIds.Add(s.Id));
  731. string title = $"系统通知";
  732. string content = $"团组[{groupName}]已确认出团!";
  733. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  734. }
  735. catch (Exception ex)
  736. {
  737. }
  738. #endregion
  739. #region 应用推送
  740. try
  741. {
  742. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  743. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  744. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  745. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  746. {
  747. List<string> userList = new List<string>() { users.QiyeChatUserId };
  748. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  749. }
  750. }
  751. catch (Exception ex)
  752. {
  753. }
  754. #endregion
  755. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  756. return Ok(JsonView(true, "操作成功!", groupData.Data));
  757. }
  758. /// <summary>
  759. /// 获取团组名称data And 签证国别Data
  760. /// </summary>
  761. /// <param name="dto"></param>
  762. /// <returns></returns>
  763. [HttpPost]
  764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  765. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  766. {
  767. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  768. if (groupData.Code != 0)
  769. {
  770. return Ok(JsonView(false, groupData.Msg));
  771. }
  772. return Ok(JsonView(groupData.Data));
  773. }
  774. /// <summary>
  775. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  776. /// </summary>
  777. /// <returns></returns>
  778. [HttpPost]
  779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  780. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  781. {
  782. try
  783. {
  784. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  785. if (groupData.Code != 0)
  786. {
  787. return Ok(JsonView(false, groupData.Msg));
  788. }
  789. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  790. }
  791. catch (Exception ex)
  792. {
  793. return Ok(JsonView(false, "程序错误!"));
  794. throw;
  795. }
  796. }
  797. #endregion
  798. #region 团组&签证
  799. /// <summary>
  800. /// 根据团组Id获取签证客户信息List
  801. /// </summary>
  802. /// <param name="dto">请求dto</param>
  803. /// <returns></returns>
  804. [HttpPost]
  805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  806. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  807. {
  808. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  809. if (groupData.Code != 0)
  810. {
  811. return Ok(JsonView(false, groupData.Msg));
  812. }
  813. return Ok(JsonView(groupData.Data));
  814. }
  815. /// <summary>
  816. /// IOS获取团组签证拍照上传进度01(团组列表)
  817. /// </summary>
  818. /// <param name="dto">请求dto</param>
  819. /// <returns></returns>
  820. [HttpPost]
  821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  822. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  823. {
  824. if (dto == null)
  825. {
  826. return Ok(JsonView(false, "参数为空"));
  827. }
  828. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  829. return Ok(JsonView(visaList));
  830. }
  831. /// <summary>
  832. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  833. /// </summary>
  834. /// <returns></returns>
  835. [HttpPost]
  836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  837. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  838. {
  839. if (dto == null)
  840. {
  841. return Ok(JsonView(false, "请求错误:"));
  842. }
  843. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  844. return Ok(JsonView(list));
  845. }
  846. /// <summary>
  847. /// IOS获取团组签证拍照上传进度03(相册)
  848. /// </summary>
  849. /// <returns></returns>
  850. [HttpPost]
  851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  852. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  853. {
  854. if (dto == null)
  855. {
  856. return Ok(JsonView(false, "请求错误:"));
  857. }
  858. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  859. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  860. list.ForEach(s => s.url = url);
  861. return Ok(JsonView(list));
  862. }
  863. /// <summary>
  864. /// IOS获取团组签证拍照上传进度04(图片上传)
  865. /// </summary>
  866. /// <param name="dto"></param>
  867. /// <returns></returns>
  868. [HttpPost]
  869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  870. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  871. {
  872. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  873. //if (!string.IsNullOrEmpty(result))
  874. //{
  875. //}
  876. //else {
  877. // return Ok(JsonView(false, "上传失败"));
  878. //}
  879. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  880. int sucNum = 0;
  881. try
  882. {
  883. foreach (var item in dto.base64DataList)
  884. {
  885. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  886. string result = decodeBase64ToImage(item, imageName);
  887. if (!string.IsNullOrEmpty(result))
  888. {
  889. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  890. pic.CreateUserId = dto.CreateUserId;
  891. pic.PicName = imageName;
  892. pic.PicPath = result;
  893. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  894. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  895. if (insertResult > 0)
  896. {
  897. sucNum++;
  898. }
  899. }
  900. }
  901. }
  902. catch (Exception ex)
  903. {
  904. return Ok(JsonView(false, ex.Message));
  905. }
  906. string msg = string.Format(@"成功上传{0}张", sucNum);
  907. return Ok(JsonView(true, msg));
  908. }
  909. private string decodeBase64ToImage(string base64DataURL, string imgName)
  910. {
  911. string filename = "";//声明一个string类型的相对路径
  912. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  913. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  914. try//会有异常抛出,try,catch一下
  915. {
  916. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  917. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  918. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  919. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  920. //文件名称
  921. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  922. //上传的文件的路径
  923. string filePath = "";
  924. if (!Directory.Exists(fileDir))
  925. {
  926. Directory.CreateDirectory(fileDir);
  927. }
  928. //上传的文件的路径
  929. filePath = fileDir + filename;
  930. //string url = HttpRuntime.AppDomainAppPath.ToString();
  931. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  932. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  933. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  934. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  935. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  936. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  937. ms.Close();//关闭当前流,并释放所有与之关联的资源
  938. bitmap.Dispose();
  939. }
  940. catch (Exception e)
  941. {
  942. string massage = e.Message;
  943. Logs("IOS图片上传Error:" + massage);
  944. //filename = e.Message;
  945. }
  946. return filename;//返回相对路径
  947. }
  948. /// <summary>
  949. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  950. /// </summary>
  951. /// <param name="dto"></param>
  952. /// <returns></returns>
  953. [HttpPost]
  954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  955. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  956. {
  957. if (dto == null)
  958. {
  959. return Ok(JsonView(false, "请求错误:"));
  960. }
  961. string msg = "参数错误";
  962. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  963. {
  964. try
  965. {
  966. //_delegationVisaRep.BeginTran();
  967. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  968. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  969. .Where(s => s.Id == dto.visaProgressCustomerId)
  970. .ExecuteCommandAsync();
  971. if (updCount > 0 && dto.publishCode == 1)
  972. {
  973. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  974. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  975. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  976. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  977. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  978. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  979. if (groupData == null)
  980. {
  981. _delegationVisaRep.RollbackTran();
  982. }
  983. string title = string.Format(@"[签证进度更新]");
  984. string content = string.Format(@"测试文本");
  985. bool rst = await _message.AddMsg(new MessageDto()
  986. {
  987. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  988. IssuerId = dto.publisher,
  989. Title = title,
  990. Content = content,
  991. ReleaseTime = DateTime.Now,
  992. UIdList = new List<int> {
  993. 234
  994. }
  995. });
  996. if (rst)
  997. {
  998. return Ok(JsonView(true, "发送通知成功"));
  999. }
  1000. }
  1001. //_delegationVisaRep.CommitTran();
  1002. }
  1003. catch (Exception)
  1004. {
  1005. //_delegationVisaRep.RollbackTran();
  1006. }
  1007. }
  1008. return Ok(JsonView(true, msg));
  1009. }
  1010. #endregion
  1011. #region 团组任务分配
  1012. /// <summary>
  1013. /// 团组任务分配初始化
  1014. /// </summary>
  1015. /// <param name="dto"></param>
  1016. /// <returns></returns>
  1017. [HttpPost]
  1018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1019. public async Task<IActionResult> GetTaskAssignmen()
  1020. {
  1021. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1022. if (groupData.Code != 0)
  1023. {
  1024. return Ok(JsonView(false, groupData.Msg));
  1025. }
  1026. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1027. }
  1028. /// <summary>
  1029. /// 团组任务分配查询
  1030. /// </summary>
  1031. /// <param name="dto"></param>
  1032. /// <returns></returns>
  1033. [HttpPost]
  1034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1035. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1036. {
  1037. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1038. if (groupData.Code != 0)
  1039. {
  1040. return Ok(JsonView(false, groupData.Msg));
  1041. }
  1042. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1043. }
  1044. /// <summary>
  1045. /// 团组任务分配操作
  1046. /// </summary>
  1047. /// <param name="dto"></param>
  1048. /// <returns></returns>
  1049. [HttpPost]
  1050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1051. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1052. {
  1053. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1054. if (groupData.Code != 0)
  1055. {
  1056. return Ok(JsonView(false, groupData.Msg));
  1057. }
  1058. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1059. }
  1060. #endregion
  1061. #region 团组费用审核
  1062. /// <summary>
  1063. /// 费用审核
  1064. /// 团组列表 Page
  1065. /// </summary>
  1066. /// <param name="_dto">团组列表请求dto</param>
  1067. /// <returns></returns>
  1068. [HttpPost]
  1069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1070. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1071. {
  1072. #region 参数验证
  1073. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1074. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1075. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1076. #region 页面操作权限验证
  1077. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1078. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1079. #endregion
  1080. #endregion
  1081. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1082. {
  1083. string sqlWhere = string.Empty;
  1084. if (_dto.IsSure == 0) //未完成
  1085. {
  1086. sqlWhere += string.Format(@" And IsSure = 0");
  1087. }
  1088. else if (_dto.IsSure == 1) //已完成
  1089. {
  1090. sqlWhere += string.Format(@" And IsSure = 1");
  1091. }
  1092. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1093. {
  1094. string tj = _dto.SearchCriteria;
  1095. 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}%')",
  1096. tj, tj, tj, tj, tj);
  1097. }
  1098. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1099. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1100. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1101. From (
  1102. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1103. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1104. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1105. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1106. From Grp_DelegationInfo gdi
  1107. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1108. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1109. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1110. Where gdi.IsDel = 0 {0}
  1111. ) temp ", sqlWhere);
  1112. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1113. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1114. var _view = new
  1115. {
  1116. PageFuncAuth = pageFunAuthView,
  1117. Data = _DelegationList
  1118. };
  1119. return Ok(JsonView(true, "查询成功!", _view, total));
  1120. }
  1121. else
  1122. {
  1123. return Ok(JsonView(false, "查询失败"));
  1124. }
  1125. }
  1126. /// <summary>
  1127. /// 获取团组费用审核
  1128. /// </summary>
  1129. /// <param name="paras">参数Json字符串</param>
  1130. /// <returns></returns>
  1131. [HttpPost]
  1132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1133. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1134. {
  1135. try
  1136. {
  1137. #region 参数验证
  1138. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1139. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1140. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1141. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1142. #region 页面操作权限验证
  1143. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1144. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1145. #endregion
  1146. #endregion
  1147. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1148. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1149. #region 费用清单
  1150. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1151. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1152. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1153. List<Grp_CreditCardPayment> entityList = _groupRepository
  1154. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1155. .Where(exp.ToExpression())
  1156. .ToList();
  1157. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1158. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1159. /*
  1160. * 76://酒店预订
  1161. */
  1162. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1163. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1164. .ToListAsync();
  1165. /*
  1166. * 79://车/导游地接
  1167. */
  1168. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1169. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1170. .ToListAsync();
  1171. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1172. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. /*
  1175. * 80: //签证
  1176. */
  1177. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1178. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. /*
  1181. *81: //邀请/公务活动
  1182. */
  1183. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1184. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 82: //团组客户保险
  1188. */
  1189. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1190. /*
  1191. * Lable = 85 机票预订
  1192. */
  1193. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1194. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1195. .ToListAsync();
  1196. /*
  1197. * 85 机票预定
  1198. */
  1199. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1200. /*
  1201. * 98 其他款项
  1202. */
  1203. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1204. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1205. .ToListAsync();
  1206. /*
  1207. * 285:收款退还
  1208. */
  1209. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1210. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1211. .ToListAsync();
  1212. /*
  1213. * 1015: //超支费用
  1214. */
  1215. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1216. /*
  1217. * 币种信息
  1218. */
  1219. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1220. /*
  1221. * 车/导游地接 费用类型
  1222. */
  1223. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1224. /*
  1225. * 车/导游地接 费用类型
  1226. */
  1227. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1228. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1229. /*
  1230. * 用户信息
  1231. */
  1232. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1233. /*
  1234. * 费用模块
  1235. */
  1236. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1237. string priceModule = string.Empty;
  1238. if (sdPriceName != null)
  1239. {
  1240. priceModule = sdPriceName.Name;
  1241. }
  1242. /*
  1243. * 处理详情数据
  1244. */
  1245. foreach (var entity in entityList)
  1246. {
  1247. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1248. _detail.Id = entity.Id;
  1249. _detail.PriceName = priceModule;
  1250. /*
  1251. * 应付款金额
  1252. */
  1253. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1254. string PaymentCurrency_WaitPay = "Unknown";
  1255. string hotelCurrncyCode = "Unknown";
  1256. string hotelCurrncyName = "Unknown";
  1257. if (sdPaymentCurrency_WaitPay != null)
  1258. {
  1259. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1260. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1261. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1262. if (hotelCurrncyCode.Equals("CNY"))
  1263. {
  1264. entity.DayRate = 1.0000M;
  1265. }
  1266. }
  1267. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1268. /*
  1269. * 此次付款金额
  1270. */
  1271. decimal CurrPayStr = 0;
  1272. if (entity.PayPercentage == 0)
  1273. {
  1274. if (entity.PayThenMoney != 0)
  1275. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1276. }
  1277. else
  1278. {
  1279. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1280. }
  1281. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1282. /*
  1283. * 剩余尾款
  1284. */
  1285. decimal BalanceStr = 0;
  1286. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1287. BalanceStr = 0;
  1288. else
  1289. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1290. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1291. /*
  1292. * Bus名称
  1293. */
  1294. _detail.BusName = "待增加";
  1295. /*
  1296. *费用所属
  1297. */
  1298. switch (entity.CTable)
  1299. {
  1300. case 76://酒店预订
  1301. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1302. if (hotelReservations != null)
  1303. {
  1304. string GovernmentRentCode = "", GovernmentRentName = "", CityTaxCode = "", CityTaxName = "", BreakfastCode = "", BreakfastName = "";
  1305. Sys_SetData sdPaymentCurrency_GovernmentRent = currencyItems.Where(s => s.Id == hotelReservations.GovernmentRentCurrency).FirstOrDefault();
  1306. if (sdPaymentCurrency_GovernmentRent != null)
  1307. {
  1308. GovernmentRentCode = sdPaymentCurrency_GovernmentRent.Name;
  1309. GovernmentRentName = sdPaymentCurrency_GovernmentRent.Remark;
  1310. }
  1311. Sys_SetData sdPaymentCurrency_CityTax = currencyItems.Where(s => s.Id == hotelReservations.CityTaxCurrency).FirstOrDefault();
  1312. if (sdPaymentCurrency_CityTax != null)
  1313. {
  1314. CityTaxCode = sdPaymentCurrency_CityTax.Name;
  1315. CityTaxName = sdPaymentCurrency_CityTax.Remark;
  1316. }
  1317. Sys_SetData sdPaymentCurrency_Breakfast = currencyItems.Where(s => s.Id == hotelReservations.BreakfastCurrency).FirstOrDefault();
  1318. if (sdPaymentCurrency_Breakfast != null)
  1319. {
  1320. BreakfastCode = sdPaymentCurrency_Breakfast.Name;
  1321. BreakfastName = sdPaymentCurrency_Breakfast.Remark;
  1322. }
  1323. string isoppayStr = hotelReservations.Isoppay == 0 ? "是" : "否";
  1324. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1325. $"房间说明: {hotelReservations.Remark} <br/>" +
  1326. $"地税: {hotelReservations.GovernmentRent.ToString("#0.00")} {GovernmentRentCode} ({GovernmentRentName})<br/>" +
  1327. $"城市税: {hotelReservations.CityTax.ToString("#0.00")} {CityTaxCode} ({CityTaxName})<br/>" +
  1328. $"酒店早餐: {hotelReservations.BreakfastPrice.ToString("#0.00")} {BreakfastCode} ({BreakfastName})<br/>" +
  1329. $"酒店早餐是否由地接代付: {isoppayStr}";
  1330. _detail.PriceNameContent = hotelReservations.HotelName;
  1331. }
  1332. break;
  1333. case 79://车/导游地接
  1334. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1335. if (touristGuideGroundReservations != null)
  1336. {
  1337. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1338. {
  1339. _detail.BusName = touristGuideGroundReservations.BusName;
  1340. }
  1341. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1342. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1343. //if (isInt)
  1344. //{
  1345. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1346. // if (cityInfo != null)
  1347. // {
  1348. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1349. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1350. // if (carFeeItem != null)
  1351. // {
  1352. // nameContent += $@"({carFeeItem.Name})";
  1353. // }
  1354. // _detail.PriceNameContent = nameContent;
  1355. // }
  1356. //}
  1357. //else
  1358. //{
  1359. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1360. //}
  1361. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1362. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1363. string priceMsg = string.Empty;
  1364. foreach (var item in touristGuideGroundReservationsContents)
  1365. {
  1366. string typeName = "Unknown";
  1367. string carCurrencyCode = "Unknown";
  1368. string carCurrencyName = "Unknown";
  1369. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1370. if (carTypeData != null) typeName = carTypeData.Name;
  1371. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1372. if (currencyData != null)
  1373. {
  1374. carCurrencyCode = currencyData.Name;
  1375. carCurrencyName = currencyData.Remark;
  1376. }
  1377. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1378. "明细:" + item.PriceContent + "<br/>" +
  1379. "备注:" + item.Remark + "<br/><br/>";
  1380. }
  1381. _detail.PriceMsgContent = priceMsg;
  1382. }
  1383. break;
  1384. case 80: //签证
  1385. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1386. if (visaInfo != null)
  1387. {
  1388. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1389. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1390. }
  1391. break;
  1392. case 81: //邀请/公务活动
  1393. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1394. if (_ioa != null)
  1395. {
  1396. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1397. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1398. sendCurrName = "Unknown", //快递费用币种 Name
  1399. sendCurrCode = "Unknown", //快递费用币种 Code
  1400. eventsCurrName = "Unknown", //公务活动费币种 Name
  1401. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1402. translateCurrName = "Unknown", //公务翻译费 Name
  1403. translateCurrCode = "Unknown"; //公务翻译费 Code
  1404. #region 处理费用币种
  1405. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1406. if (inviteCurrData != null)
  1407. {
  1408. inviteCurrName = inviteCurrData.Remark;
  1409. inviteCurrCode = inviteCurrData.Name;
  1410. }
  1411. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1412. if (sendCurrData != null)
  1413. {
  1414. sendCurrName = sendCurrData.Remark;
  1415. sendCurrCode = sendCurrData.Name;
  1416. }
  1417. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1418. if (eventsCurrData != null)
  1419. {
  1420. eventsCurrName = eventsCurrData.Remark;
  1421. eventsCurrCode = eventsCurrData.Name;
  1422. }
  1423. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1424. if (translateCurrData != null)
  1425. {
  1426. translateCurrName = translateCurrData.Remark;
  1427. translateCurrCode = translateCurrData.Name;
  1428. }
  1429. #endregion
  1430. _detail.PriceNameContent = _ioa.InviterArea;
  1431. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1432. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1433. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1434. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1435. $@"备注:" + _ioa.Remark + "<br/>";
  1436. }
  1437. break;
  1438. case 82: //团组客户保险
  1439. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1440. if (customers != null)
  1441. {
  1442. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1443. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1444. }
  1445. break;
  1446. case 85: //机票预订
  1447. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1448. if (jpRes != null)
  1449. {
  1450. string FlightsDescription = jpRes.FlightsDescription;
  1451. string PriceDescription = jpRes.PriceDescription;
  1452. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1453. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1454. }
  1455. break;
  1456. case 98://其他款项
  1457. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1458. if (gdpRes != null)
  1459. {
  1460. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1461. _detail.PriceNameContent = gdpRes.PriceName;
  1462. }
  1463. break;
  1464. case 285://收款退还
  1465. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1466. if (refundAndOtherMoney != null)
  1467. {
  1468. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1469. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1470. }
  1471. break;
  1472. case 751://酒店早餐
  1473. break;
  1474. case 1015://超支费用
  1475. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1476. if (groupExtraCost != null)
  1477. {
  1478. _detail.PriceNameContent = groupExtraCost.PriceName;
  1479. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1480. }
  1481. break;
  1482. default:
  1483. break;
  1484. }
  1485. /*
  1486. * 申请人
  1487. */
  1488. string operatorName = " - ";
  1489. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1490. if (_opUser != null)
  1491. {
  1492. operatorName = _opUser.CnName;
  1493. }
  1494. _detail.OperatorName = operatorName;
  1495. /*
  1496. * 审核人
  1497. */
  1498. string auditOperatorName = "Unknown";
  1499. if (entity.AuditGMOperate == 0)
  1500. auditOperatorName = " - ";
  1501. else if (entity.AuditGMOperate == 4)
  1502. auditOperatorName = "自动审核";
  1503. else
  1504. {
  1505. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1506. if (_adUser != null)
  1507. {
  1508. auditOperatorName = _adUser.CnName;
  1509. }
  1510. }
  1511. _detail.AuditOperatorName = auditOperatorName;
  1512. /*
  1513. * 超预算比例
  1514. */
  1515. string overBudgetStr = "";
  1516. if (entity.ExceedBudget == -1)
  1517. overBudgetStr = sdPriceName.Name + "尚无预算";
  1518. else if (entity.ExceedBudget == 0)
  1519. overBudgetStr = "未超预算";
  1520. else
  1521. overBudgetStr = entity.ExceedBudget.ToString("P");
  1522. _detail.OverBudget = overBudgetStr;
  1523. /*
  1524. * 费用总计
  1525. */
  1526. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1527. {
  1528. CurrencyId = entity.PaymentCurrency,
  1529. CurrencyName = PaymentCurrency_WaitPay,
  1530. AmountPayable = entity.PayMoney,
  1531. ThisPayment = CurrPayStr,
  1532. BalancePayment = BalanceStr,
  1533. AuditedFunds = CurrPayStr
  1534. });
  1535. _detail.IsAuditGM = entity.IsAuditGM;
  1536. detailList.Add(_detail);
  1537. }
  1538. #endregion
  1539. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1540. /*
  1541. * 下方描述处理
  1542. */
  1543. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1544. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1545. if (ccpCurrencyPrice != null)
  1546. {
  1547. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1548. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1549. }
  1550. else
  1551. {
  1552. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1553. }
  1554. string amountPayableStr = string.Format(@"应付款总金额: ");
  1555. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1556. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1557. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1558. foreach (var item in nonDuplicat)
  1559. {
  1560. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1561. if (strs.Count > 0)
  1562. {
  1563. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1564. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1565. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1566. //单独处理此次付款金额
  1567. if (item.CurrencyId == 836) //人民币
  1568. {
  1569. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1570. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1571. }
  1572. else
  1573. {
  1574. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1575. }
  1576. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1577. //单独处理已审核费用
  1578. if (item.CurrencyId == 836) //人民币
  1579. {
  1580. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1581. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1582. }
  1583. else
  1584. {
  1585. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1586. }
  1587. }
  1588. }
  1589. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1590. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1591. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1592. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1593. var _view1 = new
  1594. {
  1595. PageFuncAuth = pageFunAuthView,
  1596. Data = _view
  1597. };
  1598. return Ok(JsonView(_view1));
  1599. }
  1600. catch (Exception ex)
  1601. {
  1602. return Ok(JsonView(false, ex.Message));
  1603. }
  1604. }
  1605. /// <summary>
  1606. /// 费用审核
  1607. /// 修改团组费用审核状态
  1608. /// </summary>
  1609. /// <param name="_dto">参数Json字符串</param>
  1610. /// <returns></returns>
  1611. [HttpPost]
  1612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1613. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1614. {
  1615. #region 参数验证
  1616. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1617. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1618. #endregion
  1619. #region 页面操作权限验证
  1620. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1621. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1622. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1623. #endregion
  1624. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1625. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1626. DateTime dtNow = DateTime.Now;
  1627. _groupRepository.BeginTran();
  1628. int rst = 0;
  1629. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1630. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1631. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1632. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1633. List<dynamic> msgDatas = new List<dynamic>();
  1634. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1635. foreach (var item in idList)
  1636. {
  1637. int CreditId = int.Parse(item);
  1638. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1639. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1640. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1641. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1642. .Where(s => s.Id == CreditId)
  1643. .ExecuteCommandAsync();
  1644. if (result < 1)
  1645. {
  1646. rst = -1;
  1647. _groupRepository.RollbackTran();
  1648. return Ok(JsonView(false, "操作失败并回滚!"));
  1649. }
  1650. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1651. if (creditData != null)
  1652. {
  1653. #region 应用通知配置
  1654. try
  1655. {
  1656. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1657. }
  1658. catch (Exception ex)
  1659. {
  1660. }
  1661. #endregion
  1662. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1663. string groupNameStr = string.Empty;
  1664. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1665. if (groupData != null) groupNameStr = groupData.TeamName;
  1666. string creditTypeStr = string.Empty;
  1667. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1668. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1669. string creditCurrency = string.Empty;
  1670. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1671. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1672. if (creditCurrency.Equals("CNY"))
  1673. {
  1674. creditData.DayRate = 1.0000M;
  1675. }
  1676. if (creditData.PayPercentage == 0.00M)
  1677. {
  1678. creditData.PayPercentage = 100M;
  1679. }
  1680. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1681. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1682. string msgContent = "";
  1683. if (creditCurrency.Equals("CNY"))
  1684. {
  1685. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1686. }
  1687. else
  1688. {
  1689. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1690. }
  1691. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1692. }
  1693. }
  1694. if (rst == 0)
  1695. {
  1696. _groupRepository.CommitTran();
  1697. foreach (var item in msgDatas)
  1698. {
  1699. //发送消息
  1700. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1701. }
  1702. #region 应用推送
  1703. try
  1704. {
  1705. foreach (var ccpId in dic_ccp_user.Keys)
  1706. {
  1707. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1708. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1709. }
  1710. }
  1711. catch (Exception)
  1712. {
  1713. }
  1714. #endregion
  1715. return Ok(JsonView(true, "操作成功!"));
  1716. }
  1717. return Ok(JsonView(false, "操作失败!"));
  1718. }
  1719. #endregion
  1720. #region 机票费用录入
  1721. /// <summary>
  1722. /// 机票录入当前登录人可操作团组
  1723. /// </summary>
  1724. /// <param name="dto"></param>
  1725. /// <returns></returns>
  1726. [HttpPost]
  1727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1728. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1729. {
  1730. try
  1731. {
  1732. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1733. if (groupData.Code != 0)
  1734. {
  1735. return Ok(JsonView(false, groupData.Msg));
  1736. }
  1737. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1738. }
  1739. catch (Exception ex)
  1740. {
  1741. return Ok(JsonView(false, "程序错误!"));
  1742. throw;
  1743. }
  1744. }
  1745. /// <summary>
  1746. /// 机票费用录入列表
  1747. /// </summary>
  1748. /// <param name="dto"></param>
  1749. /// <returns></returns>
  1750. [HttpPost]
  1751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1752. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1753. {
  1754. try
  1755. {
  1756. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1757. if (groupData.Code != 0)
  1758. {
  1759. return Ok(JsonView(false, groupData.Msg));
  1760. }
  1761. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1762. }
  1763. catch (Exception ex)
  1764. {
  1765. return Ok(JsonView(false, ex.Message));
  1766. throw;
  1767. }
  1768. }
  1769. /// <summary>
  1770. /// 根据id查询费用录入信息
  1771. /// </summary>
  1772. /// <param name="dto"></param>
  1773. /// <returns></returns>
  1774. [HttpPost]
  1775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1776. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1777. {
  1778. try
  1779. {
  1780. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1781. if (groupData.Code != 0)
  1782. {
  1783. return Ok(JsonView(false, groupData.Msg));
  1784. }
  1785. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1786. }
  1787. catch (Exception ex)
  1788. {
  1789. return Ok(JsonView(false, "程序错误!"));
  1790. throw;
  1791. }
  1792. }
  1793. /// <summary>
  1794. /// 机票费用录入操作(Status:1.新增,2.修改)
  1795. /// </summary>
  1796. /// <param name="dto"></param>
  1797. /// <returns></returns>
  1798. [HttpPost]
  1799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1800. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1801. {
  1802. try
  1803. {
  1804. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1805. if (groupData.Code != 0)
  1806. {
  1807. return Ok(JsonView(false, groupData.Msg));
  1808. }
  1809. #region 应用推送
  1810. try
  1811. {
  1812. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1813. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1814. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1815. }
  1816. catch (Exception ex)
  1817. {
  1818. }
  1819. #endregion
  1820. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1821. }
  1822. catch (Exception ex)
  1823. {
  1824. return Ok(JsonView(false, "程序错误!"));
  1825. throw;
  1826. }
  1827. }
  1828. /// <summary>
  1829. /// 根据舱位类型查询接团客户名单信息
  1830. /// </summary>
  1831. /// <param name="dto"></param>
  1832. /// <returns></returns>
  1833. [HttpPost]
  1834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1835. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1836. {
  1837. try
  1838. {
  1839. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1840. if (crm_Groups.Count != 0)
  1841. {
  1842. List<dynamic> Customer = new List<dynamic>();
  1843. foreach (var item in crm_Groups)
  1844. {
  1845. var data = new
  1846. {
  1847. Id = item.Id,
  1848. Pinyin = item.Pinyin,
  1849. Name = item.LastName + item.FirstName
  1850. };
  1851. Customer.Add(data);
  1852. }
  1853. return Ok(JsonView(true, "查询成功!", Customer));
  1854. }
  1855. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1856. }
  1857. catch (Exception ex)
  1858. {
  1859. return Ok(JsonView(false, "程序错误!"));
  1860. throw;
  1861. }
  1862. }
  1863. /// <summary>
  1864. /// 根据团号获取客户信息
  1865. /// </summary>
  1866. /// <param name="dto"></param>
  1867. /// <returns></returns>
  1868. [HttpPost]
  1869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1870. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1871. {
  1872. var jw = JsonView(false);
  1873. if (dto.DIID < 1)
  1874. {
  1875. jw.Msg += "请输入正确的diid";
  1876. return Ok(jw);
  1877. }
  1878. var arr = getSimplClientList(dto.DIID);
  1879. jw = JsonView(true, "获取成功!", arr);
  1880. return Ok(jw);
  1881. }
  1882. private List<SimplClientInfo> getSimplClientList(int diId)
  1883. {
  1884. 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);
  1885. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1886. return arr;
  1887. }
  1888. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1889. {
  1890. string result = origin;
  1891. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1892. {
  1893. string[] temparr = origin.Split(',');
  1894. string fistrStr = temparr[0];
  1895. int count = temparr.Count();
  1896. int tempId;
  1897. bool success = int.TryParse(fistrStr, out tempId);
  1898. if (success)
  1899. {
  1900. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1901. if (tempInfo != null)
  1902. {
  1903. if (count > 1)
  1904. {
  1905. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1906. }
  1907. else
  1908. {
  1909. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1910. }
  1911. }
  1912. }
  1913. }
  1914. return result;
  1915. }
  1916. /// <summary>
  1917. /// 机票费用录入,删除
  1918. /// </summary>
  1919. /// <param name="dto"></param>
  1920. /// <returns></returns>
  1921. [HttpPost]
  1922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1923. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1924. {
  1925. try
  1926. {
  1927. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1928. if (res)
  1929. {
  1930. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1931. {
  1932. IsDel = 1,
  1933. DeleteUserId = dto.DeleteUserId,
  1934. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1935. }).ExecuteCommandAsync();
  1936. return Ok(JsonView(true, "删除成功!"));
  1937. }
  1938. return Ok(JsonView(false, "删除失败!"));
  1939. }
  1940. catch (Exception ex)
  1941. {
  1942. return Ok(JsonView(false, "程序错误!"));
  1943. throw;
  1944. }
  1945. }
  1946. /// <summary>
  1947. /// 导出机票录入报表
  1948. /// </summary>
  1949. /// <param name="dto"></param>
  1950. /// <returns></returns>
  1951. [HttpPost]
  1952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1953. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1954. {
  1955. try
  1956. {
  1957. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1958. if (groupData.Code != 0)
  1959. {
  1960. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  1961. }
  1962. else
  1963. {
  1964. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1965. if (AirTicketReservations.Count != 0)
  1966. {
  1967. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1968. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1969. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1970. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1971. WorkbookDesigner designer = new WorkbookDesigner();
  1972. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1973. decimal countCost = 0;
  1974. foreach (var item in AirTicketReservations)
  1975. {
  1976. #region 处理客人姓名
  1977. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  1978. item.ClientName = clientNames;
  1979. #endregion
  1980. if (item.BankType == "其他")
  1981. {
  1982. item.BankNo = "--";
  1983. }
  1984. else
  1985. {
  1986. if (!string.IsNullOrEmpty(item.BankType))
  1987. {
  1988. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  1989. }
  1990. }
  1991. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1992. item.Price = System.Decimal.Round(item.Price, 2);
  1993. countCost += Convert.ToDecimal(item.Price);
  1994. }
  1995. designer.SetDataSource("Export", AirTicketReservations);
  1996. designer.SetDataSource("ExportDiCode", diCode);
  1997. designer.SetDataSource("ExportDiName", diName);
  1998. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1999. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2000. designer.Process();
  2001. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2002. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2003. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2004. return Ok(JsonView(true, "成功", url = rst));
  2005. }
  2006. else
  2007. {
  2008. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2009. }
  2010. }
  2011. }
  2012. catch (Exception ex)
  2013. {
  2014. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2015. throw;
  2016. }
  2017. }
  2018. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2019. /// <summary>
  2020. /// 行程单导出
  2021. /// </summary>
  2022. /// <param name="dto"></param>
  2023. /// <returns></returns>
  2024. [HttpPost]
  2025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2026. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2027. {
  2028. try
  2029. {
  2030. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2031. if (groupData.Code != 0)
  2032. {
  2033. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2034. }
  2035. else
  2036. {
  2037. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2038. if (dto.Language == "CN")
  2039. {
  2040. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2041. DocumentBuilder builder = new DocumentBuilder(doc);
  2042. int tableIndex = 0;//表格索引
  2043. //得到文档中的第一个表格
  2044. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2045. foreach (var item in _AirTicketReservations)
  2046. {
  2047. #region 处理固定数据
  2048. string[] FlightsCode = item.FlightsCode.Split('/');
  2049. if (FlightsCode.Length != 0)
  2050. {
  2051. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2052. if (_AirCompany != null)
  2053. {
  2054. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2055. }
  2056. else
  2057. {
  2058. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2059. }
  2060. }
  2061. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2062. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2063. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2064. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2065. string name = "";
  2066. foreach (string clientName in nameArray)
  2067. {
  2068. if (!name.Contains(clientName))
  2069. {
  2070. name += clientName + ",";
  2071. }
  2072. }
  2073. if (!string.IsNullOrWhiteSpace(name))
  2074. {
  2075. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2076. }
  2077. else
  2078. {
  2079. table.Range.Bookmarks["ClientName"].Text = "--";
  2080. }
  2081. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2082. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2083. table.Range.Bookmarks["JointTicket"].Text = "--";
  2084. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2085. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2086. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2087. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2088. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2089. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2090. #endregion
  2091. #region 循环数据处理
  2092. List<AirInfo> airs = new List<AirInfo>();
  2093. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2094. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2095. for (int i = 0; i < FlightsCode.Length; i++)
  2096. {
  2097. AirInfo air = new AirInfo();
  2098. string[] tempstr = DayArray[i]
  2099. .Replace("\r\n", string.Empty)
  2100. .Replace("\\r\\n", string.Empty)
  2101. .TrimStart().TrimEnd()
  2102. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2103. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2104. string starCity = "";
  2105. if (star_Three != null)
  2106. {
  2107. starCity = star_Three.AirPort;
  2108. }
  2109. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2110. string EndCity = "";
  2111. if (End_Three != null)
  2112. {
  2113. EndCity = End_Three.AirPort;
  2114. }
  2115. air.Destination = starCity + "/" + EndCity;
  2116. air.Flight = FlightsCode[i];
  2117. air.SeatingClass = item.CTypeName;
  2118. string dateTime = tempstr[2];
  2119. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2120. air.FlightDate = DateTemp;
  2121. air.DepartureTime = tempstr[5];
  2122. air.LandingTime = tempstr[6];
  2123. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2124. air.TicketStatus = "--";
  2125. air.Luggage = "--";
  2126. air.DepartureTerminal = "--";
  2127. air.LandingTerminal = "--";
  2128. airs.Add(air);
  2129. }
  2130. int row = 13;
  2131. for (int i = 0; i < airs.Count; i++)
  2132. {
  2133. if (airs.Count > 2)
  2134. {
  2135. for (int j = 0; j < airs.Count - 2; j++)
  2136. {
  2137. var CopyRow = table.Rows[12].Clone(true);
  2138. table.Rows.Add(CopyRow);
  2139. }
  2140. }
  2141. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2142. int index = 0;
  2143. foreach (PropertyInfo property in properties)
  2144. {
  2145. string value = property.GetValue(airs[i]).ToString();
  2146. Cell ishcel0 = table.Rows[row].Cells[index];
  2147. Paragraph p = new Paragraph(doc);
  2148. string s = value;
  2149. p.AppendChild(new Run(doc, s));
  2150. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2151. ishcel0.AppendChild(p);
  2152. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2153. index++;
  2154. }
  2155. row++;
  2156. }
  2157. #endregion
  2158. Paragraph lastParagraph = new Paragraph(doc);
  2159. //第一个表格末尾加段落
  2160. table.ParentNode.InsertAfter(lastParagraph, table);
  2161. //复制第一个表格
  2162. Table cloneTable = (Table)table.Clone(true);
  2163. //在文档末尾段落后面加入复制的表格
  2164. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2165. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2166. {
  2167. int rownewsIndex = 13;
  2168. for (int i = 0; i < 2; i++)
  2169. {
  2170. var CopyRow = table.Rows[12].Clone(true);
  2171. table.Rows.RemoveAt(13);
  2172. table.Rows.Add(CopyRow);
  2173. rownewsIndex++;
  2174. }
  2175. }
  2176. else
  2177. {
  2178. table.Rows.RemoveAt(12);
  2179. }
  2180. cloneTable.Rows.RemoveAt(12);
  2181. }
  2182. if (_AirTicketReservations.Count != 0)
  2183. {
  2184. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2185. if (FlightsCode.Length != 0)
  2186. {
  2187. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2188. if (_AirCompany != null)
  2189. {
  2190. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2191. }
  2192. else
  2193. {
  2194. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2195. }
  2196. }
  2197. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2198. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2199. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2200. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2201. string name = "";
  2202. foreach (string clientName in nameArray)
  2203. {
  2204. if (!name.Contains(clientName))
  2205. {
  2206. name += clientName + ",";
  2207. }
  2208. }
  2209. if (!string.IsNullOrWhiteSpace(name))
  2210. {
  2211. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2212. }
  2213. else
  2214. {
  2215. table.Range.Bookmarks["ClientName"].Text = "--";
  2216. }
  2217. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2218. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2219. table.Range.Bookmarks["JointTicket"].Text = "--";
  2220. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2221. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2222. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2223. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2224. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2225. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2226. }
  2227. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2228. //保存合并后的文档
  2229. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2230. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2231. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2232. return Ok(JsonView(true, "成功!", rst));
  2233. }
  2234. else
  2235. {
  2236. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2237. DocumentBuilder builder = new DocumentBuilder(doc);
  2238. int tableIndex = 0;//表格索引
  2239. //得到文档中的第一个表格
  2240. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2241. List<string> texts = new List<string>();
  2242. foreach (var item in _AirTicketReservations)
  2243. {
  2244. string[] FlightsCode = item.FlightsCode.Split('/');
  2245. if (FlightsCode.Length != 0)
  2246. {
  2247. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2248. if (_AirCompany != null)
  2249. {
  2250. if (!transDic.ContainsKey(_AirCompany.CnName))
  2251. {
  2252. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2253. }
  2254. }
  2255. else
  2256. {
  2257. if (!transDic.ContainsKey("--"))
  2258. {
  2259. transDic.Add("--", "--");
  2260. }
  2261. }
  2262. }
  2263. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2264. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2265. string name = "";
  2266. foreach (string clientName in nameArray)
  2267. {
  2268. name += clientName + ",";
  2269. }
  2270. if (!texts.Contains(name))
  2271. {
  2272. texts.Add(name);
  2273. }
  2274. List<AirInfo> airs = new List<AirInfo>();
  2275. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2276. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2277. for (int i = 0; i < FlightsCode.Length; i++)
  2278. {
  2279. AirInfo air = new AirInfo();
  2280. string[] tempstr = DayArray[i]
  2281. .Replace("\r\n", string.Empty)
  2282. .Replace("\\r\\n", string.Empty)
  2283. .TrimStart().TrimEnd()
  2284. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2285. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2286. if (star_Three != null)
  2287. {
  2288. if (!transDic.ContainsKey(star_Three.AirPort))
  2289. {
  2290. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2291. }
  2292. }
  2293. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2294. if (End_Three != null)
  2295. {
  2296. if (!transDic.ContainsKey(End_Three.AirPort))
  2297. {
  2298. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2299. }
  2300. }
  2301. if (!texts.Contains(item.CTypeName))
  2302. {
  2303. texts.Add(item.CTypeName);
  2304. }
  2305. }
  2306. }
  2307. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2308. if (transData.Count > 0)
  2309. {
  2310. foreach (TranslateResult item in transData)
  2311. {
  2312. if (!transDic.ContainsKey(item.Query))
  2313. {
  2314. transDic.Add(item.Query, item.Translation);
  2315. }
  2316. }
  2317. }
  2318. foreach (var item in _AirTicketReservations)
  2319. {
  2320. #region 处理固定数据
  2321. string[] FlightsCode = item.FlightsCode.Split('/');
  2322. if (FlightsCode.Length != 0)
  2323. {
  2324. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2325. if (_AirCompany != null)
  2326. {
  2327. string str = "--";
  2328. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2329. if (!string.IsNullOrEmpty(translateResult))
  2330. {
  2331. str = translateResult;
  2332. str = _airTicketResRep.Processing(str);
  2333. }
  2334. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2335. }
  2336. else
  2337. {
  2338. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2339. }
  2340. }
  2341. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2342. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2343. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2344. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2345. string names = "";
  2346. foreach (string clientName in nameArray)
  2347. {
  2348. names += clientName + ",";
  2349. }
  2350. if (!string.IsNullOrWhiteSpace(names))
  2351. {
  2352. string str = "--";
  2353. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2354. if (!string.IsNullOrEmpty(translateResult))
  2355. {
  2356. str = translateResult;
  2357. str = _airTicketResRep.Processing(str);
  2358. }
  2359. table.Range.Bookmarks["ClientName"].Text = str;
  2360. }
  2361. else
  2362. {
  2363. table.Range.Bookmarks["ClientName"].Text = "--";
  2364. }
  2365. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2366. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2367. table.Range.Bookmarks["JointTicket"].Text = "--";
  2368. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2369. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2370. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2371. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2372. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2373. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2374. #endregion
  2375. #region 循环数据处理
  2376. List<AirInfo> airs = new List<AirInfo>();
  2377. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2378. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2379. for (int i = 0; i < FlightsCode.Length; i++)
  2380. {
  2381. AirInfo air = new AirInfo();
  2382. string[] tempstr = DayArray[i]
  2383. .Replace("\r\n", string.Empty)
  2384. .Replace("\\r\\n", string.Empty)
  2385. .TrimStart().TrimEnd()
  2386. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2387. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2388. string starCity = "";
  2389. if (star_Three != null)
  2390. {
  2391. string str2 = "--";
  2392. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2393. if (!string.IsNullOrEmpty(translateResult2))
  2394. {
  2395. str2 = translateResult2;
  2396. str2 = _airTicketResRep.Processing(str2);
  2397. }
  2398. starCity = str2;
  2399. }
  2400. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2401. string EndCity = "";
  2402. if (End_Three != null)
  2403. {
  2404. string str1 = "--";
  2405. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2406. if (!string.IsNullOrEmpty(translateResult1))
  2407. {
  2408. str1 = translateResult1;
  2409. str1 = _airTicketResRep.Processing(str1);
  2410. }
  2411. EndCity = str1;
  2412. }
  2413. air.Destination = starCity + "/" + EndCity;
  2414. air.Flight = FlightsCode[i];
  2415. string str = "--";
  2416. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2417. if (!string.IsNullOrEmpty(translateResult))
  2418. {
  2419. str = translateResult;
  2420. str = _airTicketResRep.Processing(str);
  2421. }
  2422. air.SeatingClass = str;
  2423. string dateTime = tempstr[2];
  2424. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2425. air.FlightDate = DateTemp;
  2426. air.DepartureTime = tempstr[5];
  2427. air.LandingTime = tempstr[6];
  2428. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2429. air.TicketStatus = "--";
  2430. air.Luggage = "--";
  2431. air.DepartureTerminal = "--";
  2432. air.LandingTerminal = "--";
  2433. airs.Add(air);
  2434. }
  2435. int row = 13;
  2436. for (int i = 0; i < airs.Count; i++)
  2437. {
  2438. if (airs.Count > 2)
  2439. {
  2440. for (int j = 0; j < airs.Count - 2; j++)
  2441. {
  2442. var CopyRow = table.Rows[12].Clone(true);
  2443. table.Rows.Add(CopyRow);
  2444. }
  2445. }
  2446. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2447. int index = 0;
  2448. foreach (PropertyInfo property in properties)
  2449. {
  2450. string value = property.GetValue(airs[i]).ToString();
  2451. Cell ishcel0 = table.Rows[row].Cells[index];
  2452. Paragraph p = new Paragraph(doc);
  2453. string s = value;
  2454. p.AppendChild(new Run(doc, s));
  2455. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2456. ishcel0.AppendChild(p);
  2457. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2458. //ishcel0.CellFormat.VerticalAlignment=
  2459. index++;
  2460. }
  2461. row++;
  2462. }
  2463. #endregion
  2464. Paragraph lastParagraph = new Paragraph(doc);
  2465. //第一个表格末尾加段落
  2466. table.ParentNode.InsertAfter(lastParagraph, table);
  2467. //复制第一个表格
  2468. Table cloneTable = (Table)table.Clone(true);
  2469. //在文档末尾段落后面加入复制的表格
  2470. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2471. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2472. {
  2473. int rownewsIndex = 13;
  2474. for (int i = 0; i < 2; i++)
  2475. {
  2476. var CopyRow = table.Rows[12].Clone(true);
  2477. table.Rows.RemoveAt(13);
  2478. table.Rows.Add(CopyRow);
  2479. rownewsIndex++;
  2480. }
  2481. }
  2482. else
  2483. {
  2484. table.Rows.RemoveAt(12);
  2485. }
  2486. cloneTable.Rows.RemoveAt(12);
  2487. }
  2488. if (_AirTicketReservations.Count != 0)
  2489. {
  2490. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2491. if (FlightsCode.Length != 0)
  2492. {
  2493. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2494. if (_AirCompany != null)
  2495. {
  2496. string str = "--";
  2497. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2498. if (!string.IsNullOrEmpty(translateResult))
  2499. {
  2500. str = translateResult;
  2501. str = _airTicketResRep.Processing(str);
  2502. }
  2503. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2504. }
  2505. else
  2506. {
  2507. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2508. }
  2509. }
  2510. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2511. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2512. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2513. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2514. string names = "";
  2515. foreach (string clientName in nameArray)
  2516. {
  2517. names += clientName + ",";
  2518. }
  2519. if (!string.IsNullOrWhiteSpace(names))
  2520. {
  2521. string str = "--";
  2522. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2523. if (!string.IsNullOrEmpty(translateResult))
  2524. {
  2525. str = translateResult;
  2526. str = _airTicketResRep.Processing(str);
  2527. }
  2528. table.Range.Bookmarks["ClientName"].Text = str;
  2529. }
  2530. else
  2531. {
  2532. table.Range.Bookmarks["ClientName"].Text = "--";
  2533. }
  2534. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2535. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2536. table.Range.Bookmarks["JointTicket"].Text = "--";
  2537. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2538. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2539. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2540. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2541. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2542. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2543. }
  2544. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2545. //保存合并后的文档
  2546. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2547. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2548. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2549. return Ok(JsonView(true, "成功!", rst));
  2550. }
  2551. }
  2552. }
  2553. catch (Exception ex)
  2554. {
  2555. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2556. throw;
  2557. }
  2558. }
  2559. #endregion
  2560. #region 团组增减款项 --> 其他款项
  2561. /// <summary>
  2562. /// 团组增减款项下拉框绑定
  2563. /// </summary>
  2564. /// <param name="dto"></param>
  2565. /// <returns></returns>
  2566. [HttpPost]
  2567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2568. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2569. {
  2570. #region 参数验证
  2571. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2572. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2573. #endregion
  2574. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2575. }
  2576. /// <summary>
  2577. /// 根据团组Id查询团组增减款项
  2578. /// </summary>
  2579. /// <param name="dto"></param>
  2580. /// <returns></returns>
  2581. [HttpPost]
  2582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2583. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2584. {
  2585. #region 参数验证
  2586. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2587. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2588. #endregion
  2589. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2590. }
  2591. /// <summary>
  2592. /// 团组增减款项操作(Status:1.新增,2.修改)
  2593. /// </summary>
  2594. /// <param name="dto"></param>
  2595. /// <returns></returns>
  2596. [HttpPost]
  2597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2598. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2599. {
  2600. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2601. if (groupData.Code != 200)
  2602. {
  2603. return Ok(JsonView(false, groupData.Msg));
  2604. }
  2605. #region 应用推送
  2606. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2607. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2608. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2609. #endregion
  2610. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2611. }
  2612. /// <summary>
  2613. /// 团组增减款项操作 删除
  2614. /// </summary>
  2615. /// <param name="dto"></param>
  2616. /// <returns></returns>
  2617. [HttpPost]
  2618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2619. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2620. {
  2621. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2622. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2623. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2624. if (res.Code == 0)
  2625. {
  2626. return Ok(JsonView(true, "删除成功!"));
  2627. }
  2628. return Ok(JsonView(false, "删除失败!"));
  2629. }
  2630. /// <summary>
  2631. /// 根据团组增减款项Id查询
  2632. /// </summary>
  2633. /// <param name="dto"></param>
  2634. /// <returns></returns>
  2635. [HttpPost]
  2636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2637. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2638. {
  2639. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2640. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2641. }
  2642. /// <summary>
  2643. /// 查询供应商名称
  2644. /// </summary>
  2645. /// <param name="dto"></param>
  2646. /// <returns></returns>
  2647. [HttpPost]
  2648. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2649. {
  2650. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2651. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2652. ?? new List<Grp_DecreasePayments>();
  2653. dbResult = dbResult.Distinct(new
  2654. ProductComparer ()).ToList();
  2655. var jw = JsonView(true, "success", dbResult.OrderByDescending(x=>x. Id ).Select(x => new
  2656. {
  2657. x.Id,
  2658. x.SupplierAddress,
  2659. x.SupplierArea,
  2660. x.SupplierContact,
  2661. x.SupplierContactNumber,
  2662. x.SupplierEmail,
  2663. x.SupplierName,
  2664. x.SupplierSocialAccount,
  2665. x.SupplierTypeId,
  2666. }).ToList());
  2667. return Ok(jw);
  2668. }
  2669. #endregion
  2670. #region 文件上传、删除
  2671. /// <summary>
  2672. /// region 文件上传 可以带参数
  2673. /// </summary>
  2674. /// <param name="file"></param>
  2675. /// <returns></returns>
  2676. [HttpPost]
  2677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2678. public async Task<IActionResult> UploadProject(IFormFile file)
  2679. {
  2680. try
  2681. {
  2682. var TypeName = Request.Headers["TypeName"].ToString();
  2683. if (file != null)
  2684. {
  2685. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2686. //文件名称
  2687. string projectFileName = file.FileName;
  2688. //上传的文件的路径
  2689. string filePath = "";
  2690. if (TypeName == "A")//A代表团组增减款项
  2691. {
  2692. if (!Directory.Exists(fileDir))
  2693. {
  2694. Directory.CreateDirectory(fileDir);
  2695. }
  2696. //上传的文件的路径
  2697. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2698. }
  2699. else if (TypeName == "B")//B代表商邀相关文件
  2700. {
  2701. if (!Directory.Exists(fileDir))
  2702. {
  2703. Directory.CreateDirectory(fileDir);
  2704. }
  2705. //上传的文件的路径
  2706. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2707. }
  2708. using (FileStream fs = System.IO.File.Create(filePath))
  2709. {
  2710. file.CopyTo(fs);
  2711. fs.Flush();
  2712. }
  2713. return Ok(JsonView(true, "上传成功!", projectFileName));
  2714. }
  2715. else
  2716. {
  2717. return Ok(JsonView(false, "上传失败!"));
  2718. }
  2719. }
  2720. catch (Exception ex)
  2721. {
  2722. return Ok(JsonView(false, "程序错误!"));
  2723. throw;
  2724. }
  2725. }
  2726. /// <summary>
  2727. /// 删除指定文件
  2728. /// </summary>
  2729. /// <param name="dto"></param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public async Task<IActionResult> DelFile(DelFileDto dto)
  2734. {
  2735. try
  2736. {
  2737. var TypeName = Request.Headers["TypeName"].ToString();
  2738. string filePath = "";
  2739. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2740. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2741. int id = 0;
  2742. if (TypeName == "A")
  2743. {
  2744. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2745. // 删除该文件
  2746. System.IO.File.Delete(filePath);
  2747. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2748. }
  2749. else if (TypeName == "B")
  2750. {
  2751. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2752. // 删除该文件
  2753. System.IO.File.Delete(filePath);
  2754. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2755. }
  2756. if (id != 0)
  2757. {
  2758. return Ok(JsonView(true, "成功!"));
  2759. }
  2760. else
  2761. {
  2762. return Ok(JsonView(false, "失败!"));
  2763. }
  2764. }
  2765. catch (Exception ex)
  2766. {
  2767. return Ok(JsonView(false, "程序错误!"));
  2768. throw;
  2769. }
  2770. }
  2771. #endregion
  2772. #region 商邀费用录入
  2773. /// <summary>
  2774. /// 根据团组Id查询商邀费用列表
  2775. /// </summary>
  2776. /// <param name="dto"></param>
  2777. /// <returns></returns>
  2778. [HttpPost]
  2779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2780. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2781. {
  2782. try
  2783. {
  2784. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2785. if (groupData.Code != 0)
  2786. {
  2787. return Ok(JsonView(false, groupData.Msg));
  2788. }
  2789. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2790. }
  2791. catch (Exception ex)
  2792. {
  2793. return Ok(JsonView(false, "程序错误!"));
  2794. throw;
  2795. }
  2796. }
  2797. //
  2798. /// <summary>
  2799. /// 商邀费用 Info Page 基础数据源
  2800. /// </summary>
  2801. /// <param name="dto"></param>
  2802. /// <returns></returns>
  2803. [HttpPost]
  2804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2805. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2806. {
  2807. try
  2808. {
  2809. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2810. if (groupData.Code != 0)
  2811. {
  2812. return Ok(JsonView(false, groupData.Msg));
  2813. }
  2814. return Ok(JsonView(true, "操作成功", groupData.Data));
  2815. }
  2816. catch (Exception ex)
  2817. {
  2818. return Ok(JsonView(false, ex.Message));
  2819. throw;
  2820. }
  2821. }
  2822. /// <summary>
  2823. /// 根据商邀费用ID查询C表和商邀费用数据
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2829. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2830. {
  2831. try
  2832. {
  2833. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2834. if (groupData.Code != 0)
  2835. {
  2836. return Ok(JsonView(false, groupData.Msg));
  2837. }
  2838. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2839. }
  2840. catch (Exception ex)
  2841. {
  2842. return Ok(JsonView(false, ex.Message));
  2843. throw;
  2844. }
  2845. }
  2846. /// <summary>
  2847. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2848. /// </summary>
  2849. /// <param name="dto"></param>
  2850. /// <returns></returns>
  2851. [HttpPost]
  2852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2853. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2854. {
  2855. try
  2856. {
  2857. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2858. if (groupData.Code != 0)
  2859. {
  2860. return Ok(JsonView(false, groupData.Msg));
  2861. }
  2862. #region 应用推送
  2863. try
  2864. {
  2865. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2866. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2867. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2868. }
  2869. catch (Exception ex)
  2870. {
  2871. }
  2872. #endregion
  2873. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2874. }
  2875. catch (Exception ex)
  2876. {
  2877. return Ok(JsonView(false, "程序错误!"));
  2878. throw;
  2879. }
  2880. }
  2881. /// <summary>
  2882. /// 商邀删除
  2883. /// </summary>
  2884. /// <param name="dto"></param>
  2885. /// <returns></returns>
  2886. [HttpPost]
  2887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2888. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2889. {
  2890. try
  2891. {
  2892. _sqlSugar.BeginTran();
  2893. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2894. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2895. {
  2896. IsDel = 1,
  2897. DeleteUserId = dto.DeleteUserId,
  2898. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2899. })
  2900. .Where(it => it.Id == dto.Id)
  2901. .ExecuteCommand();
  2902. if (res1 > 0)
  2903. {
  2904. int _diId = 0;
  2905. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2906. if (_ioaInfo != null)
  2907. {
  2908. _diId = _ioaInfo.DiId;
  2909. }
  2910. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2911. .SetColumns(a => new Grp_CreditCardPayment()
  2912. {
  2913. IsDel = 1,
  2914. DeleteUserId = dto.DeleteUserId,
  2915. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2916. })
  2917. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2918. .ExecuteCommand();
  2919. if (res2 > 0)
  2920. {
  2921. _sqlSugar.CommitTran();
  2922. return Ok(JsonView(true, "删除成功!"));
  2923. }
  2924. }
  2925. _sqlSugar.RollbackTran();
  2926. return Ok(JsonView(false, "删除失败"));
  2927. }
  2928. catch (Exception ex)
  2929. {
  2930. _sqlSugar.RollbackTran();
  2931. return Ok(JsonView(false, ex.Message));
  2932. }
  2933. }
  2934. #endregion
  2935. #region 团组英文资料
  2936. /// <summary>
  2937. /// 查询团组英文所有资料
  2938. /// </summary>
  2939. /// <param name="dto"></param>
  2940. /// <returns></returns>
  2941. [HttpPost]
  2942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2943. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2944. {
  2945. try
  2946. {
  2947. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2948. if (groupData.Code != 0)
  2949. {
  2950. return Ok(JsonView(false, groupData.Msg));
  2951. }
  2952. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2953. }
  2954. catch (Exception ex)
  2955. {
  2956. return Ok(JsonView(false, "程序错误!"));
  2957. throw;
  2958. }
  2959. }
  2960. /// <summary>
  2961. /// 团组英文资料操作(Status:1.新增,2.修改)
  2962. /// </summary>
  2963. /// <param name="dto"></param>
  2964. /// <returns></returns>
  2965. [HttpPost]
  2966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2967. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2968. {
  2969. try
  2970. {
  2971. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2972. if (groupData.Code != 0)
  2973. {
  2974. return Ok(JsonView(false, groupData.Msg));
  2975. }
  2976. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2977. }
  2978. catch (Exception ex)
  2979. {
  2980. return Ok(JsonView(false, "程序错误!"));
  2981. throw;
  2982. }
  2983. }
  2984. /// <summary>
  2985. /// 团组英文资料Id查询数据
  2986. /// </summary>
  2987. /// <param name="dto"></param>
  2988. /// <returns></returns>
  2989. [HttpPost]
  2990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2991. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2992. {
  2993. try
  2994. {
  2995. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2996. if (_DelegationEnData != null)
  2997. {
  2998. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2999. }
  3000. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3001. }
  3002. catch (Exception ex)
  3003. {
  3004. return Ok(JsonView(false, "程序错误!"));
  3005. throw;
  3006. }
  3007. }
  3008. /// <summary>
  3009. /// 团组英文资料删除
  3010. /// </summary>
  3011. /// <param name="dto"></param>
  3012. /// <returns></returns>
  3013. [HttpPost]
  3014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3015. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3016. {
  3017. try
  3018. {
  3019. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3020. if (!res)
  3021. {
  3022. return Ok(JsonView(false, "删除失败"));
  3023. }
  3024. return Ok(JsonView(true, "删除成功!"));
  3025. }
  3026. catch (Exception ex)
  3027. {
  3028. return Ok(JsonView(false, "程序错误!"));
  3029. throw;
  3030. }
  3031. }
  3032. #endregion
  3033. #region 导出邀请函
  3034. /// <summary>
  3035. /// 导出邀请函页面初始化
  3036. /// </summary>
  3037. /// <param name="dto"></param>
  3038. /// <returns></returns>
  3039. [HttpPost]
  3040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3041. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3042. {
  3043. try
  3044. {
  3045. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3046. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3047. if (dto.DiId == 0)
  3048. {
  3049. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3050. }
  3051. else
  3052. {
  3053. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3054. }
  3055. return Ok(JsonView(true, "查询成功!", new
  3056. {
  3057. deleClient = crm_Deles,
  3058. delegations = grp_Delegations
  3059. }));
  3060. }
  3061. catch (Exception ex)
  3062. {
  3063. return Ok(JsonView(false, "程序错误!"));
  3064. throw;
  3065. }
  3066. }
  3067. /// <summary>
  3068. /// 导出邀请函
  3069. /// </summary>
  3070. /// <param name="dto"></param>
  3071. /// <returns></returns>
  3072. [HttpPost]
  3073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3074. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3075. {
  3076. #region 参数验证
  3077. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3078. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3079. #endregion
  3080. try
  3081. {
  3082. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3083. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3084. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3085. From Grp_TourClientList tcl
  3086. Left Join
  3087. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3088. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3089. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3090. From Crm_DeleClient dc
  3091. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3092. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3093. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3094. Where dc.IsDel = 0) temp
  3095. On temp.DcId =tcl.ClientId
  3096. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3097. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3098. List<string> texts = new List<string>();
  3099. if (datas.Count != 0)
  3100. {
  3101. foreach (TourClientListDetailsView item in datas)
  3102. {
  3103. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3104. {
  3105. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3106. }
  3107. else
  3108. {
  3109. string name = item.LastName + item.FirstName;
  3110. texts.Add(name);
  3111. }
  3112. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3113. {
  3114. if (!transDic.ContainsKey(item.Job))
  3115. {
  3116. texts.Add(item.Job);
  3117. }
  3118. }
  3119. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3120. {
  3121. texts.Add(item.CompanyFullName);
  3122. }
  3123. }
  3124. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3125. if (transData.Count > 0)
  3126. {
  3127. foreach (TranslateResult item in transData)
  3128. {
  3129. if (!transDic.ContainsKey(item.Query))
  3130. {
  3131. transDic.Add(item.Query, item.Translation);
  3132. }
  3133. }
  3134. }
  3135. List<GuestList> list = new List<GuestList>();
  3136. foreach (TourClientListDetailsView dele in datas)
  3137. {
  3138. GuestList guestList = new GuestList();
  3139. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3140. {
  3141. guestList.Name = dele.Pinyin;
  3142. }
  3143. else
  3144. {
  3145. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3146. guestList.Name = Name;
  3147. }
  3148. if (dele.Sex == 0)
  3149. {
  3150. guestList.Sex = "Male";
  3151. }
  3152. else if (dele.Sex == 1)
  3153. {
  3154. guestList.Sex = "Female";
  3155. }
  3156. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3157. if (!string.IsNullOrEmpty(dele.Job))
  3158. {
  3159. guestList.Job = dele.Job;
  3160. }
  3161. list.Add(guestList);
  3162. }
  3163. //载入模板
  3164. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3165. DocumentBuilder builder = new DocumentBuilder(doc);
  3166. //获取word里所有表格
  3167. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3168. //获取所填表格的序数
  3169. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3170. var rowStart = tableOne.Rows[0]; //获取第1行
  3171. //循环赋值
  3172. for (int i = 0; i < list.Count; i++)
  3173. {
  3174. builder.MoveToCell(0, i + 1, 0, 0);
  3175. builder.Write(list[i].Name.ToString());
  3176. builder.MoveToCell(0, i + 1, 1, 0);
  3177. builder.Write(list[i].Sex.ToString());
  3178. builder.MoveToCell(0, i + 1, 2, 0);
  3179. builder.Write(list[i].DOB.ToString());
  3180. builder.MoveToCell(0, i + 1, 3, 0);
  3181. builder.Write(list[i].Job.ToString());
  3182. }
  3183. //删除多余行
  3184. while (tableOne.Rows.Count > list.Count + 1)
  3185. {
  3186. tableOne.Rows.RemoveAt(list.Count + 1);
  3187. }
  3188. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3189. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3190. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3191. doc.Save(filePath);
  3192. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3193. return Ok(JsonView(true, "操作成功!", Url));
  3194. }
  3195. else
  3196. {
  3197. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3198. }
  3199. }
  3200. catch (Exception ex)
  3201. {
  3202. return Ok(JsonView(false, ex.Message));
  3203. throw;
  3204. }
  3205. }
  3206. #endregion
  3207. #region 团组经理模块 出入境费用
  3208. ///// <summary>
  3209. ///// 团组模块 - 出入境费用
  3210. ///// </summary>
  3211. ///// <returns></returns>
  3212. //[HttpPost]
  3213. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3214. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3215. //{
  3216. // try
  3217. // {
  3218. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3219. // if (data.Code != 0)
  3220. // {
  3221. // return Ok(JsonView(false, data.Msg));
  3222. // }
  3223. // return Ok(JsonView(true, "查询成功!"));
  3224. // }
  3225. // catch (Exception ex)
  3226. // {
  3227. // return Ok(JsonView(false, ex.Message));
  3228. // throw;
  3229. // }
  3230. //}
  3231. /// <summary>
  3232. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3233. /// </summary>
  3234. /// <returns></returns>
  3235. [HttpPost]
  3236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3237. public async Task<IActionResult> SetDayAndCostAreaChange()
  3238. {
  3239. try
  3240. {
  3241. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3242. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3243. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3244. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3245. foreach (var item in unite) //处理交集数据
  3246. {
  3247. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3248. }
  3249. foreach (var item in merge) //处理差集数据
  3250. {
  3251. int nationalTravelFeeId = 0;
  3252. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3253. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3254. else
  3255. {
  3256. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3257. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3258. }
  3259. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3260. }
  3261. //只更新dayAndCost 的 nationalTravelFeeId;
  3262. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3263. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3264. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3265. }
  3266. catch (Exception ex)
  3267. {
  3268. return Ok(JsonView(false, ex.Message));
  3269. throw;
  3270. }
  3271. }
  3272. /// <summary>
  3273. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3274. /// </summary>
  3275. /// <returns></returns>
  3276. [HttpPost]
  3277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3278. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3279. {
  3280. try
  3281. {
  3282. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3283. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3284. //SetDataInfoView
  3285. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3286. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3287. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3288. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3289. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3290. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3291. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3292. //默认币种显示
  3293. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3294. {
  3295. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3296. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3297. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3298. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3299. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3300. };
  3301. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3302. if (_currencyRate.Count > 0)
  3303. {
  3304. foreach (var item in _currencyInfos)
  3305. {
  3306. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3307. if (rateInfo != null)
  3308. {
  3309. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3310. rate1 *= 1.03M;
  3311. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3312. }
  3313. }
  3314. }
  3315. return Ok(JsonView(true, "查询成功!", new
  3316. {
  3317. GroupNameData = groupNameData.Data,
  3318. CurrencyData = _CurrencyData,
  3319. WordTypeData = _WordTypeData,
  3320. ExcelTypeData = _ExcelTypeData,
  3321. CurrencyInit = _currencyInfos
  3322. }));
  3323. }
  3324. catch (Exception ex)
  3325. {
  3326. return Ok(JsonView(false, ex.Message));
  3327. throw;
  3328. }
  3329. }
  3330. /// <summary>
  3331. /// 团组模块 - 出入境费用
  3332. /// 实时汇率 tips
  3333. /// 签证费用 tips
  3334. /// </summary>
  3335. /// <returns></returns>
  3336. [HttpPost]
  3337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3338. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3339. {
  3340. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3341. //默认币种显示
  3342. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3343. {
  3344. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3345. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3346. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3347. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3348. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3349. };
  3350. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3351. List<dynamic> reteInfos = new List<dynamic>();
  3352. if (_currencyRate.Count > 0)
  3353. {
  3354. foreach (var item in _currencyInfos)
  3355. {
  3356. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3357. if (rateInfo != null)
  3358. {
  3359. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3360. decimal rate1 = item.Rate;
  3361. rate1 *= 1.03M;
  3362. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3363. reteInfos.Add(new
  3364. {
  3365. currCode = item.CurrencyCode,
  3366. currName = item.CurrencyName,
  3367. rate = rate2,
  3368. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3369. });
  3370. }
  3371. }
  3372. }
  3373. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3374. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3375. return Ok(JsonView(true, "查询成功!", new
  3376. {
  3377. //GroupNameData = groupNameData.Data,
  3378. visaData = visaData.Data,
  3379. airData = airData.Data,
  3380. reteInfos = reteInfos
  3381. }));
  3382. }
  3383. /// <summary>
  3384. /// 团组模块 - 出入境费用 - Info
  3385. /// </summary>
  3386. /// <returns></returns>
  3387. [HttpPost]
  3388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3389. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3390. {
  3391. try
  3392. {
  3393. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3394. if (data.Code != 0)
  3395. {
  3396. return Ok(JsonView(false, data.Msg));
  3397. }
  3398. return Ok(JsonView(true, "查询成功!", data.Data));
  3399. }
  3400. catch (Exception ex)
  3401. {
  3402. return Ok(JsonView(false, ex.Message));
  3403. }
  3404. }
  3405. /// <summary>
  3406. /// 团组模块 - 出入境费用 - Add And Update
  3407. /// </summary>
  3408. /// <returns></returns>
  3409. [HttpPost]
  3410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3411. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3412. {
  3413. try
  3414. {
  3415. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3416. if (data.Code != 0)
  3417. {
  3418. return Ok(JsonView(false, data.Msg));
  3419. }
  3420. return Ok(JsonView(true, data.Msg, data.Data));
  3421. }
  3422. catch (Exception ex)
  3423. {
  3424. return Ok(JsonView(false, ex.Message));
  3425. }
  3426. }
  3427. /// <summary>
  3428. /// 团组模块 - 出入境费用 - File downlaod
  3429. /// </summary>
  3430. /// <param name="dto"></param>
  3431. /// <returns></returns>
  3432. [HttpPost]
  3433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3434. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3435. {
  3436. try
  3437. {
  3438. if (dto.DiId < 1)
  3439. {
  3440. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3441. }
  3442. if (dto.ExportType < 1)
  3443. {
  3444. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3445. }
  3446. if (dto.SubTypeId < 1)
  3447. {
  3448. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3449. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3450. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3451. 3 团组成员名单 1 团组成员名单"));
  3452. }
  3453. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3454. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3455. if (_EnterExitCosts == null)
  3456. {
  3457. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3458. }
  3459. //数据源
  3460. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3461. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3462. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3463. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3464. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3465. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3466. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3467. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3468. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3469. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3470. .Select((tcl, dc, cc) => new
  3471. {
  3472. Name = dc.LastName + dc.FirstName,
  3473. Sex = dc.Sex,
  3474. Birthday = dc.BirthDay,
  3475. Company = cc.CompanyFullName,
  3476. Job = dc.Job
  3477. })
  3478. .ToList();
  3479. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3480. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3481. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3482. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3483. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3484. if (dto.ExportType == 1) //明细表
  3485. {
  3486. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3487. {
  3488. //获取模板
  3489. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3490. //载入模板
  3491. Document doc = new Document(tempPath);
  3492. DocumentBuilder builder = new DocumentBuilder(doc);
  3493. //利用键值对存放数据
  3494. Dictionary<string, string> dic = new Dictionary<string, string>();
  3495. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3496. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3497. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3498. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3499. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3500. string row1_1 = "";
  3501. if (_EnterExitCosts.Visa > 0)
  3502. {
  3503. //insidePayTotal += _EnterExitCosts.Visa;
  3504. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3505. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3506. {
  3507. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3508. }
  3509. }
  3510. string row1_2 = "";
  3511. if (_EnterExitCosts.YiMiao > 0)
  3512. {
  3513. //insidePayTotal += _EnterExitCosts.YiMiao;
  3514. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3515. }
  3516. if (_EnterExitCosts.HeSuan > 0)
  3517. {
  3518. //insidePayTotal += _EnterExitCosts.HeSuan;
  3519. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3520. }
  3521. if (_EnterExitCosts.Service > 0)
  3522. {
  3523. //insidePayTotal += _EnterExitCosts.Service;
  3524. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3525. }
  3526. string row1_3 = "";
  3527. if (_EnterExitCosts.Safe > 0)
  3528. {
  3529. //insidePayTotal += _EnterExitCosts.Safe;
  3530. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3531. }
  3532. if (_EnterExitCosts.Ticket > 0)
  3533. {
  3534. //insidePayTotal += _EnterExitCosts.Ticket;
  3535. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3536. }
  3537. string row1 = "";
  3538. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3539. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3540. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3541. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3542. dic.Add("Row1Str", row1);
  3543. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3544. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3545. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3546. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3547. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3548. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3549. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3550. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3551. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3552. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3553. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3554. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3555. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3556. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3557. #region 填充word模板书签内容
  3558. foreach (var key in dic.Keys)
  3559. {
  3560. builder.MoveToBookmark(key);
  3561. builder.Write(dic[key]);
  3562. }
  3563. #endregion
  3564. #region 填充word表格内容
  3565. ////获读取指定表格方法二
  3566. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3567. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3568. for (int i = 0; i < dac1.Count; i++)
  3569. {
  3570. Grp_DayAndCost dac = dac1[i];
  3571. if (dac == null) continue;
  3572. builder.MoveToCell(0, i, 0, 0);
  3573. builder.Write("第" + dac.Days.ToString() + "晚:");
  3574. builder.MoveToCell(0, i, 1, 0);
  3575. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3576. //builder.Write(dac.Place == null ? "" : dac.Place);
  3577. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3578. builder.MoveToCell(0, i, 2, 0);
  3579. builder.Write("费用标准:");
  3580. string curr = "";
  3581. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3582. if (currData != null)
  3583. {
  3584. curr = currData.Name;
  3585. }
  3586. builder.MoveToCell(0, i, 3, 0);
  3587. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3588. builder.MoveToCell(0, i, 4, 0);
  3589. builder.Write("费用小计:");
  3590. builder.MoveToCell(0, i, 5, 0);
  3591. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3592. }
  3593. //删除多余行
  3594. while (table1.Rows.Count > dac1.Count)
  3595. {
  3596. table1.Rows.RemoveAt(dac1.Count);
  3597. }
  3598. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3599. for (int i = 0; i < dac2.Count; i++)
  3600. {
  3601. Grp_DayAndCost dac = dac2[i];
  3602. if (dac == null) continue;
  3603. builder.MoveToCell(1, i, 0, 0);
  3604. builder.Write("第" + dac.Days.ToString() + "天:");
  3605. builder.MoveToCell(1, i, 1, 0);
  3606. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3607. builder.MoveToCell(1, i, 2, 0);
  3608. builder.Write("费用标准:");
  3609. string curr = "";
  3610. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3611. if (currData != null)
  3612. {
  3613. curr = currData.Name;
  3614. }
  3615. builder.MoveToCell(1, i, 3, 0);
  3616. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3617. builder.MoveToCell(1, i, 4, 0);
  3618. builder.Write("费用小计:");
  3619. builder.MoveToCell(1, i, 5, 0);
  3620. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3621. }
  3622. //删除多余行
  3623. while (table2.Rows.Count > dac2.Count)
  3624. {
  3625. table2.Rows.RemoveAt(dac2.Count);
  3626. }
  3627. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3628. for (int i = 0; i < dac3.Count; i++)
  3629. {
  3630. Grp_DayAndCost dac = dac3[i];
  3631. if (dac == null) continue;
  3632. builder.MoveToCell(2, i, 0, 0);
  3633. builder.Write("第" + dac.Days.ToString() + "天:");
  3634. builder.MoveToCell(2, i, 1, 0);
  3635. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3636. builder.MoveToCell(2, i, 2, 0);
  3637. builder.Write("费用标准:");
  3638. string curr = "";
  3639. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3640. if (currData != null)
  3641. {
  3642. curr = currData.Name;
  3643. }
  3644. builder.MoveToCell(2, i, 3, 0);
  3645. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3646. builder.MoveToCell(2, i, 4, 0);
  3647. builder.Write("费用小计:");
  3648. builder.MoveToCell(2, i, 5, 0);
  3649. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3650. }
  3651. //删除多余行
  3652. while (table3.Rows.Count > dac3.Count)
  3653. {
  3654. table3.Rows.RemoveAt(dac3.Count);
  3655. }
  3656. #endregion
  3657. //文件名
  3658. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3659. AsposeHelper.removewatermark_v2180();
  3660. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3661. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3662. return Ok(JsonView(true, "成功", new { Url = url }));
  3663. }
  3664. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3665. {
  3666. //获取模板
  3667. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3668. //载入模板
  3669. Document doc = new Document(tempPath);
  3670. DocumentBuilder builder = new DocumentBuilder(doc);
  3671. Dictionary<string, string> dic = new Dictionary<string, string>();
  3672. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3673. {
  3674. List<string> list = new List<string>();
  3675. try
  3676. {
  3677. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3678. foreach (var item in spilitArr)
  3679. {
  3680. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3681. var depCode = spDotandEmpty[2].Substring(0, 3);
  3682. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3683. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3684. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3685. list.Add(depName);
  3686. list.Add(arrName);
  3687. }
  3688. list = list.Distinct().ToList();
  3689. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3690. }
  3691. catch (Exception)
  3692. {
  3693. dic.Add("ReturnCode", "行程录入不正确!");
  3694. }
  3695. }
  3696. else
  3697. {
  3698. dic.Add("ReturnCode", "未录入行程!");
  3699. }
  3700. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3701. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3702. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3703. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3704. {
  3705. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3706. dic.Add("Day", sp.Days.ToString());
  3707. }
  3708. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3709. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3710. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3711. //dic.Add("Names", Names);
  3712. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3713. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3714. decimal dac1totalPrice = 0.00M;
  3715. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3716. foreach (var dac in dac1)
  3717. {
  3718. if (dac.SubTotal == 0.00M)
  3719. {
  3720. continue;
  3721. }
  3722. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3723. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3724. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3725. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3726. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3727. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3728. builder.Write(currency);//币种
  3729. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3730. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3731. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3732. builder.Write("");//人数
  3733. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3734. builder.Write("");//天数
  3735. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3736. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3737. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3738. decimal rate = 0.00M;
  3739. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3740. builder.Write(rate.ToString("#0.0000"));//汇率
  3741. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3742. decimal rbmPrice = dac.SubTotal;
  3743. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3744. accommodationStartIndex++;
  3745. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3746. }
  3747. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3748. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3749. {
  3750. table1.Rows.RemoveAt(i - 1);
  3751. foodandotherStartIndex--;
  3752. }
  3753. if (dac2.Count == dac3.Count)//国家 币种 金额
  3754. {
  3755. for (int i = 0; i < dac2.Count; i++)
  3756. {
  3757. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3758. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3759. }
  3760. }
  3761. decimal dac2totalPrice = 0.00M;
  3762. foreach (var dac in dac2)
  3763. {
  3764. if (dac.SubTotal == 0)
  3765. {
  3766. continue;
  3767. }
  3768. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3769. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3770. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3771. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3772. builder.Write(currency);//币种
  3773. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3774. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3775. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3776. builder.Write("");//人数
  3777. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3778. builder.Write("");//天数
  3779. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3780. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3781. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3782. decimal rate = 0.00M;
  3783. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3784. builder.Write(rate.ToString("#0.0000"));//汇率
  3785. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3786. decimal rbmPrice = dac.SubTotal;
  3787. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3788. foodandotherStartIndex++;
  3789. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3790. }
  3791. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3792. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3793. {
  3794. table1.Rows.RemoveAt(i - 1);
  3795. }
  3796. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3797. string otherFeeStr = "";
  3798. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3799. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3800. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3801. if (otherFeeStr.Length > 0)
  3802. {
  3803. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3804. otherFeeStr = $"({otherFeeStr})";
  3805. dic.Add("OtherFeeStr", otherFeeStr);
  3806. }
  3807. //总计
  3808. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3809. //国际旅费
  3810. string outsideJJ = "";
  3811. string allPriceJJ = "";
  3812. if (_EnterExitCosts.SumJJC == 1)
  3813. {
  3814. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3815. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3816. }
  3817. string outsideGW = "";
  3818. string allPriceGW = "";
  3819. if (_EnterExitCosts.SumGWC == 1)
  3820. {
  3821. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3822. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3823. }
  3824. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3825. {
  3826. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3827. dic.Add("InTravelPrice", InTravelPriceStr);
  3828. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3829. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3830. }
  3831. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3832. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3833. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3834. foreach (var key in dic.Keys)
  3835. {
  3836. builder.MoveToBookmark(key);
  3837. builder.Write(dic[key]);
  3838. }
  3839. //模板文件名
  3840. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3841. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3842. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3843. return Ok(JsonView(true, "成功", new { Url = url }));
  3844. }
  3845. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3846. {
  3847. //获取模板
  3848. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3849. //载入模板
  3850. WorkbookDesigner designer = new WorkbookDesigner();
  3851. designer.Workbook = new Workbook(tempPath);
  3852. Dictionary<string, string> dic = new Dictionary<string, string>();
  3853. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3854. {
  3855. List<string> list = new List<string>();
  3856. try
  3857. {
  3858. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3859. foreach (var item in spilitArr)
  3860. {
  3861. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3862. var depCode = spDotandEmpty[2].Substring(0, 3);
  3863. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3864. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3865. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3866. list.Add(depName);
  3867. list.Add(arrName);
  3868. }
  3869. list = list.Distinct().ToList();
  3870. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3871. }
  3872. catch (Exception)
  3873. {
  3874. dic.Add("ReturnCode", "行程录入不正确!");
  3875. }
  3876. }
  3877. else
  3878. {
  3879. dic.Add("ReturnCode", "未录入行程!");
  3880. }
  3881. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3882. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3883. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3884. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3885. {
  3886. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3887. dic.Add("Day", sp.Days.ToString());
  3888. }
  3889. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3890. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3891. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3892. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3893. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3894. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3895. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3896. designer.SetDataSource("Name", Names);
  3897. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3898. designer.SetDataSource("Day", dic["Day"] + "天");
  3899. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3900. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3901. int startIndex = 10;
  3902. const int startIndexcopy = 10;
  3903. if (dac2.Count == dac3.Count)//国家 币种 金额
  3904. {
  3905. for (int i = 0; i < dac2.Count; i++)
  3906. {
  3907. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3908. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3909. }
  3910. }
  3911. DataTable dtdac1 = new DataTable();
  3912. List<string> place = new List<string>();
  3913. dtdac1.Columns.AddRange(new DataColumn[] {
  3914. new DataColumn(){ ColumnName = "city"},
  3915. new DataColumn(){ ColumnName = "curr"},
  3916. new DataColumn(){ ColumnName = "criterion"},
  3917. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3918. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3919. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3920. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3921. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3922. });
  3923. DataTable dtdac2 = new DataTable();
  3924. dtdac2.Columns.AddRange(new DataColumn[] {
  3925. new DataColumn(){ ColumnName = "city"},
  3926. new DataColumn(){ ColumnName = "curr"},
  3927. new DataColumn(){ ColumnName = "criterion"},
  3928. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3929. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3930. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3931. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3932. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3933. });
  3934. dtdac1.TableName = "tb1";
  3935. dtdac2.TableName = "tb2";
  3936. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3937. foreach (var item in dac1)
  3938. {
  3939. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3940. if (place.Contains(item.Place))
  3941. {
  3942. continue;
  3943. }
  3944. DataRow row = dtdac1.NewRow();
  3945. row["city"] = item.Place;
  3946. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  3947. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3948. row["curr"] = currency;
  3949. row["rate"] = rate.ToString("#0.0000");
  3950. row["criterion"] = item.Cost.ToString("#0.00");
  3951. row["number"] = 1;
  3952. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3953. //row["costRMB"] = rbmPrice;
  3954. dtdac1.Rows.Add(row);
  3955. place.Add(item.Place);
  3956. }
  3957. place = new List<string>();
  3958. foreach (var item in dac2)
  3959. {
  3960. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  3961. if (place.Contains(item.Place))
  3962. {
  3963. continue;
  3964. }
  3965. DataRow row = dtdac2.NewRow();
  3966. row["city"] = item.Place;
  3967. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  3968. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  3969. row["curr"] = currency;
  3970. row["rate"] = rate.ToString("#0.0000");
  3971. row["criterion"] = item.Cost.ToString("#0.00");
  3972. row["number"] = 1;
  3973. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  3974. //row["cost"] = item.SubTotal;
  3975. //row["costRMB"] = rbmPrice;
  3976. dtdac2.Rows.Add(row);
  3977. place.Add(item.Place);
  3978. //dac2totalPrice += rbmPrice;
  3979. }
  3980. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  3981. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  3982. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3983. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  3984. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  3985. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  3986. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  3987. string cellStr = $" 5.其他费用(";
  3988. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  3989. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  3990. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  3991. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  3992. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  3993. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  3994. if (cellStr.Length > 8)
  3995. {
  3996. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  3997. }
  3998. cellStr += ")";
  3999. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4000. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4001. decimal pxFee = dac4.Sum(it => it.Cost);
  4002. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4003. string celllastStr1 = "";
  4004. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4005. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4006. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4007. celllastStr1 += $",国际旅费 元";
  4008. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4009. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4010. designer.SetDataSource("cell4Str", cell4Str);
  4011. designer.SetDataSource("cellStr", cellStr);
  4012. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4013. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4014. designer.SetDataSource("celllastStr", celllastStr);
  4015. Workbook wb = designer.Workbook;
  4016. var sheet = wb.Worksheets[0];
  4017. //绑定datatable数据集
  4018. designer.SetDataSource(dtdac1);
  4019. designer.SetDataSource(dtdac2);
  4020. designer.Process();
  4021. var rowStart = dtdac1.Rows.Count;
  4022. while (rowStart > 0)
  4023. {
  4024. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4025. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4026. startIndex++;
  4027. rowStart--;
  4028. }
  4029. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4030. startIndex += 1; //总计行
  4031. rowStart = dtdac2.Rows.Count;
  4032. while (rowStart > 0)
  4033. {
  4034. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4035. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4036. startIndex++;
  4037. rowStart--;
  4038. }
  4039. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4040. wb.CalculateFormula(true);
  4041. //模板文件名
  4042. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4043. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4044. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4045. return Ok(JsonView(true, "成功", new { Url = url }));
  4046. }
  4047. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4048. {
  4049. //获取模板
  4050. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4051. //载入模板
  4052. Document doc = new Document(tempPath);
  4053. DocumentBuilder builder = new DocumentBuilder(doc);
  4054. Dictionary<string, string> dic = new Dictionary<string, string>();
  4055. dic.Add("GroupName", _DelegationInfo.TeamName);
  4056. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4057. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4058. string missionLeaderJob = "";//负责人job
  4059. int groupNumber = 0; //团人数
  4060. if (DeleClientList.Count > 0)
  4061. {
  4062. missionLeader = DeleClientList[0]?.Name ?? "";
  4063. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4064. }
  4065. dic.Add("MissionLeader", missionLeader); //团负责人
  4066. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4067. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4068. #region MyRegion
  4069. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4070. //{
  4071. // List<string> list = new List<string>();
  4072. // try
  4073. // {
  4074. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4075. // foreach (var item in spilitArr)
  4076. // {
  4077. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4078. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4079. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4080. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4081. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4082. // list.Add(depName);
  4083. // list.Add(arrName);
  4084. // }
  4085. // list = list.Distinct().ToList();
  4086. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4087. // }
  4088. // catch (Exception)
  4089. // {
  4090. // dic.Add("ReturnCode", "行程录入不正确!");
  4091. // }
  4092. //}
  4093. //else
  4094. //{
  4095. // dic.Add("ReturnCode", "未录入行程!");
  4096. //}
  4097. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4098. dic.Add("ReturnCode", string.Join("、", countrys));
  4099. #endregion
  4100. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4101. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4102. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4103. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4104. //{
  4105. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4106. // dic.Add("Day", sp.Days.ToString());
  4107. //}
  4108. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4109. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4110. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4111. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4112. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4113. //培训人员名单
  4114. int cultivateRowIndex = 7;
  4115. foreach (var item in DeleClientList)
  4116. {
  4117. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4118. builder.Write(item.Name);
  4119. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4120. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4121. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4122. string birthDay = "";
  4123. if (item.Birthday != null)
  4124. {
  4125. DateTime dt = Convert.ToDateTime(item.Birthday);
  4126. birthDay = $"{dt.Year}.{dt.Month}";
  4127. }
  4128. builder.Write(birthDay);
  4129. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4130. builder.Write(item.Company);
  4131. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4132. builder.Write(item.Job);
  4133. cultivateRowIndex++;
  4134. }
  4135. //删除多余行
  4136. //cultivateRowIndex -= 2;
  4137. int delRows = 10 + 7 - cultivateRowIndex;
  4138. if (delRows > 0)
  4139. {
  4140. for (int i = 0; i < delRows; i++)
  4141. {
  4142. table1.Rows.RemoveAt(cultivateRowIndex);
  4143. //cultivateRowIndex++;
  4144. }
  4145. }
  4146. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4147. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4148. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4149. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4150. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4151. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4152. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4153. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4154. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4155. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4156. //其他费用
  4157. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4158. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4159. //其他费用合计
  4160. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4161. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4162. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4163. //公务舱合计
  4164. //国际旅费
  4165. string outsideJJ = "";
  4166. string allPriceJJ = "";
  4167. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4168. {
  4169. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4170. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4171. }
  4172. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4173. {
  4174. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4175. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4176. }
  4177. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4178. {
  4179. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4180. dic.Add("AirFeeTotal", airFeeTotalStr);
  4181. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4182. dic.Add("FeeTotal", feeTotalStr);
  4183. }
  4184. foreach (var key in dic.Keys)
  4185. {
  4186. builder.MoveToBookmark(key);
  4187. builder.Write(dic[key]);
  4188. }
  4189. //模板文件名
  4190. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4191. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4192. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4193. return Ok(JsonView(true, "成功", new { Url = url }));
  4194. }
  4195. }
  4196. else if (dto.ExportType == 2) //表格
  4197. {
  4198. //利用键值对存放数据
  4199. Dictionary<string, string> dic = new Dictionary<string, string>();
  4200. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4201. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4202. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4203. dic.Add("Day", sp.Days.ToString());
  4204. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4205. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4206. {
  4207. //获取模板
  4208. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4209. //载入模板
  4210. Document doc = new Document(tempPath);
  4211. DocumentBuilder builder = new DocumentBuilder(doc);
  4212. dic.Add("TeamName", _DelegationInfo.TeamName);
  4213. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4214. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4215. string missionLeaderName = "",
  4216. missionLeaderJob = "";
  4217. if (DeleClientList.Count > 0)
  4218. {
  4219. missionLeaderName = DeleClientList[0].Name;
  4220. missionLeaderJob = DeleClientList[0].Job;
  4221. }
  4222. dic.Add("MissionLeaderName", missionLeaderName);
  4223. dic.Add("MissionLeaderJob", missionLeaderJob);
  4224. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4225. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4226. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4227. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4228. int rowCount = 10;//总人数行
  4229. int startRowIndex = 7; //起始行
  4230. for (int i = 0; i < DeleClientList.Count; i++)
  4231. {
  4232. builder.MoveToCell(0, startRowIndex, 0, 0);
  4233. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4234. builder.MoveToCell(0, startRowIndex, 1, 0);
  4235. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4236. builder.Write(sex);//性别
  4237. builder.MoveToCell(0, startRowIndex, 2, 0);
  4238. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4239. builder.MoveToCell(0, startRowIndex, 3, 0);
  4240. builder.Write(DeleClientList[i].Company);//工作单位
  4241. builder.MoveToCell(0, startRowIndex, 4, 0);
  4242. builder.Write(DeleClientList[i].Job);//职务及级别
  4243. builder.MoveToCell(0, startRowIndex, 5, 0);
  4244. builder.Write("");//人员属性
  4245. builder.MoveToCell(0, startRowIndex, 6, 0);
  4246. builder.Write("");//上次出国时间
  4247. startRowIndex++;
  4248. }
  4249. int nullRow = rowCount - DeleClientList.Count;//空行
  4250. for (int i = 0; i < nullRow; i++)
  4251. {
  4252. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4253. }
  4254. foreach (var key in dic.Keys)
  4255. {
  4256. builder.MoveToBookmark(key);
  4257. builder.Write(dic[key]);
  4258. }
  4259. //模板文件名
  4260. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4261. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4262. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4263. return Ok(JsonView(true, "成功", new { Url = url }));
  4264. }
  4265. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4266. {
  4267. //获取模板
  4268. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4269. //载入模板
  4270. Document doc = new Document(tempPath);
  4271. DocumentBuilder builder = new DocumentBuilder(doc);
  4272. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4273. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4274. dic.Add("Names", Names);
  4275. int accommodationRows = 12, foodandotherRows = 12;
  4276. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4277. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4278. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4279. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4280. int accommodationStartIndex = 6;
  4281. decimal dac1totalPrice = 0.00M;
  4282. foreach (var dac in dac1)
  4283. {
  4284. if (dac.SubTotal == 0)
  4285. {
  4286. continue;
  4287. }
  4288. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4289. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4290. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4291. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4292. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4293. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4294. builder.Write(currency);//币种
  4295. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4296. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4297. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4298. builder.Write("");//人数
  4299. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4300. builder.Write("");//天数
  4301. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4302. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4303. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4304. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4305. builder.Write(rate.ToString("#0.0000"));//汇率
  4306. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4307. decimal rbmPrice = rate * dac.SubTotal;
  4308. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4309. accommodationStartIndex++;
  4310. dac1totalPrice += rbmPrice;
  4311. }
  4312. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4313. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4314. builder.Write("小计");
  4315. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4316. builder.Write(dac1totalPrice.ToString("#0.00"));
  4317. accommodationStartIndex++;
  4318. int nullRow = accommodationRows - dac1.Count;
  4319. //删除空行
  4320. //if (nullRow > 0)
  4321. //{
  4322. // int rowIndex = accommodationStartIndex;
  4323. // for (int i = 0; i < nullRow; i++)
  4324. // {
  4325. // Row row = table1.Rows[rowIndex];
  4326. // row.Remove();
  4327. // rowIndex++;
  4328. // }
  4329. //}
  4330. if (dac2.Count == dac3.Count)//国家 币种 金额
  4331. {
  4332. for (int i = 0; i < dac2.Count; i++)
  4333. {
  4334. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4335. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4336. }
  4337. }
  4338. int foodandotherStartIndex = 19;//
  4339. decimal dac2totalPrice = 0.00M;
  4340. foreach (var dac in dac2)
  4341. {
  4342. if (dac.SubTotal == 0)
  4343. {
  4344. continue;
  4345. }
  4346. //foodandotherStartIndex = 12;
  4347. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4348. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4349. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4350. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4351. builder.Write(currency);//币种
  4352. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4353. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4354. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4355. builder.Write("");//人数
  4356. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4357. builder.Write("");//天数
  4358. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4359. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4360. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4361. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4362. builder.Write(rate.ToString("#0.0000"));//汇率
  4363. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4364. decimal rbmPrice = rate * dac.SubTotal;
  4365. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4366. foodandotherStartIndex++;
  4367. dac2totalPrice += rbmPrice;
  4368. }
  4369. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4370. //删除空行
  4371. if (dac2.Count < foodandotherRows)
  4372. {
  4373. //int nullRow = accommodationRows - dac2.Count;
  4374. //while (table2.Rows.Count > dac2.Count)
  4375. //{
  4376. // table2.Rows.RemoveAt(dac2.Count);
  4377. //}
  4378. }
  4379. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4380. string otherFeeStr = "";
  4381. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4382. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4383. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4384. if (otherFeeStr.Length > 0)
  4385. {
  4386. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4387. otherFeeStr = $"({otherFeeStr})";
  4388. dic.Add("OtherFeeStr", otherFeeStr);
  4389. }
  4390. foreach (var key in dic.Keys)
  4391. {
  4392. builder.MoveToBookmark(key);
  4393. builder.Write(dic[key]);
  4394. }
  4395. //模板文件名
  4396. string strFileName = $"省级单位出(境)经费报销单.docx";
  4397. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4398. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4399. return Ok(JsonView(true, "成功", new { Url = url }));
  4400. }
  4401. }
  4402. else if (dto.ExportType == 3)
  4403. {
  4404. if (dto.SubTypeId == 1) //团组成员名单
  4405. {
  4406. if (DeleClientList.Count < 1)
  4407. {
  4408. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4409. }
  4410. //获取模板
  4411. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4412. //载入模板
  4413. Document doc = new Document(tempPath);
  4414. DocumentBuilder builder = new DocumentBuilder(doc);
  4415. //获取word里所有表格
  4416. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4417. //获取所填表格的序数
  4418. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4419. var rowStart = tableOne.Rows[0]; //获取第1行
  4420. //循环赋值
  4421. for (int i = 0; i < DeleClientList.Count; i++)
  4422. {
  4423. builder.MoveToCell(0, i + 1, 0, 0);
  4424. builder.Write(DeleClientList[i].Name);
  4425. builder.MoveToCell(0, i + 1, 1, 0);
  4426. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4427. builder.Write(sex);
  4428. builder.MoveToCell(0, i + 1, 2, 0);
  4429. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4430. builder.MoveToCell(0, i + 1, 3, 0);
  4431. builder.Write(DeleClientList[i].Company);
  4432. builder.MoveToCell(0, i + 1, 4, 0);
  4433. builder.Write(DeleClientList[i].Job);
  4434. }
  4435. //删除多余行
  4436. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4437. {
  4438. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4439. }
  4440. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4441. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4442. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4443. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4444. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4445. return Ok(JsonView(true, "成功", new { Url = url }));
  4446. }
  4447. }
  4448. return Ok(JsonView(false, "操作失败!"));
  4449. }
  4450. catch (Exception ex)
  4451. {
  4452. return Ok(JsonView(false, ex.Message));
  4453. }
  4454. }
  4455. /// <summary>
  4456. /// 获取三公费用标准city
  4457. /// </summary>
  4458. /// <param name="placeData"></param>
  4459. /// <param name="nationalTravelFeeId"></param>
  4460. /// <returns></returns>
  4461. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4462. {
  4463. string _city = string.Empty;
  4464. if (placeData.Count < 1) return _city;
  4465. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4466. if (data == null) return _city;
  4467. string country = data.Country;
  4468. string city = data.City;
  4469. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4470. else _city = city;
  4471. return _city;
  4472. }
  4473. /// <summary>
  4474. /// 团组模块 - 出入境费用 - 明细表导出
  4475. /// </summary>
  4476. /// <returns></returns>
  4477. [HttpPost]
  4478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4479. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4480. {
  4481. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4482. if (data.Code != 0)
  4483. {
  4484. return Ok(JsonView(false, data.Msg));
  4485. }
  4486. return Ok(JsonView(true, data.Msg, data.Data));
  4487. }
  4488. /// <summary>
  4489. /// 团组模块 - 出入境费用 - 一键清空
  4490. /// </summary>
  4491. /// <returns></returns>
  4492. [HttpPost]
  4493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4494. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4495. {
  4496. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4497. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4498. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4499. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4500. if (_view.Code == 0)
  4501. {
  4502. return Ok(JsonView(true, "操作成功"));
  4503. }
  4504. return Ok(JsonView(false, "操作失败"));
  4505. }
  4506. /// <summary>
  4507. /// 团组模块 - 出入境费用 - 子项删除
  4508. /// </summary>
  4509. /// <returns></returns>
  4510. [HttpPost]
  4511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4512. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4513. {
  4514. try
  4515. {
  4516. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4517. if (data.Code != 0)
  4518. {
  4519. return Ok(JsonView(false, data.Msg));
  4520. }
  4521. return Ok(JsonView(true, "操作成功!", data.Data));
  4522. }
  4523. catch (Exception ex)
  4524. {
  4525. return Ok(JsonView(false, ex.Message));
  4526. }
  4527. }
  4528. /// <summary>
  4529. /// 团组模块 - 出入境国家费用标准 List
  4530. /// </summary>
  4531. /// <returns></returns>
  4532. [HttpPost]
  4533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4534. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4535. {
  4536. try
  4537. {
  4538. Stopwatch sw = new Stopwatch();
  4539. sw.Start();
  4540. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4541. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4542. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4543. Where gntf.Isdel = 0");
  4544. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4545. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4546. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4547. //foreach (var item in nationalTravel)
  4548. //{
  4549. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4550. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4551. // if (otherData != null)
  4552. // {
  4553. // cityData.Remove(otherData);
  4554. // cityData.Add(otherData);
  4555. // }
  4556. // nationalTravelFeeData1.Add(new
  4557. // {
  4558. // Country = item.Country,
  4559. // CityData = cityData
  4560. // });
  4561. //}
  4562. sw.Stop();
  4563. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4564. }
  4565. catch (Exception ex)
  4566. {
  4567. return Ok(JsonView(false, ex.Message));
  4568. throw;
  4569. }
  4570. }
  4571. /// <summary>
  4572. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4573. /// </summary>
  4574. /// <returns></returns>
  4575. [HttpPost]
  4576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4577. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4578. {
  4579. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4580. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4581. List<string> countryData = new List<string>();
  4582. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4583. countryData = countryData.Distinct().ToList();
  4584. List<dynamic> dataSource = new List<dynamic>();
  4585. foreach (var item in countryData)
  4586. {
  4587. List<string> cityData1 = new List<string>();
  4588. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4589. var countryData2 = new
  4590. {
  4591. CountryName = item,
  4592. CityData = cityData1
  4593. };
  4594. dataSource.Add(countryData2);
  4595. }
  4596. return Ok(JsonView(true, "查询成功!", dataSource));
  4597. }
  4598. /// <summary>
  4599. /// 团组模块 - 出入境国家费用标准 Page List
  4600. /// </summary>
  4601. /// <returns></returns>
  4602. [HttpPost]
  4603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4604. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4605. {
  4606. int portId = dto.PortType;
  4607. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4608. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4609. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4610. string whereSql = string.Empty;
  4611. if (!string.IsNullOrEmpty(dto.Country))
  4612. {
  4613. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4614. }
  4615. if (!string.IsNullOrEmpty(dto.City))
  4616. {
  4617. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4618. }
  4619. string pageSql = string.Format(@"Select * From (
  4620. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4621. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4622. From Grp_NationalTravelFee gntf
  4623. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4624. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4625. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4626. RefAsync<int> total = 0;
  4627. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4628. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4629. }
  4630. /// <summary>
  4631. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4632. /// </summary>
  4633. /// <returns></returns>
  4634. [HttpPost]
  4635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4636. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4637. {
  4638. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4639. int portId = dto.PortType;
  4640. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4641. string whereSql = string.Empty;
  4642. if (!string.IsNullOrEmpty(dto.Country))
  4643. {
  4644. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4645. }
  4646. if (!string.IsNullOrEmpty(dto.City))
  4647. {
  4648. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4649. }
  4650. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4651. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4652. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4653. From Grp_NationalTravelFee gntf
  4654. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4655. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4656. Where gntf.Isdel = 0 {0} ", whereSql);
  4657. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4658. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4659. }
  4660. /// <summary>
  4661. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4662. /// </summary>
  4663. /// <returns></returns>
  4664. [HttpPost]
  4665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4666. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4667. {
  4668. try
  4669. {
  4670. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4671. if (data.Code != 0)
  4672. {
  4673. return Ok(JsonView(false, data.Msg));
  4674. }
  4675. return Ok(JsonView(true, "操作成功!", data.Data));
  4676. }
  4677. catch (Exception ex)
  4678. {
  4679. return Ok(JsonView(false, ex.Message));
  4680. }
  4681. }
  4682. /// <summary>
  4683. /// 团组模块 - 出入境国家费用标准 - Del
  4684. /// </summary>
  4685. /// <returns></returns>
  4686. [HttpPost]
  4687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4688. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4689. {
  4690. try
  4691. {
  4692. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4693. {
  4694. Id = dto.Id,
  4695. DeleteUserId = dto.DeleteUserId,
  4696. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4697. IsDel = 1
  4698. };
  4699. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4700. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4701. .WhereColumns(it => new { it.Id })
  4702. .ExecuteCommandAsync();
  4703. if (delStatus <= 0)
  4704. {
  4705. return Ok(JsonView(false, "删除失败!"));
  4706. }
  4707. return Ok(JsonView(true, "操作成功!"));
  4708. }
  4709. catch (Exception ex)
  4710. {
  4711. return Ok(JsonView(false, ex.Message));
  4712. }
  4713. }
  4714. #endregion
  4715. #region 签证费用录入
  4716. /// <summary>
  4717. /// 根据diid查询签证费用列表
  4718. /// </summary>
  4719. /// <param name="dto"></param>
  4720. /// <returns></returns>
  4721. [HttpPost]
  4722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4723. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4724. {
  4725. try
  4726. {
  4727. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4728. if (groupData.Code != 0)
  4729. {
  4730. return Ok(JsonView(false, groupData.Msg));
  4731. }
  4732. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4733. }
  4734. catch (Exception ex)
  4735. {
  4736. return Ok(JsonView(false, ex.Message));
  4737. }
  4738. }
  4739. /// <summary>
  4740. /// 根据签证费用Id查询单条数据及c表数据
  4741. /// </summary>
  4742. /// <param name="dto"></param>
  4743. /// <returns></returns>
  4744. [HttpPost]
  4745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4746. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4747. {
  4748. try
  4749. {
  4750. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4751. if (groupData.Code != 0)
  4752. {
  4753. return Ok(JsonView(false, groupData.Msg));
  4754. }
  4755. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4756. }
  4757. catch (Exception ex)
  4758. {
  4759. return Ok(JsonView(false, ex.Message));
  4760. }
  4761. }
  4762. /// <summary>
  4763. /// 签证费用删除
  4764. /// </summary>
  4765. /// <param name="dto"></param>
  4766. /// <returns></returns>
  4767. [HttpPost]
  4768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4769. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4770. {
  4771. _sqlSugar.BeginTran();
  4772. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4773. if (!res)
  4774. {
  4775. _sqlSugar.RollbackTran();
  4776. return Ok(JsonView(false, "删除失败"));
  4777. }
  4778. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4779. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4780. .SetColumns(a => new Grp_CreditCardPayment()
  4781. {
  4782. IsDel = 1,
  4783. DeleteUserId = dto.DeleteUserId,
  4784. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4785. }).ExecuteCommand();
  4786. if (resSub < 1)
  4787. {
  4788. _sqlSugar.RollbackTran();
  4789. return Ok(JsonView(false, "删除失败"));
  4790. }
  4791. _sqlSugar.CommitTran();
  4792. return Ok(JsonView(true, "删除成功!"));
  4793. }
  4794. /// <summary>
  4795. /// 签证费用录入下拉框初始化
  4796. /// </summary>
  4797. /// <returns></returns>
  4798. [HttpPost]
  4799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4800. public async Task<IActionResult> VisaPriceAddSelect()
  4801. {
  4802. try
  4803. {
  4804. //支付方式
  4805. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4806. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4807. //币种
  4808. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4809. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4810. //乘客类型
  4811. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4812. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4813. //卡类型
  4814. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4815. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4816. var data = new
  4817. {
  4818. Payment = _Payment,
  4819. CurrencyList = _CurrencyList,
  4820. PassengerType = _PassengerType,
  4821. BankCard = _BankCard
  4822. };
  4823. return Ok(JsonView(true, "查询成功!", data));
  4824. }
  4825. catch (Exception ex)
  4826. {
  4827. return Ok(JsonView(false, "程序错误!"));
  4828. throw;
  4829. }
  4830. }
  4831. /// <summary>
  4832. /// 签证费用录入操作(Status:1.新增,2.修改)
  4833. /// </summary>
  4834. /// <param name="dto"></param>
  4835. /// <returns></returns>
  4836. [HttpPost]
  4837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4838. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4839. {
  4840. try
  4841. {
  4842. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4843. if (groupData.Code != 0)
  4844. {
  4845. return Ok(JsonView(false, groupData.Msg));
  4846. }
  4847. #region 应用推送
  4848. try
  4849. {
  4850. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4851. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4852. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4853. }
  4854. catch (Exception ex)
  4855. {
  4856. }
  4857. #endregion
  4858. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4859. }
  4860. catch (Exception ex)
  4861. {
  4862. return Ok(JsonView(false, ex.Message));
  4863. }
  4864. }
  4865. #endregion
  4866. #region op费用录入
  4867. /// <summary>
  4868. /// 根据diid查询op费用列表
  4869. /// </summary>
  4870. /// <param name="dto"></param>
  4871. /// <returns></returns>
  4872. [HttpPost]
  4873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4874. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4875. {
  4876. try
  4877. {
  4878. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4879. if (groupData.Code != 0)
  4880. {
  4881. return Ok(JsonView(false, groupData.Msg));
  4882. }
  4883. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4884. }
  4885. catch (Exception ex)
  4886. {
  4887. return Ok(JsonView(false, ex.Message));
  4888. }
  4889. }
  4890. /// <summary>
  4891. /// 根据op费用Id查询单条数据及c表数据
  4892. /// </summary>
  4893. /// <param name="dto"></param>
  4894. /// <returns></returns>
  4895. [HttpPost]
  4896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4897. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4898. {
  4899. try
  4900. {
  4901. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4902. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4903. var data = new
  4904. {
  4905. CarTouristGuideGround = _groupData,
  4906. CreditCardPayment = _creditCardPayment
  4907. };
  4908. return Ok(JsonView(true, "查询成功!", data));
  4909. }
  4910. catch (Exception ex)
  4911. {
  4912. return Ok(JsonView(false, "程序错误!"));
  4913. }
  4914. }
  4915. /// <summary>
  4916. /// op费用删除
  4917. /// </summary>
  4918. /// <param name="dto"></param>
  4919. /// <returns></returns>
  4920. [HttpPost]
  4921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4922. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4923. {
  4924. try
  4925. {
  4926. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4927. if (!res)
  4928. {
  4929. return Ok(JsonView(false, "删除失败"));
  4930. }
  4931. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4932. {
  4933. IsDel = 1,
  4934. DeleteUserId = dto.DeleteUserId,
  4935. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4936. }).ExecuteCommandAsync();
  4937. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4938. {
  4939. IsDel = 1,
  4940. DeleteUserId = dto.DeleteUserId,
  4941. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4942. }).ExecuteCommandAsync();
  4943. return Ok(JsonView(true, "删除成功!"));
  4944. }
  4945. catch (Exception ex)
  4946. {
  4947. return Ok(JsonView(false, "程序错误!"));
  4948. throw;
  4949. }
  4950. }
  4951. /// <summary>
  4952. /// op费用录入操作(Status:1.新增,2.修改)
  4953. /// </summary>
  4954. /// <param name="dto"></param>
  4955. /// <returns></returns>
  4956. [HttpPost]
  4957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4958. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  4959. {
  4960. try
  4961. {
  4962. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  4963. if (groupData.Code != 0)
  4964. {
  4965. return Ok(JsonView(false, groupData.Msg));
  4966. }
  4967. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4968. }
  4969. catch (Exception ex)
  4970. {
  4971. return Ok(JsonView(false, ex.Message));
  4972. }
  4973. }
  4974. /// <summary>
  4975. /// 填写费用详细页面初始化绑定
  4976. /// </summary>
  4977. /// <param name="dto"></param>
  4978. /// <returns></returns>
  4979. [HttpPost]
  4980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4981. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  4982. {
  4983. try
  4984. {
  4985. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  4986. if (groupData.Code != 0)
  4987. {
  4988. return Ok(JsonView(false, groupData.Msg));
  4989. }
  4990. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4991. }
  4992. catch (Exception ex)
  4993. {
  4994. return Ok(JsonView(false, ex.Message));
  4995. }
  4996. }
  4997. /// <summary>
  4998. /// 根据op费用Id查询详细数据
  4999. /// </summary>
  5000. /// <param name="dto"></param>
  5001. /// <returns></returns>
  5002. [HttpPost]
  5003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5004. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5005. {
  5006. try
  5007. {
  5008. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5009. if (groupData.Code != 0)
  5010. {
  5011. return Ok(JsonView(false, groupData.Msg));
  5012. }
  5013. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5014. }
  5015. catch (Exception ex)
  5016. {
  5017. return Ok(JsonView(false, ex.Message));
  5018. }
  5019. }
  5020. /// <summary>
  5021. /// OP费用录入填写详情
  5022. /// </summary>
  5023. /// <param name="dto"></param>
  5024. /// <returns></returns>
  5025. [HttpPost]
  5026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5027. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5028. {
  5029. try
  5030. {
  5031. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5032. if (groupData.Code != 0)
  5033. {
  5034. return Ok(JsonView(false, groupData.Msg));
  5035. }
  5036. #region 应用推送
  5037. try
  5038. {
  5039. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5040. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5041. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5042. }
  5043. catch (Exception ex)
  5044. {
  5045. }
  5046. #endregion
  5047. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5048. }
  5049. catch (Exception ex)
  5050. {
  5051. return Ok(JsonView(false, ex.Message));
  5052. }
  5053. }
  5054. /// <summary>
  5055. /// 获取三公详细所有城市
  5056. /// </summary>
  5057. /// <returns></returns>
  5058. [HttpGet]
  5059. public IActionResult OpCarCityResult()
  5060. {
  5061. var jw = JsonView(false);
  5062. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5063. {
  5064. x.Id,
  5065. x.Country,
  5066. x.City,
  5067. }).ToList();
  5068. if (data.Count > 0)
  5069. {
  5070. jw = JsonView(true, "获取成功!", data);
  5071. }
  5072. else
  5073. {
  5074. jw.Msg = "城市数据为空!";
  5075. jw.Data = new string[0];
  5076. }
  5077. return Ok(jw);
  5078. }
  5079. /// <summary>
  5080. /// 导出地接费用明细
  5081. /// </summary>
  5082. /// <param name="dto"></param>
  5083. /// <returns></returns>
  5084. [HttpPost]
  5085. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5086. {
  5087. var jw = JsonView(false);
  5088. if (dto.Diid < 1)
  5089. {
  5090. jw.Msg = "请输入正确的diid!";
  5091. return Ok(jw);
  5092. }
  5093. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  5094. if (group == null)
  5095. {
  5096. jw.Msg = "未找到团组信息!";
  5097. return Ok(jw);
  5098. }
  5099. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5100. if (localGuideArr.Count == 0)
  5101. {
  5102. jw.Msg = "该团组暂无地接信息!";
  5103. return Ok(jw);
  5104. }
  5105. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5106. var overspendSoure = new Dictionary<int, int>
  5107. {
  5108. { 91, 982 }, //车
  5109. { 92 , 1059} ,//导游
  5110. { 994 , 1073}, //翻译
  5111. { 988 , 1074 }, //早餐
  5112. { 93 , 1075 }, //午餐
  5113. { 989 , 1076 }, //晚餐
  5114. };
  5115. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5116. foreach (var groupArr in localGroup)
  5117. {
  5118. var keyValue = groupArr.Key;
  5119. if (int.TryParse(keyValue, out int cityid))
  5120. {
  5121. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5122. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5123. }
  5124. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5125. foreach (var item in groupArr)
  5126. {
  5127. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a,b)=> a.SId == b.Id
  5128. ).Where((a,b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a,b)=>
  5129. new Grp_CarTouristGuideGroundReservationsContentExtend
  5130. {
  5131. Count = a.Count,
  5132. CreateTime = a.CreateTime,
  5133. CreateUserId = a.CreateUserId,
  5134. CTGGRId = a.CTGGRId,
  5135. Currency = a.Currency,
  5136. DatePrice = a.DatePrice,
  5137. DeleteTime = a.DeleteTime,
  5138. DeleteUserId = a.DeleteUserId,
  5139. DiId = a.DiId,
  5140. Id = a.Id,
  5141. IsDel = a.IsDel,
  5142. Price = a.Price,
  5143. PriceContent = a.PriceContent,
  5144. Remark = a.Remark,
  5145. SId = a.SId,
  5146. SidName = b.Name,
  5147. Units = a.Units,
  5148. }
  5149. ).ToList();
  5150. if (content.Count > 0)
  5151. {
  5152. contentArr.Add(content);
  5153. }
  5154. }
  5155. //open excel
  5156. //set excel
  5157. //save excel
  5158. try
  5159. {
  5160. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5161. IWorkbook workbook;
  5162. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5163. {
  5164. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5165. }
  5166. else
  5167. {
  5168. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5169. }
  5170. ISheet sheet = workbook.GetSheetAt(0);
  5171. var rowStartIndex = 2;
  5172. var clounmCount = 10;
  5173. var initStyleRow = sheet.GetRow(2);
  5174. var arr = contentArr.SelectMany(x => x).OrderBy(x=>x.SId).ToList();
  5175. //var overspendArrDetail =
  5176. var existsId = new List<CarCompare>();
  5177. var lastElem = arr.Last();
  5178. var thisSid = -1;
  5179. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5180. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5181. {
  5182. Name = "未知币种!",
  5183. Remark = "未知币种!",
  5184. };
  5185. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5186. Action cloneRowFn = () =>
  5187. {
  5188. rowStartIndex++;
  5189. var cloneRow = sheet.CreateRow(rowStartIndex);
  5190. // 复制样式
  5191. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5192. {
  5193. ICell sourceCell = initStyleRow.GetCell(i);
  5194. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5195. // 确保单元格存在样式
  5196. if (sourceCell.CellStyle != null)
  5197. {
  5198. targetCell.CellStyle = sourceCell.CellStyle;
  5199. }
  5200. }
  5201. };
  5202. var mergeRow = () =>
  5203. {
  5204. for (int i = 2; i < sheet.LastRowNum; i++)
  5205. {
  5206. var row = sheet.GetRow(i);
  5207. var cellFirst = row.GetCell(0);
  5208. var thisIndex = i + 1;
  5209. while (thisIndex < sheet.LastRowNum)
  5210. {
  5211. var nextRow = sheet.GetRow(thisIndex);
  5212. var nextCellFirst = nextRow.GetCell(0);
  5213. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5214. {
  5215. thisIndex++;
  5216. }
  5217. else
  5218. {
  5219. break;
  5220. }
  5221. }
  5222. thisIndex--;
  5223. if (thisIndex != i)
  5224. {
  5225. //合并row
  5226. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5227. i, // 起始行索引(0-based)
  5228. thisIndex, // 结束行索引(0-based)
  5229. 0, // 起始列索引(0-based)
  5230. 0 // 结束列索引(0-based)
  5231. );
  5232. sheet.AddMergedRegion(cellRangeAddress);
  5233. i = thisIndex;
  5234. }
  5235. }
  5236. };
  5237. var chaoshiNumber = 0;
  5238. var totalNumber = 0.00M;
  5239. string lastStr = "";
  5240. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5241. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x,b) => new
  5242. {
  5243. b.IsAuditGM,
  5244. x.Id,
  5245. x.Area,
  5246. b.PayPercentage,
  5247. b.PayMoney,
  5248. }).ToList();
  5249. string yesPayment = "", noPayment = "";
  5250. foreach (var item in queryCarArrByCityAndDiid)
  5251. {
  5252. if (item.IsAuditGM == 1)
  5253. {
  5254. yesPayment += $"已支付团款({item.PayPercentage}):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5255. }
  5256. else
  5257. {
  5258. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5259. }
  5260. }
  5261. lastStr = yesPayment + noPayment;
  5262. foreach (var item in arr)
  5263. {
  5264. if (existsId.FirstOrDefault(x=>x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5265. {
  5266. if (thisSid != item.SId)
  5267. {
  5268. if (thisSid == -1)
  5269. {
  5270. thisSid = item.SId;
  5271. }
  5272. else
  5273. {
  5274. //合并小计行
  5275. //创建合并区域的实例
  5276. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5277. rowStartIndex, // 起始行索引(0-based)
  5278. rowStartIndex, // 结束行索引(0-based)
  5279. 0, // 起始列索引(0-based)
  5280. 3 // 结束列索引(0-based)
  5281. );
  5282. sheet.AddMergedRegion(cellRangeAddress);
  5283. var CellStyle = workbook.CreateCellStyle();
  5284. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5285. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5286. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5287. for (int i = 0; i <= clounmCount; i++)
  5288. {
  5289. if (i > 6)
  5290. {
  5291. var CellStyle1 = workbook.CreateCellStyle();
  5292. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5293. IFont Font = workbook.CreateFont(); // 创建字体
  5294. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5295. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5296. CellStyle1.SetFont(Font);
  5297. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5298. }
  5299. else
  5300. {
  5301. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5302. }
  5303. }
  5304. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5305. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x=>x.SId == thisSid).Sum(x=>x.Count * x.Price).ToString("F2"));
  5306. //超时合计
  5307. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5308. //超时数
  5309. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" :chaoshiNumber.ToString());
  5310. //超时合计费用
  5311. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5312. thisSid = item.SId;
  5313. cloneRowFn();
  5314. chaoshiNumber = 0;
  5315. totalNumber = 0;
  5316. }
  5317. }
  5318. IRow row = sheet.GetRow(rowStartIndex);
  5319. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5320. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5321. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null ;
  5322. if (isOpenOverspendSoure)
  5323. {
  5324. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5325. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5326. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5327. }
  5328. for (int i = 0; i <= clounmCount; i++)
  5329. {
  5330. var cell = row.GetCell(i);
  5331. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5332. if (cell == null)
  5333. {
  5334. cell = row.CreateCell(i);
  5335. }
  5336. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5337. fontRed.CloneStyleFrom(cell.CellStyle);
  5338. IFont Font = workbook.CreateFont(); // 创建字体
  5339. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5340. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5341. fontRed.SetFont(Font);
  5342. byte[] rgb = new byte[3] { 255, 242, 204 };
  5343. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5344. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5345. byte[] rgb1 = new byte[3] { 189,215, 238 };
  5346. if (workbook is XSSFWorkbook)
  5347. {
  5348. BackgroundColor255_242_204.FillForegroundColor = 0;
  5349. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5350. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5351. }
  5352. else
  5353. {
  5354. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5355. }
  5356. if (i == 1 || i > 6)
  5357. {
  5358. if (i > 6)
  5359. {
  5360. fontRed.FillForegroundColor = 0;
  5361. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5362. fontRed.FillPattern = FillPattern.SolidForeground;
  5363. }
  5364. cell.CellStyle = fontRed;
  5365. }
  5366. if (i > 2 && i < 7)
  5367. {
  5368. cell.CellStyle = BackgroundColor255_242_204;
  5369. }
  5370. cell.SetCellValue(setCellValue); //写入单元格
  5371. }
  5372. if (overspendSoure.ContainsKey(thisSid)) {
  5373. var overspendId = overspendSoure[thisSid];
  5374. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5375. }
  5376. cloneRowFn();
  5377. existsId.Add(new CarCompare
  5378. {
  5379. DataPrice = item.DatePrice.ObjToDate(),
  5380. Sid = item.SId
  5381. });
  5382. }
  5383. if (item.Equals(lastElem))
  5384. {
  5385. //合并小计行
  5386. //创建合并区域的实例
  5387. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5388. rowStartIndex, // 起始行索引(0-based)
  5389. rowStartIndex, // 结束行索引(0-based)
  5390. 0, // 起始列索引(0-based)
  5391. 3 // 结束列索引(0-based)
  5392. );
  5393. sheet.AddMergedRegion(cellRangeAddress);
  5394. var CellStyle = workbook.CreateCellStyle();
  5395. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5396. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5397. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5398. for (int i = 0; i <= clounmCount; i++)
  5399. {
  5400. if (i > 6)
  5401. {
  5402. var CellStyle1 = workbook.CreateCellStyle();
  5403. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5404. IFont Font = workbook.CreateFont(); // 创建字体
  5405. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5406. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5407. CellStyle1.SetFont(Font);
  5408. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5409. }
  5410. else
  5411. {
  5412. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5413. }
  5414. }
  5415. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5416. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5417. //超时合计
  5418. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5419. //超时数
  5420. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5421. //超时合计费用
  5422. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5423. cloneRowFn();
  5424. // 创建合并区域的实例
  5425. cellRangeAddress = new CellRangeAddress(
  5426. rowStartIndex, // 起始行索引(0-based)
  5427. rowStartIndex, // 结束行索引(0-based)
  5428. 0, // 起始列索引(0-based)
  5429. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5430. );
  5431. // 添加合并区域
  5432. sheet.AddMergedRegion(cellRangeAddress);
  5433. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5434. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5435. }
  5436. }
  5437. mergeRow();
  5438. // 保存修改后的Excel文件到新文件
  5439. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5440. // new FileStream(newFilePath, FileMode.CreateNew)
  5441. using (var stream = new MemoryStream())
  5442. {
  5443. workbook.Write(stream,true);
  5444. stream.Flush();
  5445. stream.Seek(0, SeekOrigin.Begin);
  5446. MemoryStream memoryStream = new MemoryStream();
  5447. stream.CopyTo(memoryStream);
  5448. memoryStream.Seek(0, SeekOrigin.Begin);
  5449. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5450. }
  5451. workbook.Close();
  5452. workbook.Dispose();
  5453. }
  5454. catch (Exception ex)
  5455. {
  5456. jw.Msg = "出现异常!" + ex.Message;
  5457. return Ok(jw);
  5458. }
  5459. }
  5460. if (Zips.Count > 0)
  5461. {
  5462. IOOperatorHelper io = new IOOperatorHelper();
  5463. var byts = io.ConvertZipStream(Zips);
  5464. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + "\\ExportLocalGuidePriceDetail\\地接费用明细.zip");
  5465. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5466. jw = JsonView(true, "success" , new { url = AppSettingsHelper.Get("OfficeBaseUrl") + "\\Office\\Excel\\ExportLocalGuidePriceDetail\\地接费用明细.zip" });
  5467. }
  5468. else
  5469. {
  5470. jw.Msg = "暂无生成文件!";
  5471. }
  5472. return Ok(jw);
  5473. }
  5474. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5475. {
  5476. string outStr = string.Empty;
  5477. switch (i)
  5478. {
  5479. case 0:
  5480. outStr = arr[0].SidName;
  5481. break;
  5482. case 1:
  5483. outStr = arr[0].DataPriceStr;
  5484. break;
  5485. case 2:
  5486. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5487. break;
  5488. case 4:
  5489. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5490. break;
  5491. case 7:
  5492. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5493. {
  5494. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5495. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5496. outStr = arrOverspendSoure.Sum(x=>x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5497. }
  5498. break;
  5499. case 8:
  5500. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5501. {
  5502. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5503. }
  5504. break;
  5505. case 9:
  5506. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5507. {
  5508. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5509. }
  5510. break;
  5511. case 10:
  5512. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5513. {
  5514. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5515. }
  5516. break;
  5517. }
  5518. return outStr;
  5519. }
  5520. #region OP行程单
  5521. /// <summary>
  5522. /// OP行程单初始化
  5523. /// </summary>
  5524. /// <param name="dto"></param>
  5525. /// <returns></returns>
  5526. [HttpPost]
  5527. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5528. {
  5529. var jw = JsonView(false);
  5530. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5531. var group = groupList.First();
  5532. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5533. if (group == null)
  5534. {
  5535. jw.Msg = "暂无团组!";
  5536. return Ok(jw);
  5537. }
  5538. group = groupList.Find(x => x.Id == diid);
  5539. if (group == null)
  5540. {
  5541. jw.Msg = "请输入正确的团组ID!";
  5542. return Ok(jw);
  5543. }
  5544. string city = string.Empty;
  5545. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5546. if (blackCode.Count > 0)
  5547. {
  5548. var black = blackCode.First();
  5549. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5550. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5551. if (blackSp.Length > 0)
  5552. {
  5553. try
  5554. {
  5555. var cityArrCode = new List<string>(20);
  5556. foreach (var item in blackSp)
  5557. {
  5558. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5559. var IndexSelect = itemSp[2];
  5560. var cityArrCodeLength = cityArrCode.Count - 1;
  5561. var startCity = IndexSelect.Substring(0, 3);
  5562. if (cityArrCodeLength > 0)
  5563. {
  5564. var arrEndCity = cityArrCode[cityArrCodeLength];
  5565. if (arrEndCity != startCity)
  5566. {
  5567. cityArrCode.Add(startCity.ToUpper());
  5568. }
  5569. }
  5570. else
  5571. {
  5572. cityArrCode.Add(startCity.ToUpper());
  5573. }
  5574. var endCity = IndexSelect.Substring(3, 3);
  5575. cityArrCode.Add(endCity.ToUpper());
  5576. }
  5577. var cityThree = string.Empty;
  5578. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5579. cityThree = cityThree.TrimEnd(',');
  5580. if (string.IsNullOrWhiteSpace(cityThree))
  5581. {
  5582. throw new
  5583. Exception("error");
  5584. }
  5585. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5586. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5587. foreach (var item in cityArrCode)
  5588. {
  5589. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5590. if (find != null)
  5591. {
  5592. city += find.City + "/";
  5593. }
  5594. else
  5595. {
  5596. city += item + "三字码未收入/";
  5597. }
  5598. }
  5599. city = city.TrimEnd('/');
  5600. }
  5601. catch (Exception e)
  5602. {
  5603. city = "黑屏代码格式不正确!";
  5604. }
  5605. }
  5606. }
  5607. else
  5608. {
  5609. city = "未录入黑屏代码";
  5610. }
  5611. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5612. {
  5613. Date = x.Date,
  5614. Days = x.Days,
  5615. Diffgroup = x.Diffgroup,
  5616. Diid = x.Diid,
  5617. Traffic_First = x.Traffic_First,
  5618. Traffic_Second = x.Traffic_Second,
  5619. Trip = x.Trip,
  5620. WeekDay = x.WeekDay,
  5621. Id = x.Id
  5622. }).ToList();
  5623. jw.Data = new
  5624. {
  5625. groupList = groupList.Select(x => new
  5626. {
  5627. x.Id,
  5628. x.TeamName,
  5629. x.TourCode
  5630. }).ToList(),
  5631. groupInfo = new
  5632. {
  5633. group.VisitDays,
  5634. group.TourCode,
  5635. group.VisitPNumber,
  5636. group.TeamName,
  5637. city
  5638. },
  5639. OpTravelList
  5640. };
  5641. jw.Code = 200;
  5642. jw.Msg = "操作成功!";
  5643. return Ok(jw);
  5644. }
  5645. /// <summary>
  5646. /// 删除团组行程单
  5647. /// </summary>
  5648. /// <returns></returns>
  5649. [HttpPost]
  5650. public IActionResult DelTravel(DelOpTravelDto dto)
  5651. {
  5652. var jw = JsonView(false);
  5653. if (dto.UserId <= 0 || dto.Diid <= 0)
  5654. {
  5655. jw.Msg = "请输入正确的参数!";
  5656. return Ok(jw);
  5657. }
  5658. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5659. .SetColumns(x => new Grp_TravelList
  5660. {
  5661. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5662. DeleteUserId = dto.UserId,
  5663. IsDel = 1,
  5664. }).ExecuteCommand();
  5665. jw = JsonView(true);
  5666. return Ok(jw);
  5667. }
  5668. /// <summary>
  5669. /// 行程单保存
  5670. /// </summary>
  5671. /// <returns></returns>
  5672. [HttpPost]
  5673. public IActionResult TravelSave(TravelSaveDto dto)
  5674. {
  5675. var jw = JsonView(false);
  5676. if (dto.Arr.Count > 0)
  5677. {
  5678. try
  5679. {
  5680. _sqlSugar.BeginTran();
  5681. foreach (var item in dto.Arr)
  5682. {
  5683. if (item.Id == 0)
  5684. {
  5685. throw new Exception("请传入正确的Id");
  5686. }
  5687. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5688. .SetColumns(x => new Grp_TravelList
  5689. {
  5690. Trip = item.Trip
  5691. }).ExecuteCommand();
  5692. }
  5693. _sqlSugar.CommitTran();
  5694. jw = JsonView(true);
  5695. }
  5696. catch (Exception ex)
  5697. {
  5698. _sqlSugar.RollbackTran();
  5699. jw.Msg = "程序异常!" + ex.Message;
  5700. }
  5701. }
  5702. else
  5703. {
  5704. jw.Msg = "请传入正确的参数!";
  5705. }
  5706. return Ok(jw);
  5707. }
  5708. /// <summary>
  5709. /// 导出行程单
  5710. /// </summary>
  5711. /// <param name="dto"></param>
  5712. /// <returns></returns>
  5713. [HttpPost]
  5714. public IActionResult ExportTravel(InitOpTravelDto dto)
  5715. {
  5716. var jw = JsonView(false);
  5717. //数据源
  5718. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5719. int diid = 0;
  5720. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5721. if (Find == null)
  5722. {
  5723. jw.Msg = "请选择正确的团组!";
  5724. return Ok(jw);
  5725. }
  5726. else
  5727. {
  5728. diid = Find.Id;
  5729. }
  5730. DataTable dtBlack = null;
  5731. try
  5732. {
  5733. dtBlack = GetTableByBlackCode(diid);
  5734. }
  5735. catch (Exception)
  5736. {
  5737. jw.Msg = "机票黑屏代码有误!";
  5738. return Ok(jw);
  5739. }
  5740. string CityStr1 = "";
  5741. List<string> countriesList = new List<string>();
  5742. List<string> cityList = new List<string>();
  5743. string countriesIntroduction = "";
  5744. string cityIntroduction = "";
  5745. string timeDifference = "";
  5746. string currExchangeRate = "";
  5747. string txt_itemPrepare = "";
  5748. string txt_specialReminder = "";
  5749. string txt_cGPrecautions = "";
  5750. string txt_yGCG = "";
  5751. string txt_conduct = "";
  5752. string txt_commonEnglish = "";
  5753. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5754. {
  5755. //提示
  5756. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5757. }
  5758. else
  5759. {
  5760. //创建三字码示例
  5761. Res_ThreeCode t = new Res_ThreeCode();
  5762. //城市缓存
  5763. string city = "";
  5764. //出访城市
  5765. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5766. {
  5767. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5768. {
  5769. continue;
  5770. }
  5771. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5772. {
  5773. //出发城市
  5774. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5775. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5776. if (t != null)
  5777. {
  5778. city = city + "/" + t.City;
  5779. }
  5780. else
  5781. {
  5782. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5783. }
  5784. if (i == dtBlack.Rows.Count - 1)
  5785. {
  5786. //抵达城市
  5787. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5788. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5789. if (t != null)
  5790. {
  5791. city = city + "/" + t.City;
  5792. }
  5793. else
  5794. {
  5795. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5796. }
  5797. }
  5798. }
  5799. }
  5800. if (city != "" && city != null)
  5801. {
  5802. string[] cityStr2 = city.Split('/');
  5803. string[] strs = cityStr2.Distinct().ToArray(); ;
  5804. string str = "";
  5805. foreach (var s in strs)
  5806. {
  5807. str += s + "/";
  5808. }
  5809. str = str.TrimStart('/');
  5810. str = str.TrimEnd('/');
  5811. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5812. CityStr1 = city.TrimStart('/');
  5813. }
  5814. // 行程repeater
  5815. if (GetByDiid(diid).Count > 0)
  5816. {
  5817. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5818. }
  5819. else
  5820. {
  5821. //生成该时间段日期
  5822. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5823. if (timeList != null)
  5824. {
  5825. string[] str = new string[timeList.Count];
  5826. //rpData.DataSource = str;
  5827. //rpData.DataBind();
  5828. }
  5829. }
  5830. }
  5831. //创建数据源Table
  5832. DataTable dtSource = new DataTable();
  5833. dtSource.Columns.Add("Days", typeof(string));
  5834. dtSource.Columns.Add("Date", typeof(string));
  5835. dtSource.Columns.Add("Week", typeof(string));
  5836. dtSource.Columns.Add("Traffic", typeof(string));
  5837. dtSource.Columns.Add("Trip", typeof(string));
  5838. //获取数据,放到datatable
  5839. foreach (var item in _travelList)
  5840. {
  5841. DataRow dr = dtSource.NewRow();
  5842. dr["Days"] = item.Days;
  5843. dr["Date"] = item.Date;
  5844. dr["Week"] = item.WeekDay;
  5845. dr["Traffic"] = item.Traffic_First
  5846. + "\r\n"
  5847. + item.Traffic_Second;
  5848. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5849. {
  5850. item.Trip += @"
  5851. 08:00 早餐于酒店;
  5852. 09:00 公务活动;
  5853. 10:30 公务活动;
  5854. 12:00 午餐于当地餐厅;
  5855. 14:00 公务活动;
  5856. 16:00 公务活动;
  5857. 18:00 晚餐于当地餐厅;
  5858. 19:00 入住酒店休息;";
  5859. }
  5860. dr["Trip"] = item.Trip;
  5861. dtSource.Rows.Add(dr);
  5862. }
  5863. //lblTeamName.Text = di.TourCode;
  5864. //lblVisitDays.Text = di.VisitDays.ToString();
  5865. //lblVisitDays2.Text = di.VisitDays.ToString();
  5866. //lblPNumber.Text = di.VisitPNumber.ToString();
  5867. //lblGroup.Text = di.TeamName.ToString();
  5868. Dictionary<string, string> dic = new Dictionary<string, string>();
  5869. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5870. dic.Add("City", CityStr1);
  5871. dic.Add("Days", Find.VisitDays.ToString());
  5872. dic.Add("DeleCode", Find.TourCode);
  5873. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5874. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5875. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5876. if (leader != null && leader.Count > 0)
  5877. {
  5878. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5879. }
  5880. else
  5881. {
  5882. dic.Add("Leader", "");
  5883. }
  5884. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5885. int UserId = 253;
  5886. dic.Add("OP", "");
  5887. dic.Add("OPTel", "");
  5888. //dic.Add("OP", "OP姓名");
  5889. //dic.Add("OPTel", "OP手机号码");
  5890. string countriesStr = "";
  5891. countriesList.ForEach(s => countriesStr += s + "、");
  5892. countriesStr = countriesStr.TrimEnd('、');
  5893. string cityStr = "";
  5894. cityList.ForEach(s => cityStr += s + "、");
  5895. cityStr = cityStr.TrimEnd('、');
  5896. //下方数据
  5897. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5898. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5899. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5900. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5901. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5902. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5903. dic.Add("temperature", "");
  5904. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5905. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5906. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5907. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5908. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5909. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5910. //模板路径
  5911. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5912. //载入模板
  5913. Document doc = null;
  5914. DocumentBuilder builder = null;
  5915. try
  5916. {
  5917. //载入模板
  5918. doc = new Document(tempPath);
  5919. builder = new DocumentBuilder(doc);
  5920. }
  5921. catch (Exception)
  5922. {
  5923. jw.Msg = "模板位置不存在!";
  5924. return Ok(jw);
  5925. }
  5926. foreach (var key in dic.Keys)
  5927. {
  5928. Bookmark bookmark = doc.Range.Bookmarks[key];
  5929. if (bookmark != null)
  5930. {
  5931. builder.MoveToBookmark(key);
  5932. builder.Write(dic[key]);
  5933. }
  5934. }
  5935. //获取word里所有表格
  5936. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5937. //获取所填表格的序数
  5938. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5939. try
  5940. {
  5941. //循环赋值
  5942. for (int i = 0; i < dtSource.Rows.Count; i++)
  5943. {
  5944. builder.MoveToCell(0, i + 1, 0, 0);
  5945. builder.Write(dtSource.Rows[i]["Days"].ToString());
  5946. builder.MoveToCell(0, i + 1, 1, 0);
  5947. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  5948. builder.MoveToCell(0, i + 1, 2, 0);
  5949. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  5950. var trip = dtSource.Rows[i]["Trip"].ToString();
  5951. builder.MoveToCell(0, i + 1, 3, 0);
  5952. builder.Write(trip);
  5953. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  5954. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  5955. // 获取特定索引的段落
  5956. Paragraph paragraph = (Paragraph)paragraphs[0];
  5957. Run run = paragraph.Runs[0];
  5958. Aspose.Words.Font font = run.Font;
  5959. font.Name = "黑体";
  5960. //设置双休红色
  5961. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  5962. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  5963. paragraph = (Paragraph)paragraphs[1];
  5964. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  5965. {
  5966. run = paragraph.Runs[0];
  5967. font = run.Font;
  5968. font.Color = Color.Red;
  5969. }
  5970. }
  5971. }
  5972. catch (Exception ex)
  5973. {
  5974. }
  5975. //删除多余行
  5976. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  5977. {
  5978. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  5979. }
  5980. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  5981. if (!Directory.Exists(savePath))
  5982. {
  5983. try
  5984. {
  5985. Directory.CreateDirectory(savePath);
  5986. }
  5987. catch
  5988. {
  5989. }
  5990. }
  5991. string path = savePath + Find.TeamName + "出访日程.docx";
  5992. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  5993. try
  5994. {
  5995. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  5996. jw = JsonView(true, "导出成功", ftpPath);
  5997. }
  5998. catch (Exception)
  5999. {
  6000. jw = JsonView(false);
  6001. }
  6002. return Ok(jw);
  6003. }
  6004. /// <summary>
  6005. ///根据机票黑屏代码整理DataTable
  6006. /// </summary>
  6007. /// <param name="diid"></param>
  6008. /// <returns></returns>
  6009. DataTable GetTableByBlackCode(int diid)
  6010. {
  6011. //黑屏代码信息
  6012. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6013. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6014. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6015. DataTable dt = new DataTable();
  6016. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6017. dt.Columns.Add("Date", typeof(string));//起飞日期
  6018. dt.Columns.Add("Three", typeof(string));//三字码
  6019. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6020. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6021. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6022. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6023. dt.Columns.Add("AirModel", typeof(string)); //机型
  6024. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6025. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6026. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6027. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6028. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6029. //判断是否录入黑屏代码
  6030. if (listcode.Count() == 0 || listcode == null)
  6031. {
  6032. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6033. }
  6034. else
  6035. {
  6036. //读取单段黑屏代码
  6037. for (int i = 0; i < listcode.Count; i++)
  6038. {
  6039. //去除序号
  6040. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6041. //去除多余空格,方法一Linq扩展方法
  6042. CodeList = CodeList.Where(str => str != "").ToArray();
  6043. CodeList = CodeList.Where(str => str != " ").ToArray();
  6044. //年
  6045. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6046. //读取单条黑屏代码
  6047. for (int j = 0; j < CodeList.Count(); j++)
  6048. {
  6049. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6050. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6051. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6052. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6053. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6054. //去除多余空格
  6055. Info = Info.Where(str => str != "").ToArray();
  6056. Info = Info.Where(str => str != " ").ToArray();
  6057. //判断黑屏代码是否正确拆分; 理应拆成9段
  6058. if (Info.Count() < 9)
  6059. {
  6060. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6061. }
  6062. else
  6063. {
  6064. try
  6065. {
  6066. //月
  6067. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6068. //日
  6069. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6070. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6071. if (j > 0)
  6072. {
  6073. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6074. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6075. Temp = Temp.Where(str => str != "").ToArray();
  6076. Temp = Temp.Where(str => str != " ").ToArray();
  6077. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6078. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6079. if (month - monthTemp < 0)
  6080. {
  6081. year = year + 1;
  6082. }
  6083. //如果相邻代码三字码不顶真,提醒
  6084. string FootThree = Temp[2].Substring(3, 3);
  6085. string HeadThree = Info[2].Substring(0, 3);
  6086. if (FootThree != HeadThree)
  6087. {
  6088. //DelegationInfoService s = new DelegationInfoService();
  6089. //UsersService us = new UsersService();
  6090. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6091. //77 行程
  6092. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6093. foreach (var temp in list2)
  6094. {
  6095. //if (temp.UId != 21)
  6096. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6097. // "黑屏代码提醒",
  6098. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6099. }
  6100. //85 机票预订
  6101. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6102. foreach (var temp in list6)
  6103. {
  6104. //if (temp.UId != 21)
  6105. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6106. // "黑屏代码提醒",
  6107. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6108. }
  6109. }
  6110. }
  6111. #endregion
  6112. #region 判断到达日期是否需要加1
  6113. if (Info[4].Contains("+"))
  6114. {
  6115. //日期+1
  6116. day = day + 1;
  6117. //判断是否进入下一月
  6118. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6119. {
  6120. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6121. month = month + 1;
  6122. //判断是否进入下一年
  6123. if (month > 12)
  6124. {
  6125. month = month - 12;
  6126. year = year + 1;
  6127. }
  6128. }
  6129. //月份整理格式
  6130. string monthTemp = month.ToString();
  6131. if (month < 10)
  6132. {
  6133. monthTemp = "0" + monthTemp;
  6134. }
  6135. //日期整理格式
  6136. string daytemp = day.ToString();
  6137. if (day < 10)
  6138. {
  6139. daytemp = "0" + daytemp;
  6140. }
  6141. string temp = Info[4].Split('+')[0];
  6142. //添加起飞数据
  6143. dt.Rows.Add(Info[0],
  6144. Info[1],
  6145. Info[2],
  6146. Info[3],
  6147. temp,
  6148. Info[5],
  6149. Info[6],
  6150. Info[7],
  6151. Info[8],
  6152. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6153. year + "-" + monthTemp + "-" + daytemp,
  6154. "",
  6155. "0");
  6156. //加1天,添加到达数据
  6157. dt.Rows.Add(Info[0],
  6158. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6159. Info[2],
  6160. Info[3],
  6161. temp,
  6162. Info[5],
  6163. Info[6],
  6164. Info[7],
  6165. Info[8],
  6166. year + "-" + monthTemp + "-" + daytemp,
  6167. year + "-" + monthTemp + "-" + daytemp,
  6168. "",
  6169. "1");
  6170. }
  6171. else
  6172. {
  6173. //月份整理格式
  6174. string monthTemp = month.ToString();
  6175. if (month < 10)
  6176. {
  6177. monthTemp = "0" + monthTemp;
  6178. }
  6179. //日期整理格式
  6180. string daytemp = day.ToString();
  6181. if (day < 10)
  6182. {
  6183. daytemp = "0" + daytemp;
  6184. }
  6185. dt.Rows.Add(Info[0],
  6186. Info[1],
  6187. Info[2],
  6188. Info[3],
  6189. Info[4],
  6190. Info[5],
  6191. Info[6],
  6192. Info[7],
  6193. Info[8],
  6194. year + "-" + monthTemp + "-" + daytemp,
  6195. year + "-" + monthTemp + "-" + daytemp,
  6196. "",
  6197. "0");
  6198. }
  6199. #endregion
  6200. }
  6201. catch (Exception ex)
  6202. {
  6203. string exstr = ex.Message.ToString();
  6204. }
  6205. }
  6206. }
  6207. //排序
  6208. dt.DefaultView.Sort = "Day asc";
  6209. dt = dt.DefaultView.ToTable();
  6210. }
  6211. }
  6212. return dt;
  6213. }
  6214. /// <summary>
  6215. /// 根据团组编号查询信息
  6216. /// </summary>
  6217. /// <returns>返回空或者对象信息</returns>
  6218. List<Grp_TravelList> GetByDiid(int Diid)
  6219. {
  6220. //调用获取单个对象的方法
  6221. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6222. }
  6223. /// <summary>
  6224. /// 20210816
  6225. /// 根据datatable生成某一时间段的日期
  6226. /// </summary>
  6227. /// <param name="dt">黑屏代码生成的datatable</param>
  6228. /// <returns></returns>
  6229. List<string> GetTimeListByDataTable(DataTable dt)
  6230. {
  6231. if (dt.Rows[0]["Day"].ToString() != "")
  6232. {
  6233. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6234. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6235. List<string> timeList = new List<string>();
  6236. while (datestart <= dateend)
  6237. {
  6238. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6239. datestart = datestart.AddDays(1);
  6240. }
  6241. return timeList;
  6242. }
  6243. return null;
  6244. }
  6245. /// <summary>
  6246. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6247. /// </summary>
  6248. /// <param name="num"></param>
  6249. /// <returns></returns>
  6250. string GetNum(string num)
  6251. {
  6252. string str = "";
  6253. switch (num)
  6254. {
  6255. case "1":
  6256. str = "一";
  6257. break;
  6258. case "2":
  6259. str = "二";
  6260. break;
  6261. case "3":
  6262. str = "三";
  6263. break;
  6264. case "4":
  6265. str = "四";
  6266. break;
  6267. case "5":
  6268. str = "五";
  6269. break;
  6270. case "6":
  6271. str = "六";
  6272. break;
  6273. case "7":
  6274. str = "七";
  6275. break;
  6276. case "8":
  6277. str = "八";
  6278. break;
  6279. case "9":
  6280. str = "九";
  6281. break;
  6282. case "10":
  6283. str = "十";
  6284. break;
  6285. case "11":
  6286. str = "十一";
  6287. break;
  6288. case "12":
  6289. str = "十二";
  6290. break;
  6291. case "一":
  6292. str = "1";
  6293. break;
  6294. case "二":
  6295. str = "2";
  6296. break;
  6297. case "三":
  6298. str = "3";
  6299. break;
  6300. case "四":
  6301. str = "4";
  6302. break;
  6303. case "五":
  6304. str = "5";
  6305. break;
  6306. case "六":
  6307. str = "6";
  6308. break;
  6309. case "七":
  6310. str = "7";
  6311. break;
  6312. case "八":
  6313. str = "8";
  6314. break;
  6315. case "九":
  6316. str = "9";
  6317. break;
  6318. case "十":
  6319. str = "10";
  6320. break;
  6321. case "十一":
  6322. str = "11";
  6323. break;
  6324. case "十二":
  6325. str = "12";
  6326. break;
  6327. }
  6328. return str;
  6329. }
  6330. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6331. {
  6332. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6333. }
  6334. /// <summary>
  6335. /// 根据星期,月份的缩写,转换成数字或者全称
  6336. /// 根据币种中文名称返回币种代码
  6337. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6338. /// 20210903贾文滔
  6339. /// </summary>
  6340. /// <param name="startDate"></param>
  6341. /// <param name="endDate"></param>
  6342. /// <returns></returns>
  6343. string GetLonger(string temp)
  6344. {
  6345. string str = "";
  6346. switch (temp.ToUpper())
  6347. {
  6348. case "美元":
  6349. str = "USD";
  6350. break;
  6351. case "日元":
  6352. str = "JPY";
  6353. break;
  6354. case "英镑":
  6355. str = "GBP";
  6356. break;
  6357. case "欧元":
  6358. str = "EUR";
  6359. break;
  6360. case "港币":
  6361. str = "HKD";
  6362. break;
  6363. case "MO":
  6364. str = "星期一";
  6365. break;
  6366. case "TU":
  6367. str = "星期二";
  6368. break;
  6369. case "WE":
  6370. str = "星期三";
  6371. break;
  6372. case "TH":
  6373. str = "星期四";
  6374. break;
  6375. case "FR":
  6376. str = "星期五";
  6377. break;
  6378. case "SA":
  6379. str = "星期六";
  6380. break;
  6381. case "SU":
  6382. str = "星期天";
  6383. break;
  6384. case "JAN":
  6385. str = "01";
  6386. break;
  6387. case "FEB":
  6388. str = "02";
  6389. break;
  6390. case "MAR":
  6391. str = "03";
  6392. break;
  6393. case "APR":
  6394. str = "04";
  6395. break;
  6396. case "MAY":
  6397. str = "05";
  6398. break;
  6399. case "JUN":
  6400. str = "06";
  6401. break;
  6402. case "JUL":
  6403. str = "07";
  6404. break;
  6405. case "AUG":
  6406. str = "08";
  6407. break;
  6408. case "SEP":
  6409. str = "09";
  6410. break;
  6411. case "OCT":
  6412. str = "10";
  6413. break;
  6414. case "NOV":
  6415. str = "11";
  6416. break;
  6417. case "DEC":
  6418. str = "12";
  6419. break;
  6420. case "MONDAY":
  6421. str = "星期一";
  6422. break;
  6423. case "TUESDAY":
  6424. str = "星期二";
  6425. break;
  6426. case "WEDNESDAY":
  6427. str = "星期三";
  6428. break;
  6429. case "THURSDAY":
  6430. str = "星期四";
  6431. break;
  6432. case "FRIDAY":
  6433. str = "星期五";
  6434. break;
  6435. case "SATURDAY":
  6436. str = "星期六";
  6437. break;
  6438. case "SUNDAY":
  6439. str = "星期日";
  6440. break;
  6441. case "01":
  6442. str = "JAN";
  6443. break;
  6444. case "02":
  6445. str = "FEB";
  6446. break;
  6447. case "03":
  6448. str = "MAR";
  6449. break;
  6450. case "04":
  6451. str = "APR";
  6452. break;
  6453. case "05":
  6454. str = "MAY";
  6455. break;
  6456. case "06":
  6457. str = "JUN";
  6458. break;
  6459. case "07":
  6460. str = "JUL";
  6461. break;
  6462. case "08":
  6463. str = "AUG";
  6464. break;
  6465. case "09":
  6466. str = "SEP";
  6467. break;
  6468. case "10":
  6469. str = "OCT";
  6470. break;
  6471. case "11":
  6472. str = "NOV";
  6473. break;
  6474. case "12":
  6475. str = "DEC";
  6476. break;
  6477. case "2":
  6478. str = "空客A";
  6479. break;
  6480. case "3":
  6481. str = "空客A";
  6482. break;
  6483. case "7":
  6484. str = "波音";
  6485. break;
  6486. }
  6487. return str;
  6488. }
  6489. /// <summary>
  6490. /// 根据月份返回天数
  6491. /// </summary>
  6492. /// <param name="temp"></param>
  6493. /// <returns></returns>
  6494. string GetDaysByMonth(string Month, int year)
  6495. {
  6496. string str = "";
  6497. //判断是否是闰年
  6498. if (DateTime.IsLeapYear(year) == false)
  6499. {
  6500. switch (Month.ToUpper())
  6501. {
  6502. case "JAN":
  6503. str = "31";
  6504. break;
  6505. case "FEB":
  6506. str = "28";
  6507. break;
  6508. case "MAR":
  6509. str = "31";
  6510. break;
  6511. case "APR":
  6512. str = "30";
  6513. break;
  6514. case "MAY":
  6515. str = "31";
  6516. break;
  6517. case "JUN":
  6518. str = "30";
  6519. break;
  6520. case "JUL":
  6521. str = "31";
  6522. break;
  6523. case "AUG":
  6524. str = "31";
  6525. break;
  6526. case "SEP":
  6527. str = "30";
  6528. break;
  6529. case "OCT":
  6530. str = "31";
  6531. break;
  6532. case "NOV":
  6533. str = "30";
  6534. break;
  6535. case "DEC":
  6536. str = "31";
  6537. break;
  6538. case "01":
  6539. str = "31";
  6540. break;
  6541. case "02":
  6542. str = "28";
  6543. break;
  6544. case "03":
  6545. str = "31";
  6546. break;
  6547. case "04":
  6548. str = "30";
  6549. break;
  6550. case "05":
  6551. str = "31";
  6552. break;
  6553. case "06":
  6554. str = "30";
  6555. break;
  6556. case "07":
  6557. str = "31";
  6558. break;
  6559. case "08":
  6560. str = "31";
  6561. break;
  6562. case "09":
  6563. str = "30";
  6564. break;
  6565. case "10":
  6566. str = "31";
  6567. break;
  6568. case "11":
  6569. str = "30";
  6570. break;
  6571. case "12":
  6572. str = "31";
  6573. break;
  6574. }
  6575. }
  6576. else
  6577. {
  6578. switch (Month.ToUpper())
  6579. {
  6580. case "JAN":
  6581. str = "31";
  6582. break;
  6583. case "FEB":
  6584. str = "29";
  6585. break;
  6586. case "MAR":
  6587. str = "31";
  6588. break;
  6589. case "APR":
  6590. str = "30";
  6591. break;
  6592. case "MAY":
  6593. str = "31";
  6594. break;
  6595. case "JUN":
  6596. str = "30";
  6597. break;
  6598. case "JUL":
  6599. str = "31";
  6600. break;
  6601. case "AUG":
  6602. str = "31";
  6603. break;
  6604. case "SEP":
  6605. str = "30";
  6606. break;
  6607. case "OCT":
  6608. str = "31";
  6609. break;
  6610. case "NOV":
  6611. str = "30";
  6612. break;
  6613. case "DEC":
  6614. str = "31";
  6615. break;
  6616. case "01":
  6617. str = "31";
  6618. break;
  6619. case "02":
  6620. str = "29";
  6621. break;
  6622. case "03":
  6623. str = "31";
  6624. break;
  6625. case "04":
  6626. str = "30";
  6627. break;
  6628. case "05":
  6629. str = "31";
  6630. break;
  6631. case "06":
  6632. str = "30";
  6633. break;
  6634. case "07":
  6635. str = "31";
  6636. break;
  6637. case "08":
  6638. str = "31";
  6639. break;
  6640. case "09":
  6641. str = "30";
  6642. break;
  6643. case "10":
  6644. str = "31";
  6645. break;
  6646. case "11":
  6647. str = "30";
  6648. break;
  6649. case "12":
  6650. str = "31";
  6651. break;
  6652. }
  6653. }
  6654. return str;
  6655. }
  6656. #endregion
  6657. #endregion
  6658. #region 团组成本
  6659. /// <summary>
  6660. /// 团组成本数据初始化
  6661. /// </summary>
  6662. /// <param name="dto"></param>
  6663. /// <returns></returns>
  6664. [HttpPost]
  6665. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6666. {
  6667. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6668. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6669. WHEN COUNT(*) >= 0 THEN 'True'
  6670. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6671. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6672. ").ToList(); //团组列表
  6673. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6674. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6675. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6676. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6677. if (groupinfoValue != null)
  6678. {
  6679. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6680. var spArr = new string[1] { countryArr };
  6681. if (countryArr.Contains("|"))
  6682. {
  6683. spArr = countryArr.Split("|");
  6684. }
  6685. else if (countryArr.Contains("、"))
  6686. {
  6687. spArr = countryArr.Split("、");
  6688. }
  6689. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6690. {
  6691. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6692. if (dbQueryCountry != null)
  6693. {
  6694. visaCountryInfoArr.Add(dbQueryCountry);
  6695. }
  6696. }
  6697. }
  6698. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6699. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6700. var create = _GroupCostRepository.
  6701. CreateGroupCostByBlackCode(dto.Diid);
  6702. if (groupCost.Count == 0 && create.Code == 0)
  6703. {
  6704. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6705. }
  6706. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6707. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6708. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6709. groupCostMap = groupCostMap.Select(x =>
  6710. {
  6711. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6712. {
  6713. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6714. }
  6715. return x;
  6716. }).ToList();
  6717. //GroupCostParameter.Add(new
  6718. // Grp_GroupCostParameter());
  6719. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6720. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0 ).Count() > 0;
  6721. return Ok(JsonView(new
  6722. {
  6723. groupList,
  6724. groupInfo,
  6725. groupChecks,
  6726. groupCost = groupCostMap,
  6727. hotelNumber,
  6728. GroupCostParameter = GroupCostParameterMap,
  6729. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6730. {
  6731. x.VisaCountry,
  6732. x.VisaPrice,
  6733. x.Id,
  6734. }).ToList(),
  6735. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6736. blackCodeIsTrue = create.Code == 0 ? true : false,
  6737. hotelIsTrue = hotelIsTrue,
  6738. })) ;
  6739. }
  6740. /// <summary>
  6741. /// 团组成本信息保存
  6742. /// </summary>
  6743. /// <param name="dto"></param>
  6744. /// <returns></returns>
  6745. [HttpPost]
  6746. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6747. {
  6748. if (dto.Diid <= 0 || dto.Userid <= 0)
  6749. {
  6750. return Ok(JsonView(false));
  6751. }
  6752. JsonView jw = null;
  6753. bool isTrue = false;
  6754. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6755. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6756. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6757. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6758. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6759. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6760. try
  6761. {
  6762. _sqlSugar.BeginTran();
  6763. isTrue = await _GroupCostRepository.
  6764. SaveGroupCostList(Grp_groups, dto.Diid,dto.Userid); //列表
  6765. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6766. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6767. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6768. _sqlSugar.CommitTran();
  6769. jw = JsonView(true, "保存成功!", isTrue);
  6770. }
  6771. catch (Exception)
  6772. {
  6773. _sqlSugar.RollbackTran();
  6774. jw = JsonView(false);
  6775. }
  6776. return Ok(jw);
  6777. }
  6778. /// <summary>
  6779. /// 司兼导数据
  6780. /// </summary>
  6781. /// <param name="dto"></param>
  6782. /// <returns></returns>
  6783. [HttpPost]
  6784. public IActionResult GetCarGuides(CarGuidesDto dto)
  6785. {
  6786. JsonView jw = null;
  6787. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6788. jw = JsonView(true, "获取成功!", Data);
  6789. return Ok(jw);
  6790. }
  6791. /// <summary>
  6792. /// 导游数据
  6793. /// </summary>
  6794. /// <param name="dto"></param>
  6795. /// <returns></returns>
  6796. [HttpPost]
  6797. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6798. {
  6799. JsonView jw = null;
  6800. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6801. // 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
  6802. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6803. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6804. jw = JsonView(true, "获取成功!", Data);
  6805. return Ok(jw);
  6806. }
  6807. /// <summary>
  6808. /// 成本车数据
  6809. /// </summary>
  6810. /// <param name="dto"></param>
  6811. /// <returns></returns>
  6812. [HttpPost]
  6813. public IActionResult GetCarInfo(CarGuidesDto dto)
  6814. {
  6815. JsonView jw = null;
  6816. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6817. jw = JsonView(true, "获取成功!", Data);
  6818. return Ok(jw);
  6819. }
  6820. /// <summary>
  6821. /// 景点数据
  6822. /// </summary>
  6823. /// <param name="dto"></param>
  6824. /// <returns></returns>
  6825. [HttpPost]
  6826. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6827. {
  6828. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6829. return Ok(JsonView(true, "获取成功!", Data));
  6830. }
  6831. /// <summary>
  6832. /// 成本通知
  6833. /// </summary>
  6834. /// <param name="dto"></param>
  6835. /// <returns></returns>
  6836. [HttpPost]
  6837. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6838. {
  6839. if (dto.Diid < 0)
  6840. {
  6841. return Ok(JsonView(false));
  6842. }
  6843. JsonView jw = null;
  6844. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6845. if (GroupCostParameter != null)
  6846. {
  6847. int IsShare = 0;
  6848. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6849. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6850. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6851. string msg = string.Empty;
  6852. if (isTrue)
  6853. {
  6854. if (IsShare == 0)
  6855. {
  6856. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6857. }
  6858. else
  6859. {
  6860. #region 企微通知对应岗位用户
  6861. try
  6862. {
  6863. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6864. }
  6865. catch (Exception ex)
  6866. {
  6867. }
  6868. #endregion
  6869. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6870. }
  6871. jw = JsonView(isTrue, msg, new { IsShare });
  6872. }
  6873. else
  6874. {
  6875. msg = "修改失败!";
  6876. jw = JsonView(isTrue, msg);
  6877. }
  6878. }
  6879. else
  6880. {
  6881. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6882. }
  6883. return Ok(jw);
  6884. }
  6885. /// <summary>
  6886. /// 导出收款账单
  6887. /// </summary>
  6888. /// <param name="dto"></param>
  6889. /// <returns></returns>
  6890. [HttpPost]
  6891. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6892. {
  6893. if (dto.Diid == 0)
  6894. {
  6895. return Ok(JsonView(false, "请传递团组id"));
  6896. }
  6897. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6898. if (deleInfo.Code != 0)
  6899. {
  6900. return Ok(JsonView(false, "团组信息查询失败!"));
  6901. }
  6902. var di = deleInfo.Data as DelegationInfoWebView;
  6903. if (di != null)
  6904. {
  6905. //文件名
  6906. string strFileName = di.TeamName + "-收款账单.doc";
  6907. //获取模板
  6908. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6909. //载入模板
  6910. Document doc = new Document(tmppath);
  6911. decimal TotalPrice = 0.00M;
  6912. string itemStr = string.Empty;
  6913. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6914. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6915. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6916. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6917. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6918. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6919. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6920. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6921. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6922. foreach (var cost in groupCostType)
  6923. {
  6924. var List = cost.ToList();
  6925. if (cost.Key == "A")
  6926. {
  6927. foreach (var ListItem in List)
  6928. {
  6929. if (ListItem.number > 0)
  6930. {
  6931. if (ListItem.code.Contains("TBR"))
  6932. {
  6933. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6934. }
  6935. else
  6936. {
  6937. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6938. }
  6939. TotalPrice += (ListItem.number * ListItem.price);
  6940. }
  6941. }
  6942. }
  6943. else
  6944. {
  6945. itemStr = itemStr.Insert(0, "A段\r\n");
  6946. itemStr += "B段\r\n";
  6947. foreach (var ListItem in List)
  6948. {
  6949. if (ListItem.number > 0)
  6950. {
  6951. if (ListItem.code.Contains("TBR"))
  6952. {
  6953. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6954. }
  6955. else
  6956. {
  6957. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6958. }
  6959. TotalPrice += (ListItem.number * ListItem.price);
  6960. }
  6961. }
  6962. }
  6963. }
  6964. #region 替换Word模板书签内容
  6965. Dictionary<string, string> marks = new Dictionary<string, string>();
  6966. marks.Add("To", di.ClientUnit);//付款方
  6967. marks.Add("ToTel", di.TellPhone);//付款方电话
  6968. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6969. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6970. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6971. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6972. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6973. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  6974. marks.Add("PayItemContent", itemStr);//详细信息
  6975. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6976. #endregion
  6977. ////注
  6978. //if (doc.Range.Bookmarks["Attention"] != null)
  6979. //{
  6980. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6981. // mark.Text = frList[0].Attention;
  6982. //}
  6983. foreach (var item in marks.Keys)
  6984. {
  6985. if (doc.Range.Bookmarks[item] != null)
  6986. {
  6987. Bookmark mark = doc.Range.Bookmarks[item];
  6988. mark.Text = marks[item];
  6989. }
  6990. }
  6991. byte[] bytes = null;
  6992. using (MemoryStream stream = new MemoryStream())
  6993. {
  6994. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6995. bytes = stream.ToArray();
  6996. }
  6997. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6998. return Ok(JsonView(true, "", new
  6999. {
  7000. Data = bytes,
  7001. strFileName,
  7002. }));
  7003. }
  7004. else
  7005. {
  7006. return Ok(JsonView(false, "团组信息不存在!"));
  7007. }
  7008. }
  7009. /// <summary>
  7010. /// 导出团组成本
  7011. /// </summary>
  7012. /// <param name="dto"></param>
  7013. /// <returns></returns>
  7014. [HttpPost]
  7015. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7016. {
  7017. var jw = JsonView(false);
  7018. if (dto.Diid == 0)
  7019. {
  7020. return Ok(JsonView(false, "请传递团组id"));
  7021. }
  7022. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7023. if (deleInfo.Code != 0)
  7024. {
  7025. return Ok(JsonView(false, "团组信息查询失败!"));
  7026. }
  7027. var di = deleInfo.Data as DelegationInfoWebView;
  7028. if (di == null)
  7029. {
  7030. return Ok(JsonView(false, "团组信息查询失败!"));
  7031. }
  7032. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7033. WorkbookDesigner designer = new WorkbookDesigner();
  7034. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7035. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7036. for (int i = 0; i < List_GC.Count; i++)
  7037. {
  7038. GroupCost_Excel gc = new GroupCost_Excel();
  7039. gc.Id = List_GC[i].Id;
  7040. gc.Diid = List_GC[i].Diid.ToString();
  7041. gc.DAY = List_GC[i].DAY;
  7042. string week = "";
  7043. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7044. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7045. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7046. gc.ITIN = List_GC[i].ITIN;
  7047. gc.CarType = List_GC[i].CarType;
  7048. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7049. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7050. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7051. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7052. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7053. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7054. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7055. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7056. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7057. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7058. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7059. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7060. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7061. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7062. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7063. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7064. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7065. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7066. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7067. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7068. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7069. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7070. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7071. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7072. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7073. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7074. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7075. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7076. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7077. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7078. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7079. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7080. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7081. List_GC1.Add(gc);
  7082. }
  7083. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7084. dt.TableName = "TB";
  7085. //报表标题等不用dt的值
  7086. designer.SetDataSource("TeamName", dto.title.TeamName);
  7087. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7088. designer.SetDataSource("Tax", dto.title.Tax);
  7089. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7090. designer.SetDataSource("Currency", dto.title.Currency);
  7091. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7092. designer.SetDataSource("Rate", dto.title.Rate);
  7093. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7094. var Aparams = hotels.Find(x => x.Type == "Default");
  7095. if (Aparams == null)
  7096. {
  7097. return Ok(jw);
  7098. }
  7099. //酒店数量
  7100. var txtSGRNumber = Aparams.SGR.ToString();
  7101. var txtTBRNumber = Aparams.TBR.ToString();
  7102. var txtJSESNumber = Aparams.JSES.ToString();
  7103. var txtSUITENumbe = Aparams.SUITE.ToString();
  7104. if (dto.costType == "B")
  7105. {
  7106. Aparams = hotels.Find(x => x.Type == "A");
  7107. var Bparams = hotels.Find(x => x.Type == "B");
  7108. if (Aparams == null || Bparams == null)
  7109. {
  7110. return Ok(jw);
  7111. }
  7112. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7113. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7114. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7115. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7116. }
  7117. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7118. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7119. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7120. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7121. var ws = designer.Workbook.Worksheets[0];
  7122. int Row = List_GC.Count;
  7123. int startIndex = 11;
  7124. int HideRows = 0;
  7125. List<int> hideRowsList = new List<int>();
  7126. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7127. #region A段left数据
  7128. var left = dto.leftInfo.Find(x => x.Type == "A");
  7129. if (left == null)
  7130. {
  7131. return Ok(jw);
  7132. }
  7133. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7134. if (leftBindData != null)
  7135. {
  7136. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7137. designer.SetDataSource("VisaRS", leftBindData.rs);
  7138. designer.SetDataSource("VisaXS", leftBindData.xs);
  7139. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7140. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7141. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7142. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7143. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7144. }
  7145. else
  7146. {
  7147. hideRowsList.Add(Row + startIndex + HideRows);
  7148. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7149. }
  7150. HideRows += 2;
  7151. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7152. if (leftBindData != null)
  7153. {
  7154. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7155. designer.SetDataSource("BXRS", leftBindData.rs);
  7156. designer.SetDataSource("BXXS", leftBindData.xs);
  7157. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7158. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7159. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7160. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7161. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7162. }
  7163. else
  7164. {
  7165. hideRowsList.Add(Row + startIndex + HideRows);
  7166. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7167. }
  7168. HideRows += 2;
  7169. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7170. if (leftBindData != null)
  7171. {
  7172. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7173. designer.SetDataSource("HSRS", leftBindData.rs);
  7174. designer.SetDataSource("HSXS", leftBindData.xs);
  7175. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7176. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7177. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7178. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7179. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7180. }
  7181. else
  7182. {
  7183. hideRowsList.Add(Row + startIndex + HideRows);
  7184. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7185. }
  7186. HideRows += 2;
  7187. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7188. if (leftBindData != null)
  7189. {
  7190. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7191. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7192. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7193. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7194. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7195. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7196. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7197. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7198. }
  7199. else
  7200. {
  7201. hideRowsList.Add(Row + startIndex + HideRows);
  7202. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7203. }
  7204. HideRows += 2;
  7205. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7206. if (leftBindData != null)
  7207. {
  7208. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7209. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7210. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7211. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7212. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7213. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7214. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7215. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7216. }
  7217. else
  7218. {
  7219. hideRowsList.Add(Row + startIndex + HideRows);
  7220. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7221. }
  7222. HideRows += 2;
  7223. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7224. if (leftBindData != null)
  7225. {
  7226. ////TBR
  7227. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7228. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7229. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7230. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7231. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7232. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7233. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7234. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7235. }
  7236. else
  7237. {
  7238. hideRowsList.Add(Row + startIndex + HideRows);
  7239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7240. }
  7241. HideRows += 2;
  7242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7243. if (leftBindData != null)
  7244. {
  7245. ////SGR
  7246. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7247. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7248. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7249. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7250. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7251. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7252. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7253. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7254. }
  7255. else
  7256. {
  7257. hideRowsList.Add(Row + startIndex + HideRows);
  7258. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7259. }
  7260. HideRows += 2;
  7261. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7262. if (leftBindData != null)
  7263. {
  7264. ////JS/ES
  7265. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7266. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7267. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7268. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7269. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7270. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7271. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7272. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7273. }
  7274. else
  7275. {
  7276. hideRowsList.Add(Row + startIndex + HideRows);
  7277. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7278. }
  7279. HideRows += 2;
  7280. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7281. if (leftBindData != null)
  7282. {
  7283. ////SUITE
  7284. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7285. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7286. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7287. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7288. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7289. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7290. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7291. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7292. }
  7293. else
  7294. {
  7295. hideRowsList.Add(Row + startIndex + HideRows);
  7296. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7297. }
  7298. HideRows += 2;
  7299. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7300. if (leftBindData != null)
  7301. {
  7302. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7303. designer.SetDataSource("DJRS", leftBindData.rs);
  7304. designer.SetDataSource("DJXS", leftBindData.xs);
  7305. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7306. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7307. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7308. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7309. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7310. }
  7311. else
  7312. {
  7313. hideRowsList.Add(Row + startIndex + HideRows);
  7314. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7315. }
  7316. HideRows += 2;
  7317. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7318. if (leftBindData != null)
  7319. {
  7320. designer.SetDataSource("HCPCB", leftBindData.cb);
  7321. designer.SetDataSource("HCPRS", leftBindData.rs);
  7322. designer.SetDataSource("HCPXS", leftBindData.xs);
  7323. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7324. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7325. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7326. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7327. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7328. }
  7329. else
  7330. {
  7331. hideRowsList.Add(Row + startIndex + HideRows);
  7332. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7333. }
  7334. HideRows += 2;
  7335. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7336. if (leftBindData != null)
  7337. {
  7338. designer.SetDataSource("CPCB", leftBindData.cb);
  7339. designer.SetDataSource("CPRS", leftBindData.rs);
  7340. designer.SetDataSource("CPXS", leftBindData.xs);
  7341. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7342. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7343. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7344. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7345. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7346. }
  7347. else
  7348. {
  7349. hideRowsList.Add(Row + startIndex + HideRows);
  7350. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7351. }
  7352. HideRows += 2;
  7353. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7354. if (leftBindData != null)
  7355. {
  7356. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7357. designer.SetDataSource("GWRS", leftBindData.rs);
  7358. designer.SetDataSource("GWXS", leftBindData.xs);
  7359. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7360. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7361. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7362. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7363. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7364. }
  7365. else
  7366. {
  7367. hideRowsList.Add(Row + startIndex + HideRows);
  7368. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7369. }
  7370. HideRows += 2;
  7371. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7372. if (leftBindData != null)
  7373. {
  7374. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7375. designer.SetDataSource("LYJRS", leftBindData.rs);
  7376. designer.SetDataSource("LYJXS", leftBindData.xs);
  7377. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7378. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7379. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7380. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7381. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7382. }
  7383. else
  7384. {
  7385. hideRowsList.Add(Row + startIndex + HideRows);
  7386. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7387. }
  7388. #endregion
  7389. #region A段Right信息
  7390. var right = dto.rightInfo.Find(x => x.Type == "A");
  7391. if (right == null)
  7392. {
  7393. return Ok(jw);
  7394. }
  7395. HideRows += 4;
  7396. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7397. if (rightBindData != null)
  7398. {
  7399. //经济舱 + 双人间 TBR
  7400. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7401. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7402. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7403. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7404. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7405. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7406. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7410. }
  7411. else
  7412. {
  7413. hideRowsList.Add(Row + startIndex + HideRows);
  7414. }
  7415. HideRows += 2;
  7416. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7417. if (rightBindData != null)
  7418. {
  7419. //经济舱 + 单人间 SGR
  7420. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7421. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7422. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7423. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7424. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7425. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7426. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7430. }
  7431. else
  7432. {
  7433. hideRowsList.Add(Row + startIndex + HideRows);
  7434. }
  7435. HideRows += 2;
  7436. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7437. if (rightBindData != null)
  7438. {
  7439. //公务舱 + 单人间 SGR
  7440. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7441. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7442. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7443. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7444. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7445. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7446. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7447. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7448. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7449. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7450. }
  7451. else
  7452. {
  7453. hideRowsList.Add(Row + startIndex + HideRows);
  7454. }
  7455. HideRows += 2;
  7456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7457. if (rightBindData != null)
  7458. {
  7459. //公务舱 + 小套房 JSES
  7460. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7461. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7462. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7463. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7464. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7465. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7466. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7470. }
  7471. else
  7472. {
  7473. hideRowsList.Add(Row + startIndex + HideRows);
  7474. }
  7475. HideRows += 2;
  7476. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7477. if (rightBindData != null)
  7478. {
  7479. //公务舱 + 小套房 JSES
  7480. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7481. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7482. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7483. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7484. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7485. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7486. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7487. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7488. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7489. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7490. }
  7491. else
  7492. {
  7493. hideRowsList.Add(Row + startIndex + HideRows);
  7494. }
  7495. HideRows += 2;
  7496. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7497. if (rightBindData != null)
  7498. {
  7499. //经济舱 + 大套房
  7500. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7501. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7502. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7503. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7504. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7505. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7506. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7507. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7508. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7509. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7510. }
  7511. else
  7512. {
  7513. hideRowsList.Add(Row + startIndex + HideRows);
  7514. }
  7515. #endregion
  7516. #region B段标题清空
  7517. designer.SetDataSource("CostBDRCB", "");
  7518. designer.SetDataSource("CostBRS", "");
  7519. designer.SetDataSource("CostBXS", "");
  7520. designer.SetDataSource("CostBZCB", "");
  7521. designer.SetDataSource("CostBDRBJ", "");
  7522. designer.SetDataSource("CostBZBJ", "");
  7523. designer.SetDataSource("CostBDRLR", "");
  7524. designer.SetDataSource("CostBZLR", "");
  7525. designer.SetDataSource("CostBDRCBOM", "");
  7526. designer.SetDataSource("CostBRSOM", "");
  7527. designer.SetDataSource("CostBZCBOM", "");
  7528. designer.SetDataSource("CostBDRBJOM", "");
  7529. designer.SetDataSource("CostBZBJOM", "");
  7530. designer.SetDataSource("CostBDRLROM", "");
  7531. designer.SetDataSource("CostBZLROM", "");
  7532. #endregion
  7533. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7534. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7535. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7536. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7537. designer.SetDataSource("DJName", "地接(CNY)");
  7538. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7539. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7540. designer.SetDataSource("GWName", "公务(CNY)");
  7541. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7542. designer.SetDataSource("LYJName", "零用金(CNY)");
  7543. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7544. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7545. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7546. designer.SetDataSource("BXName", "保险(CNY)");
  7547. designer.SetDataSource("VisaName", "签证(CNY)");
  7548. #region B段基本数据
  7549. if (dto.costType == "B")
  7550. {
  7551. left = dto.leftInfo.Find(x => x.Type == "B");
  7552. if (left == null)
  7553. {
  7554. return Ok(jw);
  7555. }
  7556. #region B段left数据
  7557. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7558. if (leftBindData != null)
  7559. {
  7560. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7561. designer.SetDataSource("BHSRS", leftBindData.rs);
  7562. designer.SetDataSource("BHSXS", leftBindData.xs);
  7563. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7564. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7565. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7566. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7567. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7568. }
  7569. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7570. if (leftBindData != null)
  7571. {
  7572. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7573. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7574. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7575. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7576. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7577. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7578. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7579. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7580. }
  7581. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7582. if (leftBindData != null)
  7583. {
  7584. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7585. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7586. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7587. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7588. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7589. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7590. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7591. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7592. }
  7593. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7594. if (leftBindData != null)
  7595. {
  7596. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7597. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7598. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7599. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7600. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7601. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7602. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7603. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7604. }
  7605. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7606. if (leftBindData != null)
  7607. {
  7608. designer.SetDataSource("BCPCB", leftBindData.cb);
  7609. designer.SetDataSource("BCPRS", leftBindData.rs);
  7610. designer.SetDataSource("BCPXS", leftBindData.xs);
  7611. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7612. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7613. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7614. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7615. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7616. }
  7617. //TBR
  7618. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7619. if (leftBindData != null)
  7620. {
  7621. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7622. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7623. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7624. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7625. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7626. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7627. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7628. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7629. }
  7630. //SGR
  7631. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7632. if (leftBindData != null)
  7633. {
  7634. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7635. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7636. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7637. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7638. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7639. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7640. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7641. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7642. }
  7643. //JS/ES
  7644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7645. if (leftBindData != null)
  7646. {
  7647. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7648. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7649. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7650. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7651. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7652. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7653. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7654. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7655. }
  7656. //SUITE
  7657. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7658. if (leftBindData != null)
  7659. {
  7660. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7661. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7662. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7663. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7664. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7665. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7666. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7667. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7668. }
  7669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7670. if (leftBindData != null)
  7671. {
  7672. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7673. designer.SetDataSource("BDJRS", leftBindData.rs);
  7674. designer.SetDataSource("BDJXS", leftBindData.xs);
  7675. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7676. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7677. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7678. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7679. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7680. }
  7681. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7682. if (leftBindData != null)
  7683. {
  7684. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7685. designer.SetDataSource("BGWRS", leftBindData.rs);
  7686. designer.SetDataSource("BGWXS", leftBindData.xs);
  7687. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7688. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7689. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7690. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7691. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7692. }
  7693. #region 优化方案
  7694. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7695. //excelBind.Add("零用金", new {
  7696. //cb="",
  7697. //rs="",
  7698. //xs ="",
  7699. //zcb = "",
  7700. //});
  7701. #endregion
  7702. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7703. if (leftBindData != null)
  7704. {
  7705. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7706. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7707. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7708. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7709. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7710. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7711. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7712. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7713. }
  7714. #endregion
  7715. #region B段Right信息
  7716. right = dto.rightInfo.Find(x => x.Type == "B");
  7717. if (right == null)
  7718. {
  7719. return Ok(jw);
  7720. }
  7721. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7722. if (rightBindData != null)
  7723. {
  7724. //经济舱 + 双人间 TBR
  7725. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7726. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7727. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7728. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7729. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7730. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7731. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7732. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7733. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7734. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7735. }
  7736. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7737. if (rightBindData != null)
  7738. {
  7739. //经济舱 + 单人间 SGR
  7740. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7741. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7742. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7743. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7744. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7745. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7746. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7747. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7748. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7749. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7750. }
  7751. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7752. if (rightBindData != null)
  7753. {
  7754. //公务舱 + 单人间 SGR
  7755. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7756. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7757. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7758. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7759. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7760. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7761. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7762. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7763. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7764. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7765. }
  7766. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7767. if (rightBindData != null)
  7768. {
  7769. //公务舱 + 小套房 JSES
  7770. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7771. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7772. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7773. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7774. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7775. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7776. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7777. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7778. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7779. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7780. }
  7781. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7782. if (rightBindData != null)
  7783. {
  7784. //公务舱 + 小套房 JSES
  7785. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7786. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7787. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7788. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7789. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7790. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7791. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7792. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7793. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7794. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7795. }
  7796. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7797. if (rightBindData != null)
  7798. {
  7799. //经济舱 + 大套房
  7800. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7801. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7802. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7803. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7804. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7805. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7806. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7807. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7808. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7809. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7810. }
  7811. #endregion
  7812. #region 标题
  7813. designer.SetDataSource("CostBDRCB", "单人成本");
  7814. designer.SetDataSource("CostBRS", "人数");
  7815. designer.SetDataSource("CostBXS", "系数");
  7816. designer.SetDataSource("CostBZCB", "总成本");
  7817. designer.SetDataSource("CostBDRBJ", "单人报价");
  7818. designer.SetDataSource("CostBZBJ", "总报价");
  7819. designer.SetDataSource("CostBDRLR", "单人利润");
  7820. designer.SetDataSource("CostBZLR", "总利润");
  7821. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7822. designer.SetDataSource("CostBRSOM", "人数");
  7823. designer.SetDataSource("CostBZCBOM", "总成本");
  7824. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7825. designer.SetDataSource("CostBZBJOM", "总报价");
  7826. designer.SetDataSource("CostBDRLROM", "单人利润");
  7827. designer.SetDataSource("CostBZLROM", "总利润");
  7828. #endregion
  7829. }
  7830. #endregion
  7831. designer.SetDataSource("TzZCB2", TzZCB2);
  7832. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7833. designer.SetDataSource("TzZLR2", TzZLR2);
  7834. string[] dataSourceKeys = new string[]
  7835. {
  7836. "VF",
  7837. "TGS",
  7838. "TGOF",
  7839. "TGM",
  7840. "TGA",
  7841. "TGTF",
  7842. "TGEF",
  7843. "CFM",
  7844. "CFOF",
  7845. "B",
  7846. "L",
  7847. "D",
  7848. "TBR",
  7849. "SGR",
  7850. "JSES",
  7851. "Suite",
  7852. "TV",
  7853. "1L",
  7854. "IF",
  7855. "EF",
  7856. "BRF",
  7857. "TE",
  7858. "TGT",
  7859. "DRVT",
  7860. "PC",
  7861. "TLF",
  7862. "ECT"
  7863. };
  7864. foreach (var item in dataSourceKeys)
  7865. {
  7866. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7867. if (find != null)
  7868. {
  7869. designer.SetDataSource(item, find.text);
  7870. }
  7871. else
  7872. {
  7873. designer.SetDataSource(item, 0);
  7874. }
  7875. }
  7876. designer.SetDataSource(dt);
  7877. //根据数据源处理生成报表内容
  7878. designer.Process();
  7879. designer.Workbook.Worksheets[0].Name = "清单";
  7880. Worksheet sheet = designer.Workbook.Worksheets[0];
  7881. foreach (var Rowindex in hideRowsList)
  7882. {
  7883. ws.Cells.HideRows(Rowindex, 2);
  7884. }
  7885. byte[] bytes = null;
  7886. string strFileName = di.TeamName + "-团组-成本.xls";
  7887. using (MemoryStream stream = new MemoryStream())
  7888. {
  7889. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7890. bytes = stream.ToArray();
  7891. }
  7892. return Ok(JsonView(true, "", new
  7893. {
  7894. Data = bytes,
  7895. strFileName,
  7896. }));
  7897. }
  7898. /// <summary>
  7899. /// 导出客户报表
  7900. /// </summary>
  7901. /// <returns></returns>
  7902. [HttpPost]
  7903. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7904. {
  7905. var jw = JsonView(false);
  7906. if (dto.Diid == 0)
  7907. {
  7908. return Ok(JsonView(false, "请传递团组id"));
  7909. }
  7910. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7911. if (deleInfo.Code != 0)
  7912. {
  7913. return Ok(JsonView(false, "团组信息查询失败!"));
  7914. }
  7915. var di = deleInfo.Data as DelegationInfoWebView;
  7916. if (di == null)
  7917. {
  7918. return Ok(JsonView(false, "团组信息查询失败!"));
  7919. }
  7920. //文件名
  7921. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7922. //获取模板
  7923. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7924. //载入模板
  7925. Document doc = new Document(tmppath);
  7926. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7927. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7928. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7929. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7930. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7931. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7932. if (AParameter == null)
  7933. {
  7934. return Ok(JsonView(false, "系数不存在!"));
  7935. }
  7936. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7937. , TzAirDesc, TzZCost;
  7938. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7939. = TzAirDesc = TzZCost = string.Empty;
  7940. TzNumber = AParameter.CostTypenumber.ToString();
  7941. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7942. CarGuides1 = dto.CarGuides1;
  7943. Meal = dto.Meal;
  7944. SubsidizedMeals = dto.SubsidizedMeals;
  7945. NightRepair = dto.NightRepair;
  7946. AttractionsTickets = dto.AttractionsTickets;
  7947. MiscellaneousFees = dto.MiscellaneousFees;
  7948. ATip = dto.ATip;
  7949. TzHotelDesc = "";
  7950. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7951. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7952. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7953. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7954. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7955. TzAirDesc = "";
  7956. TzZCost = dto.TzZCost;
  7957. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7958. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7959. var index = 1;
  7960. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7961. foreach (var item in TzHotelDescArr)
  7962. {
  7963. if (AinfoArr != null)
  7964. {
  7965. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7966. if (Ainfo != null)
  7967. {
  7968. if (int.Parse(Ainfo.rs) <= 0)
  7969. {
  7970. continue;
  7971. }
  7972. var hotelText = string.Empty;
  7973. switch (item)
  7974. {
  7975. case "SGR":
  7976. hotelText = "单人间";
  7977. break;
  7978. case "JSES":
  7979. hotelText = "小套房";
  7980. break;
  7981. case "SUITE":
  7982. hotelText = "套房";
  7983. break;
  7984. case "TBR":
  7985. hotelText = "双人间";
  7986. break;
  7987. }
  7988. if (item != "TBR")
  7989. {
  7990. 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";
  7991. }
  7992. else
  7993. {
  7994. 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";
  7995. }
  7996. index++;
  7997. }
  7998. }
  7999. }
  8000. index = 1;
  8001. foreach (var item in TzAirDescArr)
  8002. {
  8003. if (AinfoArr != null)
  8004. {
  8005. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8006. if (Ainfo != null)
  8007. {
  8008. if (int.Parse(Ainfo.rs) <= 0)
  8009. {
  8010. continue;
  8011. }
  8012. 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";
  8013. index++;
  8014. }
  8015. }
  8016. }
  8017. if (dto.costType == "B")
  8018. {
  8019. if (BParameter == null)
  8020. {
  8021. return Ok(JsonView(false, "B段系数不存在!"));
  8022. }
  8023. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8024. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8025. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8026. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8027. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8028. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8029. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8030. foreach (var item in TzHotelDescArr)
  8031. {
  8032. if (AinfoArr != null)
  8033. {
  8034. TzHotelDesc += "B段信息 \r\n";
  8035. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8036. if (Ainfo != null)
  8037. {
  8038. if (int.Parse(Ainfo.rs) <= 0)
  8039. {
  8040. continue;
  8041. }
  8042. var hotelText = string.Empty;
  8043. switch (item)
  8044. {
  8045. case "SGR":
  8046. hotelText = "单人间";
  8047. break;
  8048. case "JSES":
  8049. hotelText = "小套房";
  8050. break;
  8051. case "SUITE":
  8052. hotelText = "套房";
  8053. break;
  8054. case "TBR":
  8055. hotelText = "双人间";
  8056. break;
  8057. }
  8058. if (item != "TBR")
  8059. {
  8060. 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";
  8061. }
  8062. else
  8063. {
  8064. 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";
  8065. }
  8066. index++;
  8067. }
  8068. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8069. }
  8070. }
  8071. index = 1;
  8072. foreach (var item in TzAirDescArr)
  8073. {
  8074. if (AinfoArr != null)
  8075. {
  8076. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8077. if (Ainfo != null)
  8078. {
  8079. if (int.Parse(Ainfo.rs) <= 0)
  8080. {
  8081. continue;
  8082. }
  8083. 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";
  8084. index++;
  8085. }
  8086. }
  8087. }
  8088. }
  8089. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8090. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8091. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8092. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8093. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8094. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8095. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8096. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8097. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8098. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8099. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8100. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8101. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8102. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8103. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8104. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8105. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8106. DickeyValue.Add("TzZCost", TzZCost);
  8107. foreach (var key in DickeyValue.Keys)
  8108. {
  8109. if (doc.Range.Bookmarks[key] != null)
  8110. {
  8111. Bookmark mark = doc.Range.Bookmarks[key];
  8112. mark.Text = DickeyValue[key];
  8113. }
  8114. }
  8115. byte[] bytes = null;
  8116. string strFileName = di.TeamName + "-客户报价.doc";
  8117. using (MemoryStream stream = new MemoryStream())
  8118. {
  8119. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8120. bytes = stream.ToArray();
  8121. }
  8122. return Ok(JsonView(true, "", new
  8123. {
  8124. Data = bytes,
  8125. strFileName,
  8126. }));
  8127. }
  8128. /// <summary>
  8129. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8130. /// </summary>
  8131. /// <param name="dto"></param>
  8132. /// <returns></returns>
  8133. [HttpPost]
  8134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8135. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8136. {
  8137. try
  8138. {
  8139. #region 参数验证
  8140. if (dto.DiId < 0)
  8141. {
  8142. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8143. }
  8144. List<int> cTableIds = new List<int>() {
  8145. 76 ,//酒店预订
  8146. 77 ,//行程
  8147. 79 ,//车/导游地接
  8148. 80 ,//签证
  8149. 81 ,//邀请/公务活
  8150. 82 ,//团组客户保险
  8151. 85 ,//机票预订
  8152. 98 ,//其他款项
  8153. 285 ,//收款退还
  8154. 751 ,//酒店早餐
  8155. 1015 // 超支费用
  8156. };
  8157. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8158. {
  8159. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8160. }
  8161. #endregion
  8162. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8163. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8164. if (_GroupCostParameters.Count <= 0)
  8165. {
  8166. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8167. }
  8168. if (_GroupCostParameters[0].IsShare == 0)
  8169. {
  8170. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8171. }
  8172. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8173. //处理date为空问题
  8174. if (_GroupCosts.Count > 0)
  8175. {
  8176. for (int i = 0; i < _GroupCosts.Count; i++)
  8177. {
  8178. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8179. {
  8180. if (i > 0)
  8181. {
  8182. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8183. }
  8184. }
  8185. }
  8186. }
  8187. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8188. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8189. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8190. string currCode = "";
  8191. #region currCode 验证
  8192. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8193. if (isInt)
  8194. {
  8195. var currData = currDatas.Find(it => it.Id == intCurrency);
  8196. if (currData != null)
  8197. {
  8198. currCode = currData.Name;
  8199. }
  8200. }
  8201. else
  8202. {
  8203. currCode = _GroupCostParameters[0].Currency.Trim();
  8204. }
  8205. #endregion
  8206. //op,酒店单段模式存储
  8207. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8208. {
  8209. CurrencyCode = currCode,
  8210. Rate = _GroupCostParameters[0].Rate,
  8211. CostType = _GroupCostParameters[0].CostType,
  8212. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8213. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8214. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8215. };
  8216. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8217. if (_GroupCostParameters.Count == 2)
  8218. {
  8219. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8220. }
  8221. foreach (var item in _GroupCostParameters)
  8222. {
  8223. decimal _rate = 1;
  8224. decimal _rate1 = item.Rate;
  8225. decimal _scale = 1;
  8226. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8227. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8228. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8229. //if (userInfo != null)
  8230. //{
  8231. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8232. // {
  8233. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8234. // {
  8235. // _scale = 1.00M;
  8236. // }
  8237. // }
  8238. //}
  8239. #endregion
  8240. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8241. {
  8242. CurrencyCode = currCode,
  8243. Rate = _rate1,
  8244. CostType = item.CostType,
  8245. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8246. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8247. CostTypeNumber = item.CostTypenumber
  8248. };
  8249. if (_GroupCostParameters.Count > 1)
  8250. {
  8251. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8252. }
  8253. else
  8254. {
  8255. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8256. }
  8257. if (dto.CTable == 79)//
  8258. {
  8259. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8260. modulePromptInfo.TotalCost = item.DJCB;
  8261. }
  8262. List<string> costTypes = new List<string>() { "A", "B" };
  8263. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8264. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8265. if (_GroupCostsDuplicates.Count() == 1)
  8266. {
  8267. _GroupCostsTypeData = _GroupCosts;
  8268. }
  8269. else
  8270. {
  8271. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8272. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8273. }
  8274. /*
  8275. * 76 酒店预订
  8276. * 77 行程
  8277. * 79 车/导游地接
  8278. * 80 签证
  8279. * 81 邀请/公务活动
  8280. * 82 团组客户保险
  8281. * 85 机票预订
  8282. * 98 其他款项
  8283. * 285 收款退还
  8284. * 751 酒店早餐
  8285. * 1015 超支费用
  8286. */
  8287. switch (dto.CTable)
  8288. {
  8289. case 76: // 酒店预订
  8290. _ModuleSubPromptInfo.AddRange(
  8291. _GroupCostsTypeData.Select(it => new
  8292. {
  8293. it.DAY,
  8294. it.Date,
  8295. it.ACCON,
  8296. it.ITIN,
  8297. it.SGR,
  8298. it.TBR,
  8299. it.JS_ES,
  8300. it.Suite
  8301. })
  8302. );
  8303. break;
  8304. case 79: // 车/导游地接
  8305. _ModuleSubPromptInfo.AddRange(
  8306. _GroupCostsTypeData.Select(it => new
  8307. {
  8308. Date = it.Date, //日期
  8309. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8310. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8311. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8312. TicketFee = it.EF * _rate * _scale, //门票费
  8313. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8314. AirportTransferFee = 0.00M,
  8315. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8316. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8317. LeadersFee = it.TLF * _rate * _scale, //领队费
  8318. CarFee1 = it.CarCost * _rate * _scale,
  8319. CarType = it.CarType, //车型
  8320. SpentCash = it.PC * _rate * _scale, //零用金
  8321. })
  8322. );
  8323. break;
  8324. case 85: // 机票
  8325. List<dynamic> datas = new List<dynamic>();
  8326. datas.Add(
  8327. new
  8328. {
  8329. AirType = "经济舱",
  8330. AirNum = item.JJCRS,
  8331. AirDRCB = item.JJCCB,
  8332. AirZCB = (item.JJCRS * item.JJCCB)
  8333. }
  8334. );
  8335. datas.Add(
  8336. new
  8337. {
  8338. AirType = "公务舱",
  8339. AirNum = item.GWCRS,
  8340. AirDRCB = item.GWCCB,
  8341. AirZCB = (item.GWCRS * item.GWCCB)
  8342. }
  8343. );
  8344. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8345. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8346. modulePromptInfo.Data = new {
  8347. airFeeData = datas,
  8348. airInitData = initDatas
  8349. };
  8350. _ModulePromptInfos.Add(modulePromptInfo);
  8351. break;
  8352. default:
  8353. break;
  8354. }
  8355. }
  8356. if (dto.CTable != 85)
  8357. {
  8358. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8359. _ModulePromptInfos.Add(_ModulePromptInfo);
  8360. }
  8361. _view.ModulePromptInfos = _ModulePromptInfos;
  8362. return Ok(JsonView(true, "操作成功!", _view));
  8363. }
  8364. catch (Exception ex)
  8365. {
  8366. return Ok(JsonView(false, ex.Message));
  8367. }
  8368. }
  8369. /// <summary>
  8370. /// 根据黑屏代码重新生成行程
  8371. /// </summary>
  8372. /// <param name="dto"></param>
  8373. /// <returns></returns>
  8374. [HttpPost]
  8375. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8376. {
  8377. var jw = JsonView(false);
  8378. var Create =_GroupCostRepository.
  8379. CreateGroupCostByBlackCode(dto.Diid);
  8380. jw.Msg = Create.Msg;
  8381. if (Create.Code == 0)
  8382. {
  8383. jw.Code = 200;
  8384. jw.Data = new
  8385. {
  8386. groupCost = Create.Data,
  8387. blackCodeIsTrue = true
  8388. };
  8389. }
  8390. else
  8391. {
  8392. jw.Code = 400;
  8393. jw.Data = new
  8394. {
  8395. groupCost = Create.Data,
  8396. blackCodeIsTrue = false,
  8397. };
  8398. }
  8399. return Ok(jw);
  8400. }
  8401. /// <summary>
  8402. /// 成本获取OP历史车费用
  8403. /// </summary>
  8404. /// <param name="dto"></param>
  8405. /// <returns></returns>
  8406. [HttpPost]
  8407. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8408. {
  8409. var jw = JsonView(false);
  8410. try
  8411. {
  8412. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8413. //获取现有所有车的数据
  8414. if (!dto.Param.IsNullOrWhiteSpace())
  8415. {
  8416. string sql = $@"
  8417. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8418. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8419. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8420. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  8421. AND gctggr.ServiceEndTime is not NULL
  8422. ORDER by gctggrc.id DESC
  8423. ";
  8424. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8425. var numeberResult = await Task.Run(() =>
  8426. {
  8427. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8428. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8429. return numberArr;
  8430. });
  8431. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8432. foreach (var item in numeberResult)
  8433. {
  8434. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8435. {
  8436. Country = "数据异常!",
  8437. City = string.Empty,
  8438. };
  8439. item.Area = find.Country + " " + find.City;
  8440. }
  8441. dbResult.AddRange(numeberResult);
  8442. if (dto.Param.Contains("、"))
  8443. {
  8444. var sp = dto.Param.Split("、");
  8445. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8446. .Where(x =>
  8447. {
  8448. return System.Array.Exists(sp, e =>
  8449. {
  8450. bool where = false;
  8451. if (x.Area != null)
  8452. {
  8453. where = x.Area.Contains(e);
  8454. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8455. {
  8456. return false;
  8457. }
  8458. }
  8459. if (x.PriceName != null && !where)
  8460. {
  8461. where = x.PriceName.Contains(e);
  8462. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8463. {
  8464. return false;
  8465. }
  8466. }
  8467. return where;
  8468. });
  8469. }).ToList();
  8470. }
  8471. else
  8472. {
  8473. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8474. .Where(x =>
  8475. {
  8476. bool where = false;
  8477. if (x.Area != null)
  8478. {
  8479. where = x.Area.Contains(dto.Param);
  8480. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8481. {
  8482. return false;
  8483. }
  8484. }
  8485. if (x.PriceName != null && !where)
  8486. {
  8487. where = x.PriceName.Contains(dto.Param);
  8488. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8489. {
  8490. return false;
  8491. }
  8492. }
  8493. return where;
  8494. }
  8495. )
  8496. .ToList();
  8497. }
  8498. }
  8499. var view = dbResult.Select(x => {
  8500. decimal dp = 0.00M;
  8501. var startB = DateTime.TryParse(x.Start.ToString(),out DateTime startD);
  8502. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8503. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8504. {
  8505. if (startB && endB)
  8506. {
  8507. var timesp = endD.Subtract(startD);
  8508. if ((timesp.Days + 1) != 0 )
  8509. {
  8510. dp = x.Price / (timesp.Days + 1);
  8511. }
  8512. }
  8513. }
  8514. else
  8515. {
  8516. dp = x.Price;
  8517. }
  8518. return new
  8519. {
  8520. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8521. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8522. x.Area,
  8523. x.id,
  8524. price = x.Price.ToString("F2"),
  8525. x.PriceName,
  8526. x.PriceContent,
  8527. x.TeamName,
  8528. x.DatePrice,
  8529. dayPrice = dp.ToString("F2"),
  8530. };
  8531. }).OrderByDescending(x=>x.id).ToList();
  8532. jw = JsonView(true, "获取成功!", view);
  8533. }
  8534. catch (Exception e)
  8535. {
  8536. jw = JsonView(false,e.Message);
  8537. }
  8538. return Ok(jw);
  8539. }
  8540. #endregion
  8541. #region 酒店预定 保留
  8542. /// <summary>
  8543. /// 酒店预订页面初始化绑定
  8544. /// </summary>
  8545. /// <param name="dto"></param>
  8546. /// <returns></returns>
  8547. [HttpPost]
  8548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8549. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  8550. {
  8551. try
  8552. {
  8553. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  8554. if (groupData.Code != 0)
  8555. {
  8556. return Ok(JsonView(false, groupData.Msg));
  8557. }
  8558. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8559. }
  8560. catch (Exception ex)
  8561. {
  8562. return Ok(JsonView(false, ex.Message));
  8563. }
  8564. }
  8565. /// <summary>
  8566. /// 根据团组Id查询酒店费用列表
  8567. /// </summary>
  8568. /// <param name="dto"></param>
  8569. /// <returns></returns>
  8570. [HttpPost]
  8571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8572. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  8573. {
  8574. try
  8575. {
  8576. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  8577. if (groupData.Code != 0)
  8578. {
  8579. return Ok(JsonView(false, groupData.Msg));
  8580. }
  8581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8582. }
  8583. catch (Exception ex)
  8584. {
  8585. return Ok(JsonView(false, ex.Message));
  8586. }
  8587. }
  8588. /// <summary>
  8589. /// 根据酒店费用Id查询酒店费用详细
  8590. /// </summary>
  8591. /// <param name="dto"></param>
  8592. /// <returns></returns>
  8593. [HttpPost]
  8594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8595. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  8596. {
  8597. try
  8598. {
  8599. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  8600. if (groupData.Code != 0)
  8601. {
  8602. return Ok(JsonView(false, groupData.Msg));
  8603. }
  8604. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8605. }
  8606. catch (Exception ex)
  8607. {
  8608. return Ok(JsonView(false, ex.Message));
  8609. }
  8610. }
  8611. /// <summary>
  8612. /// 计算酒店付款总金额
  8613. /// </summary>
  8614. /// <param name="dto"></param>
  8615. /// <returns></returns>
  8616. [HttpPost]
  8617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8618. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  8619. {
  8620. try
  8621. {
  8622. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  8623. if (groupData.Code != 0)
  8624. {
  8625. return Ok(JsonView(false, groupData.Msg));
  8626. }
  8627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8628. }
  8629. catch (Exception ex)
  8630. {
  8631. return Ok(JsonView(false, ex.Message));
  8632. }
  8633. }
  8634. /// <summary>
  8635. /// 酒店费用操作(Status:1.新增,2.修改)
  8636. /// </summary>
  8637. /// <param name="dto"></param>
  8638. /// <returns></returns>
  8639. [HttpPost]
  8640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8641. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  8642. {
  8643. try
  8644. {
  8645. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  8646. if (groupData.Code != 0)
  8647. {
  8648. return Ok(JsonView(false, groupData.Msg));
  8649. }
  8650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8651. }
  8652. catch (Exception ex)
  8653. {
  8654. return Ok(JsonView(false, ex.Message));
  8655. }
  8656. }
  8657. /// <summary>
  8658. /// 文件上传
  8659. /// </summary>
  8660. /// <param name="file"></param>
  8661. /// <returns></returns>
  8662. [HttpPost]
  8663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8664. public async Task<IActionResult> UploadHotel(IFormFile file)
  8665. {
  8666. try
  8667. {
  8668. if (file != null)
  8669. {
  8670. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8671. //文件名称
  8672. string projectFileName = file.FileName;
  8673. //上传的文件的路径
  8674. string filePath = "";
  8675. if (!Directory.Exists(fileDir))
  8676. {
  8677. Directory.CreateDirectory(fileDir);
  8678. }
  8679. //上传的文件的路径
  8680. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  8681. using (FileStream fs = System.IO.File.Create(filePath))
  8682. {
  8683. file.CopyTo(fs);
  8684. fs.Flush();
  8685. }
  8686. return Ok(JsonView(true, "上传成功!", projectFileName));
  8687. }
  8688. else
  8689. {
  8690. return Ok(JsonView(false, "上传失败!"));
  8691. }
  8692. }
  8693. catch (Exception ex)
  8694. {
  8695. return Ok(JsonView(false, "程序错误!"));
  8696. throw;
  8697. }
  8698. }
  8699. /// <summary>
  8700. /// 删除指定文件
  8701. /// </summary>
  8702. /// <param name="dto"></param>
  8703. /// <returns></returns>
  8704. [HttpPost]
  8705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8706. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  8707. {
  8708. try
  8709. {
  8710. string filePath = "";
  8711. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8712. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  8713. //int id = 0;
  8714. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  8715. // 删除该文件
  8716. try
  8717. {
  8718. System.IO.File.Delete(filePath);
  8719. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  8720. {
  8721. Attachment = "",
  8722. }).ExecuteCommandAsync();
  8723. if (result != 0)
  8724. {
  8725. return Ok(JsonView(true, "成功!"));
  8726. }
  8727. else
  8728. {
  8729. return Ok(JsonView(false, "失败!"));
  8730. }
  8731. }
  8732. catch (Exception)
  8733. {
  8734. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  8735. {
  8736. Attachment = "",
  8737. }).ExecuteCommandAsync();
  8738. if (result != 0)
  8739. {
  8740. return Ok(JsonView(true, "成功!"));
  8741. }
  8742. else
  8743. {
  8744. return Ok(JsonView(false, "失败!"));
  8745. }
  8746. throw;
  8747. }
  8748. }
  8749. catch (Exception ex)
  8750. {
  8751. return Ok(JsonView(false, "程序错误!"));
  8752. throw;
  8753. }
  8754. }
  8755. /// <summary>
  8756. /// 生成VOUCHER
  8757. /// </summary>
  8758. /// <param name="dto"></param>
  8759. /// <returns></returns>
  8760. [HttpPost]
  8761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8762. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  8763. {
  8764. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  8765. //判断数据是否完整
  8766. if (h != null)
  8767. {
  8768. if (!string.IsNullOrEmpty(h.DetermineNo))
  8769. {
  8770. string strFileName = "HotelStatement/";
  8771. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  8772. if (dele != null)
  8773. strFileName += dele.TourCode;
  8774. //载入模板
  8775. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8776. Document doc = new Document(sss);
  8777. DocumentBuilder builder = new DocumentBuilder(doc);
  8778. try
  8779. {
  8780. #region 替换Word模板书签内容
  8781. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8782. //入住卷预定号码
  8783. if (doc.Range.Bookmarks["VNO"] != null)
  8784. {
  8785. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8786. mark.Text = h.CheckNumber;
  8787. }
  8788. //酒店时间
  8789. if (doc.Range.Bookmarks["Date"] != null)
  8790. {
  8791. Bookmark mark = doc.Range.Bookmarks["Date"];
  8792. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  8793. }
  8794. //团号
  8795. if (doc.Range.Bookmarks["TNo"] != null)
  8796. {
  8797. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8798. mark.Text = dele.TourCode;
  8799. }
  8800. //预定号码
  8801. if (doc.Range.Bookmarks["BookingId"] != null)
  8802. {
  8803. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8804. mark.Text = h.ReservationsNo;
  8805. }
  8806. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8807. {
  8808. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8809. mark.Text = h.DetermineNo;
  8810. }
  8811. //酒店城市
  8812. if (doc.Range.Bookmarks["City"] != null)
  8813. {
  8814. Bookmark mark = doc.Range.Bookmarks["City"];
  8815. mark.Text = h.City;
  8816. }
  8817. //酒店名称
  8818. if (doc.Range.Bookmarks["HName"] != null)
  8819. {
  8820. Bookmark mark = doc.Range.Bookmarks["HName"];
  8821. mark.Text = h.HotelName;
  8822. }
  8823. //酒店地址
  8824. if (doc.Range.Bookmarks["Address"] != null)
  8825. {
  8826. Bookmark mark = doc.Range.Bookmarks["Address"];
  8827. mark.Text = h.HotelAddress;
  8828. }
  8829. //酒店电话
  8830. if (doc.Range.Bookmarks["Tel"] != null)
  8831. {
  8832. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8833. mark.Text = h.HotelTel;
  8834. }
  8835. //酒店传真
  8836. if (doc.Range.Bookmarks["Fax"] != null)
  8837. {
  8838. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8839. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  8840. {
  8841. mark.Text = h.HotelFax;
  8842. }
  8843. }
  8844. //入住时间
  8845. if (doc.Range.Bookmarks["CIn"] != null)
  8846. {
  8847. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  8848. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8849. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8850. }
  8851. //退房时间
  8852. if (doc.Range.Bookmarks["COut"] != null)
  8853. {
  8854. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  8855. Bookmark mark = doc.Range.Bookmarks["COut"];
  8856. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8857. }
  8858. //客户名称
  8859. if (doc.Range.Bookmarks["GName"] != null)
  8860. {
  8861. Bookmark mark = doc.Range.Bookmarks["GName"];
  8862. mark.Text = h.GuestName;
  8863. }
  8864. //房间介绍
  8865. if (doc.Range.Bookmarks["ROOM"] != null)
  8866. {
  8867. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8868. mark.Text = h.RoomExplanation;
  8869. }
  8870. //报价描述
  8871. if (doc.Range.Bookmarks["NOTE"] != null)
  8872. {
  8873. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8874. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  8875. if (ss != null)
  8876. mark.Text = ss.Name;
  8877. }
  8878. //入住时间
  8879. if (doc.Range.Bookmarks["CheckIn"] != null)
  8880. {
  8881. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  8882. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8883. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8884. }
  8885. //退房时间
  8886. if (doc.Range.Bookmarks["CheckOut"] != null)
  8887. {
  8888. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  8889. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8890. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8891. }
  8892. //日期
  8893. if (doc.Range.Bookmarks["DT"] != null)
  8894. {
  8895. Bookmark mark = doc.Range.Bookmarks["DT"];
  8896. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  8897. }
  8898. //名称
  8899. if (doc.Range.Bookmarks["VName"] != null)
  8900. {
  8901. Bookmark mark = doc.Range.Bookmarks["VName"];
  8902. mark.Text = h.HotelName;
  8903. }
  8904. //号码
  8905. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8906. {
  8907. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8908. mark.Text = h.CheckNumber;
  8909. }
  8910. #endregion
  8911. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  8912. strFileName += "VOUCHER.doc";
  8913. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8914. doc.Save(fileDir);
  8915. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8916. return Ok(JsonView(true, "成功!", Url));
  8917. }
  8918. catch (Exception ex)
  8919. {
  8920. throw;
  8921. }
  8922. }
  8923. else
  8924. {
  8925. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8926. }
  8927. }
  8928. else
  8929. {
  8930. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8931. }
  8932. }
  8933. /// <summary>
  8934. /// 导出确认单
  8935. /// </summary>
  8936. /// <param name=""></param>
  8937. /// <returns></returns>
  8938. [HttpPost]
  8939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8940. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  8941. {
  8942. //团组信息
  8943. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  8944. //酒店数据
  8945. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  8946. //利datatable存储
  8947. DataTable dt = new DataTable();
  8948. dt.Columns.Add("CheckInDate", typeof(string));
  8949. dt.Columns.Add("City", typeof(string));
  8950. dt.Columns.Add("Hotel", typeof(string));
  8951. dt.Columns.Add("Room", typeof(string));
  8952. for (int i = 0; i < listhoteldata.Count; i++)
  8953. {
  8954. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8955. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8956. while (dayStart < dayEnd)
  8957. {
  8958. string temp = "";
  8959. DataRow row = dt.NewRow();
  8960. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8961. row["City"] = listhoteldata[i].City;
  8962. row["Hotel"] = listhoteldata[i].HotelName;
  8963. if (listhoteldata[i].SingleRoomCount > 0)
  8964. {
  8965. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8966. }
  8967. if (listhoteldata[i].DoubleRoomCount > 0)
  8968. {
  8969. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  8970. }
  8971. if (listhoteldata[i].SuiteRoomCount > 0)
  8972. {
  8973. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8974. }
  8975. if (listhoteldata[i].OtherRoomCount > 0)
  8976. {
  8977. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  8978. }
  8979. row["Room"] = temp;
  8980. dt.Rows.Add(row);
  8981. dayStart = dayStart.AddDays(1);
  8982. }
  8983. }
  8984. Dictionary<string, string> dic = new Dictionary<string, string>();
  8985. dic.Add("Dele", di.TeamName);
  8986. dic.Add("City", di.VisitCountry);
  8987. //模板路径
  8988. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  8989. //载入模板
  8990. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  8991. DocumentBuilder builder = new DocumentBuilder(doc);
  8992. foreach (var key in dic.Keys)
  8993. {
  8994. builder.MoveToBookmark(key);
  8995. builder.Write(dic[key]);
  8996. }
  8997. //获取word里所有表格
  8998. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8999. //获取所填表格的序数
  9000. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9001. var rowStart = tableOne.Rows[0]; //获取第1行
  9002. try
  9003. {
  9004. //循环赋值
  9005. for (int i = 0; i < dt.Rows.Count; i++)
  9006. {
  9007. builder.MoveToCell(0, i + 1, 0, 0);
  9008. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9009. builder.MoveToCell(0, i + 1, 1, 0);
  9010. builder.Write(dt.Rows[i]["City"].ToString());
  9011. builder.MoveToCell(0, i + 1, 2, 0);
  9012. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9013. builder.MoveToCell(0, i + 1, 3, 0);
  9014. builder.Write(dt.Rows[i]["Room"].ToString());
  9015. }
  9016. }
  9017. catch
  9018. {
  9019. }
  9020. //删除多余行
  9021. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9022. {
  9023. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9024. }
  9025. string strFileName = di.TeamName + "酒店确认单.doc";
  9026. try
  9027. {
  9028. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9029. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9030. return Ok(JsonView(true, "成功", Url));
  9031. }
  9032. catch (Exception)
  9033. {
  9034. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  9035. throw;
  9036. }
  9037. }
  9038. /// <summary>
  9039. /// 酒店费用删除
  9040. /// </summary>
  9041. /// <param name="dto"></param>
  9042. /// <returns></returns>
  9043. [HttpPost]
  9044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9045. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  9046. {
  9047. try
  9048. {
  9049. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  9050. if (!res)
  9051. {
  9052. return Ok(JsonView(false, "删除失败"));
  9053. }
  9054. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  9055. {
  9056. IsDel = 1,
  9057. DeleteUserId = dto.DeleteUserId,
  9058. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9059. }).ExecuteCommandAsync();
  9060. return Ok(JsonView(true, "删除成功!"));
  9061. }
  9062. catch (Exception ex)
  9063. {
  9064. return Ok(JsonView(false, "程序错误!"));
  9065. throw;
  9066. }
  9067. }
  9068. #endregion
  9069. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9070. /// <summary>
  9071. /// 酒店预订
  9072. /// 酒店费用列表 根据团组Id查询
  9073. /// </summary>
  9074. /// <param name="_dto"></param>
  9075. /// <returns></returns>
  9076. [HttpPost]
  9077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9078. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9079. {
  9080. try
  9081. {
  9082. #region 参数验证
  9083. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9084. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9085. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9086. #region 团组操作权限验证 76 酒店预定模块
  9087. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9088. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9089. #endregion
  9090. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9091. #region 页面操作权限验证
  9092. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9093. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9094. #endregion
  9095. #endregion
  9096. Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
  9097. if (_view.Code != 0)
  9098. {
  9099. return Ok(JsonView(false, _view.Msg));
  9100. }
  9101. return Ok(JsonView(true, _view.Msg, _view.Data));
  9102. }
  9103. catch (Exception ex)
  9104. {
  9105. return Ok(JsonView(false, ex.Message));
  9106. }
  9107. }
  9108. /// <summary>
  9109. /// 酒店预订
  9110. /// 基础数据
  9111. /// </summary>
  9112. /// <param name="_dto"></param>
  9113. /// <returns></returns>
  9114. [HttpPost]
  9115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9116. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9117. {
  9118. try
  9119. {
  9120. #region 参数验证
  9121. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9122. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9123. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9124. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9125. #region 页面操作权限验证
  9126. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9127. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9128. #endregion
  9129. #region 团组操作权限验证 76 酒店预定模块
  9130. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9131. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9132. #endregion
  9133. #endregion
  9134. Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
  9135. if (data.Code != 0)
  9136. {
  9137. return Ok(JsonView(false, data.Msg));
  9138. }
  9139. return Ok(JsonView(true, data.Msg, data.Data));
  9140. }
  9141. catch (Exception ex)
  9142. {
  9143. return Ok(JsonView(false, "Catch:" + ex.Message));
  9144. }
  9145. }
  9146. /// <summary>
  9147. /// 酒店预订
  9148. /// 创建 入住卷号码
  9149. /// </summary>
  9150. /// <param name="_dto"></param>
  9151. /// <returns></returns>
  9152. [HttpPost]
  9153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9154. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9155. {
  9156. try
  9157. {
  9158. #region 参数验证
  9159. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9160. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9161. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9162. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9163. #region 页面操作权限验证
  9164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9165. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9166. #endregion
  9167. #region 团组操作权限验证 76 酒店预定模块
  9168. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9169. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9170. #endregion
  9171. #endregion
  9172. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9173. if (data.Code != 0)
  9174. {
  9175. return Ok(JsonView(false, data.Msg));
  9176. }
  9177. return Ok(JsonView(true, data.Msg, data.Data));
  9178. }
  9179. catch (Exception ex)
  9180. {
  9181. return Ok(JsonView(false, ex.Message));
  9182. }
  9183. }
  9184. /// <summary>
  9185. /// 酒店预订
  9186. /// 详情
  9187. /// </summary>
  9188. /// <param name="_dto"></param>
  9189. /// <returns></returns>
  9190. [HttpPost]
  9191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9192. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9193. {
  9194. try
  9195. {
  9196. #region 参数验证
  9197. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9198. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9199. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9200. #region 团组操作权限验证 76 酒店预定模块
  9201. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9202. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9203. #endregion
  9204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9205. #region 页面操作权限验证
  9206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9207. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9208. #endregion
  9209. #endregion
  9210. Result data = await _hotelPriceRep._Details(_dto.PortType, _dto.Id);
  9211. if (data.Code != 0)
  9212. {
  9213. return Ok(JsonView(false, data.Msg));
  9214. }
  9215. return Ok(JsonView(true, data.Msg, data.Data));
  9216. }
  9217. catch (Exception ex)
  9218. {
  9219. return Ok(JsonView(false, ex.Message));
  9220. }
  9221. }
  9222. /// <summary>
  9223. /// 酒店预订
  9224. /// Add Or Edit
  9225. /// </summary>
  9226. /// <param name="_dto"></param>
  9227. /// <returns></returns>
  9228. [HttpPost]
  9229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9230. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9231. {
  9232. try
  9233. {
  9234. #region 参数验证
  9235. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9236. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9237. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9238. #region 团组操作权限验证 76 酒店预定模块
  9239. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9240. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9241. #endregion
  9242. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9243. #region 页面操作权限验证
  9244. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9245. if (_dto.Id == 0) // Add
  9246. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9247. else if (_dto.Id > 0) // Edit
  9248. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9249. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9250. #endregion
  9251. #endregion
  9252. Result data = await _hotelPriceRep._AddOrEdit(_dto);
  9253. if (data.Code != 0)
  9254. {
  9255. return Ok(JsonView(false, data.Msg));
  9256. }
  9257. #region 应用推送
  9258. try
  9259. {
  9260. int ccpId = data.Data.GetType().GetProperty("ccpId").GetValue(data.Data, null);
  9261. int sign = data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9262. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9263. }
  9264. catch (Exception ex)
  9265. {
  9266. }
  9267. #endregion
  9268. return Ok(JsonView(true, data.Msg, data.Data));
  9269. }
  9270. catch (Exception ex)
  9271. {
  9272. return Ok(JsonView(false, ex.Message));
  9273. }
  9274. }
  9275. /// <summary>
  9276. /// 酒店预订
  9277. /// Del
  9278. /// </summary>
  9279. /// <param name="_dto"></param>
  9280. /// <returns></returns>
  9281. [HttpPost]
  9282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9283. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9284. {
  9285. try
  9286. {
  9287. #region 参数验证
  9288. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9289. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9290. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9291. #region 团组操作权限验证 76 酒店预定模块
  9292. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9293. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9294. #endregion
  9295. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9296. #region 页面操作权限验证
  9297. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9298. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9299. #endregion
  9300. #endregion
  9301. Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  9302. if (data.Code != 0)
  9303. {
  9304. return Ok(JsonView(false, data.Msg));
  9305. }
  9306. return Ok(JsonView(true, data.Msg, data.Data));
  9307. }
  9308. catch (Exception ex)
  9309. {
  9310. return Ok(JsonView(false, ex.Message));
  9311. }
  9312. }
  9313. /// <summary>
  9314. /// 酒店预订
  9315. /// 生成VOUCHER
  9316. /// 2024.05.06 之前版本
  9317. /// </summary>
  9318. /// <param name="_dto"></param>
  9319. /// <returns></returns>
  9320. [HttpPost]
  9321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9322. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  9323. {
  9324. try
  9325. {
  9326. #region 参数验证
  9327. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9328. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9329. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9330. #region 团组操作权限验证 76 酒店预定模块
  9331. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9332. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9333. #endregion
  9334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9335. #region 页面操作权限验证
  9336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9337. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9338. #endregion
  9339. #endregion
  9340. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9341. //判断数据是否完整
  9342. if (hr != null)
  9343. {
  9344. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9345. {
  9346. string strFileName = "HotelStatement/";
  9347. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9348. if (dele != null)
  9349. strFileName += dele.TourCode;
  9350. //载入模板
  9351. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9352. Document doc = new Document(sss);
  9353. DocumentBuilder builder = new DocumentBuilder(doc);
  9354. #region 替换Word模板书签内容
  9355. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9356. //入住卷预定号码
  9357. if (doc.Range.Bookmarks["VNO"] != null)
  9358. {
  9359. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9360. mark.Text = hr.CheckNumber;
  9361. }
  9362. //酒店时间
  9363. if (doc.Range.Bookmarks["Date"] != null)
  9364. {
  9365. Bookmark mark = doc.Range.Bookmarks["Date"];
  9366. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9367. }
  9368. //团号
  9369. if (doc.Range.Bookmarks["TNo"] != null)
  9370. {
  9371. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9372. mark.Text = dele.TourCode;
  9373. }
  9374. //预定号码
  9375. if (doc.Range.Bookmarks["BookingId"] != null)
  9376. {
  9377. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9378. mark.Text = hr.ReservationsNo;
  9379. }
  9380. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9381. {
  9382. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9383. mark.Text = hr.DetermineNo;
  9384. }
  9385. //酒店城市
  9386. if (doc.Range.Bookmarks["City"] != null)
  9387. {
  9388. Bookmark mark = doc.Range.Bookmarks["City"];
  9389. mark.Text = hr.City;
  9390. }
  9391. //酒店名称
  9392. if (doc.Range.Bookmarks["HName"] != null)
  9393. {
  9394. Bookmark mark = doc.Range.Bookmarks["HName"];
  9395. mark.Text = hr.HotelName;
  9396. }
  9397. //酒店地址
  9398. if (doc.Range.Bookmarks["Address"] != null)
  9399. {
  9400. Bookmark mark = doc.Range.Bookmarks["Address"];
  9401. mark.Text = hr.HotelAddress;
  9402. }
  9403. //酒店电话
  9404. if (doc.Range.Bookmarks["Tel"] != null)
  9405. {
  9406. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9407. mark.Text = hr.HotelTel;
  9408. }
  9409. //酒店传真
  9410. if (doc.Range.Bookmarks["Fax"] != null)
  9411. {
  9412. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9413. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9414. {
  9415. mark.Text = hr.HotelFax;
  9416. }
  9417. }
  9418. //入住时间
  9419. if (doc.Range.Bookmarks["CIn"] != null)
  9420. {
  9421. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9422. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9423. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9424. }
  9425. //退房时间
  9426. if (doc.Range.Bookmarks["COut"] != null)
  9427. {
  9428. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9429. Bookmark mark = doc.Range.Bookmarks["COut"];
  9430. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9431. }
  9432. //客户名称
  9433. if (doc.Range.Bookmarks["GName"] != null)
  9434. {
  9435. string guestName = "";
  9436. string[] clients = new string[] { };
  9437. if (hr.GuestName.Contains(","))
  9438. {
  9439. clients = hr.GuestName.Split(",");
  9440. }
  9441. else
  9442. {
  9443. clients = new string[] { hr.GuestName };
  9444. }
  9445. List<int> clientIds_int = new List<int>();
  9446. if (clients.Length > 0)
  9447. {
  9448. foreach (var item in clients)
  9449. {
  9450. if (item.IsNumeric())
  9451. {
  9452. clientIds_int.Add(int.Parse(item));
  9453. }
  9454. }
  9455. }
  9456. if (clientIds_int.Count > 0)
  9457. {
  9458. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9459. foreach (var client in _clientDatas)
  9460. {
  9461. //男
  9462. if (client.Sex == 0) guestName += $"Mr.";
  9463. //女
  9464. else if (client.Sex == 1) guestName += $"Ms.";
  9465. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9466. {
  9467. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9468. }
  9469. //guestName += $"{client.Pinyin},";
  9470. }
  9471. if (guestName.Length > 0)
  9472. {
  9473. guestName = guestName.Substring(0, guestName.Length - 1);
  9474. }
  9475. }
  9476. else
  9477. {
  9478. guestName = hr.GuestName;
  9479. }
  9480. Bookmark mark = doc.Range.Bookmarks["GName"];
  9481. mark.Text = guestName;
  9482. }
  9483. //房间介绍
  9484. if (doc.Range.Bookmarks["ROOM"] != null)
  9485. {
  9486. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9487. mark.Text = hr.RoomExplanation;
  9488. }
  9489. //报价描述
  9490. if (doc.Range.Bookmarks["NOTE"] != null)
  9491. {
  9492. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9493. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9494. if (ss != null)
  9495. mark.Text = ss.Name;
  9496. }
  9497. //入住时间
  9498. if (doc.Range.Bookmarks["CheckIn"] != null)
  9499. {
  9500. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9501. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9502. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9503. }
  9504. //退房时间
  9505. if (doc.Range.Bookmarks["CheckOut"] != null)
  9506. {
  9507. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9508. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9509. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9510. }
  9511. //日期
  9512. if (doc.Range.Bookmarks["DT"] != null)
  9513. {
  9514. Bookmark mark = doc.Range.Bookmarks["DT"];
  9515. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9516. }
  9517. //名称
  9518. if (doc.Range.Bookmarks["VName"] != null)
  9519. {
  9520. Bookmark mark = doc.Range.Bookmarks["VName"];
  9521. mark.Text = hr.HotelName;
  9522. }
  9523. //号码
  9524. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9525. {
  9526. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9527. mark.Text = hr.CheckNumber;
  9528. }
  9529. #endregion
  9530. strFileName += "VOUCHER.doc";
  9531. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9532. doc.Save(fileDir);
  9533. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9534. return Ok(JsonView(true, "操作成功!", Url));
  9535. }
  9536. else
  9537. {
  9538. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9539. }
  9540. }
  9541. else
  9542. {
  9543. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9544. }
  9545. }
  9546. catch (Exception ex)
  9547. {
  9548. return Ok(JsonView(false, ex.Message));
  9549. }
  9550. }
  9551. /// <summary>
  9552. /// 酒店预订
  9553. /// 生成VOUCHER
  9554. /// 2024.05.06 之后版本
  9555. /// </summary>
  9556. /// <param name="_dto"></param>
  9557. /// <returns></returns>
  9558. [HttpPost]
  9559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9560. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9561. {
  9562. #region 参数验证
  9563. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9564. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9565. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9566. #region 团组操作权限验证 76 酒店预定模块
  9567. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9568. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9569. #endregion
  9570. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9571. #region 页面操作权限验证
  9572. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9573. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9574. #endregion
  9575. #endregion
  9576. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9577. //判断数据是否完整
  9578. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9579. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9580. string strFileName = "HotelStatement/";
  9581. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9582. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9583. #region 数据处理
  9584. List<int> guestIds = new List<int>();
  9585. int index = 0;
  9586. foreach (var item in hrDtas)
  9587. {
  9588. if (item.GuestName.Contains(","))
  9589. {
  9590. string[] guestIdArr = item.GuestName.Split(',');
  9591. foreach (var guestIdStr in guestIdArr)
  9592. {
  9593. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9594. if (guestBool)
  9595. {
  9596. guestIds.Add(guestId);
  9597. }
  9598. }
  9599. }
  9600. else guestNames += item.GuestName;
  9601. var voucherInfo = new HotelVoucherInfoView()
  9602. {
  9603. HotelName = item.HotelName,
  9604. CheckInDate = item.CheckInDate,
  9605. CheckOutDate = item.CheckOutDate,
  9606. ConfirmationNumber = item.DetermineNo.Trim(),
  9607. RoomType = item.RoomExplanation
  9608. };
  9609. vouchers.Add(voucherInfo);
  9610. }
  9611. if (guestIds.Count > 0)
  9612. {
  9613. guestIds = guestIds.Distinct().ToList();
  9614. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9615. if (guestDatas.Count > 0)
  9616. {
  9617. guestNames = "";
  9618. foreach (var guest in guestDatas)
  9619. {
  9620. string guestName = "";
  9621. if (guest.Sex == 0) guestName += @"MR.";
  9622. else if (guest.Sex == 1) guestName += @"MS.";
  9623. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9624. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9625. guestNames += @$"{guestName.Trim()}、";
  9626. }
  9627. if (guestNames.Length > 0)
  9628. {
  9629. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9630. }
  9631. }
  9632. }
  9633. #endregion
  9634. //载入模板
  9635. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9636. Document doc = new Document(sss);
  9637. DocumentBuilder builder = new DocumentBuilder(doc);
  9638. if (doc.Range.Bookmarks["GuestName"] != null)
  9639. {
  9640. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9641. mark.Text = guestNames;
  9642. }
  9643. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9644. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9645. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9646. for (int i = 1; i <= vouchers.Count; i++)
  9647. {
  9648. HotelVoucherInfoView hviv = vouchers[i - 1];
  9649. builder.MoveToCell(0, i, 0, 0);
  9650. builder.Write(hviv.HotelName);
  9651. builder.MoveToCell(0, i, 1, 0);
  9652. builder.Write(hviv.CheckInDate);
  9653. builder.MoveToCell(0, i, 2, 0);
  9654. builder.Write(hviv.CheckOutDate);
  9655. builder.MoveToCell(0, i, 3, 0);
  9656. builder.Write(hviv.RoomType);
  9657. builder.MoveToCell(0, i, 4, 0);
  9658. builder.Write(hviv.ConfirmationNumber);
  9659. }
  9660. //删除多余行
  9661. int currRowIndex = vouchers.Count + 1;
  9662. int delRows = 21 - currRowIndex;
  9663. if (delRows > 0)
  9664. {
  9665. for (int i = 0; i < delRows; i++)
  9666. {
  9667. table.Rows.RemoveAt(currRowIndex);
  9668. //cultivateRowIndex++;
  9669. }
  9670. }
  9671. strFileName += "VOUCHER.docx";
  9672. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9673. doc.Save(fileDir);
  9674. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9675. return Ok(JsonView(true, "操作成功!", Url));
  9676. }
  9677. /// <summary>
  9678. /// 酒店预订
  9679. /// 生成 预定成本 Excel
  9680. /// </summary>
  9681. /// <param name="_dto"></param>
  9682. /// <returns></returns>
  9683. [HttpPost]
  9684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9685. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9686. {
  9687. #region 参数验证
  9688. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9689. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9690. if (!vadalitorRes.IsValid)
  9691. {
  9692. var errors = new StringBuilder();
  9693. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9694. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9695. }
  9696. #region 团组操作权限验证 76 酒店预定模块
  9697. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9698. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9699. #endregion
  9700. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9701. #region 页面操作权限验证
  9702. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9703. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9704. #endregion
  9705. #endregion
  9706. decimal _rate = 1.00M;
  9707. string _currency = "";
  9708. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9709. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9710. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9711. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9712. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9713. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9714. {
  9715. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9716. }
  9717. _currency = _GroupCostParameter.Currency;
  9718. bool isIntType = int.TryParse(_currency, out int currId);
  9719. if (isIntType)
  9720. {
  9721. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9722. }
  9723. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9724. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9725. if (currInfo == null)
  9726. {
  9727. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9728. }
  9729. if (!_currency.ToUpper().Equals("CNY"))
  9730. {
  9731. _rate = _GroupCostParameter.Rate;
  9732. }
  9733. _rate = currInfo.Rate;
  9734. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9735. string strFileName = "HotelStatement/";
  9736. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9737. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9738. #region 数据处理
  9739. foreach (var item in hrDtas)
  9740. {
  9741. var ccpInfo = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9742. string roomCurr = currDatas.Find(it => it.Id == ccpInfo.PaymentCurrency)?.Name ?? "";
  9743. string singleRoomFeeStr = string.Empty,
  9744. doubleRoomFeeStr = string.Empty,
  9745. suiteRoomFeeStr = string.Empty,
  9746. otherRoomFeeStr = string.Empty,
  9747. payMoneyStr = string.Empty,
  9748. cardPriceStr = string.Empty;
  9749. if (roomCurr.Equals(_currency))
  9750. {
  9751. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9752. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9753. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9754. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9755. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9756. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9757. }
  9758. else
  9759. {
  9760. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9761. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9762. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9763. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9764. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9765. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9766. }
  9767. string breakfastPriceStr = string.Empty,
  9768. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9769. governmentRentStr = string.Empty,
  9770. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9771. cityTaxStrStr = string.Empty,
  9772. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9773. //if (breakfastCurrency.Equals(_currency))
  9774. //{
  9775. // breakfastPriceStr = $"{item.BreakfastPrice.ToString("#0.00")} ({_currency})";
  9776. //}
  9777. //if (governmentRentCurrency.Equals(_currency))
  9778. //{
  9779. // governmentRentStr = $"{item.GovernmentRent.ToString("#0.00")} ({_currency})";
  9780. //}
  9781. //if (cityTaxStrCurrency.Equals(_currency))
  9782. //{
  9783. // cityTaxStrStr = $"{item.CityTax.ToString("#0.00")} ({_currency})";
  9784. //}
  9785. breakfastPriceStr = $"{item.BreakfastPrice.ToString("#0.00")} {_currency}";
  9786. governmentRentStr = $"{item.GovernmentRent.ToString("#0.00")} {_currency}";
  9787. cityTaxStrStr = $"{item.CityTax.ToString("#0.00")} {_currency}";
  9788. pcfds.Add(new HotelReservations_PCFD_View()
  9789. {
  9790. City = item.City,
  9791. HotelName = item.HotelName,
  9792. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9793. // SingleRoomCount = item.SingleRoomCount,
  9794. SingleRoomPrice = singleRoomFeeStr,
  9795. // DoubleRoomCount = item.DoubleRoomCount,
  9796. DoubleRoomPrice = doubleRoomFeeStr,
  9797. //SuiteRoomCount = item.SuiteRoomCount,
  9798. SuiteRoomPrice = suiteRoomFeeStr,
  9799. OtherRoomPrice = otherRoomFeeStr,
  9800. //OtherRoomCount = item.OtherRoomCount,
  9801. BreakfastPrice = breakfastPriceStr,
  9802. GovernmentRent = governmentRentStr,
  9803. CityTax = cityTaxStrStr,
  9804. RoomExplanation = item.RoomExplanation,
  9805. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == ccpInfo.PayDId).First()?.Name ?? "",
  9806. PayTime = ccpInfo.ConsumptionDate,
  9807. BankNo = ccpInfo.BankNo,
  9808. PayMoney = payMoneyStr,
  9809. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9810. ConsumptionPatterns = ccpInfo.ConsumptionPatterns,
  9811. CardPrice = cardPriceStr,
  9812. Remark = ccpInfo.Remark
  9813. });
  9814. }
  9815. #endregion
  9816. //载入模板
  9817. WorkbookDesigner designer = new WorkbookDesigner();
  9818. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9819. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9820. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9821. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9822. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9823. designer.SetDataSource("Opertor", userInfo.CnName);
  9824. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9825. dt.TableName = "ViewMyHotelReservations";
  9826. designer.SetDataSource(dt);
  9827. designer.Process();
  9828. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9829. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9830. designer.Workbook.Save(serverPath);
  9831. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9832. #region 删除指定行
  9833. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true,cpDel=true, remarkDel = true;
  9834. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9835. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9836. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9837. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9838. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9839. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9840. cssIndex = dt.Columns["CityTax"].Ordinal,
  9841. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9842. remarkIndex = dt.Columns["Remark"].Ordinal;
  9843. //删除指定列
  9844. foreach (DataRow item in dt.Rows)
  9845. {
  9846. string singleStr = item["SingleRoomPrice"].ToString();
  9847. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9848. if (containsDigitButNotZero1) singleDel = false;
  9849. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9850. string doubleStr = item["DoubleRoomPrice"].ToString();
  9851. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9852. if (containsDigitButNotZero2) doubleDel = false;
  9853. string suiteStr = item["SuiteRoomPrice"].ToString();
  9854. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9855. if (containsDigitButNotZero3) suiteDel = false;
  9856. string otherStr = item["OtherRoomPrice"].ToString();
  9857. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9858. if (containsDigitButNotZero4) otherDel = false;
  9859. string zcStr = item["BreakfastPrice"].ToString();
  9860. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9861. if (containsDigitButNotZero5) zcDel = false;
  9862. string dsStr = item["GovernmentRent"].ToString();
  9863. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9864. if (containsDigitButNotZero6) dsDel = false;
  9865. string cssStr = item["CityTax"].ToString();
  9866. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9867. if (containsDigitButNotZero7) cssDel = false;
  9868. string cpStr = item["ConsumptionPatterns"].ToString();
  9869. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9870. string remarkStr = item["Remark"].ToString();
  9871. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9872. }
  9873. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9874. DeleteColumn(serverPath, cpIndex, cpDel);
  9875. DeleteColumn(serverPath, dsIndex, dsDel);
  9876. DeleteColumn(serverPath, cssIndex, cssDel);
  9877. DeleteColumn(serverPath, zcIndex, zcDel);
  9878. DeleteColumn(serverPath, otherIndex, otherDel);
  9879. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9880. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9881. DeleteColumn(serverPath, singleIndex, singleDel);
  9882. #endregion
  9883. //只保留第一个表格
  9884. DeleteSheet(serverPath);
  9885. return Ok(JsonView(true, "操作成功", url = rst));
  9886. }
  9887. /// <summary>
  9888. /// 删除指定列
  9889. /// </summary>
  9890. /// <param name="file"></param>
  9891. /// <param name="columnIndex"></param>
  9892. /// <param name="isDel"></param>
  9893. private void DeleteColumn(string file, int columnIndex,bool isDel)
  9894. {
  9895. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9896. //wb.Save(file);
  9897. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9898. if (sheet1 != null)
  9899. {
  9900. if (isDel)
  9901. {
  9902. Cells cells = sheet1.Cells;
  9903. cells.DeleteColumn(columnIndex);
  9904. }
  9905. }
  9906. wb.Save(file);
  9907. }
  9908. /// <summary>
  9909. /// 删除sheet
  9910. /// </summary>
  9911. /// <param name="file"></param>
  9912. /// <param name="sheetName"></param>
  9913. private void DeleteSheet(string file, string sheetName="")
  9914. {
  9915. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9916. //wb.Save(file);
  9917. List<string> sheets = new List<string>();
  9918. foreach (var item in wb.Worksheets)
  9919. {
  9920. sheets.Add(item.Name);
  9921. }
  9922. if (sheets.Count > 0)
  9923. {
  9924. sheets.RemoveAt(0);//不删除第一个sheet
  9925. foreach (var item in sheets)
  9926. {
  9927. wb.Worksheets.RemoveAt(item);
  9928. }
  9929. }
  9930. wb.Save(file);
  9931. }
  9932. /// <summary>
  9933. /// 酒店预订
  9934. /// 确认单
  9935. /// </summary>
  9936. /// <param name="_dto"></param>
  9937. /// <returns></returns>
  9938. [HttpPost]
  9939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9940. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9941. {
  9942. try
  9943. {
  9944. #region 参数验证
  9945. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9946. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9947. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9948. #region 团组操作权限验证 76 酒店预定模块
  9949. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9950. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9951. #endregion
  9952. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9953. #region 页面操作权限验证
  9954. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9955. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9956. #endregion
  9957. #endregion
  9958. //团组信息
  9959. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9960. //酒店数据
  9961. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9962. if (listhoteldata.Count < 0)
  9963. {
  9964. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9965. }
  9966. //利datatable存储
  9967. DataTable dt = new DataTable();
  9968. dt.Columns.Add("CheckInDate", typeof(string));
  9969. dt.Columns.Add("City", typeof(string));
  9970. dt.Columns.Add("Hotel", typeof(string));
  9971. dt.Columns.Add("Room", typeof(string));
  9972. for (int i = 0; i < listhoteldata.Count; i++)
  9973. {
  9974. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9975. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9976. while (dayStart < dayEnd)
  9977. {
  9978. string temp = "";
  9979. DataRow row = dt.NewRow();
  9980. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9981. row["City"] = listhoteldata[i].City;
  9982. row["Hotel"] = listhoteldata[i].HotelName;
  9983. if (listhoteldata[i].SingleRoomCount > 0)
  9984. {
  9985. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9986. }
  9987. if (listhoteldata[i].DoubleRoomCount > 0)
  9988. {
  9989. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9990. }
  9991. if (listhoteldata[i].SuiteRoomCount > 0)
  9992. {
  9993. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9994. }
  9995. if (listhoteldata[i].OtherRoomCount > 0)
  9996. {
  9997. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9998. }
  9999. row["Room"] = temp;
  10000. dt.Rows.Add(row);
  10001. dayStart = dayStart.AddDays(1);
  10002. }
  10003. }
  10004. Dictionary<string, string> dic = new Dictionary<string, string>();
  10005. dic.Add("Dele", di.TeamName);
  10006. dic.Add("City", di.VisitCountry);
  10007. //模板路径
  10008. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10009. //载入模板
  10010. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10011. DocumentBuilder builder = new DocumentBuilder(doc);
  10012. foreach (var key in dic.Keys)
  10013. {
  10014. builder.MoveToBookmark(key);
  10015. builder.Write(dic[key]);
  10016. }
  10017. //获取word里所有表格
  10018. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10019. //获取所填表格的序数
  10020. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10021. var rowStart = tableOne.Rows[0]; //获取第1行
  10022. //循环赋值
  10023. for (int i = 0; i < dt.Rows.Count; i++)
  10024. {
  10025. builder.MoveToCell(0, i + 1, 0, 0);
  10026. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10027. builder.MoveToCell(0, i + 1, 1, 0);
  10028. builder.Write(dt.Rows[i]["City"].ToString());
  10029. builder.MoveToCell(0, i + 1, 2, 0);
  10030. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10031. builder.MoveToCell(0, i + 1, 3, 0);
  10032. builder.Write(dt.Rows[i]["Room"].ToString());
  10033. }
  10034. //删除多余行
  10035. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10036. {
  10037. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10038. }
  10039. string strFileName = di.TeamName + "酒店确认单.doc";
  10040. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10041. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10042. return Ok(JsonView(true, "成功", url));
  10043. }
  10044. catch (Exception ex)
  10045. {
  10046. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10047. }
  10048. }
  10049. #endregion
  10050. #region 团组状态
  10051. /// <summary>
  10052. /// 团组状态列表 Page
  10053. /// </summary>
  10054. /// <param name="dto">团组列表请求dto</param>
  10055. /// <returns></returns>
  10056. [HttpPost]
  10057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10058. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10059. {
  10060. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10061. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10062. {
  10063. string sqlWhere = string.Empty;
  10064. if (dto.IsSure == 0) //未完成
  10065. {
  10066. sqlWhere += string.Format(@" And IsSure = 0");
  10067. }
  10068. else if (dto.IsSure == 1) //已完成
  10069. {
  10070. sqlWhere += string.Format(@" And IsSure = 1");
  10071. }
  10072. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10073. {
  10074. string tj = dto.SearchCriteria;
  10075. 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}%')",
  10076. tj, tj, tj, tj, tj);
  10077. }
  10078. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10079. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10080. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10081. From (
  10082. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10083. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10084. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10085. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10086. From Grp_DelegationInfo gdi
  10087. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10088. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10089. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10090. Where gdi.IsDel = 0 {0}
  10091. ) temp ", sqlWhere);
  10092. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10093. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10094. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10095. }
  10096. else
  10097. {
  10098. return Ok(JsonView(false, "查询失败"));
  10099. }
  10100. }
  10101. /// <summary>
  10102. /// 团组状态
  10103. /// 设置操作完成
  10104. /// </summary>
  10105. /// <param name="dto">团组列表请求dto</param>
  10106. /// <returns></returns>
  10107. [HttpPost]
  10108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10109. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10110. {
  10111. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10112. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10113. {
  10114. Id = dto.Id,
  10115. IsSure = 1
  10116. };
  10117. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10118. .UpdateColumns(it => new { it.IsSure })
  10119. .WhereColumns(it => new { it.Id })
  10120. .ExecuteCommandAsync();
  10121. if (result > 0)
  10122. {
  10123. return Ok(JsonView(true, "操作完成!"));
  10124. }
  10125. return Ok(JsonView(false, "操作失败!"));
  10126. }
  10127. #endregion
  10128. #region 保险费用录入
  10129. /// <summary>
  10130. /// 根据团组Id查询保险费用列表
  10131. /// </summary>
  10132. /// <param name="dto"></param>
  10133. /// <returns></returns>
  10134. [HttpPost]
  10135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10136. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10137. {
  10138. try
  10139. {
  10140. Result groupData = await _customersRep.CustomersByDiId(dto);
  10141. if (groupData.Code != 0)
  10142. {
  10143. return Ok(JsonView(false, groupData.Msg));
  10144. }
  10145. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10146. }
  10147. catch (Exception ex)
  10148. {
  10149. return Ok(JsonView(false, ex.Message));
  10150. }
  10151. }
  10152. /// <summary>
  10153. /// 根据保险费用Id查询保险费用详细
  10154. /// </summary>
  10155. /// <param name="dto"></param>
  10156. /// <returns></returns>
  10157. [HttpPost]
  10158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10159. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10160. {
  10161. try
  10162. {
  10163. Result groupData = await _customersRep.CustomersById(dto);
  10164. if (groupData.Code != 0)
  10165. {
  10166. return Ok(JsonView(false, groupData.Msg));
  10167. }
  10168. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10169. }
  10170. catch (Exception ex)
  10171. {
  10172. return Ok(JsonView(false, ex.Message));
  10173. }
  10174. }
  10175. /// <summary>
  10176. /// 保险费用录入页面初始化绑定
  10177. /// </summary>
  10178. /// <param name="dto"></param>
  10179. /// <returns></returns>
  10180. [HttpPost]
  10181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10182. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10183. {
  10184. try
  10185. {
  10186. Result groupData = await _customersRep.CustomersInitialize(dto);
  10187. if (groupData.Code != 0)
  10188. {
  10189. return Ok(JsonView(false, groupData.Msg));
  10190. }
  10191. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10192. }
  10193. catch (Exception ex)
  10194. {
  10195. return Ok(JsonView(false, ex.Message));
  10196. }
  10197. }
  10198. /// <summary>
  10199. /// 保险费用操作(Status:1.新增,2.修改)
  10200. /// </summary>
  10201. /// <param name="dto"></param>
  10202. /// <returns></returns>
  10203. [HttpPost]
  10204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10205. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10206. {
  10207. try
  10208. {
  10209. Result groupData = await _customersRep.OpCustomers(dto);
  10210. if (groupData.Code != 0)
  10211. {
  10212. return Ok(JsonView(false, groupData.Msg));
  10213. }
  10214. #region 应用推送
  10215. try
  10216. {
  10217. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10218. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10219. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10220. }
  10221. catch (Exception ex)
  10222. {
  10223. }
  10224. #endregion
  10225. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10226. }
  10227. catch (Exception ex)
  10228. {
  10229. return Ok(JsonView(false, ex.Message));
  10230. }
  10231. }
  10232. /// <summary>
  10233. /// 保险文件上传
  10234. /// </summary>
  10235. /// <param name="file"></param>
  10236. /// <returns></returns>
  10237. [HttpPost]
  10238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10239. public async Task<IActionResult> UploadCus(IFormFile file)
  10240. {
  10241. try
  10242. {
  10243. if (file != null)
  10244. {
  10245. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10246. //文件名称
  10247. string projectFileName = file.FileName;
  10248. //上传的文件的路径
  10249. string filePath = "";
  10250. if (!Directory.Exists(fileDir))
  10251. {
  10252. Directory.CreateDirectory(fileDir);
  10253. }
  10254. //上传的文件的路径
  10255. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10256. using (FileStream fs = System.IO.File.Create(filePath))
  10257. {
  10258. file.CopyTo(fs);
  10259. fs.Flush();
  10260. }
  10261. return Ok(JsonView(true, "上传成功!", projectFileName));
  10262. }
  10263. else
  10264. {
  10265. return Ok(JsonView(false, "上传失败!"));
  10266. }
  10267. }
  10268. catch (Exception ex)
  10269. {
  10270. return Ok(JsonView(false, "程序错误!"));
  10271. throw;
  10272. }
  10273. }
  10274. /// <summary>
  10275. /// 保险删除指定文件
  10276. /// </summary>
  10277. /// <param name="dto"></param>
  10278. /// <returns></returns>
  10279. [HttpPost]
  10280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10281. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10282. {
  10283. try
  10284. {
  10285. string filePath = "";
  10286. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10287. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10288. //int id = 0;
  10289. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10290. // 删除该文件
  10291. try
  10292. {
  10293. System.IO.File.Delete(filePath);
  10294. 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()
  10295. {
  10296. Attachment = "",
  10297. }).ExecuteCommandAsync();
  10298. if (result != 0)
  10299. {
  10300. return Ok(JsonView(true, "成功!"));
  10301. }
  10302. else
  10303. {
  10304. return Ok(JsonView(false, "失败!"));
  10305. }
  10306. }
  10307. catch (Exception)
  10308. {
  10309. 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()
  10310. {
  10311. Attachment = "",
  10312. }).ExecuteCommandAsync();
  10313. if (result != 0)
  10314. {
  10315. return Ok(JsonView(true, "成功!"));
  10316. }
  10317. else
  10318. {
  10319. return Ok(JsonView(false, "失败!"));
  10320. }
  10321. }
  10322. }
  10323. catch (Exception ex)
  10324. {
  10325. return Ok(JsonView(false, "程序错误!"));
  10326. throw;
  10327. }
  10328. }
  10329. /// <summary>
  10330. /// 保险费用操作(删除)
  10331. /// </summary>
  10332. /// <param name="dto"></param>
  10333. /// <returns></returns>
  10334. [HttpPost]
  10335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10336. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10337. {
  10338. try
  10339. {
  10340. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10341. if (!res)
  10342. {
  10343. return Ok(JsonView(false, "删除失败"));
  10344. }
  10345. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10346. {
  10347. IsDel = 1,
  10348. DeleteUserId = dto.DeleteUserId,
  10349. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10350. }).ExecuteCommandAsync();
  10351. return Ok(JsonView(true, "删除成功!"));
  10352. }
  10353. catch (Exception ex)
  10354. {
  10355. return Ok(JsonView(false, "程序错误!"));
  10356. throw;
  10357. }
  10358. }
  10359. #endregion
  10360. #region 接团客户名单 PageId 104
  10361. /// <summary>
  10362. /// 接团客户名单
  10363. /// 迁移数据(慎用!)
  10364. /// </summary>
  10365. /// <param name="dto"></param>
  10366. /// <returns></returns>
  10367. [HttpPost]
  10368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10369. public async Task<IActionResult> PostTourClientListChange()
  10370. {
  10371. try
  10372. {
  10373. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10374. //var groupClinetData1
  10375. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10376. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10377. int updateCount = 0;
  10378. if (oldOAClientList.Count > 0)
  10379. {
  10380. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10381. _sqlSugar.BeginTran();
  10382. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10383. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10384. foreach (var item in oldOAClientList)
  10385. {
  10386. int comId = 0;
  10387. string format = "yyyy-MM-dd HH:mm:ss";
  10388. string data11 = "1990-01-01 00:00";
  10389. var data1 = IsValidDate(item.OPdate, format);
  10390. if (data1) data11 = item.OPdate;
  10391. //客户公司验证
  10392. if (!string.IsNullOrEmpty(item.Company))
  10393. {
  10394. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10395. if (clientComInfo == null) // add
  10396. {
  10397. var addInfo = new Crm_CustomerCompany()
  10398. {
  10399. CompanyAbbreviation = "",
  10400. CompanyFullName = item.Company,
  10401. Address = "",
  10402. PostCodes = "",
  10403. LastedOpUserId = item.OPer,
  10404. LastedOpDt = Convert.ToDateTime(data11),
  10405. CreateUserId = item.OPer,
  10406. CreateTime = Convert.ToDateTime(data11),
  10407. IsDel = 0
  10408. };
  10409. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10410. if (comId1 > 0) comId = comId1;
  10411. }
  10412. else comId = clientComInfo.Id;
  10413. }
  10414. //客户人员验证
  10415. int clientId = 0;
  10416. string name = item.LastName + item.Name;
  10417. if (!string.IsNullOrEmpty(name))
  10418. {
  10419. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10420. if (clientInfo == null)
  10421. {
  10422. DateTime? dateTime = null;
  10423. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10424. if (isDt) dateTime = birthDayDt;
  10425. var addInfo1 = new Crm_DeleClient()
  10426. {
  10427. CrmCompanyId = comId,
  10428. DiId = -1,
  10429. LastName = item.LastName,
  10430. FirstName = item.Name,
  10431. OldName = "",
  10432. Pinyin = item.Pinyin,
  10433. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10434. Marriage = 0,
  10435. Phone = item.Phone,
  10436. Job = item.Job,
  10437. BirthDay = dateTime
  10438. };
  10439. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10440. if (clientId1 > 0) clientId = clientId1;
  10441. }
  10442. else clientId = clientInfo.Id;
  10443. }
  10444. if (clientId < 1)
  10445. {
  10446. continue;
  10447. }
  10448. int airType = 0;
  10449. if (item.AirType == "超经舱") airType = 459;
  10450. else if (item.AirType == "公务舱") airType = 458;
  10451. else if (item.AirType == "经济舱") airType = 460;
  10452. else if (item.AirType == "其他") airType = 565;
  10453. else if (item.AirType == "头等舱") airType = 457;
  10454. var _TourClientListEntity = new Grp_TourClientList()
  10455. {
  10456. DiId = item.Diid,
  10457. ClientId = clientId,
  10458. CreateUserId = item.OPer,
  10459. CreateTime = Convert.ToDateTime(data11),
  10460. Remark = item.Remark,
  10461. IsDel = item.Isdel,
  10462. ShippingSpaceTypeId = airType,
  10463. ShippingSpaceSpecialNeeds = item.AirRemark,
  10464. HotelSpecialNeeds = item.RoomType
  10465. };
  10466. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10467. if (_TourClientList > 0)
  10468. {
  10469. updateCount++;
  10470. }
  10471. }
  10472. _sqlSugar.CommitTran();
  10473. }
  10474. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10475. }
  10476. catch (Exception ex)
  10477. {
  10478. _sqlSugar.RollbackTran();
  10479. return Ok(JsonView(false, ex.Message));
  10480. }
  10481. return Ok(JsonView(true));
  10482. }
  10483. private bool IsValidDate(string dateString, string format)
  10484. {
  10485. DateTime dateValue;
  10486. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10487. return valid;
  10488. }
  10489. /// <summary>
  10490. /// 接团客户名单
  10491. /// 根据团组Id查询List
  10492. /// </summary>
  10493. /// <param name="dto"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10498. {
  10499. #region 参数验证
  10500. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10501. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10502. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10503. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10504. #region 页面操作权限验证
  10505. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10506. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10507. #endregion
  10508. #endregion
  10509. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10510. if (viewData.Code != 0)
  10511. {
  10512. return Ok(JsonView(false, viewData.Msg));
  10513. }
  10514. return Ok(JsonView(viewData.Data));
  10515. }
  10516. /// <summary>
  10517. /// 接团客户名单
  10518. /// 基础数据 Init
  10519. /// </summary>
  10520. /// <param name="_dto"></param>
  10521. /// <returns></returns>
  10522. [HttpPost]
  10523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10524. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10525. {
  10526. #region 参数验证
  10527. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10528. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10529. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10530. #region 页面操作权限验证
  10531. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10532. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10533. #endregion
  10534. #endregion
  10535. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10536. if (viewData.Code != 0)
  10537. {
  10538. return Ok(JsonView(false, viewData.Msg));
  10539. }
  10540. return Ok(JsonView(viewData.Data));
  10541. }
  10542. /// <summary>
  10543. /// 接团客户名单
  10544. /// 根据 Id查询 Details
  10545. /// </summary>
  10546. /// <param name="_dto"></param>
  10547. /// <returns></returns>
  10548. [HttpPost]
  10549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10550. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10551. {
  10552. #region 参数验证
  10553. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10554. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10555. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10556. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10557. #region 页面操作权限验证
  10558. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10559. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10560. #endregion
  10561. #endregion
  10562. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10563. if (viewData.Code != 0)
  10564. {
  10565. return Ok(JsonView(false, viewData.Msg));
  10566. }
  10567. return Ok(JsonView(viewData.Data));
  10568. }
  10569. /// <summary>
  10570. /// 接团客户名单
  10571. /// Add Or Edit
  10572. /// </summary>
  10573. /// <param name="_dto"></param>
  10574. /// <returns></returns>
  10575. [HttpPost]
  10576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10578. {
  10579. #region 参数验证
  10580. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10581. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10582. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10583. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10584. #region 页面操作权限验证
  10585. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10586. if (_dto.Id == 0) //添加
  10587. {
  10588. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10589. }
  10590. else if (_dto.Id >= 0) //修改
  10591. {
  10592. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10593. }
  10594. #endregion
  10595. #endregion
  10596. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10597. if (viewData.Code != 0)
  10598. {
  10599. return Ok(JsonView(false, viewData.Msg));
  10600. }
  10601. return Ok(JsonView(true));
  10602. }
  10603. /// <summary>
  10604. /// 接团客户名单
  10605. /// AddMultiple(添加多个)
  10606. /// </summary>
  10607. /// <param name="_dto"></param>
  10608. /// <returns></returns>
  10609. [HttpPost]
  10610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10611. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10612. {
  10613. #region 参数验证
  10614. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10615. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10616. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10617. #region 页面操作权限验证
  10618. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10619. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10620. #endregion
  10621. #endregion
  10622. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10623. if (viewData.Code != 0)
  10624. {
  10625. return Ok(JsonView(false, viewData.Msg));
  10626. }
  10627. return Ok(JsonView(true));
  10628. }
  10629. /// <summary>
  10630. /// 接团客户名单
  10631. /// Del
  10632. /// </summary>
  10633. /// <param name="_dto"></param>
  10634. /// <returns></returns>
  10635. [HttpPost]
  10636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10637. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10638. {
  10639. #region 参数验证
  10640. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10641. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10642. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10643. #region 页面操作权限验证
  10644. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10645. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10646. #endregion
  10647. #endregion
  10648. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10649. if (viewData.Code != 0)
  10650. {
  10651. return Ok(JsonView(false, viewData.Msg));
  10652. }
  10653. return Ok(JsonView(true));
  10654. }
  10655. /// <summary>
  10656. /// 接团客户名单
  10657. /// 文件下载 客户名单
  10658. /// </summary>
  10659. /// <param name="_dto"></param>
  10660. /// <returns></returns>
  10661. [HttpPost]
  10662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10663. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10664. {
  10665. #region 参数验证
  10666. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10667. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10668. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10669. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10670. #region 页面操作权限验证
  10671. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10672. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10673. #endregion
  10674. #endregion
  10675. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10676. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10677. From Grp_TourClientList tcl
  10678. Left Join
  10679. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10680. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10681. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10682. From Crm_DeleClient dc
  10683. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10684. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10685. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10686. Where dc.IsDel = 0) temp
  10687. On temp.DcId =tcl.ClientId
  10688. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10689. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10690. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10691. //载入模板
  10692. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10693. if (_dto.Language == 1)
  10694. {
  10695. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10696. }
  10697. //载入模板
  10698. var doc = new Document(tempPath);
  10699. DocumentBuilder builder = new DocumentBuilder(doc);
  10700. //获取word里所有表格
  10701. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10702. //获取所填表格的序数
  10703. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10704. var rowStart = tableOne.Rows[0]; //获取第1行
  10705. if (_dto.Language == 0)
  10706. {
  10707. //循环赋值
  10708. for (int i = 0; i < DcList.Count; i++)
  10709. {
  10710. builder.MoveToCell(0, i + 1, 0, 0);
  10711. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10712. builder.MoveToCell(0, i + 1, 1, 0);
  10713. int sex = DcList[i].Sex;
  10714. string sexStr = string.Empty;
  10715. if (sex == 0) sexStr = "男";
  10716. else if (sex == 1) sexStr = "女";
  10717. else sexStr = "未设置";
  10718. builder.Write(sexStr);
  10719. builder.MoveToCell(0, i + 1, 2, 0);
  10720. string birthDay = DcList[i].BirthDay;
  10721. string birthDayStr = string.Empty;
  10722. if (!string.IsNullOrEmpty(birthDay))
  10723. {
  10724. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10725. }
  10726. builder.Write(birthDayStr);
  10727. builder.MoveToCell(0, i + 1, 3, 0);
  10728. string company = "";
  10729. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10730. {
  10731. company = DcList[i].CompanyFullName.ToString();
  10732. }
  10733. builder.Write(company);
  10734. builder.MoveToCell(0, i + 1, 4, 0);
  10735. builder.Write(DcList[i].Job);
  10736. }
  10737. }
  10738. else if (_dto.Language == 1)
  10739. {
  10740. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10741. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10742. //循环赋值
  10743. for (int i = 0; i < DcList.Count; i++)
  10744. {
  10745. string PYName = "";
  10746. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10747. {
  10748. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10749. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10750. PYName = PY_First + " " + PY_Last;
  10751. }
  10752. else
  10753. {
  10754. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10755. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10756. PYName = PY_First + " " + PY_Last;
  10757. }
  10758. builder.MoveToCell(0, i + 1, 0, 0);
  10759. builder.Write(PYName);
  10760. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10761. builder.MoveToCell(0, i + 1, 1, 0);
  10762. builder.Write(sex);
  10763. DateTime birthDt;
  10764. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10765. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10766. builder.MoveToCell(0, i + 1, 2, 0);
  10767. builder.Write(birthday);
  10768. string company = "";
  10769. try
  10770. {
  10771. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10772. {
  10773. //查询对照表
  10774. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10775. if (tempCec != null)
  10776. {
  10777. company = tempCec.enName;
  10778. }
  10779. //翻译
  10780. else
  10781. {
  10782. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10783. }
  10784. }
  10785. }
  10786. catch (Exception)
  10787. {
  10788. }
  10789. builder.MoveToCell(0, i + 1, 3, 0);
  10790. builder.Write(company);
  10791. string job = "";
  10792. try
  10793. {
  10794. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10795. {
  10796. //查询对照表
  10797. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10798. if (tempPec != null)
  10799. {
  10800. job = tempPec.enName;
  10801. }
  10802. //翻译
  10803. else
  10804. {
  10805. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10806. }
  10807. }
  10808. }
  10809. catch (Exception ex)
  10810. {
  10811. }
  10812. builder.MoveToCell(0, i + 1, 4, 0);
  10813. builder.Write(job);
  10814. }
  10815. }
  10816. //删除多余行
  10817. while (tableOne.Rows.Count > DcList.Count + 1)
  10818. {
  10819. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10820. }
  10821. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10822. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10823. doc.Save(fileDir);
  10824. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10825. return Ok(JsonView(true, "操作成功!", Url));
  10826. }
  10827. #endregion
  10828. #region 团组倒推表
  10829. /// <summary>
  10830. /// 倒推表基础数据
  10831. /// Init
  10832. /// </summary>
  10833. /// <param name="dto"></param>
  10834. /// <returns></returns>
  10835. [HttpPost]
  10836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10837. public async Task<IActionResult> PostInvertedListInit()
  10838. {
  10839. var viewData = await _invertedListRep._Init();
  10840. if (viewData.Code != 0)
  10841. {
  10842. return Ok(JsonView(false, viewData.Msg));
  10843. }
  10844. return Ok(JsonView(viewData.Data));
  10845. }
  10846. /// <summary>
  10847. /// 倒推表
  10848. /// Info
  10849. /// </summary>
  10850. /// <param name="dto"></param>
  10851. /// <returns></returns>
  10852. [HttpPost]
  10853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10854. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10855. {
  10856. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10857. if (viewData.Code != 0)
  10858. {
  10859. return Ok(JsonView(false, viewData.Msg));
  10860. }
  10861. return Ok(JsonView(viewData.Data));
  10862. }
  10863. /// <summary>
  10864. /// 倒推表
  10865. /// Create
  10866. /// </summary>
  10867. /// <param name="dto"></param>
  10868. /// <returns></returns>
  10869. [HttpPost]
  10870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10871. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10872. {
  10873. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10874. if (viewData.Code != 0)
  10875. {
  10876. return Ok(JsonView(false, viewData.Msg));
  10877. }
  10878. return Ok(JsonView(viewData.Data));
  10879. }
  10880. /// <summary>
  10881. /// 倒推表
  10882. /// Update
  10883. /// </summary>
  10884. /// <param name="dto"></param>
  10885. /// <returns></returns>
  10886. [HttpPost]
  10887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10888. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10889. {
  10890. var viewData = await _invertedListRep._Update(dto);
  10891. if (viewData.Code != 0)
  10892. {
  10893. return Ok(JsonView(false, viewData.Msg));
  10894. }
  10895. return Ok(JsonView(viewData.Data));
  10896. }
  10897. /// <summary>
  10898. /// 倒推表
  10899. /// File Download
  10900. /// </summary>
  10901. /// <param name="dto"></param>
  10902. /// <returns></returns>
  10903. [HttpPost]
  10904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10905. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10906. {
  10907. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10908. if (info2.Code != 0)
  10909. {
  10910. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10911. }
  10912. var info1 = info2.Data as InvertedListInfoView;
  10913. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10914. string teamName = "";
  10915. if (info != null) teamName = info.TeamName;
  10916. //载入模板
  10917. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10918. DocumentBuilder builder = new DocumentBuilder(doc);
  10919. //利用键值对存放数据
  10920. Dictionary<string, string> dic = new Dictionary<string, string>();
  10921. dic.Add("TeamName", teamName);
  10922. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10923. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10924. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10925. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10926. dic.Add("SQRemark", info1.ApprovalRemark);
  10927. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10928. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10929. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10930. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10931. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10932. dic.Add("QZRemark", info1.VisaInformationRemark);
  10933. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10934. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10935. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10936. dic.Add("CQRemark", info1.IssueVisaRemark);
  10937. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10938. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10939. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10940. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10941. #region 填充word模板书签内容
  10942. foreach (var key in dic.Keys)
  10943. {
  10944. builder.MoveToBookmark(key);
  10945. builder.Write(dic[key]);
  10946. }
  10947. #endregion
  10948. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10949. string fileName = $"{teamName}团出行准备流程表.doc";
  10950. string filePath = fileDir + $@"InvertedList/{fileName}";
  10951. doc.Save(filePath);
  10952. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10953. return Ok(JsonView(true, "操作成功!", Url));
  10954. }
  10955. #endregion
  10956. #region 三公签证费用(签证费、代办费)
  10957. /// <summary>
  10958. /// 三公签证费用(签证费、代办费)
  10959. /// List
  10960. /// </summary>
  10961. /// <returns></returns>
  10962. [HttpPost]
  10963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10964. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10965. {
  10966. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10967. if (_view.Code != 0)
  10968. {
  10969. return Ok(JsonView(false, _view.Msg));
  10970. }
  10971. return Ok(JsonView(true, "操作成功!", _view.Data));
  10972. }
  10973. /// <summary>
  10974. /// 三公签证费用(签证费、代办费)
  10975. /// Add Or Update
  10976. /// </summary>
  10977. /// <returns></returns>
  10978. [HttpPost]
  10979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10980. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10981. {
  10982. var _view = await _visaFeeInfoRep._Update(_dto);
  10983. if (_view.Code != 0)
  10984. {
  10985. return Ok(JsonView(false, _view.Msg));
  10986. }
  10987. return Ok(JsonView(true, _view.Msg));
  10988. }
  10989. #endregion
  10990. #region 酒店询价
  10991. /// <summary>
  10992. /// 酒店询价
  10993. /// Init
  10994. /// </summary>
  10995. /// <param name="dto"></param>
  10996. /// <returns></returns>
  10997. [HttpPost]
  10998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10999. public async Task<IActionResult> PostHotelInquiryInit()
  11000. {
  11001. var res = await _hotelInquiryRep._Init();
  11002. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11003. return Ok(JsonView(true, res.Msg, res.Data));
  11004. }
  11005. /// <summary>
  11006. /// 酒店询价
  11007. /// page Item
  11008. /// </summary>
  11009. /// <param name="_dto"></param>
  11010. /// <returns></returns>
  11011. [HttpPost]
  11012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11013. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11014. {
  11015. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex,_dto.PageSize,_dto.PortType,_dto.DiId);
  11016. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11017. var view = res.Data as PageDataViewBase;
  11018. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11019. }
  11020. /// <summary>
  11021. /// 酒店询价
  11022. /// info
  11023. /// </summary>
  11024. /// <param name="_dto"></param>
  11025. /// <returns></returns>
  11026. [HttpPost]
  11027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11028. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11029. {
  11030. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11031. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11032. return Ok(JsonView(true, res.Msg, res.Data));
  11033. }
  11034. /// <summary>
  11035. /// 酒店询价
  11036. /// Add Or Edit
  11037. /// </summary>
  11038. /// <param name="_dto"></param>
  11039. /// <returns></returns>
  11040. [HttpPost]
  11041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11042. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11043. {
  11044. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11045. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11046. return Ok(JsonView(true, res.Msg, res.Data));
  11047. }
  11048. /// <summary>
  11049. /// 酒店询价
  11050. /// Del
  11051. /// </summary>
  11052. /// <param name="_dto"></param>
  11053. /// <returns></returns>
  11054. [HttpPost]
  11055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11056. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11057. {
  11058. var res = await _hotelInquiryRep._Del(_dto.Id,_dto.DeleteUserId);
  11059. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11060. return Ok(JsonView(true, res.Msg, res.Data));
  11061. }
  11062. #endregion
  11063. // /// <summary>
  11064. // ///
  11065. // /// </summary>
  11066. // /// <param name="_dto"></param>
  11067. // /// <returns></returns>
  11068. // [HttpPost]
  11069. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11070. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11071. // {
  11072. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11073. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11074. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11075. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11076. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11077. // dic_psg.Add("客人", 974);
  11078. // dic_psg.Add("司机", 975);
  11079. // dic_psg.Add("导游", 976);
  11080. // dic_psg.Add("公司内部人员", 977);
  11081. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11082. // foreach (var item in list_visa)
  11083. // {
  11084. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11085. // temp.Id = item.Id;
  11086. // temp.DIId = item.DIId;
  11087. // temp.VisaClient = item.VisaClient;
  11088. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11089. // temp.VisaCurrency = item.VisaCurrency;
  11090. // temp.IsThird = item.IsThird;
  11091. // if (dic_psg.ContainsKey(item.PassengerType))
  11092. // {
  11093. // temp.PassengerType = dic_psg[item.PassengerType];
  11094. // }
  11095. // else {
  11096. // temp.PassengerType = -1;
  11097. // }
  11098. // temp.VisaNumber = item.VisaNumber;
  11099. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11100. // temp.CreateUserId = item.Operators;
  11101. // DateTime dt_ct;
  11102. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11103. // if (b_ct)
  11104. // {
  11105. // temp.CreateTime = dt_ct;
  11106. // }
  11107. // else
  11108. // {
  11109. // temp.CreateTime = DateTime.Now;
  11110. // }
  11111. // temp.DeleteTime = "";
  11112. // temp.DeleteUserId = 0;
  11113. // temp.Remark = item.Remark;
  11114. // if (string.IsNullOrEmpty(temp.Remark)) {
  11115. // temp.Remark = "";
  11116. // }
  11117. // temp.IsDel = item.IsDel;
  11118. // temp.VisaDescription = item.VisaAttachment;
  11119. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11120. //([Id]
  11121. // ,[DIId]
  11122. // ,[VisaClient]
  11123. // ,[VisaPrice]
  11124. // ,[VisaCurrency]
  11125. // ,[IsThird]
  11126. // ,[PassengerType]
  11127. // ,[VisaNumber]
  11128. // ,[VisaFreeNumber]
  11129. // ,[CreateUserId]
  11130. // ,[CreateTime]
  11131. // ,[DeleteTime]
  11132. // ,[DeleteUserId]
  11133. // ,[Remark]
  11134. // ,[IsDel]
  11135. // ,[visaDescription])
  11136. // VALUES
  11137. // ({0},{1},'{2}',{3},{4}
  11138. //,{5},{6},{7},{8},{9}
  11139. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11140. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11141. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11142. //);
  11143. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11144. // }
  11145. // return Ok(JsonView(true, "操作成功!"));
  11146. // }
  11147. /// <summary>
  11148. /// 123132123
  11149. /// </summary>
  11150. /// <param name="_dto"></param>
  11151. /// <returns></returns>
  11152. [HttpPost]
  11153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11154. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11155. {
  11156. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11157. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11158. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11159. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11160. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11161. dicDetail.Add(789, 1034);
  11162. dicDetail.Add(790, 1035);
  11163. dicDetail.Add(791, 1036);
  11164. dicDetail.Add(792, 1037);
  11165. dicDetail.Add(793, 1038);
  11166. dicDetail.Add(794, 1039);
  11167. dicDetail.Add(795, 1040);
  11168. dicDetail.Add(796, 1041);
  11169. dicDetail.Add(797, 1042);
  11170. dicDetail.Add(798, 1043);
  11171. dicDetail.Add(801, 1044);
  11172. dicDetail.Add(802, 1045);
  11173. dicDetail.Add(803, 1046);
  11174. Dictionary<int, int> dic = new Dictionary<int, int>();
  11175. dic.Add(806, 1027);
  11176. dic.Add(807, 1028);
  11177. dic.Add(808, 1029);
  11178. dic.Add(809, 1030);
  11179. dic.Add(810, 1031);
  11180. dic.Add(811, 1032);
  11181. dic.Add(812, 1033);
  11182. foreach (var item in list_visa)
  11183. {
  11184. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11185. temp.Coefficient = item.coefficient;
  11186. DateTime dtCrt;
  11187. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11188. if (b1)
  11189. {
  11190. temp.CreateTime = dtCrt;
  11191. }
  11192. else
  11193. {
  11194. temp.CreateTime = DateTime.Now;
  11195. }
  11196. temp.CreateUserId = item.Operators;
  11197. temp.DeleteTime = "";
  11198. temp.DeleteUserId = 0;
  11199. temp.DiId = int.Parse(item.DIID);
  11200. temp.FilePath = item.FilePath;
  11201. temp.IsDel = item.IsDel;
  11202. temp.Price = item.Price;
  11203. temp.PriceCount = 1;
  11204. temp.PriceCurrency = item.Currency;
  11205. int detailId = 0;
  11206. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11207. {
  11208. detailId = dicDetail[item.PriceTypeDetail];
  11209. }
  11210. temp.PriceDetailType = detailId;
  11211. temp.PriceDt = DateTime.Now;
  11212. temp.PriceName = item.PriceName;
  11213. temp.PriceSum = item.Price;
  11214. int tid = 0;
  11215. if (dic.ContainsKey(item.PriceType))
  11216. {
  11217. tid = dic[item.PriceType];
  11218. }
  11219. temp.PriceType = tid;
  11220. temp.Remark = item.Remark;
  11221. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11222. }
  11223. return Ok(JsonView(true, "操作成功!"));
  11224. }
  11225. }
  11226. }