GroupsController.cs 417 KB

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